A class for handling character strings derived from std::string. More...


Classes | |
| struct | hash |
| Deprecated hashing functor - use hasher. More... | |
| struct | hasher |
| Hashing functor for string and derived string classes. More... | |
Public Member Functions | |
| 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) |
| Replace first occurrence of sub-string s1 with s2, beginning at pos. More... | |
| string & | replaceAll (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. More... | |
| string & | replaceAny (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. More... | |
| string & | expand (const bool allowEmpty=false) |
| Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::expand. More... | |
| 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 | contains (char c) const noexcept |
| True if string contains given character (cf. C++23) More... | |
| bool | contains (const std::string &s) const noexcept |
| True if string contains given [string view] substring (cf. C++23) More... | |
| bool | contains (const char *s) const |
| True if string contains given substring (cf. C++23) More... | |
| bool | starts_with (char c) const |
| True if string starts with given character (cf. C++20) More... | |
| bool | starts_with (const std::string &s) const |
| True if string starts with given [string view] prefix (C++20) More... | |
| bool | starts_with (const char *s) const |
| True if string starts with given prefix (C++20) More... | |
| bool | ends_with (char c) const |
| True if string ends with given character (cf. C++20) More... | |
| bool | ends_with (const std::string &s) const |
| True if string ends with given [string view] suffix (cf. C++20) More... | |
| bool | ends_with (const char *s) const |
| True if string ends with given suffix (cf. C++20) More... | |
| size_type | count (const char c) const |
| Count the number of occurrences of the specified character in the string. More... | |
| 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 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 = "string" |
| The type name "string". More... | |
| static int | debug |
| The debug flag. More... | |
| static const string | null |
| An empty string. More... | |
Protected Member Functions | |
| 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 | has_ext () const |
| Return true if it has an extension or simply ends with a '.'. More... | |
| bool | has_ext (const char *ending) const |
| Return true if the extension is the same as the given ending. More... | |
| bool | has_ext (const std::string &ending) const |
| Return true if the extension is the same as the given ending. More... | |
| bool | has_ext (const wordRe &ending) const |
| Return true if the extension matches the given ending. More... | |
| bool | remove_path () |
| Remove leading path, return true if string changed. More... | |
| bool | remove_ext () |
| Remove extension, return true if string changed. More... | |
Static Protected Member Functions | |
| 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 character strings derived from std::string.
Strings may contain any characters and therefore are delimited by quotes for IO : "any list of characters".
Used as a base class for word and fileName.
|
default |
Default construct.
|
inline |
|
inline |
|
inline |
|
inlineexplicit |
Construct from Istream.
Definition at line 28 of file stringIO.C.
|
inlinestaticprotected |
|
inlineprotected |
Find position of a file extension dot, return npos on failure.
A wrapped version of find_last_of("./") with additional logic.
Definition at line 37 of file stringI.H.
Referenced by string::ext().

|
staticprotected |
A printf-style formatter for a primitive.
Definition at line 29 of file stringTemplates.C.
References n, and Foam::output().

|
staticprotected |
A printf-style formatter for a primitive.
Definition at line 57 of file stringTemplates.C.
References Foam::output().

|
protected |
Return file name extension (part after last .)
Definition at line 38 of file string.C.
References string::find_ext().
Referenced by word::ext(), fileName::ext(), word::replace_ext(), and fileName::replace_ext().


|
protected |
|
inlineprotected |
Return true if it has an extension or simply ends with a '.'.
Definition at line 43 of file stringI.H.
Referenced by word::hasExt(), and fileName::hasExt().

|
inlineprotected |
|
inlineprotected |
|
protected |
Return true if the extension matches the given ending.
Definition at line 74 of file string.C.
References wordRe::isLiteral(), and wordRe::match().

|
inlineprotected |
Remove leading path, return true if string changed.
Definition at line 79 of file stringI.H.
References erase().
Referenced by fileName::removePath().


|
inlineprotected |
Remove extension, return true if string changed.
Definition at line 93 of file stringI.H.
References erase().
Referenced by word::removeExt(), fileName::removeExt(), word::replace_ext(), and fileName::replace_ext().


|
inlinestatic |
|
inlinestatic |
Strip invalid characters from the given string.
Definition at line 164 of file stringI.H.
References Foam::constant::universal::c.
|
inlinestatic |
Return a valid String from the given string.
Definition at line 193 of file stringI.H.
References Foam::constant::universal::c.
|
inline |
Test for equality.
Definition at line 215 of file stringI.H.
Referenced by solutionControl::applyToField().

| Foam::string & replace | ( | const std::string & | s1, |
| const std::string & | s2, | ||
| size_type | pos = 0 |
||
| ) |
Replace first occurrence of sub-string s1 with s2, beginning at pos.
Definition at line 101 of file string.C.
References Foam::ListOps::find(), and Foam::pos().
Referenced by argList::displayDoc(), objectRegistry::rename(), ensightSurfaceReader::replaceMask(), cellMotionFvPatchField< Type >::updateCoeffs(), and graph::wordify().


| Foam::string & replaceAll | ( | 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.
A no-op if s1 is empty.
Definition at line 117 of file string.C.
References Foam::ListOps::find(), and Foam::pos().

| Foam::string & replaceAny | ( | 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.
A no-op if s1 is empty.
Definition at line 140 of file string.C.
References Foam::constant::physicoChemical::c2, erase(), and Foam::pos().
Referenced by FileName::stripInvalid().


| Foam::string & expand | ( | const bool | allowEmpty = false | ) |
Inplace expand initial tags, tildes, and all occurrences of environment variables as per stringOps::expand.
Any unknown entries are removed silently if allowEmpty is true
Definition at line 166 of file string.C.
References Foam::stringOps::inplaceExpand().
Referenced by pointNoise::calculate(), surfaceNoise::calculate(), chemkinReader::chemkinReader(), externalFileCoupler::externalFileCoupler(), MappedFile< Type >::MappedFile(), offsetSurface::offsetSurface(), tabulated6DoFAcceleration::read(), tabulated6DoFMotion::read(), abort::read(), timeActivatedFileUpdate::read(), Curle::read(), surfaceFormatsCore::relativeFilePath(), IOobject::selectIO(), Table< Type >::Table(), TableFile< Type >::TableFile(), and triSurfaceMesh::writeObject().


| bool removeRepeated | ( | const char | character | ) |
Remove repeated characters.
Definition at line 173 of file string.C.
References stdFoam::begin(), Foam::constant::universal::c, stdFoam::cbegin(), stdFoam::cend(), erase(), and Foam::ListOps::find().

| bool removeStart | ( | const std::string & | text | ) |
Remove the given text from the start of the string.
Definition at line 207 of file string.C.
References erase().
Referenced by dlLibraryTable::basename().


| bool removeStart | ( | const char | c | ) |
Remove leading character, unless string is a single character.
Definition at line 237 of file string.C.
References Foam::constant::universal::c, and erase().

| bool removeEnd | ( | const std::string & | text | ) |
Remove the given text from the end of the string.
Definition at line 222 of file string.C.
References erase().
Referenced by NASsurfaceFormat< Face >::read(), and string::removeTrailing().


| bool removeEnd | ( | const char | c | ) |
Remove trailing character, unless string is a single character.
Definition at line 249 of file string.C.
References Foam::constant::universal::c, erase(), and n.

|
inline |
Swap contents. Self-swapping is a no-op.
Definition at line 221 of file stringI.H.
Referenced by keyType::swap(), and wordRe::swap().

|
inline |
|
inlinenoexcept |
True if string contains given character (cf. C++23)
Definition at line 390 of file string.H.
References Foam::constant::universal::c, and Foam::ListOps::find().
Referenced by Foam::checkFormatName(), dictionary::csearchScoped(), ensightReadFile::detectBinaryHeader(), argList::displayDoc(), Foam::getStopAction(), entry::New(), ensightSurfaceReader::readCase(), ensightSurfaceReader::readField(), ensightSurfaceReader::readGeometryHeader(), and solutionControl::storePrevIter().


|
inlinenoexcept |
True if string contains given [string view] substring (cf. C++23)
Definition at line 398 of file string.H.
References Foam::ListOps::find(), and s.

|
inline |
True if string contains given substring (cf. C++23)
Definition at line 406 of file string.H.
References Foam::ListOps::find(), and s.

|
inline |
True if string starts with given character (cf. C++20)
Definition at line 414 of file string.H.
References Foam::constant::universal::c.
Referenced by argList::displayDoc(), Foam::dlOpen(), argList::parse(), ABAQUSCore::readHelper::read(), seriesWriter::scan(), and string::startsWith().

|
inline |
|
inline |
|
inline |
True if string ends with given character (cf. C++20)
Definition at line 439 of file string.H.
References Foam::constant::universal::c.
Referenced by cellCellStencil::baseName(), and string::endsWith().

|
inline |
|
inline |
| Foam::string::size_type count | ( | const char | c | ) | const |
Count the number of occurrences of the specified character in the string.
Partially deprecated (NOV-2017) in favour of stringOps::count
Definition at line 94 of file string.C.
References Foam::constant::universal::c, and Foam::stringOps::count().

|
inline |
Deprecated(2019-11)
Definition at line 474 of file string.H.
References s, and string::starts_with().

|
inline |
Deprecated(2019-11)
Definition at line 481 of file string.H.
References string::ends_with(), and s.

|
inline |
Deprecated(2019-11)
Definition at line 488 of file string.H.
References Foam::constant::universal::c, and string::removeEnd().

|
static |
|
static |
An empty string.
Definition at line 202 of file string.H.
Referenced by ABAQUSCore::readHelper::addNewElset(), genericRagelLemonDriver::clear(), argList::printMan(), Foam::printManOption(), Foam::printOption(), argList::printUsage(), token::stringToken(), and OFstreamCollator::write().
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.