#include <regula_expre.h>
Public Member Functions | |
virtual | ~regular_expression () |
regular_expression (const nstring &arg) | |
bool | match (const nstring &arg, size_t offset=0) |
const char * | strerror () const |
bool | match_and_substitute (const nstring &rhs, const nstring &actual, long how_many_times, nstring &output) |
Private Member Functions | |
void | set_error (int err) |
bool | compile () |
regular_expression () | |
regular_expression (const regular_expression &) | |
regular_expression & | operator= (const regular_expression &) |
Private Attributes | |
nstring | errstr |
nstring | lhs |
bool | compiled |
regex_t | preg |
regmatch_t | regmatch [10] |
You can match the one pattern against numerous strings by making repeated calls to the match() method.
You can match against a string, and replace it with something else, by using the match_and_substitute method. It, too, may be called more than once.
Definition at line 38 of file regula_expre.h.
virtual regular_expression::~regular_expression | ( | ) | [virtual] |
The destructor.
regular_expression::regular_expression | ( | const nstring & | arg | ) |
The constructor.
arg | The pattern to be matched against. |
regular_expression::regular_expression | ( | ) | [private] |
The default constructor. Do not use.
regular_expression::regular_expression | ( | const regular_expression & | ) | [private] |
The copy constructor. Do not use.
bool regular_expression::match | ( | const nstring & | arg, | |
size_t | offset = 0 | |||
) |
The match method is used to match a string against the pattern given to the constructor.
arg | The string to be matched against the pattern. | |
offset | The point at which to start searching in the string; defaults to zero, meaning the start of the string. |
const char* regular_expression::strerror | ( | ) | const |
Obtain an human readable representation of the most recent error, or NULL if there has been no error.
bool regular_expression::match_and_substitute | ( | const nstring & | rhs, | |
const nstring & | actual, | |||
long | how_many_times, | |||
nstring & | output | |||
) |
The match_and_substitute method is used to match the left hand side of a regular expression and substitute the right hand side if there was a match
rhs | The right-hand-side pattern for substituting. | |
actual | The text to be matched, possibly more than once. | |
how_many_times | The maximum number of times to perform the match; zero means unlimited. | |
output | The result of the substitution is placed here. |
void regular_expression::set_error | ( | int | err | ) | [private] |
The set_error method is used to obtain the text of the error for the last regex function call, and set the errstr instance variable accordingly.
err | The error code returned by the last regex call. |
bool regular_expression::compile | ( | ) | [private] |
The compile method is used to compile the left and side of the regular expression match. Compilation is deferred until the regular expression is actually used.
regular_expression& regular_expression::operator= | ( | const regular_expression & | ) | [private] |
The assignment operator. Do not use.
nstring regular_expression::errstr [private] |
The errstr instance variable is used to remember the human readable text of the last error which ocurred.
Definition at line 103 of file regula_expre.h.
nstring regular_expression::lhs [private] |
The lhs instance variable is used to remember the pattern on the left hand side to be matched against.
Definition at line 119 of file regula_expre.h.
bool regular_expression::compiled [private] |
The compiled instance variable is used to remember whether or not the left hand side has been compiled yet.
Definition at line 132 of file regula_expre.h.
regex_t regular_expression::preg [private] |
The preg instance variable is an opaque storage area used by the regex functions. It is initialised by the compile() method.
Definition at line 138 of file regula_expre.h.
regmatch_t regular_expression::regmatch[10] [private] |
The regmatch instance variable is used to remember the matching postions from the last match() method call.
Definition at line 144 of file regula_expre.h.