word Class Reference

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

Inheritance diagram for word:
[legend]
Collaboration diagram for word:
[legend]

Public Member Functions

 word ()=default
 Construct null. More...
 
 word (const word &)=default
 Copy construct. More...
 
 word (word &&w)=default
 Move construct. More...
 
 word (const string &s, bool doStrip=true)
 Copy construct from Foam::string. More...
 
 word (string &&s, bool doStrip=true)
 Move construct from Foam::string. More...
 
 word (const std::string &s, bool doStrip=true)
 Copy construct from std::string. More...
 
 word (std::string &&s, bool doStrip=true)
 Move construct from std::string. More...
 
 word (const char *s, bool doStrip=true)
 Copy from character array. More...
 
 word (const char *s, size_type len, bool doStrip)
 Copy from buffer for a maximum number of characters. More...
 
 word (Istream &is)
 Construct from Istream. More...
 
void stripInvalid ()
 Strip invalid characters from this word. More...
 
word lessExt () const
 Return word without extension (part before last .) More...
 
word ext () const
 Return file name extension (part after last .) More...
 
wordext (const word &ending)
 Append a '.' and the ending, and return the object. More...
 
bool hasExt () const
 Return true if it has an extension or simply ends with a '.'. More...
 
bool hasExt (const word &ending) const
 Return true if the extension is the same as the given ending. More...
 
bool hasExt (const wordRe &ending) const
 Return true if the extension matches the given ending. More...
 
bool removeExt ()
 Remove extension, returning true if string changed. More...
 
wordoperator= (const word &s)
 Copy assignment, no character validation required. More...
 
wordoperator= (word &&s)
 Move assignment, no character validation required. More...
 
wordoperator= (const string &s)
 Copy assignment from Foam::string, stripping invalid characters. More...
 
wordoperator= (string &&s)
 Move assignment from Foam::string, stripping invalid characters. More...
 
wordoperator= (const std::string &s)
 Copy assignment from std::string, stripping invalid characters. More...
 
wordoperator= (std::string &&s)
 Move assignment from std::string, stripping invalid characters. More...
 
wordoperator= (const char *s)
 Copy, stripping invalid characters. More...
 
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)
 
- Public Member Functions inherited from string
 string ()=default
 Construct null. 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...
 
size_type count (const char c) const
 
bool match (const std::string &text) const
 Test for equality. More...
 
stringreplace (const string &oldStr, const string &newStr, const size_type start=0)
 
stringreplaceAll (const string &oldStr, const string &newStr, const size_type start=0)
 
stringexpand (const bool allowEmpty=false)
 Expand initial tildes and all occurrences of environment variables. More...
 
bool removeRepeated (const char character)
 Remove repeated characters. More...
 
string removeRepeated (const char character) const
 Return string with repeated characters removed. More...
 
bool removeTrailing (const char character)
 Remove trailing character, unless string is a single character. More...
 
string removeTrailing (const char character) const
 Return string with trailing character removed,. More...
 
bool removeStart (const std::string &text)
 Remove the given text from the start of the string. More...
 
bool removeEnd (const std::string &text)
 Remove the given text from the end of the string. More...
 
bool startsWith (const std::string &text) const
 True if the string starts with the given text. More...
 
bool endsWith (const std::string &text) const
 True if the string ends with the given text. 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...
 
template<class String >
Foam::string quotemeta (const std::string &str, const char quote)
 

Static Public Member Functions

template<class PrimitiveType >
static word printf (const char *fmt, const PrimitiveType &val)
 Use a printf-style formatter for a primitive. More...
 
template<class PrimitiveType >
static word printf (const std::string &fmt, const PrimitiveType &val)
 Use a printf-style formatter for a primitive. More...
 
static bool valid (char c)
 Is this character valid for a word? More...
 
static word validate (const std::string &s, const bool prefix=false)
 Construct validated word (no invalid characters). More...
 
static word validate (const char *first, const char *last, const bool prefix=false)
 
- Static Public Member Functions inherited from string
template<class String >
static bool valid (const std::string &str)
 Does the string contain valid characters only? More...
 
template<class String >
static bool meta (const std::string &str, const char quote='\\')
 Does this string contain meta-characters? More...
 
template<class String >
static bool stripInvalid (std::string &str)
 Strip invalid characters from the given string. More...
 
template<class String >
static String validate (const std::string &str)
 Return a valid String from the given string. More...
 
template<class String >
static string quotemeta (const std::string &str, const char quote='\\')
 Return a String with quoted meta-characters from the given string. More...
 

Static Public Attributes

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

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. More...
 
word ext () const
 Return file name extension (part after last .) More...
 
bool ext (const word &ending)
 Append a '.' and the ending. More...
 
bool hasPath () const
 Return true if it contains a '/' character. More...
 
bool hasExt () const
 Return true if it has an extension or simply ends with a '.'. More...
 
bool hasExt (const word &ending) const
 Return true if the extension is the same as the given ending. More...
 
bool hasExt (const wordRe &ending) const
 Return true if the extension matches the given ending. More...
 
bool removeExt ()
 Remove extension, returning true if string changed. More...
 
bool removePath ()
 Remove leading path, returning 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...
 

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 61 of file word.H.

Constructor & Destructor Documentation

◆ word() [1/10]

word ( )
default

Construct null.

◆ word() [2/10]

word ( const word )
default

Copy construct.

◆ word() [3/10]

word ( word &&  w)
default

Move construct.

◆ word() [4/10]

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

Copy construct from Foam::string.

Definition at line 61 of file wordI.H.

References word::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 72 of file wordI.H.

References word::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 94 of file wordI.H.

References word::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 83 of file wordI.H.

References word::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 105 of file wordI.H.

References word::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 116 of file wordI.H.

References word::stripInvalid().

Here is the call graph for this function:

◆ word() [10/10]

word ( Istream is)
explicit

Construct from Istream.

Definition at line 33 of file wordIO.C.

Member Function Documentation

◆ printf() [1/4]

static 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

Referenced by dataCloud::write(), ensightCase::write(), vtkCloud::write(), vtkWrite::write(), ensightWriter::writeCollated(), and isoAdvection::writeIsoFaces().

Here is the caller graph for this function:

◆ printf() [2/4]

static 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

◆ valid()

bool valid ( char  c)
inlinestatic

Is this character valid for a word?

Definition at line 129 of file wordI.H.

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

Referenced by cyclicAMIPolyPatch::cyclicAMIPolyPatch(), cyclicPolyPatch::cyclicPolyPatch(), ISstream::read(), VarName::valid(), and word::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

Construct validated word (no invalid characters).

Optionally prefix any leading digit with '_' to have words that work nicely as dictionary keywords.

Definition at line 43 of file word.C.

References Foam::constant::universal::c, s, and word::valid().

Referenced by STLAsciiParseRagel::execute(), STLAsciiParseManual::execute(), Foam::getStopAction(), entry::New(), OBJedgeFormat::read(), NASedgeFormat::read(), functionObjectList::readFunctionObject(), STARCDsurfaceFormatCore::readInpCellTable(), and FIREMeshReader::readSelections().

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

◆ 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 76 of file word.C.

References Foam::constant::universal::c, and word::valid().

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 144 of file wordI.H.

References Foam::endl(), and Foam::exit().

Referenced by word::word().

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

◆ lessExt()

Foam::word lessExt ( ) const

Return word without extension (part before last .)

Definition at line 111 of file word.C.

Referenced by edgeMesh::canRead(), UnsortedMeshedSurface< Face >::canRead(), MeshedSurface< Foam::face >::canRead(), triSurface::canRead(), extendedEdgeMesh::canRead(), IOobject::member(), edgeMesh::New(), UnsortedMeshedSurface< Face >::New(), MeshedSurface< Foam::face >::New(), extendedEdgeMesh::New(), edgeMesh::read(), UnsortedMeshedSurface< Face >::read(), MeshedSurface< Foam::face >::read(), extendedEdgeMesh::read(), and Foam::readDir().

Here is the caller graph for this function:

◆ ext() [1/2]

Foam::word ext ( ) const

Return file name extension (part after last .)

Definition at line 124 of file word.C.

References string::ext().

Referenced by edgeMesh::canRead(), UnsortedMeshedSurface< Face >::canRead(), MeshedSurface< Foam::face >::canRead(), triSurface::canRead(), extendedEdgeMesh::canRead(), fileWriter::ext(), IOobject::group(), edgeMesh::New(), UnsortedMeshedSurface< Face >::New(), MeshedSurface< Foam::face >::New(), extendedEdgeMesh::New(), edgeMesh::read(), UnsortedMeshedSurface< Face >::read(), MeshedSurface< Foam::face >::read(), extendedEdgeMesh::read(), FIREMeshReader::readGeometry(), MeshedSurfaceProxy< Face >::write(), edgeMesh::write(), UnsortedMeshedSurface< Face >::write(), MeshedSurface< Foam::face >::write(), surfMesh::write(), and triSurface::write().

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)

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 130 of file word.C.

References string::ext().

Here is the call graph for this function:

◆ hasExt() [1/3]

bool hasExt ( ) const
inline

Return true if it has an extension or simply ends with a '.'.

Definition at line 164 of file wordI.H.

References string::hasExt().

Referenced by Foam::readDir().

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

◆ hasExt() [2/3]

bool hasExt ( const word ending) const

Return true if the extension is the same as the given ending.

Definition at line 137 of file word.C.

References string::hasExt().

Here is the call graph for this function:

◆ hasExt() [3/3]

bool hasExt ( const wordRe ending) const

Return true if the extension matches the given ending.

Definition at line 143 of file word.C.

References string::hasExt().

Here is the call graph for this function:

◆ removeExt()

bool removeExt ( )
inline

Remove extension, returning true if string changed.

Definition at line 170 of file wordI.H.

References string::removeExt().

Here is the call 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 178 of file wordI.H.

References s.

◆ operator=() [2/7]

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

Move assignment, no character validation required.

Self-assignment is a no-op

Definition at line 189 of file wordI.H.

References s.

◆ operator=() [3/7]

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

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

Definition at line 200 of file wordI.H.

References s.

◆ operator=() [4/7]

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

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

Definition at line 208 of file wordI.H.

References s.

◆ operator=() [5/7]

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

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

Definition at line 216 of file wordI.H.

References s.

◆ operator=() [6/7]

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

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

Definition at line 224 of file wordI.H.

References s.

◆ operator=() [7/7]

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

Copy, stripping invalid characters.

Definition at line 232 of file wordI.H.

References s.

◆ printf() [3/4]

Foam::word printf ( const char *  fmt,
const PrimitiveType &  val 
)
inline

Definition at line 35 of file wordI.H.

References Foam::val.

◆ printf() [4/4]

Foam::word printf ( const std::string &  fmt,
const PrimitiveType &  val 
)
inline

Definition at line 48 of file wordI.H.

References Foam::val.

Member Data Documentation

◆ typeName

const char *const typeName = "word"
static

The typeName.

Definition at line 70 of file word.H.

◆ debug

int debug
static

Debugging.

Definition at line 73 of file word.H.

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

◆ null

const Foam::word null
static

An empty word.

Definition at line 76 of file word.H.

Referenced by surfaceZonesInfo::addCellZonesToMesh(), FIREMeshReader::addPatches(), vtmWriter::append(), minMaxCondition::apply(), interfaceEntry::canonicalName(), fluxSummary::checkFlowType(), externalCoupled::compositeName(), pointPatch::constraintType(), pointPatchField< vector >::constraintType(), cyclicAMIPolyPatch::cyclicAMIPolyPatch(), cyclicPolyPatch::cyclicPolyPatch(), STLAsciiParseManual::execute(), fileOperation::exists(), masterUncollatedFileOperation::exists(), string::ext(), boundaryRegion::findIndex(), cellTable::findIndex(), Time::findInstancePath(), topoSet::findIOobject(), IOobject::group(), basicThermo::heBoundaryBaseTypes(), Foam::interpolate(), displacementMotionSolverMeshMover::move(), MRFZone::MRFZone(), coordinateSystem::New(), collatedFileOperation::objectPath(), stateFunctionObject::objectResultType(), orderedPhasePair::otherName(), cyclicPeriodicAMIPolyPatch::periodicPatchID(), polyPatch::polyPatch(), porosityModel::porosityModel(), decomposedBlockData::read(), regionFunctionObject::read(), sampledSurfaces::read(), functionObjectList::readFunctionObject(), fileOperation::readObjects(), masterUncollatedFileOperation::readObjects(), reference::reference(), rotatingPressureInletOutletVelocityFvPatchVectorField::rotatingPressureInletOutletVelocityFvPatchVectorField(), forces::setCoordinateSystem(), nutWallFunctionFvPatchScalarField::U(), token::wordToken(), surfaceSlipDisplacementPointPatchVectorField::write(), surfaceDisplacementPointPatchVectorField::write(), nutWallFunctionFvPatchScalarField::writeLocalEntries(), and Foam::writeMeshObject().


The documentation for this class was generated from the following files: