libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
Writer::Executor< Sink, Profile > Class Template Reference

按编译格式 profile 特化的、按输出端类型区分的字节码执行器 / Per-sink bytecode executor specialized by the compiled format profile More...

#include <writer_executor.hpp>

Collaboration diagram for Writer::Executor< Sink, Profile >:
[legend]

Public Member Functions

 Executor (Sink &sink, const uint8_t *codes, const uint8_t *args)
 将一个输出端、一份编译字节块和一份参数字节块绑定起来 / Bind one sink with one compiled byte blob and one packed argument blob
 
ErrorCode Run ()
 持续执行记录流,直到遇到 FormatOp::End / Run until the compiled record stream reaches FormatOp::End
 

Private Member Functions

ErrorCode WriteRaw (std::string_view text)
 运行期执行器共享的字段写出原语,供所有操作码路径复用 / Executor-side field-writing primitives shared by all runtime opcodes
 
ErrorCode WritePadding (char fill, size_t count)
 向输出端写入重复填充字符 / Write repeated fill characters into the sink
 
ErrorCode WriteTextField (std::string_view text, const Spec &spec)
 按宽度与对齐策略写出一个文本字段 / Write one text field with width/alignment policy applied
 
ErrorCode WriteIntegerField (char sign_char, std::string_view prefix, std::string_view digits, const Spec &spec)
 按符号、前缀、精度与填充策略写出一个整数载荷 / Write one integer payload with sign, prefix, precision, and padding policy applied
 
ErrorCode WriteFloatField (char sign_char, std::string_view text, const Spec &spec)
 按符号与字段填充策略写出一个浮点文本载荷 / Write one float text payload with sign and field padding applied
 
template<std::signed_integral Int>
ErrorCode WriteSigned (const Spec &spec, Int value)
 通过共享整数字段路径写出一个有符号整数值 / Write one signed integer value through the shared integer-field path
 
template<FormatType Type, std::unsigned_integral UInt>
ErrorCode WriteUnsigned (const Spec &spec, UInt value)
 通过共享整数字段路径写出一个无符号整数语义值 / Write one unsigned integer semantic value through the shared integer-field path
 
template<uint8_t Base, bool UpperCase = false, bool InlineAlternateOctal = false, std::unsigned_integral UInt>
ErrorCode WriteUnsignedDigits (std::string_view prefix, const Spec &spec, UInt value)
 按编译期进制/大小写/八进制备用格式参数复用无符号数字载荷写出逻辑 / Reuse the unsigned-digit payload writer with compile-time radix, case, and octal-alternate parameters
 
ErrorCode WritePointer (const Spec &spec, uintptr_t value)
 按规范指针字段策略写出一个指针值 / Write one pointer value using the canonical pointer field policy
 
ErrorCode WriteCharacter (const Spec &spec, char ch)
 写出一个字符字段值 / Write one character field value
 
ErrorCode WriteString (const Spec &spec, std::string_view text)
 写出一个字符串字段值,并在需要时应用精度截断 / Write one string field value, including precision truncation when present
 
template<typename T >
ErrorCode WriteFloat (FormatType type, const Spec &spec, T value)
 通过共享浮点文本后端写出一个浮点语义值 / Write one float semantic value through the shared float-text backend
 
ErrorCode WriteU32Dec (uint32_t value)
 单个原始 uint32_t 十进制字段的快路径。 / Fast path for one raw uint32_t decimal field.
 
ErrorCode WriteU32ZeroPadWidth (uint8_t width, uint32_t value)
 单个零填充 uint32_t 十进制字段的快路径。 / Fast path for one zero-padded uint32_t decimal field.
 
ErrorCode WriteStringRaw (std::string_view text)
 单个原始字符串参数的快路径。 / Fast path for one raw string argument.
 
ErrorCode WriteF32FixedPrec (uint8_t precision, float value)
 单个带显式精度的定点 float 快路径。 / Fast path for one fixed float with explicit precision.
 
ErrorCode WriteF64FixedPrec (uint8_t precision, double value)
 单个带显式精度的定点 double 快路径。 / Fast path for one fixed double with explicit precision.
 
template<std::signed_integral Int>
ErrorCode DispatchSignedField ()
 运行期执行器中 GenericField 的分发桥接函数 / GenericField dispatch bridges for the runtime executor
 
template<FormatType Type, std::unsigned_integral UInt>
ErrorCode DispatchUnsignedField ()
 读取一个无符号载荷并转发给选定的整数语义写出路径 / Read one unsigned payload and forward it to the selected integer semantic writer
 
template<FormatType Type, typename Float >
ErrorCode DispatchFloatField ()
 读取一个浮点载荷并转发给选定的浮点语义写出路径 / Read one float payload and forward it to the selected float semantic writer
 
ErrorCode DispatchPointerField ()
 读取一个指针载荷并走指针字段写出路径 / Read one pointer payload and write it through the pointer field path
 
ErrorCode DispatchCharacterField ()
 读取一个字符载荷并走字符字段写出路径 / Read one character payload and write it through the character field path
 
ErrorCode DispatchStringField ()
 读取一个字符串载荷并走字符串字段写出路径 / Read one string payload and write it through the string field path
 
ErrorCode DispatchGenericField (FormatType type)
 将一个 GenericField 载荷分发到对应的宽回退路径 / Dispatch one GenericField payload to the corresponding wide fallback
 
ErrorCode DispatchOp (FormatOp op)
 将一个运行期操作码分发到选中的特化路径 / Dispatch one runtime opcode to the selected specialized path
 

Static Private Member Functions

template<std::signed_integral Int>
static char ResolveSignChar (Int value, const Spec &spec)
 执行器的具体运行期数值写出函数 / Concrete runtime value writers for the executor
 
template<typename T >
static char ResolveFloatSignChar (T value, const Spec &spec)
 为一个浮点载荷确定最终可见的符号字符 / Resolve the visible sign character for one float payload
 

Private Attributes

Sink & sink_
 
CodeReader codes_
 
ArgumentReader args_
 

Detailed Description

template<OutputSink Sink, FormatProfile Profile>
class Writer::Executor< Sink, Profile >

按编译格式 profile 特化的、按输出端类型区分的字节码执行器 / Per-sink bytecode executor specialized by the compiled format profile

Definition at line 7 of file writer_executor.hpp.

Constructor & Destructor Documentation

◆ Executor()

template<OutputSink Sink, FormatProfile Profile>
Writer::Executor< Sink, Profile >::Executor ( Sink & sink,
const uint8_t * codes,
const uint8_t * args )

将一个输出端、一份编译字节块和一份参数字节块绑定起来 / Bind one sink with one compiled byte blob and one packed argument blob

writer 执行器的顶层运行期操作码循环。 / Top-level runtime opcode loop for the writer executor.

Parameters
sink输出端 / Destination sink
codes指向编译字节块的指针 / Pointer to the compiled byte blob
args指向运行期参数打包字节块的指针;无参数时可为空 / Pointer to the packed runtime argument blob, or null when no arguments exist

将一个输出端、码流和参数字节块绑定到当前执行器 / Bind one sink, code stream, and packed-argument blob to this executor

Parameters
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 14 of file writer_executor_opcode.hpp.

16 : sink_(sink),
17 codes_(codes),
18 args_(args)
19{
20}

Member Function Documentation

◆ DispatchCharacterField()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::DispatchCharacterField ( )
nodiscardprivate

读取一个字符载荷并走字符字段写出路径 / Read one character payload and write it through the character field path

Returns
返回字符字段写出结果 / Returns the character-field write result

Definition at line 60 of file writer_executor_generic.hpp.

61{
62 return WriteCharacter(codes_.ReadSpec(), args_.Read<char>());
63}
T Read()
以无对齐要求的方式读取一个已打包参数值 / Read one packed argument value without requiring alignment
Spec ReadSpec()
读取紧跟在 GenericField 类型字节后的 4 字节字段载荷 / Read the 4-byte field payload that follows one GenericField type...
ErrorCode WriteCharacter(const Spec &spec, char ch)
写出一个字符字段值 / Write one character field value

◆ DispatchFloatField()

template<OutputSink Sink, FormatProfile Profile>
template<FormatType Type, typename Float >
ErrorCode Writer::Executor< Sink, Profile >::DispatchFloatField ( )
nodiscardprivate

读取一个浮点载荷并转发给选定的浮点语义写出路径 / Read one float payload and forward it to the selected float semantic writer

Template Parameters
Type运行期浮点语义类型 / Runtime float semantic type
Float打包浮点存储类型 / Packed float storage type
Returns
返回选定浮点语义路径的写出结果 / Returns the selected float-field write result

Definition at line 40 of file writer_executor_generic.hpp.

41{
42 return WriteFloat(Type, codes_.ReadSpec(), args_.Read<Float>());
43}
ErrorCode WriteFloat(FormatType type, const Spec &spec, T value)
通过共享浮点文本后端写出一个浮点语义值 / Write one float semantic value through the shared float-text backend

◆ DispatchGenericField()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::DispatchGenericField ( FormatType type)
nodiscardprivate

将一个 GenericField 载荷分发到对应的宽回退路径 / Dispatch one GenericField payload to the corresponding wide fallback

将一个 GenericField 语义类型分发到具体宽回退写出路径 / Dispatch one GenericField semantic type to the concrete wide fallback writer

Parameters
typeGenericField 记录携带的语义字段类型 / Semantic field type carried by the GenericField record
Returns
返回该字段的具体写出结果 / Returns the concrete writer result for that field
Parameters
type当前 GenericField 携带的运行期语义类型 / Runtime semantic type carried by this GenericField
Returns
返回具体宽回退路径的写出结果 / Returns the concrete wide-path write result

Definition at line 81 of file writer_executor_generic.hpp.

82{
83 switch (type)
84 {
85 case FormatType::Signed32:
86 if constexpr (!Config::enable_integer)
87 {
88 return ErrorCode::STATE_ERR;
89 }
91 case FormatType::Signed64:
92 if constexpr (!Config::enable_integer || !Config::enable_integer_64bit)
93 {
94 return ErrorCode::STATE_ERR;
95 }
97 case FormatType::Unsigned32:
98 if constexpr (!Config::enable_integer)
99 {
100 return ErrorCode::STATE_ERR;
101 }
103 case FormatType::Unsigned64:
104 if constexpr (!Config::enable_integer || !Config::enable_integer_64bit)
105 {
106 return ErrorCode::STATE_ERR;
107 }
109 case FormatType::Binary32:
110 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
111 {
112 return ErrorCode::STATE_ERR;
113 }
115 case FormatType::Binary64:
116 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16 ||
117 !Config::enable_integer_64bit)
118 {
119 return ErrorCode::STATE_ERR;
120 }
122 case FormatType::Octal32:
123 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
124 {
125 return ErrorCode::STATE_ERR;
126 }
128 case FormatType::Octal64:
129 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16 ||
130 !Config::enable_integer_64bit)
131 {
132 return ErrorCode::STATE_ERR;
133 }
135 case FormatType::HexLower32:
136 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
137 {
138 return ErrorCode::STATE_ERR;
139 }
141 case FormatType::HexLower64:
142 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16 ||
143 !Config::enable_integer_64bit)
144 {
145 return ErrorCode::STATE_ERR;
146 }
148 case FormatType::HexUpper32:
149 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
150 {
151 return ErrorCode::STATE_ERR;
152 }
154 case FormatType::HexUpper64:
155 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16 ||
156 !Config::enable_integer_64bit)
157 {
158 return ErrorCode::STATE_ERR;
159 }
161 case FormatType::Pointer:
162 if constexpr (!Config::enable_pointer)
163 {
164 return ErrorCode::STATE_ERR;
165 }
166 return DispatchPointerField();
167 case FormatType::Character:
168 if constexpr (!Config::enable_text)
169 {
170 return ErrorCode::STATE_ERR;
171 }
172 return DispatchCharacterField();
173 case FormatType::String:
174 if constexpr (!Config::enable_text)
175 {
176 return ErrorCode::STATE_ERR;
177 }
178 return DispatchStringField();
179 case FormatType::FloatFixed:
180 if constexpr (!FloatEnabled(FormatType::FloatFixed))
181 {
182 return ErrorCode::STATE_ERR;
183 }
185 case FormatType::DoubleFixed:
186 if constexpr (!FloatEnabled(FormatType::DoubleFixed))
187 {
188 return ErrorCode::STATE_ERR;
189 }
191 case FormatType::FloatScientific:
192 if constexpr (!FloatEnabled(FormatType::FloatScientific))
193 {
194 return ErrorCode::STATE_ERR;
195 }
197 case FormatType::DoubleScientific:
198 if constexpr (!FloatEnabled(FormatType::DoubleScientific))
199 {
200 return ErrorCode::STATE_ERR;
201 }
203 case FormatType::FloatGeneral:
204 if constexpr (!FloatEnabled(FormatType::FloatGeneral))
205 {
206 return ErrorCode::STATE_ERR;
207 }
209 case FormatType::DoubleGeneral:
210 if constexpr (!FloatEnabled(FormatType::DoubleGeneral))
211 {
212 return ErrorCode::STATE_ERR;
213 }
215 case FormatType::LongDoubleFixed:
216 if constexpr (!FloatEnabled(FormatType::LongDoubleFixed))
217 {
218 return ErrorCode::STATE_ERR;
219 }
221 case FormatType::LongDoubleScientific:
222 if constexpr (!FloatEnabled(FormatType::LongDoubleScientific))
223 {
224 return ErrorCode::STATE_ERR;
225 }
227 case FormatType::LongDoubleGeneral:
228 if constexpr (!FloatEnabled(FormatType::LongDoubleGeneral))
229 {
230 return ErrorCode::STATE_ERR;
231 }
233 case FormatType::TextInline:
234 case FormatType::TextRef:
235 case FormatType::TextSpace:
236 case FormatType::End:
237 default:
238 return ErrorCode::STATE_ERR;
239 }
240}
ErrorCode DispatchFloatField()
读取一个浮点载荷并转发给选定的浮点语义写出路径 / Read one float payload and forward it to the selected float semantic writer
ErrorCode DispatchPointerField()
读取一个指针载荷并走指针字段写出路径 / Read one pointer payload and write it through the pointer field path
ErrorCode DispatchStringField()
读取一个字符串载荷并走字符串字段写出路径 / Read one string payload and write it through the string field path
ErrorCode DispatchSignedField()
运行期执行器中 GenericField 的分发桥接函数 / GenericField dispatch bridges for the runtime executor
ErrorCode DispatchUnsignedField()
读取一个无符号载荷并转发给选定的整数语义写出路径 / Read one unsigned payload and forward it to the selected integer semantic ...
ErrorCode DispatchCharacterField()
读取一个字符载荷并走字符字段写出路径 / Read one character payload and write it through the character field path

◆ DispatchOp()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::DispatchOp ( FormatOp op)
nodiscardprivate

将一个运行期操作码分发到选中的特化路径 / Dispatch one runtime opcode to the selected specialized path

将一个顶层操作码分发到其特化运行期路径 / Dispatches one top-level opcode to its specialized runtime path.

Parameters
op解码后的运行期操作码 / Decoded runtime opcode
Returns
返回该操作码对应特化路径的运行结果 / Returns the specialized runtime result for that opcode
Parameters
opDecoded runtime opcode. / 解码后的运行期操作码。
Returns
Returns the specialized runtime result for that opcode. / 返回该操作码对应特化路径的运行结果。

Definition at line 54 of file writer_executor_opcode.hpp.

55{
56 switch (op)
57 {
58 case FormatOp::TextInline:
59 return WriteRaw(codes_.ReadInlineText());
60 case FormatOp::TextRef:
61 return WriteRaw(codes_.ReadTextRef());
62 case FormatOp::TextSpace:
63 return WriteRaw(" ");
64 case FormatOp::U32Dec:
65 if constexpr (!HasProfile(Profile, FormatProfile::U32) ||
66 !Config::enable_integer)
67 {
68 return ErrorCode::STATE_ERR;
69 }
70 return WriteU32Dec(args_.Read<uint32_t>());
71 case FormatOp::U32ZeroPadWidth:
72 if constexpr (!HasProfile(Profile, FormatProfile::U32) ||
73 !Config::enable_integer)
74 {
75 return ErrorCode::STATE_ERR;
76 }
77 return WriteU32ZeroPadWidth(codes_.Read<uint8_t>(), args_.Read<uint32_t>());
78 case FormatOp::StringRaw:
79 if constexpr (!HasProfile(Profile, FormatProfile::TextArg) ||
80 !Config::enable_text)
81 {
82 return ErrorCode::STATE_ERR;
83 }
84 return WriteStringRaw(args_.Read<std::string_view>());
85 case FormatOp::F32FixedPrec:
86 if constexpr (!HasProfile(Profile, FormatProfile::F32Fixed) ||
87 !FloatEnabled(FormatType::FloatFixed))
88 {
89 return ErrorCode::STATE_ERR;
90 }
91 return WriteF32FixedPrec(codes_.Read<uint8_t>(), args_.Read<float>());
92 case FormatOp::F64FixedPrec:
93 if constexpr (!HasProfile(Profile, FormatProfile::F64Fixed) ||
94 !FloatEnabled(FormatType::DoubleFixed))
95 {
96 return ErrorCode::STATE_ERR;
97 }
98 return WriteF64FixedPrec(codes_.Read<uint8_t>(), args_.Read<double>());
99 case FormatOp::GenericField:
100 if constexpr (!HasProfile(Profile, FormatProfile::Generic))
101 {
102 return ErrorCode::STATE_ERR;
103 }
104 return DispatchGenericField(codes_.ReadFormatType());
105 case FormatOp::End:
106 default:
107 return ErrorCode::STATE_ERR;
108 }
109}
std::string_view ReadInlineText()
读取内嵌在记录流中的短文本 / Read a null-terminated short text payload embedded in the record stream
std::string_view ReadTextRef()
读取指向尾部文本池的偏移和长度 / Read an offset-size pair pointing into the trailing text pool
T Read()
读取编译期发射器按本机字节序写入的 POD 值 / Read a native-endian POD value emitted by the compile-time emitter
FormatType ReadFormatType()
读取 GenericField 载荷中的语义类型字节 / Read the semantic type byte carried by one GenericField payload
ErrorCode WriteF64FixedPrec(uint8_t precision, double value)
单个带显式精度的定点 double 快路径。 / Fast path for one fixed double with explicit precision.
ErrorCode WriteRaw(std::string_view text)
运行期执行器共享的字段写出原语,供所有操作码路径复用 / Executor-side field-writing primitives shared by all runtime opcodes
ErrorCode DispatchGenericField(FormatType type)
将一个 GenericField 载荷分发到对应的宽回退路径 / Dispatch one GenericField payload to the corresponding wide fallback
ErrorCode WriteU32ZeroPadWidth(uint8_t width, uint32_t value)
单个零填充 uint32_t 十进制字段的快路径。 / Fast path for one zero-padded uint32_t decimal field.
ErrorCode WriteF32FixedPrec(uint8_t precision, float value)
单个带显式精度的定点 float 快路径。 / Fast path for one fixed float with explicit precision.
ErrorCode WriteStringRaw(std::string_view text)
单个原始字符串参数的快路径。 / Fast path for one raw string argument.
ErrorCode WriteU32Dec(uint32_t value)
单个原始 uint32_t 十进制字段的快路径。 / Fast path for one raw uint32_t decimal field.

◆ DispatchPointerField()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::DispatchPointerField ( )
nodiscardprivate

读取一个指针载荷并走指针字段写出路径 / Read one pointer payload and write it through the pointer field path

Returns
返回指针字段写出结果 / Returns the pointer-field write result

Definition at line 50 of file writer_executor_generic.hpp.

51{
52 return WritePointer(codes_.ReadSpec(), args_.Read<uintptr_t>());
53}
ErrorCode WritePointer(const Spec &spec, uintptr_t value)
按规范指针字段策略写出一个指针值 / Write one pointer value using the canonical pointer field policy

◆ DispatchSignedField()

template<OutputSink Sink, FormatProfile Profile>
template<std::signed_integral Int>
ErrorCode Writer::Executor< Sink, Profile >::DispatchSignedField ( )
nodiscardprivate

运行期执行器中 GenericField 的分发桥接函数 / GenericField dispatch bridges for the runtime executor

读取一个有符号载荷并转发给具体有符号写出路径 / Read one signed payload and forward it to the concrete signed writer

Template Parameters
Int有符号打包存储类型 / Signed packed-storage type
Returns
返回具体有符号字段写出结果 / Returns the concrete signed-field write result

Definition at line 14 of file writer_executor_generic.hpp.

15{
16 return WriteSigned(codes_.ReadSpec(), args_.Read<Int>());
17}
ErrorCode WriteSigned(const Spec &spec, Int value)
通过共享整数字段路径写出一个有符号整数值 / Write one signed integer value through the shared integer-field path

◆ DispatchStringField()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::DispatchStringField ( )
nodiscardprivate

读取一个字符串载荷并走字符串字段写出路径 / Read one string payload and write it through the string field path

Returns
返回字符串字段写出结果 / Returns the string-field write result

Definition at line 70 of file writer_executor_generic.hpp.

71{
72 return WriteString(codes_.ReadSpec(), args_.Read<std::string_view>());
73}
ErrorCode WriteString(const Spec &spec, std::string_view text)
写出一个字符串字段值,并在需要时应用精度截断 / Write one string field value, including precision truncation when present

◆ DispatchUnsignedField()

template<OutputSink Sink, FormatProfile Profile>
template<FormatType Type, std::unsigned_integral UInt>
ErrorCode Writer::Executor< Sink, Profile >::DispatchUnsignedField ( )
nodiscardprivate

读取一个无符号载荷并转发给选定的整数语义写出路径 / Read one unsigned payload and forward it to the selected integer semantic writer

Template Parameters
Type运行期整数语义类型 / Runtime integer semantic type
UInt无符号打包存储类型 / Unsigned packed-storage type
Returns
返回选定整数语义路径的写出结果 / Returns the selected integer-field write result

Definition at line 27 of file writer_executor_generic.hpp.

28{
29 return WriteUnsigned<Type>(codes_.ReadSpec(), args_.Read<UInt>());
30}
ErrorCode WriteUnsigned(const Spec &spec, UInt value)
通过共享整数字段路径写出一个无符号整数语义值 / Write one unsigned integer semantic value through the shared integer-field p...

◆ ResolveFloatSignChar()

template<OutputSink Sink, FormatProfile Profile>
template<typename T >
char Writer::Executor< Sink, Profile >::ResolveFloatSignChar ( T value,
const Spec & spec )
staticnodiscardprivate

为一个浮点载荷确定最终可见的符号字符 / Resolve the visible sign character for one float payload

Template Parameters
T浮点类型 / Float type
Parameters
value当前要输出的浮点值 / Float value being emitted
spec解码后的字段规格 / Decoded field spec
Returns
返回 ‘’-''+'' ''\0'/ Returns'-','+',' ', or'\0'`

Definition at line 42 of file writer_executor_value.hpp.

43{
44 if (std::signbit(value))
45 {
46 return '-';
47 }
48 if (spec.ForceSign())
49 {
50 return '+';
51 }
52 if (spec.SpaceSign())
53 {
54 return ' ';
55 }
56 return '\0';
57}

◆ ResolveSignChar()

template<OutputSink Sink, FormatProfile Profile>
template<std::signed_integral Int>
char Writer::Executor< Sink, Profile >::ResolveSignChar ( Int value,
const Spec & spec )
staticnodiscardprivate

执行器的具体运行期数值写出函数 / Concrete runtime value writers for the executor

为一个有符号整数载荷确定最终可见的符号字符 / Resolve the visible sign character for one signed integer payload

Template Parameters
Int有符号整数类型 / Signed integer type
Parameters
value当前要输出的整数值 / Integer value being emitted
spec解码后的字段规格 / Decoded field spec
Returns
返回 ‘’-''+'' ''\0'/ Returns'-','+',' ', or'\0'`

Definition at line 16 of file writer_executor_value.hpp.

17{
18 if (value < 0)
19 {
20 return '-';
21 }
22 if (spec.ForceSign())
23 {
24 return '+';
25 }
26 if (spec.SpaceSign())
27 {
28 return ' ';
29 }
30 return '\0';
31}

◆ Run()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::Run ( )
nodiscard

持续执行记录流,直到遇到 FormatOp::End / Run until the compiled record stream reaches FormatOp::End

运行操作码循环,直到遇到 End 或首个 sink/运行期错误 / Runs the opcode loop until End or the first sink/runtime error.

Returns
返回首个 sink 或运行期错误;正常执行到记录流结束时返回 ErrorCode::OK / Returns the first sink or runtime error, or ErrorCode::OK when the record stream finishes normally
Returns ErrorCode::OK on normal completion, or the first sink / runtime error. / 正常结束返回 ErrorCode::OK;否则返回首个 sink/运行期错误。

Definition at line 29 of file writer_executor_opcode.hpp.

30{
31 while (true)
32 {
33 auto op = codes_.ReadOp();
34 if (op == FormatOp::End)
35 {
36 return ErrorCode::OK;
37 }
38
39 auto ec = DispatchOp(op);
40 if (ec != ErrorCode::OK)
41 {
42 return ec;
43 }
44 }
45}
FormatOp ReadOp()
读取下一条运行期操作码 / Read the next runtime opcode
ErrorCode DispatchOp(FormatOp op)
将一个运行期操作码分发到选中的特化路径 / Dispatch one runtime opcode to the selected specialized path

◆ WriteCharacter()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteCharacter ( const Spec & spec,
char ch )
nodiscardprivate

写出一个字符字段值 / Write one character field value

Parameters
spec解码后的字段规格 / Decoded field spec
ch待写出的字符值 / Character value to write
Returns
返回字符字段写出结果 / Returns the character-field write result

Definition at line 193 of file writer_executor_value.hpp.

194{
195 return WriteTextField(std::string_view(&ch, 1), spec);
196}
ErrorCode WriteTextField(std::string_view text, const Spec &spec)
按宽度与对齐策略写出一个文本字段 / Write one text field with width/alignment policy applied

◆ WriteF32FixedPrec()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteF32FixedPrec ( uint8_t precision,
float value )
nodiscardprivate

单个带显式精度的定点 float 快路径。 / Fast path for one fixed float with explicit precision.

写出一个 float32 定点精度快路径字段 / Write one float32 fixed-precision fast-path field

Parameters
precision显式定点精度 / Explicit fixed precision
value待写出的浮点值 / Float value to write
Returns
返回该快路径的写出结果 / Returns the fast-path write result

Definition at line 326 of file writer_executor_value.hpp.

328{
329 char sign_char = std::signbit(value) ? '-' : '\0';
330 float magnitude = std::signbit(value) ? -value : value;
331 if (ExceedsFixedIntegerDigits(magnitude, precision))
332 {
333 return ErrorCode::OUT_OF_RANGE;
334 }
335 char output_buffer[float_buffer_capacity];
336 size_t output_size = 0;
337 if (!FormatF32FixedPrecText(magnitude, precision, output_buffer, output_size))
338 {
339 return ErrorCode::NO_BUFF;
340 }
341
342 if (sign_char != '\0')
343 {
344 if (auto ec = WriteRaw(std::string_view(&sign_char, 1)); ec != ErrorCode::OK)
345 {
346 return ec;
347 }
348 }
349
350 return WriteRaw(std::string_view(output_buffer, output_size));
351}

◆ WriteF64FixedPrec()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteF64FixedPrec ( uint8_t precision,
double value )
nodiscardprivate

单个带显式精度的定点 double 快路径。 / Fast path for one fixed double with explicit precision.

通过通用浮点写出路径写出一个 double 定点精度字段 / Write one double fixed-precision field through the generic float writer

Parameters
precision显式定点精度 / Explicit fixed precision
value待写出的 double 值 / Double value to write
Returns
返回通用浮点写出路径的结果 / Returns the generic float-writer result

Definition at line 360 of file writer_executor_value.hpp.

362{
363 return WriteFloat(FormatType::DoubleFixed, Spec{.precision = precision}, value);
364}

◆ WriteFloat()

template<OutputSink Sink, FormatProfile Profile>
template<typename T >
ErrorCode Writer::Executor< Sink, Profile >::WriteFloat ( FormatType type,
const Spec & spec,
T value )
nodiscardprivate

通过共享浮点文本后端写出一个浮点语义值 / Write one float semantic value through the shared float-text backend

Template Parameters
T浮点类型 / Float type
Parameters
type运行期浮点语义类型 / Runtime float semantic type
spec解码后的字段规格 / Decoded field spec
value待写出的浮点值 / Float value to write
Returns
返回浮点字段写出结果 / Returns the float-field write result

Definition at line 227 of file writer_executor_value.hpp.

229{
230 if (!UsesFloatTextBackend(type))
231 {
232 return ErrorCode::ARG_ERR;
233 }
234
235 char sign_char = ResolveFloatSignChar(value, spec);
236 T magnitude = std::signbit(value) ? -static_cast<T>(value) : static_cast<T>(value);
237 uint8_t precision = spec.HasPrecision() ? spec.precision : DefaultFloatPrecision();
238 if (type == FormatType::FloatFixed || type == FormatType::DoubleFixed ||
239 type == FormatType::LongDoubleFixed)
240 {
241 if (ExceedsFixedIntegerDigits(magnitude, precision))
242 {
243 return ErrorCode::OUT_OF_RANGE;
244 }
245 }
246 else if (type == FormatType::FloatGeneral || type == FormatType::DoubleGeneral ||
247 type == FormatType::LongDoubleGeneral)
248 {
249 uint8_t significant = precision == 0 ? 1 : precision;
250 int exponent = (magnitude == 0) ? 0 : NormalizeDecimal(magnitude).exponent;
251 if (!(exponent < -4 || exponent >= significant))
252 {
253 int fractional_precision = static_cast<int>(significant) - (exponent + 1);
254 if (fractional_precision < 0)
255 {
256 fractional_precision = 0;
257 }
258 if (ExceedsFixedIntegerDigits(magnitude,
259 static_cast<uint8_t>(fractional_precision)))
260 {
261 return ErrorCode::OUT_OF_RANGE;
262 }
263 }
264 }
265 char output_buffer[float_buffer_capacity];
266 size_t output_size = 0;
267 if (!FormatFloatText(type, spec, magnitude, output_buffer, output_size))
268 {
269 return ErrorCode::NO_BUFF;
270 }
271
272 return WriteFloatField(sign_char, std::string_view(output_buffer, output_size), spec);
273}
static char ResolveFloatSignChar(T value, const Spec &spec)
为一个浮点载荷确定最终可见的符号字符 / Resolve the visible sign character for one float payload
ErrorCode WriteFloatField(char sign_char, std::string_view text, const Spec &spec)
按符号与字段填充策略写出一个浮点文本载荷 / Write one float text payload with sign and field padding applied

◆ WriteFloatField()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteFloatField ( char sign_char,
std::string_view text,
const Spec & spec )
nodiscardprivate

按符号与字段填充策略写出一个浮点文本载荷 / Write one float text payload with sign and field padding applied

Parameters
sign_char最终可见的符号字符;无符号时为 ‘’\0'/ Visible sign character, or'\0'when absent @param text 已完成格式化的浮点文本载荷 / Already formatted float text payload @param spec 解码后的字段规格 / Decoded field spec @return 返回首个 sink 错误;成功时返回ErrorCode::OK/ Returns the first sink error, orErrorCode::OK` on success

Definition at line 170 of file writer_executor_field.hpp.

173{
174 auto write_char = [this](char ch) -> ErrorCode {
175 if (ch == '\0')
176 {
177 return ErrorCode::OK;
178 }
179 return WriteRaw(std::string_view(&ch, 1));
180 };
181
182 size_t total = text.size() + static_cast<size_t>(sign_char != '\0');
183 size_t pad = FieldPadding(spec.width, total);
184 bool zero_fill = spec.ZeroPad() && !spec.LeftAlign() && !spec.CenterAlign();
185 size_t left_pad = 0;
186 size_t middle_zeros = zero_fill ? pad : 0;
187 size_t right_pad = 0;
188 if (!zero_fill)
189 {
190 if (spec.LeftAlign())
191 {
192 right_pad = pad;
193 }
194 else if (spec.CenterAlign())
195 {
196 left_pad = pad / 2;
197 right_pad = pad - left_pad;
198 }
199 else
200 {
201 left_pad = pad;
202 }
203 }
204
205 if (auto ec = WritePadding(spec.fill, left_pad); ec != ErrorCode::OK)
206 {
207 return ec;
208 }
209 if (auto ec = write_char(sign_char); ec != ErrorCode::OK)
210 {
211 return ec;
212 }
213 if (auto ec = WritePadding('0', middle_zeros); ec != ErrorCode::OK)
214 {
215 return ec;
216 }
217 if (auto ec = WriteRaw(text); ec != ErrorCode::OK)
218 {
219 return ec;
220 }
221 return WritePadding(spec.fill, right_pad);
222}
ErrorCode WritePadding(char fill, size_t count)
向输出端写入重复填充字符 / Write repeated fill characters into the sink

◆ WriteIntegerField()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteIntegerField ( char sign_char,
std::string_view prefix,
std::string_view digits,
const Spec & spec )
nodiscardprivate

按符号、前缀、精度与填充策略写出一个整数载荷 / Write one integer payload with sign, prefix, precision, and padding policy applied

Parameters
sign_char最终可见的符号字符;无符号时为 ‘’\0'/ Visible sign character, or'\0'when absent @param prefix 输出在数字前面的前缀 / Prefix emitted ahead of the digits @param digits 十进制、二进制、八进制或十六进制数字载荷 / Decimal, binary, octal, or hex digit payload @param spec 解码后的字段规格 / Decoded field spec @return 返回首个 sink 错误;成功时返回ErrorCode::OK/ Returns the first sink error, orErrorCode::OK` on success

Definition at line 91 of file writer_executor_field.hpp.

93{
94 auto write_char = [this](char ch) -> ErrorCode {
95 if (ch == '\0')
96 {
97 return ErrorCode::OK;
98 }
99 return WriteRaw(std::string_view(&ch, 1));
100 };
101 auto write_text = [this](std::string_view text) -> ErrorCode {
102 if (text.empty())
103 {
104 return ErrorCode::OK;
105 }
106 return WriteRaw(text);
107 };
108
109 size_t zeros = IntegerPrecisionZeros(spec, digits.size());
110 size_t total = digits.size() + zeros + prefix.size() +
111 static_cast<size_t>(sign_char != '\0');
112 size_t pad = FieldPadding(spec.width, total);
113 bool zero_fill = spec.ZeroPad() && !spec.LeftAlign() && !spec.CenterAlign() &&
114 !spec.HasPrecision();
115 size_t left_pad = 0;
116 size_t middle_zeros = zero_fill ? pad : 0;
117 size_t right_pad = 0;
118 if (!zero_fill)
119 {
120 if (spec.LeftAlign())
121 {
122 right_pad = pad;
123 }
124 else if (spec.CenterAlign())
125 {
126 left_pad = pad / 2;
127 right_pad = pad - left_pad;
128 }
129 else
130 {
131 left_pad = pad;
132 }
133 }
134
135 if (auto ec = WritePadding(spec.fill, left_pad); ec != ErrorCode::OK)
136 {
137 return ec;
138 }
139 if (auto ec = write_char(sign_char); ec != ErrorCode::OK)
140 {
141 return ec;
142 }
143 if (auto ec = write_text(prefix); ec != ErrorCode::OK)
144 {
145 return ec;
146 }
147 if (auto ec = WritePadding('0', middle_zeros); ec != ErrorCode::OK)
148 {
149 return ec;
150 }
151 if (auto ec = WritePadding('0', zeros); ec != ErrorCode::OK)
152 {
153 return ec;
154 }
155 if (auto ec = write_text(digits); ec != ErrorCode::OK)
156 {
157 return ec;
158 }
159 return WritePadding(spec.fill, right_pad);
160}

◆ WritePadding()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WritePadding ( char fill,
size_t count )
nodiscardprivate

向输出端写入重复填充字符 / Write repeated fill characters into the sink

Parameters
fill填充字符 / Fill character
count重复次数 / Repeat count
Returns
返回首个 sink 错误;全部填充字节写出后返回 ErrorCode::OK / Returns the first sink error, or ErrorCode::OK when all fill bytes are written

Definition at line 25 of file writer_executor_field.hpp.

26{
27 char chunk[16];
28 std::memset(chunk, fill, sizeof(chunk));
29
30 while (count != 0)
31 {
32 size_t step = (count < sizeof(chunk)) ? count : sizeof(chunk);
33 auto ec = WriteRaw(std::string_view(chunk, step));
34 if (ec != ErrorCode::OK)
35 {
36 return ec;
37 }
38 count -= step;
39 }
40
41 return ErrorCode::OK;
42}

◆ WritePointer()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WritePointer ( const Spec & spec,
uintptr_t value )
nodiscardprivate

按规范指针字段策略写出一个指针值 / Write one pointer value using the canonical pointer field policy

Parameters
spec解码后的字段规格 / Decoded field spec
valueuintptr_t 编码的指针值 / Pointer value encoded as uintptr_t
Returns
返回指针字段写出结果 / Returns the pointer-field write result

Definition at line 170 of file writer_executor_value.hpp.

172{
173 char digit_buffer[UnsignedDigitCapacity<uintptr_t, 16>()];
174 size_t digit_count = AppendUnsigned<16>(digit_buffer, value);
175 Spec actual = spec;
176
177 if (!actual.HasPrecision() || actual.precision == 0)
178 {
179 actual.precision = 1;
180 }
181
182 return WriteIntegerField('\0', "0x", std::string_view(digit_buffer, digit_count),
183 actual);
184}
ErrorCode WriteIntegerField(char sign_char, std::string_view prefix, std::string_view digits, const Spec &spec)
按符号、前缀、精度与填充策略写出一个整数载荷 / Write one integer payload with sign, prefix, precision, and padding policy a...

◆ WriteRaw()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteRaw ( std::string_view text)
nodiscardprivate

运行期执行器共享的字段写出原语,供所有操作码路径复用 / Executor-side field-writing primitives shared by all runtime opcodes

将一段原始文本直接写入输出端 / Write one raw text chunk directly into the sink

Parameters
textText chunk to write. / 待写出的文本片段。
Returns
Returns the sink write result. / 返回 sink 写出结果。

Definition at line 13 of file writer_executor_field.hpp.

14{
15 return sink_.Write(text);
16}

◆ WriteSigned()

template<OutputSink Sink, FormatProfile Profile>
template<std::signed_integral Int>
ErrorCode Writer::Executor< Sink, Profile >::WriteSigned ( const Spec & spec,
Int value )
nodiscardprivate

通过共享整数字段路径写出一个有符号整数值 / Write one signed integer value through the shared integer-field path

Template Parameters
Int有符号整数类型 / Signed integer type
Parameters
spec解码后的字段规格 / Decoded field spec
value待写出的整数值 / Integer value to write
Returns
返回共享整数字段路径的写出结果 / Returns the shared integer-field write result

Definition at line 68 of file writer_executor_value.hpp.

69{
70 using UInt = std::make_unsigned_t<Int>;
71 char digit_buffer[UnsignedDigitCapacity<UInt, 10>()];
72 UInt bits = static_cast<UInt>(value);
73 UInt magnitude = (value < 0) ? (UInt{0} - bits) : bits;
74 size_t digit_count = AppendUnsigned<10>(digit_buffer, magnitude);
75
76 std::string_view digits(digit_buffer, digit_count);
77 if (value == 0 && spec.precision == 0)
78 {
79 digits = {};
80 }
81
82 return WriteIntegerField(ResolveSignChar(value, spec), {}, digits, spec);
83}
static char ResolveSignChar(Int value, const Spec &spec)
执行器的具体运行期数值写出函数 / Concrete runtime value writers for the executor

◆ WriteString()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteString ( const Spec & spec,
std::string_view text )
nodiscardprivate

写出一个字符串字段值,并在需要时应用精度截断 / Write one string field value, including precision truncation when present

Parameters
spec解码后的字段规格 / Decoded field spec
text待写出的字符串载荷 / String payload to write
Returns
返回字符串字段写出结果 / Returns the string-field write result

Definition at line 205 of file writer_executor_value.hpp.

207{
208 auto view = text;
209 if (spec.HasPrecision() && spec.precision < view.size())
210 {
211 view = view.substr(0, spec.precision);
212 }
213
214 return WriteTextField(view, spec);
215}

◆ WriteStringRaw()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteStringRaw ( std::string_view text)
nodiscardprivate

单个原始字符串参数的快路径。 / Fast path for one raw string argument.

写出一个原始字符串快路径字段 / Writes one raw string fast-path field.

Parameters
textString payload to write. / 待写出的字符串载荷。
Returns
Returns the sink write result. / 返回 sink 写出结果。

Definition at line 314 of file writer_executor_value.hpp.

315{
316 return WriteRaw(text);
317}

◆ WriteTextField()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteTextField ( std::string_view text,
const Spec & spec )
nodiscardprivate

按宽度与对齐策略写出一个文本字段 / Write one text field with width/alignment policy applied

Parameters
text上层归一化后的文本载荷 / Text payload after higher-level normalization
spec解码后的字段规格 / Decoded field spec
Returns
返回首个 sink 错误;成功时返回 ErrorCode::OK / Returns the first sink error, or ErrorCode::OK on success

Definition at line 51 of file writer_executor_field.hpp.

53{
54 size_t pad = FieldPadding(spec.width, text.size());
55 size_t left_pad = 0;
56 size_t right_pad = 0;
57 if (spec.LeftAlign())
58 {
59 right_pad = pad;
60 }
61 else if (spec.CenterAlign())
62 {
63 left_pad = pad / 2;
64 right_pad = pad - left_pad;
65 }
66 else
67 {
68 left_pad = pad;
69 }
70
71 if (auto ec = WritePadding(spec.fill, left_pad); ec != ErrorCode::OK)
72 {
73 return ec;
74 }
75 if (auto ec = WriteRaw(text); ec != ErrorCode::OK)
76 {
77 return ec;
78 }
79 return WritePadding(spec.fill, right_pad);
80}

◆ WriteU32Dec()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteU32Dec ( uint32_t value)
nodiscardprivate

单个原始 uint32_t 十进制字段的快路径。 / Fast path for one raw uint32_t decimal field.

写出一个原始 uint32 十进制快路径字段 / Writes one raw uint32 decimal fast-path field.

Parameters
valueUnsigned value to write. / 待写出的无符号值。
Returns
Returns the sink write result. / 返回 sink 写出结果。

Definition at line 281 of file writer_executor_value.hpp.

282{
283 char digit_buffer[UnsignedDigitCapacity<uint32_t, 10>()];
284 size_t digit_count = AppendUnsigned<10>(digit_buffer, value);
285 return WriteRaw(std::string_view(digit_buffer, digit_count));
286}

◆ WriteU32ZeroPadWidth()

template<OutputSink Sink, FormatProfile Profile>
ErrorCode Writer::Executor< Sink, Profile >::WriteU32ZeroPadWidth ( uint8_t width,
uint32_t value )
nodiscardprivate

单个零填充 uint32_t 十进制字段的快路径。 / Fast path for one zero-padded uint32_t decimal field.

写出一个带零填充宽度的 uint32_t 十进制快路径字段 / Write one zero-padded uint32_t decimal fast-path field

Parameters
width目标零填充宽度 / Target zero-padded width
value待写出的无符号值 / Unsigned value to write
Returns
返回该快路径的写出结果 / Returns the fast-path write result

Definition at line 295 of file writer_executor_value.hpp.

297{
298 char digit_buffer[UnsignedDigitCapacity<uint32_t, 10>()];
299 size_t digit_count = AppendUnsigned<10>(digit_buffer, value);
300 size_t zeros = FieldPadding(width, digit_count);
301 if (auto ec = WritePadding('0', zeros); ec != ErrorCode::OK)
302 {
303 return ec;
304 }
305 return WriteRaw(std::string_view(digit_buffer, digit_count));
306}

◆ WriteUnsigned()

template<OutputSink Sink, FormatProfile Profile>
template<FormatType Type, std::unsigned_integral UInt>
ErrorCode Writer::Executor< Sink, Profile >::WriteUnsigned ( const Spec & spec,
UInt value )
nodiscardprivate

通过共享整数字段路径写出一个无符号整数语义值 / Write one unsigned integer semantic value through the shared integer-field path

Template Parameters
Type运行期整数语义类型 / Runtime integer semantic type
UInt无符号整数类型 / Unsigned integer type
Parameters
spec解码后的字段规格 / Decoded field spec
value待写出的整数值 / Integer value to write
Returns
返回共享整数字段路径的写出结果 / Returns the shared integer-field write result

This bridge does not format digits itself; it only maps one runtime integer semantic type onto the shared compile-time radix/case helper above. 这个桥接函数本身不直接格式化数字;它只负责把运行期整数语义类型映射到上面的 编译期进制/大小写共享辅助路径。

Definition at line 135 of file writer_executor_value.hpp.

136{
137 auto prefix = IntegerPrefix(Type, spec, value);
138
139 if constexpr (Type == FormatType::Unsigned32 || Type == FormatType::Unsigned64)
140 {
141 return WriteUnsignedDigits<10>(prefix, spec, value);
142 }
143 if constexpr (Type == FormatType::Binary32 || Type == FormatType::Binary64)
144 {
145 return WriteUnsignedDigits<2>(prefix, spec, value);
146 }
147 if constexpr (Type == FormatType::Octal32 || Type == FormatType::Octal64)
148 {
149 return WriteUnsignedDigits<8, false, true>(prefix, spec, value);
150 }
151 if constexpr (Type == FormatType::HexLower32 || Type == FormatType::HexLower64)
152 {
153 return WriteUnsignedDigits<16>(prefix, spec, value);
154 }
155 if constexpr (Type == FormatType::HexUpper32 || Type == FormatType::HexUpper64)
156 {
157 return WriteUnsignedDigits<16, true>(prefix, spec, value);
158 }
159
160 return ErrorCode::ARG_ERR;
161}
ErrorCode WriteUnsignedDigits(std::string_view prefix, const Spec &spec, UInt value)
按编译期进制/大小写/八进制备用格式参数复用无符号数字载荷写出逻辑 / Reuse the unsigned-digit payload writer with compile-time radix,...

◆ WriteUnsignedDigits()

template<OutputSink Sink, FormatProfile Profile>
template<uint8_t Base, bool UpperCase, bool InlineAlternateOctal, std::unsigned_integral UInt>
ErrorCode Writer::Executor< Sink, Profile >::WriteUnsignedDigits ( std::string_view prefix,
const Spec & spec,
UInt value )
nodiscardprivate

按编译期进制/大小写/八进制备用格式参数复用无符号数字载荷写出逻辑 / Reuse the unsigned-digit payload writer with compile-time radix, case, and octal-alternate parameters

通过共享整数字段路径写出一个无符号整数语义值 / Write one unsigned integer semantic value through the shared integer-field path

Template Parameters
Base整数进制 / Integer radix
UpperCase十六进制数字是否使用大写字符 / Whether hexadecimal digits should use uppercase characters
InlineAlternateOctal是否把 %#o 的前导 0 直接并入数字载荷 / Whether %#o should inline its leading 0 into the digit payload
UInt无符号整数类型 / Unsigned integer type
Parameters
prefix脱离数字载荷输出的前缀 / Prefix emitted outside the digit payload
spec解码后的字段规格 / Decoded field spec
value待写出的整数值 / Integer value to write
Returns
返回共享无符号数字写出路径的结果 / Returns the shared unsigned-digit write result
Template Parameters
Base整数进制 / Integer radix
UpperCase十六进制数字是否使用大写字符 / Whether hexadecimal digits should use uppercase characters
InlineAlternateOctal是否把 %#o 的前导 0 直接并入数字载荷 / Whether %#o should inline its leading 0 into the digit payload
UInt无符号整数类型 / Unsigned integer type
Parameters
prefix脱离数字载荷输出的前缀 / Prefix emitted outside the digit payload
spec解码后的字段规格 / Decoded field spec
value待写出的整数值 / Integer value to write
Returns
返回共享整数字段路径的写出结果 / Returns the shared integer-field write result

Definition at line 99 of file writer_executor_value.hpp.

102{
103 char digit_buffer[UnsignedDigitCapacity<UInt, Base>() +
104 (InlineAlternateOctal ? 1U : 0U)];
105 size_t digit_count = AppendUnsigned<Base, UpperCase>(digit_buffer, value);
106
107 if constexpr (InlineAlternateOctal)
108 {
109 digit_count = ApplyAlternateOctal(digit_buffer, digit_count, spec, value);
110 }
111 else if (value == 0 && spec.precision == 0)
112 {
113 digit_count = 0;
114 }
115
116 return WriteIntegerField('\0', prefix, std::string_view(digit_buffer, digit_count),
117 spec);
118}

Field Documentation

◆ args_

template<OutputSink Sink, FormatProfile Profile>
ArgumentReader Writer::Executor< Sink, Profile >::args_
private

Definition at line 131 of file writer_executor.hpp.

◆ codes_

template<OutputSink Sink, FormatProfile Profile>
CodeReader Writer::Executor< Sink, Profile >::codes_
private

Definition at line 130 of file writer_executor.hpp.

◆ sink_

template<OutputSink Sink, FormatProfile Profile>
Sink& Writer::Executor< Sink, Profile >::sink_
private

Definition at line 129 of file writer_executor.hpp.


The documentation for this class was generated from the following files: