A variant of Foam::string with expansion of dictionary variables into a comma-separated form. More...
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 doCheck=true) | |
Copy construct from std::string. More... | |
exprString (std::string &&s, bool doCheck=true) | |
Move construct from std::string. More... | |
exprString (const char *s, bool doCheck=true) | |
Construct as copy of character array. More... | |
exprString (const word &entryName, const dictionary &dict, const bool mandatory=true) | |
Construct from dictionary entry lookup. Expands dictionary variables and strips and strips any embedded C/C++ comments. More... | |
exprString (Istream &is, const dictionary &dict, const bool stripComments=true) | |
Construct from Istream with dictionary context for expanding dictionary variables. Strips any embedded C/C++ comments. More... | |
~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) |
Inplace expansion with dictionary variables, and strip any embedded C/C++ comments. More... | |
void | trim () |
Inplace trim leading and trailing whitespace. More... | |
bool | readEntry (const word &keyword, const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) |
Read/expand entry with dictionary variables, and strip any embedded C/C++ comments from the input. More... | |
bool | readIfPresent (const word &keyword, const dictionary &dict) |
Read/expand optional entry with dictionary variables, and strip any embedded C/C++ comments from the input. More... | |
exprString & | operator= (const exprString &str)=default |
Copy assign. More... | |
exprString & | operator= (exprString &&str)=default |
Move assign. More... | |
exprString & | operator= (const char *str) |
Copy assign from c-string. No expansions, no comment stripping. More... | |
exprString & | operator= (const std::string &str) |
Copy assign from string. No expansions, no comment stripping. More... | |
exprString & | operator= (std::string &&str) |
Move assign from string. No expansions, no comment stripping. More... | |
bool | writeEntry (const word &keyword, Ostream &os, bool writeEmpty=false) const |
Dictionary entry for expression string, normally suppressing empty strings. Generally uses verbatim output (readability) More... | |
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... | |
string & | replace (const std::string &s1, const std::string &s2, size_type pos=0) |
Replace first occurrence of sub-string s1 with s2, beginning at pos. More... | |
string & | replaceAll (const std::string &s1, const std::string &s2, size_type pos=0) |
Replace all occurrences of sub-string s1 with s2, beginning at pos in the string. More... | |
string & | replaceAny (const std::string &s1, const char c2, size_type pos=0) |
Replace any occurrence of s1 characters with c2, beginning at pos in the string. More... | |
string & | expand (const bool allowEmpty=false) |
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::expand. More... | |
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 | contains (char c) const noexcept |
True if string contains given character (cf. C++23) More... | |
bool | contains (const std::string &s) const noexcept |
True if string contains given [string view] substring (cf. C++23) More... | |
bool | contains (const char *s) const |
True if string contains given substring (cf. C++23) More... | |
bool | starts_with (char c) const |
True if string starts with given character (cf. C++20) More... | |
bool | starts_with (const std::string &s) const |
True if string starts with given [string view] prefix (C++20) More... | |
bool | starts_with (const char *s) const |
True if string starts with given prefix (C++20) More... | |
bool | ends_with (char c) const |
True if string ends with given character (cf. C++20) More... | |
bool | ends_with (const std::string &s) const |
True if string ends with given [string view] suffix (cf. C++20) More... | |
bool | ends_with (const char *s) const |
True if string ends with given suffix (cf. C++20) More... | |
size_type | count (const char c) const |
Count the number of occurrences of the specified character in the string. More... | |
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 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 exprString | toExpr (const std::string &str, const dictionary &dict, const bool stripComments=true) |
Copy convert string to exprString with dictionary expansions, stripping any embedded C/C++ comments. More... | |
static exprString | toExpr (std::string &&str, const dictionary &dict, const bool stripComments=true) |
Move convert string to exprString with dictionary expansions, stripping any embedded C/C++ comments. More... | |
static void | inplaceExpand (std::string &str, const dictionary &dict, const bool stripComments=true) |
Inplace expansion with dictionary variables, and strip any embedded C/C++ comments. More... | |
Static Public Member Functions inherited from string | |
static std::string::size_type | length (const char *s) |
Length of the character sequence (with nullptr protection) More... | |
static std::string::size_type | length (const std::string &s) |
The length of the string. More... | |
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 | has_ext () const |
Return true if it has an extension or simply ends with a '.'. More... | |
bool | has_ext (const char *ending) const |
Return true if the extension is the same as the given ending. More... | |
bool | has_ext (const std::string &ending) const |
Return true if the extension is the same as the given ending. More... | |
bool | has_ext (const wordRe &ending) const |
Return true if the extension matches the given ending. More... | |
bool | remove_path () |
Remove leading path, return true if string changed. More... | |
bool | remove_ext () |
Remove extension, return 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... | |
A variant of Foam::string with expansion of dictionary variables into a comma-separated form.
Definition at line 55 of file exprString.H.
|
default |
Default construct.
|
default |
Copy construct.
|
default |
Move construct.
|
inlineexplicit |
Copy construct from std::string.
Definition at line 27 of file exprStringI.H.
|
inlineexplicit |
Move construct from std::string.
Definition at line 44 of file exprStringI.H.
|
inlineexplicit |
Construct as copy of character array.
Definition at line 61 of file exprStringI.H.
|
inline |
Construct from dictionary entry lookup. Expands dictionary variables and strips and strips any embedded C/C++ comments.
entryName | Lookup key. LITERAL (not REGEX) |
Definition at line 78 of file exprStringI.H.
References dict, and readIfPresent().
|
inline |
Construct from Istream with dictionary context for expanding dictionary variables. Strips any embedded C/C++ comments.
Definition at line 96 of file exprStringI.H.
References dict, Foam::stringOps::expand(), and Foam::stringOps::removeComments().
|
default |
Destructor.
|
inlinestatic |
Copy convert string to exprString.
No expansions, know what you are doing.
Definition at line 111 of file exprStringI.H.
Referenced by exprDriver::addVariables().
|
inlinestatic |
Move convert string to exprString.
No expansions, know what you are doing.
Definition at line 122 of file exprStringI.H.
|
inlinestatic |
Copy convert string to exprString with dictionary expansions, stripping any embedded C/C++ comments.
Definition at line 134 of file exprStringI.H.
References dict, and exprString::expand().
|
inlinestatic |
Move convert string to exprString with dictionary expansions, stripping any embedded C/C++ comments.
Definition at line 151 of file exprStringI.H.
References dict, and exprString::expand().
|
static |
Inplace expansion with dictionary variables, and strip any embedded C/C++ comments.
Definition at line 29 of file exprString.C.
References dict, Foam::stringOps::inplaceExpand(), and Foam::stringOps::inplaceRemoveComments().
|
inline |
Check for unexpanded '$' entries. Fatal if any exist.
Definition at line 168 of file exprStringI.H.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.
void expand | ( | const dictionary & | dict, |
const bool | stripComments = true |
||
) |
Inplace expansion with dictionary variables, and strip any embedded C/C++ comments.
Definition at line 47 of file exprString.C.
References dict, and Foam::stringOps::inplaceExpand().
Referenced by exprString::toExpr().
void trim | ( | ) |
Inplace trim leading and trailing whitespace.
Definition at line 60 of file exprString.C.
References Foam::stringOps::inplaceTrim().
bool readEntry | ( | const word & | keyword, |
const dictionary & | dict, | ||
IOobjectOption::readOption | readOpt = IOobjectOption::MUST_READ |
||
) |
Read/expand entry with dictionary variables, and strip any embedded C/C++ comments from the input.
keyword | Lookup key. Uses LITERAL (not REGEX) |
Definition at line 67 of file exprString.C.
References clear(), dict, Foam::stringOps::expand(), and keyType::LITERAL.
|
inline |
Read/expand optional entry with dictionary variables, and strip any embedded C/C++ comments from the input.
keyword | Lookup key. Uses LITERAL (not REGEX) |
Definition at line 186 of file exprStringI.H.
References dict, Foam::glTF::key(), and IOobjectOption::READ_IF_PRESENT.
|
default |
Copy assign.
|
default |
Move assign.
|
inline |
Copy assign from c-string. No expansions, no comment stripping.
Definition at line 198 of file exprStringI.H.
|
inline |
Copy assign from string. No expansions, no comment stripping.
Definition at line 211 of file exprStringI.H.
|
inline |
Move assign from string. No expansions, no comment stripping.
Definition at line 224 of file exprStringI.H.
Dictionary entry for expression string, normally suppressing empty strings. Generally uses verbatim output (readability)
Definition at line 89 of file exprString.C.
References os(), and token::setType().