Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::xpressive::match_results< BidiIter > Struct Template Reference

Class template match_results<> holds the results of a regex_match() or a regex_search() as a collection of sub_match objects. More...

#include <xpressive_fwd.hpp>

Public Types

typedef iterator_value
< BidiIter >::type 
char_type
 
typedef detail::string_type
< char_type >::type 
string_type
 
typedef std::size_t size_type
 
typedef sub_match< BidiIter > value_type
 
typedef iterator_difference
< BidiIter >::type 
difference_type
 
typedef value_type const & reference
 
typedef value_type const & const_reference
 
typedef
detail::sub_match_vector
< BidiIter >::iterator 
iterator
 
typedef
detail::sub_match_vector
< BidiIter >::const_iterator 
const_iterator
 
typedef detail::nested_results
< BidiIter > 
nested_results_type
 

Public Member Functions

 match_results ()
 
 match_results (match_results< BidiIter > const &that)
 
 ~match_results ()
 
match_results< BidiIter > & operator= (match_results< BidiIter > const &that)
 
size_type size () const
 Returns one plus the number of marked sub-expressions in the regular expression that was matched if *this represents the result of a successful match. More...
 
bool empty () const
 Returns size() == 0. More...
 
difference_type length (size_type sub=0) const
 Returns (*this)[sub].length(). More...
 
difference_type position (size_type sub=0) const
 If !(*this)[sub].matched then returns -1. More...
 
string_type str (size_type sub=0) const
 Returns (*this)[sub].str(). More...
 
template<typename Sub >
const_reference operator[] (Sub const &sub) const
 Returns a reference to the sub_match object representing the sequence that matched marked sub-expression sub. More...
 
const_reference prefix () const
 Returns a reference to the sub_match object representing the character sequence from the start of the string being matched/searched, to the start of the match found. More...
 
const_reference suffix () const
 Returns a reference to the sub_match object representing the character sequence from the end of the match found to the end of the string being matched/searched. More...
 
const_iterator begin () const
 Returns a starting iterator that enumerates over all the marked sub-expression matches stored in *this. More...
 
const_iterator end () const
 Returns a terminating iterator that enumerates over all the marked sub-expression matches stored in *this. More...
 
 operator bool_type () const
 Returns a true value if (*this)[0].matched, else returns a false value. More...
 
bool operator! () const
 Returns true if empty() || !(*this)[0].matched, else returns false. More...
 
regex_id_type regex_id () const
 Returns the id of the basic_regex object most recently used with this match_results object. More...
 
nested_results_type const & nested_results () const
 Returns a Sequence of nested match_results elements. More...
 
template<typename Format , typename OutputIterator >
OutputIterator format (OutputIterator out, Format const &fmt, regex_constants::match_flag_type flags=regex_constants::format_default, typename disable_if< detail::is_char_ptr< Format > >::type *=0) const
 If Format models ForwardRange or is a null-terminated string, this function copies the character sequence in fmt to OutputIterator out. More...
 
template<typename OutputIterator >
OutputIterator format (OutputIterator out, char_type const *fmt, regex_constants::match_flag_type flags=regex_constants::format_default) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
template<typename Format , typename OutputIterator >
string_type format (Format const &fmt, regex_constants::match_flag_type flags=regex_constants::format_default, typename disable_if< detail::is_char_ptr< Format > >::type *=0) const
 If Format models ForwardRange or is a null-terminated string, this function returns a copy of the character sequence fmt. More...
 
string_type format (char_type const *fmt, regex_constants::match_flag_type flags=regex_constants::format_default) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void swap (match_results< BidiIter > &that)
 Swaps the contents of two match_results objects. More...
 
template<typename Arg >
match_results< BidiIter > & let (Arg const &arg)
 TODO document me. More...
 
match_results< BidiIter > const & operator() (regex_id_type regex_id, size_type index=0) const
 INTERNAL ONLY. More...
 
match_results< BidiIter > const & operator() (basic_regex< BidiIter > const &rex, std::size_t index=0) const
 INTERNAL ONLY. More...
 

Friends

struct detail::core_access< BidiIter >
 

Detailed Description

template<typename BidiIter>
struct boost::xpressive::match_results< BidiIter >

Class template match_results<> holds the results of a regex_match() or a regex_search() as a collection of sub_match objects.

Class template match_results<> denotes a collection of sequences representing the result of a regular expression match. Storage for the collection is allocated and freed as necessary by the member functions of class match_results<>.

The class template match_results<> conforms to the requirements of a Sequence, as specified in (lib.sequence.reqmts), except that only operations defined for const-qualified Sequences are supported.

Member Typedef Documentation

template<typename BidiIter>
typedef iterator_value<BidiIter>::type boost::xpressive::match_results< BidiIter >::char_type
template<typename BidiIter>
typedef detail::sub_match_vector<BidiIter>::const_iterator boost::xpressive::match_results< BidiIter >::const_iterator
template<typename BidiIter>
typedef value_type const& boost::xpressive::match_results< BidiIter >::const_reference
template<typename BidiIter>
typedef iterator_difference<BidiIter>::type boost::xpressive::match_results< BidiIter >::difference_type
template<typename BidiIter>
typedef detail::sub_match_vector<BidiIter>::iterator boost::xpressive::match_results< BidiIter >::iterator
template<typename BidiIter>
typedef detail::nested_results<BidiIter> boost::xpressive::match_results< BidiIter >::nested_results_type
template<typename BidiIter>
typedef value_type const& boost::xpressive::match_results< BidiIter >::reference
template<typename BidiIter>
typedef std::size_t boost::xpressive::match_results< BidiIter >::size_type
template<typename BidiIter>
typedef detail::string_type<char_type>::type boost::xpressive::match_results< BidiIter >::string_type
template<typename BidiIter>
typedef sub_match<BidiIter> boost::xpressive::match_results< BidiIter >::value_type

Constructor & Destructor Documentation

template<typename BidiIter>
boost::xpressive::match_results< BidiIter >::match_results ( )
inline
Postcondition
regex_id() == 0
size() == 0
empty() == true
str() == string_type()
template<typename BidiIter>
boost::xpressive::match_results< BidiIter >::match_results ( match_results< BidiIter > const &  that)
inline
Parameters
thatThe match_results object to copy
Postcondition
regex_id() == that.regex_id().
size() == that.size().
empty() == that.empty().
str(n) == that.str(n) for all positive integers n < that.size().
prefix() == that.prefix().
suffix() == that.suffix().
(*this)[n] == that[n] for all positive integers n < that.size().
length(n) == that.length(n) for all positive integers n < that.size().
position(n) == that.position(n) for all positive integers n < that.size().

References std::fill(), boost::xpressive::match_results< BidiIter >::size(), and boost::xpressive::detail::results_extras< BidiIter >::sub_match_stack_.

template<typename BidiIter>
boost::xpressive::match_results< BidiIter >::~match_results ( )
inline

Member Function Documentation

template<typename BidiIter>
const_iterator boost::xpressive::match_results< BidiIter >::begin ( void  ) const
inline

Returns a starting iterator that enumerates over all the marked sub-expression matches stored in *this.

Referenced by boost::xpressive::match_results< BidiIter >::operator()().

template<typename BidiIter>
const_iterator boost::xpressive::match_results< BidiIter >::end ( void  ) const
inline

Returns a terminating iterator that enumerates over all the marked sub-expression matches stored in *this.

Referenced by boost::xpressive::match_results< BidiIter >::operator()().

template<typename BidiIter>
template<typename Format , typename OutputIterator >
OutputIterator boost::xpressive::match_results< BidiIter >::format ( OutputIterator  out,
Format const &  fmt,
regex_constants::match_flag_type  flags = regex_constants::format_default,
typename disable_if< detail::is_char_ptr< Format > >::type = 0 
) const
inline

If Format models ForwardRange or is a null-terminated string, this function copies the character sequence in fmt to OutputIterator out.

For each format specifier or escape sequence in fmt, replace that sequence with either the character(s) it represents, or the sequence within *this to which it refers. The bitmasks specified in flags determines what format specifiers or escape sequences are recognized. By default, this is the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part 5.4.11 String.prototype.replace.

Otherwise, if Format models Callable<match_results<BidiIter>, OutputIterator, regex_constants::match_flag_type>, this function returns fmt(*this, out, flags).

Otherwise, if Format models Callable<match_results<BidiIter>, OutputIterator>, this function returns fmt(*this, out).

Otherwise, if Format models Callable<match_results<BidiIter> >, this function returns std::copy(x.begin(), x.end(), out), where x is the result of calling fmt(*this).

References boost::python::detail::arity().

Referenced by boost::xpressive::match_results< BidiIter >::format(), and boost::xpressive::detail::regex_replace_impl().

template<typename BidiIter>
template<typename OutputIterator >
OutputIterator boost::xpressive::match_results< BidiIter >::format ( OutputIterator  out,
char_type const *  fmt,
regex_constants::match_flag_type  flags = regex_constants::format_default 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References boost::as_literal().

template<typename BidiIter>
template<typename Format , typename OutputIterator >
string_type boost::xpressive::match_results< BidiIter >::format ( Format const &  fmt,
regex_constants::match_flag_type  flags = regex_constants::format_default,
typename disable_if< detail::is_char_ptr< Format > >::type = 0 
) const
inline

If Format models ForwardRange or is a null-terminated string, this function returns a copy of the character sequence fmt.

For each format specifier or escape sequence in fmt, replace that sequence with either the character(s) it represents, or the sequence within *this to which it refers. The bitmasks specified in flags determines what format specifiers or escape sequences are recognized. By default this is the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part 5.4.11 String.prototype.replace.

Otherwise, if Format models Callable<match_results<BidiIter>, OutputIterator, regex_constants::match_flag_type>, this function returns a string_type object x populated by calling fmt(*this, out, flags), where out is a back_insert_iterator into x.

Otherwise, if Format models Callable<match_results<BidiIter>, OutputIterator>, this function returns a string_type object x populated by calling fmt(*this, out), where out is a back_insert_iterator into x.

Otherwise, if Format models Callable<match_results<BidiIter> >, this function returns fmt(*this).

References boost::xpressive::match_results< BidiIter >::format().

template<typename BidiIter>
string_type boost::xpressive::match_results< BidiIter >::format ( char_type const *  fmt,
regex_constants::match_flag_type  flags = regex_constants::format_default 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

References boost::xpressive::match_results< BidiIter >::format().

template<typename BidiIter>
difference_type boost::xpressive::match_results< BidiIter >::length ( size_type  sub = 0) const
inline
template<typename BidiIter>
template<typename Arg >
match_results<BidiIter>& boost::xpressive::match_results< BidiIter >::let ( Arg const &  arg)
inline
template<typename BidiIter>
nested_results_type const& boost::xpressive::match_results< BidiIter >::nested_results ( ) const
inline

Returns a Sequence of nested match_results elements.

template<typename BidiIter>
boost::xpressive::match_results< BidiIter >::operator bool_type ( ) const
inline

Returns a true value if (*this)[0].matched, else returns a false value.

References boost::xpressive::match_results< BidiIter >::empty(), and boost::xpressive::matched.

template<typename BidiIter>
bool boost::xpressive::match_results< BidiIter >::operator! ( ) const
inline

Returns true if empty() || !(*this)[0].matched, else returns false.

References boost::xpressive::match_results< BidiIter >::empty().

template<typename BidiIter>
match_results<BidiIter> const& boost::xpressive::match_results< BidiIter >::operator() ( regex_id_type  regex_id,
size_type  index = 0 
) const
inline
template<typename BidiIter>
match_results<BidiIter> const& boost::xpressive::match_results< BidiIter >::operator() ( basic_regex< BidiIter > const &  rex,
std::size_t  index = 0 
) const
inline
template<typename BidiIter>
match_results<BidiIter>& boost::xpressive::match_results< BidiIter >::operator= ( match_results< BidiIter > const &  that)
inline
Parameters
thatThe match_results object to copy.
Postcondition
regex_id() == that.regex_id().
size() == that.size().
empty() == that.empty().
str(n) == that.str(n) for all positive integers n < that.size().
prefix() == that.prefix().
suffix() == that.suffix().
(*this)[n] == that[n] for all positive integers n < that.size().
length(n) == that.length(n) for all positive integers n < that.size().
position(n) == that.position(n) for all positive integers n < that.size().

References boost::xpressive::match_results< BidiIter >::swap().

template<typename BidiIter>
template<typename Sub >
const_reference boost::xpressive::match_results< BidiIter >::operator[] ( Sub const &  sub) const
inline

Returns a reference to the sub_match object representing the sequence that matched marked sub-expression sub.

If sub == 0 then returns a reference to a sub_match object representing the sequence that matched the whole regular expression. If sub >= size() then returns a sub_match object representing an unmatched sub-expression.

template<typename BidiIter>
difference_type boost::xpressive::match_results< BidiIter >::position ( size_type  sub = 0) const
inline

If !(*this)[sub].matched then returns -1.

Otherwise returns std::distance(base, (*this)[sub].first), where base is the start iterator of the sequence that was searched. [Note - unless this is part of a repeated search with a regex_iterator then base is the same as prefix().first - end note]

References boost::fusion::distance(), boost::xpressive::first, and boost::numeric::interval_lib::sub().

template<typename BidiIter>
const_reference boost::xpressive::match_results< BidiIter >::prefix ( ) const
inline

Returns a reference to the sub_match object representing the character sequence from the start of the string being matched/searched, to the start of the match found.

Precondition
(*this)[0].matched is true
template<typename BidiIter>
regex_id_type boost::xpressive::match_results< BidiIter >::regex_id ( ) const
inline

Returns the id of the basic_regex object most recently used with this match_results object.

Referenced by boost::xpressive::regex_id_filter_predicate< BidiIter >::operator()().

template<typename BidiIter>
size_type boost::xpressive::match_results< BidiIter >::size ( void  ) const
inline

Returns one plus the number of marked sub-expressions in the regular expression that was matched if *this represents the result of a successful match.

Otherwise returns 0.

Referenced by boost::xpressive::match_results< BidiIter >::empty(), and boost::xpressive::match_results< BidiIter >::match_results().

template<typename BidiIter>
string_type boost::xpressive::match_results< BidiIter >::str ( size_type  sub = 0) const
inline

Returns (*this)[sub].str().

References boost::numeric::interval_lib::sub().

template<typename BidiIter>
const_reference boost::xpressive::match_results< BidiIter >::suffix ( ) const
inline

Returns a reference to the sub_match object representing the character sequence from the end of the match found to the end of the string being matched/searched.

Precondition
(*this)[0].matched is true
template<typename BidiIter>
void boost::xpressive::match_results< BidiIter >::swap ( match_results< BidiIter > &  that)
inline

Swaps the contents of two match_results objects.

Guaranteed not to throw.

Parameters
thatThe match_results object to swap with.
Postcondition
*this contains the sequence of matched sub-expressions that were in that, that contains the sequence of matched sub-expressions that were in *this.
Exceptions
nothrow

References boost::intrusive_ptr< T >::swap(), boost::swap(), and boost::optional< T >::swap().

Referenced by boost::xpressive::match_results< BidiIter >::operator=().

Friends And Related Function Documentation

template<typename BidiIter>
friend struct detail::core_access< BidiIter >
friend

The documentation for this struct was generated from the following file: