LevelS C++ support library
3.83
|
Functions | |
std::string | trim (const std::string &orig) |
template<typename T > | |
std::string | dataToString (const T &x) |
std::string | intToString (int64 x, tsize width) |
template<typename T > | |
void | stringToData (const std::string &x, T &value) |
template<typename T > | |
T | stringToData (const std::string &x) |
void | parse_file (const std::string &filename, std::map< std::string, std::string > &dict) |
bool | equal_nocase (const std::string &a, const std::string &b) |
std::string | tolower (const std::string &input) |
template<typename T > | |
void | split (const std::string &inp, std::vector< T > &list) |
template<typename T > | |
std::vector< T > | split (const std::string &inp) |
void | tokenize (const std::string &inp, char delim, std::vector< std::string > &list) |
std::vector< std::string > | tokenize (const std::string &inp, char delim) |
void | parse_words_from_file (const std::string &filename, std::vector< std::string > &words) |
std::string trim | ( | const std::string & | orig | ) |
Returns the string orig without leading and trailing whitespace.
std::string dataToString | ( | const T & | x | ) |
Returns a string containing the text representation of x. Care is taken that no information is lost in the conversion.
Definition at line 52 of file string_utils.cc.
std::string intToString | ( | int64 | x, |
tsize | width | ||
) |
Returns a string containing the text representation of x, padded with leading zeroes to width characters.
Definition at line 93 of file string_utils.cc.
void stringToData | ( | const std::string & | x, |
T & | value | ||
) |
Reads a value of a given datatype from a string
|
inline |
Reads a value of a given datatype from a string
Definition at line 64 of file string_utils.h.
void parse_file | ( | const std::string & | filename, |
std::map< std::string, std::string > & | dict | ||
) |
Parses the file filename and returns the key/value pairs in dict.
bool equal_nocase | ( | const std::string & | a, |
const std::string & | b | ||
) |
Case-insensitive string comparison Returns true, if a and b differ only in capitalisation, else false.
std::string tolower | ( | const std::string & | input | ) |
Returns lowercase version of input.
void split | ( | const std::string & | inp, |
std::vector< T > & | list | ||
) |
Tries to split inp into a white-space separated list of values of type T, and appends them to list.
|
inline |
Tries to split inp into a white-space separated list of values of type T, and appends them to list.
Definition at line 99 of file string_utils.h.
void tokenize | ( | const std::string & | inp, |
char | delim, | ||
std::vector< std::string > & | list | ||
) |
Breaks the string inp into tokens separated by delim, and returns them in list.
|
inline |
Breaks the string inp into tokens separated by delim, and returns them as a vector<string>.
Definition at line 109 of file string_utils.h.
void parse_words_from_file | ( | const std::string & | filename, |
std::vector< std::string > & | words | ||
) |
Reads all white-space separated strings from filename, and returns them in words.