libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
ArgumentResolution Namespace Reference

brace 前端共享的参数分类与字段形状构造辅助函数 / Shared brace-frontend argument classification and field-shape helpers More...

Functions

template<typename Arg >
consteval ArgumentSummary ClassifyArgument ()
 将一个 C++ 参数类型归类到 brace 前端使用的本地参数类别 / Classify one C++ argument type into the brace frontend's local category
 
template<typename... Args>
consteval auto ClassifyArguments ()
 为 brace 前端归类整组 C++ 参数类型 / Classify one full C++ argument list for the brace frontend
 
constexpr bool HasSignOption (const ParsedField &field)
 判断某个已解析字段是否请求了显式符号策略 / Return whether one parsed field requested an explicit sign policy
 
constexpr uint8_t UnspecifiedPrecision ()
 返回“未指定精度”的本地哨兵值 / Return the local sentinel meaning "precision not specified"
 
constexpr uint8_t BuildFlags (const ParsedField &parsed, bool upper_case)
 根据一个已解析 brace 字段构造共享 FormatFlag 位集合 / Build the shared FormatFlag bitset from one parsed brace field
 
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 properties
 
constexpr bool IsDefaultOr (char presentation, char expected)
 判断展示字符是否缺省或等于目标字符 / Return whether the presentation is absent or matches the expected token
 
constexpr bool IsNonDecimalPresentation (char presentation)
 判断展示字符是否选择了非十进制整数族 / Return whether the presentation selects one non-decimal integer family
 
constexpr char DefaultFloatPresentation ()
 在当前功能开关下选择前端默认浮点展示字符 / Choose the frontend default float presentation under current feature gates
 
consteval ResolvedField ResolveFloatField (const ParsedField &parsed, ArgumentKind kind)
 针对 float、double 或 long double 参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a float, double, or long double argument
 
template<typename... Args>
consteval ResolvedField ResolveField (const ParsedField &parsed)
 先判断一个已解析 brace 字段指向哪类参数,再选择匹配的字段构造逻辑 / Check which argument family a parsed brace field points to, then choose the matching field builder
 
consteval ResolvedField ResolveIntegerField (const ParsedField &parsed, bool signed_decimal, bool uses_64bit_storage)
 针对整数类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for an integer-like argument
 
consteval ResolvedField ResolveBoolField (const ParsedField &parsed)
 针对 bool 参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a bool argument
 
consteval ResolvedField ResolveCharacterField (const ParsedField &parsed)
 针对字符参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a character argument
 
consteval ResolvedField ResolveStringField (const ParsedField &parsed)
 针对字符串类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a string-like argument
 
consteval ResolvedField ResolvePointerField (const ParsedField &parsed)
 针对指针类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a pointer-like argument
 

Detailed Description

brace 前端共享的参数分类与字段形状构造辅助函数 / Shared brace-frontend argument classification and field-shape helpers

brace 前端里处理 bool、整数、字符、字符串与指针参数字段的辅助函数 / Brace-frontend helpers for fields that point to bool, integer, character, string, and pointer arguments

brace 前端里处理浮点参数字段的辅助函数 / Brace-frontend helpers for fields that point to float arguments

Function Documentation

◆ BuildFlags()

uint8_t ArgumentResolution::BuildFlags ( const ParsedField & parsed,
bool upper_case )
nodiscardconstexpr

根据一个已解析 brace 字段构造共享 FormatFlag 位集合 / Build the shared FormatFlag bitset from one parsed brace field

Parameters
parsed已解析的 brace 字段 / Parsed brace field
upper_case最终展示是否使用大写字母 / Whether the final presentation should use uppercase letters
Returns
返回该字段对应的共享 FormatFlag 位集合 / Returns the shared FormatFlag bitset for this field

Definition at line 117 of file format_frontend_binding_base.hpp.

118{
119 uint8_t flags = 0;
120 if (parsed.align == Align::Left)
121 {
122 flags |= static_cast<uint8_t>(FormatFlag::LeftAlign);
123 }
124 if (parsed.align == Align::Center)
125 {
126 flags |= static_cast<uint8_t>(FormatFlag::CenterAlign);
127 }
128 if (parsed.force_sign)
129 {
130 flags |= static_cast<uint8_t>(FormatFlag::ForceSign);
131 }
132 if (parsed.space_sign)
133 {
134 flags |= static_cast<uint8_t>(FormatFlag::SpaceSign);
135 }
136 if (parsed.alternate)
137 {
138 flags |= static_cast<uint8_t>(FormatFlag::Alternate);
139 }
140 if (parsed.zero_pad && parsed.align == Align::None)
141 {
142 flags |= static_cast<uint8_t>(FormatFlag::ZeroPad);
143 }
144 if (upper_case)
145 {
146 flags |= static_cast<uint8_t>(FormatFlag::UpperCase);
147 }
148 return flags;
149}

◆ ClassifyArgument()

template<typename Arg >
ArgumentSummary ArgumentResolution::ClassifyArgument ( )
nodiscardconsteval

将一个 C++ 参数类型归类到 brace 前端使用的本地参数类别 / Classify one C++ argument type into the brace frontend's local category

Template Parameters
Arg待归类的 C++ 参数类型 / C++ argument type to classify
Returns
返回后续字段解析要使用的本地前端参数摘要 / Returns the local frontend summary used by later field resolution

Definition at line 18 of file format_frontend_binding_base.hpp.

19{
20 using Traits = FormatArgument::TypeTraits<Arg>;
21 using Decayed = typename Traits::Decayed;
22 using Normalized = typename Traits::Normalized;
23
24 if constexpr (std::is_same_v<Decayed, bool>)
25 {
26 return ArgumentSummary{.kind = ArgumentKind::Bool};
27 }
28 else if constexpr (std::is_same_v<Decayed, char>)
29 {
30 return ArgumentSummary{.kind = ArgumentKind::Character};
31 }
32 else if constexpr (Traits::is_string_like)
33 {
34 return ArgumentSummary{.kind = ArgumentKind::String};
35 }
36 else if constexpr (Traits::is_pointer_like)
37 {
38 return ArgumentSummary{.kind = ArgumentKind::Pointer};
39 }
40 else if constexpr (Traits::is_signed_integer)
41 {
42 return ArgumentSummary{
43 .kind = ArgumentKind::Signed,
44 .uses_64bit_storage = sizeof(Normalized) > sizeof(int32_t),
45 };
46 }
47 else if constexpr (Traits::is_unsigned_integer)
48 {
49 return ArgumentSummary{
50 .kind = ArgumentKind::Unsigned,
51 .uses_64bit_storage = sizeof(Normalized) > sizeof(uint32_t),
52 };
53 }
54 else if constexpr (std::is_same_v<Decayed, float>)
55 {
56 return ArgumentSummary{.kind = ArgumentKind::Float32};
57 }
58 else if constexpr (std::is_same_v<Decayed, double>)
59 {
60 return ArgumentSummary{.kind = ArgumentKind::Float64};
61 }
62 else if constexpr (std::is_same_v<Decayed, long double>)
63 {
64 return ArgumentSummary{.kind = ArgumentKind::LongDouble};
65 }
66 else
67 {
68 return ArgumentSummary{};
69 }
70}

◆ ClassifyArguments()

template<typename... Args>
auto ArgumentResolution::ClassifyArguments ( )
nodiscardconsteval

为 brace 前端归类整组 C++ 参数类型 / Classify one full C++ argument list for the brace frontend

Template Parameters
Args待归类的 C++ 实参类型列表 / C++ argument types to classify
Returns
按源参数顺序返回每个参数对应的一份 ArgumentSummary / Returns one ArgumentSummary per argument in source order

Definition at line 80 of file format_frontend_binding_base.hpp.

81{
82 return std::array<ArgumentSummary, sizeof...(Args)>{ClassifyArgument<Args>()...};
83}

◆ DefaultFloatPresentation()

char ArgumentResolution::DefaultFloatPresentation ( )
nodiscardconstexpr

在当前功能开关下选择前端默认浮点展示字符 / Choose the frontend default float presentation under current feature gates

Returns
返回默认浮点展示字符;若全部浮点展示都被关闭则返回 0 / Returns the default float presentation token, or zero when all float presentations are disabled

Definition at line 210 of file format_frontend_binding_base.hpp.

211{
212 if (Config::enable_float_general)
213 {
214 return 'g';
215 }
216 if (Config::enable_float_fixed)
217 {
218 return 'f';
219 }
220 if (Config::enable_float_scientific)
221 {
222 return 'e';
223 }
224 return 0;
225}

◆ HasSignOption()

bool ArgumentResolution::HasSignOption ( const ParsedField & field)
nodiscardconstexpr

判断某个已解析字段是否请求了显式符号策略 / Return whether one parsed field requested an explicit sign policy

Parameters
field待检查的已解析字段 / Parsed field to inspect
Returns
若请求了 + 或空格符号策略则返回 true,否则返回 false / Returns true when + or space-sign was requested, otherwise false

Definition at line 92 of file format_frontend_binding_base.hpp.

93{
94 return field.force_sign || field.space_sign;
95}

◆ IsDefaultOr()

bool ArgumentResolution::IsDefaultOr ( char presentation,
char expected )
nodiscardconstexpr

判断展示字符是否缺省或等于目标字符 / Return whether the presentation is absent or matches the expected token

Parameters
presentation已解析展示字符;缺省时为 0 / Parsed presentation token, or zero when absent
expected期望的展示字符 / Expected presentation token
Returns
若展示字符缺省或等于 expected 则返回 true / Returns true when the presentation is absent or matches expected

Definition at line 186 of file format_frontend_binding_base.hpp.

187{
188 return presentation == 0 || presentation == expected;
189}

◆ IsNonDecimalPresentation()

bool ArgumentResolution::IsNonDecimalPresentation ( char presentation)
nodiscardconstexpr

判断展示字符是否选择了非十进制整数族 / Return whether the presentation selects one non-decimal integer family

Parameters
presentation已解析展示字符 / Parsed presentation token
Returns
若选择了二进制、八进制或十六进制展示则返回 true,否则返回 false / Returns true for binary, octal, or hex presentations, otherwise false

Definition at line 198 of file format_frontend_binding_base.hpp.

199{
200 return presentation == 'b' || presentation == 'B' || presentation == 'o' ||
201 presentation == 'x' || presentation == 'X';
202}

◆ MakeField()

FormatField ArgumentResolution::MakeField ( const ParsedField & parsed,
FormatType type,
FormatPackKind pack,
bool upper_case = false )
nodiscardconstexpr

根据 brace 字段属性构造一条共享 FormatField 记录 / Build one shared FormatField record from parsed brace-field properties

Parameters
parsed已解析的 brace 字段 / Parsed brace field
type共享运行期字段类型 / Shared runtime field type
pack运行期参数打包类型 / Runtime packed-argument kind
upper_case最终展示是否使用大写字母 / Whether the final presentation should use uppercase letters
Returns
返回共享编译后端要消费的 FormatField 记录 / Returns the shared FormatField record consumed by the compile-time backend

Definition at line 162 of file format_frontend_binding_base.hpp.

165{
166 return FormatField{
167 .type = type,
168 .pack = pack,
169 .rule = FormatArgumentRule::None,
170 .flags = BuildFlags(parsed, upper_case),
171 .fill = parsed.fill,
172 .width = parsed.width,
173 .precision = parsed.has_precision ? parsed.precision : UnspecifiedPrecision(),
174 };
175}
constexpr uint8_t BuildFlags(const ParsedField &parsed, bool upper_case)
根据一个已解析 brace 字段构造共享 FormatFlag 位集合 / Build the shared FormatFlag bitset from one parsed brace field
constexpr uint8_t UnspecifiedPrecision()
返回“未指定精度”的本地哨兵值 / Return the local sentinel meaning "precision notspecified"

◆ ResolveBoolField()

ResolvedField ArgumentResolution::ResolveBoolField ( const ParsedField & parsed)
nodiscardconsteval

针对 bool 参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a bool argument

Parameters
parsed已解析的 brace 字段 / Parsed brace field
Returns
返回解析后的共享字段;不匹配时返回首个类型错误 / Returns the resolved shared field, or the first type-mismatch error

Definition at line 121 of file format_frontend_binding_integer.hpp.

122{
123 if (parsed.presentation == 0)
124 {
125 return ResolvedField{.error = Error::ArgumentTypeMismatch};
126 }
127 return ResolveIntegerField(parsed, false, false);
128}
consteval ResolvedField ResolveIntegerField(const ParsedField &parsed, bool signed_decimal, bool uses_64bit_storage)
针对整数类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for an integer-like argument

◆ ResolveCharacterField()

ResolvedField ArgumentResolution::ResolveCharacterField ( const ParsedField & parsed)
nodiscardconsteval

针对字符参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a character argument

Parameters
parsed已解析的 brace 字段 / Parsed brace field
Returns
返回解析后的共享字段;不匹配时返回首个类型错误 / Returns the resolved shared field, or the first type-mismatch error

Definition at line 137 of file format_frontend_binding_integer.hpp.

138{
139 if (parsed.presentation != 0 && parsed.presentation != 'c')
140 {
141 return ResolvedField{.error = Error::ArgumentTypeMismatch};
142 }
143 if (parsed.alternate || HasSignOption(parsed) || parsed.zero_pad ||
144 parsed.has_precision)
145 {
146 return ResolvedField{.error = Error::ArgumentTypeMismatch};
147 }
148 if (!Config::enable_text)
149 {
150 return ResolvedField{.error = Error::ArgumentTypeMismatch};
151 }
152
153 ParsedField adjusted = parsed;
154 if (adjusted.align == Align::None)
155 {
156 adjusted.align = Align::Left;
157 }
158
159 return ResolvedField{
160 .field = MakeField(adjusted, FormatType::Character, FormatPackKind::Character)};
161}
constexpr bool HasSignOption(const ParsedField &field)
判断某个已解析字段是否请求了显式符号策略 / Return whether one parsed field requested an explicit sign policy
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...

◆ ResolveField()

template<typename... Args>
ResolvedField ArgumentResolution::ResolveField ( const ParsedField & parsed)
nodiscardconsteval

先判断一个已解析 brace 字段指向哪类参数,再选择匹配的字段构造逻辑 / Check which argument family a parsed brace field points to, then choose the matching field builder

Template Parameters
Args已绑定的 C++ 实参类型列表 / Bound C++ argument types
Parameters
parsed已解析的 brace 字段 / Parsed brace field
Returns
返回解析后的共享字段;缺参或类型不支持时返回首个错误 / Returns the resolved shared field, or the first missing-argument or unsupported-type error

Definition at line 111 of file format_frontend_binding_float.hpp.

112{
113 constexpr auto argument_summaries = ClassifyArguments<Args...>();
114 if (parsed.arg_index >= argument_summaries.size())
115 {
116 return ResolvedField{.error = Error::MissingArgument};
117 }
118
119 auto argument = argument_summaries[parsed.arg_index];
120 switch (argument.kind)
121 {
122 case ArgumentKind::Bool:
123 return ResolveBoolField(parsed);
124 case ArgumentKind::Character:
125 return ResolveCharacterField(parsed);
126 case ArgumentKind::Signed:
127 return ResolveIntegerField(parsed, true, argument.uses_64bit_storage);
128 case ArgumentKind::Unsigned:
129 return ResolveIntegerField(parsed, false, argument.uses_64bit_storage);
130 case ArgumentKind::String:
131 return ResolveStringField(parsed);
132 case ArgumentKind::Pointer:
133 return ResolvePointerField(parsed);
134 case ArgumentKind::Float32:
135 case ArgumentKind::Float64:
136 case ArgumentKind::LongDouble:
137 return ResolveFloatField(parsed, argument.kind);
138 case ArgumentKind::Unsupported:
139 default:
140 return ResolvedField{.error = Error::UnsupportedArgumentType};
141 }
142}
consteval ResolvedField ResolveBoolField(const ParsedField &parsed)
针对 bool 参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a bool argument
consteval ResolvedField ResolvePointerField(const ParsedField &parsed)
针对指针类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a pointer-like argument
consteval auto ClassifyArguments()
为 brace 前端归类整组 C++ 参数类型 / Classify one full C++ argument list for the brace frontend
consteval ResolvedField ResolveCharacterField(const ParsedField &parsed)
针对字符参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a character argument
consteval ResolvedField ResolveFloatField(const ParsedField &parsed, ArgumentKind kind)
针对 float、double 或 long double 参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a float,...
consteval ResolvedField ResolveStringField(const ParsedField &parsed)
针对字符串类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a string-like argument

◆ ResolveFloatField()

ResolvedField ArgumentResolution::ResolveFloatField ( const ParsedField & parsed,
ArgumentKind kind )
nodiscardconsteval

针对 float、double 或 long double 参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a float, double, or long double argument

Parameters
parsed已解析的 brace 字段 / Parsed brace field
kind当前字段选中的前端参数类别 / Frontend-side argument family selected for this field
Returns
返回解析后的共享字段;精度或类型不匹配时返回首个错误 / Returns the resolved shared field, or the first precision or type mismatch error
Note
double 支持关闭时,double 参数会降为 F32 存储与格式化 / When double support is disabled, double arguments are reduced to F32 storage and formatting

Definition at line 21 of file format_frontend_binding_float.hpp.

23{
24 if (parsed.has_precision && parsed.precision > Config::max_float_precision)
25 {
26 return ResolvedField{.error = Error::FloatPrecisionLimitExceeded};
27 }
28
29 char presentation =
30 parsed.presentation == 0 ? DefaultFloatPresentation() : parsed.presentation;
31 if (presentation == 0)
32 {
33 return ResolvedField{.error = Error::ArgumentTypeMismatch};
34 }
35 bool upper_case = presentation == 'F' || presentation == 'E' || presentation == 'G';
36
37 FormatType type = FormatType::End;
38 FormatPackKind pack = FormatPackKind::F32;
39
40 auto pick_type = [&](FormatType f32_type, FormatType f64_type,
41 FormatType ld_type) consteval -> bool
42 {
43 switch (kind)
44 {
45 case ArgumentKind::Float32:
46 type = f32_type;
47 pack = FormatPackKind::F32;
48 return true;
49 case ArgumentKind::Float64:
50 type = Config::enable_float_double ? f64_type : f32_type;
51 pack = Config::enable_float_double ? FormatPackKind::F64 : FormatPackKind::F32;
52 return true;
53 case ArgumentKind::LongDouble:
54 if (!Config::enable_float_long_double)
55 {
56 return false;
57 }
58 type = ld_type;
59 pack = FormatPackKind::LongDouble;
60 return true;
61 default:
62 return false;
63 }
64 };
65
66 switch (presentation)
67 {
68 case 'f':
69 case 'F':
70 if (!Config::enable_float_fixed ||
71 !pick_type(FormatType::FloatFixed, FormatType::DoubleFixed,
72 FormatType::LongDoubleFixed))
73 {
74 return ResolvedField{.error = Error::ArgumentTypeMismatch};
75 }
76 break;
77 case 'e':
78 case 'E':
79 if (!Config::enable_float_scientific ||
80 !pick_type(FormatType::FloatScientific, FormatType::DoubleScientific,
81 FormatType::LongDoubleScientific))
82 {
83 return ResolvedField{.error = Error::ArgumentTypeMismatch};
84 }
85 break;
86 case 'g':
87 case 'G':
88 if (!Config::enable_float_general ||
89 !pick_type(FormatType::FloatGeneral, FormatType::DoubleGeneral,
90 FormatType::LongDoubleGeneral))
91 {
92 return ResolvedField{.error = Error::ArgumentTypeMismatch};
93 }
94 break;
95 default:
96 return ResolvedField{.error = Error::ArgumentTypeMismatch};
97 }
98
99 return ResolvedField{.field = MakeField(parsed, type, pack, upper_case)};
100}
constexpr char DefaultFloatPresentation()
在当前功能开关下选择前端默认浮点展示字符 / Choose the frontend default float presentation under current feature gates

◆ ResolveIntegerField()

ResolvedField ArgumentResolution::ResolveIntegerField ( const ParsedField & parsed,
bool signed_decimal,
bool uses_64bit_storage )
nodiscardconsteval

针对整数类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for an integer-like argument

Parameters
parsed已解析的 brace 字段 / Parsed brace field
signed_decimal选中的参数是否按有符号十进制族处理 / Whether the selected argument should be treated as a signed decimal family
uses_64bit_storage选中的参数是否需要 64 位打包存储 / Whether the selected argument requires 64-bit packed storage
Returns
返回解析后的共享字段;不匹配时返回首个类型错误 / Returns the resolved shared field, or the first type-mismatch error

Definition at line 22 of file format_frontend_binding_integer.hpp.

25{
26 if (!Config::enable_integer)
27 {
28 return ResolvedField{.error = Error::ArgumentTypeMismatch};
29 }
30 if (uses_64bit_storage && !Config::enable_integer_64bit)
31 {
32 return ResolvedField{.error = Error::ArgumentTypeMismatch};
33 }
34
35 if (parsed.has_precision)
36 {
37 return ResolvedField{.error = Error::ArgumentTypeMismatch};
38 }
39
40 if (parsed.presentation == 'c')
41 {
42 if (parsed.alternate || HasSignOption(parsed) || parsed.zero_pad)
43 {
44 return ResolvedField{.error = Error::ArgumentTypeMismatch};
45 }
46 return ResolvedField{
47 .field = MakeField(parsed, FormatType::Character, FormatPackKind::Character)};
48 }
49
50 if (IsDefaultOr(parsed.presentation, 'd'))
51 {
52 if (parsed.alternate)
53 {
54 return ResolvedField{.error = Error::ArgumentTypeMismatch};
55 }
56 if (!signed_decimal && HasSignOption(parsed))
57 {
58 return ResolvedField{.error = Error::ArgumentTypeMismatch};
59 }
60
61 if (signed_decimal)
62 {
63 return ResolvedField{
64 .field = MakeField(
65 parsed, uses_64bit_storage ? FormatType::Signed64 : FormatType::Signed32,
66 uses_64bit_storage ? FormatPackKind::I64 : FormatPackKind::I32)};
67 }
68
69 return ResolvedField{
70 .field = MakeField(
71 parsed, uses_64bit_storage ? FormatType::Unsigned64 : FormatType::Unsigned32,
72 uses_64bit_storage ? FormatPackKind::U64 : FormatPackKind::U32)};
73 }
74
75 if (!Config::enable_integer_base8_16 || HasSignOption(parsed))
76 {
77 return ResolvedField{.error = Error::ArgumentTypeMismatch};
78 }
79
80 switch (parsed.presentation)
81 {
82 case 'b':
83 return ResolvedField{
84 .field = MakeField(
85 parsed, uses_64bit_storage ? FormatType::Binary64 : FormatType::Binary32,
86 uses_64bit_storage ? FormatPackKind::U64 : FormatPackKind::U32)};
87 case 'B':
88 return ResolvedField{
89 .field = MakeField(
90 parsed, uses_64bit_storage ? FormatType::Binary64 : FormatType::Binary32,
91 uses_64bit_storage ? FormatPackKind::U64 : FormatPackKind::U32, true)};
92 case 'o':
93 return ResolvedField{
94 .field = MakeField(
95 parsed, uses_64bit_storage ? FormatType::Octal64 : FormatType::Octal32,
96 uses_64bit_storage ? FormatPackKind::U64 : FormatPackKind::U32)};
97 case 'x':
98 return ResolvedField{
99 .field = MakeField(
100 parsed,
101 uses_64bit_storage ? FormatType::HexLower64 : FormatType::HexLower32,
102 uses_64bit_storage ? FormatPackKind::U64 : FormatPackKind::U32)};
103 case 'X':
104 return ResolvedField{
105 .field = MakeField(
106 parsed,
107 uses_64bit_storage ? FormatType::HexUpper64 : FormatType::HexUpper32,
108 uses_64bit_storage ? FormatPackKind::U64 : FormatPackKind::U32, true)};
109 default:
110 return ResolvedField{.error = Error::ArgumentTypeMismatch};
111 }
112}
constexpr bool IsDefaultOr(char presentation, char expected)
判断展示字符是否缺省或等于目标字符 / Return whether the presentation is absent or matches the expected token

◆ ResolvePointerField()

ResolvedField ArgumentResolution::ResolvePointerField ( const ParsedField & parsed)
nodiscardconsteval

针对指针类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a pointer-like argument

Parameters
parsed已解析的 brace 字段 / Parsed brace field
Returns
返回解析后的共享字段;不匹配时返回首个类型错误 / Returns the resolved shared field, or the first type-mismatch error

Definition at line 202 of file format_frontend_binding_integer.hpp.

203{
204 if (parsed.presentation != 0 && parsed.presentation != 'p')
205 {
206 return ResolvedField{.error = Error::ArgumentTypeMismatch};
207 }
208 if (parsed.alternate || HasSignOption(parsed) || parsed.zero_pad ||
209 parsed.has_precision)
210 {
211 return ResolvedField{.error = Error::ArgumentTypeMismatch};
212 }
213 if (!Config::enable_pointer)
214 {
215 return ResolvedField{.error = Error::ArgumentTypeMismatch};
216 }
217
218 return ResolvedField{
219 .field = MakeField(parsed, FormatType::Pointer, FormatPackKind::Pointer)};
220}

◆ ResolveStringField()

ResolvedField ArgumentResolution::ResolveStringField ( const ParsedField & parsed)
nodiscardconsteval

针对字符串类参数解析一个已解析的 brace 字段 / Resolve one parsed brace field for a string-like argument

Parameters
parsed已解析的 brace 字段 / Parsed brace field
Returns
返回解析后的共享字段;不匹配时返回首个类型错误 / Returns the resolved shared field, or the first type-mismatch error

Definition at line 170 of file format_frontend_binding_integer.hpp.

171{
172 if (parsed.presentation != 0 && parsed.presentation != 's')
173 {
174 return ResolvedField{.error = Error::ArgumentTypeMismatch};
175 }
176 if (parsed.alternate || HasSignOption(parsed) || parsed.zero_pad)
177 {
178 return ResolvedField{.error = Error::ArgumentTypeMismatch};
179 }
180 if (!Config::enable_text)
181 {
182 return ResolvedField{.error = Error::ArgumentTypeMismatch};
183 }
184
185 ParsedField adjusted = parsed;
186 if (adjusted.align == Align::None)
187 {
188 adjusted.align = Align::Left;
189 }
190
191 return ResolvedField{
192 .field = MakeField(adjusted, FormatType::String, FormatPackKind::StringView)};
193}

◆ UnspecifiedPrecision()

uint8_t ArgumentResolution::UnspecifiedPrecision ( )
nodiscardconstexpr

返回“未指定精度”的本地哨兵值 / Return the local sentinel meaning "precision not specified"

Returns
返回 brace 前端内部使用的精度哨兵值 / Returns the precision sentinel byte used inside the brace frontend

Definition at line 103 of file format_frontend_binding_base.hpp.

104{
105 return std::numeric_limits<uint8_t>::max();
106}