Loading...
Searching...
No Matches
word Class Reference

A class for handling words, derived from Foam::string. More...

#include <word.H>

Inheritance diagram for word:
Collaboration diagram for word:

Public Member Functions

 word ()=default
 Default construct.
 word (const word &)=default
 Copy construct.
 word (word &&w)=default
 Move construct.
 word (const string &s, bool doStrip=true)
 Copy construct from Foam::string.
 word (string &&s, bool doStrip=true)
 Move construct from Foam::string.
 word (const std::string &s, bool doStrip=true)
 Copy construct from std::string.
 word (std::string &&s, bool doStrip=true)
 Move construct from std::string.
 word (const char *s, bool doStrip=true)
 Copy from character array.
 word (const char *s, size_type len, bool doStrip)
 Copy from buffer for a maximum number of characters.
 word (Istream &is)
 Construct from Istream.
void stripInvalid ()
 Strip invalid characters from this word.
word ext () const
 Return file name extension (part after last .).
wordext (const word &ending)
 Append a '.' and the ending, and return the object.
wordreplace_ext (const word &ending)
 Remove extension (if any) and append a new one.
word lessExt () const
 Return word without extension (part before last .).
wordoperator= (const word &s)
 Copy assignment, no character validation required.
wordoperator= (word &&s)
 Move assignment, no character validation required.
wordoperator= (const string &s)
 Copy assignment from Foam::string, stripping invalid characters.
wordoperator= (string &&s)
 Move assignment from Foam::string, stripping invalid characters.
wordoperator= (const std::string &s)
 Copy assignment from std::string, stripping invalid characters.
wordoperator= (std::string &&s)
 Move assignment from std::string, stripping invalid characters.
wordoperator= (const char *s)
 Copy, stripping invalid characters.
bool hasExt () const
 Same as has_ext().
bool hasExt (const std::string &s) const
 Same as has_ext().
bool removeExt ()
 Same as remove_ext().
template<class PrimitiveType>
Foam::word printf (const char *fmt, const PrimitiveType &val)
template<class PrimitiveType>
Foam::word printf (const std::string &fmt, const PrimitiveType &val)
bool remove_ext ()
 Remove extension, return true if string changed.
bool has_ext () const
 Various checks for extensions.
bool has_ext (const char *ending) const
 Various checks for extensions.
bool has_ext (const std::string &ending) const
 Various checks for extensions.
bool has_ext (const wordRe &ending) const
 Various checks for extensions.
Public Member Functions inherited from string
 string ()=default
 Default construct.
 string (const std::string &str)
 Copy construct from std::string.
 string (std::string &&str)
 Move construct from std::string.
 string (const char *str)
 Construct as copy of character array.
 string (const char *str, const size_type len)
 Construct as copy with a maximum number of characters.
 string (const char c)
 Construct from a single character.
 string (const size_type len, const char c)
 Construct fill copies of a single character.
 string (Istream &is)
 Construct from Istream.
bool match (const std::string &text) const
 Test for equality.
stringreplace (const std::string &s1, const std::string &s2, size_type pos=0)
 Replace first occurrence of sub-string s1 with s2, beginning at pos.
stringreplaceAll (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.
stringreplaceAny (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.
stringexpand (const bool allowEmpty=false)
 Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::expand.
bool removeRepeated (const char character)
 Remove repeated characters.
bool removeStart (const std::string &text)
 Remove the given text from the start of the string.
bool removeStart (const char c)
 Remove leading character, unless string is a single character.
bool removeEnd (const std::string &text)
 Remove the given text from the end of the string.
bool removeEnd (const char c)
 Remove trailing character, unless string is a single character.
void swap (std::string &str)
 Swap contents. Self-swapping is a no-op.
bool operator() (const std::string &text) const
 Test for equality. Allows use as a predicate.
bool contains (char c) const noexcept
 True if string contains given character (cf. C++23).
bool contains (const std::string &s) const noexcept
 True if string contains given [string view] substring (cf. C++23).
bool contains (const char *s) const
 True if string contains given substring (cf. C++23).
bool starts_with (char c) const
 True if string starts with given character (cf. C++20).
bool starts_with (const std::string &s) const
 True if string starts with given [string view] prefix (C++20).
bool starts_with (const char *s) const
 True if string starts with given prefix (C++20).
bool ends_with (char c) const
 True if string ends with given character (cf. C++20).
bool ends_with (const std::string &s) const
 True if string ends with given [string view] suffix (cf. C++20).
bool ends_with (const char *s) const
 True if string ends with given suffix (cf. C++20).
size_type count (const char c) const
 Count the number of occurrences of the specified character in the string.
bool startsWith (const std::string &s) const
 Deprecated(2019-11).
bool endsWith (const std::string &s) const
 Deprecated(2019-11).
bool removeTrailing (const char c)
 Deprecated(2019-11).

Static Public Member Functions

template<class PrimitiveType>
static word printf (const char *fmt, const PrimitiveType &val)
 Use a printf-style formatter for a primitive.
template<class PrimitiveType>
static word printf (const std::string &fmt, const PrimitiveType &val)
 Use a printf-style formatter for a primitive.
static bool valid (char c)
 Is this character valid for a word?
static word validate (const std::string &s, const bool prefix=false)
 Construct validated word (no invalid characters).
static word validate (const char *first, const char *last, const bool prefix=false)
 Construct validated word (no invalid characters) from a sequence of characters in the range [first,last),.
Static Public Member Functions inherited from string
static std::string::size_type length (const char *s)
 Length of the character sequence (with nullptr protection).
static std::string::size_type length (const std::string &s)
 The length of the string.
template<class StringType>
static bool valid (const std::string &str)
 Does the string contain valid characters only?
template<class StringType>
static bool stripInvalid (std::string &str)
 Strip invalid characters from the given string.
template<class StringType>
static StringType validate (const std::string &str)
 Return a valid String from the given string.

Static Public Attributes

static const char *const typeName = "word"
 The typeName.
static int debug
 Debugging.
static const word null
 An empty word.
Static Public Attributes inherited from string
static const char *const typeName = "string"
 The type name "string".
static int debug
 The debug flag.
static const string null
 An empty string.

Additional Inherited Members

Protected Member Functions inherited from string
std::string::size_type find_ext () const
 Find position of a file extension dot, return npos on failure.
word ext () const
 Return file name extension (part after last .).
bool ext (const word &ending)
 Append a '.' and the ending.
bool has_ext () const
 Return true if it has an extension or simply ends with a '.'.
bool has_ext (const char *ending) const
 Return true if the extension is the same as the given ending.
bool has_ext (const std::string &ending) const
 Return true if the extension is the same as the given ending.
bool has_ext (const wordRe &ending) const
 Return true if the extension matches the given ending.
bool remove_path ()
 Remove leading path, return true if string changed.
bool remove_ext ()
 Remove extension, return true if string changed.
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.
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.
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.

Detailed Description

A class for handling words, derived from Foam::string.

A word is a string of characters without whitespace, quotes, slashes, semicolons or brace brackets. Words are delimited by whitespace.

Source files

Definition at line 63 of file word.H.

Constructor & Destructor Documentation

◆ word() [1/10]

◆ word() [2/10]

word ( const word & )
default

Copy construct.

References word().

Here is the call graph for this function:

◆ word() [3/10]

word ( word && w)
default

Move construct.

References s(), and word().

Here is the call graph for this function:

◆ word() [4/10]

word ( const string & s,
bool doStrip = true )
inline

Copy construct from Foam::string.

Definition at line 69 of file wordI.H.

References s(), string::string(), and stripInvalid().

Here is the call graph for this function:

◆ word() [5/10]

word ( string && s,
bool doStrip = true )
inline

Move construct from Foam::string.

Definition at line 80 of file wordI.H.

References s(), string::string(), and stripInvalid().

Here is the call graph for this function:

◆ word() [6/10]

word ( const std::string & s,
bool doStrip = true )
inline

Copy construct from std::string.

Definition at line 102 of file wordI.H.

References s(), string::string(), and stripInvalid().

Here is the call graph for this function:

◆ word() [7/10]

word ( std::string && s,
bool doStrip = true )
inline

Move construct from std::string.

Definition at line 91 of file wordI.H.

References s(), string::string(), and stripInvalid().

Here is the call graph for this function:

◆ word() [8/10]

word ( const char * s,
bool doStrip = true )
inline

Copy from character array.

Definition at line 113 of file wordI.H.

References s(), string::string(), and stripInvalid().

Here is the call graph for this function:

◆ word() [9/10]

word ( const char * s,
size_type len,
bool doStrip )
inline

Copy from buffer for a maximum number of characters.

Definition at line 124 of file wordI.H.

References s(), string::string(), and stripInvalid().

Here is the call graph for this function:

◆ word() [10/10]

word ( Istream & is)
explicit

Construct from Istream.

Definition at line 28 of file wordIO.C.

Member Function Documentation

◆ printf() [1/4]

template<class PrimitiveType>
word printf ( const char * fmt,
const PrimitiveType & val )
inlinestatic

Use a printf-style formatter for a primitive.

The representation is not checked for valid characters - it is assumed that the caller knows what they are doing

References word().

Referenced by isoSurfaceTopo::isoSurfaceTopo(), ensightCase::write(), dataCloud::write(), and isoAdvection::writeIsoFaces().

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

◆ printf() [2/4]

template<class PrimitiveType>
word printf ( const std::string & fmt,
const PrimitiveType & val )
inlinestatic

Use a printf-style formatter for a primitive.

The representation is not checked for valid characters - it is assumed that the caller knows what they are doing

References string::has_ext(), string::remove_ext(), s(), and word().

Here is the call graph for this function:

◆ valid()

bool valid ( char c)
inlinestatic

Is this character valid for a word?

Definition at line 52 of file wordI.H.

References Foam::isspace().

Referenced by ISstream::read(), ISstream::read(), VarName::valid(), keyType::valid(), wordRe::valid(), validate(), and validate().

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

◆ validate() [1/2]

Foam::word validate ( const std::string & s,
const bool prefix = false )
static

◆ validate() [2/2]

Foam::word validate ( const char * first,
const char * last,
const bool prefix = false )
static

Construct validated word (no invalid characters) from a sequence of characters in the range [first,last),.

Optionally prefix any leading digit with '_'.

Definition at line 71 of file word.C.

References Foam::isdigit(), valid(), and word().

Here is the call graph for this function:

◆ stripInvalid()

void stripInvalid ( )
inline

Strip invalid characters from this word.

Trips an abort on invalid characters for debug 2 or greater

Definition at line 137 of file wordI.H.

References debug, and string::stripInvalid().

Referenced by operator=(), operator=(), operator=(), operator=(), operator=(), word(), word(), word(), word(), word(), and word().

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

◆ ext() [1/2]

Foam::word ext ( ) const
inline

Return file name extension (part after last .).

Definition at line 171 of file wordI.H.

References string::ext().

Referenced by dlLibraryTable::fullname(), IOobject::group(), coordSetWriter::suffix(), and coordSetWriter::suffix().

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

◆ ext() [2/2]

Foam::word & ext ( const word & ending)
inline

Append a '.' and the ending, and return the object.

The '.' and ending will not be added when the ending is empty, or when the file name is empty or ended with a '/'.

Definition at line 177 of file wordI.H.

References string::ext(), and word().

Here is the call graph for this function:

◆ replace_ext()

Foam::word & replace_ext ( const word & ending)
inline

Remove extension (if any) and append a new one.

Definition at line 184 of file wordI.H.

References string::ext(), string::remove_ext(), and word().

Here is the call graph for this function:

◆ lessExt()

Foam::word lessExt ( ) const
inline

Return word without extension (part before last .).

Definition at line 192 of file wordI.H.

References string::find_ext().

Referenced by IOobject::member().

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

◆ operator=() [1/7]

Foam::word & operator= ( const word & s)
inline

Copy assignment, no character validation required.

Self-assignment is a no-op

Definition at line 207 of file wordI.H.

References s(), and word().

Here is the call graph for this function:

◆ operator=() [2/7]

Foam::word & operator= ( word && s)
inline

Move assignment, no character validation required.

Self-assignment is a no-op

Definition at line 218 of file wordI.H.

References s(), and word().

Here is the call graph for this function:

◆ operator=() [3/7]

Foam::word & operator= ( const string & s)
inline

Copy assignment from Foam::string, stripping invalid characters.

Definition at line 229 of file wordI.H.

References s(), and stripInvalid().

Here is the call graph for this function:

◆ operator=() [4/7]

Foam::word & operator= ( string && s)
inline

Move assignment from Foam::string, stripping invalid characters.

Definition at line 237 of file wordI.H.

References s(), and stripInvalid().

Here is the call graph for this function:

◆ operator=() [5/7]

Foam::word & operator= ( const std::string & s)
inline

Copy assignment from std::string, stripping invalid characters.

Definition at line 245 of file wordI.H.

References s(), and stripInvalid().

Here is the call graph for this function:

◆ operator=() [6/7]

Foam::word & operator= ( std::string && s)
inline

Move assignment from std::string, stripping invalid characters.

Definition at line 253 of file wordI.H.

References s(), and stripInvalid().

Here is the call graph for this function:

◆ operator=() [7/7]

Foam::word & operator= ( const char * s)
inline

Copy, stripping invalid characters.

Definition at line 261 of file wordI.H.

References s(), and stripInvalid().

Here is the call graph for this function:

◆ hasExt() [1/2]

bool hasExt ( ) const
inline

Same as has_ext().

Definition at line 287 of file word.H.

References has_ext().

Here is the call graph for this function:

◆ hasExt() [2/2]

bool hasExt ( const std::string & s) const
inline

Same as has_ext().

Definition at line 292 of file word.H.

References has_ext(), and s().

Here is the call graph for this function:

◆ removeExt()

bool removeExt ( )
inline

Same as remove_ext().

Definition at line 297 of file word.H.

References remove_ext().

Here is the call graph for this function:

◆ printf() [3/4]

template<class PrimitiveType>
Foam::word printf ( const char * fmt,
const PrimitiveType & val )
inline

Definition at line 27 of file wordI.H.

References string::string_printf(), and word().

Here is the call graph for this function:

◆ printf() [4/4]

template<class PrimitiveType>
Foam::word printf ( const std::string & fmt,
const PrimitiveType & val )
inline

Definition at line 40 of file wordI.H.

References string::string_printf(), and word().

Here is the call graph for this function:

◆ remove_ext()

bool remove_ext ( )
inline

Remove extension, return true if string changed.

Definition at line 162 of file stringI.H.

Referenced by removeExt().

Here is the caller graph for this function:

◆ has_ext() [1/4]

bool has_ext ( ) const
inline

Various checks for extensions.

Definition at line 135 of file stringI.H.

Referenced by hasExt(), and hasExt().

Here is the caller graph for this function:

◆ has_ext() [2/4]

bool has_ext ( const char * ending) const
inline

Various checks for extensions.

Definition at line 142 of file stringI.H.

◆ has_ext() [3/4]

bool has_ext ( const std::string & ending) const
inline

Various checks for extensions.

Definition at line 147 of file stringI.H.

◆ has_ext() [4/4]

bool has_ext ( const wordRe & ending) const

Various checks for extensions.

Definition at line 152 of file string.C.

Member Data Documentation

◆ typeName

const char *const typeName = "word"
static

The typeName.

Definition at line 74 of file word.H.

◆ debug

int debug
static

Debugging.

Definition at line 79 of file word.H.

Referenced by keyType::setType(), stripInvalid(), keyType::uncompile(), and wordRe::uncompile().

◆ null

const Foam::word null
static

An empty word.

Definition at line 84 of file word.H.

Referenced by adjointSensitivity::accumulateIntegrand(), FIREMeshReader::addPatches(), faceZoneSet::addSet(), coordSetWriter::appendField(), vtmWriter::beginBlock(), surfaceFormatsCore::checkFile(), surfaceFormatsCore::checkFile(), fluxSummary::checkFlowType(), MRFZone::ClassName(), coordinateSystem::Clone(), externalCoupled::compositeName(), pointPatch::constraintType(), pointPatchFieldBase::constraintType(), Foam::createZeroBoundaryPtr(), optionList::d2dt2(), coordSetWriter::declareRunTimeSelectionTable(), fluidThermo::declareRunTimeSelectionTable(), patchDistMethod::declareRunTimeSelectionTable(), psiReactionThermo::declareRunTimeSelectionTable(), psiThermo::declareRunTimeSelectionTable(), psiuReactionThermo::declareRunTimeSelectionTable(), rhoReactionThermo::declareRunTimeSelectionTable(), rhoThermo::declareRunTimeSelectionTable(), solidReactionThermo::declareRunTimeSelectionTable(), solidThermo::declareRunTimeSelectionTable(), vtmWriter::endBlock(), STLAsciiParseManual::execute(), fileOperation::exists(), masterUncollatedFileOperation::exists(), faMesh::faMesh(), fvExpressionField::fieldName(), Foam::filteredName(), surfaceFormatsCore::findFile(), surfaceFormatsCore::findFile(), topoSet::findIOobject(), topoSet::findIOobject(), Enum< EnumType >::get(), fvExprDriver::getFieldClassName(), sizeDistribution::initialise(), Foam::interpolate(), faMeshTools::loadOrCreateMesh(), faMeshTools::loadOrCreateMesh(), polyTopoChange::makeMesh(), dynamicRefineFvMesh::mapFields(), MeshedSurface< Face >::MeshedSurface(), displacementMotionSolverMeshMover::move(), basicSolidChemistryModel::New(), basicThermo::New(), basicThermo::New(), basicThermo::New(), combustionModel::New(), faePatchField< Type >::New(), faPatchField< Type >::New(), Function1< Type >::New(), Function1< Type >::New(), fvPatchField< Type >::New(), fvsPatchField< Type >::New(), pointPatchField< Type >::New(), Function1< label >::NewCompat(), Function1< Type >::NewIfPresent(), faMeshTools::newMesh(), collatedFileOperation::objectPath(), properties::objectResultType(), blockDescriptor::operator=(), surfacePatch::operator=(), surfMesh::operator=(), surfZone::operator=(), orderedPhasePair::otherName(), outletMappedUniformInletFvPatchField< Type >::outletMappedUniformInletFvPatchField(), decomposedBlockData::read(), BilgerMixtureFraction::read(), regionFunctionObject::read(), moleFractions< ThermoType >::read(), rigidBodyMotion::read(), sampledSurfaces::read(), reference::reference(), polyMesh::regionName(), surfaceFormatsCore::relativeFilePath(), sampledPatchInternalField::sampledPatchInternalField(), Foam::serializeHex(), sizeDistribution::setCellZoneCells(), PDRobstacle::setFromLegacy(), sensitivitySurfacePoints::setSuffixName(), faceZoneSet::subset(), faceZoneSet::subtractSet(), StandardChemistryModel< ReactionThermo, ThermoType >::tc(), triSurface::triSurface(), IOobject::typeHeaderOk(), fieldExpression::TypeName(), fieldsExpression::TypeName(), dynamicRefineFvMesh::unrefine(), UnsortedMeshedSurface< Face >::UnsortedMeshedSurface(), token::wordToken(), edgeSlipDisplacementPointPatchVectorField::write(), FLMAsurfaceFormat< Face >::write(), X3DsurfaceFormat< Face >::write(), multiFieldValue::write(), mappedMixedFieldFvPatchField< Type >::write(), mappedMixedFvPatchField< Type >::write(), mappedPatchBase::write(), MeshedSurface< face >::write(), pointAttractionDisplacementPointPatchVectorField::write(), surfaceDisplacementPointPatchVectorField::write(), surfaceSlipDisplacementPointPatchVectorField::write(), UnsortedMeshedSurface< face >::write(), caseInfo::writeFileDicts(), nutWallFunctionFvPatchScalarField::writeLocalEntries(), Foam::writeMeshObject(), functionObjectList::~functionObjectList(), sensitivityMultiple::~sensitivityMultiple(), sensitivitySurfacePoints::~sensitivitySurfacePoints(), and topOSource::~topOSource().


The documentation for this class was generated from the following files:
  • src/OpenFOAM/primitives/strings/word/word.H
  • src/OpenFOAM/primitives/strings/word/word.C
  • src/OpenFOAM/primitives/strings/word/wordI.H
  • src/OpenFOAM/primitives/strings/word/wordIO.C