mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 00:21:13 +00:00
Simplify presentation type parsing
This commit is contained in:
parent
14a69fcc54
commit
aad546baa5
@ -2375,7 +2375,7 @@ FMT_CONSTEXPR auto parse_precision(const Char* begin, const Char* end,
|
|||||||
return parse_dynamic_spec(begin, end, value, ref, ctx);
|
return parse_dynamic_spec(begin, end, value, ref, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_CONSTEXPR inline auto do_parse_presentation_type(char c, type t)
|
FMT_CONSTEXPR inline auto parse_presentation_type(char c, type t)
|
||||||
-> presentation_type {
|
-> presentation_type {
|
||||||
using pt = presentation_type;
|
using pt = presentation_type;
|
||||||
constexpr auto integral_set = sint_set | uint_set | bool_set | char_set;
|
constexpr auto integral_set = sint_set | uint_set | bool_set | char_set;
|
||||||
@ -2421,14 +2421,6 @@ FMT_CONSTEXPR inline auto do_parse_presentation_type(char c, type t)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FMT_CONSTEXPR inline auto parse_presentation_type(char c, type t)
|
|
||||||
-> presentation_type {
|
|
||||||
auto pt = do_parse_presentation_type(c, t);
|
|
||||||
if (pt == presentation_type::none)
|
|
||||||
throw_format_error("invalid format specifier");
|
|
||||||
return pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class state { start, align, sign, hash, zero, width, precision, locale };
|
enum class state { start, align, sign, hash, zero, width, precision, locale };
|
||||||
|
|
||||||
// Parses standard format specifiers.
|
// Parses standard format specifiers.
|
||||||
@ -2522,7 +2514,10 @@ FMT_CONSTEXPR FMT_INLINE auto parse_format_specs(
|
|||||||
return begin;
|
return begin;
|
||||||
default: {
|
default: {
|
||||||
if (is_ascii_letter(c) || c == '?') {
|
if (is_ascii_letter(c) || c == '?') {
|
||||||
specs.type = parse_presentation_type(c, arg_type);
|
auto type = parse_presentation_type(c, arg_type);
|
||||||
|
if (type == presentation_type::none)
|
||||||
|
throw_format_error("invalid format specifier");
|
||||||
|
specs.type = type;
|
||||||
return begin + 1;
|
return begin + 1;
|
||||||
}
|
}
|
||||||
if (*begin == '}') return begin;
|
if (*begin == '}') return begin;
|
||||||
|
@ -504,7 +504,7 @@ void vprintf(buffer<Char>& buf, basic_string_view<Char> format,
|
|||||||
}
|
}
|
||||||
specs.type = parse_presentation_type(type, arg.type());
|
specs.type = parse_presentation_type(type, arg.type());
|
||||||
if (specs.type == presentation_type::none)
|
if (specs.type == presentation_type::none)
|
||||||
throw_format_error("invalid type specifier");
|
throw_format_error("invalid format specifier");
|
||||||
|
|
||||||
start = it;
|
start = it;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user