MCPcopy Create free account
hub / github.com/ElementsProject/elements / ParseInt64

Function ParseInt64

src/univalue/lib/univalue_get.cpp:47–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47bool 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
62bool ParseDouble(const std::string& str, double *out)
63{

Callers 1

get_int64Method · 0.70

Calls 1

ParsePrechecksFunction · 0.85

Tested by

no test coverage detected