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

Function ParseIntegral

src/util/strencodings.cpp:280–296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

278namespace {
279template <typename T>
280bool ParseIntegral(const std::string& str, T* out)
281{
282 static_assert(std::is_integral<T>::value);
283 // Replicate the exact behavior of strtol/strtoll/strtoul/strtoull when
284 // handling leading +/- for backwards compatibility.
285 if (str.length() >= 2 && str[0] == '+' && str[1] == '-') {
286 return false;
287 }
288 const std::optional<T> opt_int = ToIntegral<T>((!str.empty() && str[0] == '+') ? str.substr(1) : str);
289 if (!opt_int) {
290 return false;
291 }
292 if (out != nullptr) {
293 *out = *opt_int;
294 }
295 return true;
296}
297}; // namespace
298
299bool ParseInt32(const std::string& str, int32_t* out)

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.45

Tested by

no test coverage detected