PUMA Library Reference Manual
Puma::RegComp Class Reference

#include <Puma/RegComp.h>

Description

Regular expression matching. This class compiles the expression when a string is matched for the first time. In case of an error, an error message can be printed on an error stream.

Public Member Functions

 RegComp (const std::string &expr)
 Constructor. More...
 
 RegComp (const RegComp &copy)
 Copy-constructor. More...
 
RegCompoperator= (const RegComp &copy)
 Assign a regular expression. More...
 
bool compile (const std::string &expr)
 Compile the regular expression. More...
 
bool match (const std::string &str)
 Match against a string. More...
 
void comperror (ErrorStream &err) const
 Print a regular expression compilation error message on the given error stream. More...
 
bool error () const
 Check whether there was an error compiling the regular expression. More...
 

Constructor & Destructor Documentation

◆ RegComp() [1/2]

Puma::RegComp::RegComp ( const std::string &  expr)

Constructor.

Parameters
exprThe regular expression.

◆ RegComp() [2/2]

Puma::RegComp::RegComp ( const RegComp copy)

Copy-constructor.

Parameters
copyThe regular expression to copy.

Member Function Documentation

◆ comperror()

void Puma::RegComp::comperror ( ErrorStream err) const

Print a regular expression compilation error message on the given error stream.

To be called when compile() fails.

Parameters
errError stream on which to print the error message.

◆ compile()

bool Puma::RegComp::compile ( const std::string &  expr)

Compile the regular expression.

Parameters
exprThe regular expression.
Returns
False in case of an errors. Use comperror() to print the error message.

◆ error()

bool Puma::RegComp::error ( ) const
inline

Check whether there was an error compiling the regular expression.

Returns
True in case of an error. Use comperror to print it.

◆ match()

bool Puma::RegComp::match ( const std::string &  str)

Match against a string.

Parameters
strString to be matched.
Returns
True if the regular expression matches the string.

◆ operator=()

RegComp& Puma::RegComp::operator= ( const RegComp copy)

Assign a regular expression.

Parameters
copyThe regular expression.
Returns
A reference to this object.