18 if (parsed.has_precision && parsed.precision > Config::max_float_precision)
20 return ResolvedField{.error = Error::FloatPrecisionLimitExceeded};
25 if (presentation == 0)
27 return ResolvedField{.error = Error::ArgumentTypeMismatch};
30 presentation ==
'F' || presentation ==
'E' || presentation ==
'G';
32 FormatType type = FormatType::End;
33 FormatPackKind pack = FormatPackKind::F32;
35 auto pick_type = [&](FormatType f32_type, FormatType f64_type,
36 FormatType ld_type)
consteval ->
bool {
39 case ArgumentKind::Float32:
41 pack = FormatPackKind::F32;
43 case ArgumentKind::Float64:
44 type = Config::enable_float_double ? f64_type : f32_type;
45 pack = Config::enable_float_double ? FormatPackKind::F64 : FormatPackKind::F32;
47 case ArgumentKind::LongDouble:
48 if (!Config::enable_float_long_double)
53 pack = FormatPackKind::LongDouble;
64 if (!Config::enable_float_fixed ||
65 !pick_type(FormatType::FloatFixed, FormatType::DoubleFixed,
66 FormatType::LongDoubleFixed))
68 return ResolvedField{.error = Error::ArgumentTypeMismatch};
73 if (!Config::enable_float_scientific ||
74 !pick_type(FormatType::FloatScientific, FormatType::DoubleScientific,
75 FormatType::LongDoubleScientific))
77 return ResolvedField{.error = Error::ArgumentTypeMismatch};
82 if (!Config::enable_float_general ||
83 !pick_type(FormatType::FloatGeneral, FormatType::DoubleGeneral,
84 FormatType::LongDoubleGeneral))
86 return ResolvedField{.error = Error::ArgumentTypeMismatch};
90 return ResolvedField{.error = Error::ArgumentTypeMismatch};
93 return ResolvedField{.field =
MakeField(parsed, type, pack, upper_case)};
103[[nodiscard]]
consteval ResolvedField
ResolveField(
const ParsedField& parsed)
106 if (parsed.arg_index >= argument_summaries.size())
108 return ResolvedField{.error = Error::MissingArgument};
111 auto argument = argument_summaries[parsed.arg_index];
112 switch (argument.kind)
114 case ArgumentKind::Bool:
116 case ArgumentKind::Character:
118 case ArgumentKind::Signed:
120 case ArgumentKind::Unsigned:
122 case ArgumentKind::String:
124 case ArgumentKind::Pointer:
126 case ArgumentKind::Float32:
127 case ArgumentKind::Float64:
128 case ArgumentKind::LongDouble:
130 case ArgumentKind::Unsupported:
132 return ResolvedField{.error = Error::UnsupportedArgumentType};
constexpr FormatField MakeField(const ParsedField &parsed, FormatType type, FormatPackKind pack, bool upper_case=false)
根据 brace 字段属性构造一条共享 FormatField 记录 / Build one shared FormatField record from parsed brace-field prop...