OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

string Class Reference

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

Inheritance diagram for string:
Collaboration diagram for string:

List of all members.


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 &)

Detailed Description

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.

See also:
Foam::findEtcFile() for information about the site/user OpenFOAM configuration directory
Source files

Definition at line 70 of file string.H.


Constructor & Destructor Documentation

string (  )  [inline]

Construct null.

Definition at line 22 of file stringI.H.

string ( const std::string &  str  )  [inline]

Construct from std::string.

Definition at line 26 of file stringI.H.

string ( const char *  str  )  [inline]

Construct as copy of character array.

Definition at line 33 of file stringI.H.

string ( const char *  str,
const size_type  len 
) [inline]

Construct as copy of specified number of characters.

Definition at line 40 of file stringI.H.

string ( const char  c  )  [inline]

Construct from a single character.

Definition at line 47 of file stringI.H.

string ( Istream &  is  ) 

Construct from Istream.

Definition at line 23 of file stringIO.C.


Member Function Documentation

Foam::string::size_type count ( const char  c  )  const

Count and return the number of a given character in the string.

Definition at line 30 of file string.C.

bool valid ( const string &  str  )  [inline, static]

Is this string type valid?

Definition at line 56 of file stringI.H.

bool meta ( const string &  str,
const char  quote = '\\' 
) [inline, static]

Does this string have particular meta-characters?

The meta characters can be optionally quoted.

Definition at line 104 of file stringI.H.

bool stripInvalid ( string &  str  )  [inline, static]

Strip invalid characters from the given string.

Definition at line 70 of file stringI.H.

String validate ( const string &  str  )  [inline, static]

Return a valid String from the given string.

Definition at line 164 of file stringI.H.

Foam::string quotemeta ( const string &  str,
const char  quote = '\\' 
) [inline, static]

Return a String with quoted meta-characters from the given string.

Definition at line 128 of file stringI.H.

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 48 of file string.C.

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 67 of file string.C.

Referenced by foamName().

Here is the caller graph for this function:

Foam::string & expand (  ) 

Expand initial tildes and all occurences of environment variables.

Expansion includes:

  1. environment variables
    • "$VAR", "${VAR}"
  2. current directory
    • leading "./" : the current directory
  3. tilde expansion
    • leading "~/" : home directory
    • leading "~user" : home directory for specified user
    • leading "~OpenFOAM" : site/user OpenFOAM configuration directory

See also:
Foam::findEtcFile

Definition at line 89 of file string.C.

bool removeRepeated ( const char  character  ) 

Remove repeated characters returning true if string changed.

Definition at line 216 of file string.C.

Referenced by string::removeTrailing().

Here is the caller graph for this function:

Foam::string removeRepeated ( const char  character  )  const

Return string with repeated characters removed.

Definition at line 255 of file string.C.

bool removeTrailing ( const char  character  ) 

Remove trailing character returning true if string changed.

Definition at line 264 of file string.C.

References string::removeRepeated().

Here is the call graph for this function:

Foam::string removeTrailing ( const char  character  )  const

Return string with trailing character removed.

Definition at line 280 of file string.C.

Foam::string operator() ( const size_type  i,
const size_type  n 
) const [inline]

Return the sub-string from the i-th character for n characters.

Definition at line 175 of file stringI.H.

Foam::string operator() ( const size_type  n  )  const [inline]

Return the sub-string from the first character for n characters.

Definition at line 184 of file stringI.H.


Friends And Related Function Documentation

Istream& operator>> ( Istream &  ,
string &   
) [friend]

Ostream& operator<< ( Ostream &  ,
const string &   
) [friend]


Member Data Documentation

const char *const typeName = "string" [static]

Reimplemented in fileName, and word.

Definition at line 78 of file string.H.

int debug [static]

Reimplemented in fileName, and word.

Definition at line 79 of file string.H.

const Foam::string null [static]

Reimplemented in fileName, and word.

Definition at line 80 of file string.H.


The documentation for this class was generated from the following files:
  • src/OpenFOAM/primitives/strings/string/string.H
  • src/OpenFOAM/primitives/strings/string/string.C
  • src/OpenFOAM/primitives/strings/string/stringI.H
  • src/OpenFOAM/primitives/strings/string/stringIO.C
Copyright © 2000-2009 OpenCFD Ltd