DUtils::StringFunctions Class Reference

Functions to manipulate strings. More...

#include <StringFunctions.h>

List of all members.

Static Public Member Functions

static void split (const std::string &s, std::vector< std::string > &tokens, const std::string &delims=" \t\n", int max_splits=-1)
static void trim (std::string &s)
static void removeFrom (std::string &s, const char c, const std::string &escape="")
static void replace (std::string &s, const std::vector< std::pair< std::string, std::string > > &map)
static void replace (std::string &s, const std::string &search, const std::string &rep)
template<class T >
static std::string toString (const T &data)
template<class T >
static T fromString (const std::string &s)

Detailed Description

Functions to manipulate strings.


Member Function Documentation

template<class T >
T DUtils::StringFunctions::fromString ( const std::string &  s  )  [inline, static]

Returns a data type from a string representation

Parameters:
s 
void StringFunctions::replace ( std::string &  s,
const std::string &  search,
const std::string &  rep 
) [static]

The same as above, but only with one "pair"

Parameters:
s 
search 
rep 
void StringFunctions::replace ( std::string &  s,
const std::vector< std::pair< std::string, std::string > > &  map 
) [static]

Replaces each occurrence of one of several strings in s by another string

Parameters:
s the original string whose substring will be replaced
map a vector of pairs of string where the first one is the substring to search for, and the second one, the replacing text
Note:
the entries are searched for as they appear in the map vector. An entry can replace the text already put by previous entries
void StringFunctions::split ( const std::string &  s,
std::vector< std::string > &  tokens,
const std::string &  delims = " \t\n",
int  max_splits = -1 
) [static]

Splits the given string into single tokens

Parameters:
s string
tokens returned tokens (no empty tokens are returned)
delims delimitation characters
max_splits maximum number of splits. If -1, all the possible splits are done. Otherwise, those delimiters found after the max number of splits has been done are ignored
template<class T >
std::string DUtils::StringFunctions::toString ( const T &  data  )  [inline, static]

Converts a piece of data into a string

Parameters:
data 
void StringFunctions::trim ( std::string &  s  )  [static]

Removes blank spaces, tabs and new lines from the beginning and the end of the string

Parameters:
s 

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Friends
Generated on Thu Feb 7 19:16:00 2013 by  doxygen 1.6.3