FreeFOAM The Cross-Platform CFD Toolkit
regExp Class Reference

Wrapper around POSIX extended regular expressions. More...

#include <OSspecific/regExp.H>


Detailed Description

Wrapper around POSIX extended regular expressions.

See also:
The manpage regex(7) for more information about POSIX regular expressions. These differ somewhat from Perl and sed regular expressions.
Source files

Definition at line 58 of file regExp.H.

List of all members.

Public Member Functions

 regExp ()
 Construct null.
 regExp (const char *, const bool ignoreCase=false)
 Construct from character array, optionally ignoring case.
 regExp (const std::string &, const bool ignoreCase=false)
 Construct from std::string (or string), optionally ignoring case.
 ~regExp ()
bool empty () const
 Access.
bool exists () const
 Does a precompiled expression exist?
int ngroups () const
 Return the number of (groups)
void set (const char *, const bool ignoreCase=false) const
 Editing.
void set (const std::string &, const bool ignoreCase=false) const
 Compile pattern into a regular expression, optionally ignoring case.
bool clear () const
 Release precompiled expression.
std::string::size_type find (const std::string &str) const
 Searching.
bool match (const std::string &) const
 Return true if it matches the entire string.
bool match (const string &, List< string > &groups) const
 Return true if it matches and sets the sub-groups matched.
bool search (const std::string &str) const
 Return true if the regex was found in within string.
void operator= (const char *)
 Assign and compile pattern from a character array.
void operator= (const std::string &)
 Assign and compile pattern from string.

Static Public Member Functions

static bool meta (char c)
 Is character a regular expression meta-character?

Constructor & Destructor Documentation

regExp ( )

Construct null.

Definition at line 36 of file regExp.C.

regExp ( const char *  pattern,
const bool  ignoreCase = false 
)

Construct from character array, optionally ignoring case.

Definition at line 42 of file regExp.C.

regExp ( const std::string &  pattern,
const bool  ignoreCase = false 
)

Construct from std::string (or string), optionally ignoring case.

Definition at line 50 of file regExp.C.

~regExp ( )

Definition at line 60 of file regExp.C.

References clear().


Member Function Documentation

static bool meta ( char  c)
inlinestatic

Is character a regular expression meta-character?

any character: '.'
quantifiers: '*', '+', '?'
grouping: '(', '|', ')'
range: '[', ']'

Don't bother checking for '{digit}' bounds

Definition at line 82 of file regExp.H.

bool empty ( ) const
inline

Access.

Return true if a precompiled expression does not exist

Definition at line 115 of file regExp.H.

bool exists ( ) const
inline

Does a precompiled expression exist?

Definition at line 121 of file regExp.H.

int ngroups ( ) const
inline

Return the number of (groups)

Definition at line 127 of file regExp.H.

void set ( const char *  pattern,
const bool  ignoreCase = false 
) const

Editing.

Compile pattern into a regular expression, optionally ignoring case

Definition at line 68 of file regExp.C.

References clear(), Foam::exit(), Foam::FatalError, and FatalErrorIn.

void set ( const std::string &  pattern,
const bool  ignoreCase = false 
) const

Compile pattern into a regular expression, optionally ignoring case.

Definition at line 95 of file regExp.C.

bool clear ( ) const

Release precompiled expression.

Returns true if precompiled expression existed before clear

Definition at line 101 of file regExp.C.

std::string::size_type find ( const std::string &  str) const

Searching.

Find position within string.

Returns the index where it begins or string::npos if not found

Definition at line 116 of file regExp.C.

Referenced by regExp::search().

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

Return true if it matches the entire string.

The begin-of-line (^) and end-of-line ($) anchors are implicit

Definition at line 133 of file regExp.C.

Referenced by layerParameters::layerParameters().

bool match ( const string str,
List< string > &  groups 
) const

Return true if it matches and sets the sub-groups matched.

The begin-of-line (^) and end-of-line ($) anchors are implicit

Definition at line 156 of file regExp.C.

References List< T >::clear(), and List< T >::setSize().

bool search ( const std::string &  str) const
inline

Return true if the regex was found in within string.

Definition at line 162 of file regExp.H.

References regExp::find().

void operator= ( const char *  pat)

Assign and compile pattern from a character array.

Always case sensitive

Definition at line 203 of file regExp.C.

void operator= ( const std::string &  pat)

Assign and compile pattern from string.

Always case sensitive

Definition at line 209 of file regExp.C.


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