OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

wordRe Class Reference

A wordRe is a word, but can also have a regular expression for matching words. More...

Inheritance diagram for wordRe:
Collaboration diagram for wordRe:

List of all members.


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.
Ostreaminfo (Ostream &) const
 Output some basic info.
const wordReoperator= (const wordRe &)
 Assign copy.
const wordReoperator= (const word &)
 Copy word, never a regular expression.
const wordReoperator= (const string &)
 Copy string, auto-test for regular expression.
const wordReoperator= (const std::string &)
 Copy string, auto-test for regular expression.
const wordReoperator= (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

Istreamoperator>> (Istream &, wordRe &)
Ostreamoperator<< (Ostream &, const wordRe &)

Detailed Description

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).

Note:
If the string contents are changed - eg, by the operator+=() or by string::replace(), etc - it will be necessary to use compile() or recompile() to synchronize the regular expression.
Source files

Definition at line 71 of file wordRe.H.


Member Enumeration Documentation

enum compOption

Enumeration with compile options.

Note that 'REGEXP' is implicit if 'NOCASE' is specified alone.

Enumerator:
LITERAL  treat as a string literal
DETECT  treat as regular expression
REGEXP  detect if the string contains meta-characters
NOCASE  ignore case in regular expression
DETECT_NOCASE 
REGEXP_NOCASE 

Definition at line 88 of file wordRe.H.


Constructor & Destructor Documentation

wordRe (  )  [inline]

Construct null.

Definition at line 34 of file wordReI.H.

wordRe ( const wordRe str  )  [inline]

Construct as copy.

Definition at line 41 of file wordReI.H.

wordRe ( const word str  )  [inline]

Construct as copy of word.

Definition at line 53 of file wordReI.H.

References wordRe::isPattern().

Here is the call graph for this function:

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 60 of file wordReI.H.

wordRe ( const string str,
const compOption  opt = LITERAL 
) [inline]

Construct as copy of string.

Optionally specify how it should be treated.

Definition at line 69 of file wordReI.H.

References wordRe::compile().

Here is the call graph for this function:

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 78 of file wordReI.H.

References wordRe::compile().

Here is the call graph for this function:

wordRe ( Istream is  ) 

Construct from Istream.

Words are treated as literals, strings with an auto-test

Definition at line 24 of file wordReIO.C.


Member Function Documentation

bool meta ( char  c  )  [inline, static]

Is this a meta character?

Definition at line 20 of file wordReI.H.

Referenced by wordRe::isPattern().

Here is the caller graph for this function:

bool isPattern ( const string str  )  [inline, static]

Test string for regular expression meta characters.

Definition at line 26 of file wordReI.H.

References wordRe::meta().

Referenced by wordRe::info(), and wordRe::wordRe().

Here is the call graph for this function:

Here is the caller graph for this function:

bool isPattern (  )  const [inline]

Access.

Should be treated as a match rather than a literal string?

Definition at line 89 of file wordReI.H.

bool compile (  )  const [inline]

Infrastructure.

Compile the regular expression

Definition at line 129 of file wordReI.H.

References regExp::clear().

Referenced by wordRe::operator=(), wordRe::set(), and wordRe::wordRe().

Here is the call graph for this function:

Here is the caller graph for this function:

bool compile ( const compOption  opt  )  const [inline]

Possibly compile the regular expression, with greater control.

Definition at line 95 of file wordReI.H.

References regExp::exists().

Here is the call graph for this function:

bool recompile (  )  const [inline]

Recompile an existing regular expression.

Definition at line 136 of file wordReI.H.

References regExp::exists().

Here is the call graph for this function:

void uncompile ( const bool  doStripInvalid = false  )  const [inline]

Frees precompiled regular expression, making wordRe a literal.

Optionally strips invalid word characters

Definition at line 147 of file wordReI.H.

void set ( const std::string &  str,
const compOption  opt = DETECT 
) [inline]

Editing.

Copy string, auto-test for regular expression or other options

Definition at line 191 of file wordReI.H.

void set ( const char *  str,
const compOption  opt = DETECT 
) [inline]

Copy string, auto-test for regular expression or other options.

Definition at line 198 of file wordReI.H.

References wordRe::compile(), and wordRe::operator=().

Here is the call graph for this function:

void clear (  )  [inline]

Clear string and precompiled regular expression.

Definition at line 163 of file wordReI.H.

Referenced by wordRe::match().

Here is the caller graph for this function:

bool match ( const string str,
bool  literalMatch = false 
) const [inline]

Searching.

Smart match as regular expression or as a string

Optionally specify a literal match only

Definition at line 170 of file wordReI.H.

References regExp::clear(), and wordRe::clear().

Here is the call graph for this function:

Foam::string quotemeta (  )  const [inline]

Miscellaneous.

Return a string with quoted meta-characters

Definition at line 185 of file wordReI.H.

Foam::Ostream & info ( Ostream os  )  const

Output some basic info.

Definition at line 78 of file wordReIO.C.

References IOstream::check(), wordRe::isPattern(), and Ostream::writeQuoted().

Here is the call graph for this function:

const Foam::wordRe & operator= ( const wordRe str  )  [inline]

Assign copy.

Always case sensitive

Definition at line 207 of file wordReI.H.

References wordRe::compile().

Referenced by wordRe::operator=(), and wordRe::set().

Here is the call graph for this function:

Here is the caller graph for this function:

const Foam::wordRe & operator= ( const word str  )  [inline]

Copy word, never a regular expression.

Reimplemented from word.

Definition at line 223 of file wordReI.H.

const Foam::wordRe & operator= ( const string str  )  [inline]

Copy string, auto-test for regular expression.

Always case sensitive

Reimplemented from word.

Definition at line 231 of file wordReI.H.

References regExp::clear(), and wordRe::operator=().

Here is the call graph for this function:

const Foam::wordRe & operator= ( const std::string &  str  )  [inline]

Copy string, auto-test for regular expression.

Always case sensitive

Reimplemented from word.

Definition at line 239 of file wordReI.H.

References wordRe::compile(), wordRe::DETECT, and wordRe::operator=().

Here is the call graph for this function:

const Foam::wordRe & operator= ( const char *  str  )  [inline]

Copy string, auto-test for regular expression.

Always case sensitive

Reimplemented from word.

Definition at line 247 of file wordReI.H.

References wordRe::compile(), wordRe::DETECT, and wordRe::operator=().

Here is the call graph for this function:


Friends And Related Function Documentation

Istream& operator>> ( Istream ,
wordRe  
) [friend]

Ostream& operator<< ( Ostream ,
const wordRe  
) [friend]


The documentation for this class was generated from the following files:
  • src/OpenFOAM/primitives/strings/wordRe/wordRe.H
  • src/OpenFOAM/primitives/strings/wordRe/wordReI.H
  • src/OpenFOAM/primitives/strings/wordRe/wordReIO.C
Copyright © 2000-2009 OpenCFD Ltd