23 #ifndef string_helpers_hpp
24 #define string_helpers_hpp
41 using std::wistringstream;
55 toBool(
const wstring& ws,
bool vdefault)
73 if (ws.length() == 0) {
77 val = ((ws.length() == 4)
78 && (ws[0] == L
'T' || ws[0] == L
't')
79 && (ws[1] == L
'R' || ws[1] == L
'r')
80 && (ws[2] == L
'U' || ws[2] == L
'u')
81 && (ws[3] == L
'E' || ws[3] == L
'e'));
92 template<
typename I >
94 toI(
const wstring& ws, I vdefault, I verror)
97 if (ws.length() == 0) {
100 wistringstream wiss(ws);
102 if (wiss.fail() || !wiss.eof()) {
110 toInt(
const wstring& ws,
int vdefault,
int verror)
112 return toI< int >(ws, vdefault, verror);
126 snprintf(s, 256,
"%d", i);
139 toString(
const wstring& ws)
142 string s(ws.begin(), ws.end());
153 toString(
const set< string >& s)
157 set< string >::iterator
i = s.begin();
162 while (++i != s.end()) {
174 #endif // string_helpers_hpp