OpenIG  2.0.4
cross-platform open-source OpenSceneGraph Image Generator
Public Types | Public Member Functions | Static Public Member Functions | List of all members
OpenIG::Base::StringUtils Class Reference

The singleton StringUtils class. More...

#include <StringUtils.h>

Public Types

typedef std::vector< std::string > Tokens
 
typedef std::vector< std::string >::iterator TokensIterator
 
typedef std::vector< std::string >::const_iterator TokensConstIterator
 
typedef std::vector< std::string > StringList
 
typedef std::vector< std::string >::iterator StringListIterator
 
typedef std::vector< std::string >::const_iterator StringListConstIterator
 

Public Member Functions

Tokens tokenize (const std::string &str, const std::string &delimiters=" ")
 Creates tokens std::vector<std::string> from a string and given delimiters. More...
 
Tokens tokenizeExtended (const std::string &str)
 Creates tokens std::vector<std::string> from a string and "" delimiters. More...
 
template<typename T >
std::string & ltrim (std::string &s, T istestchar=std::isspace)
 trim a string from left More...
 
template<typename T >
std::string & rtrim (std::string &s, T istestchar=std::isspace)
 trim a string from right More...
 
template<typename T >
std::string & trim (std::string &s, T istestchar=std::isspace)
 trim a string from left and right More...
 
unsigned int numberOfLines (const std::string &text)
 Computes the number of lines in a string. More...
 
std::string env (const std::string &var)
 Returns the value of an ENV variable, provided in form $ENV_VAR. More...
 

Static Public Member Functions

static StringUtilsinstance ()
 The singleton. More...
 

Detailed Description

The singleton StringUtils class.

Handy class to use wit std::strings

Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015

Member Function Documentation

std::string OpenIG::Base::StringUtils::env ( const std::string &  var)

Returns the value of an ENV variable, provided in form $ENV_VAR.

Parameters
varthe ENV variable, provided in form $ENV_VAR
Returns
the value of an ENV variable
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Fri Oct 23 2015
static StringUtils* OpenIG::Base::StringUtils::instance ( )
static

The singleton.

Returns
The singleton
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
template<typename T >
std::string& OpenIG::Base::StringUtils::ltrim ( std::string &  s,
istestchar = std::isspace 
)
inline

trim a string from left

Parameters
sThe text to trim
istestcharFunction to test a char if it is a space char
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
unsigned int OpenIG::Base::StringUtils::numberOfLines ( const std::string &  text)

Computes the number of lines in a string.

Parameters
textthe input string
Returns
number of lines in the input string
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
template<typename T >
std::string& OpenIG::Base::StringUtils::rtrim ( std::string &  s,
istestchar = std::isspace 
)
inline

trim a string from right

Parameters
sThe text to trim
istestcharFunction to test a char if it is a space char
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
Tokens OpenIG::Base::StringUtils::tokenize ( const std::string &  str,
const std::string &  delimiters = " " 
)

Creates tokens std::vector<std::string> from a string and given delimiters.

Parameters
strThe input string to tokenize
delimitersString of delimiter chars
Returns
std::vector<std::string> of tokens found
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015
Tokens OpenIG::Base::StringUtils::tokenizeExtended ( const std::string &  str)

Creates tokens std::vector<std::string> from a string and "" delimiters.

Parameters
strThe input string to tokenize
delimitersString of delimiter chars
Returns
std::vector<std::string> of tokens found
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Tue Jun 30 2015
template<typename T >
std::string& OpenIG::Base::StringUtils::trim ( std::string &  s,
istestchar = std::isspace 
)
inline

trim a string from left and right

Parameters
sThe text to trim
istestcharFunction to test a char if it is a space char
Author
Trajce Nikolov Nick openi.nosp@m.g@co.nosp@m.mpro..nosp@m.net
Date
Sun Jan 11 2015

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