A class for handling character strings derived from std::string. More...
Classes | |
class | hash |
Hashing function class, shared by all the derived classes. More... | |
Public Member Functions | |
string () | |
Construct null. More... | |
string (const std::string &) | |
Construct from std::string. More... | |
string (const string &) | |
Copy constructor. More... | |
string (string &&) | |
Move constructor. More... | |
string (const char *) | |
Construct as copy of character array. More... | |
string (const UList< char > &) | |
Construct as copy of UList of character. More... | |
string (const char *, const size_type) | |
Construct as copy of specified number of characters. More... | |
string (const char) | |
Construct from a single character. More... | |
string (const size_type, const char) | |
Construct from copies of a single character. More... | |
string (Istream &) | |
Construct from Istream. More... | |
size_type | count (const char) const |
Count and return the number of a given character in the string. More... | |
bool | match (const std::string &) const |
True when strings match literally. More... | |
string & | replace (const string &oldStr, const string &newStr, size_type start=0) |
In this string replace first occurrence of sub-string oldStr. More... | |
string | replace (const string &oldStr, const string &newStr, size_type start=0) const |
Replace first occurrence of sub-string oldStr with newStr. More... | |
string & | replaceAll (const string &oldStr, const string &newStr, size_type start=0) |
In this string replace all occurrences of sub-string oldStr. More... | |
string | replaceAll (const string &oldStr, const string &newStr, size_type start=0) const |
Replace all occurrences of sub-string oldStr with newStr. More... | |
string & | expand (const bool allowEmpty=false) |
Expand initial tildes and all occurrences of environment variables. More... | |
bool | remove (const char) |
Remove all occurrences of character returning true if string changed. More... | |
string | remove (const char) const |
Remove all occurrences of character and return the string. More... | |
bool | removeRepeated (const char) |
Remove repeated character returning true if string changed. More... | |
string | removeRepeated (const char) const |
Remove repeated character and return the string. More... | |
bool | removeTrailing (const char) |
Remove trailing character returning true if string changed. More... | |
string | removeTrailing (const char) const |
Return string with trailing character removed. More... | |
bool | removeTrailing (const string &) |
Remove trailing string returning true if string changed. More... | |
string | removeTrailing (const string &) const |
Return string with trailing string removed. More... | |
void | strip (const string &) |
Strip characters from the start and end of the string. More... | |
size_type | findClosing (const char, const size_type) const |
Find the closing character. Brackets counting algorithm. The. More... | |
string | operator() (const size_type i, const size_type n) const |
Return the sub-string from the i-th character for n characters. More... | |
string | operator() (const size_type n) const |
Return the sub-string from the first character for n characters. More... | |
void | operator= (const string &) |
void | operator= (string &&) |
template<class String > | |
Foam::string | quotemeta (const string &str, const char quote) |
Static Public Member Functions | |
template<class String > | |
static bool | valid (const string &) |
Is this string type valid? More... | |
template<class String > | |
static bool | meta (const string &, const char quote='\\') |
Does this string have particular meta-characters? More... | |
template<class String > | |
static bool | stripInvalid (string &) |
Strip invalid characters from the given string. More... | |
template<class String > | |
static String | validate (const string &) |
Return a valid String from the given string. More... | |
template<class String > | |
static string | quotemeta (const string &, const char quote='\\') |
Return a String with quoted meta-characters from the given string. More... | |
Static Public Attributes | |
static const char *const | typeName = "string" |
static int | debug |
static const string | null |
An empty string. More... | |
Friends | |
Istream & | operator>> (Istream &, string &) |
Ostream & | operator<< (Ostream &, const string &) |
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.
|
inline |
|
inline |
|
inline |
Construct from Istream.
Definition at line 31 of file stringIO.C.
Foam::string::size_type count | ( | const char | c | ) | const |
Count and return the number of a given character in the string.
Definition at line 47 of file string.C.
References Foam::constant::universal::c.
Referenced by string::strip(), OSstream::write(), and OSstream::writeQuoted().
|
inlinestatic |
Is this string type valid?
Definition at line 79 of file stringI.H.
References Foam::blendedInterfacialModel::valid().
|
inlinestatic |
|
inlinestatic |
Strip invalid characters from the given string.
Definition at line 93 of file stringI.H.
References Foam::constant::universal::c, and Foam::blendedInterfacialModel::valid().
|
inlinestatic |
Return a String with quoted meta-characters from the given string.
|
inline |
True when strings match literally.
Definition at line 194 of file stringI.H.
Referenced by IOobjectList::lookup(), convergenceControl::residualControlIndex(), and objectRegistry::toc().
Foam::string & replace | ( | const string & | oldStr, |
const string & | newStr, | ||
size_type | start = 0 |
||
) |
In this string replace first occurrence of sub-string oldStr.
with newStr starting at start
Definition at line 63 of file string.C.
Referenced by fileName::caseName(), argList::displayDoc(), objectRegistry::rename(), string::replace(), and cellMotionFvPatchField< Type >::updateCoeffs().
Foam::string replace | ( | const string & | oldStr, |
const string & | newStr, | ||
size_type | start = 0 |
||
) | const |
Replace first occurrence of sub-string oldStr with newStr.
starting at start
Definition at line 81 of file string.C.
References string::replace().
Foam::string & replaceAll | ( | const string & | oldStr, |
const string & | newStr, | ||
size_type | start = 0 |
||
) |
In this string replace all occurrences of sub-string oldStr.
with newStr starting at start
Definition at line 92 of file string.C.
Referenced by Foam::printSourceFileAndLine(), and string::replaceAll().
Foam::string replaceAll | ( | const string & | oldStr, |
const string & | newStr, | ||
size_type | start = 0 |
||
) | const |
Replace all occurrences of sub-string oldStr with newStr.
starting at start
Definition at line 114 of file string.C.
References string::replaceAll().
Foam::string & expand | ( | const bool | allowEmpty = false | ) |
Expand initial tildes and all occurrences of environment variables.
Expansion includes:
Any unknown entries are removed silently if allowEmpty is true
Definition at line 125 of file string.C.
References Foam::stringOps::inplaceExpandEnvVar().
Referenced by argList::displayDoc(), externalCoupledMixedFvPatchField< Type >::externalCoupledMixedFvPatchField(), TableFileReader< Type >::read(), stopAtFile::stopAtFile(), timeVaryingMappedFvPatchField< Type >::timeVaryingMappedFvPatchField(), and triSurfaceMesh::writeObject().
bool remove | ( | const char | character | ) |
Remove all occurrences of character returning true if string changed.
Definition at line 132 of file string.C.
References Foam::constant::universal::c, n, and resize().
Referenced by fvConstraint::New(), fvModel::New(), functionObject::New(), ISstream::read(), and string::remove().
Foam::string remove | ( | const char | character | ) | const |
Remove all occurrences of character and return the string.
Definition at line 166 of file string.C.
References string::remove().
bool removeRepeated | ( | const char | character | ) |
Remove repeated character returning true if string changed.
Definition at line 175 of file string.C.
References Foam::constant::universal::c, n, and resize().
Referenced by string::removeRepeated().
Foam::string removeRepeated | ( | const char | character | ) | const |
Remove repeated character and return the string.
Definition at line 211 of file string.C.
References string::removeRepeated().
bool removeTrailing | ( | const char | character | ) |
Remove trailing character returning true if string changed.
Definition at line 219 of file string.C.
Referenced by Reaction< ThermoType >::New(), and string::removeTrailing().
Foam::string removeTrailing | ( | const char | character | ) | const |
Return string with trailing character removed.
Definition at line 234 of file string.C.
References string::removeTrailing().
bool removeTrailing | ( | const string & | str | ) |
Foam::string removeTrailing | ( | const string & | str | ) | const |
Return string with trailing string removed.
Definition at line 257 of file string.C.
References string::removeTrailing().
void strip | ( | const string & | str | ) |
Strip characters from the start and end of the string.
Definition at line 265 of file string.C.
References string::count(), and resize().
Referenced by Foam::readConfigFile().
Foam::string::size_type findClosing | ( | const char | , |
const | size_type | ||
) | const |
Find the closing character. Brackets counting algorithm. The.
opening bracket character is taken to be the one at the starting position. The closing character is provided by argument.
Examples:
[char #1] [char #15] | | V V string("0(2(4,6)8,a(c)e)g").findClosing(')',1) == 15
[char #3] [char #7] | | V V string("0(2(4,6)8,a(c)e)g").findClosing(')',3) == 7
Definition at line 298 of file string.C.
References Foam::constant::universal::c.
|
inline |
|
inline |
|
inline |
Definition at line 229 of file stringI.H.
Referenced by fileName::operator=(), keyType::operator=(), variable::operator=(), verbatimString::operator=(), word::operator=(), wordRe::operator=(), and wordRe::set().
|
inline |
|
static |
Definition at line 84 of file string.H.
Referenced by token::anyStringToken(), and token::stringToken().
|
static |
An empty string.
Definition at line 88 of file string.H.
Referenced by token::anyStringToken(), argList::displayDoc(), Foam::getVariable(), token::stringToken(), and OFstreamCollator::write().