Collection of static functions to do various simple string-related operations. More...
Functions | |
string | expandEnvVar (const string &, const bool allowEmpty=false) |
Expand all occurrences of environment variables and paths. More... | |
string & | inplaceExpandEnvVar (string &, const bool allowEmpty=false) |
Expand all occurrences of environment variables and paths. More... | |
string & | inplaceExpandCodeString (string &, const dictionary &dict, const word &dictVar="dict", const char sigil='$') |
Inplace expand occurrences of variables according to the dictionary. More... | |
string & | inplaceExpandCodeTemplate (string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$') |
Inplace expand occurrences of variables according to the mapping. More... | |
string & | inplaceExpandEntry (string &s, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty, const char sigil='$') |
Inplace expand occurrences of variables according to the dictionary. More... | |
string | trimLeft (const string &) |
Return string trimmed of leading whitespace. More... | |
string & | inplaceTrimLeft (string &) |
Trim leading whitespace inplace. More... | |
string | trimRight (const string &) |
Return string trimmed of trailing whitespace. More... | |
string & | inplaceTrimRight (string &) |
Trim trailing whitespace inplace. More... | |
string | trim (const string &) |
Return string trimmed of leading and trailing whitespace. More... | |
string & | inplaceTrim (string &) |
Trim leading and trailing whitespace inplace. More... | |
string | breakIntoIndentedLines (const string &str, const string::size_type nLength=80, const string::size_type nIndent=0) |
Break a string up into indented lines. More... | |
Collection of static functions to do various simple string-related operations.
Foam::string expandEnvVar | ( | const string & | original, |
const bool | allowEmpty = false |
||
) |
Expand all occurrences of environment variables and paths.
Expansion includes:
Supports default values as per the Bourne/Korn shell.
If parameter is unset or null, the defValue
is substituted. Otherwise, the value of parameter is substituted.
Supports alternative values as per the Bourne/Korn shell.
If parameter is unset or null, nothing is substituted. Otherwise the altValue
is substituted.
Any unknown entries are removed silently, if allowEmpty is true.
Malformed entries (eg, brace mismatch, sigil followed by bad character) are left as is.
Definition at line 240 of file stringOps.C.
References inplaceExpandEnvVar(), and s().
Referenced by dynamicCode::copyOrCreateFiles(), and Foam::findConfigFile().
Foam::string & inplaceExpandEnvVar | ( | string & | s, |
const bool | allowEmpty = false |
||
) |
Expand all occurrences of environment variables and paths.
See expandEnvVar
Definition at line 251 of file stringOps.C.
References Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::findParameterAlternative(), Foam::getEnv(), Foam::inplaceExpandPath(), and s().
Referenced by string::expand(), expandEnvVar(), and inplaceExpandCodeString().
Foam::string & inplaceExpandCodeString | ( | string & | s, |
const dictionary & | dict, | ||
const word & | dictVar = "dict" , |
||
const char | sigil = '$' |
||
) |
Inplace expand occurrences of variables according to the dictionary.
Expansion includes:
Any unknown entries are left as-is
Definition at line 409 of file stringOps.C.
References dict, entry::dict(), Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, inplaceExpandEnvVar(), entry::isDict(), Foam::nl, OSstream::precision(), s(), Foam::scientific(), List< T >::size(), OStringStream::str(), and dictionary::write().
Referenced by dynamicCodeContext::dynamicCodeContext().
Foam::string & inplaceExpandCodeTemplate | ( | string & | s, |
const HashTable< string, word, string::hash > & | mapping, | ||
const char | sigil = '$' |
||
) |
Inplace expand occurrences of variables according to the mapping.
Expansion includes:
Any unknown entries are removed silently.
Definition at line 653 of file stringOps.C.
References HashTable< T, Key, Hash >::find(), and s().
Referenced by dynamicCode::copyAndFilter().
Foam::string & inplaceExpandEntry | ( | string & | s, |
const dictionary & | dict, | ||
const bool | allowEnvVars, | ||
const bool | allowEmpty, | ||
const char | sigil = '$' |
||
) |
Inplace expand occurrences of variables according to the dictionary.
and optionally environment variables Expansion includes:
with the "${}" syntax doing a recursive substitution.
Any unknown entries are left as-is
Definition at line 759 of file stringOps.C.
References dict, Foam::expand(), Foam::getVariable(), Foam::inplaceExpandPath(), and s().
Referenced by calcIncludeEntry::execute(), includeEntry::includeFileName(), and entry::New().
Foam::string trimLeft | ( | const string & | s | ) |
Return string trimmed of leading whitespace.
Definition at line 870 of file stringOps.C.
References Foam::isspace(), and s().
Referenced by trim().
Foam::string & inplaceTrimLeft | ( | string & | s | ) |
Trim leading whitespace inplace.
Definition at line 890 of file stringOps.C.
References Foam::isspace(), and s().
Referenced by inplaceTrim().
Foam::string trimRight | ( | const string & | s | ) |
Return string trimmed of trailing whitespace.
Definition at line 910 of file stringOps.C.
References Foam::isspace(), and s().
Referenced by trim().
Foam::string & inplaceTrimRight | ( | string & | s | ) |
Trim trailing whitespace inplace.
Definition at line 930 of file stringOps.C.
References Foam::isspace(), and s().
Referenced by inplaceTrim().
Foam::string trim | ( | const string & | original | ) |
Return string trimmed of leading and trailing whitespace.
Definition at line 947 of file stringOps.C.
References trimLeft(), and trimRight().
Referenced by dynamicCodeContext::dynamicCodeContext(), PackedBoolList::operator^=(), and PackedBoolList::set().
Foam::string & inplaceTrim | ( | string & | s | ) |
Trim leading and trailing whitespace inplace.
Definition at line 953 of file stringOps.C.
References inplaceTrimLeft(), inplaceTrimRight(), and s().
Foam::string breakIntoIndentedLines | ( | const string & | str, |
const string::size_type | nLength = 80 , |
||
const string::size_type | nIndent = 0 |
||
) |
Break a string up into indented lines.
Definition at line 962 of file stringOps.C.
References Foam::indent().
Referenced by cyclicTransform::cyclicTransform(), mappedValueFvPatchField< Type >::mappedValueFvPatchField(), mappedPatchBaseBase::validateForField(), and mappedPatchBaseBase::validateMapForField().