Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef ZSERIO_REFLECTABLE_H_INC |
2 | | #define ZSERIO_REFLECTABLE_H_INC |
3 | | |
4 | | #include <functional> |
5 | | #include <type_traits> |
6 | | |
7 | | #include "zserio/AllocatorHolder.h" |
8 | | #include "zserio/BitSizeOfCalculator.h" |
9 | | #include "zserio/CppRuntimeException.h" |
10 | | #include "zserio/IReflectable.h" |
11 | | #include "zserio/Span.h" |
12 | | #include "zserio/StringConvertUtil.h" |
13 | | #include "zserio/Traits.h" |
14 | | #include "zserio/TypeInfo.h" |
15 | | #include "zserio/TypeInfoUtil.h" |
16 | | #include "zserio/Types.h" |
17 | | |
18 | | namespace zserio |
19 | | { |
20 | | |
21 | | /** |
22 | | * Base class for all reflectable implementations. |
23 | | * |
24 | | * Implements the find() feature and overrides all generic methods except of write() and bitSizeOf() with |
25 | | * default throw behavior. |
26 | | */ |
27 | | template <typename ALLOC> |
28 | | class ReflectableBase : public IBasicReflectable<ALLOC> |
29 | | { |
30 | | public: |
31 | | /** |
32 | | * Constructor. |
33 | | * |
34 | | * \param typeInfo Type info of the reflected object. |
35 | | */ |
36 | | explicit ReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo); |
37 | | |
38 | | /** Destructor. */ |
39 | 1.68k | ~ReflectableBase() override = 0; |
40 | | |
41 | | /** |
42 | | * Copying and moving is disallowed! |
43 | | * \{ |
44 | | */ |
45 | | ReflectableBase(const ReflectableBase&) = delete; |
46 | | ReflectableBase& operator=(const ReflectableBase&) = delete; |
47 | | |
48 | | ReflectableBase(const ReflectableBase&&) = delete; |
49 | | ReflectableBase& operator=(const ReflectableBase&&) = delete; |
50 | | /** |
51 | | * \} |
52 | | */ |
53 | | |
54 | | const IBasicTypeInfo<ALLOC>& getTypeInfo() const override; |
55 | | bool isArray() const override; |
56 | | |
57 | | void initializeChildren() override; |
58 | | void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) override; |
59 | | size_t initializeOffsets(size_t bitPosition) override; |
60 | | size_t initializeOffsets() override; |
61 | | size_t bitSizeOf(size_t bitPosition) const override; |
62 | | size_t bitSizeOf() const override; |
63 | | void write(BitStreamWriter& writer) const override; |
64 | | |
65 | | IBasicReflectableConstPtr<ALLOC> getField(StringView name) const override; |
66 | | IBasicReflectablePtr<ALLOC> getField(StringView name) override; |
67 | | IBasicReflectablePtr<ALLOC> createField(StringView name) override; |
68 | | void setField(StringView name, const AnyHolder<ALLOC>& value) override; |
69 | | IBasicReflectableConstPtr<ALLOC> getParameter(StringView name) const override; |
70 | | IBasicReflectablePtr<ALLOC> getParameter(StringView name) override; |
71 | | IBasicReflectableConstPtr<ALLOC> callFunction(StringView name) const override; |
72 | | IBasicReflectablePtr<ALLOC> callFunction(StringView name) override; |
73 | | |
74 | | StringView getChoice() const override; |
75 | | |
76 | | IBasicReflectableConstPtr<ALLOC> find(StringView path) const override; |
77 | | IBasicReflectablePtr<ALLOC> find(StringView path) override; |
78 | | IBasicReflectableConstPtr<ALLOC> operator[](StringView path) const override; |
79 | | IBasicReflectablePtr<ALLOC> operator[](StringView path) override; |
80 | | |
81 | | size_t size() const override; |
82 | | void resize(size_t size) override; |
83 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override; |
84 | | IBasicReflectablePtr<ALLOC> at(size_t index) override; |
85 | | IBasicReflectableConstPtr<ALLOC> operator[](size_t index) const override; |
86 | | IBasicReflectablePtr<ALLOC> operator[](size_t index) override; |
87 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override; |
88 | | void append(const AnyHolder<ALLOC>& value) override; |
89 | | |
90 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override; |
91 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override; |
92 | | AnyHolder<ALLOC> getAnyValue() const override; |
93 | | AnyHolder<ALLOC> getAnyValue() override; |
94 | | |
95 | | // exact checked getters |
96 | | bool getBool() const override; |
97 | | int8_t getInt8() const override; |
98 | | int16_t getInt16() const override; |
99 | | int32_t getInt32() const override; |
100 | | int64_t getInt64() const override; |
101 | | uint8_t getUInt8() const override; |
102 | | uint16_t getUInt16() const override; |
103 | | uint32_t getUInt32() const override; |
104 | | uint64_t getUInt64() const override; |
105 | | float getFloat() const override; |
106 | | double getDouble() const override; |
107 | | Span<const uint8_t> getBytes() const override; |
108 | | StringView getStringView() const override; |
109 | | const BasicBitBuffer<ALLOC>& getBitBuffer() const override; |
110 | | |
111 | | // convenience conversions |
112 | | int64_t toInt() const override; |
113 | | uint64_t toUInt() const override; |
114 | | double toDouble() const override; |
115 | | string<ALLOC> toString(const ALLOC& allocator) const override; |
116 | | string<ALLOC> toString() const override; |
117 | | |
118 | | const ParsingInfo& parsingInfo() const override; |
119 | | |
120 | | private: |
121 | | const IBasicTypeInfo<ALLOC>& m_typeInfo; |
122 | | }; |
123 | | |
124 | | /** |
125 | | * Base class for all builtin reflectables. |
126 | | */ |
127 | | template <typename ALLOC, typename T, typename = void> |
128 | | class BuiltinReflectableBase : public ReflectableBase<ALLOC> |
129 | | { |
130 | | private: |
131 | | using Base = ReflectableBase<ALLOC>; |
132 | | |
133 | | protected: |
134 | | BuiltinReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo, const T& value) : |
135 | | Base(typeInfo), |
136 | | m_value(value) |
137 | 32 | {} |
138 | | |
139 | | const T& getValue() const |
140 | 52 | { |
141 | 52 | return m_value; |
142 | 52 | } |
143 | | |
144 | | public: |
145 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
146 | 4 | { |
147 | 4 | return AnyHolder<ALLOC>(std::cref(getValue()), allocator); |
148 | 4 | } |
149 | | |
150 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
151 | 4 | { |
152 | | // we have only const reference, thus return it |
153 | 4 | return AnyHolder<ALLOC>(std::cref(getValue()), allocator); |
154 | 4 | } |
155 | | |
156 | | private: |
157 | | const T& m_value; |
158 | | }; |
159 | | |
160 | | /** |
161 | | * Specialization of the BuiltinReflectableBase base class for numeric (arithmetic) types, string view and span. |
162 | | * |
163 | | * Hold the value instead of reference. |
164 | | */ |
165 | | template <typename ALLOC, typename T> |
166 | | class BuiltinReflectableBase<ALLOC, T, |
167 | | typename std::enable_if<std::is_arithmetic<T>::value || std::is_same<T, StringView>::value || |
168 | | is_span<T>::value>::type> : public ReflectableBase<ALLOC> |
169 | | { |
170 | | private: |
171 | | using Base = ReflectableBase<ALLOC>; |
172 | | |
173 | | protected: |
174 | | BuiltinReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo, T value) : |
175 | | Base(typeInfo), |
176 | | m_value(value) |
177 | 851 | {} |
178 | | |
179 | | T getValue() const |
180 | 2.06k | { |
181 | 2.06k | return m_value; |
182 | 2.06k | } |
183 | | |
184 | | public: |
185 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
186 | 174 | { |
187 | 174 | return AnyHolder<ALLOC>(m_value, allocator); |
188 | 174 | } |
189 | | |
190 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
191 | 99 | { |
192 | 99 | return AnyHolder<ALLOC>(m_value, allocator); |
193 | 99 | } |
194 | | |
195 | | private: |
196 | | T m_value; |
197 | | }; |
198 | | |
199 | | /** |
200 | | * Base class for integral reflectables. |
201 | | * |
202 | | * Implements toString() and toDouble() conversions, implements write() for all integral builtin types. |
203 | | * |
204 | | * Hold dynamic bit size even though it has sense only for dynamic bit fields (otherwise it's always set to 0). |
205 | | * This solution was chosen for simplicity. |
206 | | */ |
207 | | template <typename ALLOC, typename T> |
208 | | class IntegralReflectableBase : public BuiltinReflectableBase<ALLOC, T> |
209 | | { |
210 | | protected: |
211 | | static_assert(std::is_integral<T>::value, "T must be a signed integral type!"); |
212 | | |
213 | | using Base = BuiltinReflectableBase<ALLOC, T>; |
214 | | |
215 | | public: |
216 | | IntegralReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo, T value) : |
217 | | Base(typeInfo, value) |
218 | 592 | {} |
219 | | |
220 | | double toDouble() const override |
221 | 243 | { |
222 | 243 | return static_cast<double>(Base::getValue()); |
223 | 243 | } |
224 | | |
225 | | string<ALLOC> toString(const ALLOC& allocator) const override |
226 | 232 | { |
227 | 232 | return ::zserio::toString<ALLOC>(Base::getValue(), allocator); |
228 | 232 | } |
229 | | }; |
230 | | |
231 | | /** |
232 | | * Base class for signed integral reflectables. |
233 | | * |
234 | | * Implements toInt() conversion. |
235 | | */ |
236 | | template <typename ALLOC, typename T> |
237 | | class SignedReflectableBase : public IntegralReflectableBase<ALLOC, T> |
238 | | { |
239 | | protected: |
240 | | static_assert(std::is_signed<T>::value, "T must be a signed integral type!"); |
241 | | |
242 | | using Base = IntegralReflectableBase<ALLOC, T>; |
243 | | |
244 | | using Base::Base; |
245 | | |
246 | | public: |
247 | | int64_t toInt() const override |
248 | 150 | { |
249 | 150 | return Base::getValue(); |
250 | 150 | } |
251 | | }; |
252 | | |
253 | | /** |
254 | | * Base class for unsigned integral reflectables. |
255 | | * |
256 | | * Implements toUInt() conversion. |
257 | | */ |
258 | | template <typename ALLOC, typename T> |
259 | | class UnsignedReflectableBase : public IntegralReflectableBase<ALLOC, T> |
260 | | { |
261 | | protected: |
262 | | static_assert(std::is_unsigned<T>::value, "T must be an unsigned integral type!"); |
263 | | |
264 | | using Base = IntegralReflectableBase<ALLOC, T>; |
265 | | |
266 | | using Base::Base; |
267 | | |
268 | | public: |
269 | | uint64_t toUInt() const override |
270 | 233 | { |
271 | 233 | return Base::getValue(); |
272 | 233 | } |
273 | | }; |
274 | | |
275 | | /** |
276 | | * Reflectable for values of bool type. |
277 | | */ |
278 | | template <typename ALLOC> |
279 | | class BoolReflectable : public UnsignedReflectableBase<ALLOC, bool> |
280 | | { |
281 | | private: |
282 | | using Base = UnsignedReflectableBase<ALLOC, bool>; |
283 | | |
284 | | public: |
285 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
286 | 23 | { |
287 | 23 | return BuiltinTypeInfo<ALLOC>::getBool(); |
288 | 23 | } |
289 | | |
290 | | explicit BoolReflectable(bool value) : |
291 | | Base(typeInfo(), value) |
292 | 21 | {} |
293 | | |
294 | | size_t bitSizeOf(size_t) const override |
295 | 9 | { |
296 | 9 | return 1; |
297 | 9 | } |
298 | | |
299 | | void write(BitStreamWriter& writer) const override |
300 | 9 | { |
301 | 9 | writer.writeBool(Base::getValue()); |
302 | 9 | } |
303 | | |
304 | | bool getBool() const override |
305 | 27 | { |
306 | 27 | return Base::getValue(); |
307 | 27 | } |
308 | | }; |
309 | | |
310 | | /** |
311 | | * Base class for 8-bit signed integral reflectables. |
312 | | * |
313 | | * Implements getInt8() conversion. |
314 | | */ |
315 | | template <typename ALLOC> |
316 | | class Int8ReflectableBase : public SignedReflectableBase<ALLOC, int8_t> |
317 | | { |
318 | | protected: |
319 | | using Base = SignedReflectableBase<ALLOC, int8_t>; |
320 | | |
321 | | using Base::Base; |
322 | | |
323 | | public: |
324 | | int8_t getInt8() const override |
325 | 96 | { |
326 | 96 | return Base::getValue(); |
327 | 96 | } |
328 | | }; |
329 | | |
330 | | /** |
331 | | * Base class for 16-bit signed integral reflectables. |
332 | | * |
333 | | * Implements getInt16() conversion. |
334 | | */ |
335 | | template <typename ALLOC> |
336 | | class Int16ReflectableBase : public SignedReflectableBase<ALLOC, int16_t> |
337 | | { |
338 | | protected: |
339 | | using Base = SignedReflectableBase<ALLOC, int16_t>; |
340 | | |
341 | | using Base::Base; |
342 | | |
343 | | public: |
344 | | int16_t getInt16() const override |
345 | 40 | { |
346 | 40 | return Base::getValue(); |
347 | 40 | } |
348 | | }; |
349 | | |
350 | | /** |
351 | | * Base class for 32-bit signed integral reflectables. |
352 | | * |
353 | | * Implements getInt32() conversion. |
354 | | */ |
355 | | template <typename ALLOC> |
356 | | class Int32ReflectableBase : public SignedReflectableBase<ALLOC, int32_t> |
357 | | { |
358 | | protected: |
359 | | using Base = SignedReflectableBase<ALLOC, int32_t>; |
360 | | |
361 | | using Base::Base; |
362 | | |
363 | | public: |
364 | | int32_t getInt32() const override |
365 | 55 | { |
366 | 55 | return Base::getValue(); |
367 | 55 | } |
368 | | }; |
369 | | |
370 | | /** |
371 | | * Base class for 64-bit signed integral reflectables. |
372 | | * |
373 | | * Implements getInt64() conversion. |
374 | | */ |
375 | | template <typename ALLOC> |
376 | | class Int64ReflectableBase : public SignedReflectableBase<ALLOC, int64_t> |
377 | | { |
378 | | protected: |
379 | | using Base = SignedReflectableBase<ALLOC, int64_t>; |
380 | | |
381 | | using Base::Base; |
382 | | |
383 | | public: |
384 | | int64_t getInt64() const override |
385 | 58 | { |
386 | 58 | return Base::getValue(); |
387 | 58 | } |
388 | | }; |
389 | | |
390 | | /** |
391 | | * Base class for 8-bit unsigned integral reflectables. |
392 | | * |
393 | | * Implements getUInt8() conversion. |
394 | | */ |
395 | | template <typename ALLOC> |
396 | | class UInt8ReflectableBase : public UnsignedReflectableBase<ALLOC, uint8_t> |
397 | | { |
398 | | protected: |
399 | | using Base = UnsignedReflectableBase<ALLOC, uint8_t>; |
400 | | |
401 | | using Base::Base; |
402 | | |
403 | | public: |
404 | | uint8_t getUInt8() const override |
405 | 62 | { |
406 | 62 | return Base::getValue(); |
407 | 62 | } |
408 | | }; |
409 | | |
410 | | /** |
411 | | * Base class for 16-bit unsigned integral reflectables. |
412 | | * |
413 | | * Implements getUInt16() conversion. |
414 | | */ |
415 | | template <typename ALLOC> |
416 | | class UInt16ReflectableBase : public UnsignedReflectableBase<ALLOC, uint16_t> |
417 | | { |
418 | | protected: |
419 | | using Base = UnsignedReflectableBase<ALLOC, uint16_t>; |
420 | | |
421 | | using Base::Base; |
422 | | |
423 | | public: |
424 | | uint16_t getUInt16() const override |
425 | 40 | { |
426 | 40 | return Base::getValue(); |
427 | 40 | } |
428 | | }; |
429 | | |
430 | | /** |
431 | | * Base class for 32-bit unsigned integral reflectables. |
432 | | * |
433 | | * Implements getUInt32() conversion. |
434 | | */ |
435 | | template <typename ALLOC> |
436 | | class UInt32ReflectableBase : public UnsignedReflectableBase<ALLOC, uint32_t> |
437 | | { |
438 | | protected: |
439 | | using Base = UnsignedReflectableBase<ALLOC, uint32_t>; |
440 | | |
441 | | using Base::Base; |
442 | | |
443 | | public: |
444 | | uint32_t getUInt32() const override |
445 | 111 | { |
446 | 111 | return Base::getValue(); |
447 | 111 | } |
448 | | }; |
449 | | |
450 | | /** |
451 | | * Base class for 64-bit unsigned integral reflectables. |
452 | | * |
453 | | * Implements getUInt64() conversion. |
454 | | */ |
455 | | template <typename ALLOC> |
456 | | class UInt64ReflectableBase : public UnsignedReflectableBase<ALLOC, uint64_t> |
457 | | { |
458 | | protected: |
459 | | using Base = UnsignedReflectableBase<ALLOC, uint64_t>; |
460 | | |
461 | | using Base::Base; |
462 | | |
463 | | public: |
464 | | uint64_t getUInt64() const override |
465 | 58 | { |
466 | 58 | return Base::getValue(); |
467 | 58 | } |
468 | | }; |
469 | | |
470 | | /** |
471 | | * Reflectable for int8 type. |
472 | | */ |
473 | | template <typename ALLOC> |
474 | | class Int8Reflectable : public Int8ReflectableBase<ALLOC> |
475 | | { |
476 | | private: |
477 | | using Base = Int8ReflectableBase<ALLOC>; |
478 | | |
479 | | public: |
480 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
481 | 32 | { |
482 | 32 | return BuiltinTypeInfo<ALLOC>::getInt8(); |
483 | 32 | } |
484 | | |
485 | | explicit Int8Reflectable(int8_t value) : |
486 | | Base(typeInfo(), value) |
487 | 30 | {} |
488 | | |
489 | | size_t bitSizeOf(size_t) const override |
490 | 13 | { |
491 | 13 | return 8; |
492 | 13 | } |
493 | | |
494 | | void write(BitStreamWriter& writer) const override |
495 | 13 | { |
496 | 13 | writer.writeSignedBits(Base::getValue(), 8); |
497 | 13 | } |
498 | | }; |
499 | | |
500 | | /** |
501 | | * Reflectable for int16 type. |
502 | | */ |
503 | | template <typename ALLOC> |
504 | | class Int16Reflectable : public Int16ReflectableBase<ALLOC> |
505 | | { |
506 | | private: |
507 | | using Base = Int16ReflectableBase<ALLOC>; |
508 | | |
509 | | public: |
510 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
511 | 22 | { |
512 | 22 | return BuiltinTypeInfo<ALLOC>::getInt16(); |
513 | 22 | } |
514 | | |
515 | | explicit Int16Reflectable(int16_t value) : |
516 | | Base(typeInfo(), value) |
517 | 20 | {} |
518 | | |
519 | | size_t bitSizeOf(size_t) const override |
520 | 9 | { |
521 | 9 | return 16; |
522 | 9 | } |
523 | | |
524 | | void write(BitStreamWriter& writer) const override |
525 | 9 | { |
526 | 9 | writer.writeSignedBits(Base::getValue(), 16); |
527 | 9 | } |
528 | | }; |
529 | | |
530 | | /** |
531 | | * Reflectable for int32 type. |
532 | | */ |
533 | | template <typename ALLOC> |
534 | | class Int32Reflectable : public Int32ReflectableBase<ALLOC> |
535 | | { |
536 | | private: |
537 | | using Base = Int32ReflectableBase<ALLOC>; |
538 | | |
539 | | public: |
540 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
541 | 25 | { |
542 | 25 | return BuiltinTypeInfo<ALLOC>::getInt32(); |
543 | 25 | } |
544 | | |
545 | | explicit Int32Reflectable(int32_t value) : |
546 | | Base(typeInfo(), value) |
547 | 23 | {} |
548 | | |
549 | | size_t bitSizeOf(size_t) const override |
550 | 9 | { |
551 | 9 | return 32; |
552 | 9 | } |
553 | | |
554 | | void write(BitStreamWriter& writer) const override |
555 | 9 | { |
556 | 9 | writer.writeSignedBits(Base::getValue(), 32); |
557 | 9 | } |
558 | | }; |
559 | | |
560 | | /** |
561 | | * Reflectable for int64 type. |
562 | | */ |
563 | | template <typename ALLOC> |
564 | | class Int64Reflectable : public Int64ReflectableBase<ALLOC> |
565 | | { |
566 | | private: |
567 | | using Base = Int64ReflectableBase<ALLOC>; |
568 | | |
569 | | public: |
570 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
571 | 21 | { |
572 | 21 | return BuiltinTypeInfo<ALLOC>::getInt64(); |
573 | 21 | } |
574 | | |
575 | | explicit Int64Reflectable(int64_t value) : |
576 | | Base(typeInfo(), value) |
577 | 19 | {} |
578 | | |
579 | | size_t bitSizeOf(size_t) const override |
580 | 9 | { |
581 | 9 | return 64; |
582 | 9 | } |
583 | | |
584 | | void write(BitStreamWriter& writer) const override |
585 | 9 | { |
586 | 9 | writer.writeSignedBits64(Base::getValue(), 64); |
587 | 9 | } |
588 | | }; |
589 | | |
590 | | /** |
591 | | * Reflectable for uint8 type. |
592 | | */ |
593 | | template <typename ALLOC> |
594 | | class UInt8Reflectable : public UInt8ReflectableBase<ALLOC> |
595 | | { |
596 | | private: |
597 | | using Base = UInt8ReflectableBase<ALLOC>; |
598 | | |
599 | | public: |
600 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
601 | 47 | { |
602 | 47 | return BuiltinTypeInfo<ALLOC>::getUInt8(); |
603 | 47 | } |
604 | | |
605 | | explicit UInt8Reflectable(uint8_t value) : |
606 | | Base(typeInfo(), value) |
607 | 43 | {} |
608 | | |
609 | | size_t bitSizeOf(size_t) const override |
610 | 9 | { |
611 | 9 | return 8; |
612 | 9 | } |
613 | | |
614 | | void write(BitStreamWriter& writer) const override |
615 | 9 | { |
616 | 9 | writer.writeBits(Base::getValue(), 8); |
617 | 9 | } |
618 | | }; |
619 | | |
620 | | /** |
621 | | * Reflectable for uint16 type. |
622 | | */ |
623 | | template <typename ALLOC> |
624 | | class UInt16Reflectable : public UInt16ReflectableBase<ALLOC> |
625 | | { |
626 | | private: |
627 | | using Base = UInt16ReflectableBase<ALLOC>; |
628 | | |
629 | | public: |
630 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
631 | 21 | { |
632 | 21 | return BuiltinTypeInfo<ALLOC>::getUInt16(); |
633 | 21 | } |
634 | | |
635 | | explicit UInt16Reflectable(uint16_t value) : |
636 | | Base(typeInfo(), value) |
637 | 19 | {} |
638 | | |
639 | | size_t bitSizeOf(size_t) const override |
640 | 9 | { |
641 | 9 | return 16; |
642 | 9 | } |
643 | | |
644 | | void write(BitStreamWriter& writer) const override |
645 | 9 | { |
646 | 9 | writer.writeBits(Base::getValue(), 16); |
647 | 9 | } |
648 | | }; |
649 | | |
650 | | /** |
651 | | * Reflectable for uint32 type. |
652 | | */ |
653 | | template <typename ALLOC> |
654 | | class UInt32Reflectable : public UInt32ReflectableBase<ALLOC> |
655 | | { |
656 | | private: |
657 | | using Base = UInt32ReflectableBase<ALLOC>; |
658 | | |
659 | | public: |
660 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
661 | 107 | { |
662 | 107 | return BuiltinTypeInfo<ALLOC>::getUInt32(); |
663 | 107 | } |
664 | | |
665 | | explicit UInt32Reflectable(uint32_t value) : |
666 | | Base(typeInfo(), value) |
667 | 96 | {} |
668 | | |
669 | | size_t bitSizeOf(size_t) const override |
670 | 9 | { |
671 | 9 | return 32; |
672 | 9 | } |
673 | | |
674 | | void write(BitStreamWriter& writer) const override |
675 | 9 | { |
676 | 9 | writer.writeBits(Base::getValue(), 32); |
677 | 9 | } |
678 | | }; |
679 | | |
680 | | /** |
681 | | * Reflectable for uint64 type. |
682 | | */ |
683 | | template <typename ALLOC> |
684 | | class UInt64Reflectable : public UInt64ReflectableBase<ALLOC> |
685 | | { |
686 | | private: |
687 | | using Base = UInt64ReflectableBase<ALLOC>; |
688 | | |
689 | | public: |
690 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
691 | 22 | { |
692 | 22 | return BuiltinTypeInfo<ALLOC>::getUInt64(); |
693 | 22 | } |
694 | | |
695 | | explicit UInt64Reflectable(uint64_t value) : |
696 | | Base(typeInfo(), value) |
697 | 20 | {} |
698 | | |
699 | | size_t bitSizeOf(size_t) const override |
700 | 9 | { |
701 | 9 | return 64; |
702 | 9 | } |
703 | | |
704 | | void write(BitStreamWriter& writer) const override |
705 | 9 | { |
706 | 9 | writer.writeBits64(Base::getValue(), 64); |
707 | 9 | } |
708 | | }; |
709 | | |
710 | | template <typename ALLOC, typename T> |
711 | | class FixedSignedBitFieldReflectable; |
712 | | |
713 | | template <typename ALLOC> |
714 | | class FixedSignedBitFieldReflectable<ALLOC, int8_t> : public Int8ReflectableBase<ALLOC> |
715 | | { |
716 | | private: |
717 | | using Base = Int8ReflectableBase<ALLOC>; |
718 | | |
719 | | public: |
720 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
721 | 21 | { |
722 | 21 | return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize); |
723 | 21 | } |
724 | | |
725 | | FixedSignedBitFieldReflectable(int8_t value, uint8_t bitSize) : |
726 | | Base(typeInfo(bitSize), value) |
727 | 19 | { |
728 | 19 | if (bitSize > 8) |
729 | 1 | { |
730 | 1 | throw CppRuntimeException("FixedSignedBitFieldReflectable ") |
731 | 1 | << " - invalid bit size '" << bitSize << "' for 'int8_t' value!"; |
732 | 1 | } |
733 | 19 | } |
734 | | |
735 | | size_t bitSizeOf(size_t) const override |
736 | 16 | { |
737 | 16 | return Base::getTypeInfo().getBitSize(); |
738 | 16 | } |
739 | | |
740 | | void write(BitStreamWriter& writer) const override |
741 | 16 | { |
742 | 16 | writer.writeSignedBits(Base::getValue(), Base::getTypeInfo().getBitSize()); |
743 | 16 | } |
744 | | }; |
745 | | |
746 | | template <typename ALLOC> |
747 | | class FixedSignedBitFieldReflectable<ALLOC, int16_t> : public Int16ReflectableBase<ALLOC> |
748 | | { |
749 | | private: |
750 | | using Base = Int16ReflectableBase<ALLOC>; |
751 | | |
752 | | public: |
753 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
754 | 3 | { |
755 | 3 | return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize); |
756 | 3 | } |
757 | | |
758 | | FixedSignedBitFieldReflectable(int16_t value, uint8_t bitSize) : |
759 | | Base(typeInfo(bitSize), value) |
760 | 3 | { |
761 | 3 | if (bitSize <= 8 || bitSize > 162 ) |
762 | 2 | { |
763 | 2 | throw CppRuntimeException("FixedSignedBitFieldReflectable ") |
764 | 2 | << " - invalid bit size '" << bitSize << "' for 'int16_t' value!"; |
765 | 2 | } |
766 | 3 | } |
767 | | |
768 | | size_t bitSizeOf(size_t) const override |
769 | 1 | { |
770 | 1 | return Base::getTypeInfo().getBitSize(); |
771 | 1 | } |
772 | | |
773 | | void write(BitStreamWriter& writer) const override |
774 | 1 | { |
775 | 1 | writer.writeSignedBits(Base::getValue(), Base::getTypeInfo().getBitSize()); |
776 | 1 | } |
777 | | }; |
778 | | |
779 | | template <typename ALLOC> |
780 | | class FixedSignedBitFieldReflectable<ALLOC, int32_t> : public Int32ReflectableBase<ALLOC> |
781 | | { |
782 | | private: |
783 | | using Base = Int32ReflectableBase<ALLOC>; |
784 | | |
785 | | public: |
786 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
787 | 37 | { |
788 | 37 | return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize); |
789 | 37 | } |
790 | | |
791 | | FixedSignedBitFieldReflectable(int32_t value, uint8_t bitSize) : |
792 | | Base(typeInfo(bitSize), value) |
793 | 37 | { |
794 | 37 | if (bitSize <= 16 || bitSize > 3236 ) |
795 | 2 | { |
796 | 2 | throw CppRuntimeException("FixedSignedBitFieldReflectable ") |
797 | 2 | << " - invalid bit size '" << bitSize << "' for 'int32_t' value!"; |
798 | 2 | } |
799 | 37 | } |
800 | | |
801 | | size_t bitSizeOf(size_t) const override |
802 | 1 | { |
803 | 1 | return Base::getTypeInfo().getBitSize(); |
804 | 1 | } |
805 | | |
806 | | void write(BitStreamWriter& writer) const override |
807 | 1 | { |
808 | 1 | writer.writeSignedBits(Base::getValue(), Base::getTypeInfo().getBitSize()); |
809 | 1 | } |
810 | | }; |
811 | | |
812 | | template <typename ALLOC> |
813 | | class FixedSignedBitFieldReflectable<ALLOC, int64_t> : public Int64ReflectableBase<ALLOC> |
814 | | { |
815 | | private: |
816 | | using Base = Int64ReflectableBase<ALLOC>; |
817 | | |
818 | | public: |
819 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
820 | 3 | { |
821 | 3 | return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize); |
822 | 3 | } |
823 | | |
824 | | FixedSignedBitFieldReflectable(int64_t value, uint8_t bitSize) : |
825 | | Base(typeInfo(bitSize), value) |
826 | 3 | { |
827 | 3 | if (bitSize <= 32) // check for maximum bit size (64) is done in type info |
828 | 1 | { |
829 | 1 | throw CppRuntimeException("FixedSignedBitFieldReflectable ") |
830 | 1 | << " - invalid bit size '" << bitSize << "' for 'int64_t' value!"; |
831 | 1 | } |
832 | 3 | } |
833 | | |
834 | | size_t bitSizeOf(size_t) const override |
835 | 1 | { |
836 | 1 | return Base::getTypeInfo().getBitSize(); |
837 | 1 | } |
838 | | |
839 | | void write(BitStreamWriter& writer) const override |
840 | 1 | { |
841 | 1 | writer.writeSignedBits64(Base::getValue(), Base::getTypeInfo().getBitSize()); |
842 | 1 | } |
843 | | }; |
844 | | |
845 | | template <typename ALLOC, typename T> |
846 | | class FixedUnsignedBitFieldReflectable; |
847 | | |
848 | | template <typename ALLOC> |
849 | | class FixedUnsignedBitFieldReflectable<ALLOC, uint8_t> : public UInt8ReflectableBase<ALLOC> |
850 | | { |
851 | | private: |
852 | | using Base = UInt8ReflectableBase<ALLOC>; |
853 | | |
854 | | public: |
855 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
856 | 14 | { |
857 | 14 | return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize); |
858 | 14 | } |
859 | | |
860 | | FixedUnsignedBitFieldReflectable(uint8_t value, uint8_t bitSize) : |
861 | | Base(typeInfo(bitSize), value) |
862 | 12 | { |
863 | 12 | if (bitSize > 8) |
864 | 1 | { |
865 | 1 | throw CppRuntimeException("FixedUnsignedBitFieldReflectable") |
866 | 1 | << " - invalid bit size '" << bitSize << "' for 'uint8_t' value!"; |
867 | 1 | } |
868 | 12 | } |
869 | | |
870 | | size_t bitSizeOf(size_t) const override |
871 | 11 | { |
872 | 11 | return Base::getTypeInfo().getBitSize(); |
873 | 11 | } |
874 | | |
875 | | void write(BitStreamWriter& writer) const override |
876 | 11 | { |
877 | 11 | writer.writeBits(Base::getValue(), Base::getTypeInfo().getBitSize()); |
878 | 11 | } |
879 | | }; |
880 | | |
881 | | template <typename ALLOC> |
882 | | class FixedUnsignedBitFieldReflectable<ALLOC, uint16_t> : public UInt16ReflectableBase<ALLOC> |
883 | | { |
884 | | private: |
885 | | using Base = UInt16ReflectableBase<ALLOC>; |
886 | | |
887 | | public: |
888 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
889 | 3 | { |
890 | 3 | return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize); |
891 | 3 | } |
892 | | |
893 | | FixedUnsignedBitFieldReflectable(uint16_t value, uint8_t bitSize) : |
894 | | Base(typeInfo(bitSize), value) |
895 | 3 | { |
896 | 3 | if (bitSize <= 8 || bitSize > 162 ) |
897 | 2 | { |
898 | 2 | throw CppRuntimeException("FixedUnsignedBitFieldReflectable") |
899 | 2 | << " - invalid bit size '" << bitSize << "' for 'uint16_t' value!"; |
900 | 2 | } |
901 | 3 | } |
902 | | |
903 | | size_t bitSizeOf(size_t) const override |
904 | 1 | { |
905 | 1 | return Base::getTypeInfo().getBitSize(); |
906 | 1 | } |
907 | | |
908 | | void write(BitStreamWriter& writer) const override |
909 | 1 | { |
910 | 1 | writer.writeBits(Base::getValue(), Base::getTypeInfo().getBitSize()); |
911 | 1 | } |
912 | | }; |
913 | | |
914 | | template <typename ALLOC> |
915 | | class FixedUnsignedBitFieldReflectable<ALLOC, uint32_t> : public UInt32ReflectableBase<ALLOC> |
916 | | { |
917 | | private: |
918 | | using Base = UInt32ReflectableBase<ALLOC>; |
919 | | |
920 | | public: |
921 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
922 | 74 | { |
923 | 74 | return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize); |
924 | 74 | } |
925 | | |
926 | | FixedUnsignedBitFieldReflectable(uint32_t value, uint8_t bitSize) : |
927 | | Base(typeInfo(bitSize), value) |
928 | 74 | { |
929 | 74 | if (bitSize <= 16 || bitSize > 3273 ) |
930 | 2 | { |
931 | 2 | throw CppRuntimeException("FixedUnsignedBitFieldReflectable") |
932 | 2 | << " - invalid bit size '" << bitSize << "' for 'uint32_t' value!"; |
933 | 2 | } |
934 | 74 | } |
935 | | |
936 | | size_t bitSizeOf(size_t) const override |
937 | 1 | { |
938 | 1 | return Base::getTypeInfo().getBitSize(); |
939 | 1 | } |
940 | | |
941 | | void write(BitStreamWriter& writer) const override |
942 | 1 | { |
943 | 1 | writer.writeBits(Base::getValue(), Base::getTypeInfo().getBitSize()); |
944 | 1 | } |
945 | | }; |
946 | | |
947 | | template <typename ALLOC> |
948 | | class FixedUnsignedBitFieldReflectable<ALLOC, uint64_t> : public UInt64ReflectableBase<ALLOC> |
949 | | { |
950 | | private: |
951 | | using Base = UInt64ReflectableBase<ALLOC>; |
952 | | |
953 | | public: |
954 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize) |
955 | 3 | { |
956 | 3 | return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize); |
957 | 3 | } |
958 | | |
959 | | FixedUnsignedBitFieldReflectable(uint64_t value, uint8_t bitSize) : |
960 | | Base(typeInfo(bitSize), value) |
961 | 3 | { |
962 | 3 | if (bitSize <= 32) // check for maximum bit size (64) is done in type info |
963 | 1 | { |
964 | 1 | throw CppRuntimeException("FixedUnsignedBitFieldReflectable") |
965 | 1 | << " - invalid bit size '" << bitSize << "' for 'uint64_t' value!"; |
966 | 1 | } |
967 | 3 | } |
968 | | |
969 | | size_t bitSizeOf(size_t) const override |
970 | 1 | { |
971 | 1 | return Base::getTypeInfo().getBitSize(); |
972 | 1 | } |
973 | | |
974 | | void write(BitStreamWriter& writer) const override |
975 | 1 | { |
976 | 1 | writer.writeBits64(Base::getValue(), Base::getTypeInfo().getBitSize()); |
977 | 1 | } |
978 | | }; |
979 | | |
980 | | template <typename ALLOC, typename T> |
981 | | class DynamicSignedBitFieldReflectable; |
982 | | |
983 | | template <typename ALLOC> |
984 | | class DynamicSignedBitFieldReflectable<ALLOC, int8_t> : public Int8ReflectableBase<ALLOC> |
985 | | { |
986 | | private: |
987 | | using Base = Int8ReflectableBase<ALLOC>; |
988 | | |
989 | | public: |
990 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
991 | 22 | { |
992 | 22 | return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize); |
993 | 22 | } |
994 | | |
995 | | DynamicSignedBitFieldReflectable(int8_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
996 | | Base(typeInfo(maxBitSize), value), |
997 | | m_dynamicBitSize(dynamicBitSize) |
998 | 20 | { |
999 | 20 | if (maxBitSize > 8) |
1000 | 1 | { |
1001 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable") |
1002 | 1 | << " - invalid max bit size '" << maxBitSize << "' for 'int8_t' value!"; |
1003 | 1 | } |
1004 | | |
1005 | 19 | if (dynamicBitSize > maxBitSize) |
1006 | 1 | { |
1007 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1008 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1009 | 1 | } |
1010 | 19 | } |
1011 | | |
1012 | | size_t bitSizeOf(size_t) const override |
1013 | 16 | { |
1014 | 16 | return m_dynamicBitSize; |
1015 | 16 | } |
1016 | | |
1017 | | void write(BitStreamWriter& writer) const override |
1018 | 16 | { |
1019 | 16 | writer.writeSignedBits(Base::getValue(), m_dynamicBitSize); |
1020 | 16 | } |
1021 | | |
1022 | | private: |
1023 | | uint8_t m_dynamicBitSize; |
1024 | | }; |
1025 | | |
1026 | | template <typename ALLOC> |
1027 | | class DynamicSignedBitFieldReflectable<ALLOC, int16_t> : public Int16ReflectableBase<ALLOC> |
1028 | | { |
1029 | | private: |
1030 | | using Base = Int16ReflectableBase<ALLOC>; |
1031 | | |
1032 | | public: |
1033 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
1034 | 4 | { |
1035 | 4 | return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize); |
1036 | 4 | } |
1037 | | |
1038 | | DynamicSignedBitFieldReflectable(int16_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
1039 | | Base(typeInfo(maxBitSize), value), |
1040 | | m_dynamicBitSize(dynamicBitSize) |
1041 | 4 | { |
1042 | 4 | if (maxBitSize <= 8 || maxBitSize > 163 ) |
1043 | 2 | { |
1044 | 2 | throw CppRuntimeException("DynamicSignedBitFieldReflectable") |
1045 | 2 | << " - invalid max bit size '" << maxBitSize << "' for 'int16_t' value!"; |
1046 | 2 | } |
1047 | | |
1048 | 2 | if (dynamicBitSize > maxBitSize) |
1049 | 1 | { |
1050 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1051 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1052 | 1 | } |
1053 | 2 | } |
1054 | | |
1055 | | size_t bitSizeOf(size_t) const override |
1056 | 1 | { |
1057 | 1 | return m_dynamicBitSize; |
1058 | 1 | } |
1059 | | |
1060 | | void write(BitStreamWriter& writer) const override |
1061 | 1 | { |
1062 | 1 | writer.writeSignedBits(Base::getValue(), m_dynamicBitSize); |
1063 | 1 | } |
1064 | | |
1065 | | private: |
1066 | | uint8_t m_dynamicBitSize; |
1067 | | }; |
1068 | | |
1069 | | template <typename ALLOC> |
1070 | | class DynamicSignedBitFieldReflectable<ALLOC, int32_t> : public Int32ReflectableBase<ALLOC> |
1071 | | { |
1072 | | private: |
1073 | | using Base = Int32ReflectableBase<ALLOC>; |
1074 | | |
1075 | | public: |
1076 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
1077 | 4 | { |
1078 | 4 | return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize); |
1079 | 4 | } |
1080 | | |
1081 | | DynamicSignedBitFieldReflectable(int32_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
1082 | | Base(typeInfo(maxBitSize), value), |
1083 | | m_dynamicBitSize(dynamicBitSize) |
1084 | 4 | { |
1085 | 4 | if (maxBitSize <= 16 || maxBitSize > 323 ) |
1086 | 2 | { |
1087 | 2 | throw CppRuntimeException("DynamicSignedBitFieldReflectable") |
1088 | 2 | << " - invalid max bit size '" << maxBitSize << "' for 'int32_t' value!"; |
1089 | 2 | } |
1090 | | |
1091 | 2 | if (dynamicBitSize > maxBitSize) |
1092 | 1 | { |
1093 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1094 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1095 | 1 | } |
1096 | 2 | } |
1097 | | |
1098 | | size_t bitSizeOf(size_t) const override |
1099 | 1 | { |
1100 | 1 | return m_dynamicBitSize; |
1101 | 1 | } |
1102 | | |
1103 | | void write(BitStreamWriter& writer) const override |
1104 | 1 | { |
1105 | 1 | writer.writeSignedBits(Base::getValue(), m_dynamicBitSize); |
1106 | 1 | } |
1107 | | |
1108 | | private: |
1109 | | uint8_t m_dynamicBitSize; |
1110 | | }; |
1111 | | |
1112 | | template <typename ALLOC> |
1113 | | class DynamicSignedBitFieldReflectable<ALLOC, int64_t> : public Int64ReflectableBase<ALLOC> |
1114 | | { |
1115 | | private: |
1116 | | using Base = Int64ReflectableBase<ALLOC>; |
1117 | | |
1118 | | public: |
1119 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
1120 | 5 | { |
1121 | 5 | return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize); |
1122 | 5 | } |
1123 | | |
1124 | | DynamicSignedBitFieldReflectable(int64_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
1125 | | Base(typeInfo(maxBitSize), value), |
1126 | | m_dynamicBitSize(dynamicBitSize) |
1127 | 5 | { |
1128 | 5 | if (maxBitSize <= 32) // check for maximum bit size (64) is done in type info |
1129 | 1 | { |
1130 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable") |
1131 | 1 | << " - invalid max bit size '" << maxBitSize << "' for 'int64_t' value!"; |
1132 | 1 | } |
1133 | | |
1134 | 4 | if (dynamicBitSize > maxBitSize) |
1135 | 1 | { |
1136 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1137 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1138 | 1 | } |
1139 | 4 | } |
1140 | | |
1141 | | size_t bitSizeOf(size_t) const override |
1142 | 1 | { |
1143 | 1 | return m_dynamicBitSize; |
1144 | 1 | } |
1145 | | |
1146 | | void write(BitStreamWriter& writer) const override |
1147 | 1 | { |
1148 | 1 | writer.writeSignedBits64(Base::getValue(), m_dynamicBitSize); |
1149 | 1 | } |
1150 | | |
1151 | | private: |
1152 | | uint8_t m_dynamicBitSize; |
1153 | | }; |
1154 | | |
1155 | | template <typename ALLOC, typename T> |
1156 | | class DynamicUnsignedBitFieldReflectable; |
1157 | | |
1158 | | template <typename ALLOC> |
1159 | | class DynamicUnsignedBitFieldReflectable<ALLOC, uint8_t> : public UInt8ReflectableBase<ALLOC> |
1160 | | { |
1161 | | private: |
1162 | | using Base = UInt8ReflectableBase<ALLOC>; |
1163 | | |
1164 | | public: |
1165 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
1166 | 15 | { |
1167 | 15 | return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize); |
1168 | 15 | } |
1169 | | |
1170 | | DynamicUnsignedBitFieldReflectable(uint8_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
1171 | | Base(typeInfo(maxBitSize), value), |
1172 | | m_dynamicBitSize(dynamicBitSize) |
1173 | 13 | { |
1174 | 13 | if (maxBitSize > 8) |
1175 | 1 | { |
1176 | 1 | throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") |
1177 | 1 | << " - invalid max bit size '" << maxBitSize << "' for 'uint8_t' value!"; |
1178 | 1 | } |
1179 | | |
1180 | 12 | if (dynamicBitSize > maxBitSize) |
1181 | 1 | { |
1182 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1183 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1184 | 1 | } |
1185 | 12 | } |
1186 | | |
1187 | | size_t bitSizeOf(size_t) const override |
1188 | 11 | { |
1189 | 11 | return m_dynamicBitSize; |
1190 | 11 | } |
1191 | | |
1192 | | void write(BitStreamWriter& writer) const override |
1193 | 11 | { |
1194 | 11 | writer.writeBits(Base::getValue(), m_dynamicBitSize); |
1195 | 11 | } |
1196 | | |
1197 | | private: |
1198 | | uint8_t m_dynamicBitSize; |
1199 | | }; |
1200 | | |
1201 | | template <typename ALLOC> |
1202 | | class DynamicUnsignedBitFieldReflectable<ALLOC, uint16_t> : public UInt16ReflectableBase<ALLOC> |
1203 | | { |
1204 | | private: |
1205 | | using Base = UInt16ReflectableBase<ALLOC>; |
1206 | | |
1207 | | public: |
1208 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
1209 | 4 | { |
1210 | 4 | return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize); |
1211 | 4 | } |
1212 | | |
1213 | | DynamicUnsignedBitFieldReflectable(uint16_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
1214 | | Base(typeInfo(maxBitSize), value), |
1215 | | m_dynamicBitSize(dynamicBitSize) |
1216 | 4 | { |
1217 | 4 | if (maxBitSize <= 8 || maxBitSize > 163 ) |
1218 | 2 | { |
1219 | 2 | throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") |
1220 | 2 | << " - invalid max bit size '" << maxBitSize << "' for 'uint16_t' value!"; |
1221 | 2 | } |
1222 | | |
1223 | 2 | if (dynamicBitSize > maxBitSize) |
1224 | 1 | { |
1225 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1226 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1227 | 1 | } |
1228 | 2 | } |
1229 | | |
1230 | | size_t bitSizeOf(size_t) const override |
1231 | 1 | { |
1232 | 1 | return m_dynamicBitSize; |
1233 | 1 | } |
1234 | | |
1235 | | void write(BitStreamWriter& writer) const override |
1236 | 1 | { |
1237 | 1 | writer.writeBits(Base::getValue(), m_dynamicBitSize); |
1238 | 1 | } |
1239 | | |
1240 | | private: |
1241 | | uint8_t m_dynamicBitSize; |
1242 | | }; |
1243 | | |
1244 | | template <typename ALLOC> |
1245 | | class DynamicUnsignedBitFieldReflectable<ALLOC, uint32_t> : public UInt32ReflectableBase<ALLOC> |
1246 | | { |
1247 | | private: |
1248 | | using Base = UInt32ReflectableBase<ALLOC>; |
1249 | | |
1250 | | public: |
1251 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
1252 | 4 | { |
1253 | 4 | return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize); |
1254 | 4 | } |
1255 | | |
1256 | | DynamicUnsignedBitFieldReflectable(uint32_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
1257 | | Base(typeInfo(maxBitSize), value), |
1258 | | m_dynamicBitSize(dynamicBitSize) |
1259 | 4 | { |
1260 | 4 | if (maxBitSize <= 16 || maxBitSize > 323 ) |
1261 | 2 | { |
1262 | 2 | throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") |
1263 | 2 | << " - invalid max bit size '" << maxBitSize << "' for 'uint32_t' value!"; |
1264 | 2 | } |
1265 | | |
1266 | 2 | if (dynamicBitSize > maxBitSize) |
1267 | 1 | { |
1268 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1269 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1270 | 1 | } |
1271 | 2 | } |
1272 | | |
1273 | | size_t bitSizeOf(size_t) const override |
1274 | 1 | { |
1275 | 1 | return m_dynamicBitSize; |
1276 | 1 | } |
1277 | | |
1278 | | void write(BitStreamWriter& writer) const override |
1279 | 1 | { |
1280 | 1 | writer.writeBits(Base::getValue(), m_dynamicBitSize); |
1281 | 1 | } |
1282 | | |
1283 | | private: |
1284 | | uint8_t m_dynamicBitSize; |
1285 | | }; |
1286 | | |
1287 | | template <typename ALLOC> |
1288 | | class DynamicUnsignedBitFieldReflectable<ALLOC, uint64_t> : public UInt64ReflectableBase<ALLOC> |
1289 | | { |
1290 | | private: |
1291 | | using Base = UInt64ReflectableBase<ALLOC>; |
1292 | | |
1293 | | public: |
1294 | | static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize) |
1295 | 5 | { |
1296 | 5 | return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize); |
1297 | 5 | } |
1298 | | |
1299 | | DynamicUnsignedBitFieldReflectable(uint64_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
1300 | | Base(typeInfo(maxBitSize), value), |
1301 | | m_dynamicBitSize(dynamicBitSize) |
1302 | 5 | { |
1303 | 5 | if (maxBitSize <= 32) // check for maximum bit size (64) is done in type info |
1304 | 1 | { |
1305 | 1 | throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") |
1306 | 1 | << " - invalid max bit size '" << maxBitSize << "' for 'uint64_t' value!"; |
1307 | 1 | } |
1308 | | |
1309 | 4 | if (dynamicBitSize > maxBitSize) |
1310 | 1 | { |
1311 | 1 | throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") |
1312 | 1 | << dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!"; |
1313 | 1 | } |
1314 | 4 | } |
1315 | | |
1316 | | size_t bitSizeOf(size_t) const override |
1317 | 1 | { |
1318 | 1 | return m_dynamicBitSize; |
1319 | 1 | } |
1320 | | |
1321 | | void write(BitStreamWriter& writer) const override |
1322 | 1 | { |
1323 | 1 | writer.writeBits64(Base::getValue(), m_dynamicBitSize); |
1324 | 1 | } |
1325 | | |
1326 | | private: |
1327 | | uint8_t m_dynamicBitSize; |
1328 | | }; |
1329 | | |
1330 | | /** |
1331 | | * Reflectable for varint16 type. |
1332 | | */ |
1333 | | template <typename ALLOC> |
1334 | | class VarInt16Reflectable : public Int16ReflectableBase<ALLOC> |
1335 | | { |
1336 | | private: |
1337 | | using Base = Int16ReflectableBase<ALLOC>; |
1338 | | |
1339 | | public: |
1340 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1341 | 12 | { |
1342 | 12 | return BuiltinTypeInfo<ALLOC>::getVarInt16(); |
1343 | 12 | } |
1344 | | |
1345 | | explicit VarInt16Reflectable(int16_t value) : |
1346 | | Base(typeInfo(), value) |
1347 | 10 | {} |
1348 | | |
1349 | | size_t bitSizeOf(size_t) const override |
1350 | 9 | { |
1351 | 9 | return zserio::bitSizeOfVarInt16(Base::getValue()); |
1352 | 9 | } |
1353 | | |
1354 | | void write(BitStreamWriter& writer) const override |
1355 | 9 | { |
1356 | 9 | writer.writeVarInt16(Base::getValue()); |
1357 | 9 | } |
1358 | | }; |
1359 | | |
1360 | | /** |
1361 | | * Reflectable for varint32 type. |
1362 | | */ |
1363 | | template <typename ALLOC> |
1364 | | class VarInt32Reflectable : public Int32ReflectableBase<ALLOC> |
1365 | | { |
1366 | | private: |
1367 | | using Base = Int32ReflectableBase<ALLOC>; |
1368 | | |
1369 | | public: |
1370 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1371 | 12 | { |
1372 | 12 | return BuiltinTypeInfo<ALLOC>::getVarInt32(); |
1373 | 12 | } |
1374 | | |
1375 | | explicit VarInt32Reflectable(int32_t value) : |
1376 | | Base(typeInfo(), value) |
1377 | 10 | {} |
1378 | | |
1379 | | size_t bitSizeOf(size_t) const override |
1380 | 9 | { |
1381 | 9 | return zserio::bitSizeOfVarInt32(Base::getValue()); |
1382 | 9 | } |
1383 | | |
1384 | | void write(BitStreamWriter& writer) const override |
1385 | 9 | { |
1386 | 9 | writer.writeVarInt32(Base::getValue()); |
1387 | 9 | } |
1388 | | }; |
1389 | | |
1390 | | /** |
1391 | | * Reflectable for varint64 type. |
1392 | | */ |
1393 | | template <typename ALLOC> |
1394 | | class VarInt64Reflectable : public Int64ReflectableBase<ALLOC> |
1395 | | { |
1396 | | private: |
1397 | | using Base = Int64ReflectableBase<ALLOC>; |
1398 | | |
1399 | | public: |
1400 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1401 | 12 | { |
1402 | 12 | return BuiltinTypeInfo<ALLOC>::getVarInt64(); |
1403 | 12 | } |
1404 | | |
1405 | | explicit VarInt64Reflectable(int64_t value) : |
1406 | | Base(typeInfo(), value) |
1407 | 10 | {} |
1408 | | |
1409 | | size_t bitSizeOf(size_t) const override |
1410 | 9 | { |
1411 | 9 | return zserio::bitSizeOfVarInt64(Base::getValue()); |
1412 | 9 | } |
1413 | | |
1414 | | void write(BitStreamWriter& writer) const override |
1415 | 9 | { |
1416 | 9 | writer.writeVarInt64(Base::getValue()); |
1417 | 9 | } |
1418 | | }; |
1419 | | |
1420 | | /** |
1421 | | * Reflectable for varint type. |
1422 | | */ |
1423 | | template <typename ALLOC> |
1424 | | class VarIntReflectable : public Int64ReflectableBase<ALLOC> |
1425 | | { |
1426 | | private: |
1427 | | using Base = Int64ReflectableBase<ALLOC>; |
1428 | | |
1429 | | public: |
1430 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1431 | 13 | { |
1432 | 13 | return BuiltinTypeInfo<ALLOC>::getVarInt(); |
1433 | 13 | } |
1434 | | |
1435 | | explicit VarIntReflectable(int64_t value) : |
1436 | | Base(typeInfo(), value) |
1437 | 11 | {} |
1438 | | |
1439 | | size_t bitSizeOf(size_t) const override |
1440 | 9 | { |
1441 | 9 | return zserio::bitSizeOfVarInt(Base::getValue()); |
1442 | 9 | } |
1443 | | |
1444 | | void write(BitStreamWriter& writer) const override |
1445 | 9 | { |
1446 | 9 | writer.writeVarInt(Base::getValue()); |
1447 | 9 | } |
1448 | | }; |
1449 | | |
1450 | | /** |
1451 | | * Reflectable for varuint16 type. |
1452 | | */ |
1453 | | template <typename ALLOC> |
1454 | | class VarUInt16Reflectable : public UInt16ReflectableBase<ALLOC> |
1455 | | { |
1456 | | private: |
1457 | | using Base = UInt16ReflectableBase<ALLOC>; |
1458 | | |
1459 | | public: |
1460 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1461 | 12 | { |
1462 | 12 | return BuiltinTypeInfo<ALLOC>::getVarUInt16(); |
1463 | 12 | } |
1464 | | |
1465 | | explicit VarUInt16Reflectable(uint16_t value) : |
1466 | | Base(typeInfo(), value) |
1467 | 10 | {} |
1468 | | |
1469 | | size_t bitSizeOf(size_t) const override |
1470 | 9 | { |
1471 | 9 | return zserio::bitSizeOfVarUInt16(Base::getValue()); |
1472 | 9 | } |
1473 | | |
1474 | | void write(BitStreamWriter& writer) const override |
1475 | 9 | { |
1476 | 9 | writer.writeVarUInt16(Base::getValue()); |
1477 | 9 | } |
1478 | | }; |
1479 | | |
1480 | | /** |
1481 | | * Reflectable for varuint32 type. |
1482 | | */ |
1483 | | template <typename ALLOC> |
1484 | | class VarUInt32Reflectable : public UInt32ReflectableBase<ALLOC> |
1485 | | { |
1486 | | private: |
1487 | | using Base = UInt32ReflectableBase<ALLOC>; |
1488 | | |
1489 | | public: |
1490 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1491 | 12 | { |
1492 | 12 | return BuiltinTypeInfo<ALLOC>::getVarUInt32(); |
1493 | 12 | } |
1494 | | |
1495 | | explicit VarUInt32Reflectable(uint32_t value) : |
1496 | | Base(typeInfo(), value) |
1497 | 10 | {} |
1498 | | |
1499 | | size_t bitSizeOf(size_t) const override |
1500 | 9 | { |
1501 | 9 | return zserio::bitSizeOfVarUInt32(Base::getValue()); |
1502 | 9 | } |
1503 | | |
1504 | | void write(BitStreamWriter& writer) const override |
1505 | 9 | { |
1506 | 9 | writer.writeVarUInt32(Base::getValue()); |
1507 | 9 | } |
1508 | | }; |
1509 | | |
1510 | | /** |
1511 | | * Reflectable for varuint64 type. |
1512 | | */ |
1513 | | template <typename ALLOC> |
1514 | | class VarUInt64Reflectable : public UInt64ReflectableBase<ALLOC> |
1515 | | { |
1516 | | private: |
1517 | | using Base = UInt64ReflectableBase<ALLOC>; |
1518 | | |
1519 | | public: |
1520 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1521 | 12 | { |
1522 | 12 | return BuiltinTypeInfo<ALLOC>::getVarUInt64(); |
1523 | 12 | } |
1524 | | |
1525 | | explicit VarUInt64Reflectable(uint64_t value) : |
1526 | | Base(typeInfo(), value) |
1527 | 10 | {} |
1528 | | |
1529 | | size_t bitSizeOf(size_t) const override |
1530 | 9 | { |
1531 | 9 | return zserio::bitSizeOfVarUInt64(Base::getValue()); |
1532 | 9 | } |
1533 | | |
1534 | | void write(BitStreamWriter& writer) const override |
1535 | 9 | { |
1536 | 9 | writer.writeVarUInt64(Base::getValue()); |
1537 | 9 | } |
1538 | | }; |
1539 | | |
1540 | | /** |
1541 | | * Reflectable for varuint type. |
1542 | | */ |
1543 | | template <typename ALLOC> |
1544 | | class VarUIntReflectable : public UInt64ReflectableBase<ALLOC> |
1545 | | { |
1546 | | private: |
1547 | | using Base = UInt64ReflectableBase<ALLOC>; |
1548 | | |
1549 | | public: |
1550 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1551 | 12 | { |
1552 | 12 | return BuiltinTypeInfo<ALLOC>::getVarUInt(); |
1553 | 12 | } |
1554 | | |
1555 | | explicit VarUIntReflectable(uint64_t value) : |
1556 | | Base(typeInfo(), value) |
1557 | 10 | {} |
1558 | | |
1559 | | size_t bitSizeOf(size_t) const override |
1560 | 9 | { |
1561 | 9 | return zserio::bitSizeOfVarUInt(Base::getValue()); |
1562 | 9 | } |
1563 | | |
1564 | | void write(BitStreamWriter& writer) const override |
1565 | 9 | { |
1566 | 9 | writer.writeVarUInt(Base::getValue()); |
1567 | 9 | } |
1568 | | }; |
1569 | | |
1570 | | /** |
1571 | | * Reflectable for varsize type. |
1572 | | */ |
1573 | | template <typename ALLOC> |
1574 | | class VarSizeReflectable : public UInt32ReflectableBase<ALLOC> |
1575 | | { |
1576 | | private: |
1577 | | using Base = UInt32ReflectableBase<ALLOC>; |
1578 | | |
1579 | | public: |
1580 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1581 | 13 | { |
1582 | 13 | return BuiltinTypeInfo<ALLOC>::getVarSize(); |
1583 | 13 | } |
1584 | | |
1585 | | explicit VarSizeReflectable(uint32_t value) : |
1586 | | Base(typeInfo(), value) |
1587 | 11 | {} |
1588 | | |
1589 | | size_t bitSizeOf(size_t) const override |
1590 | 9 | { |
1591 | 9 | return zserio::bitSizeOfVarUInt(Base::getValue()); |
1592 | 9 | } |
1593 | | |
1594 | | void write(BitStreamWriter& writer) const override |
1595 | 9 | { |
1596 | 9 | writer.writeVarSize(Base::getValue()); |
1597 | 9 | } |
1598 | | }; |
1599 | | |
1600 | | /** |
1601 | | * Base class for floating point reflectables. |
1602 | | */ |
1603 | | template <typename ALLOC, typename T> |
1604 | | class FloatingPointReflectableBase : public BuiltinReflectableBase<ALLOC, T> |
1605 | | { |
1606 | | protected: |
1607 | | static_assert(std::is_floating_point<T>::value, "T must be a floating point type!"); |
1608 | | |
1609 | | using BuiltinReflectableBase<ALLOC, T>::getValue; |
1610 | | using BuiltinReflectableBase<ALLOC, T>::BuiltinReflectableBase; |
1611 | | |
1612 | | public: |
1613 | | double toDouble() const override |
1614 | 61 | { |
1615 | 61 | return static_cast<double>(getValue()); |
1616 | 61 | } |
1617 | | }; |
1618 | | |
1619 | | /** |
1620 | | * Reflectable for values of 16-bit float type. |
1621 | | */ |
1622 | | template <typename ALLOC> |
1623 | | class Float16Reflectable : public FloatingPointReflectableBase<ALLOC, float> |
1624 | | { |
1625 | | private: |
1626 | | using Base = FloatingPointReflectableBase<ALLOC, float>; |
1627 | | |
1628 | | public: |
1629 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1630 | 13 | { |
1631 | 13 | return BuiltinTypeInfo<ALLOC>::getFloat16(); |
1632 | 13 | } |
1633 | | |
1634 | | explicit Float16Reflectable(float value) : |
1635 | | Base(typeInfo(), value) |
1636 | 11 | {} |
1637 | | |
1638 | | size_t bitSizeOf(size_t) const override |
1639 | 5 | { |
1640 | 5 | return 16; |
1641 | 5 | } |
1642 | | |
1643 | | void write(BitStreamWriter& writer) const override |
1644 | 5 | { |
1645 | 5 | writer.writeFloat16(Base::getValue()); |
1646 | 5 | } |
1647 | | |
1648 | | float getFloat() const override |
1649 | 10 | { |
1650 | 10 | return Base::getValue(); |
1651 | 10 | } |
1652 | | }; |
1653 | | |
1654 | | /** |
1655 | | * Reflectable for values of 32-bit float type. |
1656 | | */ |
1657 | | template <typename ALLOC> |
1658 | | class Float32Reflectable : public FloatingPointReflectableBase<ALLOC, float> |
1659 | | { |
1660 | | private: |
1661 | | using Base = FloatingPointReflectableBase<ALLOC, float>; |
1662 | | |
1663 | | public: |
1664 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1665 | 17 | { |
1666 | 17 | return BuiltinTypeInfo<ALLOC>::getFloat32(); |
1667 | 17 | } |
1668 | | |
1669 | | explicit Float32Reflectable(float value) : |
1670 | | Base(typeInfo(), value) |
1671 | 15 | {} |
1672 | | |
1673 | | size_t bitSizeOf(size_t) const override |
1674 | 7 | { |
1675 | 7 | return 32; |
1676 | 7 | } |
1677 | | |
1678 | | void write(BitStreamWriter& writer) const override |
1679 | 7 | { |
1680 | 7 | writer.writeFloat32(Base::getValue()); |
1681 | 7 | } |
1682 | | |
1683 | | float getFloat() const override |
1684 | 15 | { |
1685 | 15 | return Base::getValue(); |
1686 | 15 | } |
1687 | | }; |
1688 | | |
1689 | | /** |
1690 | | * Reflectable for values of double type. |
1691 | | */ |
1692 | | template <typename ALLOC> |
1693 | | class Float64Reflectable : public FloatingPointReflectableBase<ALLOC, double> |
1694 | | { |
1695 | | private: |
1696 | | using Base = FloatingPointReflectableBase<ALLOC, double>; |
1697 | | |
1698 | | public: |
1699 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1700 | 45 | { |
1701 | 45 | return BuiltinTypeInfo<ALLOC>::getFloat64(); |
1702 | 45 | } |
1703 | | |
1704 | | explicit Float64Reflectable(double value) : |
1705 | | Base(typeInfo(), value) |
1706 | 43 | {} |
1707 | | |
1708 | | size_t bitSizeOf(size_t) const override |
1709 | 7 | { |
1710 | 7 | return 64; |
1711 | 7 | } |
1712 | | |
1713 | | void write(BitStreamWriter& writer) const override |
1714 | 7 | { |
1715 | 7 | writer.writeFloat64(Base::getValue()); |
1716 | 7 | } |
1717 | | |
1718 | | double getDouble() const override |
1719 | 15 | { |
1720 | 15 | return Base::getValue(); |
1721 | 15 | } |
1722 | | }; |
1723 | | |
1724 | | /** |
1725 | | * Reflectable for values of bytes type. |
1726 | | */ |
1727 | | template <typename ALLOC> |
1728 | | class BytesReflectable : public BuiltinReflectableBase<ALLOC, Span<const uint8_t>> |
1729 | | { |
1730 | | private: |
1731 | | using Base = BuiltinReflectableBase<ALLOC, Span<const uint8_t>>; |
1732 | | |
1733 | | public: |
1734 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1735 | 46 | { |
1736 | 46 | return BuiltinTypeInfo<ALLOC>::getBytes(); |
1737 | 46 | } |
1738 | | |
1739 | | explicit BytesReflectable(Span<const uint8_t> value) : |
1740 | | Base(typeInfo(), value) |
1741 | 33 | {} |
1742 | | |
1743 | | size_t bitSizeOf(size_t) const override |
1744 | 7 | { |
1745 | 7 | return zserio::bitSizeOfBytes(Base::getValue()); |
1746 | 7 | } |
1747 | | |
1748 | | void write(BitStreamWriter& writer) const override |
1749 | 7 | { |
1750 | 7 | writer.writeBytes(Base::getValue()); |
1751 | 7 | } |
1752 | | |
1753 | | Span<const uint8_t> getBytes() const override |
1754 | 54 | { |
1755 | 54 | return Base::getValue(); |
1756 | 54 | } |
1757 | | }; |
1758 | | |
1759 | | /** |
1760 | | * Reflectable for values of string type. |
1761 | | */ |
1762 | | template <typename ALLOC> |
1763 | | class StringReflectable : public BuiltinReflectableBase<ALLOC, StringView> |
1764 | | { |
1765 | | private: |
1766 | | using Base = BuiltinReflectableBase<ALLOC, StringView>; |
1767 | | |
1768 | | public: |
1769 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1770 | 178 | { |
1771 | 178 | return BuiltinTypeInfo<ALLOC>::getString(); |
1772 | 178 | } |
1773 | | |
1774 | | explicit StringReflectable(StringView value) : |
1775 | | Base(typeInfo(), value) |
1776 | 157 | {} |
1777 | | |
1778 | | size_t bitSizeOf(size_t) const override |
1779 | 11 | { |
1780 | 11 | return zserio::bitSizeOfString(Base::getValue()); |
1781 | 11 | } |
1782 | | |
1783 | | void write(BitStreamWriter& writer) const override |
1784 | 11 | { |
1785 | 11 | writer.writeString(Base::getValue()); |
1786 | 11 | } |
1787 | | |
1788 | | StringView getStringView() const override |
1789 | 107 | { |
1790 | 107 | return Base::getValue(); |
1791 | 107 | } |
1792 | | |
1793 | | string<ALLOC> toString(const ALLOC& allocator) const override |
1794 | 34 | { |
1795 | 34 | return zserio::toString(Base::getValue(), allocator); |
1796 | 34 | } |
1797 | | }; |
1798 | | |
1799 | | /** |
1800 | | * Reflectable for values of bit buffer type. |
1801 | | */ |
1802 | | template <typename ALLOC> |
1803 | | class BitBufferReflectable : public BuiltinReflectableBase<ALLOC, BasicBitBuffer<ALLOC>> |
1804 | | { |
1805 | | private: |
1806 | | using Base = BuiltinReflectableBase<ALLOC, BasicBitBuffer<ALLOC>>; |
1807 | | |
1808 | | public: |
1809 | | static const IBasicTypeInfo<ALLOC>& typeInfo() |
1810 | 44 | { |
1811 | 44 | return BuiltinTypeInfo<ALLOC>::getBitBuffer(); |
1812 | 44 | } |
1813 | | |
1814 | | explicit BitBufferReflectable(const BasicBitBuffer<ALLOC>& value) : |
1815 | | Base(typeInfo(), value) |
1816 | 32 | {} |
1817 | | |
1818 | | size_t bitSizeOf(size_t) const override |
1819 | 7 | { |
1820 | 7 | return zserio::bitSizeOfBitBuffer(Base::getValue()); |
1821 | 7 | } |
1822 | | |
1823 | | void write(BitStreamWriter& writer) const override |
1824 | 7 | { |
1825 | 7 | writer.writeBitBuffer(Base::getValue()); |
1826 | 7 | } |
1827 | | |
1828 | | const BasicBitBuffer<ALLOC>& getBitBuffer() const override |
1829 | 30 | { |
1830 | 30 | return Base::getValue(); |
1831 | 30 | } |
1832 | | }; |
1833 | | |
1834 | | namespace detail |
1835 | | { |
1836 | | |
1837 | | template <typename ALLOC> |
1838 | | IBasicReflectableConstPtr<ALLOC> getFieldFromObject(const IBasicReflectable<ALLOC>& object, StringView name) |
1839 | 626 | { |
1840 | 626 | const auto& typeInfo = object.getTypeInfo(); |
1841 | 626 | if (TypeInfoUtil::isCompound(typeInfo.getSchemaType())) |
1842 | 176 | { |
1843 | 176 | const auto& fields = typeInfo.getFields(); |
1844 | 176 | auto fieldsIt = std::find_if(fields.begin(), fields.end(), |
1845 | 270 | [name](const BasicFieldInfo<ALLOC>& fieldInfo) { return fieldInfo.schemaName == name; }); |
1846 | 176 | if (fieldsIt != fields.end()) |
1847 | 106 | { |
1848 | 106 | return object.getField(name); |
1849 | 106 | } |
1850 | 176 | } |
1851 | | |
1852 | 520 | return nullptr; |
1853 | 626 | } |
1854 | | |
1855 | | template <typename ALLOC> |
1856 | | IBasicReflectablePtr<ALLOC> getFieldFromObject(IBasicReflectable<ALLOC>& object, StringView name) |
1857 | 488 | { |
1858 | 488 | const auto& typeInfo = object.getTypeInfo(); |
1859 | 488 | if (TypeInfoUtil::isCompound(typeInfo.getSchemaType())) |
1860 | 175 | { |
1861 | 175 | const auto& fields = typeInfo.getFields(); |
1862 | 175 | auto fieldsIt = std::find_if(fields.begin(), fields.end(), |
1863 | 411 | [name](const BasicFieldInfo<ALLOC>& fieldInfo) { return fieldInfo.schemaName == name; }); |
1864 | 175 | if (fieldsIt != fields.end()) |
1865 | 143 | { |
1866 | 143 | return object.getField(name); |
1867 | 143 | } |
1868 | 175 | } |
1869 | | |
1870 | 345 | return nullptr; |
1871 | 488 | } |
1872 | | |
1873 | | template <typename ALLOC> |
1874 | | IBasicReflectableConstPtr<ALLOC> getParameterFromObject(const IBasicReflectable<ALLOC>& object, StringView name) |
1875 | 520 | { |
1876 | 520 | const auto& typeInfo = object.getTypeInfo(); |
1877 | 520 | if (TypeInfoUtil::isCompound(typeInfo.getSchemaType())) |
1878 | 70 | { |
1879 | 70 | const auto& parameters = typeInfo.getParameters(); |
1880 | 70 | auto parametersIt = std::find_if( |
1881 | 100 | parameters.begin(), parameters.end(), [name](const BasicParameterInfo<ALLOC>& parameterInfo) { |
1882 | 100 | return parameterInfo.schemaName == name; |
1883 | 100 | }); |
1884 | 70 | if (parametersIt != parameters.end()) |
1885 | 26 | { |
1886 | 26 | return object.getParameter(name); |
1887 | 26 | } |
1888 | 70 | } |
1889 | | |
1890 | 494 | return nullptr; |
1891 | 520 | } |
1892 | | |
1893 | | template <typename ALLOC> |
1894 | | IBasicReflectablePtr<ALLOC> getParameterFromObject(IBasicReflectable<ALLOC>& object, StringView name) |
1895 | 345 | { |
1896 | 345 | const auto& typeInfo = object.getTypeInfo(); |
1897 | 345 | if (TypeInfoUtil::isCompound(typeInfo.getSchemaType())) |
1898 | 32 | { |
1899 | 32 | const auto& parameters = typeInfo.getParameters(); |
1900 | 32 | auto parametersIt = std::find_if( |
1901 | 39 | parameters.begin(), parameters.end(), [name](const BasicParameterInfo<ALLOC>& parameterInfo) { |
1902 | 39 | return parameterInfo.schemaName == name; |
1903 | 39 | }); |
1904 | 32 | if (parametersIt != parameters.end()) |
1905 | 11 | { |
1906 | 11 | return object.getParameter(name); |
1907 | 11 | } |
1908 | 32 | } |
1909 | | |
1910 | 334 | return nullptr; |
1911 | 345 | } |
1912 | | |
1913 | | template <typename ALLOC> |
1914 | | IBasicReflectableConstPtr<ALLOC> callFunctionInObject(const IBasicReflectable<ALLOC>& object, StringView name) |
1915 | 494 | { |
1916 | 494 | const auto& typeInfo = object.getTypeInfo(); |
1917 | 494 | if (TypeInfoUtil::isCompound(typeInfo.getSchemaType())) |
1918 | 44 | { |
1919 | 44 | const auto& functions = typeInfo.getFunctions(); |
1920 | 44 | auto functionsIt = std::find_if( |
1921 | 44 | functions.begin(), functions.end(), [name](const BasicFunctionInfo<ALLOC>& functionInfo) { |
1922 | 32 | return functionInfo.schemaName == name; |
1923 | 32 | }); |
1924 | 44 | if (functionsIt != functions.end()) |
1925 | 16 | { |
1926 | 16 | return object.callFunction(name); |
1927 | 16 | } |
1928 | 44 | } |
1929 | | |
1930 | 478 | return nullptr; |
1931 | 494 | } |
1932 | | |
1933 | | template <typename ALLOC> |
1934 | | IBasicReflectablePtr<ALLOC> callFunctionInObject(IBasicReflectable<ALLOC>& object, StringView name) |
1935 | 334 | { |
1936 | 334 | const auto& typeInfo = object.getTypeInfo(); |
1937 | 334 | if (TypeInfoUtil::isCompound(typeInfo.getSchemaType())) |
1938 | 21 | { |
1939 | 21 | const auto& functions = typeInfo.getFunctions(); |
1940 | 21 | auto functionsIt = std::find_if( |
1941 | 21 | functions.begin(), functions.end(), [name](const BasicFunctionInfo<ALLOC>& functionInfo) { |
1942 | 12 | return functionInfo.schemaName == name; |
1943 | 12 | }); |
1944 | 21 | if (functionsIt != functions.end()) |
1945 | 6 | { |
1946 | 6 | return object.callFunction(name); |
1947 | 6 | } |
1948 | 21 | } |
1949 | | |
1950 | 328 | return nullptr; |
1951 | 334 | } |
1952 | | |
1953 | | template <typename ALLOC> |
1954 | | IBasicReflectableConstPtr<ALLOC> getFromObject( |
1955 | | const IBasicReflectable<ALLOC>& object, StringView path, size_t pos) |
1956 | 626 | { |
1957 | 626 | try |
1958 | 626 | { |
1959 | 626 | const size_t dotPos = path.find('.', pos); |
1960 | 626 | const bool isLast = dotPos == StringView::npos; |
1961 | 626 | const StringView name = path.substr(pos, dotPos == StringView::npos ? StringView::npos82 : dotPos - pos544 ); |
1962 | | |
1963 | 626 | auto field = getFieldFromObject(object, name); |
1964 | 626 | if (field) |
1965 | 106 | { |
1966 | 106 | return isLast ? std::move(field)16 : getFromObject(*field, path, dotPos + 1)90 ; |
1967 | 106 | } |
1968 | | |
1969 | 520 | auto parameter = getParameterFromObject(object, name); |
1970 | 520 | if (parameter) |
1971 | 24 | { |
1972 | 24 | return isLast ? std::move(parameter)16 : getFromObject(*parameter, path, dotPos + 1)8 ; |
1973 | 24 | } |
1974 | | |
1975 | 496 | auto functionResult = callFunctionInObject(object, name); |
1976 | 496 | if (functionResult) |
1977 | 16 | { |
1978 | 16 | return isLast ? std::move(functionResult)8 : getFromObject(*functionResult, path, dotPos + 1)8 ; |
1979 | 16 | } |
1980 | 496 | } |
1981 | 626 | catch (const CppRuntimeException&) |
1982 | 626 | {}2 |
1983 | | |
1984 | 480 | return nullptr; |
1985 | 626 | } |
1986 | | |
1987 | | template <typename ALLOC> |
1988 | | IBasicReflectablePtr<ALLOC> getFromObject(IBasicReflectable<ALLOC>& object, StringView path, size_t pos) |
1989 | 488 | { |
1990 | 488 | try |
1991 | 488 | { |
1992 | 488 | const size_t dotPos = path.find('.', pos); |
1993 | 488 | const bool isLast = dotPos == StringView::npos; |
1994 | 488 | const StringView name = path.substr(pos, dotPos == StringView::npos ? StringView::npos90 : dotPos - pos398 ); |
1995 | | |
1996 | 488 | auto field = getFieldFromObject(object, name); |
1997 | 488 | if (field) |
1998 | 143 | { |
1999 | 143 | return isLast ? std::move(field)60 : getFromObject(*field, path, dotPos + 1)83 ; |
2000 | 143 | } |
2001 | | |
2002 | 345 | auto parameter = getParameterFromObject(object, name); |
2003 | 345 | if (parameter) |
2004 | 10 | { |
2005 | 10 | return isLast ? std::move(parameter)7 : getFromObject(*parameter, path, dotPos + 1)3 ; |
2006 | 10 | } |
2007 | | |
2008 | 335 | auto functionResult = callFunctionInObject(object, name); |
2009 | 335 | if (functionResult) |
2010 | 6 | { |
2011 | 6 | return isLast ? std::move(functionResult)3 : getFromObject(*functionResult, path, dotPos + 1)3 ; |
2012 | 6 | } |
2013 | 335 | } |
2014 | 488 | catch (const CppRuntimeException&) |
2015 | 488 | {}1 |
2016 | | |
2017 | 329 | return nullptr; |
2018 | 488 | } |
2019 | | |
2020 | | } // namespace detail |
2021 | | |
2022 | | /** |
2023 | | * Base class for reflectable which needs to hold an allocator. |
2024 | | */ |
2025 | | template <typename ALLOC> |
2026 | | class ReflectableAllocatorHolderBase : public ReflectableBase<ALLOC>, public AllocatorHolder<ALLOC> |
2027 | | { |
2028 | | public: |
2029 | | ReflectableAllocatorHolderBase(const IBasicTypeInfo<ALLOC>& typeInfo, const ALLOC& allocator) : |
2030 | | ReflectableBase<ALLOC>(typeInfo), |
2031 | | AllocatorHolder<ALLOC>(allocator) |
2032 | 707 | {} |
2033 | | }; |
2034 | | |
2035 | | /** |
2036 | | * Base class for constant reflectable which needs to hold an allocator. |
2037 | | * |
2038 | | * Overrides non constant methods and throws exception with info about constness. |
2039 | | */ |
2040 | | template <typename ALLOC> |
2041 | | class ReflectableConstAllocatorHolderBase : public ReflectableAllocatorHolderBase<ALLOC> |
2042 | | { |
2043 | | private: |
2044 | | using Base = ReflectableAllocatorHolderBase<ALLOC>; |
2045 | | |
2046 | | public: |
2047 | | using Base::Base; |
2048 | | using Base::getTypeInfo; |
2049 | | |
2050 | | void initializeChildren() override; |
2051 | | void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) override; |
2052 | | size_t initializeOffsets(size_t bitPosition) override; |
2053 | | |
2054 | | IBasicReflectablePtr<ALLOC> getField(StringView name) override; |
2055 | | void setField(StringView name, const AnyHolder<ALLOC>& value) override; |
2056 | | IBasicReflectablePtr<ALLOC> getParameter(StringView name) override; |
2057 | | IBasicReflectablePtr<ALLOC> callFunction(StringView name) override; |
2058 | | |
2059 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override; |
2060 | | }; |
2061 | | |
2062 | | /** |
2063 | | * Base class for reflectable arrays. |
2064 | | * |
2065 | | * Overrides all generic methods with default throw behaviour. |
2066 | | */ |
2067 | | template <typename ALLOC> |
2068 | | class ReflectableArrayBase : public ReflectableAllocatorHolderBase<ALLOC> |
2069 | | { |
2070 | | private: |
2071 | | using Base = ReflectableAllocatorHolderBase<ALLOC>; |
2072 | | |
2073 | | public: |
2074 | | using Base::Base; |
2075 | | using Base::getTypeInfo; |
2076 | | |
2077 | | bool isArray() const override |
2078 | 98 | { |
2079 | 98 | return true; |
2080 | 98 | } |
2081 | | |
2082 | | void initializeChildren() override; |
2083 | | void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) override; |
2084 | | size_t initializeOffsets(size_t bitPosition) override; |
2085 | | size_t bitSizeOf(size_t bitPosition) const override; |
2086 | | void write(BitStreamWriter& writer) const override; |
2087 | | |
2088 | | IBasicReflectableConstPtr<ALLOC> getField(StringView name) const override; |
2089 | | IBasicReflectablePtr<ALLOC> getField(StringView name) override; |
2090 | | IBasicReflectablePtr<ALLOC> createField(StringView name) override; |
2091 | | void setField(StringView name, const AnyHolder<ALLOC>& value) override; |
2092 | | IBasicReflectableConstPtr<ALLOC> getParameter(StringView name) const override; |
2093 | | IBasicReflectablePtr<ALLOC> getParameter(StringView name) override; |
2094 | | IBasicReflectableConstPtr<ALLOC> callFunction(StringView name) const override; |
2095 | | IBasicReflectablePtr<ALLOC> callFunction(StringView name) override; |
2096 | | |
2097 | | StringView getChoice() const override; |
2098 | | |
2099 | | IBasicReflectableConstPtr<ALLOC> operator[](size_t index) const override; |
2100 | | IBasicReflectablePtr<ALLOC> operator[](size_t index) override; |
2101 | | |
2102 | | bool getBool() const override; |
2103 | | int8_t getInt8() const override; |
2104 | | int16_t getInt16() const override; |
2105 | | int32_t getInt32() const override; |
2106 | | int64_t getInt64() const override; |
2107 | | uint8_t getUInt8() const override; |
2108 | | uint16_t getUInt16() const override; |
2109 | | uint32_t getUInt32() const override; |
2110 | | uint64_t getUInt64() const override; |
2111 | | float getFloat() const override; |
2112 | | double getDouble() const override; |
2113 | | Span<const uint8_t> getBytes() const override; |
2114 | | StringView getStringView() const override; |
2115 | | const BasicBitBuffer<ALLOC>& getBitBuffer() const override; |
2116 | | |
2117 | | int64_t toInt() const override; |
2118 | | uint64_t toUInt() const override; |
2119 | | double toDouble() const override; |
2120 | | string<ALLOC> toString(const ALLOC& allocator) const override; |
2121 | | }; |
2122 | | |
2123 | | /** |
2124 | | * Base class for constant reflectable arrays. |
2125 | | * |
2126 | | * Overrides non constant methods and throws exception with info about constness. |
2127 | | */ |
2128 | | template <typename ALLOC> |
2129 | | class ReflectableConstArrayBase : public ReflectableArrayBase<ALLOC> |
2130 | | { |
2131 | | private: |
2132 | | using Base = ReflectableArrayBase<ALLOC>; |
2133 | | |
2134 | | public: |
2135 | | using Base::Base; |
2136 | | using Base::getTypeInfo; |
2137 | | |
2138 | | void resize(size_t index) override; |
2139 | | IBasicReflectablePtr<ALLOC> at(size_t index) override; |
2140 | | IBasicReflectablePtr<ALLOC> operator[](size_t index) override; |
2141 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override; |
2142 | | void append(const AnyHolder<ALLOC>& value) override; |
2143 | | |
2144 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override; |
2145 | | }; |
2146 | | |
2147 | | /** |
2148 | | * Reflectable for arrays of builtin types (except bit field arrays). |
2149 | | */ |
2150 | | /** \{ */ |
2151 | | template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE> |
2152 | | class BuiltinReflectableConstArray : public ReflectableConstArrayBase<ALLOC> |
2153 | | { |
2154 | | private: |
2155 | | using Base = ReflectableConstArrayBase<ALLOC>; |
2156 | | |
2157 | | using ElementReflectable = ELEMENT_REFLECTABLE; |
2158 | | |
2159 | | public: |
2160 | | using Base::at; |
2161 | | using Base::getTypeInfo; |
2162 | | using Base::operator[]; |
2163 | | using Base::getAnyValue; |
2164 | | |
2165 | | BuiltinReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) : |
2166 | | Base(ElementReflectable::typeInfo(), allocator), |
2167 | | m_rawArray(rawArray) |
2168 | 25 | {} |
2169 | | |
2170 | | size_t size() const override |
2171 | 207 | { |
2172 | 207 | return m_rawArray.size(); |
2173 | 207 | } |
2174 | | |
2175 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2176 | 135 | { |
2177 | 135 | if (index >= size()) |
2178 | 48 | { |
2179 | 48 | throw CppRuntimeException("Index ") |
2180 | 48 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2181 | 48 | << "' of size " << size() << "!"; |
2182 | 48 | } |
2183 | | |
2184 | 87 | return std::allocate_shared<ElementReflectable>(Base::get_allocator(), m_rawArray[index]); |
2185 | 135 | } |
2186 | | |
2187 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2188 | 25 | { |
2189 | 25 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2190 | 25 | } |
2191 | | |
2192 | | private: |
2193 | | const RAW_ARRAY& m_rawArray; |
2194 | | }; |
2195 | | |
2196 | | template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE> |
2197 | | class BuiltinReflectableArray : public ReflectableArrayBase<ALLOC> |
2198 | | { |
2199 | | private: |
2200 | | using Base = ReflectableArrayBase<ALLOC>; |
2201 | | |
2202 | | using ElementReflectable = ELEMENT_REFLECTABLE; |
2203 | | |
2204 | | public: |
2205 | | using Base::getTypeInfo; |
2206 | | |
2207 | | BuiltinReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) : |
2208 | | Base(ElementReflectable::typeInfo(), allocator), |
2209 | | m_rawArray(rawArray) |
2210 | 74 | {} |
2211 | | |
2212 | | size_t size() const override |
2213 | 367 | { |
2214 | 367 | return m_rawArray.size(); |
2215 | 367 | } |
2216 | | |
2217 | | void resize(size_t size) override |
2218 | 8 | { |
2219 | 8 | m_rawArray.resize(size); |
2220 | 8 | } |
2221 | | |
2222 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2223 | 47 | { |
2224 | 47 | if (index >= size()) |
2225 | 8 | { |
2226 | 8 | throw CppRuntimeException("Index ") |
2227 | 8 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2228 | 8 | << "' of size " << size() << "!"; |
2229 | 8 | } |
2230 | | |
2231 | 39 | return std::allocate_shared<ElementReflectable>(Base::get_allocator(), m_rawArray[index]); |
2232 | 47 | } |
2233 | | |
2234 | | IBasicReflectablePtr<ALLOC> at(size_t index) override |
2235 | 164 | { |
2236 | 164 | if (index >= size()) |
2237 | 48 | { |
2238 | 48 | throw CppRuntimeException("Index ") |
2239 | 48 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2240 | 48 | << "' of size " << size() << "!"; |
2241 | 48 | } |
2242 | | |
2243 | 116 | return std::allocate_shared<ElementReflectable>(Base::get_allocator(), m_rawArray[index]); |
2244 | 164 | } |
2245 | | |
2246 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override |
2247 | 8 | { |
2248 | 8 | if (index >= size()) |
2249 | 4 | { |
2250 | 4 | throw CppRuntimeException("Index ") |
2251 | 4 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2252 | 4 | << "' of size " << size() << "!"; |
2253 | 4 | } |
2254 | | |
2255 | 4 | m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>(); |
2256 | 4 | } |
2257 | | |
2258 | | void append(const AnyHolder<ALLOC>& value) override |
2259 | 22 | { |
2260 | 22 | m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>()); |
2261 | 22 | } |
2262 | | |
2263 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2264 | 4 | { |
2265 | 4 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2266 | 4 | } |
2267 | | |
2268 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
2269 | 25 | { |
2270 | 25 | return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator); |
2271 | 25 | } |
2272 | | |
2273 | | private: |
2274 | | RAW_ARRAY& m_rawArray; |
2275 | | }; |
2276 | | /** \} */ |
2277 | | |
2278 | | /** |
2279 | | * Reflectable for arrays of fixed bit fields. |
2280 | | */ |
2281 | | /** \{ */ |
2282 | | template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE> |
2283 | | class FixedBitFieldReflectableConstArray : public ReflectableConstArrayBase<ALLOC> |
2284 | | { |
2285 | | private: |
2286 | | using Base = ReflectableConstArrayBase<ALLOC>; |
2287 | | |
2288 | | using ElementReflectable = ELEMENT_REFLECTABLE; |
2289 | | |
2290 | | public: |
2291 | | using Base::at; |
2292 | | using Base::getTypeInfo; |
2293 | | using Base::operator[]; |
2294 | | using Base::getAnyValue; |
2295 | | |
2296 | | FixedBitFieldReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray, uint8_t bitSize) : |
2297 | | Base(ElementReflectable::typeInfo(bitSize), allocator), |
2298 | | m_rawArray(rawArray) |
2299 | 2 | {} |
2300 | | |
2301 | | size_t size() const override |
2302 | 20 | { |
2303 | 20 | return m_rawArray.size(); |
2304 | 20 | } |
2305 | | |
2306 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2307 | 14 | { |
2308 | 14 | if (index >= size()) |
2309 | 4 | { |
2310 | 4 | throw CppRuntimeException("Index ") |
2311 | 4 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2312 | 4 | << "' of size " << size() << "!"; |
2313 | 4 | } |
2314 | | |
2315 | 10 | return std::allocate_shared<ElementReflectable>( |
2316 | 10 | Base::get_allocator(), m_rawArray[index], getTypeInfo().getBitSize()); |
2317 | 14 | } |
2318 | | |
2319 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2320 | 2 | { |
2321 | 2 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2322 | 2 | } |
2323 | | |
2324 | | private: |
2325 | | const RAW_ARRAY& m_rawArray; |
2326 | | }; |
2327 | | |
2328 | | template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE> |
2329 | | class FixedBitFieldReflectableArray : public ReflectableArrayBase<ALLOC> |
2330 | | { |
2331 | | private: |
2332 | | using Base = ReflectableArrayBase<ALLOC>; |
2333 | | |
2334 | | using ElementReflectable = ELEMENT_REFLECTABLE; |
2335 | | |
2336 | | public: |
2337 | | using Base::getTypeInfo; |
2338 | | |
2339 | | FixedBitFieldReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray, uint8_t bitSize) : |
2340 | | Base(ElementReflectable::typeInfo(bitSize), allocator), |
2341 | | m_rawArray(rawArray) |
2342 | 2 | {} |
2343 | | |
2344 | | size_t size() const override |
2345 | 39 | { |
2346 | 39 | return m_rawArray.size(); |
2347 | 39 | } |
2348 | | |
2349 | | void resize(size_t size) override |
2350 | 2 | { |
2351 | 2 | m_rawArray.resize(size); |
2352 | 2 | } |
2353 | | |
2354 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2355 | 7 | { |
2356 | 7 | if (index >= size()) |
2357 | 2 | { |
2358 | 2 | throw CppRuntimeException("Index ") |
2359 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2360 | 2 | << "' of size " << size() << "!"; |
2361 | 2 | } |
2362 | | |
2363 | 5 | return std::allocate_shared<ElementReflectable>( |
2364 | 5 | Base::get_allocator(), m_rawArray[index], getTypeInfo().getBitSize()); |
2365 | 7 | } |
2366 | | |
2367 | | IBasicReflectablePtr<ALLOC> at(size_t index) override |
2368 | 16 | { |
2369 | 16 | if (index >= size()) |
2370 | 4 | { |
2371 | 4 | throw CppRuntimeException("Index ") |
2372 | 4 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2373 | 4 | << "' of size " << size() << "!"; |
2374 | 4 | } |
2375 | | |
2376 | 12 | return std::allocate_shared<ElementReflectable>( |
2377 | 12 | Base::get_allocator(), m_rawArray[index], getTypeInfo().getBitSize()); |
2378 | 16 | } |
2379 | | |
2380 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override |
2381 | 2 | { |
2382 | 2 | if (index >= size()) |
2383 | 1 | { |
2384 | 1 | throw CppRuntimeException("Index ") |
2385 | 1 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2386 | 1 | << "' of size " << size() << "!"; |
2387 | 1 | } |
2388 | | |
2389 | 1 | m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>(); |
2390 | 1 | } |
2391 | | |
2392 | | void append(const AnyHolder<ALLOC>& value) override |
2393 | 1 | { |
2394 | 1 | m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>()); |
2395 | 1 | } |
2396 | | |
2397 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2398 | 1 | { |
2399 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2400 | 1 | } |
2401 | | |
2402 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
2403 | 2 | { |
2404 | 2 | return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator); |
2405 | 2 | } |
2406 | | |
2407 | | private: |
2408 | | RAW_ARRAY& m_rawArray; |
2409 | | }; |
2410 | | /** \} */ |
2411 | | |
2412 | | /** |
2413 | | * Reflectable for arrays of dynamic bit fields. |
2414 | | */ |
2415 | | /** \{ */ |
2416 | | template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE> |
2417 | | class DynamicBitFieldReflectableConstArray : public ReflectableConstArrayBase<ALLOC> |
2418 | | { |
2419 | | private: |
2420 | | using Base = ReflectableConstArrayBase<ALLOC>; |
2421 | | |
2422 | | using ElementReflectable = ELEMENT_REFLECTABLE; |
2423 | | |
2424 | | public: |
2425 | | using Base::at; |
2426 | | using Base::getTypeInfo; |
2427 | | using Base::operator[]; |
2428 | | using Base::getAnyValue; |
2429 | | |
2430 | | DynamicBitFieldReflectableConstArray( |
2431 | | const ALLOC& allocator, const RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
2432 | | Base(ElementReflectable::typeInfo(maxBitSize), allocator), |
2433 | | m_rawArray(rawArray), |
2434 | | m_maxBitSize(maxBitSize), |
2435 | | m_dynamicBitSize(dynamicBitSize) |
2436 | 2 | {} |
2437 | | |
2438 | | size_t size() const override |
2439 | 20 | { |
2440 | 20 | return m_rawArray.size(); |
2441 | 20 | } |
2442 | | |
2443 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2444 | 14 | { |
2445 | 14 | if (index >= size()) |
2446 | 4 | { |
2447 | 4 | throw CppRuntimeException("Index ") |
2448 | 4 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2449 | 4 | << "' of size " << size() << "!"; |
2450 | 4 | } |
2451 | | |
2452 | 10 | return std::allocate_shared<ElementReflectable>( |
2453 | 10 | Base::get_allocator(), m_rawArray[index], m_maxBitSize, m_dynamicBitSize); |
2454 | 14 | } |
2455 | | |
2456 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2457 | 2 | { |
2458 | 2 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2459 | 2 | } |
2460 | | |
2461 | | private: |
2462 | | const RAW_ARRAY& m_rawArray; |
2463 | | const uint8_t m_maxBitSize; |
2464 | | const uint8_t m_dynamicBitSize; |
2465 | | }; |
2466 | | |
2467 | | template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE> |
2468 | | class DynamicBitFieldReflectableArray : public ReflectableArrayBase<ALLOC> |
2469 | | { |
2470 | | private: |
2471 | | using Base = ReflectableArrayBase<ALLOC>; |
2472 | | |
2473 | | using ElementReflectable = ELEMENT_REFLECTABLE; |
2474 | | |
2475 | | public: |
2476 | | using Base::getTypeInfo; |
2477 | | |
2478 | | DynamicBitFieldReflectableArray( |
2479 | | const ALLOC& allocator, RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize) : |
2480 | | Base(ElementReflectable::typeInfo(maxBitSize), allocator), |
2481 | | m_rawArray(rawArray), |
2482 | | m_maxBitSize(maxBitSize), |
2483 | | m_dynamicBitSize(dynamicBitSize) |
2484 | 2 | {} |
2485 | | |
2486 | | size_t size() const override |
2487 | 39 | { |
2488 | 39 | return m_rawArray.size(); |
2489 | 39 | } |
2490 | | |
2491 | | void resize(size_t size) override |
2492 | 2 | { |
2493 | 2 | m_rawArray.resize(size); |
2494 | 2 | } |
2495 | | |
2496 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2497 | 7 | { |
2498 | 7 | if (index >= size()) |
2499 | 2 | { |
2500 | 2 | throw CppRuntimeException("Index ") |
2501 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2502 | 2 | << "' of size " << size() << "!"; |
2503 | 2 | } |
2504 | | |
2505 | 5 | return std::allocate_shared<ElementReflectable>( |
2506 | 5 | Base::get_allocator(), m_rawArray[index], m_maxBitSize, m_dynamicBitSize); |
2507 | 7 | } |
2508 | | |
2509 | | IBasicReflectablePtr<ALLOC> at(size_t index) override |
2510 | 16 | { |
2511 | 16 | if (index >= size()) |
2512 | 4 | { |
2513 | 4 | throw CppRuntimeException("Index ") |
2514 | 4 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2515 | 4 | << "' of size " << size() << "!"; |
2516 | 4 | } |
2517 | | |
2518 | 12 | return std::allocate_shared<ElementReflectable>( |
2519 | 12 | Base::get_allocator(), m_rawArray[index], m_maxBitSize, m_dynamicBitSize); |
2520 | 16 | } |
2521 | | |
2522 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override |
2523 | 2 | { |
2524 | 2 | if (index >= size()) |
2525 | 1 | { |
2526 | 1 | throw CppRuntimeException("Index ") |
2527 | 1 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2528 | 1 | << "' of size " << size() << "!"; |
2529 | 1 | } |
2530 | | |
2531 | 1 | m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>(); |
2532 | 1 | } |
2533 | | |
2534 | | void append(const AnyHolder<ALLOC>& value) override |
2535 | 1 | { |
2536 | 1 | m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>()); |
2537 | 1 | } |
2538 | | |
2539 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2540 | 1 | { |
2541 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2542 | 1 | } |
2543 | | |
2544 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
2545 | 2 | { |
2546 | 2 | return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator); |
2547 | 2 | } |
2548 | | |
2549 | | private: |
2550 | | RAW_ARRAY& m_rawArray; |
2551 | | const uint8_t m_maxBitSize; |
2552 | | const uint8_t m_dynamicBitSize; |
2553 | | }; |
2554 | | /** \} */ |
2555 | | |
2556 | | /** |
2557 | | * Typedef to a builtin array. |
2558 | | */ |
2559 | | /** \{ */ |
2560 | | template <typename ALLOC, typename RAW_ARRAY> |
2561 | | using BoolReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, BoolReflectable<ALLOC>>; |
2562 | | template <typename ALLOC, typename RAW_ARRAY> |
2563 | | using BoolReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, BoolReflectable<ALLOC>>; |
2564 | | |
2565 | | template <typename ALLOC, typename RAW_ARRAY> |
2566 | | using Int8ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int8Reflectable<ALLOC>>; |
2567 | | template <typename ALLOC, typename RAW_ARRAY> |
2568 | | using Int8ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int8Reflectable<ALLOC>>; |
2569 | | |
2570 | | template <typename ALLOC, typename RAW_ARRAY> |
2571 | | using Int16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int16Reflectable<ALLOC>>; |
2572 | | template <typename ALLOC, typename RAW_ARRAY> |
2573 | | using Int16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int16Reflectable<ALLOC>>; |
2574 | | |
2575 | | template <typename ALLOC, typename RAW_ARRAY> |
2576 | | using Int32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int32Reflectable<ALLOC>>; |
2577 | | template <typename ALLOC, typename RAW_ARRAY> |
2578 | | using Int32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int32Reflectable<ALLOC>>; |
2579 | | |
2580 | | template <typename ALLOC, typename RAW_ARRAY> |
2581 | | using Int64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int64Reflectable<ALLOC>>; |
2582 | | template <typename ALLOC, typename RAW_ARRAY> |
2583 | | using Int64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int64Reflectable<ALLOC>>; |
2584 | | |
2585 | | template <typename ALLOC, typename RAW_ARRAY> |
2586 | | using UInt8ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt8Reflectable<ALLOC>>; |
2587 | | template <typename ALLOC, typename RAW_ARRAY> |
2588 | | using UInt8ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt8Reflectable<ALLOC>>; |
2589 | | |
2590 | | template <typename ALLOC, typename RAW_ARRAY> |
2591 | | using UInt16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt16Reflectable<ALLOC>>; |
2592 | | template <typename ALLOC, typename RAW_ARRAY> |
2593 | | using UInt16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt16Reflectable<ALLOC>>; |
2594 | | |
2595 | | template <typename ALLOC, typename RAW_ARRAY> |
2596 | | using UInt32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt32Reflectable<ALLOC>>; |
2597 | | template <typename ALLOC, typename RAW_ARRAY> |
2598 | | using UInt32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt32Reflectable<ALLOC>>; |
2599 | | |
2600 | | template <typename ALLOC, typename RAW_ARRAY> |
2601 | | using UInt64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt64Reflectable<ALLOC>>; |
2602 | | template <typename ALLOC, typename RAW_ARRAY> |
2603 | | using UInt64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt64Reflectable<ALLOC>>; |
2604 | | |
2605 | | template <typename ALLOC, typename RAW_ARRAY> |
2606 | | using FixedSignedBitFieldReflectableConstArray = FixedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY, |
2607 | | FixedSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2608 | | template <typename ALLOC, typename RAW_ARRAY> |
2609 | | using FixedSignedBitFieldReflectableArray = FixedBitFieldReflectableArray<ALLOC, RAW_ARRAY, |
2610 | | FixedSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2611 | | |
2612 | | template <typename ALLOC, typename RAW_ARRAY> |
2613 | | using FixedUnsignedBitFieldReflectableConstArray = FixedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY, |
2614 | | FixedUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2615 | | template <typename ALLOC, typename RAW_ARRAY> |
2616 | | using FixedUnsignedBitFieldReflectableArray = FixedBitFieldReflectableArray<ALLOC, RAW_ARRAY, |
2617 | | FixedUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2618 | | |
2619 | | template <typename ALLOC, typename RAW_ARRAY> |
2620 | | using DynamicSignedBitFieldReflectableConstArray = DynamicBitFieldReflectableConstArray<ALLOC, RAW_ARRAY, |
2621 | | DynamicSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2622 | | template <typename ALLOC, typename RAW_ARRAY> |
2623 | | using DynamicSignedBitFieldReflectableArray = DynamicBitFieldReflectableArray<ALLOC, RAW_ARRAY, |
2624 | | DynamicSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2625 | | |
2626 | | template <typename ALLOC, typename RAW_ARRAY> |
2627 | | using DynamicUnsignedBitFieldReflectableConstArray = DynamicBitFieldReflectableConstArray<ALLOC, RAW_ARRAY, |
2628 | | DynamicUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2629 | | template <typename ALLOC, typename RAW_ARRAY> |
2630 | | using DynamicUnsignedBitFieldReflectableArray = DynamicBitFieldReflectableArray<ALLOC, RAW_ARRAY, |
2631 | | DynamicUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>; |
2632 | | |
2633 | | template <typename ALLOC, typename RAW_ARRAY> |
2634 | | using VarInt16ReflectableConstArray = |
2635 | | BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarInt16Reflectable<ALLOC>>; |
2636 | | template <typename ALLOC, typename RAW_ARRAY> |
2637 | | using VarInt16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarInt16Reflectable<ALLOC>>; |
2638 | | |
2639 | | template <typename ALLOC, typename RAW_ARRAY> |
2640 | | using VarInt32ReflectableConstArray = |
2641 | | BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarInt32Reflectable<ALLOC>>; |
2642 | | template <typename ALLOC, typename RAW_ARRAY> |
2643 | | using VarInt32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarInt32Reflectable<ALLOC>>; |
2644 | | |
2645 | | template <typename ALLOC, typename RAW_ARRAY> |
2646 | | using VarInt64ReflectableConstArray = |
2647 | | BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarInt64Reflectable<ALLOC>>; |
2648 | | template <typename ALLOC, typename RAW_ARRAY> |
2649 | | using VarInt64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarInt64Reflectable<ALLOC>>; |
2650 | | |
2651 | | template <typename ALLOC, typename RAW_ARRAY> |
2652 | | using VarIntReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarIntReflectable<ALLOC>>; |
2653 | | template <typename ALLOC, typename RAW_ARRAY> |
2654 | | using VarIntReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarIntReflectable<ALLOC>>; |
2655 | | |
2656 | | template <typename ALLOC, typename RAW_ARRAY> |
2657 | | using VarUInt16ReflectableConstArray = |
2658 | | BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarUInt16Reflectable<ALLOC>>; |
2659 | | template <typename ALLOC, typename RAW_ARRAY> |
2660 | | using VarUInt16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUInt16Reflectable<ALLOC>>; |
2661 | | |
2662 | | template <typename ALLOC, typename RAW_ARRAY> |
2663 | | using VarUInt32ReflectableConstArray = |
2664 | | BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarUInt32Reflectable<ALLOC>>; |
2665 | | template <typename ALLOC, typename RAW_ARRAY> |
2666 | | using VarUInt32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUInt32Reflectable<ALLOC>>; |
2667 | | |
2668 | | template <typename ALLOC, typename RAW_ARRAY> |
2669 | | using VarUInt64ReflectableConstArray = |
2670 | | BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarUInt64Reflectable<ALLOC>>; |
2671 | | template <typename ALLOC, typename RAW_ARRAY> |
2672 | | using VarUInt64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUInt64Reflectable<ALLOC>>; |
2673 | | |
2674 | | template <typename ALLOC, typename RAW_ARRAY> |
2675 | | using VarUIntReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarUIntReflectable<ALLOC>>; |
2676 | | template <typename ALLOC, typename RAW_ARRAY> |
2677 | | using VarUIntReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUIntReflectable<ALLOC>>; |
2678 | | |
2679 | | template <typename ALLOC, typename RAW_ARRAY> |
2680 | | using VarSizeReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarSizeReflectable<ALLOC>>; |
2681 | | template <typename ALLOC, typename RAW_ARRAY> |
2682 | | using VarSizeReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarSizeReflectable<ALLOC>>; |
2683 | | |
2684 | | template <typename ALLOC, typename RAW_ARRAY> |
2685 | | using Float16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Float16Reflectable<ALLOC>>; |
2686 | | template <typename ALLOC, typename RAW_ARRAY> |
2687 | | using Float16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Float16Reflectable<ALLOC>>; |
2688 | | |
2689 | | template <typename ALLOC, typename RAW_ARRAY> |
2690 | | using Float32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Float32Reflectable<ALLOC>>; |
2691 | | template <typename ALLOC, typename RAW_ARRAY> |
2692 | | using Float32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Float32Reflectable<ALLOC>>; |
2693 | | |
2694 | | template <typename ALLOC, typename RAW_ARRAY> |
2695 | | using Float64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Float64Reflectable<ALLOC>>; |
2696 | | template <typename ALLOC, typename RAW_ARRAY> |
2697 | | using Float64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Float64Reflectable<ALLOC>>; |
2698 | | |
2699 | | template <typename ALLOC, typename RAW_ARRAY> |
2700 | | using BytesReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, BytesReflectable<ALLOC>>; |
2701 | | template <typename ALLOC, typename RAW_ARRAY> |
2702 | | using BytesReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, BytesReflectable<ALLOC>>; |
2703 | | |
2704 | | template <typename ALLOC, typename RAW_ARRAY> |
2705 | | using StringReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, StringReflectable<ALLOC>>; |
2706 | | template <typename ALLOC, typename RAW_ARRAY> |
2707 | | using StringReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, StringReflectable<ALLOC>>; |
2708 | | |
2709 | | template <typename ALLOC, typename RAW_ARRAY> |
2710 | | using BitBufferReflectableConstArray = |
2711 | | BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, BitBufferReflectable<ALLOC>>; |
2712 | | template <typename ALLOC, typename RAW_ARRAY> |
2713 | | using BitBufferReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, BitBufferReflectable<ALLOC>>; |
2714 | | /** \} */ |
2715 | | |
2716 | | /** |
2717 | | * Reflectable for arrays of compound types. |
2718 | | */ |
2719 | | /** \{ */ |
2720 | | template <typename ALLOC, typename RAW_ARRAY> |
2721 | | class CompoundReflectableConstArray : public ReflectableConstArrayBase<ALLOC> |
2722 | | { |
2723 | | private: |
2724 | | using Base = ReflectableConstArrayBase<ALLOC>; |
2725 | | |
2726 | | using ElementType = typename RAW_ARRAY::value_type; |
2727 | | |
2728 | | public: |
2729 | | using Base::at; |
2730 | | using Base::getTypeInfo; |
2731 | | using Base::operator[]; |
2732 | | using Base::getAnyValue; |
2733 | | |
2734 | | CompoundReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) : |
2735 | | Base(ElementType::typeInfo(), allocator), |
2736 | | m_rawArray(rawArray) |
2737 | 1 | {} |
2738 | | |
2739 | | size_t size() const override |
2740 | 8 | { |
2741 | 8 | return m_rawArray.size(); |
2742 | 8 | } |
2743 | | |
2744 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2745 | 4 | { |
2746 | 4 | if (index >= size()) |
2747 | 2 | { |
2748 | 2 | throw CppRuntimeException("Index ") |
2749 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2750 | 2 | << "' of size " << size() << "!"; |
2751 | 2 | } |
2752 | | |
2753 | 2 | return m_rawArray[index].reflectable(Base::get_allocator()); |
2754 | 4 | } |
2755 | | |
2756 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2757 | 1 | { |
2758 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2759 | 1 | } |
2760 | | |
2761 | | private: |
2762 | | const RAW_ARRAY& m_rawArray; |
2763 | | }; |
2764 | | |
2765 | | template <typename ALLOC, typename RAW_ARRAY> |
2766 | | class CompoundReflectableArray : public ReflectableArrayBase<ALLOC> |
2767 | | { |
2768 | | private: |
2769 | | using Base = ReflectableArrayBase<ALLOC>; |
2770 | | |
2771 | | using ElementType = typename RAW_ARRAY::value_type; |
2772 | | |
2773 | | public: |
2774 | | using Base::getTypeInfo; |
2775 | | |
2776 | | CompoundReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) : |
2777 | | Base(ElementType::typeInfo(), allocator), |
2778 | | m_rawArray(rawArray) |
2779 | 41 | {} |
2780 | | |
2781 | | size_t size() const override |
2782 | 112 | { |
2783 | 112 | return m_rawArray.size(); |
2784 | 112 | } |
2785 | | |
2786 | | void resize(size_t size) override |
2787 | 5 | { |
2788 | 5 | m_rawArray.resize(size); |
2789 | 5 | } |
2790 | | |
2791 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2792 | 31 | { |
2793 | 31 | if (index >= size()) |
2794 | 2 | { |
2795 | 2 | throw CppRuntimeException("Index ") |
2796 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2797 | 2 | << "' of size " << size() << "!"; |
2798 | 2 | } |
2799 | | |
2800 | 29 | return m_rawArray[index].reflectable(Base::get_allocator()); |
2801 | 31 | } |
2802 | | |
2803 | | IBasicReflectablePtr<ALLOC> at(size_t index) override |
2804 | 27 | { |
2805 | 27 | if (index >= size()) |
2806 | 2 | { |
2807 | 2 | throw CppRuntimeException("Index ") |
2808 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2809 | 2 | << "' of size " << size() << "!"; |
2810 | 2 | } |
2811 | | |
2812 | 25 | return m_rawArray[index].reflectable(Base::get_allocator()); |
2813 | 27 | } |
2814 | | |
2815 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override |
2816 | 2 | { |
2817 | 2 | if (index >= size()) |
2818 | 1 | { |
2819 | 1 | throw CppRuntimeException("Index ") |
2820 | 1 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2821 | 1 | << "' of size " << size() << "!"; |
2822 | 1 | } |
2823 | | |
2824 | 1 | m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>(); |
2825 | 1 | } |
2826 | | |
2827 | | void append(const AnyHolder<ALLOC>& value) override |
2828 | 2 | { |
2829 | 2 | m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>()); |
2830 | 2 | } |
2831 | | |
2832 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2833 | 1 | { |
2834 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2835 | 1 | } |
2836 | | |
2837 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
2838 | 2 | { |
2839 | 2 | return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator); |
2840 | 2 | } |
2841 | | |
2842 | | private: |
2843 | | RAW_ARRAY& m_rawArray; |
2844 | | }; |
2845 | | /** \} */ |
2846 | | |
2847 | | /** Reflectable for arrays of bitmask types. */ |
2848 | | /** \{ */ |
2849 | | template <typename ALLOC, typename RAW_ARRAY> |
2850 | | class BitmaskReflectableConstArray : public ReflectableConstArrayBase<ALLOC> |
2851 | | { |
2852 | | private: |
2853 | | using Base = ReflectableConstArrayBase<ALLOC>; |
2854 | | |
2855 | | using ElementType = typename RAW_ARRAY::value_type; |
2856 | | |
2857 | | public: |
2858 | | using Base::at; |
2859 | | using Base::getTypeInfo; |
2860 | | using Base::operator[]; |
2861 | | using Base::getAnyValue; |
2862 | | |
2863 | | BitmaskReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) : |
2864 | | Base(ElementType::typeInfo(), allocator), |
2865 | | m_rawArray(rawArray) |
2866 | 1 | {} |
2867 | | |
2868 | | size_t size() const override |
2869 | 8 | { |
2870 | 8 | return m_rawArray.size(); |
2871 | 8 | } |
2872 | | |
2873 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2874 | 5 | { |
2875 | 5 | if (index >= size()) |
2876 | 2 | { |
2877 | 2 | throw CppRuntimeException("Index ") |
2878 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2879 | 2 | << "' of size " << size() << "!"; |
2880 | 2 | } |
2881 | | |
2882 | 3 | return m_rawArray[index].reflectable(Base::get_allocator()); |
2883 | 5 | } |
2884 | | |
2885 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2886 | 1 | { |
2887 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2888 | 1 | } |
2889 | | |
2890 | | private: |
2891 | | const RAW_ARRAY& m_rawArray; |
2892 | | }; |
2893 | | |
2894 | | template <typename ALLOC, typename RAW_ARRAY> |
2895 | | class BitmaskReflectableArray : public ReflectableArrayBase<ALLOC> |
2896 | | { |
2897 | | private: |
2898 | | using Base = ReflectableArrayBase<ALLOC>; |
2899 | | |
2900 | | using ElementType = typename RAW_ARRAY::value_type; |
2901 | | using UnderlyingElementType = typename ElementType::underlying_type; |
2902 | | |
2903 | | public: |
2904 | | using Base::getTypeInfo; |
2905 | | |
2906 | | BitmaskReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) : |
2907 | | Base(ElementType::typeInfo(), allocator), |
2908 | | m_rawArray(rawArray) |
2909 | 1 | {} |
2910 | | |
2911 | | size_t size() const override |
2912 | 30 | { |
2913 | 30 | return m_rawArray.size(); |
2914 | 30 | } |
2915 | | |
2916 | | void resize(size_t size) override |
2917 | 2 | { |
2918 | 2 | m_rawArray.resize(size); |
2919 | 2 | } |
2920 | | |
2921 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
2922 | 5 | { |
2923 | 5 | if (index >= size()) |
2924 | 2 | { |
2925 | 2 | throw CppRuntimeException("Index ") |
2926 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2927 | 2 | << "' of size " << size() << "!"; |
2928 | 2 | } |
2929 | | |
2930 | 3 | return m_rawArray[index].reflectable(Base::get_allocator()); |
2931 | 5 | } |
2932 | | |
2933 | | IBasicReflectablePtr<ALLOC> at(size_t index) override |
2934 | 9 | { |
2935 | 9 | if (index >= size()) |
2936 | 2 | { |
2937 | 2 | throw CppRuntimeException("Index ") |
2938 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2939 | 2 | << "' of size " << size() << "!"; |
2940 | 2 | } |
2941 | | |
2942 | 7 | return m_rawArray[index].reflectable(Base::get_allocator()); |
2943 | 9 | } |
2944 | | |
2945 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override |
2946 | 3 | { |
2947 | 3 | if (index >= size()) |
2948 | 1 | { |
2949 | 1 | throw CppRuntimeException("Index ") |
2950 | 1 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
2951 | 1 | << "' of size " << size() << "!"; |
2952 | 1 | } |
2953 | | |
2954 | 2 | if (value.template isType<ElementType>()) |
2955 | 1 | { |
2956 | 1 | m_rawArray[index] = value.template get<ElementType>(); |
2957 | 1 | } |
2958 | 1 | else |
2959 | 1 | { |
2960 | 1 | m_rawArray[index] = ElementType(value.template get<UnderlyingElementType>()); |
2961 | 1 | } |
2962 | 2 | } |
2963 | | |
2964 | | void append(const AnyHolder<ALLOC>& value) override |
2965 | 2 | { |
2966 | 2 | if (value.template isType<ElementType>()) |
2967 | 1 | { |
2968 | 1 | m_rawArray.push_back(value.template get<ElementType>()); |
2969 | 1 | } |
2970 | 1 | else |
2971 | 1 | { |
2972 | 1 | m_rawArray.push_back(ElementType(value.template get<UnderlyingElementType>())); |
2973 | 1 | } |
2974 | 2 | } |
2975 | | |
2976 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
2977 | 1 | { |
2978 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
2979 | 1 | } |
2980 | | |
2981 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
2982 | 1 | { |
2983 | 1 | return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator); |
2984 | 1 | } |
2985 | | |
2986 | | private: |
2987 | | RAW_ARRAY& m_rawArray; |
2988 | | }; |
2989 | | /** \} */ |
2990 | | |
2991 | | /** Reflectable for arrays of enum types. */ |
2992 | | /** \{ */ |
2993 | | template <typename ALLOC, typename RAW_ARRAY> |
2994 | | class EnumReflectableConstArray : public ReflectableConstArrayBase<ALLOC> |
2995 | | { |
2996 | | private: |
2997 | | using Base = ReflectableConstArrayBase<ALLOC>; |
2998 | | |
2999 | | using ElementType = typename RAW_ARRAY::value_type; |
3000 | | |
3001 | | public: |
3002 | | using Base::at; |
3003 | | using Base::getTypeInfo; |
3004 | | using Base::operator[]; |
3005 | | using Base::getAnyValue; |
3006 | | |
3007 | | EnumReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) : |
3008 | | Base(enumTypeInfo<ElementType, ALLOC>(), allocator), |
3009 | | m_rawArray(rawArray) |
3010 | 1 | {} |
3011 | | |
3012 | | size_t size() const override |
3013 | 8 | { |
3014 | 8 | return m_rawArray.size(); |
3015 | 8 | } |
3016 | | |
3017 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
3018 | 5 | { |
3019 | 5 | if (index >= size()) |
3020 | 2 | { |
3021 | 2 | throw CppRuntimeException("Index ") |
3022 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
3023 | 2 | << "' of size " << size() << "!"; |
3024 | 2 | } |
3025 | | |
3026 | 3 | return enumReflectable(m_rawArray[index], Base::get_allocator()); |
3027 | 5 | } |
3028 | | |
3029 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
3030 | 1 | { |
3031 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
3032 | 1 | } |
3033 | | |
3034 | | private: |
3035 | | const RAW_ARRAY& m_rawArray; |
3036 | | }; |
3037 | | |
3038 | | template <typename ALLOC, typename RAW_ARRAY> |
3039 | | class EnumReflectableArray : public ReflectableArrayBase<ALLOC> |
3040 | | { |
3041 | | private: |
3042 | | using Base = ReflectableArrayBase<ALLOC>; |
3043 | | |
3044 | | using ElementType = typename RAW_ARRAY::value_type; |
3045 | | using UnderlyingElementType = typename std::underlying_type<ElementType>::type; |
3046 | | |
3047 | | public: |
3048 | | using Base::getTypeInfo; |
3049 | | |
3050 | | EnumReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) : |
3051 | | Base(enumTypeInfo<ElementType, ALLOC>(), allocator), |
3052 | | m_rawArray(rawArray) |
3053 | 1 | {} |
3054 | | |
3055 | | size_t size() const override |
3056 | 30 | { |
3057 | 30 | return m_rawArray.size(); |
3058 | 30 | } |
3059 | | |
3060 | | void resize(size_t size) override |
3061 | 2 | { |
3062 | 2 | m_rawArray.resize(size); |
3063 | 2 | } |
3064 | | |
3065 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
3066 | 5 | { |
3067 | 5 | if (index >= size()) |
3068 | 2 | { |
3069 | 2 | throw CppRuntimeException("Index ") |
3070 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
3071 | 2 | << "' of size " << size() << "!"; |
3072 | 2 | } |
3073 | | |
3074 | 3 | return enumReflectable(m_rawArray[index], Base::get_allocator()); |
3075 | 5 | } |
3076 | | |
3077 | | IBasicReflectablePtr<ALLOC> at(size_t index) override |
3078 | 9 | { |
3079 | 9 | if (index >= size()) |
3080 | 2 | { |
3081 | 2 | throw CppRuntimeException("Index ") |
3082 | 2 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
3083 | 2 | << "' of size " << size() << "!"; |
3084 | 2 | } |
3085 | | |
3086 | 7 | return enumReflectable(m_rawArray[index], Base::get_allocator()); |
3087 | 9 | } |
3088 | | |
3089 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override |
3090 | 3 | { |
3091 | 3 | if (index >= size()) |
3092 | 1 | { |
3093 | 1 | throw CppRuntimeException("Index ") |
3094 | 1 | << index << " out of range for reflectable array '" << getTypeInfo().getSchemaName() |
3095 | 1 | << "' of size " << size() << "!"; |
3096 | 1 | } |
3097 | | |
3098 | 2 | if (value.template isType<ElementType>()) |
3099 | 1 | { |
3100 | 1 | m_rawArray[index] = value.template get<ElementType>(); |
3101 | 1 | } |
3102 | 1 | else |
3103 | 1 | { |
3104 | 1 | m_rawArray[index] = valueToEnum<ElementType>(value.template get<UnderlyingElementType>()); |
3105 | 1 | } |
3106 | 2 | } |
3107 | | |
3108 | | void append(const AnyHolder<ALLOC>& value) override |
3109 | 2 | { |
3110 | 2 | if (value.template isType<ElementType>()) |
3111 | 1 | { |
3112 | 1 | m_rawArray.push_back(value.template get<ElementType>()); |
3113 | 1 | } |
3114 | 1 | else |
3115 | 1 | { |
3116 | 1 | m_rawArray.push_back(valueToEnum<ElementType>(value.template get<UnderlyingElementType>())); |
3117 | 1 | } |
3118 | 2 | } |
3119 | | |
3120 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
3121 | 1 | { |
3122 | 1 | return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator); |
3123 | 1 | } |
3124 | | |
3125 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
3126 | 1 | { |
3127 | 1 | return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator); |
3128 | 1 | } |
3129 | | |
3130 | | private: |
3131 | | RAW_ARRAY& m_rawArray; |
3132 | | }; |
3133 | | /** \} */ |
3134 | | |
3135 | | /** |
3136 | | * Wrapper around reflectable which actually owns the reflected object. |
3137 | | * |
3138 | | * This is needed in ZserioTreeCreator to be able to generically create the new instance of a zserio object. |
3139 | | */ |
3140 | | template <typename T, typename ALLOC = typename T::allocator_type> |
3141 | | class ReflectableOwner : public IBasicReflectable<ALLOC> |
3142 | | { |
3143 | | public: |
3144 | | ReflectableOwner() : |
3145 | | ReflectableOwner(ALLOC()) |
3146 | | {} |
3147 | | |
3148 | | explicit ReflectableOwner(const ALLOC& allocator) : |
3149 | | m_object(allocator), |
3150 | | m_reflectable(m_object.reflectable(allocator)) |
3151 | 85 | {} |
3152 | | |
3153 | | const IBasicTypeInfo<ALLOC>& getTypeInfo() const override |
3154 | 2 | { |
3155 | 2 | return m_reflectable->getTypeInfo(); |
3156 | 2 | } |
3157 | | |
3158 | | bool isArray() const override |
3159 | 1 | { |
3160 | 1 | return m_reflectable->isArray(); |
3161 | 1 | } |
3162 | | |
3163 | | void initializeChildren() override |
3164 | 8 | { |
3165 | 8 | m_reflectable->initializeChildren(); |
3166 | 8 | } |
3167 | | |
3168 | | void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) override |
3169 | 6 | { |
3170 | 6 | m_reflectable->initialize(typeArguments); |
3171 | 6 | } |
3172 | | |
3173 | | size_t initializeOffsets(size_t bitPosition) override |
3174 | 1 | { |
3175 | 1 | return m_reflectable->initializeOffsets(bitPosition); |
3176 | 1 | } |
3177 | | |
3178 | | size_t initializeOffsets() override |
3179 | 1 | { |
3180 | 1 | return initializeOffsets(0); |
3181 | 1 | } |
3182 | | |
3183 | | size_t bitSizeOf(size_t bitPosition) const override |
3184 | 2 | { |
3185 | 2 | return m_reflectable->bitSizeOf(bitPosition); |
3186 | 2 | } |
3187 | | |
3188 | | size_t bitSizeOf() const override |
3189 | 2 | { |
3190 | 2 | return bitSizeOf(0); |
3191 | 2 | } |
3192 | | |
3193 | | void write(BitStreamWriter& writer) const override |
3194 | 1 | { |
3195 | 1 | m_reflectable->write(writer); |
3196 | 1 | } |
3197 | | |
3198 | | IBasicReflectableConstPtr<ALLOC> getField(StringView name) const override |
3199 | 1 | { |
3200 | 1 | return m_reflectable->getField(name); |
3201 | 1 | } |
3202 | | |
3203 | | IBasicReflectablePtr<ALLOC> getField(StringView name) override |
3204 | 132 | { |
3205 | 132 | return m_reflectable->getField(name); |
3206 | 132 | } |
3207 | | |
3208 | | IBasicReflectablePtr<ALLOC> createField(StringView name) override |
3209 | 18 | { |
3210 | 18 | return m_reflectable->createField(name); |
3211 | 18 | } |
3212 | | |
3213 | | void setField(StringView name, const AnyHolder<ALLOC>& value) override |
3214 | 62 | { |
3215 | 62 | m_reflectable->setField(name, value); |
3216 | 62 | } |
3217 | | |
3218 | | IBasicReflectableConstPtr<ALLOC> getParameter(StringView name) const override |
3219 | 1 | { |
3220 | 1 | return m_reflectable->getParameter(name); |
3221 | 1 | } |
3222 | | |
3223 | | IBasicReflectablePtr<ALLOC> getParameter(StringView name) override |
3224 | 10 | { |
3225 | 10 | return m_reflectable->getParameter(name); |
3226 | 10 | } |
3227 | | |
3228 | | IBasicReflectableConstPtr<ALLOC> callFunction(StringView name) const override |
3229 | 1 | { |
3230 | 1 | return m_reflectable->callFunction(name); |
3231 | 1 | } |
3232 | | |
3233 | | IBasicReflectablePtr<ALLOC> callFunction(StringView name) override |
3234 | 1 | { |
3235 | 1 | return m_reflectable->callFunction(name); |
3236 | 1 | } |
3237 | | |
3238 | | StringView getChoice() const override |
3239 | 2 | { |
3240 | 2 | return m_reflectable->getChoice(); |
3241 | 2 | } |
3242 | | |
3243 | | IBasicReflectableConstPtr<ALLOC> find(StringView path) const override |
3244 | 1 | { |
3245 | 1 | return m_reflectable->find(path); |
3246 | 1 | } |
3247 | | |
3248 | | IBasicReflectablePtr<ALLOC> find(StringView path) override |
3249 | 48 | { |
3250 | 48 | return m_reflectable->find(path); |
3251 | 48 | } |
3252 | | |
3253 | | IBasicReflectableConstPtr<ALLOC> operator[](StringView path) const override |
3254 | 1 | { |
3255 | 1 | return m_reflectable->operator[](path); |
3256 | 1 | } |
3257 | | |
3258 | | IBasicReflectablePtr<ALLOC> operator[](StringView path) override |
3259 | 1 | { |
3260 | 1 | return m_reflectable->operator[](path); |
3261 | 1 | } |
3262 | | |
3263 | | size_t size() const override |
3264 | 1 | { |
3265 | 1 | return m_reflectable->size(); |
3266 | 1 | } |
3267 | | |
3268 | | void resize(size_t size) override |
3269 | 1 | { |
3270 | 1 | m_reflectable->resize(size); |
3271 | 1 | } |
3272 | | |
3273 | | IBasicReflectableConstPtr<ALLOC> at(size_t index) const override |
3274 | 1 | { |
3275 | 1 | return m_reflectable->at(index); |
3276 | 1 | } |
3277 | | |
3278 | | IBasicReflectablePtr<ALLOC> at(size_t index) override |
3279 | 1 | { |
3280 | 1 | return m_reflectable->at(index); |
3281 | 1 | } |
3282 | | |
3283 | | IBasicReflectableConstPtr<ALLOC> operator[](size_t index) const override |
3284 | 1 | { |
3285 | 1 | return m_reflectable->operator[](index); |
3286 | 1 | } |
3287 | | |
3288 | | IBasicReflectablePtr<ALLOC> operator[](size_t index) override |
3289 | 1 | { |
3290 | 1 | return m_reflectable->operator[](index); |
3291 | 1 | } |
3292 | | |
3293 | | void setAt(const AnyHolder<ALLOC>& value, size_t index) override |
3294 | 1 | { |
3295 | 1 | m_reflectable->setAt(value, index); |
3296 | 1 | } |
3297 | | |
3298 | | void append(const AnyHolder<ALLOC>& value) override |
3299 | 1 | { |
3300 | 1 | m_reflectable->append(value); |
3301 | 1 | } |
3302 | | |
3303 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override |
3304 | 1 | { |
3305 | 1 | return m_reflectable->getAnyValue(allocator); |
3306 | 1 | } |
3307 | | |
3308 | | AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override |
3309 | 17 | { |
3310 | 17 | return m_reflectable->getAnyValue(allocator); |
3311 | 17 | } |
3312 | | |
3313 | | AnyHolder<ALLOC> getAnyValue() const override |
3314 | 1 | { |
3315 | 1 | return getAnyValue(ALLOC()); |
3316 | 1 | } |
3317 | | |
3318 | | AnyHolder<ALLOC> getAnyValue() override |
3319 | 1 | { |
3320 | 1 | return getAnyValue(ALLOC()); |
3321 | 1 | } |
3322 | | |
3323 | | // exact checked getters |
3324 | | bool getBool() const override |
3325 | 1 | { |
3326 | 1 | return m_reflectable->getBool(); |
3327 | 1 | } |
3328 | | int8_t getInt8() const override |
3329 | 1 | { |
3330 | 1 | return m_reflectable->getInt8(); |
3331 | 1 | } |
3332 | | int16_t getInt16() const override |
3333 | 1 | { |
3334 | 1 | return m_reflectable->getInt16(); |
3335 | 1 | } |
3336 | | int32_t getInt32() const override |
3337 | 1 | { |
3338 | 1 | return m_reflectable->getInt32(); |
3339 | 1 | } |
3340 | | int64_t getInt64() const override |
3341 | 1 | { |
3342 | 1 | return m_reflectable->getInt64(); |
3343 | 1 | } |
3344 | | uint8_t getUInt8() const override |
3345 | 1 | { |
3346 | 1 | return m_reflectable->getUInt8(); |
3347 | 1 | } |
3348 | | uint16_t getUInt16() const override |
3349 | 1 | { |
3350 | 1 | return m_reflectable->getUInt16(); |
3351 | 1 | } |
3352 | | uint32_t getUInt32() const override |
3353 | 1 | { |
3354 | 1 | return m_reflectable->getUInt32(); |
3355 | 1 | } |
3356 | | uint64_t getUInt64() const override |
3357 | 1 | { |
3358 | 1 | return m_reflectable->getUInt64(); |
3359 | 1 | } |
3360 | | float getFloat() const override |
3361 | 1 | { |
3362 | 1 | return m_reflectable->getFloat(); |
3363 | 1 | } |
3364 | | double getDouble() const override |
3365 | 1 | { |
3366 | 1 | return m_reflectable->getDouble(); |
3367 | 1 | } |
3368 | | Span<const uint8_t> getBytes() const override |
3369 | 1 | { |
3370 | 1 | return m_reflectable->getBytes(); |
3371 | 1 | } |
3372 | | StringView getStringView() const override |
3373 | 1 | { |
3374 | 1 | return m_reflectable->getStringView(); |
3375 | 1 | } |
3376 | | const BasicBitBuffer<ALLOC>& getBitBuffer() const override |
3377 | 1 | { |
3378 | 1 | return m_reflectable->getBitBuffer(); |
3379 | 1 | } |
3380 | | |
3381 | | // convenience conversions |
3382 | | int64_t toInt() const override |
3383 | 1 | { |
3384 | 1 | return m_reflectable->toInt(); |
3385 | 1 | } |
3386 | | uint64_t toUInt() const override |
3387 | 1 | { |
3388 | 1 | return m_reflectable->toUInt(); |
3389 | 1 | } |
3390 | | double toDouble() const override |
3391 | 1 | { |
3392 | 1 | return m_reflectable->toDouble(); |
3393 | 1 | } |
3394 | | string<RebindAlloc<ALLOC, char>> toString(const ALLOC& allocator) const override |
3395 | 1 | { |
3396 | 1 | return m_reflectable->toString(allocator); |
3397 | 1 | } |
3398 | | string<RebindAlloc<ALLOC, char>> toString() const override |
3399 | 1 | { |
3400 | 1 | return toString(ALLOC()); |
3401 | 1 | } |
3402 | | |
3403 | | const ParsingInfo& parsingInfo() const override |
3404 | 1 | { |
3405 | 1 | return m_reflectable->parsingInfo(); |
3406 | 1 | } |
3407 | | |
3408 | | private: |
3409 | | T m_object; |
3410 | | IBasicReflectablePtr<ALLOC> m_reflectable; |
3411 | | }; |
3412 | | |
3413 | | /** |
3414 | | * Factory used to make it easier to create reflectable instances. |
3415 | | * |
3416 | | * Creates reflectables for all builtin types and for arrays. |
3417 | | */ |
3418 | | template <typename ALLOC> |
3419 | | class BasicReflectableFactory |
3420 | | { |
3421 | | public: |
3422 | | static IBasicReflectablePtr<ALLOC> getBool(bool value, const ALLOC& allocator = ALLOC()) |
3423 | 13 | { |
3424 | 13 | return std::allocate_shared<BoolReflectable<ALLOC>>(allocator, value); |
3425 | 13 | } |
3426 | | |
3427 | | static IBasicReflectablePtr<ALLOC> getInt8(int8_t value, const ALLOC& allocator = ALLOC()) |
3428 | 16 | { |
3429 | 16 | return std::allocate_shared<Int8Reflectable<ALLOC>>(allocator, value); |
3430 | 16 | } |
3431 | | |
3432 | | static IBasicReflectablePtr<ALLOC> getInt16(int16_t value, const ALLOC& allocator = ALLOC()) |
3433 | 12 | { |
3434 | 12 | return std::allocate_shared<Int16Reflectable<ALLOC>>(allocator, value); |
3435 | 12 | } |
3436 | | |
3437 | | static IBasicReflectablePtr<ALLOC> getInt32(int32_t value, const ALLOC& allocator = ALLOC()) |
3438 | 15 | { |
3439 | 15 | return std::allocate_shared<Int32Reflectable<ALLOC>>(allocator, value); |
3440 | 15 | } |
3441 | | |
3442 | | static IBasicReflectablePtr<ALLOC> getInt64(int64_t value, const ALLOC& allocator = ALLOC()) |
3443 | 11 | { |
3444 | 11 | return std::allocate_shared<Int64Reflectable<ALLOC>>(allocator, value); |
3445 | 11 | } |
3446 | | |
3447 | | static IBasicReflectablePtr<ALLOC> getUInt8(uint8_t value, const ALLOC& allocator = ALLOC()) |
3448 | 35 | { |
3449 | 35 | return std::allocate_shared<UInt8Reflectable<ALLOC>>(allocator, value); |
3450 | 35 | } |
3451 | | |
3452 | | static IBasicReflectablePtr<ALLOC> getUInt16(uint16_t value, const ALLOC& allocator = ALLOC()) |
3453 | 11 | { |
3454 | 11 | return std::allocate_shared<UInt16Reflectable<ALLOC>>(allocator, value); |
3455 | 11 | } |
3456 | | |
3457 | | static IBasicReflectablePtr<ALLOC> getUInt32(uint32_t value, const ALLOC& allocator = ALLOC()) |
3458 | 60 | { |
3459 | 60 | return std::allocate_shared<UInt32Reflectable<ALLOC>>(allocator, value); |
3460 | 60 | } |
3461 | | |
3462 | | static IBasicReflectablePtr<ALLOC> getUInt64(uint64_t value, const ALLOC& allocator = ALLOC()) |
3463 | 12 | { |
3464 | 12 | return std::allocate_shared<UInt64Reflectable<ALLOC>>(allocator, value); |
3465 | 12 | } |
3466 | | |
3467 | | template <typename T, typename std::enable_if<std::is_signed<T>::value, int>::type = 0> |
3468 | | static IBasicReflectablePtr<ALLOC> getFixedSignedBitField( |
3469 | | T value, uint8_t bitSize, const ALLOC& allocator = ALLOC()) |
3470 | 45 | { |
3471 | 45 | return std::allocate_shared<FixedSignedBitFieldReflectable<ALLOC, T>>(allocator, value, bitSize); |
3472 | 45 | } |
3473 | | |
3474 | | template <typename T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0> |
3475 | | static IBasicReflectablePtr<ALLOC> getFixedUnsignedBitField( |
3476 | | T value, uint8_t bitSize, const ALLOC& allocator = ALLOC()) |
3477 | 82 | { |
3478 | 82 | return std::allocate_shared<FixedUnsignedBitFieldReflectable<ALLOC, T>>(allocator, value, bitSize); |
3479 | 82 | } |
3480 | | |
3481 | | template <typename T, typename std::enable_if<std::is_signed<T>::value, int>::type = 0> |
3482 | | static IBasicReflectablePtr<ALLOC> getDynamicSignedBitField( |
3483 | | T value, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC()) |
3484 | 16 | { |
3485 | 16 | return std::allocate_shared<DynamicSignedBitFieldReflectable<ALLOC, T>>( |
3486 | 16 | allocator, value, maxBitSize, dynamicBitSize); |
3487 | 16 | } |
3488 | | |
3489 | | // for dynamic signed bit field given by a type reference (e.g. parameter, function return type) |
3490 | | static IBasicReflectablePtr<ALLOC> getDynamicSignedBitField( |
3491 | | int64_t value, uint8_t maxBitSize, const ALLOC& allocator = ALLOC()) |
3492 | 2 | { |
3493 | 2 | if (maxBitSize != 64) |
3494 | 1 | { |
3495 | 1 | throw CppRuntimeException("ReflectableFactory::getDynamicSignedBitField - ") |
3496 | 1 | << "maxBitSize != 64 for referenced dynamic bit field!"; |
3497 | 1 | } |
3498 | | |
3499 | 1 | return getDynamicSignedBitField(value, maxBitSize, maxBitSize, allocator); |
3500 | 2 | } |
3501 | | |
3502 | | template <typename T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0> |
3503 | | static IBasicReflectablePtr<ALLOC> getDynamicUnsignedBitField( |
3504 | | T value, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC()) |
3505 | 16 | { |
3506 | 16 | return std::allocate_shared<DynamicUnsignedBitFieldReflectable<ALLOC, T>>( |
3507 | 16 | allocator, value, maxBitSize, dynamicBitSize); |
3508 | 16 | } |
3509 | | |
3510 | | // for dynamic unsigned bit field given a by type reference (e.g. parameter, function return type) |
3511 | | static IBasicReflectablePtr<ALLOC> getDynamicUnsignedBitField( |
3512 | | uint64_t value, uint8_t maxBitSize, const ALLOC& allocator = ALLOC()) |
3513 | 2 | { |
3514 | 2 | if (maxBitSize != 64) |
3515 | 1 | { |
3516 | 1 | throw CppRuntimeException("ReflectableFactory::getDynamicUnsignedBitField - ") |
3517 | 1 | << "maxBitSize != 64 for referenced dynamic bit field!"; |
3518 | 1 | } |
3519 | | |
3520 | 1 | return getDynamicUnsignedBitField(value, maxBitSize, maxBitSize, allocator); |
3521 | 2 | } |
3522 | | |
3523 | | static IBasicReflectablePtr<ALLOC> getVarInt16(int16_t value, const ALLOC& allocator = ALLOC()) |
3524 | 2 | { |
3525 | 2 | return std::allocate_shared<VarInt16Reflectable<ALLOC>>(allocator, value); |
3526 | 2 | } |
3527 | | |
3528 | | static IBasicReflectablePtr<ALLOC> getVarInt32(int32_t value, const ALLOC& allocator = ALLOC()) |
3529 | 2 | { |
3530 | 2 | return std::allocate_shared<VarInt32Reflectable<ALLOC>>(allocator, value); |
3531 | 2 | } |
3532 | | |
3533 | | static IBasicReflectablePtr<ALLOC> getVarInt64(int64_t value, const ALLOC& allocator = ALLOC()) |
3534 | 2 | { |
3535 | 2 | return std::allocate_shared<VarInt64Reflectable<ALLOC>>(allocator, value); |
3536 | 2 | } |
3537 | | |
3538 | | static IBasicReflectablePtr<ALLOC> getVarInt(int64_t value, const ALLOC& allocator = ALLOC()) |
3539 | 3 | { |
3540 | 3 | return std::allocate_shared<VarIntReflectable<ALLOC>>(allocator, value); |
3541 | 3 | } |
3542 | | |
3543 | | static IBasicReflectablePtr<ALLOC> getVarUInt16(uint16_t value, const ALLOC& allocator = ALLOC()) |
3544 | 2 | { |
3545 | 2 | return std::allocate_shared<VarUInt16Reflectable<ALLOC>>(allocator, value); |
3546 | 2 | } |
3547 | | |
3548 | | static IBasicReflectablePtr<ALLOC> getVarUInt32(uint32_t value, const ALLOC& allocator = ALLOC()) |
3549 | 2 | { |
3550 | 2 | return std::allocate_shared<VarUInt32Reflectable<ALLOC>>(allocator, value); |
3551 | 2 | } |
3552 | | |
3553 | | static IBasicReflectablePtr<ALLOC> getVarUInt64(uint64_t value, const ALLOC& allocator = ALLOC()) |
3554 | 2 | { |
3555 | 2 | return std::allocate_shared<VarUInt64Reflectable<ALLOC>>(allocator, value); |
3556 | 2 | } |
3557 | | |
3558 | | static IBasicReflectablePtr<ALLOC> getVarUInt(uint64_t value, const ALLOC& allocator = ALLOC()) |
3559 | 2 | { |
3560 | 2 | return std::allocate_shared<VarUIntReflectable<ALLOC>>(allocator, value); |
3561 | 2 | } |
3562 | | |
3563 | | static IBasicReflectablePtr<ALLOC> getVarSize(uint32_t value, const ALLOC& allocator = ALLOC()) |
3564 | 3 | { |
3565 | 3 | return std::allocate_shared<VarSizeReflectable<ALLOC>>(allocator, value); |
3566 | 3 | } |
3567 | | |
3568 | | static IBasicReflectablePtr<ALLOC> getFloat16(float value, const ALLOC& allocator = ALLOC()) |
3569 | 7 | { |
3570 | 7 | return std::allocate_shared<Float16Reflectable<ALLOC>>(allocator, value); |
3571 | 7 | } |
3572 | | |
3573 | | static IBasicReflectablePtr<ALLOC> getFloat32(float value, const ALLOC& allocator = ALLOC()) |
3574 | 9 | { |
3575 | 9 | return std::allocate_shared<Float32Reflectable<ALLOC>>(allocator, value); |
3576 | 9 | } |
3577 | | |
3578 | | static IBasicReflectablePtr<ALLOC> getFloat64(double value, const ALLOC& allocator = ALLOC()) |
3579 | 37 | { |
3580 | 37 | return std::allocate_shared<Float64Reflectable<ALLOC>>(allocator, value); |
3581 | 37 | } |
3582 | | |
3583 | | static IBasicReflectablePtr<ALLOC> getBytes(Span<const uint8_t> value, const ALLOC& allocator = ALLOC()) |
3584 | 20 | { |
3585 | 20 | return std::allocate_shared<BytesReflectable<ALLOC>>(allocator, value); |
3586 | 20 | } |
3587 | | |
3588 | | static IBasicReflectablePtr<ALLOC> getString(StringView value, const ALLOC& allocator = ALLOC()) |
3589 | 134 | { |
3590 | 134 | return std::allocate_shared<StringReflectable<ALLOC>>(allocator, value); |
3591 | 134 | } |
3592 | | |
3593 | | static IBasicReflectablePtr<ALLOC> getBitBuffer( |
3594 | | const BasicBitBuffer<ALLOC>& value, const ALLOC& allocator = ALLOC()) |
3595 | 20 | { |
3596 | 20 | return std::allocate_shared<BitBufferReflectable<ALLOC>>(allocator, value); |
3597 | 20 | } |
3598 | | |
3599 | | template <typename RAW_ARRAY> |
3600 | | static IBasicReflectableConstPtr<ALLOC> getBoolArray( |
3601 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3602 | 1 | { |
3603 | 1 | return std::allocate_shared<BoolReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3604 | 1 | allocator, allocator, rawArray); |
3605 | 1 | } |
3606 | | |
3607 | | template <typename RAW_ARRAY> |
3608 | | static IBasicReflectablePtr<ALLOC> getBoolArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3609 | 1 | { |
3610 | 1 | return std::allocate_shared<BoolReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3611 | 1 | } |
3612 | | |
3613 | | template <typename RAW_ARRAY> |
3614 | | static IBasicReflectableConstPtr<ALLOC> getInt8Array( |
3615 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3616 | 1 | { |
3617 | 1 | return std::allocate_shared<Int8ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3618 | 1 | allocator, allocator, rawArray); |
3619 | 1 | } |
3620 | | |
3621 | | template <typename RAW_ARRAY> |
3622 | | static IBasicReflectablePtr<ALLOC> getInt8Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3623 | 1 | { |
3624 | 1 | return std::allocate_shared<Int8ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3625 | 1 | } |
3626 | | |
3627 | | template <typename RAW_ARRAY> |
3628 | | static IBasicReflectableConstPtr<ALLOC> getInt16Array( |
3629 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3630 | 1 | { |
3631 | 1 | return std::allocate_shared<Int16ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3632 | 1 | allocator, allocator, rawArray); |
3633 | 1 | } |
3634 | | |
3635 | | template <typename RAW_ARRAY> |
3636 | | static IBasicReflectablePtr<ALLOC> getInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3637 | 1 | { |
3638 | 1 | return std::allocate_shared<Int16ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3639 | 1 | } |
3640 | | |
3641 | | template <typename RAW_ARRAY> |
3642 | | static IBasicReflectableConstPtr<ALLOC> getInt32Array( |
3643 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3644 | 1 | { |
3645 | 1 | return std::allocate_shared<Int32ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3646 | 1 | allocator, allocator, rawArray); |
3647 | 1 | } |
3648 | | |
3649 | | template <typename RAW_ARRAY> |
3650 | | static IBasicReflectablePtr<ALLOC> getInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3651 | 1 | { |
3652 | 1 | return std::allocate_shared<Int32ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3653 | 1 | } |
3654 | | |
3655 | | template <typename RAW_ARRAY> |
3656 | | static IBasicReflectableConstPtr<ALLOC> getInt64Array( |
3657 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3658 | 1 | { |
3659 | 1 | return std::allocate_shared<Int64ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3660 | 1 | allocator, allocator, rawArray); |
3661 | 1 | } |
3662 | | |
3663 | | template <typename RAW_ARRAY> |
3664 | | static IBasicReflectablePtr<ALLOC> getInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3665 | 1 | { |
3666 | 1 | return std::allocate_shared<Int64ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3667 | 1 | } |
3668 | | |
3669 | | template <typename RAW_ARRAY> |
3670 | | static IBasicReflectableConstPtr<ALLOC> getUInt8Array( |
3671 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3672 | 2 | { |
3673 | 2 | return std::allocate_shared<UInt8ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3674 | 2 | allocator, allocator, rawArray); |
3675 | 2 | } |
3676 | | |
3677 | | template <typename RAW_ARRAY> |
3678 | | static IBasicReflectablePtr<ALLOC> getUInt8Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3679 | 2 | { |
3680 | 2 | return std::allocate_shared<UInt8ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3681 | 2 | } |
3682 | | |
3683 | | template <typename RAW_ARRAY> |
3684 | | static IBasicReflectableConstPtr<ALLOC> getUInt16Array( |
3685 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3686 | 1 | { |
3687 | 1 | return std::allocate_shared<UInt16ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3688 | 1 | allocator, allocator, rawArray); |
3689 | 1 | } |
3690 | | |
3691 | | template <typename RAW_ARRAY> |
3692 | | static IBasicReflectablePtr<ALLOC> getUInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3693 | 1 | { |
3694 | 1 | return std::allocate_shared<UInt16ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3695 | 1 | } |
3696 | | |
3697 | | template <typename RAW_ARRAY> |
3698 | | static IBasicReflectableConstPtr<ALLOC> getUInt32Array( |
3699 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3700 | 1 | { |
3701 | 1 | return std::allocate_shared<UInt32ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3702 | 1 | allocator, allocator, rawArray); |
3703 | 1 | } |
3704 | | |
3705 | | template <typename RAW_ARRAY> |
3706 | | static IBasicReflectablePtr<ALLOC> getUInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3707 | 10 | { |
3708 | 10 | return std::allocate_shared<UInt32ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3709 | 10 | } |
3710 | | |
3711 | | template <typename RAW_ARRAY> |
3712 | | static IBasicReflectableConstPtr<ALLOC> getUInt64Array( |
3713 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3714 | 1 | { |
3715 | 1 | return std::allocate_shared<UInt64ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3716 | 1 | allocator, allocator, rawArray); |
3717 | 1 | } |
3718 | | |
3719 | | template <typename RAW_ARRAY> |
3720 | | static IBasicReflectablePtr<ALLOC> getUInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3721 | 1 | { |
3722 | 1 | return std::allocate_shared<UInt64ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3723 | 1 | } |
3724 | | |
3725 | | template <typename RAW_ARRAY> |
3726 | | static IBasicReflectableConstPtr<ALLOC> getFixedSignedBitFieldArray( |
3727 | | const RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC()) |
3728 | 1 | { |
3729 | 1 | return std::allocate_shared<FixedSignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3730 | 1 | allocator, allocator, rawArray, bitSize); |
3731 | 1 | } |
3732 | | |
3733 | | template <typename RAW_ARRAY> |
3734 | | static IBasicReflectablePtr<ALLOC> getFixedSignedBitFieldArray( |
3735 | | RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC()) |
3736 | 1 | { |
3737 | 1 | return std::allocate_shared<FixedSignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>( |
3738 | 1 | allocator, allocator, rawArray, bitSize); |
3739 | 1 | } |
3740 | | |
3741 | | template <typename RAW_ARRAY> |
3742 | | static IBasicReflectableConstPtr<ALLOC> getFixedUnsignedBitFieldArray( |
3743 | | const RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC()) |
3744 | 1 | { |
3745 | 1 | return std::allocate_shared<FixedUnsignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3746 | 1 | allocator, allocator, rawArray, bitSize); |
3747 | 1 | } |
3748 | | |
3749 | | template <typename RAW_ARRAY> |
3750 | | static IBasicReflectablePtr<ALLOC> getFixedUnsignedBitFieldArray( |
3751 | | RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC()) |
3752 | 1 | { |
3753 | 1 | return std::allocate_shared<FixedUnsignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>( |
3754 | 1 | allocator, allocator, rawArray, bitSize); |
3755 | 1 | } |
3756 | | |
3757 | | template <typename RAW_ARRAY> |
3758 | | static IBasicReflectableConstPtr<ALLOC> getDynamicSignedBitFieldArray(const RAW_ARRAY& rawArray, |
3759 | | uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC()) |
3760 | 1 | { |
3761 | 1 | return std::allocate_shared<DynamicSignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3762 | 1 | allocator, allocator, rawArray, maxBitSize, dynamicBitSize); |
3763 | 1 | } |
3764 | | |
3765 | | template <typename RAW_ARRAY> |
3766 | | static IBasicReflectablePtr<ALLOC> getDynamicSignedBitFieldArray( |
3767 | | RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC()) |
3768 | 1 | { |
3769 | 1 | return std::allocate_shared<DynamicSignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>( |
3770 | 1 | allocator, allocator, rawArray, maxBitSize, dynamicBitSize); |
3771 | 1 | } |
3772 | | |
3773 | | template <typename RAW_ARRAY> |
3774 | | static IBasicReflectableConstPtr<ALLOC> getDynamicUnsignedBitFieldArray(const RAW_ARRAY& rawArray, |
3775 | | uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC()) |
3776 | 1 | { |
3777 | 1 | return std::allocate_shared<DynamicUnsignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3778 | 1 | allocator, allocator, rawArray, maxBitSize, dynamicBitSize); |
3779 | 1 | } |
3780 | | |
3781 | | template <typename RAW_ARRAY> |
3782 | | static IBasicReflectablePtr<ALLOC> getDynamicUnsignedBitFieldArray( |
3783 | | RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC()) |
3784 | 1 | { |
3785 | 1 | return std::allocate_shared<DynamicUnsignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>( |
3786 | 1 | allocator, allocator, rawArray, maxBitSize, dynamicBitSize); |
3787 | 1 | } |
3788 | | |
3789 | | template <typename RAW_ARRAY> |
3790 | | static IBasicReflectableConstPtr<ALLOC> getVarInt16Array( |
3791 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3792 | 1 | { |
3793 | 1 | return std::allocate_shared<VarInt16ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3794 | 1 | allocator, allocator, rawArray); |
3795 | 1 | } |
3796 | | |
3797 | | template <typename RAW_ARRAY> |
3798 | | static IBasicReflectablePtr<ALLOC> getVarInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3799 | 1 | { |
3800 | 1 | return std::allocate_shared<VarInt16ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3801 | 1 | } |
3802 | | |
3803 | | template <typename RAW_ARRAY> |
3804 | | static IBasicReflectableConstPtr<ALLOC> getVarInt32Array( |
3805 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3806 | 1 | { |
3807 | 1 | return std::allocate_shared<VarInt32ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3808 | 1 | allocator, allocator, rawArray); |
3809 | 1 | } |
3810 | | |
3811 | | template <typename RAW_ARRAY> |
3812 | | static IBasicReflectablePtr<ALLOC> getVarInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3813 | 1 | { |
3814 | 1 | return std::allocate_shared<VarInt32ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3815 | 1 | } |
3816 | | |
3817 | | template <typename RAW_ARRAY> |
3818 | | static IBasicReflectableConstPtr<ALLOC> getVarInt64Array( |
3819 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3820 | 1 | { |
3821 | 1 | return std::allocate_shared<VarInt64ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3822 | 1 | allocator, allocator, rawArray); |
3823 | 1 | } |
3824 | | |
3825 | | template <typename RAW_ARRAY> |
3826 | | static IBasicReflectablePtr<ALLOC> getVarInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3827 | 1 | { |
3828 | 1 | return std::allocate_shared<VarInt64ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3829 | 1 | } |
3830 | | |
3831 | | template <typename RAW_ARRAY> |
3832 | | static IBasicReflectableConstPtr<ALLOC> getVarIntArray( |
3833 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3834 | 1 | { |
3835 | 1 | return std::allocate_shared<VarIntReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3836 | 1 | allocator, allocator, rawArray); |
3837 | 1 | } |
3838 | | |
3839 | | template <typename RAW_ARRAY> |
3840 | | static IBasicReflectablePtr<ALLOC> getVarIntArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3841 | 1 | { |
3842 | 1 | return std::allocate_shared<VarIntReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3843 | 1 | } |
3844 | | |
3845 | | template <typename RAW_ARRAY> |
3846 | | static IBasicReflectableConstPtr<ALLOC> getVarUInt16Array( |
3847 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3848 | 1 | { |
3849 | 1 | return std::allocate_shared<VarUInt16ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3850 | 1 | allocator, allocator, rawArray); |
3851 | 1 | } |
3852 | | |
3853 | | template <typename RAW_ARRAY> |
3854 | | static IBasicReflectablePtr<ALLOC> getVarUInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3855 | 1 | { |
3856 | 1 | return std::allocate_shared<VarUInt16ReflectableArray<ALLOC, RAW_ARRAY>>( |
3857 | 1 | allocator, allocator, rawArray); |
3858 | 1 | } |
3859 | | |
3860 | | template <typename RAW_ARRAY> |
3861 | | static IBasicReflectableConstPtr<ALLOC> getVarUInt32Array( |
3862 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3863 | 1 | { |
3864 | 1 | return std::allocate_shared<VarUInt32ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3865 | 1 | allocator, allocator, rawArray); |
3866 | 1 | } |
3867 | | |
3868 | | template <typename RAW_ARRAY> |
3869 | | static IBasicReflectablePtr<ALLOC> getVarUInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3870 | 1 | { |
3871 | 1 | return std::allocate_shared<VarUInt32ReflectableArray<ALLOC, RAW_ARRAY>>( |
3872 | 1 | allocator, allocator, rawArray); |
3873 | 1 | } |
3874 | | |
3875 | | template <typename RAW_ARRAY> |
3876 | | static IBasicReflectableConstPtr<ALLOC> getVarUInt64Array( |
3877 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3878 | 1 | { |
3879 | 1 | return std::allocate_shared<VarUInt64ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3880 | 1 | allocator, allocator, rawArray); |
3881 | 1 | } |
3882 | | |
3883 | | template <typename RAW_ARRAY> |
3884 | | static IBasicReflectablePtr<ALLOC> getVarUInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3885 | 1 | { |
3886 | 1 | return std::allocate_shared<VarUInt64ReflectableArray<ALLOC, RAW_ARRAY>>( |
3887 | 1 | allocator, allocator, rawArray); |
3888 | 1 | } |
3889 | | |
3890 | | template <typename RAW_ARRAY> |
3891 | | static IBasicReflectableConstPtr<ALLOC> getVarUIntArray( |
3892 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3893 | 1 | { |
3894 | 1 | return std::allocate_shared<VarUIntReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3895 | 1 | allocator, allocator, rawArray); |
3896 | 1 | } |
3897 | | |
3898 | | template <typename RAW_ARRAY> |
3899 | | static IBasicReflectablePtr<ALLOC> getVarUIntArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3900 | 1 | { |
3901 | 1 | return std::allocate_shared<VarUIntReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3902 | 1 | } |
3903 | | |
3904 | | template <typename RAW_ARRAY> |
3905 | | static IBasicReflectableConstPtr<ALLOC> getVarSizeArray( |
3906 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3907 | 1 | { |
3908 | 1 | return std::allocate_shared<VarSizeReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3909 | 1 | allocator, allocator, rawArray); |
3910 | 1 | } |
3911 | | |
3912 | | template <typename RAW_ARRAY> |
3913 | | static IBasicReflectablePtr<ALLOC> getVarSizeArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3914 | 1 | { |
3915 | 1 | return std::allocate_shared<VarSizeReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3916 | 1 | } |
3917 | | |
3918 | | template <typename RAW_ARRAY> |
3919 | | static IBasicReflectableConstPtr<ALLOC> getFloat16Array( |
3920 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3921 | 1 | { |
3922 | 1 | return std::allocate_shared<Float16ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3923 | 1 | allocator, allocator, rawArray); |
3924 | 1 | } |
3925 | | |
3926 | | template <typename RAW_ARRAY> |
3927 | | static IBasicReflectablePtr<ALLOC> getFloat16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3928 | 1 | { |
3929 | 1 | return std::allocate_shared<Float16ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3930 | 1 | } |
3931 | | |
3932 | | template <typename RAW_ARRAY> |
3933 | | static IBasicReflectableConstPtr<ALLOC> getFloat32Array( |
3934 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3935 | 1 | { |
3936 | 1 | return std::allocate_shared<Float32ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3937 | 1 | allocator, allocator, rawArray); |
3938 | 1 | } |
3939 | | |
3940 | | template <typename RAW_ARRAY> |
3941 | | static IBasicReflectablePtr<ALLOC> getFloat32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3942 | 1 | { |
3943 | 1 | return std::allocate_shared<Float32ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3944 | 1 | } |
3945 | | |
3946 | | template <typename RAW_ARRAY> |
3947 | | static IBasicReflectableConstPtr<ALLOC> getFloat64Array( |
3948 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3949 | 1 | { |
3950 | 1 | return std::allocate_shared<Float64ReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3951 | 1 | allocator, allocator, rawArray); |
3952 | 1 | } |
3953 | | |
3954 | | template <typename RAW_ARRAY> |
3955 | | static IBasicReflectablePtr<ALLOC> getFloat64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3956 | 1 | { |
3957 | 1 | return std::allocate_shared<Float64ReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3958 | 1 | } |
3959 | | |
3960 | | template <typename RAW_ARRAY> |
3961 | | static IBasicReflectableConstPtr<ALLOC> getBytesArray( |
3962 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3963 | 1 | { |
3964 | 1 | return std::allocate_shared<BytesReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3965 | 1 | allocator, allocator, rawArray); |
3966 | 1 | } |
3967 | | |
3968 | | template <typename RAW_ARRAY> |
3969 | | static IBasicReflectablePtr<ALLOC> getBytesArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3970 | 12 | { |
3971 | 12 | return std::allocate_shared<BytesReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3972 | 12 | } |
3973 | | |
3974 | | template <typename RAW_ARRAY> |
3975 | | static IBasicReflectableConstPtr<ALLOC> getStringArray( |
3976 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3977 | 1 | { |
3978 | 1 | return std::allocate_shared<StringReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3979 | 1 | allocator, allocator, rawArray); |
3980 | 1 | } |
3981 | | |
3982 | | template <typename RAW_ARRAY> |
3983 | | static IBasicReflectablePtr<ALLOC> getStringArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3984 | 20 | { |
3985 | 20 | return std::allocate_shared<StringReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
3986 | 20 | } |
3987 | | |
3988 | | template <typename RAW_ARRAY> |
3989 | | static IBasicReflectableConstPtr<ALLOC> getBitBufferArray( |
3990 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3991 | 1 | { |
3992 | 1 | return std::allocate_shared<BitBufferReflectableConstArray<ALLOC, RAW_ARRAY>>( |
3993 | 1 | allocator, allocator, rawArray); |
3994 | 1 | } |
3995 | | |
3996 | | template <typename RAW_ARRAY> |
3997 | | static IBasicReflectablePtr<ALLOC> getBitBufferArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
3998 | 11 | { |
3999 | 11 | return std::allocate_shared<BitBufferReflectableArray<ALLOC, RAW_ARRAY>>( |
4000 | 11 | allocator, allocator, rawArray); |
4001 | 11 | } |
4002 | | |
4003 | | template <typename RAW_ARRAY> |
4004 | | static IBasicReflectableConstPtr<ALLOC> getCompoundArray( |
4005 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
4006 | 1 | { |
4007 | 1 | return std::allocate_shared<CompoundReflectableConstArray<ALLOC, RAW_ARRAY>>( |
4008 | 1 | allocator, allocator, rawArray); |
4009 | 1 | } |
4010 | | |
4011 | | template <typename RAW_ARRAY> |
4012 | | static IBasicReflectablePtr<ALLOC> getCompoundArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
4013 | 41 | { |
4014 | 41 | return std::allocate_shared<CompoundReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
4015 | 41 | } |
4016 | | |
4017 | | template <typename RAW_ARRAY> |
4018 | | static IBasicReflectableConstPtr<ALLOC> getBitmaskArray( |
4019 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
4020 | 1 | { |
4021 | 1 | return std::allocate_shared<BitmaskReflectableConstArray<ALLOC, RAW_ARRAY>>( |
4022 | 1 | allocator, allocator, rawArray); |
4023 | 1 | } |
4024 | | |
4025 | | template <typename RAW_ARRAY> |
4026 | | static IBasicReflectablePtr<ALLOC> getBitmaskArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
4027 | 1 | { |
4028 | 1 | return std::allocate_shared<BitmaskReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
4029 | 1 | } |
4030 | | |
4031 | | template <typename RAW_ARRAY> |
4032 | | static IBasicReflectableConstPtr<ALLOC> getEnumArray( |
4033 | | const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
4034 | 1 | { |
4035 | 1 | return std::allocate_shared<EnumReflectableConstArray<ALLOC, RAW_ARRAY>>( |
4036 | 1 | allocator, allocator, rawArray); |
4037 | 1 | } |
4038 | | |
4039 | | template <typename RAW_ARRAY> |
4040 | | static IBasicReflectablePtr<ALLOC> getEnumArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC()) |
4041 | 1 | { |
4042 | 1 | return std::allocate_shared<EnumReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray); |
4043 | 1 | } |
4044 | | }; |
4045 | | |
4046 | | /** Typedef to the reflectable factory provided for convenience - using default std::allocator<uint8_t>. */ |
4047 | | using ReflectableFactory = BasicReflectableFactory<std::allocator<uint8_t>>; |
4048 | | |
4049 | | template <typename ALLOC> |
4050 | | ReflectableBase<ALLOC>::ReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo) : |
4051 | | m_typeInfo(typeInfo) |
4052 | 1.68k | {} |
4053 | | |
4054 | | template <typename ALLOC> |
4055 | | ReflectableBase<ALLOC>::~ReflectableBase() = default; |
4056 | | |
4057 | | template <typename ALLOC> |
4058 | | const IBasicTypeInfo<ALLOC>& ReflectableBase<ALLOC>::getTypeInfo() const |
4059 | 13.3k | { |
4060 | 13.3k | return m_typeInfo; |
4061 | 13.3k | } |
4062 | | |
4063 | | template <typename ALLOC> |
4064 | | bool ReflectableBase<ALLOC>::isArray() const |
4065 | 558 | { |
4066 | 558 | return false; |
4067 | 558 | } |
4068 | | |
4069 | | template <typename ALLOC> |
4070 | | void ReflectableBase<ALLOC>::initializeChildren() |
4071 | 122 | { |
4072 | 122 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not a compound type!"; |
4073 | 122 | } |
4074 | | |
4075 | | template <typename ALLOC> |
4076 | | void ReflectableBase<ALLOC>::initialize(const vector<AnyHolder<ALLOC>, ALLOC>&) |
4077 | 123 | { |
4078 | 123 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no type arguments!"; |
4079 | 123 | } |
4080 | | |
4081 | | template <typename ALLOC> |
4082 | | size_t ReflectableBase<ALLOC>::initializeOffsets(size_t) |
4083 | 122 | { |
4084 | 122 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not a compound type!"; |
4085 | 122 | } |
4086 | | |
4087 | | template <typename ALLOC> |
4088 | | size_t ReflectableBase<ALLOC>::initializeOffsets() |
4089 | 153 | { |
4090 | 153 | return initializeOffsets(0); |
4091 | 153 | } |
4092 | | |
4093 | | template <typename ALLOC> |
4094 | | size_t ReflectableBase<ALLOC>::bitSizeOf(size_t) const |
4095 | 1 | { |
4096 | 1 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!"; |
4097 | 1 | } |
4098 | | |
4099 | | template <typename ALLOC> |
4100 | | size_t ReflectableBase<ALLOC>::bitSizeOf() const |
4101 | 308 | { |
4102 | 308 | return bitSizeOf(0); |
4103 | 308 | } |
4104 | | |
4105 | | template <typename ALLOC> |
4106 | | void ReflectableBase<ALLOC>::write(BitStreamWriter&) const |
4107 | 1 | { |
4108 | 1 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!"; |
4109 | 1 | } |
4110 | | |
4111 | | template <typename ALLOC> |
4112 | | IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::getField(StringView) const |
4113 | 175 | { |
4114 | 175 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to get!"; |
4115 | 175 | } |
4116 | | |
4117 | | template <typename ALLOC> |
4118 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::getField(StringView) |
4119 | 122 | { |
4120 | 122 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to get!"; |
4121 | 122 | } |
4122 | | |
4123 | | template <typename ALLOC> |
4124 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::createField(StringView) |
4125 | 122 | { |
4126 | 122 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to create!"; |
4127 | 122 | } |
4128 | | |
4129 | | template <typename ALLOC> |
4130 | | void ReflectableBase<ALLOC>::setField(StringView, const AnyHolder<ALLOC>&) |
4131 | 122 | { |
4132 | 122 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to set!"; |
4133 | 122 | } |
4134 | | |
4135 | | template <typename ALLOC> |
4136 | | IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::getParameter(StringView) const |
4137 | 175 | { |
4138 | 175 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no parameters to get!"; |
4139 | 175 | } |
4140 | | |
4141 | | template <typename ALLOC> |
4142 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::getParameter(StringView) |
4143 | 124 | { |
4144 | 124 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no parameters to get!"; |
4145 | 124 | } |
4146 | | |
4147 | | template <typename ALLOC> |
4148 | | IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::callFunction(StringView) const |
4149 | 175 | { |
4150 | 175 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no functions to call!"; |
4151 | 175 | } |
4152 | | |
4153 | | template <typename ALLOC> |
4154 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::callFunction(StringView) |
4155 | 124 | { |
4156 | 124 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no functions to call!"; |
4157 | 124 | } |
4158 | | |
4159 | | template <typename ALLOC> |
4160 | | StringView ReflectableBase<ALLOC>::getChoice() const |
4161 | 299 | { |
4162 | 299 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is neither choice nor union!"; |
4163 | 299 | } |
4164 | | |
4165 | | template <typename ALLOC> |
4166 | | IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::find(StringView path) const |
4167 | 520 | { |
4168 | 520 | return detail::getFromObject(*this, path, 0); |
4169 | 520 | } |
4170 | | |
4171 | | template <typename ALLOC> |
4172 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::find(StringView path) |
4173 | 399 | { |
4174 | 399 | return detail::getFromObject(*this, path, 0); |
4175 | 399 | } |
4176 | | |
4177 | | template <typename ALLOC> |
4178 | | IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::operator[](StringView path) const |
4179 | 247 | { |
4180 | 247 | return find(path); |
4181 | 247 | } |
4182 | | |
4183 | | template <typename ALLOC> |
4184 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::operator[](StringView path) |
4185 | 167 | { |
4186 | 167 | return find(path); |
4187 | 167 | } |
4188 | | |
4189 | | template <typename ALLOC> |
4190 | | size_t ReflectableBase<ALLOC>::size() const |
4191 | 309 | { |
4192 | 309 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4193 | 309 | } |
4194 | | |
4195 | | template <typename ALLOC> |
4196 | | void ReflectableBase<ALLOC>::resize(size_t) |
4197 | 126 | { |
4198 | 126 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4199 | 126 | } |
4200 | | |
4201 | | template <typename ALLOC> |
4202 | | IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::at(size_t) const |
4203 | 308 | { |
4204 | 308 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4205 | 308 | } |
4206 | | |
4207 | | template <typename ALLOC> |
4208 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::at(size_t) |
4209 | 127 | { |
4210 | 127 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4211 | 127 | } |
4212 | | |
4213 | | template <typename ALLOC> |
4214 | | IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::operator[](size_t) const |
4215 | 308 | { |
4216 | 308 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4217 | 308 | } |
4218 | | |
4219 | | template <typename ALLOC> |
4220 | | IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::operator[](size_t) |
4221 | 127 | { |
4222 | 127 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4223 | 127 | } |
4224 | | |
4225 | | template <typename ALLOC> |
4226 | | void ReflectableBase<ALLOC>::setAt(const AnyHolder<ALLOC>&, size_t) |
4227 | 126 | { |
4228 | 126 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4229 | 126 | } |
4230 | | |
4231 | | template <typename ALLOC> |
4232 | | void ReflectableBase<ALLOC>::append(const AnyHolder<ALLOC>&) |
4233 | 1 | { |
4234 | 1 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!"; |
4235 | 1 | } |
4236 | | |
4237 | | template <typename ALLOC> |
4238 | | AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue(const ALLOC&) const |
4239 | 1 | { |
4240 | 1 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!"; |
4241 | 1 | } |
4242 | | |
4243 | | template <typename ALLOC> |
4244 | | AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue(const ALLOC&) |
4245 | 1 | { |
4246 | 1 | throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!"; |
4247 | 1 | } |
4248 | | |
4249 | | template <typename ALLOC> |
4250 | | AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue() const |
4251 | 225 | { |
4252 | 225 | return getAnyValue(ALLOC()); |
4253 | 225 | } |
4254 | | |
4255 | | template <typename ALLOC> |
4256 | | AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue() |
4257 | 159 | { |
4258 | 159 | return getAnyValue(ALLOC()); |
4259 | 159 | } |
4260 | | |
4261 | | template <typename ALLOC> |
4262 | | bool ReflectableBase<ALLOC>::getBool() const |
4263 | 300 | { |
4264 | 300 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not boolean type!"; |
4265 | 300 | } |
4266 | | |
4267 | | template <typename ALLOC> |
4268 | | int8_t ReflectableBase<ALLOC>::getInt8() const |
4269 | 254 | { |
4270 | 254 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int8 type!"; |
4271 | 254 | } |
4272 | | |
4273 | | template <typename ALLOC> |
4274 | | int16_t ReflectableBase<ALLOC>::getInt16() const |
4275 | 289 | { |
4276 | 289 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int16 type!"; |
4277 | 289 | } |
4278 | | |
4279 | | template <typename ALLOC> |
4280 | | int32_t ReflectableBase<ALLOC>::getInt32() const |
4281 | 289 | { |
4282 | 289 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int32 type!"; |
4283 | 289 | } |
4284 | | |
4285 | | template <typename ALLOC> |
4286 | | int64_t ReflectableBase<ALLOC>::getInt64() const |
4287 | 280 | { |
4288 | 280 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int64 type!"; |
4289 | 280 | } |
4290 | | |
4291 | | template <typename ALLOC> |
4292 | | uint8_t ReflectableBase<ALLOC>::getUInt8() const |
4293 | 267 | { |
4294 | 267 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint8 type!"; |
4295 | 267 | } |
4296 | | |
4297 | | template <typename ALLOC> |
4298 | | uint16_t ReflectableBase<ALLOC>::getUInt16() const |
4299 | 289 | { |
4300 | 289 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint16 type!"; |
4301 | 289 | } |
4302 | | |
4303 | | template <typename ALLOC> |
4304 | | uint32_t ReflectableBase<ALLOC>::getUInt32() const |
4305 | 280 | { |
4306 | 280 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint32 type!"; |
4307 | 280 | } |
4308 | | |
4309 | | template <typename ALLOC> |
4310 | | uint64_t ReflectableBase<ALLOC>::getUInt64() const |
4311 | 280 | { |
4312 | 280 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint64 type!"; |
4313 | 280 | } |
4314 | | |
4315 | | template <typename ALLOC> |
4316 | | float ReflectableBase<ALLOC>::getFloat() const |
4317 | 297 | { |
4318 | 297 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not float type!"; |
4319 | 297 | } |
4320 | | |
4321 | | template <typename ALLOC> |
4322 | | double ReflectableBase<ALLOC>::getDouble() const |
4323 | 302 | { |
4324 | 302 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not double type!"; |
4325 | 302 | } |
4326 | | |
4327 | | template <typename ALLOC> |
4328 | | Span<const uint8_t> ReflectableBase<ALLOC>::getBytes() const |
4329 | 302 | { |
4330 | 302 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not bytes type!"; |
4331 | 302 | } |
4332 | | |
4333 | | template <typename ALLOC> |
4334 | | StringView ReflectableBase<ALLOC>::getStringView() const |
4335 | 298 | { |
4336 | 298 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not string type!"; |
4337 | 298 | } |
4338 | | |
4339 | | template <typename ALLOC> |
4340 | | const BasicBitBuffer<ALLOC>& ReflectableBase<ALLOC>::getBitBuffer() const |
4341 | 302 | { |
4342 | 302 | throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not an extern type!"; |
4343 | 302 | } |
4344 | | |
4345 | | template <typename ALLOC> |
4346 | | int64_t ReflectableBase<ALLOC>::toInt() const |
4347 | 185 | { |
4348 | 185 | throw CppRuntimeException("Conversion from '") |
4349 | 185 | << getTypeInfo().getSchemaName() << "' to signed integer is not available!"; |
4350 | 185 | } |
4351 | | |
4352 | | template <typename ALLOC> |
4353 | | uint64_t ReflectableBase<ALLOC>::toUInt() const |
4354 | 180 | { |
4355 | 180 | throw CppRuntimeException("Conversion from '") |
4356 | 180 | << getTypeInfo().getSchemaName() << "' to unsigned integer is not available!"; |
4357 | 180 | } |
4358 | | |
4359 | | template <typename ALLOC> |
4360 | | double ReflectableBase<ALLOC>::toDouble() const |
4361 | 37 | { |
4362 | 37 | throw CppRuntimeException("Conversion from '") |
4363 | 37 | << getTypeInfo().getSchemaName() << "' to double is not available!"; |
4364 | 37 | } |
4365 | | |
4366 | | template <typename ALLOC> |
4367 | | string<ALLOC> ReflectableBase<ALLOC>::toString(const ALLOC&) const |
4368 | 45 | { |
4369 | 45 | throw CppRuntimeException("Conversion from '") |
4370 | 45 | << getTypeInfo().getSchemaName() << "' to string is not available!"; |
4371 | 45 | } |
4372 | | |
4373 | | template <typename ALLOC> |
4374 | | string<ALLOC> ReflectableBase<ALLOC>::toString() const |
4375 | 402 | { |
4376 | 402 | return toString(ALLOC()); |
4377 | 402 | } |
4378 | | |
4379 | | template <typename ALLOC> |
4380 | | const ParsingInfo& ReflectableBase<ALLOC>::parsingInfo() const |
4381 | 1 | { |
4382 | 1 | throw CppRuntimeException("Parsing information is not available for type '") |
4383 | 1 | << getTypeInfo().getSchemaName() << "'!"; |
4384 | 1 | } |
4385 | | |
4386 | | template <typename ALLOC> |
4387 | | void ReflectableConstAllocatorHolderBase<ALLOC>::initializeChildren() |
4388 | 1 | { |
4389 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4390 | 1 | } |
4391 | | |
4392 | | template <typename ALLOC> |
4393 | | void ReflectableConstAllocatorHolderBase<ALLOC>::initialize(const vector<AnyHolder<ALLOC>, ALLOC>&) |
4394 | 1 | { |
4395 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4396 | 1 | } |
4397 | | |
4398 | | template <typename ALLOC> |
4399 | | size_t ReflectableConstAllocatorHolderBase<ALLOC>::initializeOffsets(size_t) |
4400 | 1 | { |
4401 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4402 | 1 | } |
4403 | | |
4404 | | template <typename ALLOC> |
4405 | | IBasicReflectablePtr<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::getField(StringView) |
4406 | 1 | { |
4407 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4408 | 1 | } |
4409 | | |
4410 | | template <typename ALLOC> |
4411 | | void ReflectableConstAllocatorHolderBase<ALLOC>::setField(StringView, const AnyHolder<ALLOC>&) |
4412 | 1 | { |
4413 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4414 | 1 | } |
4415 | | |
4416 | | template <typename ALLOC> |
4417 | | IBasicReflectablePtr<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::getParameter(StringView) |
4418 | 1 | { |
4419 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4420 | 1 | } |
4421 | | |
4422 | | template <typename ALLOC> |
4423 | | IBasicReflectablePtr<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::callFunction(StringView) |
4424 | 1 | { |
4425 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4426 | 1 | } |
4427 | | |
4428 | | template <typename ALLOC> |
4429 | | AnyHolder<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::getAnyValue(const ALLOC&) |
4430 | 1 | { |
4431 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!"; |
4432 | 1 | } |
4433 | | |
4434 | | template <typename ALLOC> |
4435 | | void ReflectableArrayBase<ALLOC>::initializeChildren() |
4436 | 31 | { |
4437 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4438 | 31 | } |
4439 | | |
4440 | | template <typename ALLOC> |
4441 | | void ReflectableArrayBase<ALLOC>::initialize(const vector<AnyHolder<ALLOC>, ALLOC>&) |
4442 | 31 | { |
4443 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4444 | 31 | } |
4445 | | |
4446 | | template <typename ALLOC> |
4447 | | size_t ReflectableArrayBase<ALLOC>::initializeOffsets(size_t) |
4448 | 31 | { |
4449 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4450 | 31 | } |
4451 | | |
4452 | | template <typename ALLOC> |
4453 | | size_t ReflectableArrayBase<ALLOC>::bitSizeOf(size_t) const |
4454 | 71 | { |
4455 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4456 | 71 | } |
4457 | | |
4458 | | template <typename ALLOC> |
4459 | | void ReflectableArrayBase<ALLOC>::write(BitStreamWriter&) const |
4460 | 71 | { |
4461 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4462 | 71 | } |
4463 | | |
4464 | | template <typename ALLOC> |
4465 | | IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::getField(StringView) const |
4466 | 40 | { |
4467 | 40 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4468 | 40 | } |
4469 | | |
4470 | | template <typename ALLOC> |
4471 | | IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::getField(StringView) |
4472 | 31 | { |
4473 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4474 | 31 | } |
4475 | | |
4476 | | template <typename ALLOC> |
4477 | | IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::createField(StringView) |
4478 | 31 | { |
4479 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4480 | 31 | } |
4481 | | |
4482 | | template <typename ALLOC> |
4483 | | void ReflectableArrayBase<ALLOC>::setField(StringView, const AnyHolder<ALLOC>&) |
4484 | 31 | { |
4485 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4486 | 31 | } |
4487 | | |
4488 | | template <typename ALLOC> |
4489 | | IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::getParameter(StringView) const |
4490 | 40 | { |
4491 | 40 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4492 | 40 | } |
4493 | | |
4494 | | template <typename ALLOC> |
4495 | | IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::getParameter(StringView) |
4496 | 31 | { |
4497 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4498 | 31 | } |
4499 | | |
4500 | | template <typename ALLOC> |
4501 | | IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::callFunction(StringView) const |
4502 | 40 | { |
4503 | 40 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4504 | 40 | } |
4505 | | |
4506 | | template <typename ALLOC> |
4507 | | IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::callFunction(StringView) |
4508 | 31 | { |
4509 | 31 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4510 | 31 | } |
4511 | | |
4512 | | template <typename ALLOC> |
4513 | | StringView ReflectableArrayBase<ALLOC>::getChoice() const |
4514 | 71 | { |
4515 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4516 | 71 | } |
4517 | | |
4518 | | template <typename ALLOC> |
4519 | | IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::operator[](size_t index) const |
4520 | 105 | { |
4521 | 105 | return this->at(index); |
4522 | 105 | } |
4523 | | |
4524 | | template <typename ALLOC> |
4525 | | IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::operator[](size_t index) |
4526 | 84 | { |
4527 | 84 | return this->at(index); |
4528 | 84 | } |
4529 | | |
4530 | | template <typename ALLOC> |
4531 | | bool ReflectableArrayBase<ALLOC>::getBool() const |
4532 | 71 | { |
4533 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4534 | 71 | } |
4535 | | |
4536 | | template <typename ALLOC> |
4537 | | int8_t ReflectableArrayBase<ALLOC>::getInt8() const |
4538 | 71 | { |
4539 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4540 | 71 | } |
4541 | | |
4542 | | template <typename ALLOC> |
4543 | | int16_t ReflectableArrayBase<ALLOC>::getInt16() const |
4544 | 71 | { |
4545 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4546 | 71 | } |
4547 | | |
4548 | | template <typename ALLOC> |
4549 | | int32_t ReflectableArrayBase<ALLOC>::getInt32() const |
4550 | 71 | { |
4551 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4552 | 71 | } |
4553 | | |
4554 | | template <typename ALLOC> |
4555 | | int64_t ReflectableArrayBase<ALLOC>::getInt64() const |
4556 | 71 | { |
4557 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4558 | 71 | } |
4559 | | |
4560 | | template <typename ALLOC> |
4561 | | uint8_t ReflectableArrayBase<ALLOC>::getUInt8() const |
4562 | 71 | { |
4563 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4564 | 71 | } |
4565 | | |
4566 | | template <typename ALLOC> |
4567 | | uint16_t ReflectableArrayBase<ALLOC>::getUInt16() const |
4568 | 71 | { |
4569 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4570 | 71 | } |
4571 | | |
4572 | | template <typename ALLOC> |
4573 | | uint32_t ReflectableArrayBase<ALLOC>::getUInt32() const |
4574 | 71 | { |
4575 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4576 | 71 | } |
4577 | | |
4578 | | template <typename ALLOC> |
4579 | | uint64_t ReflectableArrayBase<ALLOC>::getUInt64() const |
4580 | 71 | { |
4581 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4582 | 71 | } |
4583 | | |
4584 | | template <typename ALLOC> |
4585 | | float ReflectableArrayBase<ALLOC>::getFloat() const |
4586 | 71 | { |
4587 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4588 | 71 | } |
4589 | | |
4590 | | template <typename ALLOC> |
4591 | | double ReflectableArrayBase<ALLOC>::getDouble() const |
4592 | 71 | { |
4593 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4594 | 71 | } |
4595 | | |
4596 | | template <typename ALLOC> |
4597 | | Span<const uint8_t> ReflectableArrayBase<ALLOC>::getBytes() const |
4598 | 71 | { |
4599 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4600 | 71 | } |
4601 | | |
4602 | | template <typename ALLOC> |
4603 | | StringView ReflectableArrayBase<ALLOC>::getStringView() const |
4604 | 71 | { |
4605 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4606 | 71 | } |
4607 | | |
4608 | | template <typename ALLOC> |
4609 | | const BasicBitBuffer<ALLOC>& ReflectableArrayBase<ALLOC>::getBitBuffer() const |
4610 | 71 | { |
4611 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4612 | 71 | } |
4613 | | |
4614 | | template <typename ALLOC> |
4615 | | int64_t ReflectableArrayBase<ALLOC>::toInt() const |
4616 | 71 | { |
4617 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4618 | 71 | } |
4619 | | |
4620 | | template <typename ALLOC> |
4621 | | uint64_t ReflectableArrayBase<ALLOC>::toUInt() const |
4622 | 71 | { |
4623 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4624 | 71 | } |
4625 | | |
4626 | | template <typename ALLOC> |
4627 | | double ReflectableArrayBase<ALLOC>::toDouble() const |
4628 | 71 | { |
4629 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4630 | 71 | } |
4631 | | |
4632 | | template <typename ALLOC> |
4633 | | string<ALLOC> ReflectableArrayBase<ALLOC>::toString(const ALLOC&) const |
4634 | 71 | { |
4635 | 71 | throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!"; |
4636 | 71 | } |
4637 | | |
4638 | | template <typename ALLOC> |
4639 | | void ReflectableConstArrayBase<ALLOC>::resize(size_t) |
4640 | 1 | { |
4641 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!"; |
4642 | 1 | } |
4643 | | |
4644 | | template <typename ALLOC> |
4645 | | IBasicReflectablePtr<ALLOC> ReflectableConstArrayBase<ALLOC>::at(size_t) |
4646 | 1 | { |
4647 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!"; |
4648 | 1 | } |
4649 | | |
4650 | | template <typename ALLOC> |
4651 | | IBasicReflectablePtr<ALLOC> ReflectableConstArrayBase<ALLOC>::operator[](size_t) |
4652 | 1 | { |
4653 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!"; |
4654 | 1 | } |
4655 | | |
4656 | | template <typename ALLOC> |
4657 | | void ReflectableConstArrayBase<ALLOC>::setAt(const AnyHolder<ALLOC>&, size_t) |
4658 | 1 | { |
4659 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!"; |
4660 | 1 | } |
4661 | | |
4662 | | template <typename ALLOC> |
4663 | | void ReflectableConstArrayBase<ALLOC>::append(const AnyHolder<ALLOC>&) |
4664 | 1 | { |
4665 | 1 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!"; |
4666 | 1 | } |
4667 | | |
4668 | | template <typename ALLOC> |
4669 | | AnyHolder<ALLOC> ReflectableConstArrayBase<ALLOC>::getAnyValue(const ALLOC&) |
4670 | 6 | { |
4671 | 6 | throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!"; |
4672 | 6 | } |
4673 | | |
4674 | | } // namespace zserio |
4675 | | |
4676 | | #endif // ZSERIO_REFLECTABLE_H_INC |