MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / ParseInt32

Function ParseInt32

src/commons/util/util.cpp:1041–1055  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1039}
1040
1041bool ParseInt32(const std::string& str, int32_t *out)
1042{
1043 if (!ParsePrechecks(str))
1044 return false;
1045 char *endp = nullptr;
1046 errno = 0; // strtol will not set errno if valid
1047 long int n = strtol(str.c_str(), &endp, 10);
1048 if(out) *out = (int32_t)n;
1049 // Note that strtol returns a *long int*, so even if strtol doesn't report an over/underflow
1050 // we still have to check that the returned value is within the range of an *int32_t*. On 64-bit
1051 // platforms the size of these types may be different.
1052 return endp && *endp == 0 && !errno &&
1053 n >= std::numeric_limits<int32_t>::min() &&
1054 n <= std::numeric_limits<int32_t>::max();
1055}
1056
1057bool ConvertPermsToString(uint64_t perms, uint8_t total_perms_count, string& permsList) {
1058 ostringstream s;

Callers 1

LookupSubNetFunction · 0.85

Calls 1

ParsePrechecksFunction · 0.85

Tested by

no test coverage detected