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

Sub-match placeholder type, used to create named captures in static regexes. More...

#include <regex_primitives.hpp>

Inheritance diagram for boost::xpressive::mark_tag:
Collaboration diagram for boost::xpressive::mark_tag:

Public Member Functions

 mark_tag (int mark_nbr)
 Initialize a mark_tag placeholder. More...
 
 operator detail::basic_mark_tag const & () const
 INTERNAL ONLY. More...
 

Detailed Description

Sub-match placeholder type, used to create named captures in static regexes.

mark_tag is the type of the global sub-match placeholders s0, s1, etc.. You can use the mark_tag type to create your own sub-match placeholders with more meaningful names. This is roughly equivalent to the "named capture" feature of dynamic regular expressions.

To create a named sub-match placeholder, initialize it with a unique integer. The integer must only be unique within the regex in which the placeholder is used. Then you can use it within static regexes to created sub-matches by assigning a sub-expression to it, or to refer back to already created sub-matches.

mark_tag number(1); // "number" is now equivalent to "s1"
// Match a number, followed by a space and the same number again
sregex rx = (number = +_d) >> ' ' >> number;

After a successful regex_match() or regex_search(), the sub-match placeholder can be used to index into the match_results<> object to retrieve the corresponding sub-match.

Constructor & Destructor Documentation

boost::xpressive::mark_tag::mark_tag ( int  mark_nbr)
inline

Initialize a mark_tag placeholder.

Parameters
mark_nbrAn integer that uniquely identifies this mark_tag within the static regexes in which this mark_tag will be used.
Precondition
mark_nbr > 0

References BOOST_ASSERT.

Member Function Documentation

boost::xpressive::mark_tag::operator detail::basic_mark_tag const & ( ) const
inline

INTERNAL ONLY.


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