DUECA/DUSIME
Functions
String manipulation functions

Functions

template<typename T >
string & dueca::operator<< (string &lhs, const T &rhs)
 std::string stream in operator More...
 
template<class T >
T & dueca::s2num (const string &s, T &num)
 Convert a string to a numeric. More...
 
template<typename T >
string dueca::num2s (const T &num, int width=-1)
 Convert any numeric to a string. More...
 
template<class T >
string dueca::real2s (const T &num)
 Convert a floating point value to a string. More...
 
string dueca::replaceAll (string s, const string &search, const string &repl)
 Replace all occurences of a certain search string in a string. More...
 
unsigned int dueca::split (const string &input, vector< string > &output, const string &separators=" \\5")
 Split strings into pieces. More...
 
string dueca::trim (const string &s, const string &pattern=", \\5")
 Strip definable characters from both ends of a string. More...
 

Detailed Description

Function Documentation

◆ operator<<()

template<typename T >
string& dueca::operator<< ( string &  lhs,
const T &  rhs 
)

std::string stream in operator

Templated function that converts the right-hand-side object to a string, and appends it to a string.

Parameters
lhsString to append to
rhsObject to append to string lhs
Returns
Reference to string lhs

◆ s2num()

template<class T >
T& dueca::s2num ( const string &  s,
T &  num 
)

Convert a string to a numeric.

Parameters
sString containing a textual representation of a number
numThe variable to output the converted numeric to
Returns
Reference to parameter num

◆ num2s()

template<typename T >
string dueca::num2s ( const T &  num,
int  width = -1 
)

Convert any numeric to a string.

Parameters
numNumeric to convert to a string
width(optional) When provided, the returned string is padded to the right with zeros to the specified width
Returns
Newly created string containing textual representation of parameter num

◆ real2s()

template<class T >
string dueca::real2s ( const T &  num)

Convert a floating point value to a string.

The converted string uses scientific format, and higher precision than num2s

Parameters
numValue to convert to a string
Returns
Newly created string containing textual representation of parameter num

◆ replaceAll()

string dueca::replaceAll ( string  s,
const string &  search,
const string &  repl 
)

Replace all occurences of a certain search string in a string.

Parameters
sSource string
searchSubstring to be replaced
replReplacement string
Returns
The new string

◆ split()

unsigned int dueca::split ( const string &  input,
vector< string > &  output,
const string &  separators = " \\5" 
)

Split strings into pieces.

Parameters
inputInput string to cut into pieces
outputVector to append the pieces to. If the vector is not empty, pieces are appended to the end of the vector
separatorsCharacter(s) to recognise as separator between pieces
Returns
The amount of generated pieces

◆ trim()

string dueca::trim ( const string &  s,
const string &  pattern = ", \\5" 
)

Strip definable characters from both ends of a string.

Parameters
sString to parse
patternCharacters that should be trimmed from the string
Returns
The trimmed string