Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Struct template sub_match

boost::xpressive::sub_match — Class template sub_match denotes the sequence of characters matched by a particular marked sub-expression.

Synopsis

// In header: <boost/xpressive/sub_match.hpp>

template<typename BidiIter> 
struct sub_match : public std::pair< BidiIter, BidiIter > {
  // types
  typedef iterator_value< BidiIter >::type      value_type;     
  typedef iterator_difference< BidiIter >::type difference_type;
  typedef unspecified                           string_type;    
  typedef BidiIter                              iterator;       

  // construct/copy/destruct
  sub_match();
  sub_match(BidiIter, BidiIter, bool = false);

  // public member functions
  string_type str() const;
  operator string_type() const;
  difference_type length() const;
  operator bool_type() const;
  bool operator!() const;
  int compare(string_type const &) const;
  int compare(sub_match const &) const;
  int compare(value_type const *) const;

  // public data members
  bool matched;  // true if this sub-match participated in the full match. 
};

Description

When the marked sub-expression denoted by an object of type sub_match<> participated in a regular expression match then member matched evaluates to true, and members first and second denote the range of characters [first,second) which formed that match. Otherwise matched is false, and members first and second contained undefined values.

If an object of type sub_match<> represents sub-expression 0 - that is to say the whole match - then member matched is always true, unless a partial match was obtained as a result of the flag match_partial being passed to a regular expression algorithm, in which case member matched is false, and members first and second represent the character range that formed the partial match.

sub_match public construct/copy/destruct

  1. sub_match();
  2. sub_match(BidiIter first, BidiIter second, bool matched_ = false);

sub_match public member functions

  1. string_type str() const;
  2. operator string_type() const;
  3. difference_type length() const;
  4. operator bool_type() const;
  5. bool operator!() const;
  6. int compare(string_type const & str) const;
    Performs a lexicographic string comparison.

    Parameters:

    str

    the string against which to compare

    Returns:

    the results of (*this).str().compare(str)

  7. int compare(sub_match const & sub) const;

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

  8. int compare(value_type const * ptr) const;

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


PrevUpHomeNext