MCPcopy Create free account
hub / github.com/ablab/spades / parse_nonnegative_int

Function parse_nonnegative_int

ext/src/cppformat/format.cc:202–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200// This function assumes that the first character of s is a digit.
201template <typename Char>
202int parse_nonnegative_int(const Char *&s) {
203 assert('0' <= *s && *s <= '9');
204 unsigned value = 0;
205 do {
206 unsigned new_value = value * 10 + (*s++ - '0');
207 // Check if value wrapped around.
208 if (new_value < value) {
209 value = UINT_MAX;
210 break;
211 }
212 value = new_value;
213 } while ('0' <= *s && *s <= '9');
214 if (value > INT_MAX)
215 FMT_THROW(fmt::FormatError("number is too big"));
216 return value;
217}
218
219inline void require_numeric_argument(const Arg &arg, char spec) {
220 if (arg.type > Arg::LAST_NUMERIC_TYPE) {

Callers 3

parse_arg_indexMethod · 0.85
parse_headerMethod · 0.85
formatMethod · 0.85

Calls 2

assertClass · 0.85
FormatErrorClass · 0.85

Tested by

no test coverage detected