| 45 | } |
| 46 | |
| 47 | bool ParseInt64(const std::string& str, int64_t *out) |
| 48 | { |
| 49 | if (!ParsePrechecks(str)) |
| 50 | return false; |
| 51 | char *endp = nullptr; |
| 52 | errno = 0; // strtoll will not set errno if valid |
| 53 | long long int n = strtoll(str.c_str(), &endp, 10); |
| 54 | if(out) *out = (int64_t)n; |
| 55 | // Note that strtoll returns a *long long int*, so even if strtol doesn't report a over/underflow |
| 56 | // we still have to check that the returned value is within the range of an *int64_t*. |
| 57 | return endp && *endp == 0 && !errno && |
| 58 | n >= std::numeric_limits<int64_t>::min() && |
| 59 | n <= std::numeric_limits<int64_t>::max(); |
| 60 | } |
| 61 | |
| 62 | bool ParseDouble(const std::string& str, double *out) |
| 63 | { |
no test coverage detected