iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages

Various helpful methods for dealing with std::strings

Functions

std::string nrt::replaceEnvVars (std::string const &str)
 Replace all environment variables in the given string with the values found in the environment. More...
 
std::vector< std::string > nrt::splitString (std::string const &string, char const delimiter)
 Split the string by the given delimiter. More...
 
std::string nrt::joinStrings (std::vector< std::string > const &strings, std::string const &delimiter)
 Join a vector of strings with the given delimiter. More...
 
std::string nrt::trimString (std::string const &s)
 Trim whitespace from both ends of a string. More...
 
std::string nrt::lTrimString (std::string const &s)
 Trim whitespace from the left side of a string. More...
 
std::string nrt::rTrimString (std::string const &s)
 Trim whitespace from the right side of a string. More...
 
std::string nrt::sformat (const char *fmt,...) __attribute__((format(__printf__
 Create a string using printf style arguments. More...
 
std::string std::string nrt::urlDecode (std::string const &str)
 Decode url-encoded strings. More...
 

Function Documentation

std::string nrt::replaceEnvVars ( std::string const &  str)

Replace all environment variables in the given string with the values found in the environment.

Note
Use the helpers provided in Environment.H rather than replaceEnvVars() to access NRT-related environment variables in a safer, strongly-typed manner.
std::vector<std::string> nrt::splitString ( std::string const &  string,
char const  delimiter 
)
std::string nrt::joinStrings ( std::vector< std::string > const &  strings,
std::string const &  delimiter 
)

Join a vector of strings with the given delimiter.

Examples:
tests/test-Log.C.
std::string nrt::trimString ( std::string const &  s)

Trim whitespace from both ends of a string.

std::string nrt::lTrimString ( std::string const &  s)

Trim whitespace from the left side of a string.

std::string nrt::rTrimString ( std::string const &  s)

Trim whitespace from the right side of a string.

std::string nrt::sformat ( const char *  fmt,
  ... 
)

Create a string using printf style arguments.

Example:

std::string s = nrt::sformat("MyString_%f_%d", 1.0, 2);
Examples:
tests/test-stream.C.

Referenced by nrt::operator<<(), and nrt::operator>>().

std::string std::string nrt::urlDecode ( std::string const &  str)

Decode url-encoded strings.