CppCMS
Public Types | Public Member Functions | Static Public Attributes
booster::regex Class Reference

This is a simple wrapper of PCRE library. More...

#include <booster/booster/perl_regex.h>

List of all members.

Public Types

typedef char value_type

Public Member Functions

 regex (regex const &)
regex const & operator= (regex const &)
 regex (std::string const &pattern, int flags=normal)
void assign (std::string const &pattern, int flags=normal)
int flags () const
std::string str () const
unsigned mark_count () const
bool match (char const *begin, char const *end, int flags=0) const
bool match (char const *begin, char const *end, std::vector< std::pair< int, int > > &marks, int flags=0) const
bool search (char const *begin, char const *end, int flags=0) const
bool search (char const *begin, char const *end, std::vector< std::pair< int, int > > &marks, int flags=0) const
bool empty () const

Static Public Attributes

static const int perl = 0
 Constant for expression type - Perl Compatible Regex.
static const int normal = 0
 Constant for expression type - synonym of perl, default.

Detailed Description

This is a simple wrapper of PCRE library.

It is designed to be used with sub_match, match_results, regex_match and regex_search template functions.

It provides API similar to ones of Boost.Regex but it is also much simplified.


Constructor & Destructor Documentation

booster::regex::regex ( regex const &  )

Copy regular expression. Note. This is much more efficient then creating a new expression with same patter.

booster::regex::regex ( std::string const &  pattern,
int  flags = normal 
)

Create regular expression using a patter and special flags. Note, at this point flags should be normal or perl only (which are equivalent). May be extended in future.

Throws regex_error in case of invalid expression.


Member Function Documentation

void booster::regex::assign ( std::string const &  pattern,
int  flags = normal 
)

Assigns regular expression using a patter and special flags. Note, at this point flags should be normal or perl only (which are equivalent). May be extended in future.

Throws regex_error in case of invalid expression.

bool booster::regex::empty ( ) const

Returns true if the expression wasn't assigned.

int booster::regex::flags ( ) const

Get expression flags. Now always 0.

unsigned booster::regex::mark_count ( ) const

Get number of captured subexpressions.

bool booster::regex::match ( char const *  begin,
char const *  end,
int  flags = 0 
) const

Match the expression in the text in range [begin,end) exactly. Parameter flags currently unused.

Return true if matches

bool booster::regex::match ( char const *  begin,
char const *  end,
std::vector< std::pair< int, int > > &  marks,
int  flags = 0 
) const

Match the expression in the text in range [begin,end) exactly. Parameter flags currently unused.

Return true if matches, and stores captured sub-patterns in marks. Each pair represents a text in rage [begin+first,begin+second).

If no such patter was captured, returns (-1,-1) as pair.

regex const& booster::regex::operator= ( regex const &  )

Copy regular expression. Note. This is much more efficient then creating a new expression with same patter.

bool booster::regex::search ( char const *  begin,
char const *  end,
int  flags = 0 
) const

Search the expression in the text in range [begin,end). Parameter flags currently unused.

Return true if found.

bool booster::regex::search ( char const *  begin,
char const *  end,
std::vector< std::pair< int, int > > &  marks,
int  flags = 0 
) const

Search the expression in the text in range [begin,end). Parameter flags currently unused.

Return true if found, and stores captured sub-patterns in marks. Each pair represents a text in rage [begin+first,begin+second).

If no such patter was captured, returns (-1,-1) as pair.

std::string booster::regex::str ( ) const

Get the string that the regular expression was created with.


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