A class for handling character strings derived from std::string. More...
#include <OpenFOAM/string.H>
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.
Definition at line 75 of file string.H.
Classes | |
class | hash |
Hashing function class, shared by all the derived classes. More...
| |
Public Member Functions | |
string () | |
Construct null.
| |
string (const std::string &) | |
Construct from std::string.
| |
string (const char *) | |
Construct as copy of character array.
| |
string (const char *, const size_type) | |
Construct as copy of specified number of characters.
| |
string (const char) | |
Construct from a single character.
| |
string (Istream &) | |
Construct from Istream.
| |
size_type | count (const char) const |
Count and return the number of a given character in the string.
| |
string & | replace (const string &oldStr, const string &newStr, size_type start=0) |
Replace first occurence of sub-string oldStr with newStr.
| |
string & | replaceAll (const string &oldStr, const string &newStr, size_type start=0) |
Replace all occurences of sub-string oldStr with newStr.
| |
string & | expand () |
Expand initial tildes and all occurences of environment variables.
| |
bool | removeRepeated (const char) |
Remove repeated characters returning true if string changed.
| |
string | removeRepeated (const char) const |
Return string with repeated characters removed.
| |
bool | removeTrailing (const char) |
Remove trailing character returning true if string changed.
| |
string | removeTrailing (const char) const |
Return string with trailing character removed.
| |
string | operator() (const size_type i, const size_type n) const |
Return the sub-string from the i-th character for n characters.
| |
string | operator() (const size_type n) const |
Return the sub-string from the first character for n characters.
| |
Static Public Member Functions | |
template<class String > | |
static bool | valid (const string &) |
Is this string type valid?
| |
template<class String > | |
static bool | meta (const string &, const char quote='\\') |
Does this string have particular meta-characters?
| |
template<class String > | |
static bool | stripInvalid (string &) |
Strip invalid characters from the given string.
| |
template<class String > | |
static String | validate (const string &) |
Return a valid String from the given string.
| |
template<class String > | |
static string | quotemeta (const string &, const char quote='\\') |
Return a String with quoted meta-characters from the given string.
| |
Static Public Attributes | |
static const char *const | typeName = "string" |
static int | debug |
static const string | null |
Friends | |
Istream & | operator>> (Istream &, string &) |
Ostream & | operator<< (Ostream &, const string &) |
string | ( | const std::string & | str ) | [inline]
|
string | ( | const char * | str ) | [inline]
|
string | ( | const char * | str, |
const size_type | len | ||
) | [inline]
|
string | ( | const char | c ) | [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 38 of file string.C.
Referenced by OSstream::write(), and OSstream::writeQuoted().
bool valid | ( | const string & | str ) | [inline, static]
|
bool meta | ( | const string & | str, |
const char | quote = '\\'
|
||
) | [inline, static]
|
bool stripInvalid | ( | string & | str ) | [inline, static]
|
String validate | ( | const string & | str ) | [inline, static]
|
Foam::string quotemeta | ( | const string & | str, |
const char | quote = '\\'
|
||
) | [inline, static]
|
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 56 of file string.C.
Referenced by objectRegistry::rename(), and cellMotionFvPatchField< Type >::updateCoeffs().
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 75 of file string.C.
Referenced by error::operator dictionary().
Foam::string & expand | ( | ) |
Expand initial tildes and all occurences of environment variables.
Expansion includes:
Definition at line 97 of file string.C.
References Foam::cwd(), Foam::exit(), Foam::FatalError, FatalErrorIn, Foam::findEtcFile(), Foam::getEnv(), and Foam::home().
Referenced by includeEntry::includeFileName().
bool removeRepeated | ( | const char | character ) |
Remove repeated characters returning true if string changed.
Definition at line 225 of file string.C.
Referenced by string::removeRepeated().
Foam::string removeRepeated | ( | const char | character ) | const |
Return string with repeated characters removed.
Definition at line 264 of file string.C.
References string::removeRepeated().
bool removeTrailing | ( | const char | character ) |
Remove trailing character returning true if string changed.
Definition at line 273 of file string.C.
Referenced by string::removeTrailing().
Foam::string removeTrailing | ( | const char | character ) | const |
Return string with trailing character removed.
Definition at line 289 of file string.C.
References string::removeTrailing().
Foam::string operator() | ( | const size_type | i, |
const size_type | n | ||
) | const [inline]
|
Foam::string operator() | ( | const size_type | n ) | const [inline]
|
const char *const typeName = "string" [static]
|
const Foam::string null [static]
|
Reimplemented in fileName, and word.
Definition at line 85 of file string.H.
Referenced by token::stringToken().