libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
writer_executor_generic.hpp
1#pragma once
2
12template <OutputSink Sink, FormatProfile Profile>
13template <std::signed_integral Int>
15{
16 return WriteSigned(codes_.ReadSpec(), args_.Read<Int>());
17}
18
25template <OutputSink Sink, FormatProfile Profile>
26template <FormatType Type, std::unsigned_integral UInt>
28{
29 return WriteUnsigned<Type>(codes_.ReadSpec(), args_.Read<UInt>());
30}
31
38template <OutputSink Sink, FormatProfile Profile>
39template <FormatType Type, typename Float>
41{
42 return WriteFloat(Type, codes_.ReadSpec(), args_.Read<Float>());
43}
44
49template <OutputSink Sink, FormatProfile Profile>
51{
52 return WritePointer(codes_.ReadSpec(), args_.Read<uintptr_t>());
53}
54
59template <OutputSink Sink, FormatProfile Profile>
61{
62 return WriteCharacter(codes_.ReadSpec(), args_.Read<char>());
63}
64
69template <OutputSink Sink, FormatProfile Profile>
71{
72 return WriteString(codes_.ReadSpec(), args_.Read<std::string_view>());
73}
74
80template <OutputSink Sink, FormatProfile Profile>
82{
83 switch (type)
84 {
85 case FormatType::Signed32:
86 if constexpr (!Config::enable_integer)
87 {
88 return ErrorCode::STATE_ERR;
89 }
90 return DispatchSignedField<int32_t>();
91 case FormatType::Signed64:
92 if constexpr (!Config::enable_integer || !Config::enable_integer_64bit)
93 {
94 return ErrorCode::STATE_ERR;
95 }
96 return DispatchSignedField<int64_t>();
97 case FormatType::Unsigned32:
98 if constexpr (!Config::enable_integer)
99 {
100 return ErrorCode::STATE_ERR;
101 }
102 return DispatchUnsignedField<FormatType::Unsigned32, uint32_t>();
103 case FormatType::Unsigned64:
104 if constexpr (!Config::enable_integer || !Config::enable_integer_64bit)
105 {
106 return ErrorCode::STATE_ERR;
107 }
108 return DispatchUnsignedField<FormatType::Unsigned64, uint64_t>();
109 case FormatType::Binary32:
110 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
111 {
112 return ErrorCode::STATE_ERR;
113 }
114 return DispatchUnsignedField<FormatType::Binary32, uint32_t>();
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 }
121 return DispatchUnsignedField<FormatType::Binary64, uint64_t>();
122 case FormatType::Octal32:
123 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
124 {
125 return ErrorCode::STATE_ERR;
126 }
127 return DispatchUnsignedField<FormatType::Octal32, uint32_t>();
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 }
134 return DispatchUnsignedField<FormatType::Octal64, uint64_t>();
135 case FormatType::HexLower32:
136 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
137 {
138 return ErrorCode::STATE_ERR;
139 }
140 return DispatchUnsignedField<FormatType::HexLower32, uint32_t>();
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 }
147 return DispatchUnsignedField<FormatType::HexLower64, uint64_t>();
148 case FormatType::HexUpper32:
149 if constexpr (!Config::enable_integer || !Config::enable_integer_base8_16)
150 {
151 return ErrorCode::STATE_ERR;
152 }
153 return DispatchUnsignedField<FormatType::HexUpper32, uint32_t>();
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 }
160 return DispatchUnsignedField<FormatType::HexUpper64, uint64_t>();
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 }
184 return DispatchFloatField<FormatType::FloatFixed, float>();
185 case FormatType::DoubleFixed:
186 if constexpr (!FloatEnabled(FormatType::DoubleFixed))
187 {
188 return ErrorCode::STATE_ERR;
189 }
190 return DispatchFloatField<FormatType::DoubleFixed, double>();
191 case FormatType::FloatScientific:
192 if constexpr (!FloatEnabled(FormatType::FloatScientific))
193 {
194 return ErrorCode::STATE_ERR;
195 }
196 return DispatchFloatField<FormatType::FloatScientific, float>();
197 case FormatType::DoubleScientific:
198 if constexpr (!FloatEnabled(FormatType::DoubleScientific))
199 {
200 return ErrorCode::STATE_ERR;
201 }
202 return DispatchFloatField<FormatType::DoubleScientific, double>();
203 case FormatType::FloatGeneral:
204 if constexpr (!FloatEnabled(FormatType::FloatGeneral))
205 {
206 return ErrorCode::STATE_ERR;
207 }
208 return DispatchFloatField<FormatType::FloatGeneral, float>();
209 case FormatType::DoubleGeneral:
210 if constexpr (!FloatEnabled(FormatType::DoubleGeneral))
211 {
212 return ErrorCode::STATE_ERR;
213 }
214 return DispatchFloatField<FormatType::DoubleGeneral, double>();
215 case FormatType::LongDoubleFixed:
216 if constexpr (!FloatEnabled(FormatType::LongDoubleFixed))
217 {
218 return ErrorCode::STATE_ERR;
219 }
220 return DispatchFloatField<FormatType::LongDoubleFixed, long double>();
221 case FormatType::LongDoubleScientific:
222 if constexpr (!FloatEnabled(FormatType::LongDoubleScientific))
223 {
224 return ErrorCode::STATE_ERR;
225 }
226 return DispatchFloatField<FormatType::LongDoubleScientific, long double>();
227 case FormatType::LongDoubleGeneral:
228 if constexpr (!FloatEnabled(FormatType::LongDoubleGeneral))
229 {
230 return ErrorCode::STATE_ERR;
231 }
232 return DispatchFloatField<FormatType::LongDoubleGeneral, long double>();
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 DispatchGenericField(FormatType type)
将一个 GenericField 载荷分发到对应的宽回退路径 / Dispatch one GenericField payload to the corresponding wide fallback
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