|
a/src/utils/smallut.cpp |
|
b/src/utils/smallut.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.11 2005-12-13 12:43:00 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.12 2006-01-04 11:33:44 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
#ifndef TEST_SMALLUT
|
4 |
#ifndef TEST_SMALLUT
|
5 |
#include <string>
|
5 |
#include <string>
|
6 |
#include <ctype.h>
|
6 |
#include <ctype.h>
|
7 |
#include <unistd.h>
|
7 |
#include <unistd.h>
|
|
... |
|
... |
263 |
return false;
|
263 |
return false;
|
264 |
}
|
264 |
}
|
265 |
return true;
|
265 |
return true;
|
266 |
}
|
266 |
}
|
267 |
|
267 |
|
|
|
268 |
void stringToTokens(const string& str, list<string>& tokens,
|
|
|
269 |
const string& delims)
|
|
|
270 |
{
|
|
|
271 |
string::size_type startPos, pos;
|
|
|
272 |
|
|
|
273 |
for (pos = 0;;) {
|
|
|
274 |
// Skip initial delims, break if this eats all.
|
|
|
275 |
if ((startPos = str.find_first_not_of(delims, pos)) == string::npos)
|
|
|
276 |
break;
|
|
|
277 |
// Find next delimiter or end of string (end of token)
|
|
|
278 |
pos = str.find_first_of(delims, startPos);
|
|
|
279 |
// Add token to the vector. Note: token cant be empty here
|
|
|
280 |
if (pos == string::npos)
|
|
|
281 |
tokens.push_back(str.substr(startPos));
|
|
|
282 |
else
|
|
|
283 |
tokens.push_back(str.substr(startPos, pos - startPos));
|
|
|
284 |
}
|
|
|
285 |
}
|
|
|
286 |
|
268 |
bool stringToBool(const string &s)
|
287 |
bool stringToBool(const string &s)
|
269 |
{
|
288 |
{
|
270 |
if (s.empty())
|
289 |
if (s.empty())
|
271 |
return false;
|
290 |
return false;
|
272 |
if (isdigit(s[0])) {
|
291 |
if (isdigit(s[0])) {
|