A wordRe is a word, but can also have a regular expression for matching words. More...
#include <OpenFOAM/wordRe.H>
A wordRe is a word, but can also have a regular expression for matching words.
By default the constructors will generally preserve the argument as string literal and the assignment operators will use the wordRe::DETECT compOption to scan the string for regular expression meta characters and/or invalid word characters and react accordingly.
The exceptions are when constructing/assigning from another Foam::wordRe (preserve the same type) or from a Foam::word (always literal).
Definition at line 76 of file wordRe.H.
Public Types | |
enum | compOption { LITERAL = 0, DETECT = 1, REGEXP = 2, NOCASE = 4, DETECT_NOCASE = DETECT | NOCASE, REGEXP_NOCASE = REGEXP | NOCASE } |
Enumeration with compile options. More... | |
Public Member Functions | |
wordRe () | |
Construct null.
| |
wordRe (const wordRe &) | |
Construct as copy.
| |
wordRe (const word &) | |
Construct as copy of word.
| |
wordRe (const char *, const compOption=LITERAL) | |
Construct as copy of character array.
| |
wordRe (const string &, const compOption=LITERAL) | |
Construct as copy of string.
| |
wordRe (const std::string &, const compOption=LITERAL) | |
Construct as copy of std::string.
| |
wordRe (Istream &) | |
Construct from Istream.
| |
bool | isPattern () const |
Access.
| |
bool | compile () const |
Infrastructure.
| |
bool | compile (const compOption) const |
Possibly compile the regular expression, with greater control.
| |
bool | recompile () const |
Recompile an existing regular expression.
| |
void | uncompile (const bool doStripInvalid=false) const |
Frees precompiled regular expression, making wordRe a literal.
| |
void | set (const std::string &, const compOption=DETECT) |
Editing.
| |
void | set (const char *, const compOption=DETECT) |
Copy string, auto-test for regular expression or other options.
| |
void | clear () |
Clear string and precompiled regular expression.
| |
bool | match (const string &, bool literalMatch=false) const |
Searching.
| |
string | quotemeta () const |
Miscellaneous.
| |
Ostream & | info (Ostream &) const |
Output some basic info.
| |
const wordRe & | operator= (const wordRe &) |
Assign copy.
| |
const wordRe & | operator= (const word &) |
Copy word, never a regular expression.
| |
const wordRe & | operator= (const string &) |
Copy string, auto-test for regular expression.
| |
const wordRe & | operator= (const std::string &) |
Copy string, auto-test for regular expression.
| |
const wordRe & | operator= (const char *) |
Copy string, auto-test for regular expression.
| |
Static Public Member Functions | |
static bool | meta (char) |
Is this a meta character?
| |
static bool | isPattern (const string &) |
Test string for regular expression meta characters.
| |
Friends | |
Istream & | operator>> (Istream &, wordRe &) |
Ostream & | operator<< (Ostream &, const wordRe &) |
enum compOption |
Construct as copy.
Definition at line 49 of file wordReI.H.
References wordRe::compile(), and wordRe::isPattern().
wordRe | ( | const char * | str, |
const compOption | opt = LITERAL
|
||
) | [inline]
|
Construct as copy of character array.
Optionally specify how it should be treated.
Definition at line 68 of file wordReI.H.
References wordRe::compile().
wordRe | ( | const string & | str, |
const compOption | opt = LITERAL
|
||
) | [inline]
|
Construct as copy of string.
Optionally specify how it should be treated.
Definition at line 77 of file wordReI.H.
References wordRe::compile().
wordRe | ( | const std::string & | str, |
const compOption | opt = LITERAL
|
||
) | [inline]
|
Construct as copy of std::string.
Optionally specify how it should be treated.
Definition at line 86 of file wordReI.H.
References wordRe::compile().
Construct from Istream.
Words are treated as literals, strings with an auto-test
Definition at line 32 of file wordReIO.C.
bool meta | ( | char | c ) | [inline, static]
|
bool isPattern | ( | const string & | str ) | [inline, static]
|
Test string for regular expression meta characters.
Definition at line 34 of file wordReI.H.
Referenced by Foam::operator<<(), wordRe::operator=(), and wordRe::wordRe().
bool isPattern | ( | ) | const [inline]
|
bool compile | ( | ) | const [inline]
|
Infrastructure.
Compile the regular expression
Definition at line 137 of file wordReI.H.
Referenced by wordRe::wordRe().
bool compile | ( | const compOption | opt ) | const [inline]
|
Possibly compile the regular expression, with greater control.
Definition at line 103 of file wordReI.H.
References wordRe::DETECT, wordRe::NOCASE, and wordRe::REGEXP.
bool recompile | ( | ) | const [inline]
|
void uncompile | ( | const bool | doStripInvalid = false
) |
const [inline]
|
Frees precompiled regular expression, making wordRe a literal.
Optionally strips invalid word characters
Definition at line 155 of file wordReI.H.
References word::debug.
void set | ( | const std::string & | str, |
const compOption | opt = DETECT
|
||
) | [inline]
|
void set | ( | const char * | str, |
const compOption | opt = DETECT
|
||
) | [inline]
|
void clear | ( | ) | [inline]
|
bool match | ( | const string & | str, |
bool | literalMatch = false
|
||
) | const [inline]
|
Foam::string quotemeta | ( | ) | const [inline]
|
Foam::Ostream & info | ( | Ostream & | os ) | const |
const Foam::wordRe & operator= | ( | const wordRe & | str ) | [inline]
|
Assign copy.
Always case sensitive
Definition at line 215 of file wordReI.H.
References wordRe::isPattern().
const Foam::wordRe & operator= | ( | const word & | str ) | [inline]
|
Copy word, never a regular expression.
Reimplemented from word.
Definition at line 231 of file wordReI.H.
References word::operator=().
const Foam::wordRe & operator= | ( | const string & | str ) | [inline]
|
const Foam::wordRe & operator= | ( | const std::string & | str ) | [inline]
|
const Foam::wordRe & operator= | ( | const char * | str ) | [inline]
|