13enum class ValueKind : uint8_t
65 flags |=
static_cast<uint8_t
>(FormatFlag::LeftAlign);
69 flags |=
static_cast<uint8_t
>(FormatFlag::ForceSign);
73 flags |=
static_cast<uint8_t
>(FormatFlag::SpaceSign);
77 flags |=
static_cast<uint8_t
>(FormatFlag::Alternate);
81 flags |=
static_cast<uint8_t
>(FormatFlag::ZeroPad);
85 flags |=
static_cast<uint8_t
>(FormatFlag::UpperCase);
106enum class FeatureGate : uint8_t
121enum class LengthPolicy : uint8_t
136 FeatureGate
gate = FeatureGate::Integer;
139 LengthPolicy::NoneOnly;
147inline constexpr size_t length_rule_count =
static_cast<size_t>(Length::LongDouble) + 1;
152inline constexpr std::array<FormatArgumentRule, length_rule_count> signed_rules{
153 FormatArgumentRule::SignedAny, FormatArgumentRule::SignedChar,
154 FormatArgumentRule::SignedShort, FormatArgumentRule::SignedLong,
155 FormatArgumentRule::SignedLongLong, FormatArgumentRule::SignedIntMax,
156 FormatArgumentRule::SignedSize, FormatArgumentRule::SignedPtrDiff,
157 FormatArgumentRule::None,
164inline constexpr std::array<FormatArgumentRule, length_rule_count> unsigned_rules{
165 FormatArgumentRule::UnsignedAny,
166 FormatArgumentRule::UnsignedChar,
167 FormatArgumentRule::UnsignedShort,
168 FormatArgumentRule::UnsignedLong,
169 FormatArgumentRule::UnsignedLongLong,
170 FormatArgumentRule::UnsignedIntMax,
171 FormatArgumentRule::UnsignedSize,
172 FormatArgumentRule::UnsignedPtrDiff,
173 FormatArgumentRule::None,
179inline constexpr std::array<SpecifierDescriptor, 17> specifiers{{
180 {
'd', ValueKind::Signed, FeatureGate::Integer, LengthPolicy::Integer,
false},
181 {
'i', ValueKind::Signed, FeatureGate::Integer, LengthPolicy::Integer,
false},
182 {
'u', ValueKind::Unsigned, FeatureGate::Integer, LengthPolicy::Integer,
false},
183 {
'b', ValueKind::Binary, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
false},
184 {
'B', ValueKind::Binary, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
true},
185 {
'o', ValueKind::Octal, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
false},
186 {
'x', ValueKind::HexLower, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
188 {
'X', ValueKind::HexUpper, FeatureGate::IntegerBase8_16, LengthPolicy::Integer,
190 {
'p', ValueKind::Pointer, FeatureGate::Pointer, LengthPolicy::NoneOnly,
false},
191 {
'c', ValueKind::Character, FeatureGate::Text, LengthPolicy::NoneOnly,
false},
192 {
's', ValueKind::String, FeatureGate::Text, LengthPolicy::NoneOnly,
false},
193 {
'f', ValueKind::FloatFixed, FeatureGate::FloatFixed, LengthPolicy::Float,
false},
194 {
'F', ValueKind::FloatFixed, FeatureGate::FloatFixed, LengthPolicy::Float,
true},
195 {
'e', ValueKind::FloatScientific, FeatureGate::FloatScientific, LengthPolicy::Float,
197 {
'E', ValueKind::FloatScientific, FeatureGate::FloatScientific, LengthPolicy::Float,
199 {
'g', ValueKind::FloatGeneral, FeatureGate::FloatGeneral, LengthPolicy::Float,
false},
200 {
'G', ValueKind::FloatGeneral, FeatureGate::FloatGeneral, LengthPolicy::Float,
true},
单个 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 / 允许的长度修饰类别
bool upper_case
whether the specifier implies uppercase output / 说明符是否隐含大写输出
char token
source conversion character / 源格式转换字符
ValueKind type
normalized semantic category / 归一化后的语义类别