ui-utilcpp  1.8.3
Data Structures | Public Types | Public Member Functions
UI::Util::PosixRegex Class Reference

Wrapper class for POSIX.2 regex functions. More...

#include <PosixRegex.hpp>

Collaboration diagram for UI::Util::PosixRegex:
Collaboration graph

Data Structures

class  Match
 Helper class representing match data. More...
 

Public Types

typedef CodeException
< reg_errcode_t > 
Exception
 Exceptions we might throw.
 

Public Member Functions

 PosixRegex (std::string const &regex, int cflags=0) throw (Exception)
 
Match runMatch (std::string const &text, int eflags=0) throw (Exception)
 Check if text matches, and return the (first) match. More...
 
bool run (std::string const &text, int eflags=0) throw (Exception)
 Check if text matches. More...
 

Detailed Description

Wrapper class for POSIX.2 regex functions.

Note
For the future, one might rather use the libboost's regexx implementation.
See also
regex(3)
Bug:

Not fully encapsulated; flags must be given using the values from regex.h; Catched exception code must be compared against the reg_errcode_t defined in regex.h.

Does not support multiple matches (seems this does not work anyway currently)

Does not support clear text error reporting as via regerror.

Examples:
Regex.cpp.

Constructor & Destructor Documentation

UI::Util::PosixRegex::PosixRegex ( std::string const &  regex,
int  cflags = 0 
)
throw (Exception
)
Parameters
regexThe regular expression
cflagsFlags as described in regex(3)

References UI_THROW_CODE.

Member Function Documentation

bool UI::Util::PosixRegex::run ( std::string const &  text,
int  eflags = 0 
)
throw (Exception
)

Check if text matches.

Parameters
textText to examine.
eflagsFlags as described in regex(3).
Returns
True if match found; else false.
PosixRegex::Match UI::Util::PosixRegex::runMatch ( std::string const &  text,
int  eflags = 0 
)
throw (Exception
)

Check if text matches, and return the (first) match.

Parameters
textText to examine.
eflagsFlags as described in regex(3).
Returns
First match found; if no match, match.matches will be false.

References UI::Util::PosixRegex::Match::begin, UI::Util::PosixRegex::Match::end, UI::Util::PosixRegex::Match::matches, and UI_THROW_CODE.


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