7#include "format_argument.hpp"
29 constexpr Text(
const char (&text)[N])
31 for (
size_t i = 0; i < N; ++i)
43 [[nodiscard]]
constexpr size_t Size()
const {
return N - 1; }
50 [[nodiscard]]
constexpr const char*
Data()
const {
return data; }
110 template <Text Source>
113 template <Text Source>
122 template <Text Source>
136 template <
Text Source,
typename... Args>
144#include "printf/printf_frontend_detail.hpp"
145namespace LibXR::Print
147template <Text Source>
152 inline static constexpr auto source_analysis = Detail::PrintfCompile::Analyze<Source>();
156 "LibXR::Print::Printf: numeric field is too large");
159 "LibXR::Print::Printf: float precision exceeds the configured print limit");
161 "LibXR::Print::Printf: unexpected end of format string");
164 "LibXR::Print::Printf: embedded NUL bytes are not supported in the format literal");
167 "LibXR::Print::Printf: positional and sequential arguments cannot be mixed");
169 "LibXR::Print::Printf: positional argument indexing is disabled in the "
172 "LibXR::Print::Printf: dynamic width and precision are not supported");
174 "LibXR::Print::Printf: invalid positional argument index");
176 "LibXR::Print::Printf: invalid format specifier");
178 "LibXR::Print::Printf: invalid length modifier");
180 "LibXR::Print::Printf: one positional argument is reused with "
181 "incompatible conversions");
183 "LibXR::Print::Printf: text pool offset is too large");
185 "LibXR::Print::Printf: text span is too large");
187 "LibXR::Print::Printf: one positional argument is reused with "
188 "incompatible conversions");
195 inline static constexpr auto codes = result.codes;
200 inline static constexpr FormatProfile
profile = result.profile;
206 [[nodiscard]]
static constexpr auto ArgumentList() {
return result.arg_info; }
212 [[nodiscard]]
static constexpr auto ArgumentOrder() {
return source_analysis.order; }
220 return source_analysis.args;
227 [[nodiscard]]
static constexpr const auto&
Codes() {
return codes; }
242 template <
typename... Args>
单个 printf 源字符串的编译期前端,负责解析并降为共享格式语义 / Compile-time printf frontend that parses and lowers one source s...
printf 风格前端,输出内部格式表示 / Printf-style frontend that emits the internal format representation
Length
归一化后的 printf 长度修饰符 / Supported printf length modifiers after normalization
@ LongLong
ll / long long 长度修饰
@ IntMax
j / intmax_t 长度修饰
@ PtrDiff
t / ptrdiff_t 长度修饰
@ LongDouble
L / long double 长度修饰
@ Default
no length modifier / 无长度修饰符
Error
通过 static_assert 暴露的编译期解析或构建失败类别 / Compile-time parse or build failure categories surfaced through st...
@ InvalidArgumentIndex
positional argument index is invalid / 位置参数索引非法
@ FloatPrecisionLimitExceeded
@ PositionalArgumentDisabled
static consteval Compiled< Source > Build()
在编译期解析并校验 printf 格式串 / Parse and validate a printf format at compile time
static consteval bool Matches()
判断 Args... 是否与启用的转换项精确匹配 / Return whether Args... exactly match the enabled conversions
static consteval bool Matches()
判断 Args... 是否就是当前编译格式期望的那组 C++ 参数类型。 / Returns whether Args... are exactly the C++ argument types thi...
static constexpr auto codes
返回运行期 writer 最终会执行的字节流。 / Returns the final byte stream that the runtime writer will execute.
static constexpr FormatProfile Profile()
返回当前编译格式携带的 writer 分支摘要。 / Returns the writer-branch summary carried by this compiled format.
static constexpr auto ArgumentOrder()
返回每个字段对应的是第几个源参数。 / Returns, for each field, which source argument index it refers to.
static constexpr FormatProfile profile
返回当前格式需要哪些 writer 分支的编译期摘要。 / Returns the compile-time summary of which writer branches this format n...
static constexpr auto SourceArgumentList()
返回仅供编译期类型匹配使用的源参数列表。 / Returns the source-argument list used only for compile-time type matching.
static constexpr auto ArgumentList()
返回运行期参数打包时要按字段顺序读取的参数列表。 / Returns the field-ordered argument list the runtime packer will follow.
static constexpr const auto & Codes()
返回与 codes 相同的最终字节流。 / Returns the same final byte stream as codes.
作为 printf 格式源的结构化字符串字面量包装 / Structural literal wrapper used as the NTTP source for printf formats
char data[N]
含结尾零字节的字面量字节序列 / Literal bytes including the terminating zero byte
constexpr Text(const char(&text)[N])
将字符串字面量复制到结构化 NTTP 对象中 / Copy the string literal into the structural NTTP object
constexpr const char * Data() const
返回含结尾零字节的字面量指针 / Return the literal bytes including the terminating zero byte
constexpr size_t Size() const
返回不含结尾零字节的格式串长度 / Return the format length without the terminating zero byte