23 #include "common_priv.h"
29 static const char NO_STR[] =
"no";
30 static const char FALSE_STR[] =
"false";
32 std::string::const_iterator cur = str.begin();
33 const std::string::const_iterator end = str.end();
34 while (cur != end && isspace(*cur)) { ++cur; }
35 if (cur == end)
return result;
36 const char *cmpstr = 0;
37 if (tolower(*cur) == NO_STR[0]) {
39 }
else if (tolower(*cur) == FALSE_STR[0]) {
40 cmpstr = &FALSE_STR[1];
41 }
else if (*cur ==
'0') {
43 while (cur != end && *cur ==
'0') { ++cur; }
44 while (cur != end && isspace(*cur)) { ++cur; }
45 if (cur == end) { result =
false; }
51 while (cur != end && cmpstr[i] !=
'\0' && tolower(*cur) == cmpstr[i]) {
54 while (cur != end && isspace(*cur)) { ++cur; }
55 if (cur == end) { result =
false; }
bool ParseBool(const std::string &str)
Parses string for a boolean value.