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

按输出端共享重后端、按调用点 profile 裁剪操作码分发的字节码执行器 / Per-sink bytecode executor with shared heavy backends and per-call profile-pruned opcode dispatch More...

#include <writer_executor.hpp>

Collaboration diagram for Writer::Executor< Sink >:
[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
 
template<FormatProfile Profile>
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 DispatchUnsigned (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 PrependOctalZero = 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
 
ErrorCode WriteU32Dec (uint32_t value)
 单个原始 uint32_t 十进制字段的快路径。 / Fast path for one raw uint32_t decimal field.
 
ErrorCode WriteI32Dec (int32_t value)
 单个原始 int32_t 十进制字段的快路径。 / Fast path for one raw int32_t decimal field.
 
template<uint8_t Base, bool UpperCase = false>
ErrorCode WriteU32Base (uint32_t value)
 单个原始 uint32_t 非十进制字段的快路径。 / Fast path for one raw uint32_t non-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 WriteCharacterRaw (char ch)
 单个原始字符参数的快路径。 / Fast path for one raw character argument.
 
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
 
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
 
template<FormatProfile Profile>
ErrorCode DispatchGenericField (FormatType type)
 将一个 GenericField 载荷分发到对应的宽回退路径 / Dispatch one GenericField payload to the corresponding wide fallback
 
template<FormatProfile Profile>
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
 

Private Attributes

Sink & sink_
 
CodeReader codes_
 
ArgumentReader args_
 

Detailed Description

template<OutputSink Sink>
class Writer::Executor< Sink >

按输出端共享重后端、按调用点 profile 裁剪操作码分发的字节码执行器 / Per-sink bytecode executor with shared heavy backends and per-call profile-pruned opcode dispatch

Template Parameters
Sink输出端类型,需满足 OutputSink / Sink type satisfying OutputSink

Definition at line 10 of file writer_executor.hpp.

Constructor & Destructor Documentation

◆ Executor()

template<OutputSink Sink>
Writer::Executor< Sink >::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 17 of file writer_executor_opcode.hpp.

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

Member Function Documentation

◆ DispatchCharacterField()

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

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

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

Definition at line 69 of file writer_executor_generic.hpp.

70{
71 return WriteCharacter(codes_.ReadSpec(), args_.Read<char>());
72}
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

◆ DispatchGenericField()

template<OutputSink Sink>
template<FormatProfile Profile>
ErrorCode Writer::Executor< Sink >::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

Template Parameters
Profile当前编译格式使用的精确通用字段类型集合 / Exact generic-field type set used by the current compiled format
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 94 of file writer_executor_generic.hpp.

95{
96 switch (type)
97 {
98 case FormatType::Signed32:
99 if constexpr (HasProfile(Profile, FormatProfile::GenericSigned32) &&
100 Config::enable_integer)
101 {
103 }
104 return ErrorCode::STATE_ERR;
105 case FormatType::Signed64:
106 if constexpr (HasProfile(Profile, FormatProfile::GenericSigned64) &&
107 Config::enable_integer && Config::enable_integer_64bit)
108 {
110 }
111 return ErrorCode::STATE_ERR;
112 case FormatType::Unsigned32:
113 if constexpr (HasProfile(Profile, FormatProfile::GenericUnsigned32) &&
114 Config::enable_integer)
115 {
117 }
118 return ErrorCode::STATE_ERR;
119 case FormatType::Unsigned64:
120 if constexpr (HasProfile(Profile, FormatProfile::GenericUnsigned64) &&
121 Config::enable_integer && Config::enable_integer_64bit)
122 {
124 }
125 return ErrorCode::STATE_ERR;
126 case FormatType::Binary32:
127 if constexpr (HasProfile(Profile, FormatProfile::GenericBinary32) &&
128 Config::enable_integer && Config::enable_integer_base8_16)
129 {
131 }
132 return ErrorCode::STATE_ERR;
133 case FormatType::Binary64:
134 if constexpr (HasProfile(Profile, FormatProfile::GenericBinary64) &&
135 Config::enable_integer && Config::enable_integer_base8_16 &&
136 Config::enable_integer_64bit)
137 {
139 }
140 return ErrorCode::STATE_ERR;
141 case FormatType::Octal32:
142 if constexpr (HasProfile(Profile, FormatProfile::GenericOctal32) &&
143 Config::enable_integer && Config::enable_integer_base8_16)
144 {
146 }
147 return ErrorCode::STATE_ERR;
148 case FormatType::Octal64:
149 if constexpr (HasProfile(Profile, FormatProfile::GenericOctal64) &&
150 Config::enable_integer && Config::enable_integer_base8_16 &&
151 Config::enable_integer_64bit)
152 {
154 }
155 return ErrorCode::STATE_ERR;
156 case FormatType::HexLower32:
157 if constexpr (HasProfile(Profile, FormatProfile::GenericHexLower32) &&
158 Config::enable_integer && Config::enable_integer_base8_16)
159 {
161 }
162 return ErrorCode::STATE_ERR;
163 case FormatType::HexLower64:
164 if constexpr (HasProfile(Profile, FormatProfile::GenericHexLower64) &&
165 Config::enable_integer && Config::enable_integer_base8_16 &&
166 Config::enable_integer_64bit)
167 {
169 }
170 return ErrorCode::STATE_ERR;
171 case FormatType::HexUpper32:
172 if constexpr (HasProfile(Profile, FormatProfile::GenericHexUpper32) &&
173 Config::enable_integer && Config::enable_integer_base8_16)
174 {
176 }
177 return ErrorCode::STATE_ERR;
178 case FormatType::HexUpper64:
179 if constexpr (HasProfile(Profile, FormatProfile::GenericHexUpper64) &&
180 Config::enable_integer && Config::enable_integer_base8_16 &&
181 Config::enable_integer_64bit)
182 {
184 }
185 return ErrorCode::STATE_ERR;
186 case FormatType::Pointer:
187 if constexpr (HasProfile(Profile, FormatProfile::GenericPointer) &&
188 Config::enable_pointer)
189 {
190 return DispatchPointerField();
191 }
192 return ErrorCode::STATE_ERR;
193 case FormatType::Character:
194 if constexpr (HasProfile(Profile, FormatProfile::GenericCharacter) &&
195 Config::enable_text)
196 {
197 return DispatchCharacterField();
198 }
199 return ErrorCode::STATE_ERR;
200 case FormatType::String:
201 if constexpr (HasProfile(Profile, FormatProfile::GenericString) &&
202 Config::enable_text)
203 {
204 return DispatchStringField();
205 }
206 return ErrorCode::STATE_ERR;
207#if LIBXR_PRINT_ENABLE_FLOAT
208 case FormatType::FloatFixed:
209 if constexpr (HasProfile(Profile, FormatProfile::GenericFloatFixed) &&
210 FloatEnabled(FormatType::FloatFixed))
211 {
212 return DispatchFloatField<FormatType::FloatFixed, float>();
213 }
214 return ErrorCode::STATE_ERR;
215 case FormatType::DoubleFixed:
216 if constexpr (HasProfile(Profile, FormatProfile::GenericDoubleFixed) &&
217 FloatEnabled(FormatType::DoubleFixed))
218 {
219 return DispatchFloatField<FormatType::DoubleFixed, double>();
220 }
221 return ErrorCode::STATE_ERR;
222 case FormatType::FloatScientific:
223 if constexpr (HasProfile(Profile, FormatProfile::GenericFloatScientific) &&
224 FloatEnabled(FormatType::FloatScientific))
225 {
226 return DispatchFloatField<FormatType::FloatScientific, float>();
227 }
228 return ErrorCode::STATE_ERR;
229 case FormatType::DoubleScientific:
230 if constexpr (HasProfile(Profile, FormatProfile::GenericDoubleScientific) &&
231 FloatEnabled(FormatType::DoubleScientific))
232 {
233 return DispatchFloatField<FormatType::DoubleScientific, double>();
234 }
235 return ErrorCode::STATE_ERR;
236 case FormatType::FloatGeneral:
237 if constexpr (HasProfile(Profile, FormatProfile::GenericFloatGeneral) &&
238 FloatEnabled(FormatType::FloatGeneral))
239 {
240 return DispatchFloatField<FormatType::FloatGeneral, float>();
241 }
242 return ErrorCode::STATE_ERR;
243 case FormatType::DoubleGeneral:
244 if constexpr (HasProfile(Profile, FormatProfile::GenericDoubleGeneral) &&
245 FloatEnabled(FormatType::DoubleGeneral))
246 {
247 return DispatchFloatField<FormatType::DoubleGeneral, double>();
248 }
249 return ErrorCode::STATE_ERR;
250 case FormatType::LongDoubleFixed:
251 if constexpr (HasProfile(Profile, FormatProfile::GenericLongDoubleFixed) &&
252 FloatEnabled(FormatType::LongDoubleFixed))
253 {
254 return DispatchFloatField<FormatType::LongDoubleFixed, long double>();
255 }
256 return ErrorCode::STATE_ERR;
257 case FormatType::LongDoubleScientific:
258 if constexpr (HasProfile(Profile, FormatProfile::GenericLongDoubleScientific) &&
259 FloatEnabled(FormatType::LongDoubleScientific))
260 {
261 return DispatchFloatField<FormatType::LongDoubleScientific, long double>();
262 }
263 return ErrorCode::STATE_ERR;
264 case FormatType::LongDoubleGeneral:
265 if constexpr (HasProfile(Profile, FormatProfile::GenericLongDoubleGeneral) &&
266 FloatEnabled(FormatType::LongDoubleGeneral))
267 {
268 return DispatchFloatField<FormatType::LongDoubleGeneral, long double>();
269 }
270 return ErrorCode::STATE_ERR;
271#endif
272 case FormatType::TextInline:
273 case FormatType::TextRef:
274 case FormatType::TextSpace:
275 case FormatType::End:
276 default:
277 return ErrorCode::STATE_ERR;
278 }
279}
ErrorCode DispatchSignedField()
运行期执行器中 GenericField 的分发桥接函数 / GenericField dispatch bridges for the runtime executor
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 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>
template<FormatProfile Profile>
ErrorCode Writer::Executor< Sink >::DispatchOp ( FormatOp op)
nodiscardprivate

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

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

Template Parameters
Profile当前编译格式需要的操作码配置 / Opcode profile required by the current compiled format
Parameters
op解码后的运行期操作码 / Decoded runtime opcode
Returns
返回该操作码对应特化路径的运行结果 / Returns the specialized runtime result for that opcode
Template Parameters
Profile当前编译格式需要的操作码配置 / Opcode profile required by the current compiled format
Parameters
opDecoded runtime opcode. / 解码后的运行期操作码。
Returns
Returns the specialized runtime result for that opcode. / 返回该操作码对应特化路径的运行结果。

Definition at line 62 of file writer_executor_opcode.hpp.

63{
64 switch (op)
65 {
66 case FormatOp::TextInline:
67 return WriteRaw(codes_.ReadInlineText());
68 case FormatOp::TextRef:
69 return WriteRaw(codes_.ReadTextRef());
70 case FormatOp::TextSpace:
71 return WriteRaw(" ");
72 case FormatOp::U32Dec:
73 if constexpr (!HasProfile(Profile, FormatProfile::NarrowInt) ||
74 !Config::enable_integer)
75 {
76 return ErrorCode::STATE_ERR;
77 }
78 return WriteU32Dec(args_.Read<uint32_t>());
79 case FormatOp::I32Dec:
80 if constexpr (!HasProfile(Profile, FormatProfile::NarrowInt) ||
81 !Config::enable_integer)
82 {
83 return ErrorCode::STATE_ERR;
84 }
85 return WriteI32Dec(args_.Read<int32_t>());
86 case FormatOp::U32ZeroPadWidth:
87 if constexpr (!HasProfile(Profile, FormatProfile::NarrowInt) ||
88 !Config::enable_integer)
89 {
90 return ErrorCode::STATE_ERR;
91 }
92 return WriteU32ZeroPadWidth(codes_.Read<uint8_t>(), args_.Read<uint32_t>());
93 case FormatOp::U32Binary:
94 if constexpr (!HasProfile(Profile, FormatProfile::NarrowInt) ||
95 !Config::enable_integer || !Config::enable_integer_base8_16)
96 {
97 return ErrorCode::STATE_ERR;
98 }
99 return WriteU32Base<2>(args_.Read<uint32_t>());
100 case FormatOp::U32Octal:
101 if constexpr (!HasProfile(Profile, FormatProfile::NarrowInt) ||
102 !Config::enable_integer || !Config::enable_integer_base8_16)
103 {
104 return ErrorCode::STATE_ERR;
105 }
106 return WriteU32Base<8>(args_.Read<uint32_t>());
107 case FormatOp::U32HexLower:
108 if constexpr (!HasProfile(Profile, FormatProfile::NarrowInt) ||
109 !Config::enable_integer || !Config::enable_integer_base8_16)
110 {
111 return ErrorCode::STATE_ERR;
112 }
113 return WriteU32Base<16>(args_.Read<uint32_t>());
114 case FormatOp::U32HexUpper:
115 if constexpr (!HasProfile(Profile, FormatProfile::NarrowInt) ||
116 !Config::enable_integer || !Config::enable_integer_base8_16)
117 {
118 return ErrorCode::STATE_ERR;
119 }
120 return WriteU32Base<16, true>(args_.Read<uint32_t>());
121 case FormatOp::StringRaw:
122 if constexpr (!HasProfile(Profile, FormatProfile::TextArg) || !Config::enable_text)
123 {
124 return ErrorCode::STATE_ERR;
125 }
126 return WriteStringRaw(args_.Read<std::string_view>());
127 case FormatOp::CharacterRaw:
128 if constexpr (!HasProfile(Profile, FormatProfile::TextArg) || !Config::enable_text)
129 {
130 return ErrorCode::STATE_ERR;
131 }
132 return WriteCharacterRaw(args_.Read<char>());
133 case FormatOp::GenericField:
134 if constexpr (!HasProfile(Profile, FormatProfile::Generic))
135 {
136 return ErrorCode::STATE_ERR;
137 }
139 case FormatOp::End:
140 default:
141 return ErrorCode::STATE_ERR;
142 }
143}
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 WriteI32Dec(int32_t value)
单个原始 int32_t 十进制字段的快路径。 / Fast path for one raw int32_t decimal field.
ErrorCode WriteStringRaw(std::string_view text)
单个原始字符串参数的快路径。 / Fast path for one raw string argument.
ErrorCode WriteRaw(std::string_view text)
运行期执行器共享的字段写出原语,供所有操作码路径复用 / Executor-side field-writing primitives shared by all runtime opcodes
ErrorCode WriteU32Base(uint32_t value)
单个原始 uint32_t 非十进制字段的快路径。 / Fast path for one raw uint32_t non-decimal field.
ErrorCode DispatchGenericField(FormatType type)
将一个 GenericField 载荷分发到对应的宽回退路径 / Dispatch one GenericField payload to the corresponding wide fallback
ErrorCode WriteU32Dec(uint32_t value)
单个原始 uint32_t 十进制字段的快路径。 / Fast path for one raw uint32_t decimal field.
ErrorCode WriteCharacterRaw(char ch)
单个原始字符参数的快路径。 / Fast path for one raw character argument.
ErrorCode WriteU32ZeroPadWidth(uint8_t width, uint32_t value)
单个零填充 uint32_t 十进制字段的快路径。 / Fast path for one zero-padded uint32_t decimal field.

◆ DispatchPointerField()

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

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

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

Definition at line 58 of file writer_executor_generic.hpp.

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

◆ DispatchSignedField()

template<OutputSink Sink>
template<std::signed_integral Int>
ErrorCode Writer::Executor< Sink >::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 16 of file writer_executor_generic.hpp.

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

◆ DispatchStringField()

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

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

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

Definition at line 80 of file writer_executor_generic.hpp.

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

◆ DispatchUnsigned()

template<OutputSink Sink>
template<FormatType Type, std::unsigned_integral UInt>
ErrorCode Writer::Executor< Sink >::DispatchUnsigned ( 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 150 of file writer_executor_value.hpp.

151{
152 auto prefix = IntegerPrefix(Type, spec, value);
153
154 if constexpr (Type == FormatType::Unsigned32 || Type == FormatType::Unsigned64)
155 {
156 return WriteUnsignedDigits<10>(prefix, spec, value);
157 }
158 if constexpr (Type == FormatType::Binary32 || Type == FormatType::Binary64)
159 {
160 return WriteUnsignedDigits<2>(prefix, spec, value);
161 }
162 if constexpr (Type == FormatType::Octal32 || Type == FormatType::Octal64)
163 {
164 return WriteUnsignedDigits<8, false, true>(prefix, spec, value);
165 }
166 if constexpr (Type == FormatType::HexLower32 || Type == FormatType::HexLower64)
167 {
168 return WriteUnsignedDigits<16>(prefix, spec, value);
169 }
170 if constexpr (Type == FormatType::HexUpper32 || Type == FormatType::HexUpper64)
171 {
172 return WriteUnsignedDigits<16, true>(prefix, spec, value);
173 }
174
175 return ErrorCode::ARG_ERR;
176}
ErrorCode WriteUnsignedDigits(std::string_view prefix, const Spec &spec, UInt value)
按编译期进制/大小写/八进制备用格式参数复用无符号数字载荷写出逻辑 / Reuse the unsigned-digit payload writer with compile-time radix,...

◆ DispatchUnsignedField()

template<OutputSink Sink>
template<FormatType Type, std::unsigned_integral UInt>
ErrorCode Writer::Executor< Sink >::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 31 of file writer_executor_generic.hpp.

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

◆ ResolveSignChar()

template<OutputSink Sink>
template<std::signed_integral Int>
char Writer::Executor< Sink >::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 17 of file writer_executor_value.hpp.

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

◆ Run()

template<OutputSink Sink>
template<FormatProfile Profile>
ErrorCode Writer::Executor< Sink >::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.

Template Parameters
Profile当前编译格式需要的操作码配置 / Opcode profile required by the current compiled format
Returns
返回首个 sink 或运行期错误;正常执行到记录流结束时返回 ErrorCode::OK / Returns the first sink or runtime error, or ErrorCode::OK when the record stream finishes normally
Template Parameters
Profile当前编译格式需要的操作码配置 / Opcode profile required by the current compiled format
Returns
Returns ErrorCode::OK on normal completion, or the first sink / runtime error. / 正常结束返回 ErrorCode::OK;否则返回首个 sink/运行期错误。

Definition at line 33 of file writer_executor_opcode.hpp.

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

◆ WriteCharacter()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 208 of file writer_executor_value.hpp.

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

◆ WriteCharacterRaw()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::WriteCharacterRaw ( char ch)
nodiscardprivate

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

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

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

Definition at line 393 of file writer_executor_value.hpp.

394{
395 return WriteRaw(std::string_view(&ch, 1));
396}

◆ WriteFloatField()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 184 of file writer_executor_field.hpp.

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

◆ WriteI32Dec()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::WriteI32Dec ( int32_t value)
nodiscardprivate

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

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

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

Definition at line 320 of file writer_executor_value.hpp.

321{
322 using UInt = std::make_unsigned_t<int32_t>;
323 char digit_buffer[UnsignedDigitCapacity<UInt, 10>()];
324 UInt bits = static_cast<UInt>(value);
325 UInt magnitude = (value < 0) ? (UInt{0} - bits) : bits;
326 size_t digit_count = AppendUnsigned<10>(digit_buffer, magnitude);
327
328 if (value < 0)
329 {
330 if (auto ec = WriteRaw("-"); ec != ErrorCode::OK)
331 {
332 return ec;
333 }
334 }
335
336 return WriteRaw(std::string_view(digit_buffer, digit_count));
337}

◆ WriteIntegerField()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 98 of file writer_executor_field.hpp.

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

◆ WritePadding()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 27 of file writer_executor_field.hpp.

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

◆ WritePointer()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 186 of file writer_executor_value.hpp.

187{
188 char digit_buffer[UnsignedDigitCapacity<uintptr_t, 16>()];
189 size_t digit_count = AppendUnsigned<16>(digit_buffer, value);
190 Spec actual = spec;
191
192 if (!actual.HasPrecision() || actual.precision == 0)
193 {
194 actual.precision = 1;
195 }
196
197 return WriteIntegerField('\0', "0x", std::string_view(digit_buffer, digit_count),
198 actual);
199}
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>
ErrorCode Writer::Executor< Sink >::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 14 of file writer_executor_field.hpp.

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

◆ WriteSigned()

template<OutputSink Sink>
template<std::signed_integral Int>
ErrorCode Writer::Executor< Sink >::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 81 of file writer_executor_value.hpp.

82{
83 using UInt = std::make_unsigned_t<Int>;
84 char digit_buffer[UnsignedDigitCapacity<UInt, 10>()];
85 UInt bits = static_cast<UInt>(value);
86 UInt magnitude = (value < 0) ? (UInt{0} - bits) : bits;
87 size_t digit_count = AppendUnsigned<10>(digit_buffer, magnitude);
88
89 std::string_view digits(digit_buffer, digit_count);
90 if (value == 0 && spec.precision == 0)
91 {
92 digits = {};
93 }
94
95 return WriteIntegerField(ResolveSignChar(value, spec), {}, digits, spec);
96}
static char ResolveSignChar(Int value, const Spec &spec)
执行器的具体运行期数值写出函数 / Concrete runtime value writers for the executor

◆ WriteString()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 221 of file writer_executor_value.hpp.

222{
223 auto view = text;
224 if (spec.HasPrecision() && spec.precision < view.size())
225 {
226 view = view.substr(0, spec.precision);
227 }
228
229 return WriteTextField(view, spec);
230}

◆ WriteStringRaw()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 382 of file writer_executor_value.hpp.

383{
384 return WriteRaw(text);
385}

◆ WriteTextField()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 55 of file writer_executor_field.hpp.

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

◆ WriteU32Base()

template<OutputSink Sink>
template<uint8_t Base, bool UpperCase>
ErrorCode Writer::Executor< Sink >::WriteU32Base ( uint32_t value)
nodiscardprivate

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

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

Template Parameters
BaseInteger radix. / 整数进制。
UpperCaseWhether hexadecimal digits are uppercase. / 十六进制数字是否大写。
Parameters
valueUnsigned value to write. / 待写出的无符号值。
Returns
Returns the sink write result. / 返回 sink 写出结果。

Definition at line 349 of file writer_executor_value.hpp.

350{
351 char digit_buffer[UnsignedDigitCapacity<uint32_t, Base>()];
352 size_t digit_count = AppendUnsigned<Base, UpperCase>(digit_buffer, value);
353 return WriteRaw(std::string_view(digit_buffer, digit_count));
354}

◆ WriteU32Dec()

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

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

通过共享浮点文本后端写出一个浮点语义值 / 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

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

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

Definition at line 306 of file writer_executor_value.hpp.

307{
308 char digit_buffer[UnsignedDigitCapacity<uint32_t, 10>()];
309 size_t digit_count = AppendUnsigned<10>(digit_buffer, value);
310 return WriteRaw(std::string_view(digit_buffer, digit_count));
311}

◆ WriteU32ZeroPadWidth()

template<OutputSink Sink>
ErrorCode Writer::Executor< Sink >::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 364 of file writer_executor_value.hpp.

365{
366 char digit_buffer[UnsignedDigitCapacity<uint32_t, 10>()];
367 size_t digit_count = AppendUnsigned<10>(digit_buffer, value);
368 size_t zeros = FieldPadding(width, digit_count);
369 if (auto ec = WritePadding('0', zeros); ec != ErrorCode::OK)
370 {
371 return ec;
372 }
373 return WriteRaw(std::string_view(digit_buffer, digit_count));
374}

◆ WriteUnsignedDigits()

template<OutputSink Sink>
template<uint8_t Base, bool UpperCase, bool PrependOctalZero, std::unsigned_integral UInt>
ErrorCode Writer::Executor< Sink >::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
PrependOctalZero是否把 %#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
PrependOctalZero是否把 %#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 115 of file writer_executor_value.hpp.

117{
118 char digit_buffer[UnsignedDigitCapacity<UInt, Base>() + (PrependOctalZero ? 1U : 0U)];
119 size_t digit_count = AppendUnsigned<Base, UpperCase>(digit_buffer, value);
120
121 if constexpr (PrependOctalZero)
122 {
123 digit_count = ApplyAlternateOctal(digit_buffer, digit_count, spec, value);
124 }
125 else if (value == 0 && spec.precision == 0)
126 {
127 digit_count = 0;
128 }
129
130 return WriteIntegerField('\0', prefix, std::string_view(digit_buffer, digit_count),
131 spec);
132}

Field Documentation

◆ args_

template<OutputSink Sink>
ArgumentReader Writer::Executor< Sink >::args_
private

Definition at line 172 of file writer_executor.hpp.

◆ codes_

template<OutputSink Sink>
CodeReader Writer::Executor< Sink >::codes_
private

Definition at line 171 of file writer_executor.hpp.

◆ sink_

template<OutputSink Sink>
Sink& Writer::Executor< Sink >::sink_
private

Definition at line 170 of file writer_executor.hpp.


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