A class for handling character strings derived from std::string. More...
Data Structures | |
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 char *) | |
Construct as copy of character array. 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 (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) |
Replace first occurence of sub-string oldStr with newStr. More... | |
string & | replaceAll (const string &oldStr, const string &newStr, size_type start=0) |
Replace all occurences of sub-string oldStr with newStr. More... | |
string & | expand (const bool allowEmpty=false) |
Expand initial tildes and all occurences of environment variables. More... | |
bool | removeRepeated (const char) |
Remove repeated characters returning true if string changed. More... | |
string | removeRepeated (const char) const |
Return string with repeated characters removed. 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... | |
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... | |
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 40 of file string.C.
References Foam::constant::universal::c.
Referenced by OSstream::write(), and OSstream::writeQuoted().
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Strip invalid characters from the given string.
Definition at line 78 of file stringI.H.
References Foam::constant::universal::c.
|
inlinestatic |
Return a String with quoted meta-characters from the given string.
|
inline |
True when strings match literally.
Definition at line 179 of file stringI.H.
Referenced by solutionControl::applyToField(), IOobjectList::lookup(), and objectRegistry::names().
Foam::string & replace | ( | const string & | oldStr, |
const string & | newStr, | ||
size_type | start = 0 |
||
) |
Replace first occurence of sub-string oldStr with newStr.
starting at start
Definition at line 58 of file string.C.
Referenced by fileName::caseName(), Foam::dlOpen(), main(), objectRegistry::rename(), cellMotionFvPatchField< Type >::updateCoeffs(), and graph::wordify().
Foam::string & replaceAll | ( | const string & | oldStr, |
const string & | newStr, | ||
size_type | start = 0 |
||
) |
Replace all occurences of sub-string oldStr with newStr.
starting at start
Definition at line 77 of file string.C.
Referenced by argList::displayDoc(), main(), Foam::printSourceFileAndLine(), and chemkinReader::stringToScalar().
Foam::string & expand | ( | const bool | allowEmpty = false | ) |
Expand initial tildes and all occurences of environment variables.
Expansion includes:
Any unknown entries are removed silently if allowEmpty is true
Definition at line 98 of file string.C.
References Foam::stringOps::inplaceExpand().
Referenced by geometrySurface::addGeometryToScene(), chemkinReader::chemkinReader(), argList::displayDoc(), main(), offsetSurface::offsetSurface(), tabulated6DoFAcceleration::read(), CSV::read(), tabulated6DoFMotion::read(), interpolation2DTable< Type >::readTable(), interpolationTable< scalar >::readTable(), and TableFile::TableFile().
bool removeRepeated | ( | const char | character | ) |
Remove repeated characters returning true if string changed.
Definition at line 106 of file string.C.
References Foam::constant::universal::c, and resize().
Referenced by string::removeRepeated(), and fileName::stripInvalid().
Foam::string removeRepeated | ( | const char | character | ) | const |
Return string with repeated characters removed.
Definition at line 145 of file string.C.
References string::removeRepeated().
bool removeTrailing | ( | const char | character | ) |
Remove trailing character returning true if string changed.
Definition at line 154 of file string.C.
References resize().
Referenced by string::removeTrailing(), and fileName::stripInvalid().
Foam::string removeTrailing | ( | const char | character | ) | const |
Return string with trailing character removed.
Definition at line 170 of file string.C.
References string::removeTrailing().
|
inline |
|
inline |
|
inline |
|
static |
Definition at line 82 of file string.H.
Referenced by token::stringToken().
|
static |
Copyright © 2011-2018 OpenFOAM | OPENFOAM® is a registered trademark of OpenCFD Ltd.