in src/common/UtilAll.cpp [179:197]
bool UtilAll::StringToInt32(const std::string& str, int32_t& out) {
out = 0;
if (str.empty()) {
return false;
}
char* end = NULL;
errno = 0;
long l = strtol(str.c_str(), &end, 10);
/* Both checks are needed because INT_MAX == LONG_MAX is possible. */
if (l > INT_MAX || (errno == ERANGE && l == LONG_MAX))
return false;
if (l < INT_MIN || (errno == ERANGE && l == LONG_MIN))
return false;
if (*end != '\0')
return false;
out = l;
return true;
}