Classes | Functions
Foam::stringOps Namespace Reference

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

Classes

struct  natural_sort
 

Functions

std::string::size_type count (const std::string &s, const char c)
 
std::string::size_type count (const char *s, const char c)
 
bool match (const UList< wordRe > &patterns, const std::string &text)
 
template<class StringType , class UnaryPredicate >
StringType quotemeta (const StringType &str, const UnaryPredicate &meta, const char quote='\\')
 
string expand (const std::string &s, const HashTable< string > &mapping, const char sigil='$')
 
void inplaceExpand (std::string &s, const HashTable< string > &mapping, const char sigil='$')
 
void inplaceExpand (std::string &s, const dictionary &dict, const bool allowEnv, const bool allowEmpty, const bool allowSubDict=false, const char sigil='$')
 
string expand (const std::string &s, const dictionary &dict, const char sigil='$')
 
void inplaceExpand (std::string &s, const dictionary &dict, const char sigil='$')
 
string expand (const std::string &s, const bool allowEmpty=false)
 
void inplaceExpand (std::string &s, const bool allowEmpty=false)
 
bool inplaceReplaceVar (std::string &s, const word &varName)
 
template<class StringType , class UnaryPredicate >
StringType validate (const std::string &str, const UnaryPredicate &accept, const bool invert=false)
 
std::pair< size_t, size_t > findTrim (const std::string &s, size_t pos=0, size_t len=std::string::npos)
 
string trimLeft (const std::string &s)
 
void inplaceTrimLeft (std::string &s)
 
string trimRight (const std::string &s)
 
void inplaceTrimRight (std::string &s)
 
string trim (const std::string &s)
 
void inplaceTrim (std::string &s)
 
void inplaceRemoveSpace (std::string &s)
 
string removeComments (const std::string &s)
 
void inplaceRemoveComments (std::string &s)
 
string lower (const std::string &s)
 
void inplaceLower (std::string &s)
 
string upper (const std::string &s)
 
void inplaceUpper (std::string &s)
 
label splitFunctionArgs (const std::string &str, wordRes &args, List< Tuple2< word, string >> &namedArgs)
 
template<class StringType >
Foam::SubStrings< StringType > split (const StringType &str, const char delim, const bool keepEmpty=false)
 
template<class StringType >
Foam::SubStrings< StringType > split (const StringType &str, const std::string &delim, const bool keepEmpty=false)
 
template<class StringType >
Foam::SubStrings< StringType > splitAny (const StringType &str, const std::string &delim)
 
template<class StringType >
Foam::SubStrings< StringType > splitFixed (const StringType &str, const std::string::size_type width, const std::string::size_type start=0)
 
template<class StringType >
Foam::SubStrings< StringType > splitSpace (const StringType &str)
 
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)
 
string evaluate (label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
 
string evaluate (const std::string &s, size_t pos=0, size_t len=std::string::npos)
 
int natstrcmp (const char *s1, const char *s2)
 

Detailed Description

Collection of static functions for various string-related operations.

Source files

Function Documentation

◆ count() [1/2]

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

Definition at line 690 of file stringOps.C.

References Foam::constant::universal::c, Foam::BitOps::count(), and s.

Referenced by string::count(), ensightSurfaceReader::replaceMask(), OSstream::write(), and OSstream::writeQuoted().

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

◆ count() [2/2]

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

Definition at line 699 of file stringOps.C.

References Foam::constant::universal::c, Foam::BitOps::count(), and s.

Here is the call graph for this function:

◆ match()

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

◆ quotemeta()

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

Definition at line 25 of file stringOpsTemplates.C.

References Foam::constant::universal::c.

Referenced by ddt2::read().

Here is the caller graph for this function:

◆ expand() [1/3]

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

Definition at line 711 of file stringOps.C.

References inplaceExpand(), and s.

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

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

◆ inplaceExpand() [1/4]

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

◆ inplaceExpand() [2/4]

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

Definition at line 849 of file stringOps.C.

References dict, Foam::expandString(), and s.

Here is the call graph for this function:

◆ expand() [2/3]

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

Definition at line 836 of file stringOps.C.

References dict, inplaceExpand(), and s.

Here is the call graph for this function:

◆ inplaceExpand() [3/4]

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

Definition at line 863 of file stringOps.C.

References dict, Foam::expandString(), and s.

Here is the call graph for this function:

◆ expand() [3/3]

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

Definition at line 876 of file stringOps.C.

References inplaceExpand(), and s.

Here is the call graph for this function:

◆ inplaceExpand() [4/4]

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

Definition at line 888 of file stringOps.C.

References Foam::expandString(), and s.

Here is the call graph for this function:

◆ inplaceReplaceVar()

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

Definition at line 899 of file stringOps.C.

References Foam::getEnv(), and s.

Here is the call graph for this function:

◆ validate()

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

◆ findTrim()

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

Referenced by evaluate().

Here is the caller graph for this function:

◆ trimLeft()

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

Definition at line 923 of file stringOps.C.

References stdFoam::end(), Foam::isspace(), Foam::pos(), and s.

Here is the call graph for this function:

◆ inplaceTrimLeft()

void inplaceTrimLeft ( std::string &  s)

Definition at line 945 of file stringOps.C.

References stdFoam::end(), Foam::isspace(), Foam::pos(), and s.

Referenced by inplaceTrim().

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

◆ trimRight()

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

Definition at line 965 of file stringOps.C.

References stdFoam::end(), Foam::isspace(), and s.

Here is the call graph for this function:

◆ inplaceTrimRight()

void inplaceTrimRight ( std::string &  s)

Definition at line 985 of file stringOps.C.

References stdFoam::end(), Foam::isspace(), and s.

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

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

◆ trim()

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

Definition at line 1039 of file stringOps.C.

References stdFoam::end(), Foam::isspace(), Foam::pos(), and s.

Referenced by exprDriver::addVariables(), bitSet::orEq(), splitFunctionArgs(), and bitSet::xorEq().

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

◆ inplaceTrim()

void inplaceTrim ( std::string &  s)

Definition at line 1060 of file stringOps.C.

References inplaceTrimLeft(), inplaceTrimRight(), and s.

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

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

◆ inplaceRemoveSpace()

void inplaceRemoveSpace ( std::string &  s)

Definition at line 1067 of file stringOps.C.

References Foam::isspace(), and s.

Referenced by Foam::getIdentifier().

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

◆ removeComments()

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

Definition at line 1073 of file stringOps.C.

References inplaceRemoveComments(), and s.

Referenced by exprString::exprString().

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

◆ inplaceRemoveComments()

void inplaceRemoveComments ( std::string &  s)

Definition at line 1081 of file stringOps.C.

References Foam::constant::universal::c, Foam::isspace(), n, and s.

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

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

◆ lower()

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

◆ inplaceLower()

void inplaceLower ( std::string &  s)

Definition at line 1187 of file stringOps.C.

References s, and Foam::transform().

Referenced by STARCDMeshReader::readBoundary().

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

◆ upper()

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

◆ inplaceUpper()

void inplaceUpper ( std::string &  s)

Definition at line 1203 of file stringOps.C.

References s, and Foam::transform().

Here is the call graph for this function:

◆ splitFunctionArgs()

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

Definition at line 50 of file stringOpsSplit.C.

References args, Foam::constant::universal::c, Foam::name(), Foam::pos(), argList::size(), trim(), and validate().

Referenced by functionObjectList::readFunctionObject().

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

◆ split() [1/2]

Foam::SubStrings< StringType > split ( const StringType &  str,
const char  delim,
const bool  keepEmpty = false 
)

Definition at line 91 of file stringOpsTemplates.C.

References SubStrings::append(), and stdFoam::end().

Referenced by dictionary::makeScopedDict().

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

◆ split() [2/2]

Foam::SubStrings< StringType > split ( const StringType &  str,
const std::string &  delim,
const bool  keepEmpty = false 
)

Definition at line 127 of file stringOpsTemplates.C.

References SubStrings::append(), and stdFoam::end().

Here is the call graph for this function:

◆ splitAny()

Foam::SubStrings< StringType > splitAny ( const StringType &  str,
const std::string &  delim 
)

Definition at line 163 of file stringOpsTemplates.C.

References SubStrings::append(), stdFoam::end(), and Foam::pos().

Referenced by scalarRanges::parse(), and splitSpace().

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

◆ splitFixed()

Foam::SubStrings< StringType > splitFixed ( const StringType &  str,
const std::string::size_type  width,
const std::string::size_type  start = 0 
)

Definition at line 204 of file stringOpsTemplates.C.

References SubStrings::append(), stdFoam::end(), and Foam::pos().

Here is the call graph for this function:

◆ splitSpace()

Foam::SubStrings< StringType > splitSpace ( const StringType &  str)

Definition at line 239 of file stringOpsTemplates.C.

References splitAny().

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

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

◆ writeWrapped()

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 
)

Definition at line 1210 of file stringOps.C.

References Foam::constant::universal::c, stdFoam::end(), Foam::indent(), Foam::isspace(), Foam::nl, os(), and Foam::pos().

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

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

◆ evaluate() [1/2]

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

InfoErr<< "Evaluate " << str.substr(pos, len) << nl;

InfoErr<< "Evaluate " << str.substr(pos, len) << nl;

Definition at line 30 of file stringOpsEvaluate.C.

References findTrim(), exprResult::hasValue(), Foam::InfoErr, Foam::nl, os(), parseDriver::parse(), Foam::pos(), exprDriver::result(), exprResult::size(), exprResult::writeField(), and exprResult::writeValue().

Referenced by alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField(), alphaContactAngleTwoPhaseFvPatchScalarField::alphaContactAngleTwoPhaseFvPatchScalarField(), uniformFixedValuePointPatchField< Type >::autoMap(), uniformFixedValueFvPatchField< Type >::autoMap(), uniformNormalFixedValueFvPatchVectorField::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< ModelType >::D(), directionMixedFvPatchField< Type >::directionMixedFvPatchField(), BlendedInterfacialModel< ModelType >::dmdt(), dynamicAlphaContactAngleFvPatchScalarField::dynamicAlphaContactAngleFvPatchScalarField(), energyJumpAMIFvPatchScalarField::energyJumpAMIFvPatchScalarField(), energyJumpFvPatchScalarField::energyJumpFvPatchScalarField(), evaluate(), basicSymmetryFvPatchField< Type >::evaluate(), basicSymmetryFaPatchField< Type >::evaluate(), extrapolatedCalculatedFvPatchField< Type >::evaluate(), alphaContactAngleTwoPhaseFvPatchScalarField::evaluate(), symmetryPlaneFvPatchField< Type >::evaluate(), coupledFvPatchField< vector >::evaluate(), valuePointPatchField< vector >::evaluate(), kqRWallFunctionFvPatchField< Type >::evaluate(), fixedGradientFaPatchField< Type >::evaluate(), mixedFaPatchField< Type >::evaluate(), directionMixedFvPatchField< Type >::evaluate(), fluxCorrectedVelocityFvPatchVectorField::evaluate(), fixedGradientFvPatchField< Type >::evaluate(), partialSlipFvPatchField< Type >::evaluate(), fixedNormalSlipFvPatchField< Type >::evaluate(), codedFixedValueFvPatchField< Type >::evaluate(), codedFixedValuePointPatchField< Type >::evaluate(), codedMixedFvPatchField< Type >::evaluate(), mixedFvPatchField< vector >::evaluate(), wordDirective::execute(), calcEntry::execute(), messageDirective::execute(), evalEntry::execute(), ifeqEntry::execute(), codeStream::execute(), externalCoupledTemperatureMixedFvPatchScalarField::externalCoupledTemperatureMixedFvPatchScalarField(), extrapolatedCalculatedFvPatchField< Type >::extrapolatedCalculatedFvPatchField(), BlendedInterfacialModel< ModelType >::F(), fanFvPatchField< Type >::fanFvPatchField(), BlendedInterfacialModel< ModelType >::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< ModelType >::K(), BlendedInterfacialModel< ModelType >::Kf(), matchedFlowRateOutletVelocityFvPatchVectorField::matchedFlowRateOutletVelocityFvPatchVectorField(), CrankNicolsonDdtScheme< Type >::meshPhi(), mixedFaPatchField< Type >::mixedFaPatchField(), mixedFvPatchField< vector >::mixedFvPatchField(), transformFaPatchField< Type >::operator=(), transformFvPatchField< Type >::operator=(), partialSlipFvPatchField< Type >::partialSlipFvPatchField(), Foam::recursiveExpand(), temperatureDependentAlphaContactAngleFvPatchScalarField::temperatureDependentAlphaContactAngleFvPatchScalarField(), timeVaryingAlphaContactAngleFvPatchScalarField::timeVaryingAlphaContactAngleFvPatchScalarField(), timeVaryingMappedFixedValueFvPatchField< Type >::timeVaryingMappedFixedValueFvPatchField(), timeVaryingMappedFixedValuePointPatchField< Type >::timeVaryingMappedFixedValuePointPatchField(), uniformDensityHydrostaticPressureFvPatchScalarField::uniformDensityHydrostaticPressureFvPatchScalarField(), uniformFixedGradientFvPatchField< Type >::uniformFixedGradientFvPatchField(), uniformFixedValueFvPatchField< Type >::uniformFixedValueFvPatchField(), uniformFixedValuePointPatchField< Type >::uniformFixedValuePointPatchField(), uniformJumpAMIFvPatchField< Type >::uniformJumpAMIFvPatchField(), uniformJumpFvPatchField< Type >::uniformJumpFvPatchField(), uniformNormalFixedValueFvPatchVectorField::uniformNormalFixedValueFvPatchVectorField(), pressureInletOutletVelocityFvPatchVectorField::updateCoeffs(), fixedNormalInletOutletVelocityFvPatchVectorField::updateCoeffs(), wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField(), wedgeFaPatchField< Type >::wedgeFaPatchField(), and wedgeFvPatchField< Type >::wedgeFvPatchField().

Here is the call graph for this function:

◆ evaluate() [2/2]

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

Definition at line 87 of file stringOpsEvaluate.C.

References evaluate(), and Foam::pos().

Here is the call graph for this function:

◆ natstrcmp()

int natstrcmp ( const char *  s1,
const char *  s2 
)

Definition at line 118 of file stringOpsSort.C.

Referenced by natural_sort::compare().

Here is the caller graph for this function: