12enum class ValueKind : uint8_t
35 ValueKind
type = ValueKind::None;
57 flags |=
static_cast<uint8_t
>(FormatFlag::LeftAlign);
61 flags |=
static_cast<uint8_t
>(FormatFlag::ForceSign);
65 flags |=
static_cast<uint8_t
>(FormatFlag::SpaceSign);
69 flags |=
static_cast<uint8_t
>(FormatFlag::Alternate);
73 flags |=
static_cast<uint8_t
>(FormatFlag::ZeroPad);
77 flags |=
static_cast<uint8_t
>(FormatFlag::UpperCase);
95enum class FeatureGate : uint8_t
109enum class LengthPolicy : uint8_t
122 ValueKind
type = ValueKind::None;
124 FeatureGate::Integer;
126 LengthPolicy::NoneOnly;
133inline constexpr size_t length_rule_count =
134 static_cast<size_t>(Length::LongDouble) + 1;
139inline constexpr std::array<FormatArgumentRule, length_rule_count> signed_rules{
140 FormatArgumentRule::SignedAny,
141 FormatArgumentRule::SignedChar,
142 FormatArgumentRule::SignedShort,
143 FormatArgumentRule::SignedLong,
144 FormatArgumentRule::SignedLongLong,
145 FormatArgumentRule::SignedIntMax,
146 FormatArgumentRule::SignedSize,
147 FormatArgumentRule::SignedPtrDiff,
148 FormatArgumentRule::None,
154inline constexpr std::array<FormatArgumentRule, length_rule_count> unsigned_rules{
155 FormatArgumentRule::UnsignedAny,
156 FormatArgumentRule::UnsignedChar,
157 FormatArgumentRule::UnsignedShort,
158 FormatArgumentRule::UnsignedLong,
159 FormatArgumentRule::UnsignedLongLong,
160 FormatArgumentRule::UnsignedIntMax,
161 FormatArgumentRule::UnsignedSize,
162 FormatArgumentRule::UnsignedPtrDiff,
163 FormatArgumentRule::None,
169inline constexpr std::array<SpecifierDescriptor, 17> specifiers{{
170 {
'd', ValueKind::Signed, FeatureGate::Integer, LengthPolicy::Integer,
false},
171 {
'i', ValueKind::Signed, FeatureGate::Integer, LengthPolicy::Integer,
false},
172 {
'u', ValueKind::Unsigned, FeatureGate::Integer, LengthPolicy::Integer,
false},
173 {
'b', ValueKind::Binary, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
false},
174 {
'B', ValueKind::Binary, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
true},
175 {
'o', ValueKind::Octal, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
false},
176 {
'x', ValueKind::HexLower, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
178 {
'X', ValueKind::HexUpper, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
180 {
'p', ValueKind::Pointer, FeatureGate::Pointer, LengthPolicy::NoneOnly,
false},
181 {
'c', ValueKind::Character, FeatureGate::Text, LengthPolicy::NoneOnly,
false},
182 {
's', ValueKind::String, FeatureGate::Text, LengthPolicy::NoneOnly,
false},
183 {
'f', ValueKind::FloatFixed, FeatureGate::FloatFixed, LengthPolicy::Float,
false},
184 {
'F', ValueKind::FloatFixed, FeatureGate::FloatFixed, LengthPolicy::Float,
true},
185 {
'e', ValueKind::FloatScientific, FeatureGate::FloatScientific,
186 LengthPolicy::Float,
false},
187 {
'E', ValueKind::FloatScientific, FeatureGate::FloatScientific,
188 LengthPolicy::Float,
true},
189 {
'g', ValueKind::FloatGeneral, FeatureGate::FloatGeneral, LengthPolicy::Float,
191 {
'G', ValueKind::FloatGeneral, FeatureGate::FloatGeneral, LengthPolicy::Float,
单个 printf 转换在降为共享格式前的解析结果 / One parsed printf conversion before lowering into the shared format
ValueKind type
semantic conversion category / 转换项归一化后的语义类别
bool upper_case
implied uppercase output / 隐含的大写输出标志
constexpr uint8_t FlagsByte() const
将前端解析出的标志位打包成共享的 FormatFlag 字节 / Pack the parsed frontend flags into the shared FormatFlag byte
bool left_align
parsed - flag / 已解析的 - 标志
Length length
parsed length modifier / 已解析的长度修饰符
uint8_t width
parsed field width / 已解析的字段宽度
bool force_sign
parsed + flag / 已解析的 + 标志
bool positional
whether arg_index came from n$ syntax / arg_index 是否来自 n$ 语法
bool zero_pad
parsed 0 flag / 已解析的 0 标志
constexpr uint8_t PrecisionByte() const
返回共享精度字节;若未显式指定精度则为 0xFF / Return the shared precision byte, or 0xFF when precision is absent
bool space_sign
parsed space-sign flag / 已解析的空格正号标志
size_t arg_index
source argument index consumed by this field / 当前字段消耗的源参数索引
bool alternate
parsed # flag / 已解析的 # 标志
uint8_t precision
parsed precision value / 已解析的精度值
bool has_precision
whether precision was explicitly provided / 是否显式提供了精度
单个源级 printf 说明符描述项 / One source-level printf specifier descriptor
LengthPolicy length_policy
accepted length family / 允许的长度修饰类别
FeatureGate gate
feature gate controlling this specifier / 控制该说明符的功能开关
bool upper_case
whether the specifier implies uppercase output / 说明符是否隐含大写输出
char token
source conversion character / 源格式转换字符
ValueKind type
normalized semantic category / 归一化后的语义类别