Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
wordRe Class Reference

A wordRe is a Foam::word, but can contain a regular expression for matching words or strings. More...

Inheritance diagram for wordRe:
Inheritance graph
[legend]
Collaboration diagram for wordRe:
Collaboration graph
[legend]

Public Types

enum  compOption {
  LITERAL = 0, REGEX = 1, ICASE = 2, NOCASE = 2,
  DETECT = 4, UNKNOWN = 4, REGEX_ICASE = (REGEX|ICASE), DETECT_ICASE = (DETECT|ICASE)
}
 

Public Member Functions

 wordRe ()
 
 wordRe (const wordRe &str)
 
 wordRe (wordRe &&str)
 
 wordRe (const word &str)
 
 wordRe (word &&str)
 
 wordRe (const std::string &str, const compOption opt=compOption::LITERAL)
 
 wordRe (const char *str, const compOption opt=compOption::LITERAL)
 
 wordRe (const keyType &str)
 
 wordRe (Istream &is)
 
bool isLiteral () const noexcept
 
bool isPattern () const noexcept
 
bool assign (const token &tok)
 
bool compile ()
 
void uncompile ()
 
bool compile (const compOption opt)
 
void uncompile (bool adjust)
 
void set (const std::string &str, const compOption opt=DETECT)
 
void set (const char *str, const compOption opt=DETECT)
 
void clear ()
 
void swap (wordRe &str)
 
bool match (const std::string &text, bool literal=false) const
 
bool operator() (const std::string &text) const
 
void operator= (const wordRe &str)
 
void operator= (const word &str)
 
void operator= (const keyType &str)
 
void operator= (const string &str)
 
void operator= (const std::string &str)
 
void operator= (const char *str)
 
void operator= (wordRe &&str)
 
- Public Member Functions inherited from word
 word ()=default
 
 word (const word &)=default
 
 word (word &&w)=default
 
 word (const string &s, bool doStrip=true)
 
 word (string &&s, bool doStrip=true)
 
 word (const std::string &s, bool doStrip=true)
 
 word (std::string &&s, bool doStrip=true)
 
 word (const char *s, bool doStrip=true)
 
 word (const char *s, size_type len, bool doStrip)
 
 word (Istream &is)
 
void stripInvalid ()
 
word lessExt () const
 
word ext () const
 
wordext (const word &ending)
 
wordoperator= (const word &s)
 
wordoperator= (word &&s)
 
wordoperator= (const string &s)
 
wordoperator= (string &&s)
 
wordoperator= (const std::string &s)
 
wordoperator= (std::string &&s)
 
wordoperator= (const char *s)
 
template<class PrimitiveType >
Foam::word printf (const char *fmt, const PrimitiveType &val)
 
template<class PrimitiveType >
Foam::word printf (const std::string &fmt, const PrimitiveType &val)
 
bool hasExt () const
 
bool hasExt (const char *ending) const
 
bool hasExt (const std::string &ending) const
 
bool hasExt (const wordRe &ending) const
 
bool removeExt ()
 
- Public Member Functions inherited from string
 string ()=default
 
 string (const std::string &str)
 
 string (std::string &&str)
 
 string (const char *str)
 
 string (const char *str, const size_type len)
 
 string (const char c)
 
 string (const size_type len, const char c)
 
 string (Istream &is)
 
bool match (const std::string &text) const
 
stringreplace (const std::string &s1, const std::string &s2, size_type pos=0)
 
stringreplaceAll (const std::string &s1, const std::string &s2, size_type pos=0)
 
stringreplaceAny (const std::string &s1, const char c2, size_type pos=0)
 
stringexpand (const bool allowEmpty=false)
 
bool removeRepeated (const char character)
 
bool removeStart (const std::string &text)
 
bool removeStart (const char c)
 
bool removeEnd (const std::string &text)
 
bool removeEnd (const char c)
 
void swap (std::string &str)
 
bool operator() (const std::string &text) const
 
bool starts_with (const std::string &s) const
 
bool starts_with (const char c) const
 
bool ends_with (const std::string &s) const
 
bool ends_with (const char c) const
 
size_type count (const char c) const
 
bool startsWith (const std::string &s) const
 
bool endsWith (const std::string &s) const
 
bool removeTrailing (const char c)
 

Static Public Member Functions

static bool valid (const char c)
 
- Static Public Member Functions inherited from word
template<class PrimitiveType >
static word printf (const char *fmt, const PrimitiveType &val)
 
template<class PrimitiveType >
static word printf (const std::string &fmt, const PrimitiveType &val)
 
static bool valid (char c)
 
static word validate (const std::string &s, const bool prefix=false)
 
static word validate (const char *first, const char *last, const bool prefix=false)
 
- Static Public Member Functions inherited from string
template<class StringType >
static bool valid (const std::string &str)
 
template<class StringType >
static bool stripInvalid (std::string &str)
 
template<class StringType >
static StringType validate (const std::string &str)
 

Static Public Attributes

static const wordRe null
 
- Static Public Attributes inherited from word
static const char *const typeName = "word"
 
static int debug
 
static const word null
 
- Static Public Attributes inherited from string
static const char *const typeName = "string"
 
static int debug
 
static const string null
 

Additional Inherited Members

- Protected Member Functions inherited from string
std::string::size_type find_ext () const
 
word ext () const
 
bool ext (const word &ending)
 
bool hasPath () const
 
bool hasExt () const
 
bool hasExt (const char *ending) const
 
bool hasExt (const std::string &ending) const
 
bool hasExt (const wordRe &ending) const
 
bool removeExt ()
 
bool removePath ()
 
- Static Protected Member Functions inherited from string
static std::string::size_type find_ext (const std::string &str)
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const char *fmt, const PrimitiveType &val)
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const std::string &fmt, const PrimitiveType &val)
 

Detailed Description

A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.

By default the constructors will generally preserve the argument as a 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 uncompile() to synchronize the regular expression.
Source files

Definition at line 78 of file wordRe.H.

Member Enumeration Documentation

◆ compOption

enum compOption
Enumerator
LITERAL 

String literal.

REGEX 

Regular expression.

ICASE 

Ignore case in regular expression.

NOCASE 
Deprecated:
(2018-04) Alias for ICASE
DETECT 

Detect if the string contains meta-characters.

UNKNOWN 

Unknown content (for return value).

REGEX_ICASE 

Combined REGEX and ICASE.

DETECT_ICASE 

Combined DETECT and ICASE.

Definition at line 100 of file wordRe.H.

Constructor & Destructor Documentation

◆ wordRe() [1/9]

wordRe ( )
inline

Definition at line 33 of file wordReI.H.

◆ wordRe() [2/9]

wordRe ( const wordRe str)
inline

Definition at line 40 of file wordReI.H.

References wordRe::compile(), and wordRe::isPattern().

Here is the call graph for this function:

◆ wordRe() [3/9]

wordRe ( wordRe &&  str)
inline

Definition at line 51 of file wordReI.H.

◆ wordRe() [4/9]

wordRe ( const word str)
inline

Definition at line 58 of file wordReI.H.

◆ wordRe() [5/9]

wordRe ( word &&  str)
inline

Definition at line 64 of file wordReI.H.

◆ wordRe() [6/9]

wordRe ( const std::string &  str,
const compOption  opt = compOption::LITERAL 
)
inline

Definition at line 70 of file wordReI.H.

References wordRe::compile(), and wordRe::LITERAL.

Here is the call graph for this function:

◆ wordRe() [7/9]

wordRe ( const char *  str,
const compOption  opt = compOption::LITERAL 
)
inline

Definition at line 81 of file wordReI.H.

References wordRe::compile(), and wordRe::LITERAL.

Here is the call graph for this function:

◆ wordRe() [8/9]

wordRe ( const keyType str)

Definition at line 34 of file wordRe.C.

References wordRe::compile(), and keyType::isPattern().

Here is the call graph for this function:

◆ wordRe() [9/9]

wordRe ( Istream is)
explicit

Definition at line 45 of file wordRe.C.

Member Function Documentation

◆ valid()

bool valid ( const char  c)
inlinestatic

Definition at line 24 of file wordReI.H.

References Foam::constant::universal::c, and word::valid().

Here is the call graph for this function:

◆ isLiteral()

bool isLiteral ( ) const
inlinenoexcept

Definition at line 94 of file wordReI.H.

Referenced by string::hasExt().

Here is the caller graph for this function:

◆ isPattern()

bool isPattern ( ) const
inlinenoexcept

◆ assign()

bool assign ( const token tok)

Definition at line 53 of file wordRe.C.

References Foam::FieldOps::assign(), wordRe::DETECT, token::isQuotedString(), token::isWord(), token::stringToken(), and token::wordToken().

Referenced by Foam::operator>>().

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

◆ compile() [1/2]

bool compile ( )
inline

Definition at line 137 of file wordReI.H.

Referenced by wordRe::wordRe().

Here is the caller graph for this function:

◆ uncompile() [1/2]

void uncompile ( )
inline

Definition at line 143 of file wordReI.H.

◆ compile() [2/2]

bool compile ( const compOption  opt)
inline

Definition at line 106 of file wordReI.H.

References wordRe::DETECT, wordRe::ICASE, regExpPosix::is_meta(), wordRe::LITERAL, and wordRe::REGEX.

Here is the call graph for this function:

◆ uncompile() [2/2]

void uncompile ( bool  adjust)
inline

Definition at line 149 of file wordReI.H.

References word::debug.

◆ set() [1/2]

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

Definition at line 178 of file wordReI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ set() [2/2]

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

Definition at line 185 of file wordReI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ clear()

void clear ( )
inline

Definition at line 160 of file wordReI.H.

References clear().

Referenced by zoneToCell::zones(), zoneToPoint::zones(), and zoneToFace::zones().

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

◆ swap()

void swap ( wordRe str)
inline

Definition at line 192 of file wordReI.H.

References string::swap().

Here is the call graph for this function:

◆ match()

bool match ( const std::string &  text,
bool  literal = false 
) const
inline

Definition at line 167 of file wordReI.H.

Referenced by string::hasExt(), polyBoundaryMesh::indices(), and solverFieldSelection::updateSelection().

Here is the caller graph for this function:

◆ operator()()

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

Definition at line 206 of file wordReI.H.

References Foam::stringOps::match().

Here is the call graph for this function:

◆ operator=() [1/7]

void operator= ( const wordRe str)
inline

Definition at line 212 of file wordReI.H.

References Foam::FieldOps::assign(), and wordRe::isPattern().

Here is the call graph for this function:

◆ operator=() [2/7]

void operator= ( const word str)
inline

Definition at line 231 of file wordReI.H.

References Foam::FieldOps::assign().

Here is the call graph for this function:

◆ operator=() [3/7]

void operator= ( const keyType str)

Definition at line 76 of file wordRe.C.

References Foam::FieldOps::assign(), and keyType::isPattern().

Here is the call graph for this function:

◆ operator=() [4/7]

void operator= ( const string str)
inline

Definition at line 238 of file wordReI.H.

References Foam::FieldOps::assign(), and wordRe::DETECT.

Here is the call graph for this function:

◆ operator=() [5/7]

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

Definition at line 245 of file wordReI.H.

References Foam::FieldOps::assign(), and wordRe::DETECT.

Here is the call graph for this function:

◆ operator=() [6/7]

void operator= ( const char *  str)
inline

Definition at line 252 of file wordReI.H.

References Foam::FieldOps::assign(), and wordRe::DETECT.

Here is the call graph for this function:

◆ operator=() [7/7]

void operator= ( wordRe &&  str)
inline

Definition at line 259 of file wordReI.H.

References clear().

Here is the call graph for this function:

Member Data Documentation

◆ null

const Foam::wordRe null
static

Definition at line 93 of file wordRe.H.


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