Foam::stringOps Namespace Reference

Collection of static functions for various string-related operations. More...

Classes

struct  natural_sort
 Encapsulation of natural order sorting for algorithms. More...
 

Functions

std::string::size_type count (const char *s, const char c)
 Count the number of occurrences of the specified character. More...
 
std::string::size_type count (const std::string &s, const char c)
 Count the number of occurrences of the specified character. More...
 
bool match (const UList< wordRe > &selectors, const std::string &text)
 True if text matches one of the selector expressions. More...
 
template<class StringType , class UnaryPredicate >
StringType quotemeta (const StringType &str, const UnaryPredicate &meta, const char quote='\\')
 Quote any meta-characters in given string. More...
 
string expand (const std::string &s, const HashTable< string > &mapping, const char sigil='$')
 Expand occurrences of variables according to the mapping and return the expanded string. More...
 
void inplaceExpand (std::string &s, const HashTable< string > &mapping, const char sigil='$')
 Inplace expand occurrences of variables according to the mapping. Does not use environment values. More...
 
void inplaceExpand (std::string &s, const dictionary &dict, const bool allowEnv, const bool allowEmpty, const bool allowSubDict=false, const char sigil='$')
 Inplace expand occurrences of variables according to the dictionary and (optionally) environment variables. More...
 
string expand (const std::string &s, const dictionary &dict, const char sigil='$')
 Expand occurrences of dictionary or environment variables. More...
 
void inplaceExpand (std::string &s, const dictionary &dict, const char sigil='$')
 Inplace expand occurrences of dictionary or environment variables. More...
 
string expand (const std::string &s, const bool allowEmpty=false)
 Expand initial tags, tildes, and all occurrences of environment variables. More...
 
void inplaceExpand (std::string &s, const bool allowEmpty=false)
 Expand initial tags, tildes, and all occurrences of environment variables. More...
 
bool inplaceReplaceVar (std::string &s, const word &varName)
 Replace environment variable contents with its name. More...
 
template<class StringType , class UnaryPredicate >
StringType validate (const std::string &str, const UnaryPredicate &accept, const bool invert=false)
 Return a copy of the input string with validated characters. More...
 
std::pair< size_t, size_t > findTrim (const std::string &s, size_t pos=0, size_t len=std::string::npos)
 Find (first, last) non-space locations in string or sub-string. More...
 
string trimLeft (const std::string &s)
 Return string trimmed of leading whitespace. More...
 
void inplaceTrimLeft (std::string &s)
 Trim leading whitespace inplace. More...
 
string trimRight (const std::string &s)
 Return string trimmed of trailing whitespace. More...
 
void inplaceTrimRight (std::string &s)
 Trim trailing whitespace inplace. More...
 
string trim (const std::string &s)
 Return string trimmed of leading and trailing whitespace. More...
 
void inplaceTrim (std::string &s)
 Trim leading and trailing whitespace inplace. More...
 
void inplaceRemoveSpace (std::string &s)
 Eliminate whitespace inplace. More...
 
string removeComments (const std::string &s)
 Return string with C/C++ comments removed. More...
 
void inplaceRemoveComments (std::string &s)
 Remove C/C++ comments inplace. More...
 
string lower (const std::string &s)
 Return string copy transformed with std::tolower on each character. More...
 
void inplaceLower (std::string &s)
 Inplace transform string with std::tolower on each character. More...
 
string upper (const std::string &s)
 Return string copy transformed with std::toupper on each character. More...
 
void inplaceUpper (std::string &s)
 Inplace transform string with std::toupper on each character. More...
 
label splitFunctionArgs (const std::string &str, wordRes &args, List< Tuple2< word, string >> &namedArgs)
 Split out arguments (named or unnamed) from an input string. More...
 
Foam::SubStrings split (const std::string &str, const char delim, std::string::size_type pos=0, const bool keepEmpty=false)
 Split string into sub-strings at the delimiter character. More...
 
Foam::SubStrings split (const std::string &str, const std::string &delim, std::string::size_type pos=0, const bool keepEmpty=false)
 Split string into sub-strings using delimiter string. More...
 
Foam::SubStrings splitAny (const std::string &str, const std::string &delim, std::string::size_type pos=0)
 Split string into sub-strings using any characters in delimiter. More...
 
Foam::SubStrings splitFixed (const std::string &str, const std::string::size_type width, std::string::size_type pos=0)
 Split string into sub-strings using a fixed field width. More...
 
Foam::SubStrings splitSpace (const std::string &str, std::string::size_type pos=0)
 Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC) More...
 
void writeWrapped (OSstream &os, const std::string &str, const std::string::size_type width, const std::string::size_type indent=0, const bool escape=false)
 Output string with text wrapping. More...
 
string evaluate (label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
 String evaluation with specified (positive, non-zero) field width. More...
 
string evaluate (const std::string &s, size_t pos=0, size_t len=std::string::npos)
 A simple string evaluation that handles various basic expressions. For trivial input, use readScalar instead (faster). More...
 
int natstrcmp (const char *s1, const char *s2)
 'Natural' compare for C-strings More...
 

Detailed Description

Collection of static functions for various string-related operations.

Source files

Function Documentation

◆ count() [1/2]

std::string::size_type Foam::stringOps::count ( const char *  s,
const char  c 
)

Count the number of occurrences of the specified character.

Correctly handles nullptr.

Referenced by string::count().

Here is the caller graph for this function:

◆ count() [2/2]

std::string::size_type Foam::stringOps::count ( const std::string &  s,
const char  c 
)

Count the number of occurrences of the specified character.

◆ match()

bool Foam::stringOps::match ( const UList< wordRe > &  selectors,
const std::string &  text 
)
inline

True if text matches one of the selector expressions.

Definition at line 79 of file stringOps.H.

References wordRes::match().

Referenced by fileRegEx::apply(), degenerateMatcher::match(), regExpCxx::match(), triangle2D::nClosePoints(), keyType::operator()(), wordRe::operator()(), regExpCxx::operator()(), and triangle2D::snapClosePoints().

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

◆ quotemeta()

StringType Foam::stringOps::quotemeta ( const StringType &  str,
const UnaryPredicate &  meta,
const char  quote = '\\' 
)

Quote any meta-characters in given string.

Referenced by ddt2::read().

Here is the caller graph for this function:

◆ expand() [1/3]

string Foam::stringOps::expand ( const std::string &  s,
const HashTable< string > &  mapping,
const char  sigil = '$' 
)

Expand occurrences of variables according to the mapping and return the expanded string.

See also
stringOps::inplaceExpand() for details

Referenced by blockDescriptor::blockDescriptor(), dynamicCode::copyOrCreateFiles(), dictionaryValue::dictionaryValue(), argList::displayDoc(), exprString::exprString(), functionObjectList::findDict(), Foam::operator<<(), exprString::readEntry(), and STDMD::update().

Here is the caller graph for this function:

◆ inplaceExpand() [1/4]

void Foam::stringOps::inplaceExpand ( std::string &  s,
const HashTable< string > &  mapping,
const char  sigil = '$' 
)

Inplace expand occurrences of variables according to the mapping. Does not use environment values.

Expansion includes:

  1. Variables
    • $VAR
    • ${VAR}
  2. Default and alternative values as per the POSIX shell:
    • ${parameter:-defValue} If parameter is unset or null, the defValue is substituted. Otherwise, the value of parameter is substituted.
    • ${parameter:+altValue} If parameter is unset or null, nothing is substituted. Otherwise the altValue is substituted.

General behaviour:

  • Unknown entries are removed silently.
  • Malformed entries (eg, brace mismatch, sigil followed by unknown characters) are left as is.
Parameters
[in,out]sThe string to modify inplace.
mappingThe lookup table
sigilThe leading sigil. Can be changed to avoid conflict with other string expansions. (default: '$')
Expansion behaviour
  • alternatives = True
  • environment = False
  • allow empty = True
  • subDict = Not applicable
Note
Currently only used by Foam::dynamicCode.

Referenced by dynamicCode::copyAndFilter(), expressionEntry::expand(), exprString::expand(), string::expand(), dynamicCodeContext::inplaceExpand(), expressionEntry::inplaceExpand(), exprString::inplaceExpand(), entry::New(), includeEtcEntry::resolveEtcFile(), and includeEntry::resolveFile().

Here is the caller graph for this function:

◆ inplaceExpand() [2/4]

void Foam::stringOps::inplaceExpand ( std::string &  s,
const dictionary dict,
const bool  allowEnv,
const bool  allowEmpty,
const bool  allowSubDict = false,
const char  sigil = '$' 
)

Inplace expand occurrences of variables according to the dictionary and (optionally) environment variables.

Expansion includes:

  1. Dictionary variables and (optionally) environment variables
    • $VAR
    • ${VAR}
    • ${VAR:-defValue}
    • ${VAR:+altValue}
  2. Mathematical evaluation using stringOps::evaluate
    • ${{EXPR}}
  3. Current directory
  4. Leading tag expansion for commonly used directories
    • <etc>/ : user/group/other OpenFOAM etc directory
    • <etc:[ugoa]+)>/ : user/group/other etc with specified location mode
    • <case>/ : The $FOAM_CASE directory
    • <constant>/ : The $FOAM_CASE/constant directory
    • <system>/ : The $FOAM_CASE/system directory
  5. Tilde expansion
    • leading "~/" : home directory
    • leading "~user" : home directory for specified user
  6. Default and alternative values as per the POSIX shell:
    • ${parameter:-defValue} If parameter is unset or null, the defValue is substituted. Otherwise, the value of parameter is substituted.
    • ${parameter:+altValue} If parameter is unset or null, nothing is substituted. Otherwise the altValue is substituted.

General behaviour:

  • Malformed entries (eg, brace mismatch, sigil followed by unknown characters) are left as is.
  • Supports recursive variable expansions. For example, "${var${num}}" and "${{100 + ${var}}}"
Parameters
[in,out]sThe string to modify inplace
dictThe dictionary context for the expansion
allowEnvAllow use of environment values as fallback
allowEmptyAllow empty expansions, or treat as Fatal
allowSubDictAllow expansion of subDict entries as well as primitive entries (default: false)
sigilThe leading sigil. Can be changed to avoid conflict with other string expansions. (default: '$')
See also
Foam::findEtcEntry(), Foam::findEtcEntries(), stringOps::evaluate()
Expansion behaviour
  • alternatives = True
  • environment = Given by parameter
  • allow empty = Given by parameter
  • subDict = Given by parameter (default: False)
Note
This function has too many parameters and should generally be avoided in user coding.

◆ expand() [2/3]

string Foam::stringOps::expand ( const std::string &  s,
const dictionary dict,
const char  sigil = '$' 
)

Expand occurrences of dictionary or environment variables.

Empty expansions are allowed. Serialization of subDict entries is permitted.

See also
stringOps::inplaceExpand(std::string&, const dictionary&, char)

◆ inplaceExpand() [3/4]

void Foam::stringOps::inplaceExpand ( std::string &  s,
const dictionary dict,
const char  sigil = '$' 
)

Inplace expand occurrences of dictionary or environment variables.

Empty expansions are allowed. Serialization of subDict entries is permitted.

See also
stringOps::inplaceExpand (std::string&, const dictionary&, bool, bool, bool, char)
Expansion behaviour
  • alternatives = True
  • environment = True
  • allow empty = True
  • subDict = True

◆ expand() [3/3]

string Foam::stringOps::expand ( const std::string &  s,
const bool  allowEmpty = false 
)

Expand initial tags, tildes, and all occurrences of environment variables.

See also
stringOps::inplaceExpand(std::string&, bool);

◆ inplaceExpand() [4/4]

void Foam::stringOps::inplaceExpand ( std::string &  s,
const bool  allowEmpty = false 
)

Expand initial tags, tildes, and all occurrences of environment variables.

The expansion behaviour is identical to stringOps::inplaceExpand (std::string&, const dictionary&, bool, bool, bool, char) except that there is no dictionary and the environment variables are always enabled.

Expansion behaviour
  • alternatives = True
  • environment = True
  • allow empty = Given by parameter (default: False)
  • subDict = Not applicable

◆ inplaceReplaceVar()

bool Foam::stringOps::inplaceReplaceVar ( std::string &  s,
const word varName 
)

Replace environment variable contents with its name.

This is essentially the inverse operation for inplaceExpand for a single element. Return true if a replacement was successful.

◆ validate()

StringType Foam::stringOps::validate ( const std::string &  str,
const UnaryPredicate &  accept,
const bool  invert = false 
)

Return a copy of the input string with validated characters.

Parameters
invertInvert the test logic

Referenced by surfMesh::addZones(), surfMesh::copySurface(), dictionary::csearchCompat(), IOobject::fileNameComponents(), OBJsurfaceFormat< Face >::read(), AC3DsurfaceFormat< Face >::read(), ABAQUSsurfaceFormat< Face >::read(), NASsurfaceFormat< Face >::read(), Foam::readDir(), and surfMesh::transfer().

Here is the caller graph for this function:

◆ findTrim()

std::pair<size_t, size_t> Foam::stringOps::findTrim ( const std::string &  s,
size_t  pos = 0,
size_t  len = std::string::npos 
)

Find (first, last) non-space locations in string or sub-string.

This may change to std::string_view in the future.

◆ trimLeft()

string Foam::stringOps::trimLeft ( const std::string &  s)

Return string trimmed of leading whitespace.

◆ inplaceTrimLeft()

void Foam::stringOps::inplaceTrimLeft ( std::string &  s)

Trim leading whitespace inplace.

◆ trimRight()

string Foam::stringOps::trimRight ( const std::string &  s)

Return string trimmed of trailing whitespace.

◆ inplaceTrimRight()

void Foam::stringOps::inplaceTrimRight ( std::string &  s)

Trim trailing whitespace inplace.

Referenced by Foam::readEnsightString(), ensightSurfaceReader::readLine(), and Foam::readUntilBalancedDelimiter().

Here is the caller graph for this function:

◆ trim()

string Foam::stringOps::trim ( const std::string &  s)

Return string trimmed of leading and trailing whitespace.

Referenced by exprDriver::addVariables(), and substitutionModel::cleanKey().

Here is the caller graph for this function:

◆ inplaceTrim()

void Foam::stringOps::inplaceTrim ( std::string &  s)

Trim leading and trailing whitespace inplace.

Referenced by exprDriver::addVariables(), dynamicCodeContext::inplaceExpand(), expressionEntry::inplaceExpand(), and exprString::trim().

Here is the caller graph for this function:

◆ inplaceRemoveSpace()

void Foam::stringOps::inplaceRemoveSpace ( std::string &  s)

Eliminate whitespace inplace.

Referenced by Foam::getIdentifier().

Here is the caller graph for this function:

◆ removeComments()

string Foam::stringOps::removeComments ( const std::string &  s)

Return string with C/C++ comments removed.

Referenced by exprString::exprString().

Here is the caller graph for this function:

◆ inplaceRemoveComments()

void Foam::stringOps::inplaceRemoveComments ( std::string &  s)

Remove C/C++ comments inplace.

Referenced by exprString::inplaceExpand().

Here is the caller graph for this function:

◆ lower()

string Foam::stringOps::lower ( const std::string &  s)

Return string copy transformed with std::tolower on each character.

Referenced by oversetFvMeshBase::addInterpolation(), LduMatrix< Type, DType, LUType >::Amul(), lduMatrix::Amul(), viewFactor::calculate(), GAMGAgglomeration::checkRestriction(), Foam::clamp(), FieldField< Foam::Field, LUType >::clamp_min(), Field< Foam::vector >::clamp_min(), GeometricField< Foam::vector, Foam::fvPatchField, Foam::volMesh >::clamp_min(), FieldField< Foam::Field, LUType >::clamp_range(), Field< Foam::vector >::clamp_range(), GeometricField< Foam::vector, Foam::fvPatchField, Foam::volMesh >::clamp_range(), STLAsciiParseManual::execute(), oversetFvPatchField< Type >::fringeFlux(), LduMatrix< Type, DType, LUType >::H(), viewFactor::initialise(), labelRange::join(), waWallFunctionFvPatchScalarField::manipulateMatrix(), oversetFvPatchField< Type >::manipulateMatrix(), FixedList< point, 2 >::moveFirst(), UList< Foam::vector >::moveFirst(), LduMatrix< Type, DType, LUType >::operator*=(), lduMatrix::operator*=(), LduMatrix< Type, DType, LUType >::operator+=(), lduMatrix::operator+=(), LduMatrix< Type, DType, LUType >::operator-=(), lduMatrix::operator-=(), lduMatrix::operator=(), labelRanges::remove(), LduMatrix< Type, DType, LUType >::residual(), lduMatrix::residual(), faMatrix< Type >::setValuesFromList(), fvMatrix< Type >::setValuesFromList(), fvMatrix< Type >::solveCoupled(), fvMatrix< Type >::solveSegregated(), oversetFvPatchField< Type >::storeFringeCoefficients(), labelRange::subset(), labelRange::subset0(), LduMatrix< Type, DType, LUType >::sumA(), lduMatrix::sumA(), LduMatrix< Type, DType, LUType >::Tmul(), lduMatrix::Tmul(), fvMatrix< Type >::transferFvMatrixCoeffs(), lduPrimitiveMesh::upperTriOrder(), and oversetFvMeshBase::write().

Here is the caller graph for this function:

◆ inplaceLower()

void Foam::stringOps::inplaceLower ( std::string &  s)

Inplace transform string with std::tolower on each character.

Referenced by STARCDMeshReader::readBoundary().

Here is the caller graph for this function:

◆ upper()

string Foam::stringOps::upper ( const std::string &  s)

Return string copy transformed with std::toupper on each character.

Referenced by oversetFvMeshBase::addInterpolation(), ABAQUSCore::readHelper::addNewElset(), LduMatrix< Type, DType, LUType >::Amul(), lduMatrix::Amul(), viewFactor::calculate(), GAMGAgglomeration::checkRestriction(), Foam::clamp(), FieldField< Foam::Field, LUType >::clamp_max(), Field< Foam::vector >::clamp_max(), GeometricField< Foam::vector, Foam::fvPatchField, Foam::volMesh >::clamp_max(), FieldField< Foam::Field, LUType >::clamp_range(), Field< Foam::vector >::clamp_range(), GeometricField< Foam::vector, Foam::fvPatchField, Foam::volMesh >::clamp_range(), substitutionModel::cleanKey(), oversetFvPatchField< Type >::fringeFlux(), Foam::getIdentifier(), LduMatrix< Type, DType, LUType >::H(), viewFactor::initialise(), labelRange::join(), Foam::lessThan(), waWallFunctionFvPatchScalarField::manipulateMatrix(), oversetFvPatchField< Type >::manipulateMatrix(), FixedList< point, 2 >::moveLast(), UList< Foam::vector >::moveLast(), LduMatrix< Type, DType, LUType >::operator*=(), lduMatrix::operator*=(), LduMatrix< Type, DType, LUType >::operator+=(), lduMatrix::operator+=(), LduMatrix< Type, DType, LUType >::operator-=(), lduMatrix::operator-=(), lduMatrix::operator=(), argList::printMan(), ABAQUSCore::readHelper::read(), ABAQUSCore::readHelper::readSurfaceElements(), labelRanges::remove(), LduMatrix< Type, DType, LUType >::residual(), lduMatrix::residual(), faMatrix< Type >::setValuesFromList(), fvMatrix< Type >::setValuesFromList(), fvMatrix< Type >::solveCoupled(), fvMatrix< Type >::solveSegregated(), oversetFvPatchField< Type >::storeFringeCoefficients(), labelRange::subset(), labelRange::subset0(), LduMatrix< Type, DType, LUType >::sumA(), lduMatrix::sumA(), FixedList< point, 2 >::swapLast(), UList< Foam::vector >::swapLast(), LduMatrix< Type, DType, LUType >::Tmul(), lduMatrix::Tmul(), fvMatrix< Type >::transferFvMatrixCoeffs(), lduPrimitiveMesh::upperTriOrder(), oversetFvMeshBase::write(), and Foam::writeCoordHeader().

◆ inplaceUpper()

void Foam::stringOps::inplaceUpper ( std::string &  s)

Inplace transform string with std::toupper on each character.

◆ splitFunctionArgs()

label Foam::stringOps::splitFunctionArgs ( const std::string &  str,
wordRes args,
List< Tuple2< word, string >> &  namedArgs 
)

Split out arguments (named or unnamed) from an input string.

For example,

* (U)
*     -> named = ()
*     -> unnamed = (U)
* 
* (patch=inlet, p)
*     -> named = ((patch inlet))
*     -> unnamed = (p)
* 
* testing, start=100, stop=200
*     -> named = ((start 100)(stop 200))
*     -> unnamed = (testing)
* 
Returns
total number of arguments

Referenced by functionObjectList::readFunctionObject().

Here is the caller graph for this function:

◆ split() [1/2]

Foam::SubStrings Foam::stringOps::split ( const std::string &  str,
const char  delim,
std::string::size_type  pos = 0,
const bool  keepEmpty = false 
)

Split string into sub-strings at the delimiter character.

Empty sub-strings are normally suppressed. Behaviour is ill-defined if delim is a NUL character.

Parameters
strThe string to split
delimThe delimiter for splitting. Ill-defined if NUL character
posOffset within string to start splitting
keepEmptyRetain empty fields

Referenced by exprDriver::addVariables(), dictionary::cfindScopedDict(), fileName::component(), fileName::components(), loadLibrary(), and dictionary::makeScopedDict().

Here is the caller graph for this function:

◆ split() [2/2]

Foam::SubStrings Foam::stringOps::split ( const std::string &  str,
const std::string &  delim,
std::string::size_type  pos = 0,
const bool  keepEmpty = false 
)

Split string into sub-strings using delimiter string.

Empty sub-strings are normally suppressed.

Parameters
strThe string to split
delimThe delimiters for splitting. Ill-defined if empty
posOffset within string to start splitting
keepEmptyRetain empty fields

◆ splitAny()

Foam::SubStrings Foam::stringOps::splitAny ( const std::string &  str,
const std::string &  delim,
std::string::size_type  pos = 0 
)

Split string into sub-strings using any characters in delimiter.

Empty sub-strings are normally suppressed. Behaviour is ill-defined if delim is an empty string.

Parameters
strThe string to split
delimThe delimiters for splitting. Ill-defined if empty!
posOffset within string to start splitting

Referenced by scalarRanges::parse(), Foam::splitStringToList(), and basicThermo::splitThermoName().

Here is the caller graph for this function:

◆ splitFixed()

Foam::SubStrings Foam::stringOps::splitFixed ( const std::string &  str,
const std::string::size_type  width,
std::string::size_type  pos = 0 
)

Split string into sub-strings using a fixed field width.

Behaviour is ill-defined if width is zero.

Parameters
strThe string to split
widthFixed field width for each sub-string
posOffset within string to start splitting

◆ splitSpace()

Foam::SubStrings Foam::stringOps::splitSpace ( const std::string &  str,
std::string::size_type  pos = 0 
)

Split string into sub-strings at whitespace (TAB, NL, VT, FF, CR, SPC)

Empty sub-strings are suppressed.

Parameters
strThe string to split
posOffset within string to start splitting

Referenced by argList::displayDoc(), ensightReadFile::getTimeStepFooter(), OBJsurfaceFormat< Face >::read(), OBJedgeFormat::read(), and ensightSurfaceReader::readCase().

Here is the caller graph for this function:

◆ writeWrapped()

void Foam::stringOps::writeWrapped ( OSstream os,
const std::string &  str,
const std::string::size_type  width,
const std::string::size_type  indent = 0,
const bool  escape = false 
)

Output string with text wrapping.

Always includes a trailing newline, unless the string itself is empty.

Parameters
osThe output stream
strThe text to be output
widthThe max-width before wrapping
indentIndentation for continued lines
escapeEscape any backslashes on output

Referenced by argList::printMan(), Foam::printManOption(), argList::printNotes(), and Foam::printOptionUsage().

Here is the caller graph for this function:

◆ evaluate() [1/2]

string Foam::stringOps::evaluate ( label  fieldWidth,
const std::string &  s,
size_t  pos = 0,
size_t  len = std::string::npos 
)

String evaluation with specified (positive, non-zero) field width.

Referenced by alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField(), alphaContactAngleTwoPhaseFvPatchScalarField::alphaContactAngleTwoPhaseFvPatchScalarField(), uniformFixedValuePointPatchField< Type >::autoMap(), uniformNormalFixedValueFvPatchVectorField::autoMap(), uniformFixedValueFvPatchField< Type >::autoMap(), scaledFixedValueFvPatchField< Type >::autoMap(), basicSymmetryFaPatchField< Type >::basicSymmetryFaPatchField(), basicSymmetryFvPatchField< Type >::basicSymmetryFvPatchField(), constantAlphaContactAngleFvPatchScalarField::constantAlphaContactAngleFvPatchScalarField(), cyclicACMIFvPatchField< Type >::cyclicACMIFvPatchField(), cyclicAMIFvPatchField< scalar >::cyclicAMIFvPatchField(), cyclicFaPatchField< Type >::cyclicFaPatchField(), cyclicFvPatchField< vector >::cyclicFvPatchField(), BlendedInterfacialModel< Foam::turbulentDispersionModel >::D(), directionMixedFvPatchField< Type >::directionMixedFvPatchField(), BlendedInterfacialModel< Foam::turbulentDispersionModel >::dmdt(), dynamicAlphaContactAngleFvPatchScalarField::dynamicAlphaContactAngleFvPatchScalarField(), energyJumpAMIFvPatchScalarField::energyJumpAMIFvPatchScalarField(), energyJumpFvPatchScalarField::energyJumpFvPatchScalarField(), basicSymmetryFvPatchField< Type >::evaluate(), basicSymmetryFaPatchField< Type >::evaluate(), extrapolatedCalculatedFvPatchField< Type >::evaluate(), extrapolatedCalculatedFaPatchField< Type >::evaluate(), jumpCyclicAMIFvPatchField< scalar >::evaluate(), zeroGradientFvPatchField< scalar >::evaluate(), alphaContactAngleTwoPhaseFvPatchScalarField::evaluate(), symmetryPlaneFvPatchField< Type >::evaluate(), kqRWallFunctionFvPatchField< scalar >::evaluate(), coupledFvPatchField< vector >::evaluate(), directionMixedFvPatchField< Type >::evaluate(), fluxCorrectedVelocityFvPatchVectorField::evaluate(), valuePointPatchField< vector >::evaluate(), fixedGradientFvPatchField< Type >::evaluate(), fixedGradientFaPatchField< Type >::evaluate(), partialSlipFvPatchField< Type >::evaluate(), fixedNormalSlipFvPatchField< Type >::evaluate(), mixedFaPatchField< Type >::evaluate(), codedFixedValuePointPatchField< Type >::evaluate(), codedFixedValueFvPatchField< Type >::evaluate(), codedMixedFvPatchField< Type >::evaluate(), cyclicACMIFvPatchField< Type >::evaluate(), cyclicAMIFvPatchField< scalar >::evaluate(), mixedFvPatchField< vector >::evaluate(), wordDirective::execute(), calcEntry::execute(), messageDirective::execute(), evalEntry::execute(), ifeqEntry::execute(), codeStream::execute(), externalCoupledTemperatureMixedFvPatchScalarField::externalCoupledTemperatureMixedFvPatchScalarField(), BlendedInterfacialModel< Foam::turbulentDispersionModel >::F(), fanFvPatchField< Type >::fanFvPatchField(), BlendedInterfacialModel< Foam::turbulentDispersionModel >::Ff(), fixedGradientFaPatchField< Type >::fixedGradientFaPatchField(), fixedGradientFvPatchField< Type >::fixedGradientFvPatchField(), fixedJumpAMIFvPatchField< scalar >::fixedJumpAMIFvPatchField(), fixedJumpFvPatchField< vector >::fixedJumpFvPatchField(), fixedNormalSlipFvPatchField< Type >::fixedNormalSlipFvPatchField(), fixedProfileFvPatchField< Type >::fixedProfileFvPatchField(), flowRateInletVelocityFvPatchVectorField::flowRateInletVelocityFvPatchVectorField(), flowRateOutletVelocityFvPatchVectorField::flowRateOutletVelocityFvPatchVectorField(), CrankNicolsonDdtScheme< Type >::fvcDdt(), CrankNicolsonDdtScheme< Type >::fvcDdtPhiCorr(), CrankNicolsonDdtScheme< Type >::fvcDdtUfCorr(), CrankNicolsonDdtScheme< Type >::fvmDdt(), interfaceCompressionFvPatchScalarField::interfaceCompressionFvPatchScalarField(), BlendedInterfacialModel< Foam::turbulentDispersionModel >::K(), BlendedInterfacialModel< Foam::turbulentDispersionModel >::Kf(), matchedFlowRateOutletVelocityFvPatchVectorField::matchedFlowRateOutletVelocityFvPatchVectorField(), CrankNicolsonDdtScheme< Type >::meshPhi(), mixedFaPatchField< Type >::mixedFaPatchField(), mixedFvPatchField< vector >::mixedFvPatchField(), transformFaPatchField< Type >::operator=(), transformFvPatchField< Type >::operator=(), porousBafflePressureFvPatchField::porousBafflePressureFvPatchField(), temperatureDependentAlphaContactAngleFvPatchScalarField::temperatureDependentAlphaContactAngleFvPatchScalarField(), timeVaryingAlphaContactAngleFvPatchScalarField::timeVaryingAlphaContactAngleFvPatchScalarField(), timeVaryingMappedFixedValueFvPatchField< Type >::timeVaryingMappedFixedValueFvPatchField(), timeVaryingMappedFixedValuePointPatchField< Type >::timeVaryingMappedFixedValuePointPatchField(), uniformDensityHydrostaticPressureFvPatchScalarField::uniformDensityHydrostaticPressureFvPatchScalarField(), uniformFixedGradientFaPatchField< Type >::uniformFixedGradientFaPatchField(), uniformFixedGradientFvPatchField< Type >::uniformFixedGradientFvPatchField(), uniformFixedValueFaPatchField< Type >::uniformFixedValueFaPatchField(), uniformFixedValueFvPatchField< Type >::uniformFixedValueFvPatchField(), uniformFixedValuePointPatchField< Type >::uniformFixedValuePointPatchField(), uniformJumpAMIFvPatchField< Type >::uniformJumpAMIFvPatchField(), uniformJumpFvPatchField< Type >::uniformJumpFvPatchField(), uniformMixedFaPatchField< Type >::uniformMixedFaPatchField(), uniformMixedFvPatchField< Type >::uniformMixedFvPatchField(), uniformNormalFixedValueFvPatchVectorField::uniformNormalFixedValueFvPatchVectorField(), pressureInletOutletVelocityFvPatchVectorField::updateCoeffs(), fixedNormalInletOutletVelocityFvPatchVectorField::updateCoeffs(), wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField(), wedgeFaPatchField< Type >::wedgeFaPatchField(), and wedgeFvPatchField< Type >::wedgeFvPatchField().

◆ evaluate() [2/2]

string Foam::stringOps::evaluate ( const std::string &  s,
size_t  pos = 0,
size_t  len = std::string::npos 
)

A simple string evaluation that handles various basic expressions. For trivial input, use readScalar instead (faster).

The evaluation supports the following:

  • operations: - + * / %
  • functions: exp, log, log10, pow, sqrt, cbrt, sqr, mag, magSqr
  • trigonometric: sin, cos, tan, asin, acos, atan, atan2, hypot
  • hyperbolic: sinh, cosh, tanh
  • conversions: degToRad, radToDeg
  • type conversion: bool, mag
  • constants: pi(), true, false
  • limits: neg, pos, neg0, pos0, sign, floor, ceil, round
  • other: rand, rand(seed)
  • logic: ! ? : == != <= => < >
Note
Unlike C/C++, the ternary and logical operations are not short-circuiting. So additional guards may be required.
The rand() function returns a uniform scalar on [0-1] interval and uses a constant seed.

◆ natstrcmp()

int Foam::stringOps::natstrcmp ( const char *  s1,
const char *  s2 
)

'Natural' compare for C-strings

Uses algorithm and code from Jan-Marten Spit jmspi.nosp@m.t@eu.nosp@m.ronet.nosp@m..nl

In the 'natural' comparison, strings are compared alphabetically and numerically. Thus 'file010.txt' sorts after 'file2.txt'

Parameters
s1left string
s2right string
Returns
-1 when s1 < s2, 0 when s1 == s2, 1 when s1 > s2

Referenced by natural_sort::compare().

Here is the caller graph for this function: