|
a/src/utils/smallut.cpp |
|
b/src/utils/smallut.cpp |
|
... |
|
... |
279 |
return false;
|
279 |
return false;
|
280 |
}
|
280 |
}
|
281 |
return true;
|
281 |
return true;
|
282 |
}
|
282 |
}
|
283 |
|
283 |
|
284 |
bool stringToStrings(const string &s, list<string> &tokens,
|
284 |
template bool stringToStrings<list<string> >(const string &,
|
285 |
const string& as)
|
285 |
list<string> &, const string&);
|
286 |
{
|
286 |
template bool stringToStrings<vector<string> >(const string &,
|
287 |
return stringToStrings<list<string> >(s, tokens, as);
|
287 |
vector<string> &,const string&);
|
288 |
}
|
288 |
template bool stringToStrings<set<string> >(const string &,
|
289 |
bool stringToStrings(const string &s, vector<string> &tokens,
|
289 |
set<string> &, const string&);
|
290 |
const string& as)
|
|
|
291 |
{
|
|
|
292 |
return stringToStrings<vector<string> >(s, tokens, as);
|
|
|
293 |
}
|
|
|
294 |
bool stringToStrings(const string &s, set<string> &tokens,
|
|
|
295 |
const string& as)
|
|
|
296 |
{
|
|
|
297 |
return stringToStrings<set<string> >(s, tokens, as);
|
|
|
298 |
}
|
|
|
299 |
|
290 |
|
300 |
template <class T> void stringsToString(const T &tokens, string &s)
|
291 |
template <class T> void stringsToString(const T &tokens, string &s)
|
301 |
{
|
292 |
{
|
302 |
for (typename T::const_iterator it = tokens.begin();
|
293 |
for (typename T::const_iterator it = tokens.begin();
|
303 |
it != tokens.end(); it++) {
|
294 |
it != tokens.end(); it++) {
|
|
... |
|
... |
319 |
}
|
310 |
}
|
320 |
if (hasblanks)
|
311 |
if (hasblanks)
|
321 |
s.append(1, '"');
|
312 |
s.append(1, '"');
|
322 |
}
|
313 |
}
|
323 |
}
|
314 |
}
|
324 |
void stringsToString(const list<string> &tokens, string &s)
|
315 |
template void stringsToString<list<string> >(const list<string> &, string &);
|
325 |
{
|
316 |
template void stringsToString<vector<string> >(const vector<string> &,string &);
|
326 |
stringsToString<list<string> >(tokens, s);
|
317 |
template void stringsToString<set<string> >(const set<string> &, string &);
|
327 |
}
|
|
|
328 |
void stringsToString(const vector<string> &tokens, string &s)
|
|
|
329 |
{
|
|
|
330 |
stringsToString<vector<string> >(tokens, s);
|
|
|
331 |
}
|
|
|
332 |
void stringsToString(const set<string> &tokens, string &s)
|
|
|
333 |
{
|
|
|
334 |
stringsToString<set<string> >(tokens, s);
|
|
|
335 |
}
|
|
|
336 |
|
318 |
|
337 |
void stringToTokens(const string& str, vector<string>& tokens,
|
319 |
void stringToTokens(const string& str, vector<string>& tokens,
|
338 |
const string& delims, bool skipinit)
|
320 |
const string& delims, bool skipinit)
|
339 |
{
|
321 |
{
|
340 |
string::size_type startPos = 0, pos;
|
322 |
string::size_type startPos = 0, pos;
|
|
... |
|
... |
497 |
out += "\"";
|
479 |
out += "\"";
|
498 |
return out;
|
480 |
return out;
|
499 |
}
|
481 |
}
|
500 |
|
482 |
|
501 |
|
483 |
|
502 |
// Small utility to substitute printf-like percents cmds in a string
|
484 |
// Substitute printf-like percent cmds inside a string
|
503 |
bool pcSubst(const string& in, string& out, map<char, string>& subs)
|
485 |
bool pcSubst(const string& in, string& out, map<char, string>& subs)
|
504 |
{
|
486 |
{
|
505 |
string::const_iterator it;
|
487 |
string::const_iterator it;
|
506 |
for (it = in.begin(); it != in.end();it++) {
|
488 |
for (it = in.begin(); it != in.end();it++) {
|
507 |
if (*it == '%') {
|
489 |
if (*it == '%') {
|