in lib/core/CStringUtils.cc [786:854]
bool CStringUtils::_stringToType(bool silent, const std::string& str, bool& ret) {
switch (str.length()) {
case 0:
if (!silent) {
LOG_ERROR(<< "Cannot convert empty string to bool");
}
return false;
case 1:
switch (str[0]) {
case 'T':
case 'Y':
case 't':
case 'y':
ret = true;
return true;
case 'F':
case 'N':
case 'f':
case 'n':
ret = false;
return true;
}
break;
case 2:
if (CStrCaseCmp::strCaseCmp(str.c_str(), "no") == 0) {
ret = false;
return true;
}
if (CStrCaseCmp::strCaseCmp(str.c_str(), "on") == 0) {
ret = true;
return true;
}
break;
case 3:
if (CStrCaseCmp::strCaseCmp(str.c_str(), "yes") == 0) {
ret = true;
return true;
}
if (CStrCaseCmp::strCaseCmp(str.c_str(), "off") == 0) {
ret = false;
return true;
}
break;
case 4:
if (CStrCaseCmp::strCaseCmp(str.c_str(), "true") == 0) {
ret = true;
return true;
}
break;
case 5:
if (CStrCaseCmp::strCaseCmp(str.c_str(), "false") == 0) {
ret = false;
return true;
}
break;
}
long l(0);
if (CStringUtils::_stringToType(silent, str, l) == false) {
if (!silent) {
LOG_ERROR(<< "Cannot convert " << str << " to bool");
}
return false;
}
ret = (l != 0);
return true;
}