regExpPosix Class Reference

Wrapper around POSIX extended regular expressions. More...

Public Types

typedef SubStrings< std::string > results_type
 Type for matches - similar to std::smatch. More...
 

Public Member Functions

 regExpPosix ()
 Construct null. More...
 
 regExpPosix (const regExpPosix &)=delete
 Copy construct - disallowed. More...
 
 regExpPosix (regExpPosix &&rgx)
 Move construct. More...
 
 regExpPosix (const char *pattern)
 Construct from character array. More...
 
 regExpPosix (const std::string &pattern)
 Construct from string. More...
 
 regExpPosix (const char *pattern, bool ignoreCase)
 Construct from character array, optionally ignore case. More...
 
 regExpPosix (const std::string &pattern, bool ignoreCase)
 Construct from string, optionally ignore case. More...
 
 ~regExpPosix ()
 Destructor. More...
 
bool empty () const noexcept
 Return true if a precompiled expression does not exist. More...
 
bool exists () const noexcept
 Return true if a precompiled expression exists. More...
 
unsigned ngroups () const
 The number of capture groups for a non-empty expression. More...
 
bool clear ()
 Clear expression. More...
 
void swap (regExpPosix &rgx)
 Swap contents. More...
 
bool set (const char *pattern, bool ignoreCase=false)
 Compile pattern into a regular expression, optionally ignore case. More...
 
bool set (const std::string &pattern, bool ignoreCase=false)
 Compile pattern into a regular expression, optionally ignore case. More...
 
std::string::size_type find (const std::string &text) const
 Find position within the text. More...
 
bool match (const std::string &text) const
 True if the regex matches the entire text. More...
 
bool match (const std::string &text, results_type &matches) const
 True if the regex matches the text, set the matches. More...
 
bool search (const std::string &text) const
 Return true if the regex was found within the text. More...
 
bool operator() (const std::string &text) const
 Perform match on text. More...
 
void operator= (const regExpPosix &)=delete
 Copy assignment - disallowed. More...
 
void operator= (regExpPosix &&rgx)
 Move assignment. More...
 
void operator= (const char *pattern)
 Assign and compile pattern from a character array. More...
 
void operator= (const std::string &pattern)
 Assign and compile pattern from string. More...
 

Static Public Member Functions

static bool meta (char c)
 Test if character appears to be a regular expression meta-character. More...
 

Static Public Attributes

static int grammar
 Grammar (unused) - for compatibility with Foam::regExpCxx. More...
 

Detailed Description

Wrapper around POSIX extended regular expressions.

The PCRE '(?i)' extension is provided to compile the regular expression as being case-insensitive.

See also
The manpage regex(7) for more information about POSIX regular expressions. These differ somewhat from Perl and sed regular expressions.
Foam::regExp and Foam::regExpCxx
Warning
This class should not be used directly. Use the Foam::regExp typedef instead.
Deprecated:
This class will be superseded by Foam::regExpCxx as compiler support for regular expressions continues to improve.
Source files

Definition at line 75 of file regExpPosix.H.

Member Typedef Documentation

◆ results_type

typedef SubStrings<std::string> results_type

Type for matches - similar to std::smatch.

Definition at line 87 of file regExpPosix.H.

Constructor & Destructor Documentation

◆ regExpPosix() [1/7]

regExpPosix ( )
inline

Construct null.

Definition at line 46 of file regExpPosixI.H.

◆ regExpPosix() [2/7]

regExpPosix ( const regExpPosix )
delete

Copy construct - disallowed.

◆ regExpPosix() [3/7]

regExpPosix ( regExpPosix &&  rgx)
inline

Move construct.

Definition at line 84 of file regExpPosixI.H.

◆ regExpPosix() [4/7]

regExpPosix ( const char *  pattern)
inlineexplicit

Construct from character array.

Definition at line 52 of file regExpPosixI.H.

References regExpPosix::set().

Here is the call graph for this function:

◆ regExpPosix() [5/7]

regExpPosix ( const std::string &  pattern)
inlineexplicit

Construct from string.

Definition at line 60 of file regExpPosixI.H.

References regExpPosix::set().

Here is the call graph for this function:

◆ regExpPosix() [6/7]

regExpPosix ( const char *  pattern,
bool  ignoreCase 
)
inline

Construct from character array, optionally ignore case.

Definition at line 68 of file regExpPosixI.H.

References regExpPosix::set().

Here is the call graph for this function:

◆ regExpPosix() [7/7]

regExpPosix ( const std::string &  pattern,
bool  ignoreCase 
)
inline

Construct from string, optionally ignore case.

Definition at line 76 of file regExpPosixI.H.

References regExpPosix::set().

Here is the call graph for this function:

◆ ~regExpPosix()

~regExpPosix ( )
inline

Destructor.

Definition at line 94 of file regExpPosixI.H.

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ meta()

bool meta ( char  c)
inlinestatic

Test if character appears to be a regular expression meta-character.

Returns
true if character is one of the following:
  • any character: '.'
  • quantifiers: '*', '+', '?'
  • grouping: '(', '|', ')'
  • range: '[', ']'
Note
The presence of '{', '}' regex bounds is not considered

Definition at line 32 of file regExpPosixI.H.

References Foam::constant::universal::c.

◆ empty()

bool empty ( ) const
inlinenoexcept

Return true if a precompiled expression does not exist.

Definition at line 102 of file regExpPosixI.H.

◆ exists()

bool exists ( ) const
inlinenoexcept

Return true if a precompiled expression exists.

Definition at line 108 of file regExpPosixI.H.

◆ ngroups()

unsigned ngroups ( ) const
inline

The number of capture groups for a non-empty expression.

Definition at line 114 of file regExpPosixI.H.

◆ clear()

bool clear ( )

Clear expression.

Returns
True if expression had existed prior to the clear.

Definition at line 54 of file regExpPosix.C.

◆ swap()

void swap ( regExpPosix rgx)
inline

Swap contents.

Definition at line 126 of file regExpPosixI.H.

◆ set() [1/2]

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

Compile pattern into a regular expression, optionally ignore case.

Returns
True if the pattern was compiled

Definition at line 69 of file regExpPosix.C.

References clear(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.

Referenced by regExpPosix::regExpPosix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [2/2]

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

Compile pattern into a regular expression, optionally ignore case.

Returns
True if the pattern was compiled

Definition at line 120 of file regExpPosix.C.

References Foam::BitOps::set().

Here is the call graph for this function:

◆ find()

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

Find position within the text.

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

Definition at line 126 of file regExpPosix.C.

◆ match() [1/2]

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

True if the regex matches the entire text.

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

Definition at line 143 of file regExpPosix.C.

◆ match() [2/2]

bool match ( const std::string &  text,
results_type matches 
) const

True if the regex matches the text, set the matches.

The first group starts at index 1 (0 is the entire match). The begin-of-line (^) and end-of-line ($) anchors are implicit

◆ search()

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

Return true if the regex was found within the text.

Definition at line 120 of file regExpPosixI.H.

References Foam::ListOps::find().

Here is the call graph for this function:

◆ operator()()

bool operator() ( const std::string &  text) const
inline

Perform match on text.

Definition at line 138 of file regExpPosixI.H.

References Foam::stringOps::match().

Here is the call graph for this function:

◆ operator=() [1/4]

void operator= ( const regExpPosix )
delete

Copy assignment - disallowed.

◆ operator=() [2/4]

void operator= ( regExpPosix &&  rgx)
inline

Move assignment.

Definition at line 144 of file regExpPosixI.H.

References clear().

Here is the call graph for this function:

◆ operator=() [3/4]

void operator= ( const char *  pattern)
inline

Assign and compile pattern from a character array.

Matching is case sensitive.

Definition at line 151 of file regExpPosixI.H.

References Foam::BitOps::set().

Here is the call graph for this function:

◆ operator=() [4/4]

void operator= ( const std::string &  pattern)
inline

Assign and compile pattern from string.

Matching is case sensitive.

Definition at line 157 of file regExpPosixI.H.

References Foam::BitOps::set().

Here is the call graph for this function:

Member Data Documentation

◆ grammar

int grammar
static

Grammar (unused) - for compatibility with Foam::regExpCxx.

Definition at line 93 of file regExpPosix.H.


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