Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
string Class Reference

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

Inheritance diagram for string:
Inheritance graph
[legend]
Collaboration diagram for string:
Collaboration graph
[legend]

Classes

struct  hash
 
struct  hasher
 

Public Member Functions

 string ()=default
 
 string (const std::string &str)
 
 string (std::string &&str)
 
 string (const char *str)
 
 string (const char *str, const size_type len)
 
 string (const char c)
 
 string (const size_type len, const char c)
 
 string (Istream &is)
 
bool match (const std::string &text) const
 
stringreplace (const std::string &s1, const std::string &s2, size_type pos=0)
 
stringreplaceAll (const std::string &s1, const std::string &s2, size_type pos=0)
 
stringreplaceAny (const std::string &s1, const char c2, size_type pos=0)
 
stringexpand (const bool allowEmpty=false)
 
bool removeRepeated (const char character)
 
bool removeStart (const std::string &text)
 
bool removeStart (const char c)
 
bool removeEnd (const std::string &text)
 
bool removeEnd (const char c)
 
void swap (std::string &str)
 
bool operator() (const std::string &text) const
 
bool starts_with (const std::string &s) const
 
bool starts_with (const char c) const
 
bool ends_with (const std::string &s) const
 
bool ends_with (const char c) const
 
size_type count (const char c) const
 
bool startsWith (const std::string &s) const
 
bool endsWith (const std::string &s) const
 
bool removeTrailing (const char c)
 

Static Public Member Functions

template<class StringType >
static bool valid (const std::string &str)
 
template<class StringType >
static bool stripInvalid (std::string &str)
 
template<class StringType >
static StringType validate (const std::string &str)
 

Static Public Attributes

static const char *const typeName = "string"
 
static int debug
 
static const string null
 

Protected Member Functions

std::string::size_type find_ext () const
 
word ext () const
 
bool ext (const word &ending)
 
bool hasPath () const
 
bool hasExt () const
 
bool hasExt (const char *ending) const
 
bool hasExt (const std::string &ending) const
 
bool hasExt (const wordRe &ending) const
 
bool removeExt ()
 
bool removePath ()
 

Static Protected Member Functions

static std::string::size_type find_ext (const std::string &str)
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const char *fmt, const PrimitiveType &val)
 
template<class PrimitiveType >
static std::string::size_type string_printf (std::string &output, const std::string &fmt, const PrimitiveType &val)
 

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 72 of file string.H.

Constructor & Destructor Documentation

◆ string() [1/8]

string ( )
default

◆ string() [2/8]

string ( const std::string &  str)
inline

Definition at line 106 of file stringI.H.

◆ string() [3/8]

string ( std::string &&  str)
inline

Definition at line 112 of file stringI.H.

◆ string() [4/8]

string ( const char *  str)
inline

Definition at line 118 of file stringI.H.

◆ string() [5/8]

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

Definition at line 124 of file stringI.H.

◆ string() [6/8]

string ( const char  c)
inlineexplicit

Definition at line 130 of file stringI.H.

◆ string() [7/8]

string ( const size_type  len,
const char  c 
)
inline

Definition at line 136 of file stringI.H.

◆ string() [8/8]

string ( Istream is)
explicit

Definition at line 28 of file stringIO.C.

Member Function Documentation

◆ find_ext() [1/2]

std::string::size_type find_ext ( const std::string &  str)
inlinestaticprotected

Definition at line 24 of file stringI.H.

◆ find_ext() [2/2]

std::string::size_type find_ext ( ) const
inlineprotected

Definition at line 37 of file stringI.H.

Referenced by string::ext().

Here is the caller graph for this function:

◆ string_printf() [1/2]

std::string::size_type string_printf ( std::string &  output,
const char *  fmt,
const PrimitiveType &  val 
)
staticprotected

Definition at line 29 of file stringTemplates.C.

References n, and Foam::output().

Here is the call graph for this function:

◆ string_printf() [2/2]

std::string::size_type string_printf ( std::string &  output,
const std::string &  fmt,
const PrimitiveType &  val 
)
staticprotected

Definition at line 57 of file stringTemplates.C.

References Foam::output().

Here is the call graph for this function:

◆ ext() [1/2]

Foam::word ext ( ) const
protected

Definition at line 38 of file string.C.

References string::find_ext(), and word::null.

Referenced by word::ext(), and fileName::ext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ext() [2/2]

bool ext ( const word ending)
protected

Definition at line 51 of file string.C.

References append().

Here is the call graph for this function:

◆ hasPath()

bool hasPath ( ) const
inlineprotected

Definition at line 43 of file stringI.H.

References Foam::ListOps::find().

Referenced by fileName::hasPath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasExt() [1/4]

bool hasExt ( ) const
inlineprotected

Definition at line 49 of file stringI.H.

Referenced by string::hasExt().

Here is the caller graph for this function:

◆ hasExt() [2/4]

bool hasExt ( const char *  ending) const
inlineprotected

Definition at line 55 of file stringI.H.

References string::hasExt().

Here is the call graph for this function:

◆ hasExt() [3/4]

bool hasExt ( const std::string &  ending) const
inlineprotected

Definition at line 61 of file stringI.H.

◆ hasExt() [4/4]

bool hasExt ( const wordRe ending) const
protected

Definition at line 74 of file string.C.

References wordRe::isLiteral(), and wordRe::match().

Here is the call graph for this function:

◆ removeExt()

bool removeExt ( )
inlineprotected

Definition at line 89 of file stringI.H.

References erase().

Here is the call graph for this function:

◆ removePath()

bool removePath ( )
inlineprotected

Definition at line 75 of file stringI.H.

References erase().

Referenced by fileName::removePath().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ valid()

bool valid ( const std::string &  str)
inlinestatic

Definition at line 145 of file stringI.H.

◆ stripInvalid()

bool stripInvalid ( std::string &  str)
inlinestatic

Definition at line 160 of file stringI.H.

References Foam::constant::universal::c.

◆ validate()

StringType validate ( const std::string &  str)
inlinestatic

Definition at line 189 of file stringI.H.

References Foam::constant::universal::c.

◆ match()

bool match ( const std::string &  text) const
inline

Definition at line 211 of file stringI.H.

Referenced by solutionControl::applyToField().

Here is the caller graph for this function:

◆ replace()

Foam::string & replace ( const std::string &  s1,
const std::string &  s2,
size_type  pos = 0 
)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replaceAll()

Foam::string & replaceAll ( const std::string &  s1,
const std::string &  s2,
size_type  pos = 0 
)

Definition at line 117 of file string.C.

References Foam::ListOps::find(), and Foam::pos().

Here is the call graph for this function:

◆ replaceAny()

Foam::string & replaceAny ( const std::string &  s1,
const char  c2,
size_type  pos = 0 
)

Definition at line 140 of file string.C.

References Foam::constant::physicoChemical::c2, erase(), and Foam::pos().

Referenced by FileName::stripInvalid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand()

Foam::string & expand ( const bool  allowEmpty = false)

◆ removeRepeated()

bool removeRepeated ( const char  character)

Definition at line 173 of file string.C.

References stdFoam::begin(), Foam::constant::universal::c, stdFoam::cbegin(), stdFoam::cend(), erase(), and Foam::ListOps::find().

Here is the call graph for this function:

◆ removeStart() [1/2]

bool removeStart ( const std::string &  text)

Definition at line 207 of file string.C.

References erase().

Referenced by dlLibraryTable::basename().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeStart() [2/2]

bool removeStart ( const char  c)

Definition at line 237 of file string.C.

References Foam::constant::universal::c, and erase().

Here is the call graph for this function:

◆ removeEnd() [1/2]

bool removeEnd ( const std::string &  text)

Definition at line 222 of file string.C.

References erase().

Referenced by NASsurfaceFormat< Face >::read(), and string::removeTrailing().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeEnd() [2/2]

bool removeEnd ( const char  c)

Definition at line 249 of file string.C.

References Foam::constant::universal::c, erase(), and n.

Here is the call graph for this function:

◆ swap()

void swap ( std::string &  str)
inline

Definition at line 217 of file stringI.H.

Referenced by keyType::swap(), and wordRe::swap().

Here is the caller graph for this function:

◆ operator()()

bool operator() ( const std::string &  text) const
inline

Definition at line 229 of file stringI.H.

◆ starts_with() [1/2]

bool starts_with ( const std::string &  s) const
inline

Definition at line 293 of file string.H.

References s.

Referenced by argList::displayDoc(), Foam::dlOpen(), argList::parse(), fileOperation::processorsPath(), ABAQUSCore::readHelper::read(), seriesWriter::scan(), and string::startsWith().

Here is the caller graph for this function:

◆ starts_with() [2/2]

bool starts_with ( const char  c) const
inline

Definition at line 299 of file string.H.

References Foam::constant::universal::c.

◆ ends_with() [1/2]

bool ends_with ( const std::string &  s) const
inline

Definition at line 305 of file string.H.

References s.

Referenced by dynamicOversetFvMesh::baseName(), and string::endsWith().

Here is the caller graph for this function:

◆ ends_with() [2/2]

bool ends_with ( const char  c) const
inline

Definition at line 311 of file string.H.

References Foam::constant::universal::c.

◆ count()

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

Definition at line 94 of file string.C.

References Foam::constant::universal::c, and Foam::stringOps::count().

Here is the call graph for this function:

◆ startsWith()

bool startsWith ( const std::string &  s) const
inline

Definition at line 323 of file string.H.

References s, and string::starts_with().

Here is the call graph for this function:

◆ endsWith()

bool endsWith ( const std::string &  s) const
inline

Definition at line 327 of file string.H.

References string::ends_with(), and s.

Here is the call graph for this function:

◆ removeTrailing()

bool removeTrailing ( const char  c)
inline

Definition at line 331 of file string.H.

References Foam::constant::universal::c, and string::removeEnd().

Here is the call graph for this function:

Member Data Documentation

◆ typeName

const char *const typeName = "string"
static

Definition at line 159 of file string.H.

◆ debug

int debug
static

Definition at line 162 of file string.H.

◆ null

const Foam::string null
static

The documentation for this class was generated from the following files: