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; }
111 template <Text Source>
114 template <Text Source>
123 template <Text Source>
137 template <
Text Source,
typename... Args>
145#include "printf/printf_frontend_detail.hpp"
146namespace LibXR::Print
148template <Text Source>
153 inline static constexpr auto source_analysis = Detail::PrintfCompile::Analyze<Source>();
157 "LibXR::Print::Printf: numeric field is too large");
160 "LibXR::Print::Printf: float precision exceeds the configured print limit");
162 "LibXR::Print::Printf: unexpected end of format string");
165 "LibXR::Print::Printf: embedded NUL bytes are not supported in the format literal");
168 "LibXR::Print::Printf: positional and sequential arguments cannot be mixed");
170 "LibXR::Print::Printf: positional argument indexing is disabled in the "
173 "LibXR::Print::Printf: dynamic width and precision are not supported");
175 "LibXR::Print::Printf: invalid positional argument index");
177 "LibXR::Print::Printf: invalid format specifier");
179 "LibXR::Print::Printf: invalid length modifier");
181 "LibXR::Print::Printf: one positional argument is reused with "
182 "incompatible conversions");
184 "LibXR::Print::Printf: text pool offset is too large");
186 "LibXR::Print::Printf: text span is too large");
188 "LibXR::Print::Printf: one positional argument is reused with "
189 "incompatible conversions");
196 inline static constexpr auto codes = result.codes;
201 inline static constexpr FormatProfile
profile = result.profile;
207 [[nodiscard]]
static constexpr auto ArgumentList() {
return result.arg_info; }
213 [[nodiscard]]
static constexpr auto ArgumentOrder() {
return source_analysis.order; }
221 return source_analysis.args;
228 [[nodiscard]]
static constexpr const auto&
Codes() {
return codes; }
243 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
long long 长度修饰 / ll
@ IntMax
intmax_t 长度修饰 / j
@ PtrDiff
ptrdiff_t 长度修饰 / t
@ LongDouble
long double 长度修饰 / L
@ Default
无长度修饰符 / no length modifier
Error
通过 static_assert 暴露的编译期解析或构建失败类别 / Compile-time parse or build failure categories surfaced through st...
@ InvalidArgumentIndex
位置参数索引非法 / positional argument index is invalid
@ FloatPrecisionLimitExceeded
@ DynamicField
不支持 * 宽度或精度 / * width / precision is not supported
@ 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 this...
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 ne...
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