24[[nodiscard]]
constexpr bool IsDigit(
char ch) {
return ch >=
'0' && ch <=
'9'; }
33[[nodiscard]]
constexpr bool HasEmbeddedNul(std::string_view source)
35 for (
char ch : source)
66 if (pos >= source.size() || !IsDigit(source[pos]))
73 while (probe < source.size() && IsDigit(source[probe]))
75 auto digit =
static_cast<size_t>(source[probe] -
'0');
76 if (index > (std::numeric_limits<size_t>::max() - digit) / 10)
78 return Error::NumberOverflow;
81 index = index * 10 + digit;
85 if (probe >= source.size() || source[probe] !=
'$')
90 if (!Config::enable_explicit_argument_indexing)
92 return Error::PositionalArgumentDisabled;
97 return Error::InvalidArgumentIndex;
101 return Error::MixedIndexing;
122[[nodiscard]]
consteval Error ParseByte(std::string_view source,
size_t& pos,
123 uint8_t limit, uint8_t& value)
126 if (pos >= source.size() || !IsDigit(source[pos]))
131 while (pos < source.size() && IsDigit(source[pos]))
133 auto digit =
static_cast<uint8_t
>(source[pos] -
'0');
134 if (value >
static_cast<uint8_t
>((limit - digit) / 10))
136 return Error::NumberOverflow;
139 value =
static_cast<uint8_t
>(value * 10 + digit);
consteval Error ParseByte(std::string_view source, size_t &pos, uint8_t limit, uint8_t &value)
解析一个目标为字节宽度的十进制整数字段片段,并检查是否溢出 / Parse one decimal byte-sized integer fragment with overflow checking
consteval Error ParseArgumentIndex(std::string_view source, size_t &pos, IndexingState &indexing, Conversion &conversion)
解析可选的前导 n$ 位置参数选择器 / Parse the optional leading n$ positional argument selector
单个 printf 转换在降为共享格式前的解析结果 / One parsed printf conversion before lowering into the shared format
bool positional
arg_index 是否来自 n$ 语法 / whether arg_index came from n$ syntax
size_t arg_index
当前字段消耗的源参数索引 / source argument index consumed by this field
brace 字段自动索引与手动索引的源级状态 / Source-level indexing mode for automatic versus manual brace fields
bool uses_positional
至少有一个转换使用了 n$ 语法 / at least one conversion used n$ syntax
size_t next_index
下一个顺序参数索引 / next sequential argument index