2000-09-26 11:48:28 +00:00
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type"
|
|
|
|
content="text/html; charset=iso-8859-1">
|
|
|
|
<meta name="Template"
|
|
|
|
content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot">
|
|
|
|
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
|
|
|
|
<title>Regex++, RegEx Class Reference</title>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body bgcolor="#FFFFFF" link="#0000FF" vlink="#800080">
|
|
|
|
|
|
|
|
<p> </p>
|
|
|
|
|
|
|
|
<table border="0" cellpadding="7" cellspacing="0" width="100%">
|
|
|
|
<tr>
|
2001-09-30 10:30:14 +00:00
|
|
|
<td valign="top"><h3><img src="../../c++boost.gif"
|
|
|
|
alt="C++ Boost" width="276" height="86"></h3>
|
2000-09-26 11:48:28 +00:00
|
|
|
</td>
|
2001-09-30 10:30:14 +00:00
|
|
|
<td valign="top"><h3 align="center">Regex++, RegEx Class
|
|
|
|
Reference. </h3>
|
|
|
|
<p align="left"><i>Copyright (c) 1998-2001 </i></p>
|
|
|
|
<p align="left"><i>Dr John Maddock</i></p>
|
|
|
|
<p align="left"><i>Permission to use, copy, modify,
|
|
|
|
distribute and sell this software and its documentation
|
|
|
|
for any purpose is hereby granted without fee, provided
|
|
|
|
that the above copyright notice appear in all copies and
|
|
|
|
that both that copyright notice and this permission
|
|
|
|
notice appear in supporting documentation. Dr John
|
|
|
|
Maddock makes no representations about the suitability of
|
|
|
|
this software for any purpose. It is provided "as is"
|
|
|
|
without express or implied warranty.</i></p>
|
2000-09-26 11:48:28 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
<h3><a name="RegEx"></a><i>Class RegEx</i></h3>
|
|
|
|
|
|
|
|
<p>#include <boost/cregex.hpp> </p>
|
|
|
|
|
|
|
|
<p>The class RegEx provides a high level simplified interface to
|
|
|
|
the regular expression library, this class only handles narrow
|
|
|
|
character strings, and regular expressions always follow the
|
|
|
|
"normal" syntax - that is the same as the standard
|
|
|
|
POSIX extended syntax, but with locale specific collation
|
|
|
|
disabled, and escape characters inside character set declarations
|
|
|
|
are allowed. </p>
|
|
|
|
|
|
|
|
<pre><b>typedef</b> <b>bool</b> (*GrepCallback)(<b>const</b> RegEx& expression);
|
|
|
|
<b>typedef</b> <b>bool</b> (*GrepFileCallback)(<b>const</b> <b>char</b>* file, <b>const</b> RegEx& expression);
|
|
|
|
<b>typedef</b> <b>bool</b> (*FindFilesCallback)(<b>const</b> <b>char</b>* file);
|
|
|
|
|
|
|
|
<b>class</b> RegEx
|
|
|
|
{
|
|
|
|
<b>public</b>:
|
|
|
|
RegEx();
|
|
|
|
RegEx(<b>const</b> RegEx& o);
|
|
|
|
~RegEx();
|
|
|
|
RegEx(<b>const</b> <b>char</b>* c, <b>bool</b> icase = <b>false</b>);
|
|
|
|
<strong>explicit</strong> RegEx(<b>const</b> std::string& s, <b>bool</b> icase = <b>false</b>);
|
|
|
|
RegEx& <b>operator</b>=(<b>const</b> RegEx& o);
|
|
|
|
RegEx& <b>operator</b>=(<b>const</b> <b>char</b>* p);
|
|
|
|
RegEx& <b>operator</b>=(<b>const</b> std::string& s);
|
|
|
|
<b>unsigned</b> <b>int</b> SetExpression(<b>const</b> <b>char</b>* p, <b>bool</b> icase = <b>false</b>);
|
|
|
|
<b>unsigned</b> <b>int</b> SetExpression(<b>const</b> std::string& s, <b>bool</b> icase = <b>false</b>);
|
|
|
|
std::string Expression()<b>const</b>;
|
|
|
|
<font color="#000080"><i>//
|
|
|
|
</i> <i>// now matching operators: </i>
|
|
|
|
<i>// </i></font>
|
|
|
|
<b>bool</b> Match(<b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>bool</b> Match(<b>const</b> std::string& s, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>bool</b> Search(<b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>bool</b> Search(<b>const</b> std::string& s, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> Grep(GrepCallback cb, <b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> Grep(GrepCallback cb, <b>const</b> std::string& s, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> Grep(std::vector<std::string>& v, <b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> Grep(std::vector<std::string>& v, <b>const</b> std::string& s, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> Grep(std::vector<<b>unsigned</b> <b>int</b>>& v, <b>const</b> <b>char</b>* p, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> Grep(std::vector<<b>unsigned</b> <b>int</b>>& v, <b>const</b> std::string& s, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> GrepFiles(GrepFileCallback cb, <b>const</b> <b>char</b>* files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> GrepFiles(GrepFileCallback cb, <b>const</b> std::string& files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> FindFiles(FindFilesCallback cb, <b>const</b> <b>char</b>* files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
<b>unsigned</b> <b>int</b> FindFiles(FindFilesCallback cb, <b>const</b> std::string& files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
std::string Merge(<b>const</b> std::string& in, <b>const</b> std::string& fmt, <b>bool</b> copy = <b>true</b>, <b>unsigned</b> <b>int</b> flags = match_default);
|
|
|
|
std::string Merge(<b>const</b> char* in, <b>const</b> char* fmt, <b>bool</b> copy = <b>true</b>, <b>unsigned int </b>flags = match_default);
|
|
|
|
<b>unsigned</b> Split(std::vector<std::string>& v, std::string& s, <b>unsigned</b> flags = match_default, <b>unsigned</b> max_count = ~0);
|
|
|
|
<font color="#000080"><i>//
|
|
|
|
</i> <i>// now operators for returning what matched in more detail:
|
|
|
|
</i> <i>//
|
|
|
|
</i></font> <b>unsigned</b> <b>int</b> Position(<b>int</b> i = 0)<b>const</b>;
|
|
|
|
<b>unsigned</b> <b>int</b> Length(<b>int</b> i = 0)<b>const</b>;
|
2002-01-07 13:03:50 +00:00
|
|
|
<strong>bool</strong> Matched(<strong>int</strong> i = 0)<strong>const</strong>;
|
2000-09-26 11:48:28 +00:00
|
|
|
<b>unsigned</b> <b>int</b> Line()<b>const</b>;
|
|
|
|
<b>unsigned int</b> Marks() const;
|
|
|
|
std::string What(<b>int</b> i)<b>const</b>;
|
|
|
|
std::string <b>operator</b>[](<b>int</b> i)<b>const</b> ;
|
2002-01-07 13:03:50 +00:00
|
|
|
|
|
|
|
<strong>static const unsigned int</strong> npos;
|
2000-09-26 11:48:28 +00:00
|
|
|
}; </pre>
|
|
|
|
|
|
|
|
<p>Member functions for class RegEx are defined as follows: <br>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<table border="0" cellpadding="7" cellspacing="0" width="100%">
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">RegEx();</td>
|
|
|
|
<td valign="top" width="42%">Default constructor,
|
|
|
|
constructs an instance of RegEx without any valid
|
|
|
|
expression.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
2001-05-17 11:55:55 +00:00
|
|
|
<td valign="top" width="43%">RegEx(<b>const</b>
|
|
|
|
RegEx& o);</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top" width="42%">Copy constructor, all the
|
|
|
|
properties of parameter <i>o</i> are copied.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">RegEx(<b>const</b> <b>char</b>*
|
|
|
|
c, <b>bool</b> icase = <b>false</b>);</td>
|
|
|
|
<td valign="top" width="42%">Constructs an instance of
|
|
|
|
RegEx, setting the expression to <i>c</i>, if <i>icase</i>
|
|
|
|
is <i>true</i> then matching is insensitive to case,
|
|
|
|
otherwise it is sensitive to case. Throws <i>bad_expression</i>
|
|
|
|
on failure.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">RegEx(<b>const</b> std::string&
|
|
|
|
s, <b>bool</b> icase = <b>false</b>);</td>
|
|
|
|
<td valign="top" width="42%">Constructs an instance of
|
|
|
|
RegEx, setting the expression to <i>s</i>, if <i>icase </i>is
|
|
|
|
<i>true</i> then matching is insensitive to case,
|
|
|
|
otherwise it is sensitive to case. Throws <i>bad_expression</i>
|
|
|
|
on failure.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">RegEx& <b>operator</b>=(<b>const</b>
|
|
|
|
RegEx& o);</td>
|
|
|
|
<td valign="top" width="42%">Default assignment operator.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">RegEx& <b>operator</b>=(<b>const</b>
|
|
|
|
<b>char</b>* p);</td>
|
|
|
|
<td valign="top" width="42%">Assignment operator,
|
|
|
|
equivalent to calling <i>SetExpression(p, false).</i>
|
|
|
|
Throws <i>bad_expression</i> on failure.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">RegEx& <b>operator</b>=(<b>const</b>
|
|
|
|
std::string& s);</td>
|
|
|
|
<td valign="top" width="42%">Assignment operator,
|
|
|
|
equivalent to calling <i>SetExpression(s, false).</i>
|
|
|
|
Throws <i>bad_expression</i> on failure.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
SetExpression(<b>constchar</b>* p, <b>bool</b> icase = <b>false</b>);</td>
|
|
|
|
<td valign="top" width="42%">Sets the current expression
|
|
|
|
to <i>p</i>, if <i>icase</i> is <i>true</i> then matching
|
|
|
|
is insensitive to case, otherwise it is sensitive to case.
|
|
|
|
Throws <i>bad_expression</i> on failure.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
SetExpression(<b>const</b> std::string& s, <b>bool</b>
|
|
|
|
icase = <b>false</b>);</td>
|
|
|
|
<td valign="top" width="42%">Sets the current expression
|
|
|
|
to <i>s</i>, if <i>icase</i> is <i>true</i> then matching
|
|
|
|
is insensitive to case, otherwise it is sensitive to case.
|
|
|
|
Throws <i>bad_expression</i> on failure.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">std::string Expression()<b>const</b>;</td>
|
|
|
|
<td valign="top" width="42%">Returns a copy of the
|
|
|
|
current regular expression.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>bool</b> Match(<b>const</b>
|
2001-05-17 11:55:55 +00:00
|
|
|
<b>char</b>* p, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default);</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top" width="42%">Attempts to match the
|
|
|
|
current expression against the text <i>p</i> using the
|
|
|
|
match flags <i>flags</i> - see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
Returns <i>true</i> if the expression matches the whole
|
|
|
|
of the input string.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>bool</b> Match(<b>const</b>
|
|
|
|
std::string& s, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default) ;</td>
|
|
|
|
<td valign="top" width="42%">Attempts to match the
|
|
|
|
current expression against the text <i>s</i> using the
|
|
|
|
match flags <i>flags</i> - see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
Returns <i>true</i> if the expression matches the whole
|
|
|
|
of the input string.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>bool</b> Search(<b>const</b>
|
2001-05-17 11:55:55 +00:00
|
|
|
<b>char</b>* p, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default);</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top" width="42%">Attempts to find a match for
|
|
|
|
the current expression somewhere in the text <i>p</i>
|
|
|
|
using the match flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
Returns <i>true</i> if the match succeeds.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>bool</b> Search(<b>const</b>
|
|
|
|
std::string& s, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default) ;</td>
|
|
|
|
<td valign="top" width="42%">Attempts to find a match for
|
|
|
|
the current expression somewhere in the text <i>s</i>
|
|
|
|
using the match flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
Returns <i>true</i> if the match succeeds.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Grep(GrepCallback cb, <b>const</b> <b>char</b>* p, <b>unsigned</b>
|
|
|
|
<b>int</b> flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the text <i>p</i> using the match
|
|
|
|
flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match found calls the call-back function <i>cb</i>
|
|
|
|
as: cb(*this); <p>If at any stage the call-back function
|
|
|
|
returns false then the grep operation terminates,
|
|
|
|
otherwise continues until no further matches are found.
|
|
|
|
Returns the number of matches found.</p>
|
|
|
|
</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Grep(GrepCallback cb, <b>const</b> std::string& s, <b>unsigned</b>
|
|
|
|
<b>int</b> flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the text <i>s</i> using the match
|
|
|
|
flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match found calls the call-back function <i>cb</i>
|
|
|
|
as: cb(*this); <p>If at any stage the call-back function
|
|
|
|
returns false then the grep operation terminates,
|
|
|
|
otherwise continues until no further matches are found.
|
|
|
|
Returns the number of matches found. </p>
|
|
|
|
</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Grep(std::vector<std::string>& v, <b>const</b> <b>char</b>*
|
|
|
|
p, <b>unsigned</b> <b>int</b> flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the text <i>p</i> using the match
|
|
|
|
flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match pushes a copy of what matched onto <i>v</i>.
|
|
|
|
Returns the number of matches found.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Grep(std::vector<std::string>& v, <b>const</b>
|
|
|
|
std::string& s, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default);</td>
|
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the text <i>s</i> using the match
|
|
|
|
flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match pushes a copy of what matched onto <i>v</i>.
|
|
|
|
Returns the number of matches found.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Grep(std::vector<<b>unsigned int</b>>& v, <b>const</b>
|
2001-05-17 11:55:55 +00:00
|
|
|
<b>char</b>* p, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default);</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the text <i>p</i> using the match
|
|
|
|
flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match pushes the starting index of what matched
|
|
|
|
onto <i>v</i>. Returns the number of matches found.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Grep(std::vector<<b>unsigned int</b>>& v, <b>const</b>
|
|
|
|
std::string& s, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default);</td>
|
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the text <i>s</i> using the match
|
|
|
|
flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match pushes the starting index of what matched
|
|
|
|
onto <i>v</i>. Returns the number of matches found.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
GrepFiles(GrepFileCallback cb, <b>const</b> <b>char</b>*
|
|
|
|
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
|
|
|
|
<b>int</b> flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the files <i>files</i> using the
|
|
|
|
match flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match calls the call-back function cb. <p>If
|
|
|
|
the call-back returns false then the algorithm returns
|
|
|
|
without considering further matches in the current file,
|
|
|
|
or any further files. </p>
|
|
|
|
<p>The parameter <i>files</i> can include wild card
|
|
|
|
characters '*' and '?', if the parameter <i>recurse</i>
|
|
|
|
is true then searches sub-directories for matching file
|
|
|
|
names. </p>
|
|
|
|
<p>Returns the total number of matches found.</p>
|
|
|
|
<p>May throw an exception derived from std::runtime_error
|
|
|
|
if file io fails.</p>
|
|
|
|
</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
GrepFiles(GrepFileCallback cb, <b>const</b> std::string&
|
|
|
|
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
|
|
|
|
<b>int</b> flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Finds all matches of the
|
|
|
|
current expression in the files <i>files</i> using the
|
|
|
|
match flags <i>flags </i>- see <a
|
|
|
|
href="template_class_ref.htm#match_type">match flags</a>.
|
|
|
|
For each match calls the call-back function cb. <p>If
|
|
|
|
the call-back returns false then the algorithm returns
|
|
|
|
without considering further matches in the current file,
|
|
|
|
or any further files. </p>
|
|
|
|
<p>The parameter <i>files</i> can include wild card
|
|
|
|
characters '*' and '?', if the parameter <i>recurse</i>
|
|
|
|
is true then searches sub-directories for matching file
|
|
|
|
names. </p>
|
|
|
|
<p>Returns the total number of matches found.</p>
|
|
|
|
<p>May throw an exception derived from std::runtime_error
|
|
|
|
if file io fails.</p>
|
|
|
|
</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
FindFiles(FindFilesCallback cb, <b>const</b> <b>char</b>*
|
|
|
|
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
|
|
|
|
<b>int</b> flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Searches <i>files</i> to
|
|
|
|
find all those which contain at least one match of the
|
|
|
|
current expression using the match flags <i>flags </i>-
|
|
|
|
see <a href="template_class_ref.htm#match_type">match
|
|
|
|
flags</a>. For each matching file calls the call-back
|
|
|
|
function cb. <p>If the call-back returns false then
|
|
|
|
the algorithm returns without considering any further
|
|
|
|
files. </p>
|
|
|
|
<p>The parameter <i>files</i> can include wild card
|
|
|
|
characters '*' and '?', if the parameter <i>recurse</i>
|
|
|
|
is true then searches sub-directories for matching file
|
|
|
|
names. </p>
|
|
|
|
<p>Returns the total number of files found.</p>
|
|
|
|
<p>May throw an exception derived from std::runtime_error
|
|
|
|
if file io fails.</p>
|
|
|
|
</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
FindFiles(FindFilesCallback cb, <b>const</b> std::string&
|
|
|
|
files, <b>bool</b> recurse = <b>false</b>, <b>unsigned</b>
|
|
|
|
<b>int</b> flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Searches <i>files</i> to
|
|
|
|
find all those which contain at least one match of the
|
|
|
|
current expression using the match flags <i>flags </i>-
|
|
|
|
see <a href="template_class_ref.htm#match_type">match
|
|
|
|
flags</a>. For each matching file calls the call-back
|
|
|
|
function cb. <p>If the call-back returns false then
|
|
|
|
the algorithm returns without considering any further
|
|
|
|
files. </p>
|
|
|
|
<p>The parameter <i>files</i> can include wild card
|
|
|
|
characters '*' and '?', if the parameter <i>recurse</i>
|
|
|
|
is true then searches sub-directories for matching file
|
|
|
|
names. </p>
|
|
|
|
<p>Returns the total number of files found.</p>
|
|
|
|
<p>May throw an exception derived from std::runtime_error
|
|
|
|
if file io fails.</p>
|
|
|
|
</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">std::string Merge(<b>const</b>
|
|
|
|
std::string& in, <b>const</b> std::string& fmt, <b>bool</b>
|
|
|
|
copy = <b>true</b>, <b>unsigned</b> <b>int</b> flags =
|
|
|
|
match_default);</td>
|
|
|
|
<td valign="top" width="42%">Performs a search and
|
|
|
|
replace operation: searches through the string <i>in</i>
|
|
|
|
for all occurrences of the current expression, for each
|
|
|
|
occurrence replaces the match with the format string <i>fmt</i>.
|
2001-05-17 11:55:55 +00:00
|
|
|
Uses <i>flags</i> to determine what gets matched, and how
|
|
|
|
the format string should be treated. If <i>copy</i> is
|
|
|
|
true then all unmatched sections of input are copied
|
|
|
|
unchanged to output, if the flag <em>format_first_only</em>
|
|
|
|
is set then only the first occurance of the pattern found
|
|
|
|
is replaced. Returns the new string. See <a
|
2000-09-26 11:48:28 +00:00
|
|
|
href="format_string.htm#format_string">also format string
|
2001-05-17 11:55:55 +00:00
|
|
|
syntax</a>, <a href="template_class_ref.htm#match_type">match
|
|
|
|
flags</a> and <a
|
|
|
|
href="template_class_ref.htm#format_flags">format flags</a>.</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">std::string Merge(<b>const</b>
|
|
|
|
char* in, <b>const</b> char* fmt, <b>bool</b> copy = <b>true</b>,
|
|
|
|
<b>unsigned int </b>flags = match_default);</td>
|
|
|
|
<td valign="top" width="42%">Performs a search and
|
|
|
|
replace operation: searches through the string <i>in</i>
|
|
|
|
for all occurrences of the current expression, for each
|
|
|
|
occurrence replaces the match with the format string <i>fmt</i>.
|
2001-05-17 11:55:55 +00:00
|
|
|
Uses <i>flags</i> to determine what gets matched, and how
|
|
|
|
the format string should be treated. If <i>copy</i> is
|
|
|
|
true then all unmatched sections of input are copied
|
|
|
|
unchanged to output, if the flag <em>format_first_only</em>
|
|
|
|
is set then only the first occurance of the pattern found
|
|
|
|
is replaced. Returns the new string. See <a
|
2000-09-26 11:48:28 +00:00
|
|
|
href="format_string.htm#format_string">also format string
|
2001-05-17 11:55:55 +00:00
|
|
|
syntax</a>, <a href="template_class_ref.htm#match_type">match
|
|
|
|
flags</a> and <a
|
|
|
|
href="template_class_ref.htm#format_flags">format flags</a>.</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td> </td>
|
|
|
|
<td valign="top"><b>unsigned</b> Split(std::vector<std::string>&
|
2001-05-17 11:55:55 +00:00
|
|
|
v, std::string& s, <b>unsigned</b> flags =
|
|
|
|
match_default, <b>unsigned</b> max_count = ~0);</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top">Splits the input string and pushes each
|
|
|
|
one onto the vector. If the expression contains no marked
|
|
|
|
sub-expressions, then one string is outputted for each
|
|
|
|
section of the input that does not match the expression.
|
|
|
|
If the expression does contain marked sub-expressions,
|
|
|
|
then outputs one string for each marked sub-expression
|
|
|
|
each time a match occurs. Outputs no more than <i>max_count
|
|
|
|
</i>strings. Before returning, deletes from the input
|
|
|
|
string <i>s</i> all of the input that has been processed
|
|
|
|
(all of the string if <i>max_count</i> was not reached).
|
|
|
|
Returns the number of strings pushed onto the vector.</td>
|
|
|
|
<td> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Position(<b>int</b> i = 0)<b>const</b>;</td>
|
|
|
|
<td valign="top" width="42%">Returns the position of what
|
|
|
|
matched sub-expression <i>i</i>. If <i>i = 0</i> then
|
2002-01-07 13:03:50 +00:00
|
|
|
returns the position of the whole match. Returns RegEx::npos
|
|
|
|
if the supplied index is invalid, or if the specified sub-expression
|
2000-09-26 11:48:28 +00:00
|
|
|
did not participate in the match.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Length(<b>int</b> i = 0)<b>const</b>;</td>
|
|
|
|
<td valign="top" width="42%">Returns the length of what
|
|
|
|
matched sub-expression <i>i</i>. If <i>i = 0</i> then
|
2002-01-07 13:03:50 +00:00
|
|
|
returns the length of the whole match. Returns RegEx::npos
|
|
|
|
if the supplied index is invalid, or if the specified sub-expression
|
2000-09-26 11:48:28 +00:00
|
|
|
did not participate in the match.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
2002-01-07 13:03:50 +00:00
|
|
|
<tr>
|
|
|
|
<td> </td>
|
|
|
|
<td><strong>bool</strong> Matched(<strong>int</strong> i
|
|
|
|
= 0)<strong>const</strong>;</td>
|
|
|
|
<td>Returns true if sub-expression <em>i</em> was
|
|
|
|
matched, false otherwise.</td>
|
|
|
|
<td> </td>
|
|
|
|
</tr>
|
2000-09-26 11:48:28 +00:00
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned</b> <b>int</b>
|
|
|
|
Line()<b>const</b>;</td>
|
|
|
|
<td valign="top" width="42%">Returns the line on which
|
|
|
|
the match occurred, indexes start from 1 not zero, if no
|
2002-01-07 13:03:50 +00:00
|
|
|
match occurred then returns RegEx::npos.</td>
|
2000-09-26 11:48:28 +00:00
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%"><b>unsigned int</b> Marks()
|
|
|
|
const;</td>
|
|
|
|
<td valign="top" width="42%">Returns the number of marked
|
|
|
|
sub-expressions contained in the expression. Note that
|
|
|
|
this includes the whole match (sub-expression zero), so
|
|
|
|
the value returned is always >= 1.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">std::string What(<b>int</b>
|
|
|
|
i)<b>const</b>;</td>
|
|
|
|
<td valign="top" width="42%">Returns a copy of what
|
|
|
|
matched sub-expression <i>i</i>. If <i>i = 0</i> then
|
|
|
|
returns a copy of the whole match. Returns a null string
|
|
|
|
if the index is invalid or if the specified sub-expression
|
|
|
|
did not participate in a match.</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
<td valign="top" width="43%">std::string <b>operator</b>[](<b>int</b>
|
|
|
|
i)<b>const</b> ;</td>
|
|
|
|
<td valign="top" width="42%">Returns <i>what(i);</i> <p>Can
|
|
|
|
be used to simplify access to sub-expression matches, and
|
|
|
|
make usage more perl-like.</p>
|
|
|
|
</td>
|
|
|
|
<td valign="top" width="7%"> </td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
<p><i>Copyright </i><a href="mailto:John_Maddock@compuserve.com"><i>Dr
|
|
|
|
John Maddock</i></a><i> 1998-2000 all rights reserved.</i> </p>
|
|
|
|
</body>
|
|
|
|
</html>
|