MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / parseAsciiUint64

Function parseAsciiUint64

Libraries/HttpClient/HttpClient.cpp:97–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95}
96
97static bool parseAsciiUint64(SC::StringSpan text, SC::uint64_t& value)
98{
99 const SC::Span<const char> bytes = text.toCharSpan();
100 if (bytes.empty())
101 {
102 return false;
103 }
104
105 SC::uint64_t parsed = 0;
106 for (size_t idx = 0; idx < bytes.sizeInBytes(); ++idx)
107 {
108 const char c = bytes[idx];
109 if (c < '0' or c > '9')
110 {
111 return false;
112 }
113 const SC::uint64_t digit = static_cast<SC::uint64_t>(c - '0');
114 if (parsed > ((~static_cast<SC::uint64_t>(0)) - digit) / 10)
115 {
116 return false;
117 }
118 parsed = parsed * 10 + digit;
119 }
120
121 value = parsed;
122 return true;
123}
124
125static bool requestHasHeader(const SC::HttpClientRequest& request, SC::StringSpan name)
126{

Callers 1

getContentLengthMethod · 0.85

Calls 1

sizeInBytesMethod · 0.45

Tested by

no test coverage detected