regular_expression Class Reference

#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_expressionoperator= (const regular_expression &)

Private Attributes

nstring errstr
nstring lhs
bool compiled
regex_t preg
regmatch_t regmatch [10]


Detailed Description

The regular_expression class is used to represent the state of a regular expression match. All of the interfacing with the regex code is taken care of by this class.

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.


Constructor & Destructor Documentation

virtual regular_expression::~regular_expression (  )  [virtual]

The destructor.

regular_expression::regular_expression ( const nstring arg  ) 

The constructor.

Parameters:
arg The pattern to be matched against.
Note:
The compilation of the pattern will be deferred until it is actually used by the "match" method.

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.


Member Function Documentation

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.

Parameters:
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.
Returns:
true if there was a match, or false if there was no match or an error occurred.

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

Parameters:
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.
Returns:
true of there were no errors, or false if there was an error.

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.

Parameters:
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.


Field Documentation

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.

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.

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.


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

Generated on Wed Mar 12 23:37:42 2008 for Aegis by  doxygen 1.5.5