MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / parse_header

Function parse_header

source/extern/fmt/printf.h:341–376  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339
340template <typename Char, typename GetArg>
341auto parse_header(const Char*& it, const Char* end, format_specs<Char>& specs,
342 GetArg get_arg) -> int {
343 int arg_index = -1;
344 Char c = *it;
345 if (c >= '0' && c <= '9') {
346 // Parse an argument index (if followed by '$') or a width possibly
347 // preceded with '0' flag(s).
348 int value = parse_nonnegative_int(it, end, -1);
349 if (it != end && *it == '$') { // value is an argument index
350 ++it;
351 arg_index = value != -1 ? value : max_value<int>();
352 } else {
353 if (c == '0') specs.fill[0] = '0';
354 if (value != 0) {
355 // Nonzero value means that we parsed width and don't need to
356 // parse it or flags again, so return now.
357 if (value == -1) throw_format_error("number is too big");
358 specs.width = value;
359 return arg_index;
360 }
361 }
362 }
363 parse_flags(specs, it, end);
364 // Parse width.
365 if (it != end) {
366 if (*it >= '0' && *it <= '9') {
367 specs.width = parse_nonnegative_int(it, end, -1);
368 if (specs.width == -1) throw_format_error("number is too big");
369 } else if (*it == '*') {
370 ++it;
371 specs.width = static_cast<int>(visit_format_arg(
372 detail::printf_width_handler<Char>(specs), get_arg(-1)));
373 }
374 }
375 return arg_index;
376}
377
378inline auto parse_printf_presentation_type(char c, type t)
379 -> presentation_type {

Callers 1

vprintfFunction · 0.85

Calls 4

parse_nonnegative_intFunction · 0.85
throw_format_errorFunction · 0.85
parse_flagsFunction · 0.85
visit_format_argFunction · 0.85

Tested by

no test coverage detected