|
libxr
1.0
Want to be the best embedded framework
|
运行期 writer,负责打包调用点参数并执行编译好的字节流 / Runtime writer that packs call-site arguments and executes the compiled byte stream More...
#include <writer.hpp>
Data Structures | |
| class | ArgumentReader |
| 运行期参数字节块的顺序读取器 / Sequential reader for the packed runtime argument byte blob More... | |
| class | CodeReader |
| 编译后记录流的顺序读取器 / Sequential reader for the compiled record stream More... | |
| class | Executor |
| 按输出端共享重后端、按调用点 profile 裁剪操作码分发的字节码执行器 / Per-sink bytecode executor with shared heavy backends and per-call profile-pruned opcode dispatch More... | |
| struct | Spec |
| 运行期对单个字段描述字节组的解码视图 / Runtime view of one decoded field specification byte group More... | |
Static Public Member Functions | |
| template<typename Sink , typename Format , auto ArgumentOrder, typename... Args> requires OutputSink<Sink> && CompiledFormat<std::remove_cvref_t<Format>> | |
| static ErrorCode | RunArgumentOrder (Sink &sink, const Format &, Args &&... args) |
| 执行一份编译格式;它的字段顺序与源参数顺序可以不同 / Run one compiled format whose field order and source argument order may differ | |
Static Private Member Functions | |
| static constexpr bool | HasFlag (uint8_t flags, uint8_t bit) |
| 判断某个已解码字段修饰位是否被设置 / Test whether one decoded field-spec bit is set | |
| template<size_t N> | |
| static constexpr size_t | BoundedTextLength (const char(&text)[N]) noexcept |
| 返回一个 char 数组参数在边界内的 C 字符串长度 / Return the bounded C-string length stored inside one char array argument | |
| template<typename T > | |
| static constexpr std::string_view | ToStringView (const T &text) |
将一个字符串类运行期参数归一化为 std::string_view / Normalize one string-like runtime argument into std::string_view | |
| template<FormatPackKind pack, typename T > | |
| static constexpr auto | PackValue (T &&value) |
| 将一个运行期实参转换为某个编译参数槽要求的打包存储形态 / Convert one runtime argument into the packed storage shape required by one compiled argument slot | |
| template<typename T > | |
| static void | StoreArgument (uint8_t *&out, const T &value) |
| 把一个已打包值复制进参数字节块,并推进写指针 / Copy one packed value into the argument byte blob and advance the cursor | |
| template<auto ArgumentInfoList> | |
| static consteval size_t | PackedArgumentBytes () |
| 返回一组编译参数元信息在运行期需要的打包字节数 / Return the runtime packed-byte size required by one compiled argument metadata list | |
| template<auto ArgumentInfoList, auto ArgumentOrder, typename Tuple > | |
| static void | StoreArgumentsOrdered (uint8_t *&out, Tuple &tuple) |
| 按字段执行顺序把运行期参数打包成最终字节块 / Pack runtime arguments into the final byte blob in field execution order | |
| template<std::unsigned_integral UInt, uint8_t Base> | |
| static consteval size_t | UnsignedDigitCapacity () |
| 返回某个无符号整数在指定进制下所需的最大数字个数 / Return the maximum digit count required for one unsigned integer under the selected radix | |
| template<uint8_t Base, bool UpperCase = false, size_t N, std::unsigned_integral UInt> | |
| static size_t | AppendUnsigned (char(&out)[N], UInt value) |
| 把一个无符号整数写进调用方提供的定长数字缓冲区 / Append one unsigned integer into a caller-provided fixed-size digit buffer | |
| template<size_t N> | |
| static size_t | AppendSmallUnsigned (char(&out)[N], uint8_t value) |
| 以十进制形式追加一个较小的无符号整数 / Append one small unsigned integer in base 10 | |
| static constexpr size_t | FieldPadding (uint8_t width, size_t payload_size) |
| 返回把某段载荷扩展到目标字段宽度所需的填充长度 / Return the padding width needed to expand one payload to the requested field width | |
| static constexpr size_t | IntegerPrecisionZeros (const Spec &spec, size_t digit_count) |
| 返回整数精度引入的额外前导零个数 / Return the extra leading-zero count introduced by integer precision | |
| template<std::unsigned_integral UInt> | |
| static constexpr std::string_view | IntegerPrefix (FormatType type, const Spec &spec, UInt value) |
| 返回放在数字载荷之外的备用格式前缀 / Return the alternate-form prefix carried outside the digit payload | |
| template<std::unsigned_integral UInt> | |
| static size_t | ApplyAlternateOctal (char *digits, size_t digit_count, const Spec &spec, UInt value) |
直接在已生成的数字载荷上应用 %#o 的特殊规则 / Apply %#o special rules directly onto the generated digit payload | |
| static constexpr bool | UsesFloatTextBackend (FormatType type) |
| 判断这个字段类型是否走共享的浮点文本输出路径 / Return whether this field type is printed by the shared float-text path | |
| static constexpr bool | FloatEnabled (FormatType type) |
| 判断这个浮点字段类型是否被当前功能开关启用 / Return whether this float field type is enabled by current feature switches | |
| static constexpr uint8_t | DefaultFloatPrecision () |
| 返回格式串没有显式写精度时使用的默认浮点精度 / Return the default float precision used when the format string did not specify one | |
| template<typename Float > | |
| static bool | ExceedsFixedIntegerDigits (Float value, uint8_t precision) |
| 判断定点形态的浮点输出是否会超出当前配置的整数位数上限 / Return whether fixed-shape float output would exceed the configured integer-digit limit | |
| static bool | AppendBufferChar (char *buffer, size_t capacity, size_t &size, char ch) |
| 向有界本地格式化缓冲区追加一个字符 / Append one character to a bounded local formatting buffer | |
| static bool | AppendBufferText (char *buffer, size_t capacity, size_t &size, std::string_view text) |
| 向有界本地格式化缓冲区追加一段文本 / Append one text span to a bounded local formatting buffer | |
| static bool | AppendBufferU32ZeroPad (char *buffer, size_t capacity, size_t &size, uint32_t value, uint8_t width) |
追加一个 uint32_t 十进制值,并在前面补零到目标宽度 / Append one uint32_t decimal value and pad leading zeros up to the target width | |
| template<OutputSink Sink, FormatProfile Profile> | |
| static LIBXR_NOINLINE ErrorCode | Execute (Sink &sink, const uint8_t *codes, const uint8_t *args) |
| 使用一份已打包参数字节块执行一段编译字节流 / Execute one compiled byte stream against one already packed argument blob | |
| template<OutputSink Sink, auto ArgumentInfoList, auto ArgumentOrder, FormatProfile Profile, typename... Args> | |
| static LIBXR_NOINLINE ErrorCode | RunTaggedArgumentOrder (Sink &sink, const uint8_t *codes, Args &&... args) |
| 先打包转发后的运行期参数,再执行编译字节流 / Pack forwarded runtime arguments, then execute the compiled byte stream | |
Static Private Attributes | |
| static constexpr uint8_t | unspecified_precision = 0xFF |
| 为某个已编译参数列表生成栈上参数字节块 / Emit the stack argument byte blob for one compiled argument list | |
| template<FormatPackKind K> | |
| static constexpr bool | dependent_false_v = false |
| static constexpr size_t | float_buffer_capacity |
运行期 writer,负责打包调用点参数并执行编译好的字节流 / Runtime writer that packs call-site arguments and executes the compiled byte stream
Definition at line 120 of file writer.hpp.
|
staticnodiscardprivate |
向有界本地格式化缓冲区追加一个字符 / Append one character to a bounded local formatting buffer
| buffer | 目标缓冲区 / Destination buffer |
| capacity | 缓冲区总容量 / Total buffer capacity |
| size | 当前已保留长度;成功时会推进 / Current retained size; advanced on success |
| ch | 待追加字符 / Character to append |
true,否则返回 false / Returns true on success, otherwise false Definition at line 40 of file writer_runtime.cpp.
|
staticnodiscardprivate |
向有界本地格式化缓冲区追加一段文本 / Append one text span to a bounded local formatting buffer
| buffer | 目标缓冲区 / Destination buffer |
| capacity | 缓冲区总容量 / Total buffer capacity |
| size | 当前已保留长度;成功时会推进 / Current retained size; advanced on success |
| text | 待追加文本片段 / Text span to append |
true,否则返回 false / Returns true on success, otherwise false Definition at line 50 of file writer_runtime.cpp.
|
staticnodiscardprivate |
追加一个 uint32_t 十进制值,并在前面补零到目标宽度 / Append one uint32_t decimal value and pad leading zeros up to the target width
| buffer | 目标缓冲区 / Destination buffer |
| capacity | 缓冲区总容量 / Total buffer capacity |
| size | 当前已保留长度;成功时会推进 / Current retained size; advanced on success |
| value | 待追加的无符号值 / Unsigned value to append |
| width | 目标零填充宽度 / Target zero-padded width |
true,否则返回 false / Returns true on success, otherwise false Definition at line 62 of file writer_runtime.cpp.
|
inlinestaticnodiscardprivate |
以十进制形式追加一个较小的无符号整数 / Append one small unsigned integer in base 10
追加一个较小的十进制无符号整数 / Append one small decimal unsigned integer
| out | 目标数字缓冲区 / Destination digit buffer |
| value | 待编码的无符号值 / Unsigned value to encode |
Definition at line 77 of file writer.hpp.
|
staticnodiscardprivate |
把一个无符号整数写进调用方提供的定长数字缓冲区 / Append one unsigned integer into a caller-provided fixed-size digit buffer
将一个无符号整数写入调用方提供的定长数字缓冲区 / Append one unsigned integer into a caller-provided fixed-size digit buffer
| Base | 整数进制 / Integer radix |
| UpperCase | 十六进制数字是否使用大写字母 / Whether hexadecimal digits should use uppercase letters |
| N | 目标缓冲区长度 / Destination buffer size |
| UInt | 无符号整数类型 / Unsigned integer type |
| out | 目标数字缓冲区 / Destination digit buffer |
| value | 待编码的无符号值 / Unsigned value to encode |
Definition at line 38 of file writer.hpp.
|
staticnodiscardprivate |
直接在已生成的数字载荷上应用 %#o 的特殊规则 / Apply %#o special rules directly onto the generated digit payload
直接在已生成数字上应用 %#o 的特殊规则 / Apply the special %#o payload rules directly onto the generated digits
Octal alternate form differs from hex: it is represented by a leading zero in the digit payload itself, not by a detached prefix string. This helper also preserves the required single 0 when %#.0o formats zero. 八进制备用格式与十六进制不同:它通过数字载荷本体前导一个 0 来表示, 而不是额外分离出的前缀字符串。本函数也负责在 %#.0o 格式化零值时保留 必需的单个 0。
| UInt | 无符号整数类型 / Unsigned integer type |
| digits | 可修改的数字缓冲区 / Mutable digit buffer |
| digit_count | 当前数字个数 / Current digit count |
| spec | 解码后的字段规格 / Decoded field spec |
| value | 当前要输出的无符号值 / Unsigned value being emitted |
| UInt | 无符号整数类型 / Unsigned integer type |
| digits | 可修改的数字缓冲区 / Mutable digit buffer |
| digit_count | 当前数字个数 / Current digit count |
| spec | 解码后的字段规格 / Decoded field spec |
| value | 当前要输出的无符号值 / Unsigned value being emitted |
Definition at line 151 of file writer.hpp.
|
staticnodiscardconstexprprivatenoexcept |
返回一个 char 数组参数在边界内的 C 字符串长度 / Return the bounded C-string length stored inside one char array argument
Writer 的运行期参数归一化与打包辅助函数 / Runtime argument normalization and packing helpers for Writer.
| N | 数组长度 / Array extent |
| text | char 数组参数 / Char array argument |
返回一个 char 数组参数在边界内的 C 字符串长度 / Return the bounded C-string length inside one char array argument
| N | 数组长度 / Array extent |
| text | char 数组参数 / Char array argument |
ASSERT 会触发 / This path requires a terminating NUL inside the array bound; otherwise the internal ASSERT fires Definition at line 20 of file writer.hpp.
|
staticnodiscardconstexprprivate |
返回格式串没有显式写精度时使用的默认浮点精度 / Return the default float precision used when the format string did not specify one
|
staticnodiscardprivate |
判断定点形态的浮点输出是否会超出当前配置的整数位数上限 / Return whether fixed-shape float output would exceed the configured integer-digit limit
| Float | 浮点类型 / Float type |
| value | 待检查的浮点绝对值 / Float magnitude to test |
| precision | 请求的小数精度 / Requested fractional precision |
true,否则返回 false / Returns true when the fixed-form integer part would exceed the configured limit, otherwise false
|
inlinestaticnodiscardprivate |
使用一份已打包参数字节块执行一段编译字节流 / Execute one compiled byte stream against one already packed argument blob
| Sink | 输出端类型,需满足 OutputSink / Sink type satisfying OutputSink |
| Profile | 编译期 writer 摘要 / Compile-time writer profile |
| sink | 输出端 / Destination sink |
| codes | 指向编译字节流的指针 / Pointer to the compiled byte stream |
| args | 指向已打包参数字节块的指针;无参数时可为空 / Pointer to the packed argument blob, or null when no arguments exist |
Definition at line 678 of file writer.hpp.
|
staticnodiscardconstexprprivate |
返回把某段载荷扩展到目标字段宽度所需的填充长度 / Return the padding width needed to expand one payload to the requested field width
返回某个载荷尺寸对应的字段宽度填充量 / Return the field-width padding needed for one payload size
| width | 请求的字段宽度 / Requested field width |
| payload_size | 填充前的可见载荷长度 / Visible payload size before padding |
Definition at line 89 of file writer.hpp.
|
staticnodiscardconstexprprivate |
判断这个浮点字段类型是否被当前功能开关启用 / Return whether this float field type is enabled by current feature switches
| type | 运行期浮点字段类型 / Runtime float field type |
true,否则返回 false / Returns true when this float field type is enabled, otherwise false
|
inlinestaticnodiscardconstexprprivate |
判断某个已解码字段修饰位是否被设置 / Test whether one decoded field-spec bit is set
Definition at line 178 of file writer.hpp.
|
staticnodiscardconstexprprivate |
返回整数精度引入的额外前导零个数 / Return the extra leading-zero count introduced by integer precision
返回整数精度要求引入的额外前导零个数 / Return the extra leading zeros introduced by integer precision
| spec | 解码后的字段规格 / Decoded field spec |
| digit_count | 当前已有的数字个数 / Existing digit count |
Definition at line 101 of file writer.hpp.
|
staticnodiscardconstexprprivate |
返回放在数字载荷之外的备用格式前缀 / Return the alternate-form prefix carried outside the digit payload
返回备用格式下脱离数字主体输出的整数前缀 / Return the detached integer prefix emitted by alternate formatting
| UInt | 无符号整数类型 / Unsigned integer type |
| type | 运行期字段类型 / Runtime field type |
| spec | 解码后的字段规格 / Decoded field spec |
| value | 当前要输出的无符号值 / Unsigned value being emitted |
| UInt | 无符号整数类型 / Unsigned integer type |
| type | 运行期字段类型 / Runtime field type |
| spec | 解码后的字段规格 / Decoded field spec |
| value | 当前要输出的无符号值 / Unsigned value being emitted |
Definition at line 118 of file writer.hpp.
|
staticnodiscardconstevalprivate |
返回一组编译参数元信息在运行期需要的打包字节数 / Return the runtime packed-byte size required by one compiled argument metadata list
返回一个编译期参数列表所需的参数打包字节数 / Return the packed-byte size required by one compiled argument list
| ArgumentInfoList | 编译期参数元信息列表 / Compile-time argument metadata list |
| ArgumentInfoList | 编译期参数元信息列表 / Compile-time argument metadata list |
Definition at line 211 of file writer.hpp.
|
staticnodiscardconstexprprivate |
将一个运行期实参转换为某个编译参数槽要求的打包存储形态 / Convert one runtime argument into the packed storage shape required by one compiled argument slot
将一个已匹配的 C++ 实参归一化为某个编译参数槽要求的运行期打包存储类型 / Normalize one matched C++ argument into the packed runtime storage kind required by one compiled argument slot
| pack | 目标打包存储类型 / Target packed storage kind |
| T | 运行期实参类型 / Runtime argument type |
| value | 运行期实参值 / Runtime argument value |
| pack | 目标打包存储类型 / Target packed storage kind |
| T | 运行期实参类型 / Runtime argument type |
| value | 运行期实参值 / Runtime argument value |
Definition at line 88 of file writer.hpp.
|
inlinestaticnodiscard |
执行一份编译格式;它的字段顺序与源参数顺序可以不同 / Run one compiled format whose field order and source argument order may differ
| Sink | 输出端类型,需满足 OutputSink / Sink type satisfying OutputSink |
| Format | 编译格式类型 / Compiled format type |
| ArgumentOrder | 按字段顺序排列的源参数索引表 / Source-argument index list ordered by emitted fields |
| Args | 调用点实参类型列表 / Call-site argument types |
| sink | 输出端 / Destination sink |
| format | 编译格式对象,仅用于约束与类型推导 / Compiled format object, used only for constraints and type deduction |
| args | 调用点实参 / Call-site arguments |
This path is used by formats such as {1} {0}: fields are still executed in source order, but the runtime argument pack must be built in another order. 这条路径用于 {1} {0} 这种格式:字段仍然按源串顺序执行, 但运行期参数包要按另一种顺序构造。
Definition at line 147 of file writer.hpp.
|
inlinestaticnodiscardprivate |
先打包转发后的运行期参数,再执行编译字节流 / Pack forwarded runtime arguments, then execute the compiled byte stream
| Sink | 输出端类型,需满足 OutputSink / Sink type satisfying OutputSink |
| ArgumentInfoList | 编译期参数元信息列表 / Compile-time argument metadata list |
| ArgumentOrder | 按字段顺序排列的源参数索引表 / Source-argument index list ordered by emitted fields |
| Profile | 编译期 writer 摘要 / Compile-time writer profile |
| Args | 转发后的运行期实参类型列表 / Forwarded runtime argument types |
| sink | 输出端 / Destination sink |
| codes | 指向编译字节流的指针 / Pointer to the compiled byte stream |
| args | 转发后的运行期实参 / Forwarded runtime arguments |
Definition at line 701 of file writer.hpp.
|
staticprivate |
把一个已打包值复制进参数字节块,并推进写指针 / Copy one packed value into the argument byte blob and advance the cursor
把一个已打包参数值复制进字节块,并推进写指针 / Copy one packed argument value into the byte blob and advance the cursor
| T | 已打包值类型 / Packed value type |
| out | 当前写指针 / Current write cursor |
| value | 待写入的已打包值 / Packed value to store |
| T | 已打包值类型 / Packed value type |
| out | 当前写指针;会前进 sizeof(T) / Current write cursor; advanced by sizeof(T) |
| value | 待写入的已打包值 / Packed value to store |
Definition at line 197 of file writer.hpp.
|
staticprivate |
按字段执行顺序把运行期参数打包成最终字节块 / Pack runtime arguments into the final byte blob in field execution order
| ArgumentInfoList | 编译期参数元信息列表 / Compile-time argument metadata list |
| ArgumentOrder | 按字段顺序排列的源参数索引表 / Source-argument index list ordered by emitted fields |
| Tuple | 保存转发后运行期实参的 tuple 类型 / Tuple type holding forwarded runtime arguments |
| out | 当前写指针 / Current write cursor |
| tuple | 转发后的运行期实参集合 / Forwarded runtime arguments |
| ArgumentInfoList | 编译期参数元信息列表 / Compile-time argument metadata list |
| ArgumentOrder | 每个输出字段对应的源参数索引表 / Source-argument index per emitted field |
| Tuple | 持有转发后运行期实参的 tuple 类型 / Tuple type holding forwarded runtime arguments |
| out | 当前写指针;会随着写入推进 / Current write cursor; advanced as values are stored |
| tuple | 转发后的运行期实参集合 / Forwarded runtime arguments |
Definition at line 234 of file writer.hpp.
|
staticnodiscardconstexprprivate |
将一个字符串类运行期参数归一化为 std::string_view / Normalize one string-like runtime argument into std::string_view
| T | 运行期实参类型 / Runtime argument type |
| text | 运行期实参值 / Runtime argument value |
| T | 运行期实参类型 / Runtime argument type |
| text | 运行期实参值 / Runtime argument value |
"(null)" / Null C-string pointers are normalized to the literal "(null)" Definition at line 46 of file writer.hpp.
|
staticnodiscardconstevalprivate |
返回某个无符号整数在指定进制下所需的最大数字个数 / Return the maximum digit count required for one unsigned integer under the selected radix
运行期 writer 后端共享的整数文本辅助函数 / Shared integer-text helpers for the runtime writer backend
This helper intentionally uses a short exact integer division loop instead of a floating-point approximation. It is consteval, so it can only be used in immediate compile-time contexts such as array extents and static_assert, and therefore adds no runtime cost. 本辅助函数有意使用一个简短且精确的整数除法循环,而不是浮点近似公式。 它被声明为 consteval,只能用于数组长度、static_assert 等立即编译期 场景,因此不会引入任何运行期开销。
| UInt | 无符号整数类型 / Unsigned integer type |
| Base | 整数进制 / Integer radix |
Definition at line 10 of file writer.hpp.
|
staticnodiscardconstexprprivate |
判断这个字段类型是否走共享的浮点文本输出路径 / Return whether this field type is printed by the shared float-text path
| type | 运行期字段类型 / Runtime field type |
true,否则返回 false / Returns true when this type uses the shared float-text backend, otherwise false
|
staticconstexprprivate |
Definition at line 170 of file writer.hpp.
|
staticconstexprprivate |
Definition at line 171 of file writer.hpp.
|
staticconstexprprivate |
为某个已编译参数列表生成栈上参数字节块 / Emit the stack argument byte blob for one compiled argument list
Definition at line 168 of file writer.hpp.