libStatGen Software 1
|
This file is inspired by the poor quality of string support in STL for what should be trivial capabiltiies, for example setting or appending the ASCII representation of a floating point or integer number to a string. More...
Functions | |
int | Tokenize (std::vector< std::string > &result, const char *input, char delimiter) |
std::string & | append (std::string &s, float f) |
use std streams API to do float conversion to string, then append it. More... | |
std::string & | append (std::string &s, double f) |
use std streams API to do double conversion to string, then append it. More... | |
std::string & | append (std::string &s, char c) |
The rest we can handle readily ourselves. More... | |
std::string & | append (std::string &s, unsigned char c) |
Similar to signed char case, but this time for unsigned. More... | |
std::string & | append (std::string &s, const char *rhs) |
Now append a full C style NUL terminated string to the std::string. More... | |
std::string & | append (std::string &s, std::string &rhs) |
Prevent the generic template from picking up std::string. More... | |
template<typename T > | |
std::string & | append (std::string &s, std::vector< T > v, std::string separator="") |
iterate over the provided vector, appending all elements with an optional separator More... | |
template<typename T > | |
std::string & | append (std::string &s, T i) |
This template handles the rest of the cases for integral types. More... | |
std::string & | operator<< (std::string &s, char c) |
std::string & | operator<< (std::string &s, unsigned char c) |
std::string & | operator<< (std::string &s, uint64_t i) |
std::string & | operator<< (std::string &s, int64_t i) |
template<typename T > | |
std::string & | operator<< (std::string &s, T val) |
template<typename S > | |
std::string & | append (std::string &s, std::vector< std::string > v, S delimeter, bool itemize=false) |
template<typename T , typename S > | |
std::string & | append (std::string &s, std::vector< T > v, S delimeter, bool itemize=false) |
This file is inspired by the poor quality of string support in STL for what should be trivial capabiltiies, for example setting or appending the ASCII representation of a floating point or integer number to a string.
This file uses variadic templates to implement a type safe version (subset) of C-library printf.
Therefore, -std=c++0x is a required option on g++
|
inline |
The rest we can handle readily ourselves.
Unlike std::string operator +, this operator treats c as a character and appends the ASCII character c.
Definition at line 75 of file STLUtilities.h.
|
inline |
Now append a full C style NUL terminated string to the std::string.
Definition at line 94 of file STLUtilities.h.
|
inline |
use std streams API to do double conversion to string, then append it.
Definition at line 62 of file STLUtilities.h.
|
inline |
use std streams API to do float conversion to string, then append it.
Definition at line 50 of file STLUtilities.h.
|
inline |
Prevent the generic template from picking up std::string.
Definition at line 103 of file STLUtilities.h.
std::string & STLUtilities::append | ( | std::string & | s, |
std::vector< std::string > | v, | ||
S | delimeter, | ||
bool | itemize = false |
||
) |
Definition at line 183 of file STLUtilities.h.
std::string & STLUtilities::append | ( | std::string & | s, |
std::vector< T > | v, | ||
S | delimeter, | ||
bool | itemize = false |
||
) |
Definition at line 196 of file STLUtilities.h.
std::string & STLUtilities::append | ( | std::string & | s, |
std::vector< T > | v, | ||
std::string | separator = "" |
||
) |
iterate over the provided vector, appending all elements with an optional separator
Definition at line 113 of file STLUtilities.h.
std::string & STLUtilities::append | ( | std::string & | s, |
T | i | ||
) |
This template handles the rest of the cases for integral types.
Not user friendly if you pass in a type T that is for example a std::vector.
Definition at line 128 of file STLUtilities.h.
|
inline |
Similar to signed char case, but this time for unsigned.
Definition at line 84 of file STLUtilities.h.
|
inline |
Definition at line 158 of file STLUtilities.h.
|
inline |
Definition at line 173 of file STLUtilities.h.
std::string & STLUtilities::operator<< | ( | std::string & | s, |
T | val | ||
) |
Definition at line 178 of file STLUtilities.h.
|
inline |
Definition at line 168 of file STLUtilities.h.
|
inline |
Definition at line 163 of file STLUtilities.h.
int STLUtilities::Tokenize | ( | std::vector< std::string > & | result, |
const char * | input, | ||
char | delimiter | ||
) |
Definition at line 31 of file STLUtilities.cpp.