exprString Class Reference
Inheritance diagram for exprString:
[legend]
Collaboration diagram for exprString:
[legend]

Public Member Functions

 exprString ()=default
 Default construct. More...
 
 exprString (const exprString &rhs)=default
 Copy construct. More...
 
 exprString (exprString &&rhs)=default
 Move construct. More...
 
 exprString (const std::string &s, bool doValidate=true)
 Copy construct from std::string. More...
 
 exprString (std::string &&s, bool doValidate=true)
 Move construct from std::string. More...
 
 exprString (const char *s, bool doValidate=true)
 Construct as copy of character array. More...
 
 exprString (const std::string &str, const dictionary &dict, const bool stripComments=true)
 
 exprString (std::string &&str, const dictionary &dict, const bool stripComments=true)
 
 exprString (Istream &is, const dictionary &dict, const bool stripComments=true)
 
 ~exprString ()=default
 Destructor. More...
 
bool valid () const
 Check for unexpanded '$' entries. Fatal if any exist. More...
 
void expand (const dictionary &dict, const bool stripComments=true)
 
void trim ()
 Inplace trim leading and trailing whitespace. More...
 
bool readEntry (const word &keyword, const dictionary &dict, bool mandatory=true, const bool stripComments=true)
 
exprStringoperator= (const exprString &str)=default
 Copy assign. More...
 
exprStringoperator= (exprString &&str)=default
 Move assign. More...
 
exprStringoperator= (const char *str)
 Copy assign from c-string. No expansions, no comment stripping. More...
 
exprStringoperator= (const std::string &str)
 Copy assign from string. No expansions, no comment stripping. More...
 
exprStringoperator= (std::string &&str)
 Move assign from string. No expansions, no comment stripping. More...
 
bool writeEntry (const word &keyword, Ostream &os, bool writeEmpty=false) const
 
- Public Member Functions inherited from string
 string ()=default
 Default construct. More...
 
 string (const std::string &str)
 Copy construct from std::string. More...
 
 string (std::string &&str)
 Move construct from std::string. More...
 
 string (const char *str)
 Construct as copy of character array. More...
 
 string (const char *str, const size_type len)
 Construct as copy with a maximum number of characters. More...
 
 string (const char c)
 Construct from a single character. More...
 
 string (const size_type len, const char c)
 Construct fill copies of a single character. More...
 
 string (Istream &is)
 Construct from Istream. More...
 
bool match (const std::string &text) const
 Test for equality. More...
 
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)
 Remove repeated characters. More...
 
bool removeStart (const std::string &text)
 Remove the given text from the start of the string. More...
 
bool removeStart (const char c)
 Remove leading character, unless string is a single character. More...
 
bool removeEnd (const std::string &text)
 Remove the given text from the end of the string. More...
 
bool removeEnd (const char c)
 Remove trailing character, unless string is a single character. More...
 
void swap (std::string &str)
 Swap contents. Self-swapping is a no-op. More...
 
bool operator() (const std::string &text) const
 Test for equality. Allows use as a predicate. More...
 
bool starts_with (const std::string &s) const
 True if string starts with the given prefix (cf. C++20) More...
 
bool starts_with (const char c) const
 True if string starts with the given character (cf. C++20) More...
 
bool ends_with (const std::string &s) const
 True if string ends with the given suffix (cf. C++20) More...
 
bool ends_with (const char c) const
 True if string ends with the given character (cf. C++20) More...
 
size_type count (const char c) const
 
bool startsWith (const std::string &s) const
 Deprecated(2019-11) More...
 
bool endsWith (const std::string &s) const
 Deprecated(2019-11) More...
 
bool removeTrailing (const char c)
 Deprecated(2019-11) More...
 

Static Public Member Functions

static void inplaceExpand (std::string &str, const dictionary &dict, const bool stripComments=true)
 
static exprString getEntry (const word &keyword, const dictionary &dict, const bool stripComments=true)
 
static exprString getOptional (const word &keyword, const dictionary &dict, const bool stripComments=true)
 
static exprString toExpr (const std::string &str)
 Copy convert string to exprString. More...
 
static exprString toExpr (std::string &&str)
 Move convert string to exprString. More...
 
- Static Public Member Functions inherited from string
template<class StringType >
static bool valid (const std::string &str)
 Does the string contain valid characters only? More...
 
template<class StringType >
static bool stripInvalid (std::string &str)
 Strip invalid characters from the given string. More...
 
template<class StringType >
static StringType validate (const std::string &str)
 Return a valid String from the given string. More...
 

Additional Inherited Members

- Static Public Attributes inherited from string
static const char *const typeName = "string"
 The type name "string". More...
 
static int debug
 The debug flag. More...
 
static const string null
 An empty string. More...
 
- Protected Member Functions inherited from string
std::string::size_type find_ext () const
 Find position of a file extension dot, return npos on failure. More...
 
word ext () const
 Return file name extension (part after last .) More...
 
bool ext (const word &ending)
 Append a '.' and the ending. More...
 
bool hasPath () const
 Return true if it contains a '/' character. More...
 
bool hasExt () const
 Return true if it has an extension or simply ends with a '.'. More...
 
bool hasExt (const char *ending) const
 Return true if the extension is the same as the given ending. More...
 
bool hasExt (const std::string &ending) const
 Return true if the extension is the same as the given ending. More...
 
bool hasExt (const wordRe &ending) const
 Return true if the extension matches the given ending. More...
 
bool removeExt ()
 Remove extension, returning true if string changed. More...
 
bool removePath ()
 Remove leading path, returning true if string changed. More...
 
- Static Protected Member Functions inherited from string
static std::string::size_type find_ext (const std::string &str)
 Find position of a file extension dot, return npos on failure. More...
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const char *fmt, const PrimitiveType &val)
 A printf-style formatter for a primitive. More...
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const std::string &fmt, const PrimitiveType &val)
 A printf-style formatter for a primitive. More...
 

Detailed Description

Definition at line 60 of file exprString.H.

Constructor & Destructor Documentation

◆ exprString() [1/9]

exprString ( )
default

Default construct.

Referenced by exprString::exprString().

Here is the caller graph for this function:

◆ exprString() [2/9]

exprString ( const exprString rhs)
default

Copy construct.

◆ exprString() [3/9]

exprString ( exprString &&  rhs)
default

Move construct.

◆ exprString() [4/9]

exprString ( const std::string &  s,
bool  doValidate = true 
)
inlineexplicit

Copy construct from std::string.

Definition at line 33 of file exprStringI.H.

References exprString::exprString(), and exprString::valid().

Here is the call graph for this function:

◆ exprString() [5/9]

exprString ( std::string &&  s,
bool  doValidate = true 
)
inlineexplicit

Move construct from std::string.

Definition at line 50 of file exprStringI.H.

References exprString::exprString(), and exprString::valid().

Here is the call graph for this function:

◆ exprString() [6/9]

exprString ( const char *  s,
bool  doValidate = true 
)
inlineexplicit

Construct as copy of character array.

Definition at line 67 of file exprStringI.H.

References exprString::exprString(), and exprString::valid().

Here is the call graph for this function:

◆ exprString() [7/9]

exprString ( const std::string &  str,
const dictionary dict,
const bool  stripComments = true 
)
inline

Copy construct and expand with dictionary variables, and strip C/C++ comments from the input

Definition at line 84 of file exprStringI.H.

References dict, exprString::expand(), and exprString::exprString().

Here is the call graph for this function:

◆ exprString() [8/9]

exprString ( std::string &&  str,
const dictionary dict,
const bool  stripComments = true 
)
inline

Move construct and expand with dictionary variables, and strip C/C++ comments from the input

Definition at line 97 of file exprStringI.H.

References dict, exprString::expand(), and exprString::exprString().

Here is the call graph for this function:

◆ exprString() [9/9]

exprString ( Istream is,
const dictionary dict,
const bool  stripComments = true 
)
inline

Construct from Istream and expand with dictionary variables, and strip C/C++ comments from the input

Definition at line 110 of file exprStringI.H.

References dict, exprString::expand(), and exprString::exprString().

Here is the call graph for this function:

◆ ~exprString()

~exprString ( )
default

Destructor.

References exprString::expand(), exprString::getEntry(), exprString::getOptional(), exprString::inplaceExpand(), exprString::readEntry(), exprString::toExpr(), exprString::trim(), and exprString::valid().

Here is the call graph for this function:

Member Function Documentation

◆ inplaceExpand()

void inplaceExpand ( std::string &  str,
const dictionary dict,
const bool  stripComments = true 
)
static

Inplace expansion with dictionary variables, and strip C/C++ comments from the input.

Expansion behaviour
  • alternatives = True
  • environment = True
  • allow empty = True
  • subDict = False

Definition at line 34 of file exprString.C.

References dict, expressionEntry::inplaceExpand(), exprString::inplaceExpand(), and Foam::stringOps::inplaceRemoveComments().

Referenced by exprString::inplaceExpand(), and exprString::~exprString().

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

◆ getEntry()

Foam::expressions::exprString getEntry ( const word keyword,
const dictionary dict,
const bool  stripComments = true 
)
static

Get and expand expression with dictionary entries, optionally strip C/C++ comments from the input.

Expansion behaviour as per inplaceExpand

Parameters
keywordLookup key. Uses LITERAL (not REGEX)

Definition at line 51 of file exprString.C.

References dict, exprString::getEntry(), and exprString::readEntry().

Referenced by exprString::getEntry(), and exprString::~exprString().

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

◆ getOptional()

Foam::expressions::exprString getOptional ( const word keyword,
const dictionary dict,
const bool  stripComments = true 
)
static

Get and expand expression with dictionary entries, optionally strip C/C++ comments from the input.

Expansion behaviour as per inplaceExpand

Parameters
keywordLookup key. Uses LITERAL (not REGEX)

Definition at line 66 of file exprString.C.

References dict, exprString::getOptional(), and exprString::readEntry().

Referenced by exprString::getOptional(), and exprString::~exprString().

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

◆ toExpr() [1/2]

Foam::expressions::exprString toExpr ( const std::string &  str)
inlinestatic

Copy convert string to exprString.

No expansions, know what you are doing.

Definition at line 143 of file exprStringI.H.

References exprString::toExpr().

Referenced by exprString::toExpr(), and exprString::~exprString().

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

◆ toExpr() [2/2]

Foam::expressions::exprString toExpr ( std::string &&  str)
inlinestatic

Move convert string to exprString.

No expansions, know what you are doing.

Definition at line 154 of file exprStringI.H.

References exprString::toExpr().

Here is the call graph for this function:

◆ valid()

bool valid ( ) const
inline

Check for unexpanded '$' entries. Fatal if any exist.

Definition at line 125 of file exprStringI.H.

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

Referenced by exprString::exprString(), exprString::valid(), and exprString::~exprString().

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

◆ expand()

void expand ( const dictionary dict,
const bool  stripComments = true 
)

Inplace expansion with dictionary variables, and strip C/C++ comments from the input

Definition at line 82 of file exprString.C.

References dict, and exprString::expand().

Referenced by exprString::expand(), exprString::exprString(), and exprString::~exprString().

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

◆ trim()

void trim ( )

Inplace trim leading and trailing whitespace.

Definition at line 96 of file exprString.C.

References Foam::stringOps::inplaceTrim(), and exprString::trim().

Referenced by exprString::trim(), and exprString::~exprString().

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

◆ readEntry()

bool readEntry ( const word keyword,
const dictionary dict,
bool  mandatory = true,
const bool  stripComments = true 
)

Read/expand entry with dictionary variables, and strip C/C++ comments from the input

Parameters
keywordLookup key. Uses LITERAL (not REGEX)

Definition at line 102 of file exprString.C.

References clear(), dict, keyType::LITERAL, and exprString::readEntry().

Referenced by Function1Expression< Type >::Function1Expression(), exprString::getEntry(), exprString::getOptional(), PatchExprField< Type >::PatchExprField(), exprString::readEntry(), and exprString::~exprString().

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

◆ operator=() [1/5]

exprString & operator= ( const exprString str)
default

Copy assign.

Referenced by exprString::operator=().

Here is the caller graph for this function:

◆ operator=() [2/5]

exprString & operator= ( exprString &&  str)
default

Move assign.

References exprString::operator=(), and exprString::writeEntry().

Here is the call graph for this function:

◆ operator=() [3/5]

Foam::expressions::exprString & operator= ( const char *  str)
inline

Copy assign from c-string. No expansions, no comment stripping.

Definition at line 167 of file exprStringI.H.

References exprString::operator=(), and ObukhovLength::operator=().

Here is the call graph for this function:

◆ operator=() [4/5]

Foam::expressions::exprString & operator= ( const std::string &  str)
inline

Copy assign from string. No expansions, no comment stripping.

Definition at line 180 of file exprStringI.H.

References exprString::operator=(), and ObukhovLength::operator=().

Here is the call graph for this function:

◆ operator=() [5/5]

Foam::expressions::exprString & operator= ( std::string &&  str)
inline

Move assign from string. No expansions, no comment stripping.

Definition at line 193 of file exprStringI.H.

References exprString::operator=(), and ObukhovLength::operator=().

Here is the call graph for this function:

◆ writeEntry()

bool writeEntry ( const word keyword,
Ostream os,
bool  writeEmpty = false 
) const

Dictionary entry for expression string, normally suppressing empty strings. Generally used verbatim output (readability)

Returns
true if entry was written

Definition at line 125 of file exprString.C.

References os(), token::setType(), token::VERBATIM, and exprString::writeEntry().

Referenced by exprString::operator=(), and exprString::writeEntry().

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

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