49 std::string
toString(
const std::vector<T>& v);
52 std::string
toString(
const std::list<T>& v);
55 std::string
toString(
const std::set<T>& v);
58 std::string
toString(
const std::deque<T>& q);
60 template<
typename T,
typename U>
61 std::string
toString(
const std::pair<T, U>& p);
64 std::string
toString(
const map<std::string, std::string>& m);
69 int strNoCaseCompare(
const std::string& A,
const std::string& B);
73 int parseString(
const std::string& str, std::vector<T>& v);
77 template<
typename T,
bool B>
78 struct parseInfToken {
79 static bool apply(
const std::string& token, T& value);
86 map<string, string> parseNameValueString(std::string str);
89 bool trueString(
const std::string& str);
92 std::string padString(
const std::string& str,
int padLength,
93 unsigned char padChar =
'0');
96 std::list<string> breakString(
const std::string& str,
unsigned lineLength);
99 std::string& trim(std::string& str);
102 string strReplaceSubstr(
const string& str,
const string& substr,
const string& rep);
106 string strSpacifyCamelCase(
const string& str);
109 string bytesToString(
unsigned b);
111 string millisecondsToString(
unsigned ms);
114 string strBaseName(
const string &fullPath);
116 string strFilename(
const string &fullPath);
118 string strDirectory(
const string &fullPath);
120 string strExtension(
const string &fullPath);
122 string strReplaceExt(
const string &fullPath,
const string &ext);
124 string strWithoutExt(
const string &fullPath);
126 string strWithoutEndSlashes(
const string &fullPath);
128 int strFileIndex(
const string &fullPath);
142 std::string
toString(
const std::vector<T>& v)
145 for (
unsigned i = 0; i < v.size(); i++) {
152 std::string
toString(
const std::list<T>& v)
155 for (
typename std::list<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
156 if (it != v.begin()) s <<
" ";
163 std::string
toString(
const std::set<T>& v)
167 for (
typename std::set<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
175 std::string
toString(
const std::deque<T>& q)
178 for (
typename std::deque<T>::const_iterator it = q.begin(); it != q.end(); ++it) {
184 template<
typename T,
typename U>
185 std::string
toString(
const std::pair<T, U>& p)
188 s <<
"(" << p.first <<
", " << p.second <<
")";
194 int drwn::parseString(
const std::string& str, std::vector<T>& v)
196 std::stringstream buffer;
204 int lastPosition = buffer.tellg();
209 buffer.seekg(lastPosition, ios::beg);
212 if (!parseInfToken<T, numeric_limits<T>::has_infinity>::apply(token, data)) {
219 if (buffer.eof())
break;
227 struct parseInfToken<T, true> {
228 static bool apply(
const std::string& token, T& value) {
229 if (token.compare(
"-inf") == 0) {
230 value = -numeric_limits<T>::infinity();
231 }
else if (token.compare(
"inf") == 0) {
232 value = numeric_limits<T>::infinity();
242 struct parseInfToken<T, false> {
243 static bool apply(
const std::string& token, T& value) {
std::string DRWN_ROW_BEG
row beginning when printing tables
std::string DRWN_COL_SEP
column separator when printing tables
std::string DRWN_ROW_END
row ending when printing tables
std::string toString(const T &v)
Templated function to make conversion from simple data types like int and double to strings easy for ...
Definition: drwnStrUtils.h:134