2003-05-17 11:45:48 +00:00
|
|
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
|
|
<html>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<head>
|
|
|
|
|
<title>Boost.Regex: class match_results</title>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<meta content="HTML Tidy, see www.w3.org" name="generator">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<LINK href="../../../boost.css" type="text/css" rel="stylesheet"></head>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<body>
|
|
|
|
|
<p></p>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<table id="Table1" cellSpacing="1" cellPadding="1" width="100%" border="0">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="300">
|
|
|
|
|
<h3><A href="../../../index.htm"><IMG height="86" alt="C++ Boost" src="../../../c++boost.gif" width="277" border="0"></A></h3>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
</td>
|
|
|
|
|
<td width="353">
|
|
|
|
|
<h1 align="center">Boost.Regex</h1>
|
|
|
|
|
<h2 align="center">class match_results</h2>
|
|
|
|
|
</td>
|
|
|
|
|
<td width="50">
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<h3><A href="index.html"><IMG height="45" alt="Boost.Regex Index" src="uarrow.gif" width="43" border="0"></A></h3>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
<br>
|
|
|
|
|
<br>
|
|
|
|
|
<hr>
|
|
|
|
|
<h3>Contents</h3>
|
|
|
|
|
<dl class="index">
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<dt><A href="#synopsis">Synopsis</A> <dt><A href="#description">Description</A> </dt>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
</dl>
|
|
|
|
|
<h3><a name="synopsis"></a>Synopsis</h3>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<p>#include <<A href="../../../boost/regex.hpp">boost/regex.hpp</A>></p>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>Regular expressions are different from many simple pattern-matching algorithms
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
class <i>match_results</i> that acts as an indexed collection of sub-expression
|
2003-12-13 12:28:48 +00:00
|
|
|
|
matches, each sub-expression match being contained in an object of type <i><A href="sub_match.html">
|
|
|
|
|
sub_match</A></i> .</p>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>Template class match_results denotes a collection of character sequences
|
|
|
|
|
representing the result of a regular expression match. Objects of type
|
2003-12-13 12:28:48 +00:00
|
|
|
|
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
|
|
|
|
|
iterator <A href="regex_iterator.html">regex_iterator</A> . Storage for
|
2003-10-21 11:18:40 +00:00
|
|
|
|
the collection is allocated and freed as necessary by the member functions of
|
|
|
|
|
class match_results.</p>
|
|
|
|
|
<p>The template class match_results conforms to the requirements of a Sequence, as
|
|
|
|
|
specified in (lib.sequence.reqmts), except that only operations defined for
|
|
|
|
|
const-qualified Sequences are supported.</p>
|
|
|
|
|
<p>Class template match_results is most commonly used as one of the typedefs
|
|
|
|
|
cmatch, wcmatch, smatch, or wsmatch:</p>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<pre>template <class BidirectionalIterator,
|
2003-05-17 11:45:48 +00:00
|
|
|
|
class Allocator = allocator<sub_match<BidirectionalIterator> >
|
|
|
|
|
class match_results;
|
|
|
|
|
|
|
|
|
|
typedef match_results<const char*> cmatch;
|
|
|
|
|
typedef match_results<const wchar_t*> wcmatch;
|
|
|
|
|
typedef match_results<string::const_iterator> smatch;
|
|
|
|
|
typedef match_results<wstring::const_iterator> wsmatch;
|
|
|
|
|
|
|
|
|
|
template <class BidirectionalIterator,
|
|
|
|
|
class Allocator = allocator<sub_match<BidirectionalIterator> >
|
|
|
|
|
class match_results
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef sub_match<BidirectionalIterator> value_type;
|
|
|
|
|
typedef const value_type& const_reference;
|
|
|
|
|
typedef const_reference reference;
|
|
|
|
|
typedef implementation defined const_iterator;
|
|
|
|
|
typedef const_iterator iterator;
|
|
|
|
|
typedef typename iterator_traits<BidirectionalIterator>::difference_type difference_type;
|
|
|
|
|
typedef typename Allocator::size_type size_type;
|
|
|
|
|
typedef Allocator allocator_type;
|
|
|
|
|
typedef typename iterator_traits<BidirectionalIterator>::value_type char_type;
|
|
|
|
|
typedef basic_string<char_type> string_type;
|
|
|
|
|
|
|
|
|
|
// construct/copy/destroy:
|
2003-12-13 12:28:48 +00:00
|
|
|
|
explicit <A href="#c1" >match_results</A>(const Allocator& a = Allocator());
|
|
|
|
|
<A href="#c2" >match_results</A>(const match_results& m);
|
|
|
|
|
<A href="#c3" >match_results</A>& <A href="#c3" >operator</A>=(const match_results& m);
|
2003-05-17 11:45:48 +00:00
|
|
|
|
~match_results();
|
|
|
|
|
|
|
|
|
|
// size:
|
2003-12-13 12:28:48 +00:00
|
|
|
|
size_type <A href="#m1" >size</A>() const;
|
|
|
|
|
size_type <A href="#m2" >max_size</A>() const;
|
|
|
|
|
bool <A href="#m3" >empty</A>() const;
|
2003-05-17 11:45:48 +00:00
|
|
|
|
// element access:
|
2003-12-13 12:28:48 +00:00
|
|
|
|
difference_type <A href="#m4" >length</A>(int sub = 0) const;
|
|
|
|
|
difference_type <A href="#m5" >position</A>(unsigned int sub = 0) const;
|
|
|
|
|
string_type <A href="#m6" >str</A>(int sub = 0) const;
|
|
|
|
|
const_reference <A href="#m7" >operator</A>[](int n) const;
|
2003-05-17 11:45:48 +00:00
|
|
|
|
|
2003-12-13 12:28:48 +00:00
|
|
|
|
const_reference <A href="#m8" >prefix</A>() const;
|
2003-05-17 11:45:48 +00:00
|
|
|
|
|
2003-12-13 12:28:48 +00:00
|
|
|
|
const_reference <A href="#m9" >suffix</A>() const;
|
|
|
|
|
const_iterator <A href="#m10" >begin</A>() const;
|
|
|
|
|
const_iterator <A href="#m11" >end</A>() const;
|
2003-05-17 11:45:48 +00:00
|
|
|
|
// format:
|
|
|
|
|
template <class OutputIterator>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
OutputIterator <A href="#m12" >format</A>(OutputIterator out,
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const string_type& fmt,
|
|
|
|
|
match_flag_type flags = format_default) const;
|
2003-12-13 12:28:48 +00:00
|
|
|
|
string_type <A href="#m13" >format</A>(const string_type& fmt,
|
2003-05-17 11:45:48 +00:00
|
|
|
|
match_flag_type flags = format_default) const;
|
|
|
|
|
|
2003-12-13 12:28:48 +00:00
|
|
|
|
allocator_type <A href="#m14" >get_allocator</A>() const;
|
|
|
|
|
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
|
|
|
|
|
|
2003-05-17 11:45:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <class BidirectionalIterator, class Allocator>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
bool <A href="#n1" >operator</A> == (const match_results<BidirectionalIterator, Allocator>& m1,
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const match_results<BidirectionalIterator, Allocator>& m2);
|
|
|
|
|
template <class BidirectionalIterator, class Allocator>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
bool <A href="#n2" >operator</A> != (const match_results<BidirectionalIterator, Allocator>& m1,
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const match_results<BidirectionalIterator, Allocator>& m2);
|
|
|
|
|
|
|
|
|
|
template <class charT, class traits, class BidirectionalIterator, class Allocator>
|
|
|
|
|
basic_ostream<charT, traits>&
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<A href="#n3" >operator</A> << (basic_ostream<charT, traits>& os,
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const match_results<BidirectionalIterator, Allocator>& m);
|
|
|
|
|
|
|
|
|
|
template <class BidirectionalIterator, class Allocator>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
void <A href="#n4" >swap</A>(match_results<BidirectionalIterator, Allocator>& m1,
|
2003-05-17 11:45:48 +00:00
|
|
|
|
match_results<BidirectionalIterator, Allocator>& m2);
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<h3><a name="description"></a>Description</h3>
|
|
|
|
|
<h4>match_results constructors</h4>
|
|
|
|
|
<p>In all <code>match_results</code> constructors, a copy of the Allocator
|
|
|
|
|
argument is used for any memory allocation performed by the constructor or
|
|
|
|
|
member functions during the lifetime of the object.</p>
|
|
|
|
|
<pre><A name=c1></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
match_results(const Allocator& a = Allocator());
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Constructs an object of class match_results. The postconditions
|
|
|
|
|
of this function are indicated in the table:</p>
|
|
|
|
|
<p align="center"></p>
|
|
|
|
|
<center>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<table id="Table2" cellSpacing="1" cellPadding="7" width="624" border="1">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%"><b></b>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p><b>Element</b></p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%"><b></b>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p><b>Value</b></p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>empty()</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>true</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>size()</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>0</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>str()</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>basic_string<charT>()</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
</tbody></table>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
</center>
|
|
|
|
|
<p> </p>
|
|
|
|
|
<pre><A name=c2></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
match_results(const match_results& m);
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Constructs an object of class match_results, as a copy of m.</p>
|
|
|
|
|
<pre><A name=c3></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
match_results& operator=(const match_results& m);
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Assigns m to *this. The postconditions of this function are
|
|
|
|
|
indicated in the table:</p>
|
|
|
|
|
<p align="center"></p>
|
|
|
|
|
<center>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<table id="Table3" cellSpacing="1" cellPadding="7" width="624" border="1">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<tbody>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%"><b></b>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p><b>Element</b></p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%"><b></b>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p><b>Value</b></p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>empty()</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m.empty().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>size()</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m.size().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>str(n)</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m.str(n) for all integers n < m.size().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>prefix()</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m.prefix().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>suffix()</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m.suffix().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>(*this)[n]</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m[n] for all integers n < m.size().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>length(n)</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m.length(n) for all integers n < m.size().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>position(n)</p>
|
|
|
|
|
</td>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<td vAlign="top" width="50%">
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<p>m.position(n) for all integers n < m.size().</p>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
</tbody></table>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
</center>
|
|
|
|
|
<h4>match_results size</h4>
|
|
|
|
|
<pre><A name=m1></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
size_type size()const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns the number of sub_match elements stored in *this; that
|
|
|
|
|
is the number of marked sub-expressions in the regular expression that was
|
|
|
|
|
matched plus one.</p>
|
|
|
|
|
<pre><A name=m2></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
size_type max_size()const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns the maximum number of sub_match elements that can be
|
|
|
|
|
stored in *this.</p>
|
|
|
|
|
<pre><A name=m3></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
bool empty()const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns <code>size() == 0</code>.</p>
|
|
|
|
|
<h4>match_results element access</h4>
|
|
|
|
|
<pre><A name=m4></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
difference_type length(int sub = 0)const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns the length of sub-expression <EM>sub</EM>, that is to
|
|
|
|
|
say: <code>(*this)[sub].length()</code>.</p>
|
|
|
|
|
<pre><A name=m5></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
difference_type position(unsigned int sub = 0)const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns the starting location of sub-expression <EM>sub</EM>,
|
|
|
|
|
or -1 if <EM>sub</EM> was not matched <code>.</code></p>
|
|
|
|
|
<pre><A name=m6></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
string_type str(int sub = 0)const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns sub-expression <EM>sub</EM> as a string: <code>string_type((*this)[sub]).</code></p>
|
|
|
|
|
<pre><A name=m7></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const_reference operator[](int n) const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns a reference to the <code>sub_match</code> object
|
|
|
|
|
representing the character sequence that matched marked sub-expression <i>n</i>.
|
|
|
|
|
If <code>n == 0</code> then returns a reference to a <code>sub_match</code> object
|
|
|
|
|
representing the character sequence that matched the whole regular
|
|
|
|
|
expression. If <EM>n</EM> is out of range, or if <EM>n</EM> is an
|
|
|
|
|
unmatched sub-expression, then returns a sub_match object whose <EM>matched</EM>
|
|
|
|
|
member is <EM>false</EM>.</p>
|
|
|
|
|
<pre><A name=m8></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const_reference prefix()const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns a reference to the <code>sub_match</code> object
|
|
|
|
|
representing the character sequence from the start of the string being
|
|
|
|
|
matched/searched, to the start of the match found.</p>
|
|
|
|
|
<pre><A name=m9></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const_reference suffix()const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns a reference to the <code>sub_match</code> object
|
|
|
|
|
representing the character sequence from the end of the match found to the end
|
|
|
|
|
of the string being matched/searched.</p>
|
|
|
|
|
<pre><A name=m10></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const_iterator begin()const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns a starting iterator that enumerates over all the marked
|
|
|
|
|
sub-expression matches stored in *this.</p>
|
|
|
|
|
<pre><A name=m11></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
const_iterator end()const;
|
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns a terminating iterator that enumerates over all the
|
|
|
|
|
marked sub-expression matches stored in *this.</p>
|
|
|
|
|
<h4><A name="format"></A>match_results reformatting</h4>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<pre>template <class OutputIterator>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
OutputIterator format(OutputIterator out,
|
|
|
|
|
const string_type& fmt,
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
2003-05-17 11:45:48 +00:00
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Requires:</b> The type OutputIterator conforms to the Output Iterator
|
|
|
|
|
requirements (24.1.2).</p>
|
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Copies the character sequence <i>[fmt.begin(), fmt.end())</i> to
|
|
|
|
|
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
|
|
|
|
|
sequence of characters within *this to which it refers. The bitmasks specified
|
2003-12-13 12:28:48 +00:00
|
|
|
|
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
|
2003-10-21 11:18:40 +00:00
|
|
|
|
the format used by ECMA-262, ECMAScript Language Specification, Chapter 15 part
|
|
|
|
|
5.4.11 String.prototype.replace.</p>
|
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Returns:</b> <i>out</i>.</p>
|
|
|
|
|
<pre><A name=m13></A>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
string_type format(const string_type& fmt,
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<A href="match_flag_type.html" >match_flag_type</A> flags = format_default);
|
2003-05-17 11:45:48 +00:00
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<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
|
|
|
|
|
the character(s) it represents, or the sequence of characters within *this to
|
2003-12-13 12:28:48 +00:00
|
|
|
|
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
|
|
|
|
|
are recognized</A>, by default this is the format used by ECMA-262,
|
2003-10-21 11:18:40 +00:00
|
|
|
|
ECMAScript Language Specification, Chapter 15 part 5.4.11
|
|
|
|
|
String.prototype.replace.</p>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<H4>Allocator access</H4>
|
|
|
|
|
<pre>allocator_type get_allocator()const;
|
2003-05-17 11:45:48 +00:00
|
|
|
|
</pre>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Returns a copy of the Allocator that was passed to the object's
|
|
|
|
|
constructor.</p>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<H4><A name="m15"></A>Swap</H4>
|
|
|
|
|
<PRE>void swap(match_results& that);
|
|
|
|
|
</PRE>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Effects:</b> Swaps the contents of the two sequences.</p>
|
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Postcondition:</b> <code>*this</code> contains the sequence of matched
|
|
|
|
|
sub-expressions that were in <code>that</code>, <code>that</code> contains the
|
|
|
|
|
sequence of matched sub-expressions that were in <code>*this</code>.</p>
|
|
|
|
|
<b></b>
|
|
|
|
|
<p><b>Complexity:</b> constant time.</p>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<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>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<h4>match_results non-members</h4>
|
|
|
|
|
<PRE><A name=n1></A>template <class BidirectionalIterator, class Allocator>
|
|
|
|
|
bool operator == (const match_results<BidirectionalIterator, Allocator>& m1,
|
|
|
|
|
const match_results<BidirectionalIterator, Allocator>& m2);</PRE>
|
|
|
|
|
<P><B>Effects:</B> Compares the two sequences for equality.</P>
|
|
|
|
|
<PRE><A name=n2></A>template <class BidirectionalIterator, class Allocator>
|
|
|
|
|
bool operator != (const match_results<BidirectionalIterator, Allocator>& m1,
|
|
|
|
|
const match_results<BidirectionalIterator, Allocator>& m2);</PRE>
|
|
|
|
|
<P><B>Effects:</B> Compares the two sequences for inequality.</P>
|
|
|
|
|
<PRE><A name=n3></A>template <class charT, class traits, class BidirectionalIterator, class Allocator>
|
|
|
|
|
basic_ostream<charT, traits>&
|
|
|
|
|
operator << (basic_ostream<charT, traits>& os,
|
|
|
|
|
const match_results<BidirectionalIterator, Allocator>& m);</PRE>
|
|
|
|
|
<P><B>Effects:</B> Writes the contents of <EM>m</EM> to the stream <EM>os</EM> as
|
|
|
|
|
if by calling <code>os << m.str();</code> Returns <EM>os</EM>..</P>
|
|
|
|
|
<PRE><A name=n4></A>template <class BidirectionalIterator, class Allocator>
|
|
|
|
|
void swap(match_results<BidirectionalIterator, Allocator>& m1,
|
|
|
|
|
match_results<BidirectionalIterator, Allocator>& m2);</PRE>
|
|
|
|
|
<P><B>Effects:</B> Swaps the contents of the two sequences.</P>
|
|
|
|
|
<p></p>
|
|
|
|
|
<hr>
|
|
|
|
|
<p>Revised
|
|
|
|
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
2003-10-24 10:51:38 +00:00
|
|
|
|
24 Oct 2003
|
2003-10-21 11:18:40 +00:00
|
|
|
|
<!--webbot bot="Timestamp" endspan i-checksum="39359" --></p>
|
2003-10-24 10:51:38 +00:00
|
|
|
|
<p><i><EFBFBD> Copyright John Maddock 1998-
|
2003-12-13 12:28:48 +00:00
|
|
|
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%Y" startspan --> 2003<!--webbot bot="Timestamp" endspan i-checksum="39359" --></i></p>
|
2003-10-24 10:51:38 +00:00
|
|
|
|
<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>
|
2003-10-21 11:18:40 +00:00
|
|
|
|
</body>
|
2003-05-17 11:45:48 +00:00
|
|
|
|
</html>
|
2003-12-13 12:28:48 +00:00
|
|
|
|
|