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 105 of file format_frontend_binding_base.hpp.

106{
107 uint8_t flags = 0;
108 if (parsed.align == Align::Left)
109 {
110 flags |= static_cast<uint8_t>(FormatFlag::LeftAlign);
111 }
112 if (parsed.align == Align::Center)
113 {
114 flags |= static_cast<uint8_t>(FormatFlag::CenterAlign);
115 }
116 if (parsed.force_sign)
117 {
118 flags |= static_cast<uint8_t>(FormatFlag::ForceSign);
119 }
120 if (parsed.space_sign)
121 {
122 flags |= static_cast<uint8_t>(FormatFlag::SpaceSign);
123 }
124 if (parsed.alternate)
125 {
126 flags |= static_cast<uint8_t>(FormatFlag::Alternate);
127 }
128 if (parsed.zero_pad && parsed.align == Align::None)
129 {
130 flags |= static_cast<uint8_t>(FormatFlag::ZeroPad);
131 }
132 if (upper_case)
133 {
134 flags |= static_cast<uint8_t>(FormatFlag::UpperCase);
135 }
136 return flags;
137}

◆ 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 15 of file format_frontend_binding_base.hpp.

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

◆ 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 75 of file format_frontend_binding_base.hpp.

76{
77 return std::array<ArgumentSummary, sizeof...(Args)>{ClassifyArgument<Args>()...};
78}

◆ 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 187 of file format_frontend_binding_base.hpp.

188{
189 if (Config::enable_float_general)
190 {
191 return 'g';
192 }
193 if (Config::enable_float_fixed)
194 {
195 return 'f';
196 }
197 if (Config::enable_float_scientific)
198 {
199 return 'e';
200 }
201 return 0;
202}

◆ 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 85 of file format_frontend_binding_base.hpp.

86{
87 return field.force_sign || field.space_sign;
88}

◆ 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 167 of file format_frontend_binding_base.hpp.

168{
169 return presentation == 0 || presentation == expected;
170}

◆ 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 177 of file format_frontend_binding_base.hpp.

178{
179 return presentation == 'b' || presentation == 'B' || presentation == 'o' ||
180 presentation == 'x' || presentation == 'X';
181}

◆ 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 147 of file format_frontend_binding_base.hpp.

149{
150 return FormatField{
151 .type = type,
152 .pack = pack,
153 .rule = FormatArgumentRule::None,
154 .flags = BuildFlags(parsed, upper_case),
155 .fill = parsed.fill,
156 .width = parsed.width,
157 .precision = parsed.has_precision ? parsed.precision : UnspecifiedPrecision(),
158 };
159}
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 not specified"

◆ 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 127 of file format_frontend_binding_integer.hpp.

128{
129 if (parsed.presentation == 0)
130 {
131 return ResolvedField{.error = Error::ArgumentTypeMismatch};
132 }
133 return ResolveIntegerField(parsed, false, false);
134}
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 141 of file format_frontend_binding_integer.hpp.

142{
143 if (parsed.presentation != 0 && parsed.presentation != 'c')
144 {
145 return ResolvedField{.error = Error::ArgumentTypeMismatch};
146 }
147 if (parsed.alternate || HasSignOption(parsed) || parsed.zero_pad || parsed.has_precision)
148 {
149 return ResolvedField{.error = Error::ArgumentTypeMismatch};
150 }
151 if (!Config::enable_text)
152 {
153 return ResolvedField{.error = Error::ArgumentTypeMismatch};
154 }
155
156 ParsedField adjusted = parsed;
157 if (adjusted.align == Align::None)
158 {
159 adjusted.align = Align::Left;
160 }
161
162 return ResolvedField{
163 .field = MakeField(adjusted, FormatType::Character, FormatPackKind::Character)};
164}
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 103 of file format_frontend_binding_float.hpp.

104{
105 constexpr auto argument_summaries = ClassifyArguments<Args...>();
106 if (parsed.arg_index >= argument_summaries.size())
107 {
108 return ResolvedField{.error = Error::MissingArgument};
109 }
110
111 auto argument = argument_summaries[parsed.arg_index];
112 switch (argument.kind)
113 {
114 case ArgumentKind::Bool:
115 return ResolveBoolField(parsed);
116 case ArgumentKind::Character:
117 return ResolveCharacterField(parsed);
118 case ArgumentKind::Signed:
119 return ResolveIntegerField(parsed, true, argument.uses_64bit_storage);
120 case ArgumentKind::Unsigned:
121 return ResolveIntegerField(parsed, false, argument.uses_64bit_storage);
122 case ArgumentKind::String:
123 return ResolveStringField(parsed);
124 case ArgumentKind::Pointer:
125 return ResolvePointerField(parsed);
126 case ArgumentKind::Float32:
127 case ArgumentKind::Float64:
128 case ArgumentKind::LongDouble:
129 return ResolveFloatField(parsed, argument.kind);
130 case ArgumentKind::Unsupported:
131 default:
132 return ResolvedField{.error = Error::UnsupportedArgumentType};
133 }
134}
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

Definition at line 15 of file format_frontend_binding_float.hpp.

17{
18 if (parsed.has_precision && parsed.precision > Config::max_float_precision)
19 {
20 return ResolvedField{.error = Error::FloatPrecisionLimitExceeded};
21 }
22
23 char presentation =
24 parsed.presentation == 0 ? DefaultFloatPresentation() : parsed.presentation;
25 if (presentation == 0)
26 {
27 return ResolvedField{.error = Error::ArgumentTypeMismatch};
28 }
29 bool upper_case =
30 presentation == 'F' || presentation == 'E' || presentation == 'G';
31
32 FormatType type = FormatType::End;
33 FormatPackKind pack = FormatPackKind::F32;
34
35 auto pick_type = [&](FormatType f32_type, FormatType f64_type,
36 FormatType ld_type) consteval -> bool {
37 switch (kind)
38 {
39 case ArgumentKind::Float32:
40 type = f32_type;
41 pack = FormatPackKind::F32;
42 return true;
43 case ArgumentKind::Float64:
44 type = Config::enable_float_double ? f64_type : f32_type;
45 pack = Config::enable_float_double ? FormatPackKind::F64 : FormatPackKind::F32;
46 return true;
47 case ArgumentKind::LongDouble:
48 if (!Config::enable_float_long_double)
49 {
50 return false;
51 }
52 type = ld_type;
53 pack = FormatPackKind::LongDouble;
54 return true;
55 default:
56 return false;
57 }
58 };
59
60 switch (presentation)
61 {
62 case 'f':
63 case 'F':
64 if (!Config::enable_float_fixed ||
65 !pick_type(FormatType::FloatFixed, FormatType::DoubleFixed,
66 FormatType::LongDoubleFixed))
67 {
68 return ResolvedField{.error = Error::ArgumentTypeMismatch};
69 }
70 break;
71 case 'e':
72 case 'E':
73 if (!Config::enable_float_scientific ||
74 !pick_type(FormatType::FloatScientific, FormatType::DoubleScientific,
75 FormatType::LongDoubleScientific))
76 {
77 return ResolvedField{.error = Error::ArgumentTypeMismatch};
78 }
79 break;
80 case 'g':
81 case 'G':
82 if (!Config::enable_float_general ||
83 !pick_type(FormatType::FloatGeneral, FormatType::DoubleGeneral,
84 FormatType::LongDoubleGeneral))
85 {
86 return ResolvedField{.error = Error::ArgumentTypeMismatch};
87 }
88 break;
89 default:
90 return ResolvedField{.error = Error::ArgumentTypeMismatch};
91 }
92
93 return ResolvedField{.field = MakeField(parsed, type, pack, upper_case)};
94}
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 16 of file format_frontend_binding_integer.hpp.

19{
20 if (!Config::enable_integer)
21 {
22 return ResolvedField{.error = Error::ArgumentTypeMismatch};
23 }
24 if (uses_64bit_storage && !Config::enable_integer_64bit)
25 {
26 return ResolvedField{.error = Error::ArgumentTypeMismatch};
27 }
28
29 if (parsed.has_precision)
30 {
31 return ResolvedField{.error = Error::ArgumentTypeMismatch};
32 }
33
34 if (parsed.presentation == 'c')
35 {
36 if (parsed.alternate || HasSignOption(parsed) || parsed.zero_pad)
37 {
38 return ResolvedField{.error = Error::ArgumentTypeMismatch};
39 }
40 return ResolvedField{.field = MakeField(parsed, FormatType::Character,
41 FormatPackKind::Character)};
42 }
43
44 if (IsDefaultOr(parsed.presentation, 'd'))
45 {
46 if (parsed.alternate)
47 {
48 return ResolvedField{.error = Error::ArgumentTypeMismatch};
49 }
50 if (!signed_decimal && HasSignOption(parsed))
51 {
52 return ResolvedField{.error = Error::ArgumentTypeMismatch};
53 }
54
55 if (signed_decimal)
56 {
57 return ResolvedField{.field = MakeField(
58 parsed,
59 uses_64bit_storage ? FormatType::Signed64
60 : FormatType::Signed32,
61 uses_64bit_storage ? FormatPackKind::I64
62 : FormatPackKind::I32)};
63 }
64
65 return ResolvedField{.field = MakeField(
66 parsed,
67 uses_64bit_storage ? FormatType::Unsigned64
68 : FormatType::Unsigned32,
69 uses_64bit_storage ? FormatPackKind::U64
70 : FormatPackKind::U32)};
71 }
72
73 if (!Config::enable_integer_base8_16 || HasSignOption(parsed))
74 {
75 return ResolvedField{.error = Error::ArgumentTypeMismatch};
76 }
77
78 switch (parsed.presentation)
79 {
80 case 'b':
81 return ResolvedField{.field = MakeField(
82 parsed,
83 uses_64bit_storage ? FormatType::Binary64
84 : FormatType::Binary32,
85 uses_64bit_storage ? FormatPackKind::U64
86 : FormatPackKind::U32)};
87 case 'B':
88 return ResolvedField{.field = MakeField(
89 parsed,
90 uses_64bit_storage ? FormatType::Binary64
91 : FormatType::Binary32,
92 uses_64bit_storage ? FormatPackKind::U64
93 : FormatPackKind::U32,
94 true)};
95 case 'o':
96 return ResolvedField{.field = MakeField(
97 parsed,
98 uses_64bit_storage ? FormatType::Octal64
99 : FormatType::Octal32,
100 uses_64bit_storage ? FormatPackKind::U64
101 : FormatPackKind::U32)};
102 case 'x':
103 return ResolvedField{.field = MakeField(
104 parsed,
105 uses_64bit_storage ? FormatType::HexLower64
106 : FormatType::HexLower32,
107 uses_64bit_storage ? FormatPackKind::U64
108 : FormatPackKind::U32)};
109 case 'X':
110 return ResolvedField{.field = MakeField(
111 parsed,
112 uses_64bit_storage ? FormatType::HexUpper64
113 : FormatType::HexUpper32,
114 uses_64bit_storage ? FormatPackKind::U64
115 : FormatPackKind::U32,
116 true)};
117 default:
118 return ResolvedField{.error = Error::ArgumentTypeMismatch};
119 }
120}
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 201 of file format_frontend_binding_integer.hpp.

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

◆ 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 171 of file format_frontend_binding_integer.hpp.

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

◆ 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 94 of file format_frontend_binding_base.hpp.

95{
96 return std::numeric_limits<uint8_t>::max();
97}