A class for handling words, derived from Foam::string. More...
Public Member Functions | |
word ()=default | |
Default construct. 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... | |
word & | ext (const word &ending) |
Append a '.' and the ending, and return the object. More... | |
word & | operator= (const word &s) |
Copy assignment, no character validation required. More... | |
word & | operator= (word &&s) |
Move assignment, no character validation required. More... | |
word & | operator= (const string &s) |
Copy assignment from Foam::string, stripping invalid characters. More... | |
word & | operator= (string &&s) |
Move assignment from Foam::string, stripping invalid characters. More... | |
word & | operator= (const std::string &s) |
Copy assignment from std::string, stripping invalid characters. More... | |
word & | operator= (std::string &&s) |
Move assignment from std::string, stripping invalid characters. More... | |
word & | operator= (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) |
bool | hasExt () const |
Various checks for extensions. More... | |
bool | hasExt (const char *ending) const |
Various checks for extensions. More... | |
bool | hasExt (const std::string &ending) const |
Various checks for extensions. More... | |
bool | hasExt (const wordRe &ending) const |
Various checks for extensions. More... | |
bool | removeExt () |
Remove extension, returning true if string changed. More... | |
![]() | |
string ()=default | |
Default construct. 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... | |
bool | match (const std::string &text) const |
Test for equality. More... | |
string & | replace (const std::string &s1, const std::string &s2, size_type pos=0) |
string & | replaceAll (const std::string &s1, const std::string &s2, size_type pos=0) |
string & | replaceAny (const std::string &s1, const char c2, size_type pos=0) |
string & | expand (const bool allowEmpty=false) |
bool | removeRepeated (const char character) |
Remove repeated characters. More... | |
bool | removeStart (const std::string &text) |
Remove the given text from the start of the string. More... | |
bool | removeStart (const char c) |
Remove leading character, unless string is a single character. More... | |
bool | removeEnd (const std::string &text) |
Remove the given text from the end of the string. More... | |
bool | removeEnd (const char c) |
Remove trailing character, unless string is a single character. 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... | |
bool | starts_with (const std::string &s) const |
True if string starts with the given prefix (cf. C++20) More... | |
bool | starts_with (const char c) const |
True if string starts with the given character (cf. C++20) More... | |
bool | ends_with (const std::string &s) const |
True if string ends with the given suffix (cf. C++20) More... | |
bool | ends_with (const char c) const |
True if string ends with the given character (cf. C++20) More... | |
size_type | count (const char c) const |
bool | startsWith (const std::string &s) const |
Deprecated(2019-11) More... | |
bool | endsWith (const std::string &s) const |
Deprecated(2019-11) More... | |
bool | removeTrailing (const char c) |
Deprecated(2019-11) More... | |
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) |
![]() | |
template<class StringType > | |
static bool | valid (const std::string &str) |
Does the string contain valid characters only? More... | |
template<class StringType > | |
static bool | stripInvalid (std::string &str) |
Strip invalid characters from the given string. More... | |
template<class StringType > | |
static StringType | validate (const std::string &str) |
Return a valid String 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 const char *const | typeName = "string" |
The type name "string". More... | |
static int | debug |
The debug flag. More... | |
static const string | null |
An empty string. More... | |
Additional Inherited Members | |
![]() | |
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 char *ending) const |
Return true if the extension is the same as the given ending. More... | |
bool | hasExt (const std::string &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 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... | |
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.
|
default |
Default construct.
Copy construct from Foam::string.
Definition at line 76 of file wordI.H.
References word::stripInvalid().
Move construct from Foam::string.
Definition at line 87 of file wordI.H.
References word::stripInvalid().
Copy construct from std::string.
Definition at line 109 of file wordI.H.
References word::stripInvalid().
Move construct from std::string.
Definition at line 98 of file wordI.H.
References word::stripInvalid().
Copy from character array.
Definition at line 120 of file wordI.H.
References word::stripInvalid().
Copy from buffer for a maximum number of characters.
Definition at line 131 of file wordI.H.
References word::stripInvalid().
|
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 isoSurfaceTopo::isoSurfaceTopo(), dataCloud::write(), ensightCase::write(), vtkCloud::write(), vtkWrite::write(), ensightWriter::writeCollated(), and isoAdvection::writeIsoFaces().
|
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
|
inlinestatic |
Is this character valid for a word?
Definition at line 59 of file wordI.H.
References Foam::constant::universal::c, and Foam::isspace().
Referenced by cyclicAMIPolyPatch::cyclicAMIPolyPatch(), cyclicPolyPatch::cyclicPolyPatch(), ISstream::read(), VarName::valid(), keyType::valid(), wordRe::valid(), and word::validate().
|
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 45 of file word.C.
References Foam::constant::universal::c, s, and word::valid().
Referenced by exprDriver::addVariables(), fvExprDriver::evaluateVariableRemote(), STLAsciiParseManual::execute(), Foam::getStopAction(), entry::New(), Foam::operator>>(), NASedgeFormat::read(), OBJedgeFormat::read(), functionObjectList::readFunctionObject(), STARCDsurfaceFormatCore::readInpCellTable(), FIREMeshReader::readSelections(), and ABAQUSCore::readHelper::readSurfaceElements().
|
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 78 of file word.C.
References Foam::constant::universal::c, and word::valid().
|
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::expressions::patchExpr::debug, Foam::endl(), and Foam::exit().
Referenced by word::word().
Foam::word lessExt | ( | ) | const |
Return word without extension (part before last .)
Definition at line 113 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(), triSurface::New(), edgeMesh::read(), extendedEdgeMesh::read(), and Foam::readDir().
Foam::word ext | ( | ) | const |
Return file name extension (part after last .)
Definition at line 126 of file word.C.
References string::ext().
Referenced by edgeMesh::canRead(), UnsortedMeshedSurface< Face >::canRead(), MeshedSurface< Foam::face >::canRead(), triSurface::canRead(), extendedEdgeMesh::canRead(), fileWriter::ext(), dlLibraryTable::fullname(), IOobject::group(), edgeMesh::New(), UnsortedMeshedSurface< Face >::New(), MeshedSurface< Foam::face >::New(), extendedEdgeMesh::New(), triSurface::New(), edgeMesh::read(), extendedEdgeMesh::read(), MeshedSurfaceProxy< Face >::write(), edgeMesh::write(), UnsortedMeshedSurface< Face >::write(), surfMesh::write(), MeshedSurface< Foam::face >::write(), and triSurface::write().
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 132 of file word.C.
References string::ext().
|
inline |
Copy assignment, no character validation required.
Self-assignment is a no-op
Definition at line 166 of file wordI.H.
References Foam::FieldOps::assign(), and s.
|
inline |
Move assignment, no character validation required.
Self-assignment is a no-op
Definition at line 177 of file wordI.H.
References Foam::FieldOps::assign(), and s.
|
inline |
Copy assignment from Foam::string, stripping invalid characters.
Definition at line 188 of file wordI.H.
References Foam::FieldOps::assign(), and s.
|
inline |
Move assignment from Foam::string, stripping invalid characters.
Definition at line 196 of file wordI.H.
References Foam::FieldOps::assign(), and s.
|
inline |
Copy assignment from std::string, stripping invalid characters.
Definition at line 204 of file wordI.H.
References Foam::FieldOps::assign(), and s.
|
inline |
Move assignment from std::string, stripping invalid characters.
Definition at line 212 of file wordI.H.
References Foam::FieldOps::assign(), and s.
|
inline |
Copy, stripping invalid characters.
Definition at line 220 of file wordI.H.
References Foam::FieldOps::assign(), and s.
|
inline |
Definition at line 35 of file wordI.H.
References Foam::output().
|
inline |
Definition at line 48 of file wordI.H.
References Foam::output().
|
inline |
Various checks for extensions.
Definition at line 56 of file stringI.H.
Referenced by Foam::readDir().
|
inline |
|
static |
Debugging.
Definition at line 77 of file word.H.
Referenced by keyType::setType(), keyType::uncompile(), and wordRe::uncompile().
|
static |
An empty word.
Definition at line 80 of file word.H.
Referenced by surfaceZonesInfo::addCellZonesToMesh(), FIREMeshReader::addPatches(), vtmWriter::append(), minMaxCondition::apply(), interfaceEntry::canonicalName(), surfaceFormatsCore::checkFile(), fluxSummary::checkFlowType(), externalCoupled::compositeName(), pointPatch::constraintType(), pointPatchField< vector >::constraintType(), cyclicAMIPolyPatch::cyclicAMIPolyPatch(), cyclicPolyPatch::cyclicPolyPatch(), STLAsciiParseManual::execute(), fileOperation::exists(), masterUncollatedFileOperation::exists(), string::ext(), faMesh::faMesh(), fvExpressionField::fieldName(), Foam::filteredName(), surfaceFormatsCore::findFile(), boundaryRegion::findIndex(), cellTable::findIndex(), Time::findInstancePath(), topoSet::findIOobject(), fvExprDriver::getFieldClassName(), IOobject::group(), Foam::interpolate(), CloudSubModelBase< CloudType >::localPath(), subModelBase::localPath(), polyTopoChange::makeMesh(), displacementMotionSolverMeshMover::move(), basicSolidChemistryModel::New(), coordinateSystem::New(), collatedFileOperation::objectPath(), properties::objectResultType(), orderedPhasePair::otherName(), cyclicAMIPolyPatch::periodicPatchID(), liquidFilmBase::pg(), rawIOField< Type >::rawIOField(), decomposedBlockData::read(), regionFunctionObject::read(), rigidBodyMotion::read(), MRFZone::read(), BilgerMixtureFraction::read(), sampledSurfaces::read(), fileOperation::readObjects(), masterUncollatedFileOperation::readObjects(), reference::reference(), surfaceFormatsCore::relativeFilePath(), rotatingPressureInletOutletVelocityFvPatchVectorField::rotatingPressureInletOutletVelocityFvPatchVectorField(), sizeDistribution::setCellZoneCells(), forces::setCoordinateSystem(), sensitivitySurfacePoints::setSuffixName(), sensitivitySurface::setSuffixName(), triSurface::triSurface(), triSurfaceMesh::triSurfaceMesh(), nutWallFunctionFvPatchScalarField::U(), UnsortedMeshedSurface< Face >::UnsortedMeshedSurface(), token::wordToken(), surfaceSlipDisplacementPointPatchVectorField::write(), surfaceDisplacementPointPatchVectorField::write(), vtkWrite::write(), cyclicAMIPolyPatch::write(), mappedPatchBase::write(), nutWallFunctionFvPatchScalarField::writeLocalEntries(), Foam::writeMeshObject(), and NURBS3DSurface::writeVTK().