16 #include <boost/tokenizer.hpp> 17 #include <boost/algorithm/string.hpp> 30 const int sz = vsnprintf(ret, n, fmt, ap);
71 const size_t start = str.find_first_not_of(
' ');
72 const size_t end = str.find_last_not_of(
' ');
75 if (string::npos==start || string::npos==end)
78 return str.substr(start, end-start+1);
94 string rc =
Trim(str);
99 const char e = rc[rc.length()-1];
101 if ((b==
'\"' && e==
'\"') || (b==
'\'' && e==
'\''))
102 return rc.substr(1, rc.length()-2);
130 const size_t pos = str.length()<width ? string::npos : str.find_last_of(
' ', width);
131 if (pos==string::npos)
133 const string rc =
str;
138 const size_t indent = str.find_first_not_of(
' ');
140 const string rc = str.substr(0, pos);
141 const size_t p2 = str.find_first_not_of(
' ', pos+1);
143 str = str.substr(0, indent) + str.substr(p2==string::npos ? pos+1 : p2);
151 rc << setprecision(1) << fixed;
161 rc << val/1000. <<
" k";
167 rc << val/1000 <<
" k";
173 rc << val/1000000. <<
" M";
179 rc << val/1000000 <<
" M";
185 rc << val/1000000000. <<
" G";
189 if (val<1000000000000)
191 rc << val/1000000000 <<
" G";
195 if (val<3000000000000)
197 rc << val/1000000000000. <<
" T";
201 if (val<1000000000000000)
203 rc << val/1000000000000 <<
" T";
207 if (val<3000000000000000)
209 rc << val/1000000000000000. <<
" P";
213 rc << val/1000000000000000. <<
" P";
232 using namespace boost;
233 typedef escaped_list_separator<char> separator;
235 const string data(opt);
237 const tokenizer<separator> tok(data, separator(
"\\",
" ",
"\"'"));
243 return map<string,string>();
246 opt = string(*it).find_first_of(
'=')==string::npos ? *it++ :
"";
248 map<string,string> rc;
252 for (; it!=tok.end(); it++)
259 const size_t pos = it->find_first_of(
'=');
260 if (pos==string::npos)
264 rc[to_string(i)] = *it;
274 rc[it->substr(0, pos)] = it->substr(pos+1);
283 boost::split(rc, str, boost::is_any_of(delim));
294 using namespace boost;
295 typedef escaped_list_separator<char> separator;
297 const auto it = tokenizer<separator>(opt, separator(
"\\",
"#",
"\"'")).
begin();
299 const int charPos = it.base() - opt.begin();
301 return charPos<1 ?
"" : opt.substr(0, opt[charPos-1]==
'#' ? charPos-1 : charPos);