YGP::RegularExpression Class Reference

Class to compare text with (UNIX-style) regular expressions. More...

Inherits YGP::IRegularExpression.

List of all members.

Public Member Functions

 RegularExpression (const char *pRegExp) throw (std::invalid_argument)
virtual ~RegularExpression ()
virtual int checkIntegrity () const throw (std::invalid_argument)
RegularExpressionoperator= (const char *pRegExp) throw (std::invalid_argument)

Protected Member Functions

virtual bool compare (const char *pAktRegExp, const char *pCompare)


Detailed Description

Class to compare text with (UNIX-style) regular expressions.

This is just a little intruduction into the supported constructs; see regex(7) or the GNU regexp manual for a better description.

Attention:
This class implements regular expressions as the functions in regex.h do (at least in glibc 2.2.4), which might differ from what you expect from the reading (or how - e.g. - emacs behaves). But I have no idea what the *real* standard is and for testing it was the easiest to follow an existing implementation!
Anyway; here's something to give you a glue:

Note:
To include the character square bracket ([) in the match, it must be the first character; similar to the match-negators caret (^) and exclamaition-mark (!), wich must not be the first character to get included.

If the class is compiled with ENHANCED_REGEXP defined the following constructs are also supported (Warning: Those things are not regulary tested):

Note:
The pExpression-parameter is stored as is (and not copied); so take care it is valid during the life-time of the object.
Use IRegularExpression::matches to check if the object matches some data.

Deprecated:
Please use boost::Regex

Constructor & Destructor Documentation

YGP::RegularExpression::RegularExpression ( const char *  pRegExp  )  throw (std::invalid_argument)

Constructor, specifies the regular expression to match.

Parameters:
pRegExp Pointer to character array holding regular expression
Exceptions:
std::invalid_argument In case of an invalid regexp a describing text
Precondition:
The input is not copied, so it must be valid during the lifetime of the regular expression.

YGP::RegularExpression::~RegularExpression (  )  [virtual]

Destructor.


Member Function Documentation

int YGP::RegularExpression::checkIntegrity (  )  const throw (std::invalid_argument) [virtual]

Checks the syntax of the regular expression.

If everything is OK, 0 is returned; 1 if there is no regular expression at all. In case of any other error an exception is thrown.

Returns:
int Status; 0: OK
Exceptions:
std::invalid_argument In case of an invalid regexp a describing text
Precondition:
pFileRegExp is a valid regexp

Reimplemented from YGP::IRegularExpression.

bool YGP::RegularExpression::compare ( const char *  pActRegExp,
const char *  pCompare 
) [protected, virtual]

Checks if the passed text matches the passed regular expression.

Both passed parameters must not be NULL-pointers and the regular expression must be in a valid syntax (this can be checked with the checkIntegrity()-method).

Parameters:
pActRegExp Pointer to character array holding regular expression
pCompare Pointer to character array holding value to compare
Returns:
bool Result (true: match)
Precondition:
pAktRegExp, pCompare must be ASCIIZ-strings, not NULL

Implements YGP::IRegularExpression.

RegularExpression & YGP::RegularExpression::operator= ( const char *  pRegExp  )  throw (std::invalid_argument)

Assignmentoperator; specifies the regular expression to match.

Parameters:
pRegExp Pointer to character array holding regular expression
Returns:
RegularExpression& Reference to this
Exceptions:
std::invalid_argument In case of an invalid regexp a describing text
Precondition:
The input is not copied, so it must be valid during the lifetime of the regular expression.

Reimplemented from YGP::IRegularExpression.


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

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:27 2009 by doxygen 1.5.8