Coverage Report

Created: 2024-04-30 09:35

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