mirror of
https://github.com/boostorg/regex.git
synced 2025-07-12 20:06:38 +02:00
Added new experimental captures support.
[SVN r21243]
This commit is contained in:
250
doc/Attic/captures.html
Normal file
250
doc/Attic/captures.html
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Boost.Regex: Index</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<P>
|
||||||
|
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
||||||
|
<TR>
|
||||||
|
<td valign="top" width="300">
|
||||||
|
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
|
||||||
|
</td>
|
||||||
|
<TD width="353">
|
||||||
|
<H1 align="center">Boost.Regex</H1>
|
||||||
|
<H2 align="center">Understanding Captures</H2>
|
||||||
|
</TD>
|
||||||
|
<td width="50">
|
||||||
|
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
|
||||||
|
</td>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
</P>
|
||||||
|
<HR>
|
||||||
|
<p></p>
|
||||||
|
<H2>Marked sub-expressions</H2>
|
||||||
|
<P>Every time a Perl regular expression contains a parenthesis group (), it spits
|
||||||
|
out an extra field, known as a marked sub-expression, for example the
|
||||||
|
expression:</P>
|
||||||
|
<PRE>(\w+)\W+(\w+)</PRE>
|
||||||
|
<P>
|
||||||
|
Has two marked sub-expressions (known as $1 and $2 respectively), in addition
|
||||||
|
the complete match is known as $&, everything before the first match as $`,
|
||||||
|
and everything after the match as $'. So if the above expression is
|
||||||
|
searched for within "@abc def--", then we obtain:</P>
|
||||||
|
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
|
||||||
|
<P>
|
||||||
|
<TABLE id="Table2" cellSpacing="1" cellPadding="1" width="300" border="0">
|
||||||
|
<TR>
|
||||||
|
<TD>
|
||||||
|
<P dir="ltr" style="MARGIN-RIGHT: 0px">$`</P>
|
||||||
|
</TD>
|
||||||
|
<TD>"@"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$&</TD>
|
||||||
|
<TD>"abc def"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$1</TD>
|
||||||
|
<TD>"abc"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$2</TD>
|
||||||
|
<TD>"def"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$'</TD>
|
||||||
|
<TD>"--"</TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
</P>
|
||||||
|
</BLOCKQUOTE>
|
||||||
|
<P>In Boost.regex all these are accessible via the <A href="match_results.html">match_results</A>
|
||||||
|
class that gets filled in when calling one of the matching algorithms (<A href="regex_search.html">regex_search</A>,
|
||||||
|
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).
|
||||||
|
So given:</P>
|
||||||
|
<PRE>boost::match_results<IteratorType> m;</PRE>
|
||||||
|
<P>The Perl and Boost.Regex equivalents are as follows:</P>
|
||||||
|
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
|
||||||
|
<P>
|
||||||
|
<TABLE id="Table3" cellSpacing="1" cellPadding="1" width="300" border="0">
|
||||||
|
<TR>
|
||||||
|
<TD><STRONG>Perl</STRONG></TD>
|
||||||
|
<TD><STRONG>Boost.Regex</STRONG></TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$`</TD>
|
||||||
|
<TD>m.prefix()</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$&</TD>
|
||||||
|
<TD>m[0]</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$n</TD>
|
||||||
|
<TD>m[n]</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$'</TD>
|
||||||
|
<TD>m.suffix()</TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
</P>
|
||||||
|
</BLOCKQUOTE>
|
||||||
|
<P>
|
||||||
|
<P>In Boost.Regex each sub-expression match is represented by a <A href="sub_match.html">
|
||||||
|
sub_match</A> object, this is basically just a pair of iterators denoting
|
||||||
|
the start and end possition of the sub-expression match, but there are some
|
||||||
|
additional operators provided so that objects of type sub_match behave a lot
|
||||||
|
like a std::basic_string: for example they are implicitly <A href="sub_match.html#m3">
|
||||||
|
convertible to a basic_string</A>, they can be <A href="sub_match.html#o21">compared
|
||||||
|
to a string</A>, <A href="sub_match.html#o81">added to a string</A>, or <A href="sub_match.html#oi">
|
||||||
|
streamed out to an output stream</A>.</P>
|
||||||
|
<H2>Unmatched Sub-Expressions</H2>
|
||||||
|
<P>When a regular expression match is found there is no need for all of the marked
|
||||||
|
sub-expressions to have participated in the match, for example the expression:</P>
|
||||||
|
<P>(abc)|(def)</P>
|
||||||
|
<P>can match either $1 or $2, but never both at the same time. In
|
||||||
|
Boost.Regex you can determine which sub-expressions matched by accessing the <A href="sub_match.html#m1">
|
||||||
|
sub_match::matched</A> data member.</P>
|
||||||
|
<H2>Repeated Captures</H2>
|
||||||
|
<P>When a marked sub-expression is repeated, then the sub-expression gets
|
||||||
|
"captured" multiple times, however normally only the final capture is
|
||||||
|
available, for example if</P>
|
||||||
|
<PRE>(?:(\w+)\W+)+</PRE>
|
||||||
|
<P>is matched against</P>
|
||||||
|
<PRE>one fine day</PRE>
|
||||||
|
<P>Then $1 will contain the string "day", and all the previous captures will have
|
||||||
|
been forgotten.</P>
|
||||||
|
<P>However, Boost.Regex has an experimental feature that allows all the capture
|
||||||
|
information to be retained - this is accessed either via the <A href="match_results.html#m17">
|
||||||
|
match_results::captures</A> member function or the <A href="sub_match.html#m8">sub_match::captures</A>
|
||||||
|
member function. These functions return a container that contains a
|
||||||
|
sequence of all the captures obtained during the regular expression
|
||||||
|
matching. The following example program shows how this information may be
|
||||||
|
used:</P>
|
||||||
|
<PRE>#include <boost/regex.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
void print_captures(const std::string& regx, const std::string& text)
|
||||||
|
{
|
||||||
|
boost::regex e(regx);
|
||||||
|
boost::smatch what;
|
||||||
|
std::cout << "Expression: \"" << regx << "\"\n";
|
||||||
|
std::cout << "Text: \"" << text << "\"\n";
|
||||||
|
if(boost::regex_match(text, what, e, boost::match_extra))
|
||||||
|
{
|
||||||
|
unsigned i, j;
|
||||||
|
std::cout << "** Match found **\n Sub-Expressions:\n";
|
||||||
|
for(i = 0; i < what.size(); ++i)
|
||||||
|
std::cout << " $" << i << " = \"" << what[i] << "\"\n";
|
||||||
|
std::cout << " Captures:\n";
|
||||||
|
for(i = 0; i < what.size(); ++i)
|
||||||
|
{
|
||||||
|
std::cout << " $" << i << " = {";
|
||||||
|
for(j = 0; j < what.captures(i).size(); ++j)
|
||||||
|
{
|
||||||
|
if(j)
|
||||||
|
std::cout << ", ";
|
||||||
|
else
|
||||||
|
std::cout << " ";
|
||||||
|
std::cout << "\"" << what.captures(i)[j] << "\"";
|
||||||
|
}
|
||||||
|
std::cout << " }\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "** No Match found **\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int , char* [])
|
||||||
|
{
|
||||||
|
print_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee");
|
||||||
|
print_captures("(.*)bar|(.*)bah", "abcbar");
|
||||||
|
print_captures("(.*)bar|(.*)bah", "abcbah");
|
||||||
|
print_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party");
|
||||||
|
return 0;
|
||||||
|
}</PRE>
|
||||||
|
<P>Which produces the following output:</P>
|
||||||
|
<PRE>Expression: "(([[:lower:]]+)|([[:upper:]]+))+"
|
||||||
|
Text: "aBBcccDDDDDeeeeeeee"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "aBBcccDDDDDeeeeeeee"
|
||||||
|
$1 = "eeeeeeee"
|
||||||
|
$2 = "eeeeeeee"
|
||||||
|
$3 = "DDDDD"
|
||||||
|
Captures:
|
||||||
|
$0 = { "aBBcccDDDDDeeeeeeee" }
|
||||||
|
$1 = { "a", "BB", "ccc", "DDDDD", "eeeeeeee" }
|
||||||
|
$2 = { "a", "ccc", "eeeeeeee" }
|
||||||
|
$3 = { "BB", "DDDDD" }
|
||||||
|
Expression: "(.*)bar|(.*)bah"
|
||||||
|
Text: "abcbar"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "abcbar"
|
||||||
|
$1 = "abc"
|
||||||
|
$2 = ""
|
||||||
|
Captures:
|
||||||
|
$0 = { "abcbar" }
|
||||||
|
$1 = { "abc" }
|
||||||
|
$2 = { }
|
||||||
|
Expression: "(.*)bar|(.*)bah"
|
||||||
|
Text: "abcbah"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "abcbah"
|
||||||
|
$1 = ""
|
||||||
|
$2 = "abc"
|
||||||
|
Captures:
|
||||||
|
$0 = { "abcbah" }
|
||||||
|
$1 = { }
|
||||||
|
$2 = { "abc" }
|
||||||
|
Expression: "^(?:(\w+)|(?>\W+))*$"
|
||||||
|
Text: "now is the time for all good men to come to the aid of the party"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "now is the time for all good men to come to the aid of the party"
|
||||||
|
$1 = "party"
|
||||||
|
Captures:
|
||||||
|
$0 = { "now is the time for all good men to come to the aid of the party" }
|
||||||
|
$1 = { "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" }
|
||||||
|
</PRE>
|
||||||
|
<P>Unfortunately enabling this feature has an impact on performance (even if you
|
||||||
|
don't use it), and a much bigger impact if you do use it, therefore to use this
|
||||||
|
feature you need to:</P>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
Define BOOST_REGEX_MATCH_EXTRA for all translation units including the library
|
||||||
|
source (the best way to do this is to uncomment this define in <A href="../../../boost/regex/user.hpp">
|
||||||
|
boost/regex/user.hpp</A>
|
||||||
|
and then rebuild everything.
|
||||||
|
<LI>
|
||||||
|
Pass the <A href="match_flag_type.html">match_extra flag</A> to the particular
|
||||||
|
algorithms where you actually need the captures information (<A href="regex_search.html">regex_search</A>,
|
||||||
|
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).
|
||||||
|
</LI>
|
||||||
|
</UL>
|
||||||
|
<P>
|
||||||
|
<HR>
|
||||||
|
<P></P>
|
||||||
|
<P></P>
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||||
|
12 Dec 2003
|
||||||
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
|
<p><i><EFBFBD> Copyright John Maddock
|
||||||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -46,6 +46,7 @@ static const match_flag_type match_any;
|
|||||||
static const match_flag_type match_not_null;
|
static const match_flag_type match_not_null;
|
||||||
static const match_flag_type match_continuous;
|
static const match_flag_type match_continuous;
|
||||||
static const match_flag_type match_partial;
|
static const match_flag_type match_partial;
|
||||||
|
static const match_flag_type match_single_line;
|
||||||
static const match_flag_type match_prev_avail;
|
static const match_flag_type match_prev_avail;
|
||||||
static const match_flag_type match_not_dot_newline;
|
static const match_flag_type match_not_dot_newline;
|
||||||
static const match_flag_type match_not_dot_null;
|
static const match_flag_type match_not_dot_null;
|
||||||
@ -167,6 +168,20 @@ static const match_flag_type format_all;
|
|||||||
in a full match.</p>
|
in a full match.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<TR>
|
||||||
|
<TD vAlign="top" width="50%">match_extra</TD>
|
||||||
|
<TD vAlign="top" width="50%">Instructs the matching engine to retain all available <A href="captures.html">
|
||||||
|
capture</A> information; if a capturing group is repeated then information
|
||||||
|
about every repeat is available via <A href="match_results.html#m17">match_results::captures()</A>
|
||||||
|
or <A href="sub_match.html#m8">sub_match_captures().</A></TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD vAlign="top" width="50%">match_single_line</TD>
|
||||||
|
<TD vAlign="top" width="50%">Equivalent to Perl's s/ modifier; prevents ^ from
|
||||||
|
matching after an embedded newline character (so that it only matches at the
|
||||||
|
start of the text being matched), and $ from matching before an embedded
|
||||||
|
newline (so that it only matches at the end of the text being matched).</TD>
|
||||||
|
</TR>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td valign="top" width="50%">
|
||||||
<p>match_prev_avail</p>
|
<p>match_prev_avail</p>
|
||||||
@ -259,8 +274,7 @@ static const match_flag_type format_all;
|
|||||||
24 Oct 2003
|
24 Oct 2003
|
||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
<p><i><EFBFBD> Copyright John Maddock 1998-
|
<p><i><EFBFBD> Copyright John Maddock 1998-
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
|
||||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
|
@ -2,23 +2,22 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Boost.Regex: class match_results</title>
|
<title>Boost.Regex: class match_results</title>
|
||||||
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
<meta content="HTML Tidy, see www.w3.org" name="generator">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<p></p>
|
<p></p>
|
||||||
<table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">
|
<table id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<td vAlign="top" width="300">
|
||||||
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
|
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
<td width="353">
|
<td width="353">
|
||||||
<h1 align="center">Boost.Regex</h1>
|
<h1 align="center">Boost.Regex</h1>
|
||||||
<h2 align="center">class match_results</h2>
|
<h2 align="center">class match_results</h2>
|
||||||
</td>
|
</td>
|
||||||
<td width="50">
|
<td width="50">
|
||||||
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
|
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -27,23 +26,23 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<h3>Contents</h3>
|
<h3>Contents</h3>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a></dt>
|
<dt><A href="#synopsis">Synopsis</A> <dt><A href="#description">Description</A> </dt>
|
||||||
</dl>
|
</dl>
|
||||||
<h3><a name="synopsis"></a>Synopsis</h3>
|
<h3><a name="synopsis"></a>Synopsis</h3>
|
||||||
<p>#include <<a href="../../../boost/regex.hpp">boost/regex.hpp</a>></p>
|
<p>#include <<A href="../../../boost/regex.hpp">boost/regex.hpp</A>></p>
|
||||||
<p>Regular expressions are different from many simple pattern-matching algorithms
|
<p>Regular expressions are different from many simple pattern-matching algorithms
|
||||||
in that as well as finding an overall match they can also produce
|
in that as well as finding an overall match they can also produce
|
||||||
sub-expression matches: each sub-expression being delimited in the pattern by a
|
sub-expression matches: each sub-expression being delimited in the pattern by a
|
||||||
pair of parenthesis (...). There has to be some method for reporting
|
pair of parenthesis (...). There has to be some method for reporting
|
||||||
sub-expression matches back to the user: this is achieved this by defining a
|
sub-expression matches back to the user: this is achieved this by defining a
|
||||||
class <i>match_results</i> that acts as an indexed collection of sub-expression
|
class <i>match_results</i> that acts as an indexed collection of sub-expression
|
||||||
matches, each sub-expression match being contained in an object of type <i><a href="sub_match.html">
|
matches, each sub-expression match being contained in an object of type <i><A href="sub_match.html">
|
||||||
sub_match</a></i> .</p>
|
sub_match</A></i> .</p>
|
||||||
<p>Template class match_results denotes a collection of character sequences
|
<p>Template class match_results denotes a collection of character sequences
|
||||||
representing the result of a regular expression match. Objects of type
|
representing the result of a regular expression match. Objects of type
|
||||||
match_results are passed to the algorithms <a href="regex_match.html">regex_match</a>
|
match_results are passed to the algorithms <A href="regex_match.html">regex_match</A>
|
||||||
and <a href="regex_search.html">regex_search</a>, and are returned by the
|
and <A href="regex_search.html">regex_search</A>, and are returned by the
|
||||||
iterator <a href="regex_iterator.html">regex_iterator</a> . Storage for
|
iterator <A href="regex_iterator.html">regex_iterator</A> . Storage for
|
||||||
the collection is allocated and freed as necessary by the member functions of
|
the collection is allocated and freed as necessary by the member functions of
|
||||||
class match_results.</p>
|
class match_results.</p>
|
||||||
<p>The template class match_results conforms to the requirements of a Sequence, as
|
<p>The template class match_results conforms to the requirements of a Sequence, as
|
||||||
@ -51,8 +50,7 @@
|
|||||||
const-qualified Sequences are supported.</p>
|
const-qualified Sequences are supported.</p>
|
||||||
<p>Class template match_results is most commonly used as one of the typedefs
|
<p>Class template match_results is most commonly used as one of the typedefs
|
||||||
cmatch, wcmatch, smatch, or wsmatch:</p>
|
cmatch, wcmatch, smatch, or wsmatch:</p>
|
||||||
<pre>
|
<pre>template <class BidirectionalIterator,
|
||||||
template <class BidirectionalIterator,
|
|
||||||
class Allocator = allocator<sub_match<BidirectionalIterator> >
|
class Allocator = allocator<sub_match<BidirectionalIterator> >
|
||||||
class match_results;
|
class match_results;
|
||||||
|
|
||||||
@ -108,6 +106,12 @@ public:
|
|||||||
|
|
||||||
allocator_type <A href="#m14" >get_allocator</A>() const;
|
allocator_type <A href="#m14" >get_allocator</A>() const;
|
||||||
void <A href="#m15" >swap</A>(match_results& that);
|
void <A href="#m15" >swap</A>(match_results& that);
|
||||||
|
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
typedef typename value_type::capture_sequence_type <A href="#m16" >capture_sequence_type</A>;
|
||||||
|
const capture_sequence_type& <A href="#m17" >captures</A>(std::size_t i)const;
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class BidirectionalIterator, class Allocator>
|
template <class BidirectionalIterator, class Allocator>
|
||||||
@ -139,42 +143,41 @@ match_results(const Allocator& a = Allocator());
|
|||||||
of this function are indicated in the table:</p>
|
of this function are indicated in the table:</p>
|
||||||
<p align="center"></p>
|
<p align="center"></p>
|
||||||
<center>
|
<center>
|
||||||
<table id="Table2" cellspacing="1" cellpadding="7" width="624" border="1">
|
<table id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Element</b></p>
|
<p><b>Element</b></p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Value</b></p>
|
<p><b>Value</b></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>empty()</p>
|
<p>empty()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>true</p>
|
<p>true</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>size()</p>
|
<p>size()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>0</p>
|
<p>0</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>str()</p>
|
<p>str()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>basic_string<charT>()</p>
|
<p>basic_string<charT>()</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody></table>
|
||||||
</table>
|
|
||||||
</center>
|
</center>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<pre><A name=c2></A>
|
<pre><A name=c2></A>
|
||||||
@ -190,82 +193,81 @@ match_results& operator=(const match_results& m);
|
|||||||
indicated in the table:</p>
|
indicated in the table:</p>
|
||||||
<p align="center"></p>
|
<p align="center"></p>
|
||||||
<center>
|
<center>
|
||||||
<table id="Table3" cellspacing="1" cellpadding="7" width="624" border="1">
|
<table id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Element</b></p>
|
<p><b>Element</b></p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Value</b></p>
|
<p><b>Value</b></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>empty()</p>
|
<p>empty()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.empty().</p>
|
<p>m.empty().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>size()</p>
|
<p>size()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.size().</p>
|
<p>m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>str(n)</p>
|
<p>str(n)</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.str(n) for all integers n < m.size().</p>
|
<p>m.str(n) for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>prefix()</p>
|
<p>prefix()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.prefix().</p>
|
<p>m.prefix().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>suffix()</p>
|
<p>suffix()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.suffix().</p>
|
<p>m.suffix().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>(*this)[n]</p>
|
<p>(*this)[n]</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m[n] for all integers n < m.size().</p>
|
<p>m[n] for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>length(n)</p>
|
<p>length(n)</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.length(n) for all integers n < m.size().</p>
|
<p>m.length(n) for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>position(n)</p>
|
<p>position(n)</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.position(n) for all integers n < m.size().</p>
|
<p>m.position(n) for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody></table>
|
||||||
</table>
|
|
||||||
</center>
|
</center>
|
||||||
<h4>match_results size</h4>
|
<h4>match_results size</h4>
|
||||||
<pre><A name=m1></A>
|
<pre><A name=m1></A>
|
||||||
@ -342,11 +344,10 @@ const_iterator end()const;
|
|||||||
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
|
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
|
||||||
marked sub-expression matches stored in *this.</p>
|
marked sub-expression matches stored in *this.</p>
|
||||||
<h4><A name="format"></A>match_results reformatting</h4>
|
<h4><A name="format"></A>match_results reformatting</h4>
|
||||||
<pre><A name=m12></A>
|
<pre>template <class OutputIterator>
|
||||||
template <class OutputIterator>
|
|
||||||
OutputIterator format(OutputIterator out,
|
OutputIterator format(OutputIterator out,
|
||||||
const string_type& fmt,
|
const string_type& fmt,
|
||||||
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
|
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
||||||
</pre>
|
</pre>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Requires:</b> The type OutputIterator conforms to the Output Iterator
|
<p><b>Requires:</b> The type OutputIterator conforms to the Output Iterator
|
||||||
@ -356,34 +357,34 @@ OutputIterator format(OutputIterator out,
|
|||||||
OutputIterator <i>out</i>. For each format specifier or escape sequence in <i>fmt</i>,
|
OutputIterator <i>out</i>. For each format specifier or escape sequence in <i>fmt</i>,
|
||||||
replace that sequence with either the character(s) it represents, or the
|
replace that sequence with either the character(s) it represents, or the
|
||||||
sequence of characters within *this to which it refers. The bitmasks specified
|
sequence of characters within *this to which it refers. The bitmasks specified
|
||||||
in <i><a href="match_flag_type.html">flags</a></i> determines what <a href="format_syntax.html">
|
in <i><A href="match_flag_type.html">flags</A></i> determines what <A href="format_syntax.html">
|
||||||
format specifiers or escape sequences are recognized</a>, by default this is
|
format specifiers or escape sequences are recognized</A>, by default this is
|
||||||
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
|
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
|
||||||
5.4.11 String.prototype.replace.</p>
|
5.4.11 String.prototype.replace.</p>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Returns:</b> <i>out</i>.</p>
|
<p><b>Returns:</b> <i>out</i>.</p>
|
||||||
<pre><A name=m13></A>
|
<pre><A name=m13></A>
|
||||||
string_type format(const string_type& fmt,
|
string_type format(const string_type& fmt,
|
||||||
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
|
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
||||||
</pre>
|
</pre>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Effects:</b> Returns a copy of the string <i>fmt</i>. For each format
|
<p><b>Effects:</b> Returns a copy of the string <i>fmt</i>. For each format
|
||||||
specifier or escape sequence in <i>fmt</i>, replace that sequence with either
|
specifier or escape sequence in <i>fmt</i>, replace that sequence with either
|
||||||
the character(s) it represents, or the sequence of characters within *this to
|
the character(s) it represents, or the sequence of characters within *this to
|
||||||
which it refers. The bitmasks specified in <i><a href="match_flag_type.html">flags</a></i>
|
which it refers. The bitmasks specified in <i><A href="match_flag_type.html">flags</A></i>
|
||||||
determines what <a href="format_syntax.html">format specifiers or escape sequences
|
determines what <A href="format_syntax.html">format specifiers or escape sequences
|
||||||
are recognized</a>, by default this is the format used by ECMA-262,
|
are recognized</A>, by default this is the format used by ECMA-262,
|
||||||
ECMAScript Language Specification, Chapter 15 part 5.4.11
|
ECMAScript Language Specification, Chapter 15 part 5.4.11
|
||||||
String.prototype.replace.</p>
|
String.prototype.replace.</p>
|
||||||
<pre><A name=m14></A>
|
<H4>Allocator access</H4>
|
||||||
allocator_type get_allocator()const;
|
<pre>allocator_type get_allocator()const;
|
||||||
</pre>
|
</pre>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Effects:</b> Returns a copy of the Allocator that was passed to the object's
|
<p><b>Effects:</b> Returns a copy of the Allocator that was passed to the object's
|
||||||
constructor.</p>
|
constructor.</p>
|
||||||
<pre><A name=m15></A>
|
<H4><A name="m15"></A>Swap</H4>
|
||||||
void swap(match_results& that);
|
<PRE>void swap(match_results& that);
|
||||||
</pre>
|
</PRE>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
|
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
|
||||||
<b></b>
|
<b></b>
|
||||||
@ -392,6 +393,36 @@ void swap(match_results& that);
|
|||||||
sequence of matched sub-expressions that were in <code>*this</code>.</p>
|
sequence of matched sub-expressions that were in <code>*this</code>.</p>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Complexity:</b> constant time.</p>
|
<p><b>Complexity:</b> constant time.</p>
|
||||||
|
<H4>Captures</H4>
|
||||||
|
<PRE><A name=m16></A>typedef typename value_type::capture_sequence_type capture_sequence_type;</PRE>
|
||||||
|
<P>Defines an implementation-specific type that satisfies the requirements of
|
||||||
|
a standard library Sequence (21.1.1 including the optional Table 68
|
||||||
|
operations), whose value_type is a <EM>sub_match<BidirectionalIterator></EM>. This
|
||||||
|
type happens to be <EM>std::vector<sub_match<BidirectionalIterator> ></EM>,
|
||||||
|
but you shouldn't actually rely on that.</P>
|
||||||
|
<PRE><A name=m17></A>const capture_sequence_type& <A href="#m8" >captures</A>(std::size_t i)const; </PRE>
|
||||||
|
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
|
||||||
|
obtained for sub-expression <EM>i</EM>.</P>
|
||||||
|
<P><STRONG>Returns:</STRONG> <code>(*this)[i].captures();</code></P>
|
||||||
|
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
|
||||||
|
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
|
||||||
|
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
|
||||||
|
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
|
||||||
|
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
|
||||||
|
this member function to be defined and return useful information.</P>
|
||||||
|
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
|
||||||
|
</P>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
sub_match occupies more memory resulting in complex expressions running out of
|
||||||
|
memory or stack space more quickly during matching.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are less efficient at handling some features
|
||||||
|
(independent sub-expressions for example), even when match_extra is not used.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are much less efficient (i.e. slower), when match_extra
|
||||||
|
is used. Mostly this is down to the extra memory allocations that have to
|
||||||
|
take place.</LI></UL>
|
||||||
<h4>match_results non-members</h4>
|
<h4>match_results non-members</h4>
|
||||||
<PRE><A name=n1></A>template <class BidirectionalIterator, class Allocator>
|
<PRE><A name=n1></A>template <class BidirectionalIterator, class Allocator>
|
||||||
bool operator == (const match_results<BidirectionalIterator, Allocator>& m1,
|
bool operator == (const match_results<BidirectionalIterator, Allocator>& m1,
|
||||||
@ -418,10 +449,10 @@ void swap(match_results<BidirectionalIterator, Allocator>& m1,
|
|||||||
24 Oct 2003
|
24 Oct 2003
|
||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
<p><i><EFBFBD> Copyright John Maddock 1998-
|
<p><i><EFBFBD> Copyright John Maddock 1998-
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
|
||||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -3,21 +3,20 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>Boost.Regex: sub_match</title>
|
<title>Boost.Regex: sub_match</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<P>
|
<P>
|
||||||
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
||||||
<TR>
|
<TR>
|
||||||
<td valign="top" width="300">
|
<td vAlign="top" width="300">
|
||||||
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
|
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
<TD width="353">
|
<TD width="353">
|
||||||
<H1 align="center">Boost.Regex</H1>
|
<H1 align="center">Boost.Regex</H1>
|
||||||
<H2 align="center">sub_match</H2>
|
<H2 align="center">sub_match</H2>
|
||||||
</TD>
|
</TD>
|
||||||
<td width="50">
|
<td width="50">
|
||||||
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
|
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
</TR>
|
</TR>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
@ -41,20 +40,28 @@
|
|||||||
<P>Objects of type <EM>sub_match</EM> may be compared to objects of type <EM>std::basic_string</EM>,
|
<P>Objects of type <EM>sub_match</EM> may be compared to objects of type <EM>std::basic_string</EM>,
|
||||||
or <EM>const charT*</EM> or <EM>const charT</EM>
|
or <EM>const charT*</EM> or <EM>const charT</EM>
|
||||||
.
|
.
|
||||||
|
<P>Objects of type <EM>sub_match</EM> may be added to objects of type <EM>std::basic_string</EM>,
|
||||||
|
or <EM>const charT* </EM>or <EM>const charT</EM>, to produce a new <EM>std::basic_string
|
||||||
|
</EM>
|
||||||
|
object.
|
||||||
<P>When the marked sub-expression denoted by an object of type sub_match<>
|
<P>When the marked sub-expression denoted by an object of type sub_match<>
|
||||||
participated in a regular expression match then member <CODE>matched</CODE> evaluates
|
participated in a regular expression match then member <CODE>matched</CODE> evaluates
|
||||||
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
|
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
|
||||||
range of characters <CODE>[first,second)</CODE> which formed that match.
|
range of characters <CODE>[first,second)</CODE> which formed that match.
|
||||||
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
|
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
|
||||||
contained undefined values.</P>
|
contained undefined values.</P>
|
||||||
|
<P>When the marked sub-expression denoted by an object of type sub_match<>
|
||||||
|
was repeated, then the sub_match object represents the match obtained by the
|
||||||
|
last repeat. The complete set of all the captures obtained for all the
|
||||||
|
repeats, may be accessed via the captures() member function (Note: this has
|
||||||
|
serious performance implications, you have to explicitly enable this feature).</P>
|
||||||
<P>If an object of type <CODE>sub_match<></CODE> represents sub-expression 0
|
<P>If an object of type <CODE>sub_match<></CODE> represents sub-expression 0
|
||||||
- that is to say the whole match - then member <CODE>matched</CODE> is always
|
- that is to say the whole match - then member <CODE>matched</CODE> is always
|
||||||
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
|
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
|
||||||
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
|
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
|
||||||
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
|
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
|
||||||
character range that formed the partial match.</P>
|
character range that formed the partial match.</P>
|
||||||
<PRE>
|
<PRE>namespace boost{
|
||||||
namespace boost{
|
|
||||||
|
|
||||||
template <class BidirectionalIterator>
|
template <class BidirectionalIterator>
|
||||||
class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator>
|
class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator>
|
||||||
@ -73,6 +80,10 @@ public:
|
|||||||
int <A href="#m5" >compare</A>(const sub_match& s)const;
|
int <A href="#m5" >compare</A>(const sub_match& s)const;
|
||||||
int <A href="#m6" >compare</A>(const basic_string<value_type>& s)const;
|
int <A href="#m6" >compare</A>(const basic_string<value_type>& s)const;
|
||||||
int <A href="#m7" >compare</A>(const value_type* s)const;
|
int <A href="#m7" >compare</A>(const value_type* s)const;
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
typedef implementation-private <A href="#m9">capture_sequence_type</A>;
|
||||||
|
const capture_sequence_type& <A href="#m8" >captures</A>()const;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
// comparisons to another sub_match:
|
// comparisons to another sub_match:
|
||||||
@ -222,32 +233,32 @@ bool <A href="#o76">operator</A> <= (const sub_match<BidirectionalIterator
|
|||||||
//
|
//
|
||||||
// addition operators:
|
// addition operators:
|
||||||
//
|
//
|
||||||
template <class RandomAccessIterator, class traits, class Allocator>
|
template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
<A href="#o81">operator</A> + (const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
<A href="#o81" >operator</A> + (const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s,
|
||||||
const sub_match<RandomAccessIterator>& m);
|
const sub_match<BidirectionalIterator>& m);
|
||||||
template <class RandomAccessIterator, class traits, class Allocator>
|
template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
<A href="#o82">operator</A> + (const sub_match<RandomAccessIterator>& m,
|
<A href="#o82" >operator</A> + (const sub_match<BidirectionalIterator>& m,
|
||||||
const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s);
|
const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s);
|
||||||
template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o83">operator</A> + (typename iterator_traits<RandomAccessIterator>::value_type const* s,
|
<A href="#o83" >operator</A> + (typename iterator_traits<BidirectionalIterator>::value_type const* s,
|
||||||
const sub_match<RandomAccessIterator>& m);
|
const sub_match<BidirectionalIterator>& m);
|
||||||
template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o84">operator</A> + (const sub_match<RandomAccessIterator>& m,
|
<A href="#o84" >operator</A> + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const * s);
|
typename iterator_traits<BidirectionalIterator>::value_type const * s);
|
||||||
template <class RandomAccessIterator>
|
template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o85">operator</A> + (typename iterator_traits<RandomAccessIterator>::value_type const& s,
|
<A href="#o85" >operator</A> + (typename iterator_traits<BidirectionalIterator>::value_type const& s,
|
||||||
const sub_match<RandomAccessIterator>& m);
|
const sub_match<BidirectionalIterator>& m);
|
||||||
template <class RandomAccessIterator>
|
template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o86">operator</A> + (const sub_match<RandomAccessIterator>& m,
|
<A href="#o86" >operator</A> + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const& s);
|
typename iterator_traits<BidirectionalIterator>::value_type const& s);
|
||||||
template <class RandomAccessIterator>
|
template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o87">operator</A> + (const sub_match<RandomAccessIterator>& m1,
|
<A href="#o87" >operator</A> + (const sub_match<BidirectionalIterator>& m1,
|
||||||
const sub_match<RandomAccessIterator>& m2);
|
const sub_match<BidirectionalIterator>& m2);
|
||||||
|
|
||||||
//
|
//
|
||||||
// stream inserter:
|
// stream inserter:
|
||||||
@ -259,8 +270,7 @@ basic_ostream<charT, traits>&
|
|||||||
|
|
||||||
} // namespace boost</PRE>
|
} // namespace boost</PRE>
|
||||||
<H3>Description</H3>
|
<H3>Description</H3>
|
||||||
<H4>
|
<H4>sub_match members</H4>
|
||||||
sub_match members</H4>
|
|
||||||
<PRE>typedef typename std::iterator_traits<iterator>::value_type value_type;</PRE>
|
<PRE>typedef typename std::iterator_traits<iterator>::value_type value_type;</PRE>
|
||||||
<P>The type pointed to by the iterators.</P>
|
<P>The type pointed to by the iterators.</P>
|
||||||
<PRE>typedef typename std::iterator_traits<iterator>::difference_type difference_type;</PRE>
|
<PRE>typedef typename std::iterator_traits<iterator>::difference_type difference_type;</PRE>
|
||||||
@ -274,12 +284,10 @@ basic_ostream<charT, traits>&
|
|||||||
<PRE><A name=m1></A>bool matched</PRE>
|
<PRE><A name=m1></A>bool matched</PRE>
|
||||||
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
|
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
|
||||||
<PRE><A name=m2></A>static difference_type length();</PRE>
|
<PRE><A name=m2></A>static difference_type length();</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
|
||||||
<B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
|
|
||||||
sub-expression was not matched: <CODE>matched ? distance(first, second) : 0)</CODE>.</P>
|
sub-expression was not matched: <CODE>matched ? distance(first, second) : 0)</CODE>.</P>
|
||||||
<PRE><A name=m3></A>operator basic_string<value_type>()const;</PRE>
|
<PRE><A name=m3></A>operator basic_string<value_type>()const;</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
|
||||||
<B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
|
|
||||||
basic_string<value_type>(first, second) :
|
basic_string<value_type>(first, second) :
|
||||||
basic_string<value_type>()).</P>
|
basic_string<value_type>()).</P>
|
||||||
</CODE><PRE><A name=m4></A>basic_string<value_type> str()const;</PRE>
|
</CODE><PRE><A name=m4></A>basic_string<value_type> str()const;</PRE>
|
||||||
@ -287,32 +295,54 @@ basic_ostream<charT, traits>&
|
|||||||
basic_string<value_type>(first, second) :
|
basic_string<value_type>(first, second) :
|
||||||
basic_string<value_type>())</CODE>.</P>
|
basic_string<value_type>())</CODE>.</P>
|
||||||
<PRE><A name=m5></A>int compare(const sub_match& s)const;</PRE>
|
<PRE><A name=m5></A>int compare(const sub_match& s)const;</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
|
||||||
<B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
|
|
||||||
<PRE><A name=m6></A>int compare(const basic_string<value_type>& s)const;</PRE>
|
<PRE><A name=m6></A>int compare(const basic_string<value_type>& s)const;</PRE>
|
||||||
<P><B>Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
|
<P><B>Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
|
||||||
<PRE><A name=m7></A>int compare(const value_type* s)const;</PRE>
|
<PRE><A name=m7></A>int compare(const value_type* s)const;</PRE>
|
||||||
<P>
|
<P><B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B> </B>returns
|
||||||
<B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B> </B>returns
|
|
||||||
<CODE>str().compare(s)</CODE>.</P>
|
<CODE>str().compare(s)</CODE>.</P>
|
||||||
<H4>
|
<PRE><A name=m9></A>typedef implementation-private capture_sequence_type;</PRE>
|
||||||
sub_match non-member operators</H4>
|
<P>Defines an implementation-specific type that satisfies the requirements of
|
||||||
|
a standard library Sequence (21.1.1 including the optional Table 68
|
||||||
|
operations), whose value_type is a <EM>sub_match<BidirectionalIterator></EM>. This
|
||||||
|
type happens to be <EM>std::vector<sub_match<BidirectionalIterator> ></EM>,
|
||||||
|
but you shouldn't actually rely on that.</P>
|
||||||
|
<PRE><A name=m8></A>const capture_sequence_type& <A href="#m8" >captures</A>()const; </PRE>
|
||||||
|
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
|
||||||
|
obtained for this sub-expression.</P>
|
||||||
|
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
|
||||||
|
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
|
||||||
|
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
|
||||||
|
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
|
||||||
|
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
|
||||||
|
this member function to be defined and return useful information.</P>
|
||||||
|
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
|
||||||
|
</P>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
sub_match occupies more memory resulting in complex expressions running out of
|
||||||
|
memory or stack space more quickly during matching.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are less efficient at handling some features
|
||||||
|
(independent sub-expressions for example), even when match_extra is not used.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are much less efficient (i.e. slower), when match_extra
|
||||||
|
is used. Mostly this is down to the extra memory allocations that have to
|
||||||
|
take place.</LI></UL>
|
||||||
|
<H4>sub_match non-member operators</H4>
|
||||||
<H5>Comparisons against self</H5>
|
<H5>Comparisons against self</H5>
|
||||||
<PRE><A name=o11></A>template <class BidirectionalIterator>
|
<PRE><A name=o11></A>template <class BidirectionalIterator>
|
||||||
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
|
|
||||||
<PRE><A name=o12></A>template <class BidirectionalIterator>
|
<PRE><A name=o12></A>template <class BidirectionalIterator>
|
||||||
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
|
|
||||||
<PRE><A name=o13></A>template <class BidirectionalIterator>
|
<PRE><A name=o13></A>template <class BidirectionalIterator>
|
||||||
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) < 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) < 0</CODE>.</P>
|
|
||||||
<PRE><A name=o14></A>template <class BidirectionalIterator>
|
<PRE><A name=o14></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
@ -320,13 +350,11 @@ bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
|||||||
<PRE><A name=o15></A>template <class BidirectionalIterator>
|
<PRE><A name=o15></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) >= 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) >= 0</CODE>.</P>
|
|
||||||
<PRE><A name=o16></A>template <class BidirectionalIterator>
|
<PRE><A name=o16></A>template <class BidirectionalIterator>
|
||||||
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) > 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) > 0</CODE>.</P>
|
|
||||||
<H5>Comparisons with std::basic_string</H5>
|
<H5>Comparisons with std::basic_string</H5>
|
||||||
<pre><A name=o21></A>
|
<pre><A name=o21></A>
|
||||||
template <class BidirectionalIterator, class traits, class Allocator>
|
template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
@ -382,159 +410,135 @@ bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
|||||||
<PRE><A name=o41></A>template <class BidirectionalIterator>
|
<PRE><A name=o41></A>template <class BidirectionalIterator>
|
||||||
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o42></A>template <class BidirectionalIterator>
|
<PRE><A name=o42></A>template <class BidirectionalIterator>
|
||||||
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
|
||||||
<PRE></A><A name=o43></A>template <class BidirectionalIterator>
|
<PRE></A><A name=o43></A>template <class BidirectionalIterator>
|
||||||
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o44></A>template <class BidirectionalIterator>
|
<PRE><A name=o44></A>template <class BidirectionalIterator>
|
||||||
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o45></A>template <class BidirectionalIterator>
|
<PRE><A name=o45></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o46></A>template <class BidirectionalIterator>
|
<PRE><A name=o46></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o51></A>template <class BidirectionalIterator>
|
<PRE><A name=o51></A>template <class BidirectionalIterator>
|
||||||
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o52></A>template <class BidirectionalIterator>
|
<PRE><A name=o52></A>template <class BidirectionalIterator>
|
||||||
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o53></A>template <class BidirectionalIterator>
|
<PRE><A name=o53></A>template <class BidirectionalIterator>
|
||||||
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o54></A>template <class BidirectionalIterator>
|
<PRE><A name=o54></A>template <class BidirectionalIterator>
|
||||||
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o55></A>template <class BidirectionalIterator>
|
<PRE><A name=o55></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o56></A>template <class BidirectionalIterator>
|
<PRE><A name=o56></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
|
||||||
<H5>Comparisons with a single character</H5>
|
<H5>Comparisons with a single character</H5>
|
||||||
<PRE><A name=o61></A>template <class BidirectionalIterator>
|
<PRE><A name=o61></A>template <class BidirectionalIterator>
|
||||||
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o62></A>template <class BidirectionalIterator>
|
<PRE><A name=o62></A>template <class BidirectionalIterator>
|
||||||
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o63></A>template <class BidirectionalIterator>
|
<PRE><A name=o63></A>template <class BidirectionalIterator>
|
||||||
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o64></A>template <class BidirectionalIterator>
|
<PRE><A name=o64></A>template <class BidirectionalIterator>
|
||||||
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o65></A>template <class BidirectionalIterator>
|
<PRE><A name=o65></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o66></A>template <class BidirectionalIterator>
|
<PRE><A name=o66></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o71></A>template <class BidirectionalIterator>
|
<PRE><A name=o71></A>template <class BidirectionalIterator>
|
||||||
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o72></A>template <class BidirectionalIterator>
|
<PRE><A name=o72></A>template <class BidirectionalIterator>
|
||||||
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o73></A>template <class BidirectionalIterator>
|
<PRE><A name=o73></A>template <class BidirectionalIterator>
|
||||||
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o74></A>template <class BidirectionalIterator>
|
<PRE><A name=o74></A>template <class BidirectionalIterator>
|
||||||
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o75></A>template <class BidirectionalIterator>
|
<PRE><A name=o75></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o76></A>template <class BidirectionalIterator>
|
<PRE><A name=o76></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
|
||||||
<h5>Addition operators</h5>
|
<h5>Addition operators</h5>
|
||||||
<P>The addition operators for sub_match allow you to add a sub_match to any type
|
<P>The addition operators for sub_match allow you to add a sub_match to any type
|
||||||
to which you can add a std::string and obtain a new string as the result.</P>
|
to which you can add a std::string and obtain a new string as the result.</P>
|
||||||
<PRE><A name=o81></A>template <class RandomAccessIterator, class traits, class Allocator>
|
<PRE><A name=o81></A>template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
operator + (const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
operator + (const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s,
|
||||||
const sub_match<RandomAccessIterator>& m); </PRE>
|
const sub_match<BidirectionalIterator>& m); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
||||||
<PRE><A name=o82></A>template <class RandomAccessIterator, class traits, class Allocator>
|
<PRE><A name=o82></A>template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m,
|
operator + (const sub_match<BidirectionalIterator>& m,
|
||||||
const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s); </PRE>
|
const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
||||||
<PRE><A name=o83></A>template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
<PRE><A name=o83></A>template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (typename iterator_traits<RandomAccessIterator>::value_type const* s,
|
operator + (typename iterator_traits<BidirectionalIterator>::value_type const* s,
|
||||||
const sub_match<RandomAccessIterator>& m); </PRE>
|
const sub_match<BidirectionalIterator>& m); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
||||||
<PRE><A name=o84></A>template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
<PRE><A name=o84></A>template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m,
|
operator + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const * s);</PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const * s);</PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
||||||
<PRE><A name=o85></A>template <class RandomAccessIterator>
|
<PRE><A name=o85></A>template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (typename iterator_traits<RandomAccessIterator>::value_type const& s,
|
operator + (typename iterator_traits<BidirectionalIterator>::value_type const& s,
|
||||||
const sub_match<RandomAccessIterator>& m); </PRE>
|
const sub_match<BidirectionalIterator>& m); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
||||||
<PRE><A name=o86></A>template <class RandomAccessIterator>
|
<PRE><A name=o86></A>template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m,
|
operator + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const& s); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& s); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
||||||
<PRE><A name=o87></A>template <class RandomAccessIterator>
|
<PRE><A name=o87></A>template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m1,
|
operator + (const sub_match<BidirectionalIterator>& m1,
|
||||||
const sub_match<RandomAccessIterator>& m2);</PRE>
|
const sub_match<BidirectionalIterator>& m2);</PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m1.str() + m2.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m1.str() + m2.str()</CODE>.</P>
|
||||||
<h5>Stream inserter</h5>
|
<h5>Stream inserter</h5>
|
||||||
<PRE><A name=oi></A>template <class charT, class traits, class BidirectionalIterator>
|
<PRE><A name=oi></A>template <class charT, class traits, class BidirectionalIterator>
|
||||||
@ -549,10 +553,10 @@ basic_ostream<charT, traits>&
|
|||||||
24 Oct 2003
|
24 Oct 2003
|
||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
<p><i><EFBFBD> Copyright John Maddock 1998-
|
<p><i><EFBFBD> Copyright John Maddock 1998-
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
|
||||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
250
doc/captures.html
Normal file
250
doc/captures.html
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Boost.Regex: Index</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
|
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<P>
|
||||||
|
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
||||||
|
<TR>
|
||||||
|
<td valign="top" width="300">
|
||||||
|
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
|
||||||
|
</td>
|
||||||
|
<TD width="353">
|
||||||
|
<H1 align="center">Boost.Regex</H1>
|
||||||
|
<H2 align="center">Understanding Captures</H2>
|
||||||
|
</TD>
|
||||||
|
<td width="50">
|
||||||
|
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
|
||||||
|
</td>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
</P>
|
||||||
|
<HR>
|
||||||
|
<p></p>
|
||||||
|
<H2>Marked sub-expressions</H2>
|
||||||
|
<P>Every time a Perl regular expression contains a parenthesis group (), it spits
|
||||||
|
out an extra field, known as a marked sub-expression, for example the
|
||||||
|
expression:</P>
|
||||||
|
<PRE>(\w+)\W+(\w+)</PRE>
|
||||||
|
<P>
|
||||||
|
Has two marked sub-expressions (known as $1 and $2 respectively), in addition
|
||||||
|
the complete match is known as $&, everything before the first match as $`,
|
||||||
|
and everything after the match as $'. So if the above expression is
|
||||||
|
searched for within "@abc def--", then we obtain:</P>
|
||||||
|
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
|
||||||
|
<P>
|
||||||
|
<TABLE id="Table2" cellSpacing="1" cellPadding="1" width="300" border="0">
|
||||||
|
<TR>
|
||||||
|
<TD>
|
||||||
|
<P dir="ltr" style="MARGIN-RIGHT: 0px">$`</P>
|
||||||
|
</TD>
|
||||||
|
<TD>"@"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$&</TD>
|
||||||
|
<TD>"abc def"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$1</TD>
|
||||||
|
<TD>"abc"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$2</TD>
|
||||||
|
<TD>"def"</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$'</TD>
|
||||||
|
<TD>"--"</TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
</P>
|
||||||
|
</BLOCKQUOTE>
|
||||||
|
<P>In Boost.regex all these are accessible via the <A href="match_results.html">match_results</A>
|
||||||
|
class that gets filled in when calling one of the matching algorithms (<A href="regex_search.html">regex_search</A>,
|
||||||
|
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).
|
||||||
|
So given:</P>
|
||||||
|
<PRE>boost::match_results<IteratorType> m;</PRE>
|
||||||
|
<P>The Perl and Boost.Regex equivalents are as follows:</P>
|
||||||
|
<BLOCKQUOTE dir="ltr" style="MARGIN-RIGHT: 0px">
|
||||||
|
<P>
|
||||||
|
<TABLE id="Table3" cellSpacing="1" cellPadding="1" width="300" border="0">
|
||||||
|
<TR>
|
||||||
|
<TD><STRONG>Perl</STRONG></TD>
|
||||||
|
<TD><STRONG>Boost.Regex</STRONG></TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$`</TD>
|
||||||
|
<TD>m.prefix()</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$&</TD>
|
||||||
|
<TD>m[0]</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$n</TD>
|
||||||
|
<TD>m[n]</TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD>$'</TD>
|
||||||
|
<TD>m.suffix()</TD>
|
||||||
|
</TR>
|
||||||
|
</TABLE>
|
||||||
|
</P>
|
||||||
|
</BLOCKQUOTE>
|
||||||
|
<P>
|
||||||
|
<P>In Boost.Regex each sub-expression match is represented by a <A href="sub_match.html">
|
||||||
|
sub_match</A> object, this is basically just a pair of iterators denoting
|
||||||
|
the start and end possition of the sub-expression match, but there are some
|
||||||
|
additional operators provided so that objects of type sub_match behave a lot
|
||||||
|
like a std::basic_string: for example they are implicitly <A href="sub_match.html#m3">
|
||||||
|
convertible to a basic_string</A>, they can be <A href="sub_match.html#o21">compared
|
||||||
|
to a string</A>, <A href="sub_match.html#o81">added to a string</A>, or <A href="sub_match.html#oi">
|
||||||
|
streamed out to an output stream</A>.</P>
|
||||||
|
<H2>Unmatched Sub-Expressions</H2>
|
||||||
|
<P>When a regular expression match is found there is no need for all of the marked
|
||||||
|
sub-expressions to have participated in the match, for example the expression:</P>
|
||||||
|
<P>(abc)|(def)</P>
|
||||||
|
<P>can match either $1 or $2, but never both at the same time. In
|
||||||
|
Boost.Regex you can determine which sub-expressions matched by accessing the <A href="sub_match.html#m1">
|
||||||
|
sub_match::matched</A> data member.</P>
|
||||||
|
<H2>Repeated Captures</H2>
|
||||||
|
<P>When a marked sub-expression is repeated, then the sub-expression gets
|
||||||
|
"captured" multiple times, however normally only the final capture is
|
||||||
|
available, for example if</P>
|
||||||
|
<PRE>(?:(\w+)\W+)+</PRE>
|
||||||
|
<P>is matched against</P>
|
||||||
|
<PRE>one fine day</PRE>
|
||||||
|
<P>Then $1 will contain the string "day", and all the previous captures will have
|
||||||
|
been forgotten.</P>
|
||||||
|
<P>However, Boost.Regex has an experimental feature that allows all the capture
|
||||||
|
information to be retained - this is accessed either via the <A href="match_results.html#m17">
|
||||||
|
match_results::captures</A> member function or the <A href="sub_match.html#m8">sub_match::captures</A>
|
||||||
|
member function. These functions return a container that contains a
|
||||||
|
sequence of all the captures obtained during the regular expression
|
||||||
|
matching. The following example program shows how this information may be
|
||||||
|
used:</P>
|
||||||
|
<PRE>#include <boost/regex.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
void print_captures(const std::string& regx, const std::string& text)
|
||||||
|
{
|
||||||
|
boost::regex e(regx);
|
||||||
|
boost::smatch what;
|
||||||
|
std::cout << "Expression: \"" << regx << "\"\n";
|
||||||
|
std::cout << "Text: \"" << text << "\"\n";
|
||||||
|
if(boost::regex_match(text, what, e, boost::match_extra))
|
||||||
|
{
|
||||||
|
unsigned i, j;
|
||||||
|
std::cout << "** Match found **\n Sub-Expressions:\n";
|
||||||
|
for(i = 0; i < what.size(); ++i)
|
||||||
|
std::cout << " $" << i << " = \"" << what[i] << "\"\n";
|
||||||
|
std::cout << " Captures:\n";
|
||||||
|
for(i = 0; i < what.size(); ++i)
|
||||||
|
{
|
||||||
|
std::cout << " $" << i << " = {";
|
||||||
|
for(j = 0; j < what.captures(i).size(); ++j)
|
||||||
|
{
|
||||||
|
if(j)
|
||||||
|
std::cout << ", ";
|
||||||
|
else
|
||||||
|
std::cout << " ";
|
||||||
|
std::cout << "\"" << what.captures(i)[j] << "\"";
|
||||||
|
}
|
||||||
|
std::cout << " }\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "** No Match found **\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int , char* [])
|
||||||
|
{
|
||||||
|
print_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee");
|
||||||
|
print_captures("(.*)bar|(.*)bah", "abcbar");
|
||||||
|
print_captures("(.*)bar|(.*)bah", "abcbah");
|
||||||
|
print_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party");
|
||||||
|
return 0;
|
||||||
|
}</PRE>
|
||||||
|
<P>Which produces the following output:</P>
|
||||||
|
<PRE>Expression: "(([[:lower:]]+)|([[:upper:]]+))+"
|
||||||
|
Text: "aBBcccDDDDDeeeeeeee"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "aBBcccDDDDDeeeeeeee"
|
||||||
|
$1 = "eeeeeeee"
|
||||||
|
$2 = "eeeeeeee"
|
||||||
|
$3 = "DDDDD"
|
||||||
|
Captures:
|
||||||
|
$0 = { "aBBcccDDDDDeeeeeeee" }
|
||||||
|
$1 = { "a", "BB", "ccc", "DDDDD", "eeeeeeee" }
|
||||||
|
$2 = { "a", "ccc", "eeeeeeee" }
|
||||||
|
$3 = { "BB", "DDDDD" }
|
||||||
|
Expression: "(.*)bar|(.*)bah"
|
||||||
|
Text: "abcbar"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "abcbar"
|
||||||
|
$1 = "abc"
|
||||||
|
$2 = ""
|
||||||
|
Captures:
|
||||||
|
$0 = { "abcbar" }
|
||||||
|
$1 = { "abc" }
|
||||||
|
$2 = { }
|
||||||
|
Expression: "(.*)bar|(.*)bah"
|
||||||
|
Text: "abcbah"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "abcbah"
|
||||||
|
$1 = ""
|
||||||
|
$2 = "abc"
|
||||||
|
Captures:
|
||||||
|
$0 = { "abcbah" }
|
||||||
|
$1 = { }
|
||||||
|
$2 = { "abc" }
|
||||||
|
Expression: "^(?:(\w+)|(?>\W+))*$"
|
||||||
|
Text: "now is the time for all good men to come to the aid of the party"
|
||||||
|
** Match found **
|
||||||
|
Sub-Expressions:
|
||||||
|
$0 = "now is the time for all good men to come to the aid of the party"
|
||||||
|
$1 = "party"
|
||||||
|
Captures:
|
||||||
|
$0 = { "now is the time for all good men to come to the aid of the party" }
|
||||||
|
$1 = { "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" }
|
||||||
|
</PRE>
|
||||||
|
<P>Unfortunately enabling this feature has an impact on performance (even if you
|
||||||
|
don't use it), and a much bigger impact if you do use it, therefore to use this
|
||||||
|
feature you need to:</P>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
Define BOOST_REGEX_MATCH_EXTRA for all translation units including the library
|
||||||
|
source (the best way to do this is to uncomment this define in <A href="../../../boost/regex/user.hpp">
|
||||||
|
boost/regex/user.hpp</A>
|
||||||
|
and then rebuild everything.
|
||||||
|
<LI>
|
||||||
|
Pass the <A href="match_flag_type.html">match_extra flag</A> to the particular
|
||||||
|
algorithms where you actually need the captures information (<A href="regex_search.html">regex_search</A>,
|
||||||
|
<A href="regex_match.html">regex_match</A>, or <A href="regex_iterator.html">regex_iterator</A>).
|
||||||
|
</LI>
|
||||||
|
</UL>
|
||||||
|
<P>
|
||||||
|
<HR>
|
||||||
|
<P></P>
|
||||||
|
<P></P>
|
||||||
|
<p>Revised
|
||||||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
||||||
|
12 Dec 2003
|
||||||
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
|
<p><i><EFBFBD> Copyright John Maddock
|
||||||
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -73,6 +73,7 @@
|
|||||||
<dt><a href="partial_matches.html">Partial matches</a></dt>
|
<dt><a href="partial_matches.html">Partial matches</a></dt>
|
||||||
<dt><a href="syntax.html">Regular Expression Syntax</a></dt>
|
<dt><a href="syntax.html">Regular Expression Syntax</a></dt>
|
||||||
<dt><a href="format_syntax.html">Format String Syntax</a></dt>
|
<dt><a href="format_syntax.html">Format String Syntax</a></dt>
|
||||||
|
<dt><a href="captures.html">Understanding Captures</a></dt>
|
||||||
</dl>
|
</dl>
|
||||||
</dd>
|
</dd>
|
||||||
<dt>Deprecated interfaces</dt>
|
<dt>Deprecated interfaces</dt>
|
||||||
|
@ -46,6 +46,7 @@ static const match_flag_type match_any;
|
|||||||
static const match_flag_type match_not_null;
|
static const match_flag_type match_not_null;
|
||||||
static const match_flag_type match_continuous;
|
static const match_flag_type match_continuous;
|
||||||
static const match_flag_type match_partial;
|
static const match_flag_type match_partial;
|
||||||
|
static const match_flag_type match_single_line;
|
||||||
static const match_flag_type match_prev_avail;
|
static const match_flag_type match_prev_avail;
|
||||||
static const match_flag_type match_not_dot_newline;
|
static const match_flag_type match_not_dot_newline;
|
||||||
static const match_flag_type match_not_dot_null;
|
static const match_flag_type match_not_dot_null;
|
||||||
@ -167,6 +168,20 @@ static const match_flag_type format_all;
|
|||||||
in a full match.</p>
|
in a full match.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<TR>
|
||||||
|
<TD vAlign="top" width="50%">match_extra</TD>
|
||||||
|
<TD vAlign="top" width="50%">Instructs the matching engine to retain all available <A href="captures.html">
|
||||||
|
capture</A> information; if a capturing group is repeated then information
|
||||||
|
about every repeat is available via <A href="match_results.html#m17">match_results::captures()</A>
|
||||||
|
or <A href="sub_match.html#m8">sub_match_captures().</A></TD>
|
||||||
|
</TR>
|
||||||
|
<TR>
|
||||||
|
<TD vAlign="top" width="50%">match_single_line</TD>
|
||||||
|
<TD vAlign="top" width="50%">Equivalent to Perl's s/ modifier; prevents ^ from
|
||||||
|
matching after an embedded newline character (so that it only matches at the
|
||||||
|
start of the text being matched), and $ from matching before an embedded
|
||||||
|
newline (so that it only matches at the end of the text being matched).</TD>
|
||||||
|
</TR>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td valign="top" width="50%">
|
||||||
<p>match_prev_avail</p>
|
<p>match_prev_avail</p>
|
||||||
@ -259,8 +274,7 @@ static const match_flag_type format_all;
|
|||||||
24 Oct 2003
|
24 Oct 2003
|
||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
<p><i><EFBFBD> Copyright John Maddock 1998-
|
<p><i><EFBFBD> Copyright John Maddock 1998-
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
|
||||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
|
@ -2,23 +2,22 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Boost.Regex: class match_results</title>
|
<title>Boost.Regex: class match_results</title>
|
||||||
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
<meta content="HTML Tidy, see www.w3.org" name="generator">
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<p></p>
|
<p></p>
|
||||||
<table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">
|
<table id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="300">
|
<td vAlign="top" width="300">
|
||||||
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
|
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
<td width="353">
|
<td width="353">
|
||||||
<h1 align="center">Boost.Regex</h1>
|
<h1 align="center">Boost.Regex</h1>
|
||||||
<h2 align="center">class match_results</h2>
|
<h2 align="center">class match_results</h2>
|
||||||
</td>
|
</td>
|
||||||
<td width="50">
|
<td width="50">
|
||||||
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
|
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -27,23 +26,23 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<h3>Contents</h3>
|
<h3>Contents</h3>
|
||||||
<dl class="index">
|
<dl class="index">
|
||||||
<dt><a href="#synopsis">Synopsis</a> <dt><a href="#description">Description</a></dt>
|
<dt><A href="#synopsis">Synopsis</A> <dt><A href="#description">Description</A> </dt>
|
||||||
</dl>
|
</dl>
|
||||||
<h3><a name="synopsis"></a>Synopsis</h3>
|
<h3><a name="synopsis"></a>Synopsis</h3>
|
||||||
<p>#include <<a href="../../../boost/regex.hpp">boost/regex.hpp</a>></p>
|
<p>#include <<A href="../../../boost/regex.hpp">boost/regex.hpp</A>></p>
|
||||||
<p>Regular expressions are different from many simple pattern-matching algorithms
|
<p>Regular expressions are different from many simple pattern-matching algorithms
|
||||||
in that as well as finding an overall match they can also produce
|
in that as well as finding an overall match they can also produce
|
||||||
sub-expression matches: each sub-expression being delimited in the pattern by a
|
sub-expression matches: each sub-expression being delimited in the pattern by a
|
||||||
pair of parenthesis (...). There has to be some method for reporting
|
pair of parenthesis (...). There has to be some method for reporting
|
||||||
sub-expression matches back to the user: this is achieved this by defining a
|
sub-expression matches back to the user: this is achieved this by defining a
|
||||||
class <i>match_results</i> that acts as an indexed collection of sub-expression
|
class <i>match_results</i> that acts as an indexed collection of sub-expression
|
||||||
matches, each sub-expression match being contained in an object of type <i><a href="sub_match.html">
|
matches, each sub-expression match being contained in an object of type <i><A href="sub_match.html">
|
||||||
sub_match</a></i> .</p>
|
sub_match</A></i> .</p>
|
||||||
<p>Template class match_results denotes a collection of character sequences
|
<p>Template class match_results denotes a collection of character sequences
|
||||||
representing the result of a regular expression match. Objects of type
|
representing the result of a regular expression match. Objects of type
|
||||||
match_results are passed to the algorithms <a href="regex_match.html">regex_match</a>
|
match_results are passed to the algorithms <A href="regex_match.html">regex_match</A>
|
||||||
and <a href="regex_search.html">regex_search</a>, and are returned by the
|
and <A href="regex_search.html">regex_search</A>, and are returned by the
|
||||||
iterator <a href="regex_iterator.html">regex_iterator</a> . Storage for
|
iterator <A href="regex_iterator.html">regex_iterator</A> . Storage for
|
||||||
the collection is allocated and freed as necessary by the member functions of
|
the collection is allocated and freed as necessary by the member functions of
|
||||||
class match_results.</p>
|
class match_results.</p>
|
||||||
<p>The template class match_results conforms to the requirements of a Sequence, as
|
<p>The template class match_results conforms to the requirements of a Sequence, as
|
||||||
@ -51,8 +50,7 @@
|
|||||||
const-qualified Sequences are supported.</p>
|
const-qualified Sequences are supported.</p>
|
||||||
<p>Class template match_results is most commonly used as one of the typedefs
|
<p>Class template match_results is most commonly used as one of the typedefs
|
||||||
cmatch, wcmatch, smatch, or wsmatch:</p>
|
cmatch, wcmatch, smatch, or wsmatch:</p>
|
||||||
<pre>
|
<pre>template <class BidirectionalIterator,
|
||||||
template <class BidirectionalIterator,
|
|
||||||
class Allocator = allocator<sub_match<BidirectionalIterator> >
|
class Allocator = allocator<sub_match<BidirectionalIterator> >
|
||||||
class match_results;
|
class match_results;
|
||||||
|
|
||||||
@ -108,6 +106,12 @@ public:
|
|||||||
|
|
||||||
allocator_type <A href="#m14" >get_allocator</A>() const;
|
allocator_type <A href="#m14" >get_allocator</A>() const;
|
||||||
void <A href="#m15" >swap</A>(match_results& that);
|
void <A href="#m15" >swap</A>(match_results& that);
|
||||||
|
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
typedef typename value_type::capture_sequence_type <A href="#m16" >capture_sequence_type</A>;
|
||||||
|
const capture_sequence_type& <A href="#m17" >captures</A>(std::size_t i)const;
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class BidirectionalIterator, class Allocator>
|
template <class BidirectionalIterator, class Allocator>
|
||||||
@ -139,42 +143,41 @@ match_results(const Allocator& a = Allocator());
|
|||||||
of this function are indicated in the table:</p>
|
of this function are indicated in the table:</p>
|
||||||
<p align="center"></p>
|
<p align="center"></p>
|
||||||
<center>
|
<center>
|
||||||
<table id="Table2" cellspacing="1" cellpadding="7" width="624" border="1">
|
<table id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Element</b></p>
|
<p><b>Element</b></p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Value</b></p>
|
<p><b>Value</b></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>empty()</p>
|
<p>empty()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>true</p>
|
<p>true</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>size()</p>
|
<p>size()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>0</p>
|
<p>0</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>str()</p>
|
<p>str()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>basic_string<charT>()</p>
|
<p>basic_string<charT>()</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody></table>
|
||||||
</table>
|
|
||||||
</center>
|
</center>
|
||||||
<p> </p>
|
<p> </p>
|
||||||
<pre><A name=c2></A>
|
<pre><A name=c2></A>
|
||||||
@ -190,82 +193,81 @@ match_results& operator=(const match_results& m);
|
|||||||
indicated in the table:</p>
|
indicated in the table:</p>
|
||||||
<p align="center"></p>
|
<p align="center"></p>
|
||||||
<center>
|
<center>
|
||||||
<table id="Table3" cellspacing="1" cellpadding="7" width="624" border="1">
|
<table id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Element</b></p>
|
<p><b>Element</b></p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%"><b></b>
|
<td vAlign="top" width="50%"><b></b>
|
||||||
<p><b>Value</b></p>
|
<p><b>Value</b></p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>empty()</p>
|
<p>empty()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.empty().</p>
|
<p>m.empty().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>size()</p>
|
<p>size()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.size().</p>
|
<p>m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>str(n)</p>
|
<p>str(n)</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.str(n) for all integers n < m.size().</p>
|
<p>m.str(n) for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>prefix()</p>
|
<p>prefix()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.prefix().</p>
|
<p>m.prefix().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>suffix()</p>
|
<p>suffix()</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.suffix().</p>
|
<p>m.suffix().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>(*this)[n]</p>
|
<p>(*this)[n]</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m[n] for all integers n < m.size().</p>
|
<p>m[n] for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>length(n)</p>
|
<p>length(n)</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.length(n) for all integers n < m.size().</p>
|
<p>m.length(n) for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>position(n)</p>
|
<p>position(n)</p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top" width="50%">
|
<td vAlign="top" width="50%">
|
||||||
<p>m.position(n) for all integers n < m.size().</p>
|
<p>m.position(n) for all integers n < m.size().</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody></table>
|
||||||
</table>
|
|
||||||
</center>
|
</center>
|
||||||
<h4>match_results size</h4>
|
<h4>match_results size</h4>
|
||||||
<pre><A name=m1></A>
|
<pre><A name=m1></A>
|
||||||
@ -342,11 +344,10 @@ const_iterator end()const;
|
|||||||
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
|
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
|
||||||
marked sub-expression matches stored in *this.</p>
|
marked sub-expression matches stored in *this.</p>
|
||||||
<h4><A name="format"></A>match_results reformatting</h4>
|
<h4><A name="format"></A>match_results reformatting</h4>
|
||||||
<pre><A name=m12></A>
|
<pre>template <class OutputIterator>
|
||||||
template <class OutputIterator>
|
|
||||||
OutputIterator format(OutputIterator out,
|
OutputIterator format(OutputIterator out,
|
||||||
const string_type& fmt,
|
const string_type& fmt,
|
||||||
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
|
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
||||||
</pre>
|
</pre>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Requires:</b> The type OutputIterator conforms to the Output Iterator
|
<p><b>Requires:</b> The type OutputIterator conforms to the Output Iterator
|
||||||
@ -356,34 +357,34 @@ OutputIterator format(OutputIterator out,
|
|||||||
OutputIterator <i>out</i>. For each format specifier or escape sequence in <i>fmt</i>,
|
OutputIterator <i>out</i>. For each format specifier or escape sequence in <i>fmt</i>,
|
||||||
replace that sequence with either the character(s) it represents, or the
|
replace that sequence with either the character(s) it represents, or the
|
||||||
sequence of characters within *this to which it refers. The bitmasks specified
|
sequence of characters within *this to which it refers. The bitmasks specified
|
||||||
in <i><a href="match_flag_type.html">flags</a></i> determines what <a href="format_syntax.html">
|
in <i><A href="match_flag_type.html">flags</A></i> determines what <A href="format_syntax.html">
|
||||||
format specifiers or escape sequences are recognized</a>, by default this is
|
format specifiers or escape sequences are recognized</A>, by default this is
|
||||||
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
|
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
|
||||||
5.4.11 String.prototype.replace.</p>
|
5.4.11 String.prototype.replace.</p>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Returns:</b> <i>out</i>.</p>
|
<p><b>Returns:</b> <i>out</i>.</p>
|
||||||
<pre><A name=m13></A>
|
<pre><A name=m13></A>
|
||||||
string_type format(const string_type& fmt,
|
string_type format(const string_type& fmt,
|
||||||
<a href="match_flag_type.html">match_flag_type</a> flags = format_default);
|
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
||||||
</pre>
|
</pre>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Effects:</b> Returns a copy of the string <i>fmt</i>. For each format
|
<p><b>Effects:</b> Returns a copy of the string <i>fmt</i>. For each format
|
||||||
specifier or escape sequence in <i>fmt</i>, replace that sequence with either
|
specifier or escape sequence in <i>fmt</i>, replace that sequence with either
|
||||||
the character(s) it represents, or the sequence of characters within *this to
|
the character(s) it represents, or the sequence of characters within *this to
|
||||||
which it refers. The bitmasks specified in <i><a href="match_flag_type.html">flags</a></i>
|
which it refers. The bitmasks specified in <i><A href="match_flag_type.html">flags</A></i>
|
||||||
determines what <a href="format_syntax.html">format specifiers or escape sequences
|
determines what <A href="format_syntax.html">format specifiers or escape sequences
|
||||||
are recognized</a>, by default this is the format used by ECMA-262,
|
are recognized</A>, by default this is the format used by ECMA-262,
|
||||||
ECMAScript Language Specification, Chapter 15 part 5.4.11
|
ECMAScript Language Specification, Chapter 15 part 5.4.11
|
||||||
String.prototype.replace.</p>
|
String.prototype.replace.</p>
|
||||||
<pre><A name=m14></A>
|
<H4>Allocator access</H4>
|
||||||
allocator_type get_allocator()const;
|
<pre>allocator_type get_allocator()const;
|
||||||
</pre>
|
</pre>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Effects:</b> Returns a copy of the Allocator that was passed to the object's
|
<p><b>Effects:</b> Returns a copy of the Allocator that was passed to the object's
|
||||||
constructor.</p>
|
constructor.</p>
|
||||||
<pre><A name=m15></A>
|
<H4><A name="m15"></A>Swap</H4>
|
||||||
void swap(match_results& that);
|
<PRE>void swap(match_results& that);
|
||||||
</pre>
|
</PRE>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
|
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
|
||||||
<b></b>
|
<b></b>
|
||||||
@ -392,6 +393,36 @@ void swap(match_results& that);
|
|||||||
sequence of matched sub-expressions that were in <code>*this</code>.</p>
|
sequence of matched sub-expressions that were in <code>*this</code>.</p>
|
||||||
<b></b>
|
<b></b>
|
||||||
<p><b>Complexity:</b> constant time.</p>
|
<p><b>Complexity:</b> constant time.</p>
|
||||||
|
<H4>Captures</H4>
|
||||||
|
<PRE><A name=m16></A>typedef typename value_type::capture_sequence_type capture_sequence_type;</PRE>
|
||||||
|
<P>Defines an implementation-specific type that satisfies the requirements of
|
||||||
|
a standard library Sequence (21.1.1 including the optional Table 68
|
||||||
|
operations), whose value_type is a <EM>sub_match<BidirectionalIterator></EM>. This
|
||||||
|
type happens to be <EM>std::vector<sub_match<BidirectionalIterator> ></EM>,
|
||||||
|
but you shouldn't actually rely on that.</P>
|
||||||
|
<PRE><A name=m17></A>const capture_sequence_type& <A href="#m8" >captures</A>(std::size_t i)const; </PRE>
|
||||||
|
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
|
||||||
|
obtained for sub-expression <EM>i</EM>.</P>
|
||||||
|
<P><STRONG>Returns:</STRONG> <code>(*this)[i].captures();</code></P>
|
||||||
|
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
|
||||||
|
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
|
||||||
|
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
|
||||||
|
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
|
||||||
|
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
|
||||||
|
this member function to be defined and return useful information.</P>
|
||||||
|
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
|
||||||
|
</P>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
sub_match occupies more memory resulting in complex expressions running out of
|
||||||
|
memory or stack space more quickly during matching.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are less efficient at handling some features
|
||||||
|
(independent sub-expressions for example), even when match_extra is not used.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are much less efficient (i.e. slower), when match_extra
|
||||||
|
is used. Mostly this is down to the extra memory allocations that have to
|
||||||
|
take place.</LI></UL>
|
||||||
<h4>match_results non-members</h4>
|
<h4>match_results non-members</h4>
|
||||||
<PRE><A name=n1></A>template <class BidirectionalIterator, class Allocator>
|
<PRE><A name=n1></A>template <class BidirectionalIterator, class Allocator>
|
||||||
bool operator == (const match_results<BidirectionalIterator, Allocator>& m1,
|
bool operator == (const match_results<BidirectionalIterator, Allocator>& m1,
|
||||||
@ -418,10 +449,10 @@ void swap(match_results<BidirectionalIterator, Allocator>& m1,
|
|||||||
24 Oct 2003
|
24 Oct 2003
|
||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
<p><i><EFBFBD> Copyright John Maddock 1998-
|
<p><i><EFBFBD> Copyright John Maddock 1998-
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
|
||||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -3,21 +3,20 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>Boost.Regex: sub_match</title>
|
<title>Boost.Regex: sub_match</title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||||
<link rel="stylesheet" type="text/css" href="../../../boost.css">
|
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
|
||||||
</head>
|
|
||||||
<body>
|
<body>
|
||||||
<P>
|
<P>
|
||||||
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
||||||
<TR>
|
<TR>
|
||||||
<td valign="top" width="300">
|
<td vAlign="top" width="300">
|
||||||
<h3><a href="../../../index.htm"><img height="86" width="277" alt="C++ Boost" src="../../../c++boost.gif" border="0"></a></h3>
|
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
<TD width="353">
|
<TD width="353">
|
||||||
<H1 align="center">Boost.Regex</H1>
|
<H1 align="center">Boost.Regex</H1>
|
||||||
<H2 align="center">sub_match</H2>
|
<H2 align="center">sub_match</H2>
|
||||||
</TD>
|
</TD>
|
||||||
<td width="50">
|
<td width="50">
|
||||||
<h3><a href="index.html"><img height="45" width="43" alt="Boost.Regex Index" src="uarrow.gif" border="0"></a></h3>
|
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
|
||||||
</td>
|
</td>
|
||||||
</TR>
|
</TR>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
@ -41,20 +40,28 @@
|
|||||||
<P>Objects of type <EM>sub_match</EM> may be compared to objects of type <EM>std::basic_string</EM>,
|
<P>Objects of type <EM>sub_match</EM> may be compared to objects of type <EM>std::basic_string</EM>,
|
||||||
or <EM>const charT*</EM> or <EM>const charT</EM>
|
or <EM>const charT*</EM> or <EM>const charT</EM>
|
||||||
.
|
.
|
||||||
|
<P>Objects of type <EM>sub_match</EM> may be added to objects of type <EM>std::basic_string</EM>,
|
||||||
|
or <EM>const charT* </EM>or <EM>const charT</EM>, to produce a new <EM>std::basic_string
|
||||||
|
</EM>
|
||||||
|
object.
|
||||||
<P>When the marked sub-expression denoted by an object of type sub_match<>
|
<P>When the marked sub-expression denoted by an object of type sub_match<>
|
||||||
participated in a regular expression match then member <CODE>matched</CODE> evaluates
|
participated in a regular expression match then member <CODE>matched</CODE> evaluates
|
||||||
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
|
to true, and members <CODE>first</CODE> and <CODE>second</CODE> denote the
|
||||||
range of characters <CODE>[first,second)</CODE> which formed that match.
|
range of characters <CODE>[first,second)</CODE> which formed that match.
|
||||||
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
|
Otherwise <CODE>matched</CODE> is false, and members <CODE>first</CODE> and <CODE>second</CODE>
|
||||||
contained undefined values.</P>
|
contained undefined values.</P>
|
||||||
|
<P>When the marked sub-expression denoted by an object of type sub_match<>
|
||||||
|
was repeated, then the sub_match object represents the match obtained by the
|
||||||
|
last repeat. The complete set of all the captures obtained for all the
|
||||||
|
repeats, may be accessed via the captures() member function (Note: this has
|
||||||
|
serious performance implications, you have to explicitly enable this feature).</P>
|
||||||
<P>If an object of type <CODE>sub_match<></CODE> represents sub-expression 0
|
<P>If an object of type <CODE>sub_match<></CODE> represents sub-expression 0
|
||||||
- that is to say the whole match - then member <CODE>matched</CODE> is always
|
- that is to say the whole match - then member <CODE>matched</CODE> is always
|
||||||
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
|
true, unless a partial match was obtained as a result of the flag <CODE>match_partial</CODE>
|
||||||
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
|
being passed to a regular expression algorithm, in which case member <CODE>matched</CODE>
|
||||||
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
|
is false, and members <CODE>first</CODE> and <CODE>second</CODE> represent the
|
||||||
character range that formed the partial match.</P>
|
character range that formed the partial match.</P>
|
||||||
<PRE>
|
<PRE>namespace boost{
|
||||||
namespace boost{
|
|
||||||
|
|
||||||
template <class BidirectionalIterator>
|
template <class BidirectionalIterator>
|
||||||
class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator>
|
class sub_match : public std::pair<BidirectionalIterator, BidirectionalIterator>
|
||||||
@ -73,6 +80,10 @@ public:
|
|||||||
int <A href="#m5" >compare</A>(const sub_match& s)const;
|
int <A href="#m5" >compare</A>(const sub_match& s)const;
|
||||||
int <A href="#m6" >compare</A>(const basic_string<value_type>& s)const;
|
int <A href="#m6" >compare</A>(const basic_string<value_type>& s)const;
|
||||||
int <A href="#m7" >compare</A>(const value_type* s)const;
|
int <A href="#m7" >compare</A>(const value_type* s)const;
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
typedef implementation-private <A href="#m9">capture_sequence_type</A>;
|
||||||
|
const capture_sequence_type& <A href="#m8" >captures</A>()const;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
//
|
//
|
||||||
// comparisons to another sub_match:
|
// comparisons to another sub_match:
|
||||||
@ -222,32 +233,32 @@ bool <A href="#o76">operator</A> <= (const sub_match<BidirectionalIterator
|
|||||||
//
|
//
|
||||||
// addition operators:
|
// addition operators:
|
||||||
//
|
//
|
||||||
template <class RandomAccessIterator, class traits, class Allocator>
|
template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
<A href="#o81">operator</A> + (const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
<A href="#o81" >operator</A> + (const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s,
|
||||||
const sub_match<RandomAccessIterator>& m);
|
const sub_match<BidirectionalIterator>& m);
|
||||||
template <class RandomAccessIterator, class traits, class Allocator>
|
template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
<A href="#o82">operator</A> + (const sub_match<RandomAccessIterator>& m,
|
<A href="#o82" >operator</A> + (const sub_match<BidirectionalIterator>& m,
|
||||||
const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s);
|
const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s);
|
||||||
template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o83">operator</A> + (typename iterator_traits<RandomAccessIterator>::value_type const* s,
|
<A href="#o83" >operator</A> + (typename iterator_traits<BidirectionalIterator>::value_type const* s,
|
||||||
const sub_match<RandomAccessIterator>& m);
|
const sub_match<BidirectionalIterator>& m);
|
||||||
template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o84">operator</A> + (const sub_match<RandomAccessIterator>& m,
|
<A href="#o84" >operator</A> + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const * s);
|
typename iterator_traits<BidirectionalIterator>::value_type const * s);
|
||||||
template <class RandomAccessIterator>
|
template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o85">operator</A> + (typename iterator_traits<RandomAccessIterator>::value_type const& s,
|
<A href="#o85" >operator</A> + (typename iterator_traits<BidirectionalIterator>::value_type const& s,
|
||||||
const sub_match<RandomAccessIterator>& m);
|
const sub_match<BidirectionalIterator>& m);
|
||||||
template <class RandomAccessIterator>
|
template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o86">operator</A> + (const sub_match<RandomAccessIterator>& m,
|
<A href="#o86" >operator</A> + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const& s);
|
typename iterator_traits<BidirectionalIterator>::value_type const& s);
|
||||||
template <class RandomAccessIterator>
|
template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
<A href="#o87">operator</A> + (const sub_match<RandomAccessIterator>& m1,
|
<A href="#o87" >operator</A> + (const sub_match<BidirectionalIterator>& m1,
|
||||||
const sub_match<RandomAccessIterator>& m2);
|
const sub_match<BidirectionalIterator>& m2);
|
||||||
|
|
||||||
//
|
//
|
||||||
// stream inserter:
|
// stream inserter:
|
||||||
@ -259,8 +270,7 @@ basic_ostream<charT, traits>&
|
|||||||
|
|
||||||
} // namespace boost</PRE>
|
} // namespace boost</PRE>
|
||||||
<H3>Description</H3>
|
<H3>Description</H3>
|
||||||
<H4>
|
<H4>sub_match members</H4>
|
||||||
sub_match members</H4>
|
|
||||||
<PRE>typedef typename std::iterator_traits<iterator>::value_type value_type;</PRE>
|
<PRE>typedef typename std::iterator_traits<iterator>::value_type value_type;</PRE>
|
||||||
<P>The type pointed to by the iterators.</P>
|
<P>The type pointed to by the iterators.</P>
|
||||||
<PRE>typedef typename std::iterator_traits<iterator>::difference_type difference_type;</PRE>
|
<PRE>typedef typename std::iterator_traits<iterator>::difference_type difference_type;</PRE>
|
||||||
@ -274,12 +284,10 @@ basic_ostream<charT, traits>&
|
|||||||
<PRE><A name=m1></A>bool matched</PRE>
|
<PRE><A name=m1></A>bool matched</PRE>
|
||||||
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
|
<P>A Boolean value denoting whether this sub-expression participated in the match.</P>
|
||||||
<PRE><A name=m2></A>static difference_type length();</PRE>
|
<PRE><A name=m2></A>static difference_type length();</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
|
||||||
<B>Effects: </B>returns the length of this matched sub-expression, or 0 if this
|
|
||||||
sub-expression was not matched: <CODE>matched ? distance(first, second) : 0)</CODE>.</P>
|
sub-expression was not matched: <CODE>matched ? distance(first, second) : 0)</CODE>.</P>
|
||||||
<PRE><A name=m3></A>operator basic_string<value_type>()const;</PRE>
|
<PRE><A name=m3></A>operator basic_string<value_type>()const;</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
|
||||||
<B>Effects: </B>converts *this into a string: returns <CODE>(matched ?
|
|
||||||
basic_string<value_type>(first, second) :
|
basic_string<value_type>(first, second) :
|
||||||
basic_string<value_type>()).</P>
|
basic_string<value_type>()).</P>
|
||||||
</CODE><PRE><A name=m4></A>basic_string<value_type> str()const;</PRE>
|
</CODE><PRE><A name=m4></A>basic_string<value_type> str()const;</PRE>
|
||||||
@ -287,32 +295,54 @@ basic_ostream<charT, traits>&
|
|||||||
basic_string<value_type>(first, second) :
|
basic_string<value_type>(first, second) :
|
||||||
basic_string<value_type>())</CODE>.</P>
|
basic_string<value_type>())</CODE>.</P>
|
||||||
<PRE><A name=m5></A>int compare(const sub_match& s)const;</PRE>
|
<PRE><A name=m5></A>int compare(const sub_match& s)const;</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
|
||||||
<B>Effects: </B>performs a lexical comparison to <EM>s</EM>: returns <CODE>str().compare(s.str())</CODE>.</P>
|
|
||||||
<PRE><A name=m6></A>int compare(const basic_string<value_type>& s)const;</PRE>
|
<PRE><A name=m6></A>int compare(const basic_string<value_type>& s)const;</PRE>
|
||||||
<P><B>Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
|
<P><B>Effects: </B>compares *this to the string s: returns <CODE>str().compare(s)</CODE>.</P>
|
||||||
<PRE><A name=m7></A>int compare(const value_type* s)const;</PRE>
|
<PRE><A name=m7></A>int compare(const value_type* s)const;</PRE>
|
||||||
<P>
|
<P><B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B> </B>returns
|
||||||
<B>Effects:<B></B> </B>compares *this to the null-terminated string <EM>s</EM>:<B> </B>returns
|
|
||||||
<CODE>str().compare(s)</CODE>.</P>
|
<CODE>str().compare(s)</CODE>.</P>
|
||||||
<H4>
|
<PRE><A name=m9></A>typedef implementation-private capture_sequence_type;</PRE>
|
||||||
sub_match non-member operators</H4>
|
<P>Defines an implementation-specific type that satisfies the requirements of
|
||||||
|
a standard library Sequence (21.1.1 including the optional Table 68
|
||||||
|
operations), whose value_type is a <EM>sub_match<BidirectionalIterator></EM>. This
|
||||||
|
type happens to be <EM>std::vector<sub_match<BidirectionalIterator> ></EM>,
|
||||||
|
but you shouldn't actually rely on that.</P>
|
||||||
|
<PRE><A name=m8></A>const capture_sequence_type& <A href="#m8" >captures</A>()const; </PRE>
|
||||||
|
<P><STRONG>Effects:</STRONG> returns a sequence containing all the captures
|
||||||
|
obtained for this sub-expression.</P>
|
||||||
|
<P><STRONG>Preconditions:</STRONG> the library must be built and used with
|
||||||
|
BOOST_REGEX_MATCH_EXTRA defined, and you must pass the flag <A href="match_flag_type.html">
|
||||||
|
match_extra</A> to the regex matching functions (<A href="regex_match.html">regex_match</A>,
|
||||||
|
<A href="regex_search.html">regex_search</A>, <A href="regex_iterator.html">regex_iterator</A>
|
||||||
|
or <A href="regex_token_iterator.html">regex_token_iterator</A>) in order for
|
||||||
|
this member function to be defined and return useful information.</P>
|
||||||
|
<P><STRONG>Rationale:</STRONG> Enabling this feature has several consequences:
|
||||||
|
</P>
|
||||||
|
<UL>
|
||||||
|
<LI>
|
||||||
|
sub_match occupies more memory resulting in complex expressions running out of
|
||||||
|
memory or stack space more quickly during matching.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are less efficient at handling some features
|
||||||
|
(independent sub-expressions for example), even when match_extra is not used.
|
||||||
|
<LI>
|
||||||
|
The matching algorithms are much less efficient (i.e. slower), when match_extra
|
||||||
|
is used. Mostly this is down to the extra memory allocations that have to
|
||||||
|
take place.</LI></UL>
|
||||||
|
<H4>sub_match non-member operators</H4>
|
||||||
<H5>Comparisons against self</H5>
|
<H5>Comparisons against self</H5>
|
||||||
<PRE><A name=o11></A>template <class BidirectionalIterator>
|
<PRE><A name=o11></A>template <class BidirectionalIterator>
|
||||||
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) == 0</CODE>.</P>
|
|
||||||
<PRE><A name=o12></A>template <class BidirectionalIterator>
|
<PRE><A name=o12></A>template <class BidirectionalIterator>
|
||||||
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) != 0</CODE>.</P>
|
|
||||||
<PRE><A name=o13></A>template <class BidirectionalIterator>
|
<PRE><A name=o13></A>template <class BidirectionalIterator>
|
||||||
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) < 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) < 0</CODE>.</P>
|
|
||||||
<PRE><A name=o14></A>template <class BidirectionalIterator>
|
<PRE><A name=o14></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
@ -320,13 +350,11 @@ bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
|||||||
<PRE><A name=o15></A>template <class BidirectionalIterator>
|
<PRE><A name=o15></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) >= 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) >= 0</CODE>.</P>
|
|
||||||
<PRE><A name=o16></A>template <class BidirectionalIterator>
|
<PRE><A name=o16></A>template <class BidirectionalIterator>
|
||||||
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
const sub_match<BidirectionalIterator>& rhs);</PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.compare(rhs) > 0</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.compare(rhs) > 0</CODE>.</P>
|
|
||||||
<H5>Comparisons with std::basic_string</H5>
|
<H5>Comparisons with std::basic_string</H5>
|
||||||
<pre><A name=o21></A>
|
<pre><A name=o21></A>
|
||||||
template <class BidirectionalIterator, class traits, class Allocator>
|
template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
@ -382,159 +410,135 @@ bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
|||||||
<PRE><A name=o41></A>template <class BidirectionalIterator>
|
<PRE><A name=o41></A>template <class BidirectionalIterator>
|
||||||
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o42></A>template <class BidirectionalIterator>
|
<PRE><A name=o42></A>template <class BidirectionalIterator>
|
||||||
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
|
||||||
<PRE></A><A name=o43></A>template <class BidirectionalIterator>
|
<PRE></A><A name=o43></A>template <class BidirectionalIterator>
|
||||||
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o44></A>template <class BidirectionalIterator>
|
<PRE><A name=o44></A>template <class BidirectionalIterator>
|
||||||
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o45></A>template <class BidirectionalIterator>
|
<PRE><A name=o45></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o46></A>template <class BidirectionalIterator>
|
<PRE><A name=o46></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const* lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o51></A>template <class BidirectionalIterator>
|
<PRE><A name=o51></A>template <class BidirectionalIterator>
|
||||||
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o52></A>template <class BidirectionalIterator>
|
<PRE><A name=o52></A>template <class BidirectionalIterator>
|
||||||
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o53></A>template <class BidirectionalIterator>
|
<PRE><A name=o53></A>template <class BidirectionalIterator>
|
||||||
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o54></A>template <class BidirectionalIterator>
|
<PRE><A name=o54></A>template <class BidirectionalIterator>
|
||||||
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o55></A>template <class BidirectionalIterator>
|
<PRE><A name=o55></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o56></A>template <class BidirectionalIterator>
|
<PRE><A name=o56></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const* rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
|
||||||
<H5>Comparisons with a single character</H5>
|
<H5>Comparisons with a single character</H5>
|
||||||
<PRE><A name=o61></A>template <class BidirectionalIterator>
|
<PRE><A name=o61></A>template <class BidirectionalIterator>
|
||||||
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator == (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs == rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o62></A>template <class BidirectionalIterator>
|
<PRE><A name=o62></A>template <class BidirectionalIterator>
|
||||||
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator != (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs != rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o63></A>template <class BidirectionalIterator>
|
<PRE><A name=o63></A>template <class BidirectionalIterator>
|
||||||
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator < (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs < rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o64></A>template <class BidirectionalIterator>
|
<PRE><A name=o64></A>template <class BidirectionalIterator>
|
||||||
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator > (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs > rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o65></A>template <class BidirectionalIterator>
|
<PRE><A name=o65></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator >= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs >= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o66></A>template <class BidirectionalIterator>
|
<PRE><A name=o66></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
bool operator <= (typename iterator_traits<BidirectionalIterator>::value_type const& lhs,
|
||||||
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
const sub_match<BidirectionalIterator>& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs <= rhs.str()</CODE>.</P>
|
|
||||||
<PRE><A name=o71></A>template <class BidirectionalIterator>
|
<PRE><A name=o71></A>template <class BidirectionalIterator>
|
||||||
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
bool operator == (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() == rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o72></A>template <class BidirectionalIterator>
|
<PRE><A name=o72></A>template <class BidirectionalIterator>
|
||||||
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
bool operator != (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() != rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o73></A>template <class BidirectionalIterator>
|
<PRE><A name=o73></A>template <class BidirectionalIterator>
|
||||||
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
bool operator < (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() < rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o74></A>template <class BidirectionalIterator>
|
<PRE><A name=o74></A>template <class BidirectionalIterator>
|
||||||
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
bool operator > (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() > rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o75></A>template <class BidirectionalIterator>
|
<PRE><A name=o75></A>template <class BidirectionalIterator>
|
||||||
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator >= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() >= rhs</CODE>.</P>
|
|
||||||
<PRE><A name=o76></A>template <class BidirectionalIterator>
|
<PRE><A name=o76></A>template <class BidirectionalIterator>
|
||||||
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
bool operator <= (const sub_match<BidirectionalIterator>& lhs,
|
||||||
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& rhs); </PRE>
|
||||||
<P>
|
<P><B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
||||||
<B>Effects: </B>returns <CODE>lhs.str() <= rhs</CODE>.</P>
|
|
||||||
<h5>Addition operators</h5>
|
<h5>Addition operators</h5>
|
||||||
<P>The addition operators for sub_match allow you to add a sub_match to any type
|
<P>The addition operators for sub_match allow you to add a sub_match to any type
|
||||||
to which you can add a std::string and obtain a new string as the result.</P>
|
to which you can add a std::string and obtain a new string as the result.</P>
|
||||||
<PRE><A name=o81></A>template <class RandomAccessIterator, class traits, class Allocator>
|
<PRE><A name=o81></A>template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
operator + (const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s,
|
operator + (const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s,
|
||||||
const sub_match<RandomAccessIterator>& m); </PRE>
|
const sub_match<BidirectionalIterator>& m); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
||||||
<PRE><A name=o82></A>template <class RandomAccessIterator, class traits, class Allocator>
|
<PRE><A name=o82></A>template <class BidirectionalIterator, class traits, class Allocator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m,
|
operator + (const sub_match<BidirectionalIterator>& m,
|
||||||
const std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type, traits, Allocator>& s); </PRE>
|
const std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type, traits, Allocator>& s); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
||||||
<PRE><A name=o83></A>template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
<PRE><A name=o83></A>template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (typename iterator_traits<RandomAccessIterator>::value_type const* s,
|
operator + (typename iterator_traits<BidirectionalIterator>::value_type const* s,
|
||||||
const sub_match<RandomAccessIterator>& m); </PRE>
|
const sub_match<BidirectionalIterator>& m); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
||||||
<PRE><A name=o84></A>template <class RandomAccessIterator> std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
<PRE><A name=o84></A>template <class BidirectionalIterator> std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m,
|
operator + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const * s);</PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const * s);</PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
||||||
<PRE><A name=o85></A>template <class RandomAccessIterator>
|
<PRE><A name=o85></A>template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (typename iterator_traits<RandomAccessIterator>::value_type const& s,
|
operator + (typename iterator_traits<BidirectionalIterator>::value_type const& s,
|
||||||
const sub_match<RandomAccessIterator>& m); </PRE>
|
const sub_match<BidirectionalIterator>& m); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>s + m.str()</CODE>.</P>
|
||||||
<PRE><A name=o86></A>template <class RandomAccessIterator>
|
<PRE><A name=o86></A>template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m,
|
operator + (const sub_match<BidirectionalIterator>& m,
|
||||||
typename iterator_traits<RandomAccessIterator>::value_type const& s); </PRE>
|
typename iterator_traits<BidirectionalIterator>::value_type const& s); </PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m.str() + s</CODE>.</P>
|
||||||
<PRE><A name=o87></A>template <class RandomAccessIterator>
|
<PRE><A name=o87></A>template <class BidirectionalIterator>
|
||||||
std::basic_string<typename iterator_traits<RandomAccessIterator>::value_type>
|
std::basic_string<typename iterator_traits<BidirectionalIterator>::value_type>
|
||||||
operator + (const sub_match<RandomAccessIterator>& m1,
|
operator + (const sub_match<BidirectionalIterator>& m1,
|
||||||
const sub_match<RandomAccessIterator>& m2);</PRE>
|
const sub_match<BidirectionalIterator>& m2);</PRE>
|
||||||
<P><B>Effects: </B>returns <CODE>m1.str() + m2.str()</CODE>.</P>
|
<P><B>Effects: </B>returns <CODE>m1.str() + m2.str()</CODE>.</P>
|
||||||
<h5>Stream inserter</h5>
|
<h5>Stream inserter</h5>
|
||||||
<PRE><A name=oi></A>template <class charT, class traits, class BidirectionalIterator>
|
<PRE><A name=oi></A>template <class charT, class traits, class BidirectionalIterator>
|
||||||
@ -549,10 +553,10 @@ basic_ostream<charT, traits>&
|
|||||||
24 Oct 2003
|
24 Oct 2003
|
||||||
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
||||||
<p><i><EFBFBD> Copyright John Maddock 1998-
|
<p><i><EFBFBD> Copyright John Maddock 1998-
|
||||||
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan -->
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
||||||
2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
|
||||||
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
<P><I>Use, modification and distribution are subject to the Boost Software License,
|
||||||
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
Version 1.0. (See accompanying file <A href="../../../LICENSE_1_0.txt">LICENSE_1_0.txt</A>
|
||||||
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
or copy at <A href="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)</I></P>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
@ -45,6 +45,23 @@ test-suite regex-examples :
|
|||||||
[ regex-test-run snippets/regex_token_iterator_eg_2.cpp : $(BOOST_ROOT)/libs/regex/doc/index.html ]
|
[ regex-test-run snippets/regex_token_iterator_eg_2.cpp : $(BOOST_ROOT)/libs/regex/doc/index.html ]
|
||||||
[ regex-test-run snippets/regex_iterator_example.cpp : $(BOOST_ROOT)/boost/rational.hpp ]
|
[ regex-test-run snippets/regex_iterator_example.cpp : $(BOOST_ROOT)/boost/rational.hpp ]
|
||||||
|
|
||||||
|
[ run
|
||||||
|
# sources
|
||||||
|
snippets/captures_example.cpp
|
||||||
|
<template>../build/regex-options
|
||||||
|
# dependencies
|
||||||
|
<lib>../test/captures/boost_regex_extra
|
||||||
|
: # additional args
|
||||||
|
: # test-files
|
||||||
|
: # requirements
|
||||||
|
<threading>multi
|
||||||
|
<define>BOOST_REGEX_MATCH_EXTRA=1
|
||||||
|
<define>BOOST_REGEX_NO_LIB=1
|
||||||
|
: # test name
|
||||||
|
captures_example
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -54,3 +71,5 @@ test-suite regex-examples :
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
51
example/snippets/captures_example.cpp
Normal file
51
example/snippets/captures_example.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
|
||||||
|
#include <boost/regex.hpp>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
void print_captures(const std::string& regx, const std::string& text)
|
||||||
|
{
|
||||||
|
boost::regex e(regx);
|
||||||
|
boost::smatch what;
|
||||||
|
std::cout << "Expression: \"" << regx << "\"\n";
|
||||||
|
std::cout << "Text: \"" << text << "\"\n";
|
||||||
|
if(boost::regex_match(text, what, e, boost::match_extra))
|
||||||
|
{
|
||||||
|
unsigned i, j;
|
||||||
|
std::cout << "** Match found **\n Sub-Expressions:\n";
|
||||||
|
for(i = 0; i < what.size(); ++i)
|
||||||
|
std::cout << " $" << i << " = \"" << what[i] << "\"\n";
|
||||||
|
std::cout << " Captures:\n";
|
||||||
|
for(i = 0; i < what.size(); ++i)
|
||||||
|
{
|
||||||
|
std::cout << " $" << i << " = {";
|
||||||
|
for(j = 0; j < what.captures(i).size(); ++j)
|
||||||
|
{
|
||||||
|
if(j)
|
||||||
|
std::cout << ", ";
|
||||||
|
else
|
||||||
|
std::cout << " ";
|
||||||
|
std::cout << "\"" << what.captures(i)[j] << "\"";
|
||||||
|
}
|
||||||
|
std::cout << " }\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout << "** No Match found **\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int , char* [])
|
||||||
|
{
|
||||||
|
print_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee");
|
||||||
|
print_captures("a(b+|((c)*))+d", "abd");
|
||||||
|
print_captures("(.*)bar|(.*)bah", "abcbar");
|
||||||
|
print_captures("(.*)bar|(.*)bah", "abcbah");
|
||||||
|
print_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party");
|
||||||
|
print_captures("^(?>(\\w+)\\W*)*$", "now is the time for all good men to come to the aid of the party");
|
||||||
|
print_captures("^(\\w+)\\W+(?>(\\w+)\\W+)*(\\w+)$", "now is the time for all good men to come to the aid of the party");
|
||||||
|
print_captures("^(\\w+)\\W+(?>(\\w+)\\W+(?:(\\w+)\\W+){0,2})*(\\w+)$", "now is the time for all good men to come to the aid of the party");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -55,12 +55,10 @@
|
|||||||
# include <boost/detail/allocator.hpp>
|
# include <boost/detail/allocator.hpp>
|
||||||
# include <boost/regex/config/cstring.hpp>
|
# include <boost/regex/config/cstring.hpp>
|
||||||
# include <boost/throw_exception.hpp>
|
# include <boost/throw_exception.hpp>
|
||||||
|
# include <boost/scoped_ptr.hpp>
|
||||||
# ifndef BOOST_NO_STD_LOCALE
|
# ifndef BOOST_NO_STD_LOCALE
|
||||||
# include <locale>
|
# include <locale>
|
||||||
# endif
|
# endif
|
||||||
# ifdef BOOST_REGEX_MATCH_EXTRA
|
|
||||||
# include <boost/scoped_ptr.hpp>
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
//
|
//
|
||||||
// C build,
|
// C build,
|
||||||
|
@ -85,3 +85,8 @@
|
|||||||
// if you don't want boost.regex to cache memory.
|
// if you don't want boost.regex to cache memory.
|
||||||
// #define BOOST_REGEX_MAX_CACHE_BLOCKS 16
|
// #define BOOST_REGEX_MAX_CACHE_BLOCKS 16
|
||||||
|
|
||||||
|
// define this if you want to be able to access extended capture
|
||||||
|
// information in your sub_match's (caution this will slow things
|
||||||
|
// down quite a bit).
|
||||||
|
// #define BOOST_REGEX_MATCH_EXTRA
|
||||||
|
|
||||||
|
@ -55,7 +55,12 @@ typedef enum _match_flags
|
|||||||
match_perl = match_all << 1, // Use perl matching rules
|
match_perl = match_all << 1, // Use perl matching rules
|
||||||
match_posix = match_perl << 1, // Use POSIX matching rules
|
match_posix = match_perl << 1, // Use POSIX matching rules
|
||||||
match_nosubs = match_posix << 1, // don't trap marked subs
|
match_nosubs = match_posix << 1, // don't trap marked subs
|
||||||
match_max = match_nosubs,
|
match_extra = match_nosubs << 1, // include full capture information for repeated captures
|
||||||
|
match_single_line = match_extra << 1, // treat text as single line and ignor any \n's when matching ^ and $.
|
||||||
|
match_unused1 = match_single_line << 1, // unused
|
||||||
|
match_unused2 = match_unused1 << 1, // unused
|
||||||
|
match_unused3 = match_unused2 << 1, // unused
|
||||||
|
match_max = match_unused3,
|
||||||
|
|
||||||
format_perl = 0, // perl style replacement
|
format_perl = 0, // perl style replacement
|
||||||
format_default = 0, // ditto.
|
format_default = 0, // ditto.
|
||||||
@ -117,6 +122,8 @@ using regex_constants::match_all;
|
|||||||
using regex_constants::match_perl;
|
using regex_constants::match_perl;
|
||||||
using regex_constants::match_posix;
|
using regex_constants::match_posix;
|
||||||
using regex_constants::match_nosubs;
|
using regex_constants::match_nosubs;
|
||||||
|
using regex_constants::match_extra;
|
||||||
|
using regex_constants::match_single_line;
|
||||||
//using regex_constants::match_max;
|
//using regex_constants::match_max;
|
||||||
using regex_constants::format_all;
|
using regex_constants::format_all;
|
||||||
using regex_constants::format_sed;
|
using regex_constants::format_sed;
|
||||||
|
@ -25,19 +25,19 @@
|
|||||||
|
|
||||||
namespace boost{
|
namespace boost{
|
||||||
|
|
||||||
template <class RandomAccessIterator
|
template <class BidiIterator
|
||||||
, class Allocator = BOOST_DEFAULT_ALLOCATOR(sub_match<RandomAccessIterator> )
|
, class Allocator = BOOST_DEFAULT_ALLOCATOR(sub_match<BidiIterator> )
|
||||||
>
|
>
|
||||||
class match_results
|
class match_results
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
#ifndef BOOST_NO_STD_ALLOCATOR
|
#ifndef BOOST_NO_STD_ALLOCATOR
|
||||||
typedef std::vector<sub_match<RandomAccessIterator>, Allocator> vector_type;
|
typedef std::vector<sub_match<BidiIterator>, Allocator> vector_type;
|
||||||
#else
|
#else
|
||||||
typedef std::vector<sub_match<RandomAccessIterator> > vector_type;
|
typedef std::vector<sub_match<BidiIterator> > vector_type;
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
typedef sub_match<RandomAccessIterator> value_type;
|
typedef sub_match<BidiIterator> value_type;
|
||||||
#if !defined(BOOST_NO_STD_ALLOCATOR) && !(defined(BOOST_MSVC) && defined(_STLPORT_VERSION))
|
#if !defined(BOOST_NO_STD_ALLOCATOR) && !(defined(BOOST_MSVC) && defined(_STLPORT_VERSION))
|
||||||
typedef typename Allocator::const_reference const_reference;
|
typedef typename Allocator::const_reference const_reference;
|
||||||
#else
|
#else
|
||||||
@ -47,11 +47,11 @@ public:
|
|||||||
typedef typename vector_type::const_iterator const_iterator;
|
typedef typename vector_type::const_iterator const_iterator;
|
||||||
typedef const_iterator iterator;
|
typedef const_iterator iterator;
|
||||||
typedef typename re_detail::regex_iterator_traits<
|
typedef typename re_detail::regex_iterator_traits<
|
||||||
RandomAccessIterator>::difference_type difference_type;
|
BidiIterator>::difference_type difference_type;
|
||||||
typedef typename Allocator::size_type size_type;
|
typedef typename Allocator::size_type size_type;
|
||||||
typedef Allocator allocator_type;
|
typedef Allocator allocator_type;
|
||||||
typedef typename re_detail::regex_iterator_traits<
|
typedef typename re_detail::regex_iterator_traits<
|
||||||
RandomAccessIterator>::value_type char_type;
|
BidiIterator>::value_type char_type;
|
||||||
typedef std::basic_string<char_type> string_type;
|
typedef std::basic_string<char_type> string_type;
|
||||||
|
|
||||||
// construct/copy/destroy:
|
// construct/copy/destroy:
|
||||||
@ -91,10 +91,10 @@ public:
|
|||||||
sub += 2;
|
sub += 2;
|
||||||
if(sub < m_subs.size())
|
if(sub < m_subs.size())
|
||||||
{
|
{
|
||||||
const sub_match<RandomAccessIterator>& s = m_subs[sub];
|
const sub_match<BidiIterator>& s = m_subs[sub];
|
||||||
if(s.matched)
|
if(s.matched)
|
||||||
{
|
{
|
||||||
return boost::re_detail::distance((RandomAccessIterator)(m_base), (RandomAccessIterator)(s.first));
|
return boost::re_detail::distance((BidiIterator)(m_base), (BidiIterator)(s.first));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ~static_cast<difference_type>(0);
|
return ~static_cast<difference_type>(0);
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
string_type result;
|
string_type result;
|
||||||
if(sub < (int)m_subs.size() && (sub > 0))
|
if(sub < (int)m_subs.size() && (sub > 0))
|
||||||
{
|
{
|
||||||
const sub_match<RandomAccessIterator>& s = m_subs[sub];
|
const sub_match<BidiIterator>& s = m_subs[sub];
|
||||||
if(s.matched)
|
if(s.matched)
|
||||||
{
|
{
|
||||||
result = s;
|
result = s;
|
||||||
@ -174,9 +174,18 @@ public:
|
|||||||
bool operator!=(const match_results& that)const
|
bool operator!=(const match_results& that)const
|
||||||
{ return !(*this == that); }
|
{ return !(*this == that); }
|
||||||
|
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
typedef typename sub_match<BidiIterator>::capture_sequence_type capture_sequence_type;
|
||||||
|
|
||||||
|
const capture_sequence_type& captures(int i)const
|
||||||
|
{
|
||||||
|
return (*this)[i].captures();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// private access functions:
|
// private access functions:
|
||||||
void BOOST_REGEX_CALL set_second(RandomAccessIterator i)
|
void BOOST_REGEX_CALL set_second(BidiIterator i)
|
||||||
{
|
{
|
||||||
assert(m_subs.size() > 2);
|
assert(m_subs.size() > 2);
|
||||||
m_subs[2].second = i;
|
m_subs[2].second = i;
|
||||||
@ -188,7 +197,7 @@ public:
|
|||||||
m_null.matched = false;
|
m_null.matched = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BOOST_REGEX_CALL set_second(RandomAccessIterator i, size_type pos, bool m = true)
|
void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true)
|
||||||
{
|
{
|
||||||
pos += 2;
|
pos += 2;
|
||||||
assert(m_subs.size() > pos);
|
assert(m_subs.size() > pos);
|
||||||
@ -203,7 +212,7 @@ public:
|
|||||||
m_null.matched = false;
|
m_null.matched = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void BOOST_REGEX_CALL set_size(size_type n, RandomAccessIterator i, RandomAccessIterator j)
|
void BOOST_REGEX_CALL set_size(size_type n, BidiIterator i, BidiIterator j)
|
||||||
{
|
{
|
||||||
value_type v(j);
|
value_type v(j);
|
||||||
size_type len = m_subs.size();
|
size_type len = m_subs.size();
|
||||||
@ -220,11 +229,11 @@ public:
|
|||||||
}
|
}
|
||||||
m_subs[1].first = i;
|
m_subs[1].first = i;
|
||||||
}
|
}
|
||||||
void BOOST_REGEX_CALL set_base(RandomAccessIterator pos)
|
void BOOST_REGEX_CALL set_base(BidiIterator pos)
|
||||||
{
|
{
|
||||||
m_base = pos;
|
m_base = pos;
|
||||||
}
|
}
|
||||||
void BOOST_REGEX_CALL set_first(RandomAccessIterator i)
|
void BOOST_REGEX_CALL set_first(BidiIterator i)
|
||||||
{
|
{
|
||||||
// set up prefix:
|
// set up prefix:
|
||||||
m_subs[1].second = i;
|
m_subs[1].second = i;
|
||||||
@ -238,7 +247,7 @@ public:
|
|||||||
m_subs[n].matched = false;
|
m_subs[n].matched = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void BOOST_REGEX_CALL set_first(RandomAccessIterator i, size_type pos)
|
void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos)
|
||||||
{
|
{
|
||||||
assert(pos+2 < m_subs.size());
|
assert(pos+2 < m_subs.size());
|
||||||
if(pos)
|
if(pos)
|
||||||
@ -246,22 +255,22 @@ public:
|
|||||||
else
|
else
|
||||||
set_first(i);
|
set_first(i);
|
||||||
}
|
}
|
||||||
void BOOST_REGEX_CALL maybe_assign(const match_results<RandomAccessIterator, Allocator>& m);
|
void BOOST_REGEX_CALL maybe_assign(const match_results<BidiIterator, Allocator>& m);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector_type m_subs; // subexpressions
|
vector_type m_subs; // subexpressions
|
||||||
RandomAccessIterator m_base; // where the search started from
|
BidiIterator m_base; // where the search started from
|
||||||
sub_match<RandomAccessIterator> m_null; // a null match
|
sub_match<BidiIterator> m_null; // a null match
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class RandomAccessIterator, class Allocator>
|
template <class BidiIterator, class Allocator>
|
||||||
void BOOST_REGEX_CALL match_results<RandomAccessIterator, Allocator>::maybe_assign(const match_results<RandomAccessIterator, Allocator>& m)
|
void BOOST_REGEX_CALL match_results<BidiIterator, Allocator>::maybe_assign(const match_results<BidiIterator, Allocator>& m)
|
||||||
{
|
{
|
||||||
const_iterator p1, p2;
|
const_iterator p1, p2;
|
||||||
p1 = begin();
|
p1 = begin();
|
||||||
p2 = m.begin();
|
p2 = m.begin();
|
||||||
RandomAccessIterator base = (*this)[-1].first;
|
BidiIterator base = (*this)[-1].first;
|
||||||
std::size_t len1 = 0;
|
std::size_t len1 = 0;
|
||||||
std::size_t len2 = 0;
|
std::size_t len2 = 0;
|
||||||
std::size_t base1 = 0;
|
std::size_t base1 = 0;
|
||||||
@ -276,8 +285,8 @@ void BOOST_REGEX_CALL match_results<RandomAccessIterator, Allocator>::maybe_assi
|
|||||||
if(base1 < base2) return;
|
if(base1 < base2) return;
|
||||||
if(base2 < base1) break;
|
if(base2 < base1) break;
|
||||||
|
|
||||||
len1 = boost::re_detail::distance((RandomAccessIterator)p1->first, (RandomAccessIterator)p1->second);
|
len1 = boost::re_detail::distance((BidiIterator)p1->first, (BidiIterator)p1->second);
|
||||||
len2 = boost::re_detail::distance((RandomAccessIterator)p2->first, (RandomAccessIterator)p2->second);
|
len2 = boost::re_detail::distance((BidiIterator)p2->first, (BidiIterator)p2->second);
|
||||||
if((len1 != len2) || ((p1->matched == false) && (p2->matched == true)))
|
if((len1 != len2) || ((p1->matched == false) && (p2->matched == true)))
|
||||||
break;
|
break;
|
||||||
if((p1->matched == true) && (p2->matched == false))
|
if((p1->matched == true) && (p2->matched == false))
|
||||||
@ -293,24 +302,24 @@ void BOOST_REGEX_CALL match_results<RandomAccessIterator, Allocator>::maybe_assi
|
|||||||
*this = m;
|
*this = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class RandomAccessIterator, class Allocator>
|
template <class BidiIterator, class Allocator>
|
||||||
void swap(match_results<RandomAccessIterator, Allocator>& a, match_results<RandomAccessIterator, Allocator>& b)
|
void swap(match_results<BidiIterator, Allocator>& a, match_results<BidiIterator, Allocator>& b)
|
||||||
{
|
{
|
||||||
a.swap(b);
|
a.swap(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_STD_LOCALE
|
#ifndef BOOST_NO_STD_LOCALE
|
||||||
template <class charT, class traits, class RandomAccessIterator, class Allocator>
|
template <class charT, class traits, class BidiIterator, class Allocator>
|
||||||
std::basic_ostream<charT, traits>&
|
std::basic_ostream<charT, traits>&
|
||||||
operator << (std::basic_ostream<charT, traits>& os,
|
operator << (std::basic_ostream<charT, traits>& os,
|
||||||
const match_results<RandomAccessIterator, Allocator>& s)
|
const match_results<BidiIterator, Allocator>& s)
|
||||||
{
|
{
|
||||||
return (os << s.str());
|
return (os << s.str());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
template <class RandomAccessIterator, class Allocator>
|
template <class BidiIterator, class Allocator>
|
||||||
std::ostream& operator << (std::ostream& os,
|
std::ostream& operator << (std::ostream& os,
|
||||||
const match_results<RandomAccessIterator, Allocator>& s)
|
const match_results<BidiIterator, Allocator>& s)
|
||||||
{
|
{
|
||||||
return (os << s.str());
|
return (os << s.str());
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#define BOOST_REGEX_MATCHER_HPP
|
#define BOOST_REGEX_MATCHER_HPP
|
||||||
|
|
||||||
#include <boost/regex/v4/iterator_category.hpp>
|
#include <boost/regex/v4/iterator_category.hpp>
|
||||||
#include <boost/scoped_ptr.hpp>
|
|
||||||
|
|
||||||
#ifdef BOOST_HAS_ABI_HEADERS
|
#ifdef BOOST_HAS_ABI_HEADERS
|
||||||
# include BOOST_ABI_PREFIX
|
# include BOOST_ABI_PREFIX
|
||||||
@ -22,6 +21,12 @@
|
|||||||
namespace boost{
|
namespace boost{
|
||||||
namespace re_detail{
|
namespace re_detail{
|
||||||
|
|
||||||
|
//
|
||||||
|
// error checking API:
|
||||||
|
//
|
||||||
|
BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type ef, match_flag_type mf);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Unfortunately Rogue Waves standard library appears to have a bug
|
// Unfortunately Rogue Waves standard library appears to have a bug
|
||||||
// in std::basic_string::compare that results in eroneous answers
|
// in std::basic_string::compare that results in eroneous answers
|
||||||
|
@ -117,6 +117,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match()
|
|||||||
m_presult->set_base(base);
|
m_presult->set_base(base);
|
||||||
if(m_match_flags & match_posix)
|
if(m_match_flags & match_posix)
|
||||||
m_result = *m_presult;
|
m_result = *m_presult;
|
||||||
|
verify_options(re.flags(), m_match_flags);
|
||||||
if(0 == match_prefix())
|
if(0 == match_prefix())
|
||||||
return false;
|
return false;
|
||||||
return m_result[0].second == last;
|
return m_result[0].second == last;
|
||||||
@ -206,6 +207,7 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::find()
|
|||||||
m_result.set_base(base);
|
m_result.set_base(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify_options(re.flags(), m_match_flags);
|
||||||
// find out what kind of expression we have:
|
// find out what kind of expression we have:
|
||||||
unsigned type = (m_match_flags & match_continuous) ?
|
unsigned type = (m_match_flags & match_continuous) ?
|
||||||
static_cast<unsigned int>(regbase::restart_continue)
|
static_cast<unsigned int>(regbase::restart_continue)
|
||||||
@ -253,6 +255,19 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_prefix()
|
|||||||
m_presult->set_second(last, 0, false);
|
m_presult->set_second(last, 0, false);
|
||||||
position = last;
|
position = last;
|
||||||
}
|
}
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
if(m_has_found_match && (match_extra & m_match_flags))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// we have a match, reverse the capture information:
|
||||||
|
//
|
||||||
|
for(unsigned i = 0; i < m_presult->size(); ++i)
|
||||||
|
{
|
||||||
|
typename sub_match<BidiIterator>::capture_sequence_type & seq = ((*m_presult)[i]).get_captures();
|
||||||
|
std::reverse(seq.begin(), seq.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if(!m_has_found_match)
|
if(!m_has_found_match)
|
||||||
position = restart; // reset search postion
|
position = restart; // reset search postion
|
||||||
return m_has_found_match;
|
return m_has_found_match;
|
||||||
@ -297,7 +312,9 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_literal()
|
|||||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||||
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_start_line()
|
bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_start_line()
|
||||||
{
|
{
|
||||||
if((position == base) && ((m_match_flags & match_prev_avail) == 0))
|
if(position == base)
|
||||||
|
{
|
||||||
|
if((m_match_flags & match_prev_avail) == 0)
|
||||||
{
|
{
|
||||||
if((m_match_flags & match_not_bol) == 0)
|
if((m_match_flags & match_not_bol) == 0)
|
||||||
{
|
{
|
||||||
@ -306,6 +323,9 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_start_line
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else if(m_match_flags & match_single_line)
|
||||||
|
return false;
|
||||||
|
|
||||||
// check the previous value character:
|
// check the previous value character:
|
||||||
BidiIterator t(position);
|
BidiIterator t(position);
|
||||||
@ -331,6 +351,8 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_end_line()
|
|||||||
{
|
{
|
||||||
if(position != last)
|
if(position != last)
|
||||||
{
|
{
|
||||||
|
if(m_match_flags & match_single_line)
|
||||||
|
return false;
|
||||||
// we're not yet at the end so *first is always valid:
|
// we're not yet at the end so *first is always valid:
|
||||||
if(traits_inst.is_separator(*position))
|
if(traits_inst.is_separator(*position))
|
||||||
{
|
{
|
||||||
@ -387,6 +409,14 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_match()
|
|||||||
m_result.maybe_assign(*m_presult);
|
m_result.maybe_assign(*m_presult);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
if(match_extra & m_match_flags)
|
||||||
|
{
|
||||||
|
for(unsigned i = 0; i < m_presult->size(); ++i)
|
||||||
|
if((*m_presult)[i].matched)
|
||||||
|
((*m_presult)[i]).get_captures().push_back((*m_presult)[i]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,11 +309,38 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
|
|||||||
}
|
}
|
||||||
case -3:
|
case -3:
|
||||||
{
|
{
|
||||||
// independent sub-expression:
|
// independent sub-expression, currently this is always recursive:
|
||||||
const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p;
|
const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p;
|
||||||
pstate = pstate->next.p->next.p;
|
pstate = pstate->next.p->next.p;
|
||||||
bool r = match_all_states();
|
bool r = match_all_states();
|
||||||
pstate = next_pstate;
|
pstate = next_pstate;
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
if(r && (m_match_flags & match_extra))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// our captures have been stored in *m_presult
|
||||||
|
// we need to unpack them, and insert them
|
||||||
|
// back in the right order when we unwind the stack:
|
||||||
|
//
|
||||||
|
match_results<BidiIterator, Allocator> tm(*m_presult);
|
||||||
|
unsigned i;
|
||||||
|
for(i = 0; i < tm.size(); ++i)
|
||||||
|
(*m_presult)[i].get_captures().clear();
|
||||||
|
// match everything else:
|
||||||
|
r = match_all_states();
|
||||||
|
// now place the stored captures back:
|
||||||
|
for(i = 0; i < tm.size(); ++i)
|
||||||
|
{
|
||||||
|
typedef typename sub_match<BidiIterator>::capture_sequence_type seq;
|
||||||
|
seq& s1 = (*m_presult)[i].get_captures();
|
||||||
|
const seq& s2 = tm[i].captures();
|
||||||
|
s1.insert(
|
||||||
|
s1.end(),
|
||||||
|
s2.begin(),
|
||||||
|
s2.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -809,6 +836,13 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::unwind_paren(boo
|
|||||||
m_presult->set_first(pmp->sub.first, pmp->index);
|
m_presult->set_first(pmp->sub.first, pmp->index);
|
||||||
m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched);
|
m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched);
|
||||||
}
|
}
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
//
|
||||||
|
// we have a match, push the capture information onto the stack:
|
||||||
|
//
|
||||||
|
else if(pmp->sub.matched && (match_extra & m_match_flags))
|
||||||
|
((*m_presult)[pmp->index]).get_captures().push_back(pmp->sub);
|
||||||
|
#endif
|
||||||
// unwind stack:
|
// unwind stack:
|
||||||
m_backup_state = pmp+1;
|
m_backup_state = pmp+1;
|
||||||
boost::re_detail::inplace_destroy(pmp);
|
boost::re_detail::inplace_destroy(pmp);
|
||||||
|
@ -35,13 +35,14 @@ class backup_subex
|
|||||||
public:
|
public:
|
||||||
template <class A>
|
template <class A>
|
||||||
backup_subex(const match_results<BidiIterator, A>& w, int i)
|
backup_subex(const match_results<BidiIterator, A>& w, int i)
|
||||||
: index(i), sub(w[i]) {}
|
: index(i), sub(w[i], false) {}
|
||||||
template <class A>
|
template <class A>
|
||||||
void restore(match_results<BidiIterator, A>& w)
|
void restore(match_results<BidiIterator, A>& w)
|
||||||
{
|
{
|
||||||
w.set_first(sub.first, index);
|
w.set_first(sub.first, index);
|
||||||
w.set_second(sub.second, index, sub.matched);
|
w.set_second(sub.second, index, sub.matched);
|
||||||
}
|
}
|
||||||
|
const sub_match<BidiIterator>& get() { return sub; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||||
@ -126,6 +127,33 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
|
|||||||
pstate = pstate->next.p->next.p;
|
pstate = pstate->next.p->next.p;
|
||||||
r = match_all_states();
|
r = match_all_states();
|
||||||
pstate = next_pstate;
|
pstate = next_pstate;
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
if(r && (m_match_flags & match_extra))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// our captures have been stored in *m_presult
|
||||||
|
// we need to unpack them, and insert them
|
||||||
|
// back in the right order when we unwind the stack:
|
||||||
|
//
|
||||||
|
unsigned i;
|
||||||
|
match_results<BidiIterator, Allocator> tm(*m_presult);
|
||||||
|
for(i = 0; i < tm.size(); ++i)
|
||||||
|
(*m_presult)[i].get_captures().clear();
|
||||||
|
// match everything else:
|
||||||
|
r = match_all_states();
|
||||||
|
// now place the stored captures back:
|
||||||
|
for(i = 0; i < tm.size(); ++i)
|
||||||
|
{
|
||||||
|
typedef typename sub_match<BidiIterator>::capture_sequence_type seq;
|
||||||
|
seq& s1 = (*m_presult)[i].get_captures();
|
||||||
|
const seq& s2 = tm[i].captures();
|
||||||
|
s1.insert(
|
||||||
|
s1.end(),
|
||||||
|
s2.begin(),
|
||||||
|
s2.end());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -139,6 +167,13 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
|
|||||||
r = match_all_states();
|
r = match_all_states();
|
||||||
if(r == false)
|
if(r == false)
|
||||||
sub.restore(*m_presult);
|
sub.restore(*m_presult);
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
//
|
||||||
|
// we have a match, push the capture information onto the stack:
|
||||||
|
//
|
||||||
|
else if(sub.get().matched && (match_extra & m_match_flags))
|
||||||
|
((*m_presult)[index]).get_captures().push_back(sub.get());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -103,22 +103,14 @@ public:
|
|||||||
if(regex_search(first, end, what, *pre, flags) == true)
|
if(regex_search(first, end, what, *pre, flags) == true)
|
||||||
{
|
{
|
||||||
N = 0;
|
N = 0;
|
||||||
#if 1
|
|
||||||
result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]);
|
result = ((subs[N] == -1) ? what.prefix() : what[(int)subs[N]]);
|
||||||
#else
|
|
||||||
result = ((subs[N] == -1) ? value_type(what.prefix().str()) : value_type(what[(int)subs[N]].str()));
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if((subs[N] == -1) && (first != end))
|
else if((subs[N] == -1) && (first != end))
|
||||||
{
|
{
|
||||||
#if 1
|
|
||||||
result.first = first;
|
result.first = first;
|
||||||
result.second = end;
|
result.second = end;
|
||||||
result.matched = (first != end);
|
result.matched = (first != end);
|
||||||
#else
|
|
||||||
result = value_type(first, end);
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -142,11 +134,7 @@ public:
|
|||||||
if(N+1 < (int)subs.size())
|
if(N+1 < (int)subs.size())
|
||||||
{
|
{
|
||||||
++N;
|
++N;
|
||||||
#if 1
|
|
||||||
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
|
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
|
||||||
#else
|
|
||||||
result =((subs[N] == -1) ? value_type(what.prefix().first, what.prefix().second) : value_type(what[subs[N]].first, what[subs[N]].second));
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(what.prefix().first != what[0].second)
|
if(what.prefix().first != what[0].second)
|
||||||
@ -155,23 +143,15 @@ public:
|
|||||||
if(regex_search(last_end, end, what, *pre, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags)))
|
if(regex_search(last_end, end, what, *pre, ((what[0].first == what[0].second) ? flags | regex_constants::match_not_initial_null : flags)))
|
||||||
{
|
{
|
||||||
N =0;
|
N =0;
|
||||||
#if 1
|
|
||||||
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
|
result =((subs[N] == -1) ? what.prefix() : what[subs[N]]);
|
||||||
#else
|
|
||||||
result =((subs[N] == -1) ? value_type(what.prefix().first, what.prefix().second) : value_type(what[subs[N]].first, what[subs[N]].second));
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if((last_end != end) && (subs[0] == -1))
|
else if((last_end != end) && (subs[0] == -1))
|
||||||
{
|
{
|
||||||
N =-1;
|
N =-1;
|
||||||
#if 1
|
|
||||||
result.first = last_end;
|
result.first = last_end;
|
||||||
result.second = end;
|
result.second = end;
|
||||||
result.matched = (last_end != end);
|
result.matched = (last_end != end);
|
||||||
#else
|
|
||||||
result = value_type(last_end, end);
|
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -189,11 +169,7 @@ private:
|
|||||||
typedef shared_ptr<impl> pimpl;
|
typedef shared_ptr<impl> pimpl;
|
||||||
public:
|
public:
|
||||||
typedef basic_regex<charT, traits, Allocator> regex_type;
|
typedef basic_regex<charT, traits, Allocator> regex_type;
|
||||||
#if 1
|
|
||||||
typedef sub_match<BidirectionalIterator> value_type;
|
typedef sub_match<BidirectionalIterator> value_type;
|
||||||
#else
|
|
||||||
typedef std::basic_string<charT> value_type;
|
|
||||||
#endif
|
|
||||||
typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type
|
typedef typename re_detail::regex_iterator_traits<BidirectionalIterator>::difference_type
|
||||||
difference_type;
|
difference_type;
|
||||||
typedef const value_type* pointer;
|
typedef const value_type* pointer;
|
||||||
|
@ -83,6 +83,58 @@ struct sub_match : public std::pair<BidiIterator, BidiIterator>
|
|||||||
bool operator>=(const sub_match& that)const
|
bool operator>=(const sub_match& that)const
|
||||||
{ return compare(that) >= 0; }
|
{ return compare(that) >= 0; }
|
||||||
|
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
typedef std::vector<sub_match<BidiIterator> > capture_sequence_type;
|
||||||
|
|
||||||
|
const capture_sequence_type& captures()const
|
||||||
|
{
|
||||||
|
if(!m_captures)
|
||||||
|
m_captures.reset(new capture_sequence_type());
|
||||||
|
return *m_captures;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Private implementation API: DO NOT USE!
|
||||||
|
//
|
||||||
|
capture_sequence_type& get_captures()const
|
||||||
|
{
|
||||||
|
if(!m_captures)
|
||||||
|
m_captures.reset(new capture_sequence_type());
|
||||||
|
return *m_captures;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable boost::scoped_ptr<capture_sequence_type> m_captures;
|
||||||
|
public:
|
||||||
|
|
||||||
|
#endif
|
||||||
|
sub_match(const sub_match& that, bool
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
deep_copy
|
||||||
|
#endif
|
||||||
|
= true
|
||||||
|
)
|
||||||
|
: std::pair<BidiIterator, BidiIterator>(that),
|
||||||
|
matched(that.matched)
|
||||||
|
{
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
if(that.m_captures)
|
||||||
|
if(deep_copy)
|
||||||
|
m_captures.reset(new capture_sequence_type(*(that.m_captures)));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
sub_match& operator=(const sub_match& that)
|
||||||
|
{
|
||||||
|
this->first = that.first;
|
||||||
|
this->second = that.second;
|
||||||
|
matched = that.matched;
|
||||||
|
#ifdef BOOST_REGEX_MATCH_EXTRA
|
||||||
|
if(that.m_captures)
|
||||||
|
get_captures() = *(that.m_captures);
|
||||||
|
#endif
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef BOOST_OLD_REGEX_H
|
#ifdef BOOST_OLD_REGEX_H
|
||||||
//
|
//
|
||||||
// the following are deprecated, do not use!!
|
// the following are deprecated, do not use!!
|
||||||
|
@ -55,6 +55,21 @@ regbase::regbase(const regbase& b)
|
|||||||
|
|
||||||
namespace re_detail{
|
namespace re_detail{
|
||||||
|
|
||||||
|
//
|
||||||
|
// error checking API:
|
||||||
|
//
|
||||||
|
BOOST_REGEX_DECL void BOOST_REGEX_CALL verify_options(boost::regex::flag_type /*ef*/, match_flag_type mf)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// can't mix match_extra with POSIX matching rules:
|
||||||
|
//
|
||||||
|
if((mf & match_extra) && (mf & match_posix))
|
||||||
|
{
|
||||||
|
std::logic_error msg("Usage Error: Can't mix regular expression captures with POSIX matching rules");
|
||||||
|
throw_exception(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
#ifdef BOOST_REGEX_HAS_MS_STACK_GUARD
|
||||||
|
|
||||||
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
BOOST_REGEX_DECL void BOOST_REGEX_CALL reset_stack_guard_page()
|
||||||
|
23
test/Jamfile
23
test/Jamfile
@ -4,6 +4,7 @@ subproject libs/regex/test ;
|
|||||||
|
|
||||||
# bring in the rules for testing
|
# bring in the rules for testing
|
||||||
import testing ;
|
import testing ;
|
||||||
|
subinclude libs/regex/test/captures ;
|
||||||
|
|
||||||
#
|
#
|
||||||
# this template defines the options common to
|
# this template defines the options common to
|
||||||
@ -130,6 +131,24 @@ test-suite regex
|
|||||||
]
|
]
|
||||||
[ compile concepts/wide_concept_check.cpp
|
[ compile concepts/wide_concept_check.cpp
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[ run
|
||||||
|
# sources
|
||||||
|
captures/captures_test.cpp
|
||||||
|
<template>../build/regex-options
|
||||||
|
# dependencies
|
||||||
|
<lib>captures/boost_regex_extra
|
||||||
|
<lib>../../test/build/boost_test_exec_monitor
|
||||||
|
: # additional args
|
||||||
|
: # test-files
|
||||||
|
: # requirements
|
||||||
|
<threading>multi
|
||||||
|
<define>BOOST_REGEX_MATCH_EXTRA=1
|
||||||
|
<define>BOOST_REGEX_NO_LIB=1
|
||||||
|
: # test name
|
||||||
|
captures_test
|
||||||
|
]
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -139,3 +158,7 @@ test-suite regex
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
16
test/captures/Jamfile
Normal file
16
test/captures/Jamfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# copyright John Maddock 2003
|
||||||
|
|
||||||
|
subproject libs/regex/test/captures ;
|
||||||
|
|
||||||
|
EX_SOURCES = c_regex_traits c_regex_traits_common cpp_regex_traits
|
||||||
|
cregex fileiter posix_api regex regex_debug
|
||||||
|
regex_synch w32_regex_traits wide_posix_api instances winstances ;
|
||||||
|
|
||||||
|
lib boost_regex_extra : ../../src/$(EX_SOURCES).cpp <template>../../build/regex-options
|
||||||
|
:
|
||||||
|
<define>BOOST_REGEX_MATCH_EXTRA=1
|
||||||
|
:
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
90
test/captures/captures_test.cpp
Normal file
90
test/captures/captures_test.cpp
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
#include <boost/regex.hpp>
|
||||||
|
#include <boost/test/test_tools.hpp>
|
||||||
|
#include <boost/array.hpp>
|
||||||
|
|
||||||
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void test_captures(const std::string& regx, const std::string& text, T& expected)
|
||||||
|
{
|
||||||
|
boost::regex e(regx);
|
||||||
|
boost::smatch what;
|
||||||
|
if(boost::regex_match(text, what, e, boost::match_extra))
|
||||||
|
{
|
||||||
|
unsigned i, j;
|
||||||
|
BOOST_TEST(what.size() == ARRAY_SIZE(expected));
|
||||||
|
for(i = 0; i < what.size(); ++i)
|
||||||
|
{
|
||||||
|
BOOST_TEST(what.captures(i).size() <= ARRAY_SIZE(expected[i]));
|
||||||
|
for(j = 0; j < what.captures(i).size(); ++j)
|
||||||
|
{
|
||||||
|
BOOST_TEST(what.captures(i)[j] == expected[i][j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_main(int , char* [])
|
||||||
|
{
|
||||||
|
typedef const char* pchar;
|
||||||
|
pchar e1[4][5] =
|
||||||
|
{
|
||||||
|
{ "aBBcccDDDDDeeeeeeee", },
|
||||||
|
{ "a", "BB", "ccc", "DDDDD", "eeeeeeee", },
|
||||||
|
{ "a", "ccc", "eeeeeeee", },
|
||||||
|
{ "BB", "DDDDD", },
|
||||||
|
};
|
||||||
|
test_captures("(([[:lower:]]+)|([[:upper:]]+))+", "aBBcccDDDDDeeeeeeee", e1);
|
||||||
|
pchar e2[4][2] =
|
||||||
|
{
|
||||||
|
{ "abd" },
|
||||||
|
{ "b", "" },
|
||||||
|
{ "" },
|
||||||
|
};
|
||||||
|
test_captures("a(b+|((c)*))+d", "abd", e2);
|
||||||
|
pchar e3[3][1] =
|
||||||
|
{
|
||||||
|
{ "abcbar" },
|
||||||
|
{ "abc" },
|
||||||
|
};
|
||||||
|
test_captures("(.*)bar|(.*)bah", "abcbar", e3);
|
||||||
|
pchar e4[3][1] =
|
||||||
|
{
|
||||||
|
{ "abcbah" },
|
||||||
|
{ 0, },
|
||||||
|
{ "abc" },
|
||||||
|
};
|
||||||
|
test_captures("(.*)bar|(.*)bah", "abcbah", e4);
|
||||||
|
pchar e5[2][16] =
|
||||||
|
{
|
||||||
|
{ "now is the time for all good men to come to the aid of the party" },
|
||||||
|
{ "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" },
|
||||||
|
};
|
||||||
|
test_captures("^(?:(\\w+)|(?>\\W+))*$", "now is the time for all good men to come to the aid of the party", e5);
|
||||||
|
pchar e6[2][16] =
|
||||||
|
{
|
||||||
|
{ "now is the time for all good men to come to the aid of the party" },
|
||||||
|
{ "now", "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the", "party" },
|
||||||
|
};
|
||||||
|
test_captures("^(?>(\\w+)\\W*)*$", "now is the time for all good men to come to the aid of the party", e6);
|
||||||
|
pchar e7[4][14] =
|
||||||
|
{
|
||||||
|
{ "now is the time for all good men to come to the aid of the party" },
|
||||||
|
{ "now" },
|
||||||
|
{ "is", "the", "time", "for", "all", "good", "men", "to", "come", "to", "the", "aid", "of", "the" },
|
||||||
|
{ "party" },
|
||||||
|
};
|
||||||
|
test_captures("^(\\w+)\\W+(?>(\\w+)\\W+)*(\\w+)$", "now is the time for all good men to come to the aid of the party", e7);
|
||||||
|
pchar e8[5][9] =
|
||||||
|
{
|
||||||
|
{ "now is the time for all good men to come to the aid of the party" } ,
|
||||||
|
{ "now" },
|
||||||
|
{ "is", "for", "men", "to", "of" },
|
||||||
|
{ "the", "time", "all", "good", "to", "come", "the", "aid", "the" },
|
||||||
|
{ "party" },
|
||||||
|
};
|
||||||
|
test_captures("^(\\w+)\\W+(?>(\\w+)\\W+(?:(\\w+)\\W+){0,2})*(\\w+)$", "now is the time for all good men to come to the aid of the party", e8);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -88,6 +88,7 @@ flag_info flag_data[] = {
|
|||||||
{ BOOST_RE_STR("match_continuous"), 16, match_continuous, 3 },
|
{ BOOST_RE_STR("match_continuous"), 16, match_continuous, 3 },
|
||||||
{ BOOST_RE_STR("match_partial"), 13, match_partial, 3 },
|
{ BOOST_RE_STR("match_partial"), 13, match_partial, 3 },
|
||||||
{ BOOST_RE_STR("match_nosubs"), 12, match_nosubs, 3 },
|
{ BOOST_RE_STR("match_nosubs"), 12, match_nosubs, 3 },
|
||||||
|
{ BOOST_RE_STR("match_single_line"), 17, match_single_line, 3 },
|
||||||
|
|
||||||
{ BOOST_RE_STR("format_all"), 10, format_all, 3 },
|
{ BOOST_RE_STR("format_all"), 10, format_all, 3 },
|
||||||
{ BOOST_RE_STR("format_sed"), 10, format_sed, 3 },
|
{ BOOST_RE_STR("format_sed"), 10, format_sed, 3 },
|
||||||
|
@ -283,7 +283,7 @@ struct debug_iterator
|
|||||||
|
|
||||||
debug_iterator(T c, T f, T l)
|
debug_iterator(T c, T f, T l)
|
||||||
: cur(c), first(f), last(l) {}
|
: cur(c), first(f), last(l) {}
|
||||||
debug_iterator() : cur(), first(), last() {}
|
debug_iterator(int = 0) : cur(), first(), last() {}
|
||||||
debug_iterator(const debug_iterator& x)
|
debug_iterator(const debug_iterator& x)
|
||||||
: cur(x.cur), first(x.first), last(x.last) {}
|
: cur(x.cur), first(x.first), last(x.last) {}
|
||||||
debug_iterator& operator=(const debug_iterator& x)
|
debug_iterator& operator=(const debug_iterator& x)
|
||||||
|
@ -292,6 +292,22 @@ ab$ ab -1 -1
|
|||||||
ab$ abxx -1 -1
|
ab$ abxx -1 -1
|
||||||
ab$ ab\nzz 0 2
|
ab$ ab\nzz 0 2
|
||||||
|
|
||||||
|
; line anchors, single line mode
|
||||||
|
- match_default normal match_single_line REG_NO_POSIX_TEST
|
||||||
|
^ab ab 0 2
|
||||||
|
^ab xxabxx -1 -1
|
||||||
|
^ab xx\nabzz -1 -1
|
||||||
|
ab$ ab 0 2
|
||||||
|
ab$ abxx -1 -1
|
||||||
|
ab$ ab\nzz -1 -1
|
||||||
|
- match_default match_not_bol match_not_eol normal REG_NO_POSIX_TEST match_single_line
|
||||||
|
^ab ab -1 -1
|
||||||
|
^ab xxabxx -1 -1
|
||||||
|
^ab xx\nabzz -1 -1
|
||||||
|
ab$ ab -1 -1
|
||||||
|
ab$ abxx -1 -1
|
||||||
|
ab$ ab\nzz -1 -1
|
||||||
|
|
||||||
; back references
|
; back references
|
||||||
- match_default normal REG_PERL
|
- match_default normal REG_PERL
|
||||||
a(b)\2c !
|
a(b)\2c !
|
||||||
|
Reference in New Issue
Block a user