libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
writer_executor_generic.hpp
1#pragma once
2
14template <OutputSink Sink>
15template <std::signed_integral Int>
17{
18 return WriteSigned(codes_.ReadSpec(), args_.Read<Int>());
19}
20
29template <OutputSink Sink>
30template <FormatType Type, std::unsigned_integral UInt>
32{
33 return DispatchUnsigned<Type>(codes_.ReadSpec(), args_.Read<UInt>());
34}
35
36#if LIBXR_PRINT_ENABLE_FLOAT
44template <OutputSink Sink>
45template <FormatType Type, typename Float>
47{
48 return WriteFloat(Type, codes_.ReadSpec(), args_.Read<Float>());
49}
50#endif
51
57template <OutputSink Sink>
59{
60 return WritePointer(codes_.ReadSpec(), args_.Read<uintptr_t>());
61}
62
68template <OutputSink Sink>
70{
71 return WriteCharacter(codes_.ReadSpec(), args_.Read<char>());
72}
73
79template <OutputSink Sink>
81{
82 return WriteString(codes_.ReadSpec(), args_.Read<std::string_view>());
83}
84
92template <OutputSink Sink>
93template <FormatProfile Profile>
95{
96 switch (type)
97 {
98 case FormatType::Signed32:
99 if constexpr (HasProfile(Profile, FormatProfile::GenericSigned32) &&
100 Config::enable_integer)
101 {
102 return DispatchSignedField<int32_t>();
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 {
109 return DispatchSignedField<int64_t>();
110 }
111 return ErrorCode::STATE_ERR;
112 case FormatType::Unsigned32:
113 if constexpr (HasProfile(Profile, FormatProfile::GenericUnsigned32) &&
114 Config::enable_integer)
115 {
116 return DispatchUnsignedField<FormatType::Unsigned32, uint32_t>();
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 {
123 return DispatchUnsignedField<FormatType::Unsigned64, uint64_t>();
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 {
130 return DispatchUnsignedField<FormatType::Binary32, uint32_t>();
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 {
138 return DispatchUnsignedField<FormatType::Binary64, uint64_t>();
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 {
145 return DispatchUnsignedField<FormatType::Octal32, uint32_t>();
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 {
153 return DispatchUnsignedField<FormatType::Octal64, uint64_t>();
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 {
160 return DispatchUnsignedField<FormatType::HexLower32, uint32_t>();
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 {
168 return DispatchUnsignedField<FormatType::HexLower64, uint64_t>();
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 {
175 return DispatchUnsignedField<FormatType::HexUpper32, uint32_t>();
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 {
183 return DispatchUnsignedField<FormatType::HexUpper64, uint64_t>();
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}
按输出端共享重后端、按调用点 profile 裁剪操作码分发的字节码执行器 / Per-sink bytecode executor with shared heavy backends and per...
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 DispatchGenericField(FormatType type)
将一个 GenericField 载荷分发到对应的宽回退路径 / Dispatch one GenericField payload to the corresponding wide fallback
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