7#include "format_argument.hpp"
25 constexpr Text(
const char (&text)[N])
27 for (
size_t i = 0; i < N; ++i)
34 [[nodiscard]]
constexpr size_t Size()
const {
return N - 1; }
36 [[nodiscard]]
constexpr const char*
Data()
const {
return data; }
84 template <Text Source>
87 template <Text Source>
94 template <Text Source>
104 template <
Text Source,
typename... Args>
112#include "printf_frontend_detail.hpp"
113namespace LibXR::Print
115template <Text Source>
120 inline static constexpr auto source_analysis = Detail::PrintfCompile::Analyze<Source>();
124 "LibXR::Print::Printf: numeric field is too large");
126 "LibXR::Print::Printf: unexpected end of format string");
128 "LibXR::Print::Printf: embedded NUL bytes are not supported in the format literal");
130 "LibXR::Print::Printf: positional and sequential arguments cannot be mixed");
132 "LibXR::Print::Printf: positional argument indexing is disabled in the current profile");
134 "LibXR::Print::Printf: dynamic width and precision are not supported");
136 "LibXR::Print::Printf: invalid positional argument index");
138 "LibXR::Print::Printf: invalid format specifier");
140 "LibXR::Print::Printf: invalid length modifier");
142 "LibXR::Print::Printf: one positional argument is reused with incompatible conversions");
144 "LibXR::Print::Printf: text pool offset is too large");
146 "LibXR::Print::Printf: text span is too large");
148 "LibXR::Print::Printf: one positional argument is reused with incompatible conversions");
152 inline static constexpr auto codes = result.codes;
154 inline static constexpr FormatProfile
profile = result.profile;
159 return result.arg_info;
165 return source_analysis.order;
171 return source_analysis.args;
175 [[nodiscard]]
static constexpr const auto&
Codes()
181 [[nodiscard]]
static constexpr FormatProfile
Profile()
187 template <
typename... Args>
Compile-time printf frontend that parses and lowers one source string.
Printf-style frontend that emits the internal format representation.
Length
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
Compile-time parse/build failure categories surfaced through static_assert.
@ TextOffsetOverflow
referenced text offset no longer fits in uint16_t / 文本池偏移超出 uint16_t
@ UnexpectedEnd
format string ended in the middle of one conversion / 格式串在转换项中途结束
@ TextSizeOverflow
referenced text size no longer fits in uint16_t / 文本长度超出 uint16_t
@ InvalidArgumentIndex
positional argument index is invalid / 位置参数索引非法
@ NumberOverflow
width / precision literal does not fit in its field / 宽度或精度字面量超出字段范围
@ MixedIndexing
positional and sequential arguments were mixed / 混用了位置参数与顺序参数
@ InvalidLength
length modifier is incompatible with the conversion / 长度修饰符与转换说明不兼容
@ EmbeddedNul
format literal contains an embedded NUL byte / 格式串字面量内部包含嵌入式 NUL 字节
@ InvalidSpecifier
unsupported or disabled conversion specifier / 转换说明符无效或被禁用
@ PositionalArgumentDisabled
positional n$ indexing is disabled by configuration / 位置参数 n$ 索引已被配置关闭
@ ConflictingArgument
one positional argument was reused with incompatible rules / 同一位置参数被不兼容的规则重复使用
static consteval Compiled< Source > Build()
Parses and validates a printf format at compile time.
static consteval bool Matches()
Returns true when Args... exactly match the enabled conversions.
static consteval bool Matches()
Returns true when Args... exactly match this compiled format. / 判断 Args... 是否与当前编译格式完全匹配
static constexpr auto codes
Final runtime byte block kept by the compiled surface. / 编译格式表面保留的最终运行期字节块
static constexpr FormatProfile Profile()
Returns the compile-time executor profile. / 返回编译期执行器配置
static constexpr auto ArgumentOrder()
Field-ordered source argument references, including duplicates and reordering. / 按字段顺序排列的源参数引用,可包含重复与...
static constexpr FormatProfile profile
Compile-time executor profile used to specialize the runtime bytecode interpreter....
static constexpr auto SourceArgumentList()
Source-ordered argument metadata used only by compile-time type matching. / 按源参数顺序排列、仅供编译期类型匹配使用的元信息
static constexpr auto ArgumentList()
Field-ordered argument metadata used by runtime argument packing. / 按字段顺序排列、供运行期参数打包使用的元信息表
static constexpr const auto & Codes()
Final compiled bytes consumed directly by the runtime writer. / 供运行期 writer 直接消费的最终编译字节块
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])
Copies the string literal into the structural NTTP object.
constexpr const char * Data() const
Returns the literal bytes including the terminating zero byte. / 返回含结尾零字节的字面量指针
constexpr size_t Size() const
Returns the format length without the terminating zero byte. / 返回不含结尾零字节的格式串长度