GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/zserio/Reflectable.h Lines: 1481 1481 100.0 %
Date: 2023-12-13 14:51:09 Branches: 1825 4737 38.5 %

Line Branch Exec Source
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
1646
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
    ~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
30
class BuiltinReflectableBase : public ReflectableBase<ALLOC>
126
{
127
private:
128
    using Base = ReflectableBase<ALLOC>;
129
130
protected:
131
30
    BuiltinReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo, const T& value) :
132
30
            Base(typeInfo), m_value(value)
133
30
    {}
134
135
50
    const T& getValue() const
136
    {
137
50
        return m_value;
138
    }
139
140
public:
141
4
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
142
    {
143
4
        return AnyHolder<ALLOC>(std::cref(getValue()), allocator);
144
    }
145
146
4
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
147
    {
148
        // we have only const reference, thus return it
149
4
        return AnyHolder<ALLOC>(std::cref(getValue()), allocator);
150
    }
151
152
private:
153
    const T& m_value;
154
};
155
156
/**
157
 * Specialization of the BuiltinReflectableBase base class for numeric (arithmetic) types, string view and span.
158
 *
159
 * Hold the value instead of reference.
160
 */
161
template <typename ALLOC, typename T>
162






841
class BuiltinReflectableBase<ALLOC, T,
163
        typename std::enable_if<std::is_arithmetic<T>::value || std::is_same<T, StringView>::value ||
164
                is_span<T>::value>::type> : public ReflectableBase<ALLOC>
165
{
166
private:
167
    using Base = ReflectableBase<ALLOC>;
168
169
protected:
170
841
    BuiltinReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo, T value) :
171
841
            Base(typeInfo), m_value(value)
172
841
    {}
173
174
2059
    T getValue() const
175
    {
176
2059
        return m_value;
177
    }
178
179
public:
180
174
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
181
    {
182
174
        return AnyHolder<ALLOC>(m_value, allocator);
183
    }
184
185
99
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
186
    {
187
99
        return AnyHolder<ALLOC>(m_value, allocator);
188
    }
189
190
private:
191
    T m_value;
192
};
193
194
/**
195
 * Base class for integral reflectables.
196
 *
197
 * Implements toString() and toDouble() conversions, implements write() for all integral builtin types.
198
 *
199
 * Hold dynamic bit size even though it has sense only for dynamic bit fields (otherwise it's always set to 0).
200
 * This solution was chosen for simplicity.
201
 */
202
template <typename ALLOC, typename T>
203




586
class IntegralReflectableBase : public BuiltinReflectableBase<ALLOC, T>
204
{
205
protected:
206
    static_assert(std::is_integral<T>::value, "T must be a signed integral type!");
207
208
    using Base = BuiltinReflectableBase<ALLOC, T>;
209
210
public:
211
586
    IntegralReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo, T value) :
212
586
            Base(typeInfo, value)
213
586
    {}
214
215
243
    double toDouble() const override
216
    {
217
243
        return static_cast<double>(Base::getValue());
218
    }
219
220
232
    string<ALLOC> toString(const ALLOC& allocator) const override
221
    {
222
232
        return ::zserio::toString<ALLOC>(Base::getValue(), allocator);
223
    }
224
};
225
226
/**
227
 * Base class for signed integral reflectables.
228
 *
229
 * Implements toInt() conversion.
230
 */
231
template <typename ALLOC, typename T>
232


226
class SignedReflectableBase : public IntegralReflectableBase<ALLOC, T>
233
{
234
protected:
235
    static_assert(std::is_signed<T>::value, "T must be a signed integral type!");
236
237
    using Base = IntegralReflectableBase<ALLOC, T>;
238
239
226
    using Base::Base;
240
241
public:
242
150
    int64_t toInt() const override
243
    {
244
150
        return Base::getValue();
245
    }
246
};
247
248
/**
249
 * Base class for unsigned integral reflectables.
250
 *
251
 * Implements toUInt() conversion.
252
 */
253
template <typename ALLOC, typename T>
254


360
class UnsignedReflectableBase : public IntegralReflectableBase<ALLOC, T>
255
{
256
protected:
257
    static_assert(std::is_unsigned<T>::value, "T must be an unsigned integral type!");
258
259
    using Base = IntegralReflectableBase<ALLOC, T>;
260
261
360
    using Base::Base;
262
263
public:
264
233
    uint64_t toUInt() const override
265
    {
266
233
        return Base::getValue();
267
    }
268
};
269
270
/**
271
 * Reflectable for values of bool type.
272
 */
273
template <typename ALLOC>
274
21
class BoolReflectable : public UnsignedReflectableBase<ALLOC, bool>
275
{
276
private:
277
    using Base = UnsignedReflectableBase<ALLOC, bool>;
278
279
public:
280
23
    static const IBasicTypeInfo<ALLOC>& typeInfo()
281
    {
282
23
        return BuiltinTypeInfo<ALLOC>::getBool();
283
    }
284
285
21
    explicit BoolReflectable(bool value) :
286
21
            Base(typeInfo(), value)
287
21
    {}
288
289
9
    size_t bitSizeOf(size_t) const override
290
    {
291
9
        return 1;
292
    }
293
294
9
    void write(BitStreamWriter& writer) const override
295
    {
296
9
        writer.writeBool(Base::getValue());
297
9
    }
298
299
27
    bool getBool() const override
300
    {
301
27
        return Base::getValue();
302
    }
303
};
304
305
/**
306
 * Base class for 8-bit signed integral reflectables.
307
 *
308
 * Implements getInt8() conversion.
309
 */
310
template <typename ALLOC>
311
69
class Int8ReflectableBase : public SignedReflectableBase<ALLOC, int8_t>
312
{
313
protected:
314
    using Base = SignedReflectableBase<ALLOC, int8_t>;
315
316
69
    using Base::Base;
317
318
public:
319
96
    int8_t getInt8() const override
320
    {
321
96
        return Base::getValue();
322
    }
323
};
324
325
/**
326
 * Base class for 16-bit signed integral reflectables.
327
 *
328
 * Implements getInt16() conversion.
329
 */
330
template <typename ALLOC>
331
37
class Int16ReflectableBase : public SignedReflectableBase<ALLOC, int16_t>
332
{
333
protected:
334
    using Base = SignedReflectableBase<ALLOC, int16_t>;
335
336
37
    using Base::Base;
337
338
public:
339
40
    int16_t getInt16() const override
340
    {
341
40
        return Base::getValue();
342
    }
343
};
344
345
/**
346
 * Base class for 32-bit signed integral reflectables.
347
 *
348
 * Implements getInt32() conversion.
349
 */
350
template <typename ALLOC>
351
74
class Int32ReflectableBase : public SignedReflectableBase<ALLOC, int32_t>
352
{
353
protected:
354
    using Base = SignedReflectableBase<ALLOC, int32_t>;
355
356
74
    using Base::Base;
357
358
public:
359
55
    int32_t getInt32() const override
360
    {
361
55
        return Base::getValue();
362
    }
363
};
364
365
/**
366
 * Base class for 64-bit signed integral reflectables.
367
 *
368
 * Implements getInt64() conversion.
369
 */
370
template <typename ALLOC>
371
46
class Int64ReflectableBase : public SignedReflectableBase<ALLOC, int64_t>
372
{
373
protected:
374
    using Base = SignedReflectableBase<ALLOC, int64_t>;
375
376
46
    using Base::Base;
377
378
public:
379
58
    int64_t getInt64() const override
380
    {
381
58
        return Base::getValue();
382
    }
383
};
384
385
/**
386
 * Base class for 8-bit unsigned integral reflectables.
387
 *
388
 * Implements getUInt8() conversion.
389
 */
390
template <typename ALLOC>
391
68
class UInt8ReflectableBase : public UnsignedReflectableBase<ALLOC, uint8_t>
392
{
393
protected:
394
    using Base = UnsignedReflectableBase<ALLOC, uint8_t>;
395
396
68
    using Base::Base;
397
398
public:
399
62
    uint8_t getUInt8() const override
400
    {
401
62
        return Base::getValue();
402
    }
403
};
404
405
/**
406
 * Base class for 16-bit unsigned integral reflectables.
407
 *
408
 * Implements getUInt16() conversion.
409
 */
410
template <typename ALLOC>
411
36
class UInt16ReflectableBase : public UnsignedReflectableBase<ALLOC, uint16_t>
412
{
413
protected:
414
    using Base = UnsignedReflectableBase<ALLOC, uint16_t>;
415
416
36
    using Base::Base;
417
418
public:
419
40
    uint16_t getUInt16() const override
420
    {
421
40
        return Base::getValue();
422
    }
423
};
424
425
/**
426
 * Base class for 32-bit unsigned integral reflectables.
427
 *
428
 * Implements getUInt32() conversion.
429
 */
430
template <typename ALLOC>
431
189
class UInt32ReflectableBase : public UnsignedReflectableBase<ALLOC, uint32_t>
432
{
433
protected:
434
    using Base = UnsignedReflectableBase<ALLOC, uint32_t>;
435
436
189
    using Base::Base;
437
438
public:
439
105
    uint32_t getUInt32() const override
440
    {
441
105
        return Base::getValue();
442
    }
443
};
444
445
/**
446
 * Base class for 64-bit unsigned integral reflectables.
447
 *
448
 * Implements getUInt64() conversion.
449
 */
450
template <typename ALLOC>
451
46
class UInt64ReflectableBase : public UnsignedReflectableBase<ALLOC, uint64_t>
452
{
453
protected:
454
    using Base = UnsignedReflectableBase<ALLOC, uint64_t>;
455
456
46
    using Base::Base;
457
458
public:
459
58
    uint64_t getUInt64() const override
460
    {
461
58
        return Base::getValue();
462
    }
463
};
464
465
/**
466
 * Reflectable for int8 type.
467
 */
468
template <typename ALLOC>
469
30
class Int8Reflectable : public Int8ReflectableBase<ALLOC>
470
{
471
private:
472
    using Base = Int8ReflectableBase<ALLOC>;
473
474
public:
475
32
    static const IBasicTypeInfo<ALLOC>& typeInfo()
476
    {
477
32
        return BuiltinTypeInfo<ALLOC>::getInt8();
478
    }
479
480
30
    explicit Int8Reflectable(int8_t value) :
481
30
            Base(typeInfo(), value)
482
30
    {}
483
484
13
    size_t bitSizeOf(size_t) const override
485
    {
486
13
        return 8;
487
    }
488
489
13
    void write(BitStreamWriter& writer) const override
490
    {
491
13
        writer.writeSignedBits(Base::getValue(), 8);
492
13
    }
493
};
494
495
/**
496
 * Reflectable for int16 type.
497
 */
498
template <typename ALLOC>
499
20
class Int16Reflectable : public Int16ReflectableBase<ALLOC>
500
{
501
private:
502
    using Base = Int16ReflectableBase<ALLOC>;
503
504
public:
505
22
    static const IBasicTypeInfo<ALLOC>& typeInfo()
506
    {
507
22
        return BuiltinTypeInfo<ALLOC>::getInt16();
508
    }
509
510
20
    explicit Int16Reflectable(int16_t value) :
511
20
            Base(typeInfo(), value)
512
20
    {}
513
514
9
    size_t bitSizeOf(size_t) const override
515
    {
516
9
        return 16;
517
    }
518
519
9
    void write(BitStreamWriter& writer) const override
520
    {
521
9
        writer.writeSignedBits(Base::getValue(), 16);
522
9
    }
523
};
524
525
/**
526
 * Reflectable for int32 type.
527
 */
528
template <typename ALLOC>
529
23
class Int32Reflectable : public Int32ReflectableBase<ALLOC>
530
{
531
private:
532
    using Base = Int32ReflectableBase<ALLOC>;
533
534
public:
535
25
    static const IBasicTypeInfo<ALLOC>& typeInfo()
536
    {
537
25
        return BuiltinTypeInfo<ALLOC>::getInt32();
538
    }
539
540
23
    explicit Int32Reflectable(int32_t value) :
541
23
            Base(typeInfo(), value)
542
23
    {}
543
544
9
    size_t bitSizeOf(size_t) const override
545
    {
546
9
        return 32;
547
    }
548
549
9
    void write(BitStreamWriter& writer) const override
550
    {
551
9
        writer.writeSignedBits(Base::getValue(), 32);
552
9
    }
553
};
554
555
/**
556
 * Reflectable for int64 type.
557
 */
558
template <typename ALLOC>
559
19
class Int64Reflectable : public Int64ReflectableBase<ALLOC>
560
{
561
private:
562
    using Base = Int64ReflectableBase<ALLOC>;
563
564
public:
565
21
    static const IBasicTypeInfo<ALLOC>& typeInfo()
566
    {
567
21
        return BuiltinTypeInfo<ALLOC>::getInt64();
568
    }
569
570
19
    explicit Int64Reflectable(int64_t value) :
571
19
            Base(typeInfo(), value)
572
19
    {}
573
574
9
    size_t bitSizeOf(size_t) const override
575
    {
576
9
        return 64;
577
    }
578
579
9
    void write(BitStreamWriter& writer) const override
580
    {
581
9
        writer.writeSignedBits64(Base::getValue(), 64);
582
9
    }
583
};
584
585
/**
586
 * Reflectable for uint8 type.
587
 */
588
template <typename ALLOC>
589
43
class UInt8Reflectable : public UInt8ReflectableBase<ALLOC>
590
{
591
private:
592
    using Base = UInt8ReflectableBase<ALLOC>;
593
594
public:
595
47
    static const IBasicTypeInfo<ALLOC>& typeInfo()
596
    {
597
47
        return BuiltinTypeInfo<ALLOC>::getUInt8();
598
    }
599
600
43
    explicit UInt8Reflectable(uint8_t value) :
601
43
            Base(typeInfo(), value)
602
43
    {}
603
604
9
    size_t bitSizeOf(size_t) const override
605
    {
606
9
        return 8;
607
    }
608
609
9
    void write(BitStreamWriter& writer) const override
610
    {
611
9
        writer.writeBits(Base::getValue(), 8);
612
9
    }
613
};
614
615
/**
616
 * Reflectable for uint16 type.
617
 */
618
template <typename ALLOC>
619
19
class UInt16Reflectable : public UInt16ReflectableBase<ALLOC>
620
{
621
private:
622
    using Base = UInt16ReflectableBase<ALLOC>;
623
624
public:
625
21
    static const IBasicTypeInfo<ALLOC>& typeInfo()
626
    {
627
21
        return BuiltinTypeInfo<ALLOC>::getUInt16();
628
    }
629
630
19
    explicit UInt16Reflectable(uint16_t value) :
631
19
            Base(typeInfo(), value)
632
19
    {}
633
634
9
    size_t bitSizeOf(size_t) const override
635
    {
636
9
        return 16;
637
    }
638
639
9
    void write(BitStreamWriter& writer) const override
640
    {
641
9
        writer.writeBits(Base::getValue(), 16);
642
9
    }
643
};
644
645
/**
646
 * Reflectable for uint32 type.
647
 */
648
template <typename ALLOC>
649
90
class UInt32Reflectable : public UInt32ReflectableBase<ALLOC>
650
{
651
private:
652
    using Base = UInt32ReflectableBase<ALLOC>;
653
654
public:
655
101
    static const IBasicTypeInfo<ALLOC>& typeInfo()
656
    {
657
101
        return BuiltinTypeInfo<ALLOC>::getUInt32();
658
    }
659
660
90
    explicit UInt32Reflectable(uint32_t value) :
661
90
            Base(typeInfo(), value)
662
90
    {}
663
664
9
    size_t bitSizeOf(size_t) const override
665
    {
666
9
        return 32;
667
    }
668
669
9
    void write(BitStreamWriter& writer) const override
670
    {
671
9
        writer.writeBits(Base::getValue(), 32);
672
9
    }
673
};
674
675
/**
676
 * Reflectable for uint64 type.
677
 */
678
template <typename ALLOC>
679
20
class UInt64Reflectable : public UInt64ReflectableBase<ALLOC>
680
{
681
private:
682
    using Base = UInt64ReflectableBase<ALLOC>;
683
684
public:
685
22
    static const IBasicTypeInfo<ALLOC>& typeInfo()
686
    {
687
22
        return BuiltinTypeInfo<ALLOC>::getUInt64();
688
    }
689
690
20
    explicit UInt64Reflectable(uint64_t value) :
691
20
            Base(typeInfo(), value)
692
20
    {}
693
694
9
    size_t bitSizeOf(size_t) const override
695
    {
696
9
        return 64;
697
    }
698
699
9
    void write(BitStreamWriter& writer) const override
700
    {
701
9
        writer.writeBits64(Base::getValue(), 64);
702
9
    }
703
};
704
705
template <typename ALLOC, typename T>
706
class FixedSignedBitFieldReflectable;
707
708
template <typename ALLOC>
709
18
class FixedSignedBitFieldReflectable<ALLOC, int8_t> : public Int8ReflectableBase<ALLOC>
710
{
711
private:
712
    using Base = Int8ReflectableBase<ALLOC>;
713
714
public:
715
21
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
716
    {
717
21
        return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize);
718
    }
719
720
19
    FixedSignedBitFieldReflectable(int8_t value, uint8_t bitSize) :
721
20
            Base(typeInfo(bitSize), value)
722
    {
723
19
        if (bitSize > 8)
724
        {
725

2
            throw CppRuntimeException("FixedSignedBitFieldReflectable ") <<
726

2
                    " - invalid bit size '" << bitSize << "' for 'int8_t' value!";
727
        }
728
18
    }
729
730
16
    size_t bitSizeOf(size_t) const override
731
    {
732
16
        return Base::getTypeInfo().getBitSize();
733
    }
734
735
16
    void write(BitStreamWriter& writer) const override
736
    {
737
16
        writer.writeSignedBits(Base::getValue(), Base::getTypeInfo().getBitSize());
738
16
    }
739
};
740
741
template <typename ALLOC>
742
1
class FixedSignedBitFieldReflectable<ALLOC, int16_t> : public Int16ReflectableBase<ALLOC>
743
{
744
private:
745
    using Base = Int16ReflectableBase<ALLOC>;
746
747
public:
748
3
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
749
    {
750
3
        return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize);
751
    }
752
753
3
    FixedSignedBitFieldReflectable(int16_t value, uint8_t bitSize) :
754
5
            Base(typeInfo(bitSize), value)
755
    {
756

3
        if (bitSize <= 8 || bitSize > 16)
757
        {
758

4
            throw CppRuntimeException("FixedSignedBitFieldReflectable ") <<
759

4
                    " - invalid bit size '" << bitSize << "' for 'int16_t' value!";
760
        }
761
1
    }
762
763
1
    size_t bitSizeOf(size_t) const override
764
    {
765
1
        return Base::getTypeInfo().getBitSize();
766
    }
767
768
1
    void write(BitStreamWriter& writer) const override
769
    {
770
1
        writer.writeSignedBits(Base::getValue(), Base::getTypeInfo().getBitSize());
771
1
    }
772
};
773
774
template <typename ALLOC>
775
35
class FixedSignedBitFieldReflectable<ALLOC, int32_t> : public Int32ReflectableBase<ALLOC>
776
{
777
private:
778
    using Base = Int32ReflectableBase<ALLOC>;
779
780
public:
781
37
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
782
    {
783
37
        return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize);
784
    }
785
786
37
    FixedSignedBitFieldReflectable(int32_t value, uint8_t bitSize) :
787
39
            Base(typeInfo(bitSize), value)
788
    {
789

37
        if (bitSize <= 16 || bitSize > 32)
790
        {
791

4
            throw CppRuntimeException("FixedSignedBitFieldReflectable ") <<
792

4
                    " - invalid bit size '" << bitSize << "' for 'int32_t' value!";
793
        }
794
35
    }
795
796
1
    size_t bitSizeOf(size_t) const override
797
    {
798
1
        return Base::getTypeInfo().getBitSize();
799
    }
800
801
1
    void write(BitStreamWriter& writer) const override
802
    {
803
1
        writer.writeSignedBits(Base::getValue(), Base::getTypeInfo().getBitSize());
804
1
    }
805
};
806
807
template <typename ALLOC>
808
1
class FixedSignedBitFieldReflectable<ALLOC, int64_t> : public Int64ReflectableBase<ALLOC>
809
{
810
private:
811
    using Base = Int64ReflectableBase<ALLOC>;
812
813
public:
814
3
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
815
    {
816
3
        return BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize);
817
    }
818
819
3
    FixedSignedBitFieldReflectable(int64_t value, uint8_t bitSize) :
820
4
            Base(typeInfo(bitSize), value)
821
    {
822
2
        if (bitSize <= 32) // check for maximum bit size (64) is done in type info
823
        {
824

2
            throw CppRuntimeException("FixedSignedBitFieldReflectable ") <<
825

2
                    " - invalid bit size '" << bitSize << "' for 'int64_t' value!";
826
        }
827
1
    }
828
829
1
    size_t bitSizeOf(size_t) const override
830
    {
831
1
        return Base::getTypeInfo().getBitSize();
832
    }
833
834
1
    void write(BitStreamWriter& writer) const override
835
    {
836
1
        writer.writeSignedBits64(Base::getValue(), Base::getTypeInfo().getBitSize());
837
1
    }
838
};
839
840
template <typename ALLOC, typename T>
841
class FixedUnsignedBitFieldReflectable;
842
843
template <typename ALLOC>
844
11
class FixedUnsignedBitFieldReflectable<ALLOC, uint8_t> : public UInt8ReflectableBase<ALLOC>
845
{
846
private:
847
    using Base = UInt8ReflectableBase<ALLOC>;
848
849
public:
850
14
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
851
    {
852
14
        return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize);
853
    }
854
855
12
    FixedUnsignedBitFieldReflectable(uint8_t value, uint8_t bitSize) :
856
13
            Base(typeInfo(bitSize), value)
857
    {
858
12
        if (bitSize > 8)
859
        {
860

2
            throw CppRuntimeException("FixedUnsignedBitFieldReflectable") <<
861

2
                    " - invalid bit size '" << bitSize << "' for 'uint8_t' value!";
862
        }
863
11
    }
864
865
11
    size_t bitSizeOf(size_t) const override
866
    {
867
11
        return Base::getTypeInfo().getBitSize();
868
    }
869
870
11
    void write(BitStreamWriter& writer) const override
871
    {
872
11
        writer.writeBits(Base::getValue(), Base::getTypeInfo().getBitSize());
873
11
    }
874
};
875
876
template <typename ALLOC>
877
1
class FixedUnsignedBitFieldReflectable<ALLOC, uint16_t> : public UInt16ReflectableBase<ALLOC>
878
{
879
private:
880
    using Base = UInt16ReflectableBase<ALLOC>;
881
882
public:
883
3
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
884
    {
885
3
        return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize);
886
    }
887
888
3
    FixedUnsignedBitFieldReflectable(uint16_t value, uint8_t bitSize) :
889
5
            Base(typeInfo(bitSize), value)
890
    {
891

3
        if (bitSize <= 8 || bitSize > 16)
892
        {
893

4
            throw CppRuntimeException("FixedUnsignedBitFieldReflectable") <<
894

4
                    " - invalid bit size '" << bitSize << "' for 'uint16_t' value!";
895
        }
896
1
    }
897
898
1
    size_t bitSizeOf(size_t) const override
899
    {
900
1
        return Base::getTypeInfo().getBitSize();
901
    }
902
903
1
    void write(BitStreamWriter& writer) const override
904
    {
905
1
        writer.writeBits(Base::getValue(), Base::getTypeInfo().getBitSize());
906
1
    }
907
};
908
909
template <typename ALLOC>
910
72
class FixedUnsignedBitFieldReflectable<ALLOC, uint32_t> : public UInt32ReflectableBase<ALLOC>
911
{
912
private:
913
    using Base = UInt32ReflectableBase<ALLOC>;
914
915
public:
916
74
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
917
    {
918
74
        return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize);
919
    }
920
921
74
    FixedUnsignedBitFieldReflectable(uint32_t value, uint8_t bitSize) :
922
76
            Base(typeInfo(bitSize), value)
923
    {
924

74
        if (bitSize <= 16 || bitSize > 32)
925
        {
926

4
            throw CppRuntimeException("FixedUnsignedBitFieldReflectable") <<
927

4
                    " - invalid bit size '" << bitSize << "' for 'uint32_t' value!";
928
        }
929
72
    }
930
931
1
    size_t bitSizeOf(size_t) const override
932
    {
933
1
        return Base::getTypeInfo().getBitSize();
934
    }
935
936
1
    void write(BitStreamWriter& writer) const override
937
    {
938
1
        writer.writeBits(Base::getValue(), Base::getTypeInfo().getBitSize());
939
1
    }
940
};
941
942
template <typename ALLOC>
943
1
class FixedUnsignedBitFieldReflectable<ALLOC, uint64_t> : public UInt64ReflectableBase<ALLOC>
944
{
945
private:
946
    using Base = UInt64ReflectableBase<ALLOC>;
947
948
public:
949
3
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t bitSize)
950
    {
951
3
        return BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize);
952
    }
953
954
3
    FixedUnsignedBitFieldReflectable(uint64_t value, uint8_t bitSize) :
955
4
            Base(typeInfo(bitSize), value)
956
    {
957
2
        if (bitSize <= 32) // check for maximum bit size (64) is done in type info
958
        {
959

2
            throw CppRuntimeException("FixedUnsignedBitFieldReflectable") <<
960

2
                    " - invalid bit size '" << bitSize << "' for 'uint64_t' value!";
961
        }
962
1
    }
963
964
1
    size_t bitSizeOf(size_t) const override
965
    {
966
1
        return Base::getTypeInfo().getBitSize();
967
    }
968
969
1
    void write(BitStreamWriter& writer) const override
970
    {
971
1
        writer.writeBits64(Base::getValue(), Base::getTypeInfo().getBitSize());
972
1
    }
973
};
974
975
template <typename ALLOC, typename T>
976
class DynamicSignedBitFieldReflectable;
977
978
template <typename ALLOC>
979
18
class DynamicSignedBitFieldReflectable<ALLOC, int8_t> : public Int8ReflectableBase<ALLOC>
980
{
981
private:
982
    using Base = Int8ReflectableBase<ALLOC>;
983
984
public:
985
22
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
986
    {
987
22
        return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize);
988
    }
989
990
20
    DynamicSignedBitFieldReflectable(int8_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
991
22
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
992
    {
993
20
        if (maxBitSize > 8)
994
        {
995

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable") <<
996

2
                    " - invalid max bit size '" << maxBitSize << "' for 'int8_t' value!";
997
        }
998
999
19
        if (dynamicBitSize > maxBitSize)
1000
        {
1001

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1002

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1003
        }
1004
18
    }
1005
1006
16
    size_t bitSizeOf(size_t) const override
1007
    {
1008
16
        return m_dynamicBitSize;
1009
    }
1010
1011
16
    void write(BitStreamWriter& writer) const override
1012
    {
1013
16
        writer.writeSignedBits(Base::getValue(), m_dynamicBitSize);
1014
16
    }
1015
1016
private:
1017
    uint8_t m_dynamicBitSize;
1018
};
1019
1020
template <typename ALLOC>
1021
1
class DynamicSignedBitFieldReflectable<ALLOC, int16_t> : public Int16ReflectableBase<ALLOC>
1022
{
1023
private:
1024
    using Base = Int16ReflectableBase<ALLOC>;
1025
1026
public:
1027
4
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
1028
    {
1029
4
        return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize);
1030
    }
1031
1032
4
    DynamicSignedBitFieldReflectable(int16_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
1033
7
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
1034
    {
1035

4
        if (maxBitSize <= 8 || maxBitSize > 16)
1036
        {
1037

4
            throw CppRuntimeException("DynamicSignedBitFieldReflectable") <<
1038

4
                    " - invalid max bit size '" << maxBitSize << "' for 'int16_t' value!";
1039
        }
1040
1041
2
        if (dynamicBitSize > maxBitSize)
1042
        {
1043

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1044

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1045
        }
1046
1
    }
1047
1048
1
    size_t bitSizeOf(size_t) const override
1049
    {
1050
1
        return m_dynamicBitSize;
1051
    }
1052
1053
1
    void write(BitStreamWriter& writer) const override
1054
    {
1055
1
        writer.writeSignedBits(Base::getValue(), m_dynamicBitSize);
1056
1
    }
1057
1058
private:
1059
    uint8_t m_dynamicBitSize;
1060
};
1061
1062
template <typename ALLOC>
1063
1
class DynamicSignedBitFieldReflectable<ALLOC, int32_t> : public Int32ReflectableBase<ALLOC>
1064
{
1065
private:
1066
    using Base = Int32ReflectableBase<ALLOC>;
1067
1068
public:
1069
4
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
1070
    {
1071
4
        return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize);
1072
    }
1073
1074
4
    DynamicSignedBitFieldReflectable(int32_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
1075
7
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
1076
    {
1077

4
        if (maxBitSize <= 16 || maxBitSize > 32)
1078
        {
1079

4
            throw CppRuntimeException("DynamicSignedBitFieldReflectable") <<
1080

4
                    " - invalid max bit size '" << maxBitSize << "' for 'int32_t' value!";
1081
        }
1082
1083
2
        if (dynamicBitSize > maxBitSize)
1084
        {
1085

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1086

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1087
        }
1088
1
    }
1089
1090
1
    size_t bitSizeOf(size_t) const override
1091
    {
1092
1
        return m_dynamicBitSize;
1093
    }
1094
1095
1
    void write(BitStreamWriter& writer) const override
1096
    {
1097
1
        writer.writeSignedBits(Base::getValue(), m_dynamicBitSize);
1098
1
    }
1099
1100
private:
1101
    uint8_t m_dynamicBitSize;
1102
};
1103
1104
template <typename ALLOC>
1105
2
class DynamicSignedBitFieldReflectable<ALLOC, int64_t> : public Int64ReflectableBase<ALLOC>
1106
{
1107
private:
1108
    using Base = Int64ReflectableBase<ALLOC>;
1109
1110
public:
1111
5
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
1112
    {
1113
5
        return BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(maxBitSize);
1114
    }
1115
1116
5
    DynamicSignedBitFieldReflectable(int64_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
1117
7
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
1118
    {
1119
4
        if (maxBitSize <= 32) // check for maximum bit size (64) is done in type info
1120
        {
1121

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable") <<
1122

2
                    " - invalid max bit size '" << maxBitSize << "' for 'int64_t' value!";
1123
        }
1124
1125
3
        if (dynamicBitSize > maxBitSize)
1126
        {
1127

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1128

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1129
        }
1130
2
    }
1131
1132
1
    size_t bitSizeOf(size_t) const override
1133
    {
1134
1
        return m_dynamicBitSize;
1135
    }
1136
1137
1
    void write(BitStreamWriter& writer) const override
1138
    {
1139
1
        writer.writeSignedBits64(Base::getValue(), m_dynamicBitSize);
1140
1
    }
1141
1142
private:
1143
    uint8_t m_dynamicBitSize;
1144
};
1145
1146
template <typename ALLOC, typename T>
1147
class DynamicUnsignedBitFieldReflectable;
1148
1149
template <typename ALLOC>
1150
11
class DynamicUnsignedBitFieldReflectable<ALLOC, uint8_t> : public UInt8ReflectableBase<ALLOC>
1151
{
1152
private:
1153
    using Base = UInt8ReflectableBase<ALLOC>;
1154
1155
public:
1156
15
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
1157
    {
1158
15
        return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize);
1159
    }
1160
1161
13
    DynamicUnsignedBitFieldReflectable(uint8_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
1162
15
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
1163
    {
1164
13
        if (maxBitSize > 8)
1165
        {
1166

2
            throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") <<
1167

2
                    " - invalid max bit size '" << maxBitSize << "' for 'uint8_t' value!";
1168
        }
1169
1170
12
        if (dynamicBitSize > maxBitSize)
1171
        {
1172

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1173

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1174
        }
1175
11
    }
1176
1177
11
    size_t bitSizeOf(size_t) const override
1178
    {
1179
11
        return m_dynamicBitSize;
1180
    }
1181
1182
11
    void write(BitStreamWriter& writer) const override
1183
    {
1184
11
        writer.writeBits(Base::getValue(), m_dynamicBitSize);
1185
11
    }
1186
1187
private:
1188
    uint8_t m_dynamicBitSize;
1189
};
1190
1191
template <typename ALLOC>
1192
1
class DynamicUnsignedBitFieldReflectable<ALLOC, uint16_t> : public UInt16ReflectableBase<ALLOC>
1193
{
1194
private:
1195
    using Base = UInt16ReflectableBase<ALLOC>;
1196
1197
public:
1198
4
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
1199
    {
1200
4
        return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize);
1201
    }
1202
1203
4
    DynamicUnsignedBitFieldReflectable(uint16_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
1204
7
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
1205
    {
1206

4
        if (maxBitSize <= 8 || maxBitSize > 16)
1207
        {
1208

4
            throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") <<
1209

4
                    " - invalid max bit size '" << maxBitSize << "' for 'uint16_t' value!";
1210
        }
1211
1212
2
        if (dynamicBitSize > maxBitSize)
1213
        {
1214

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1215

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1216
        }
1217
1
    }
1218
1219
1
    size_t bitSizeOf(size_t) const override
1220
    {
1221
1
        return m_dynamicBitSize;
1222
    }
1223
1224
1
    void write(BitStreamWriter& writer) const override
1225
    {
1226
1
        writer.writeBits(Base::getValue(), m_dynamicBitSize);
1227
1
    }
1228
1229
private:
1230
    uint8_t m_dynamicBitSize;
1231
};
1232
1233
template <typename ALLOC>
1234
1
class DynamicUnsignedBitFieldReflectable<ALLOC, uint32_t> : public UInt32ReflectableBase<ALLOC>
1235
{
1236
private:
1237
    using Base = UInt32ReflectableBase<ALLOC>;
1238
1239
public:
1240
4
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
1241
    {
1242
4
        return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize);
1243
    }
1244
1245
4
    DynamicUnsignedBitFieldReflectable(uint32_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
1246
7
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
1247
    {
1248

4
        if (maxBitSize <= 16 || maxBitSize > 32)
1249
        {
1250

4
            throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") <<
1251

4
                    " - invalid max bit size '" << maxBitSize << "' for 'uint32_t' value!";
1252
        }
1253
1254
2
        if (dynamicBitSize > maxBitSize)
1255
        {
1256

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1257

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1258
        }
1259
1
    }
1260
1261
1
    size_t bitSizeOf(size_t) const override
1262
    {
1263
1
        return m_dynamicBitSize;
1264
    }
1265
1266
1
    void write(BitStreamWriter& writer) const override
1267
    {
1268
1
        writer.writeBits(Base::getValue(), m_dynamicBitSize);
1269
1
    }
1270
1271
private:
1272
    uint8_t m_dynamicBitSize;
1273
};
1274
1275
template <typename ALLOC>
1276
2
class DynamicUnsignedBitFieldReflectable<ALLOC, uint64_t> : public UInt64ReflectableBase<ALLOC>
1277
{
1278
private:
1279
    using Base = UInt64ReflectableBase<ALLOC>;
1280
1281
public:
1282
5
    static const IBasicTypeInfo<ALLOC>& typeInfo(uint8_t maxBitSize)
1283
    {
1284
5
        return BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(maxBitSize);
1285
    }
1286
1287
5
    DynamicUnsignedBitFieldReflectable(uint64_t value, uint8_t maxBitSize, uint8_t dynamicBitSize) :
1288
7
            Base(typeInfo(maxBitSize), value), m_dynamicBitSize(dynamicBitSize)
1289
    {
1290
4
        if (maxBitSize <= 32) // check for maximum bit size (64) is done in type info
1291
        {
1292

2
            throw CppRuntimeException("DynamicUnsignedBitFieldReflectable") <<
1293

2
                    " - invalid max bit size '" << maxBitSize << "' for 'uint64_t' value!";
1294
        }
1295
1296
3
        if (dynamicBitSize > maxBitSize)
1297
        {
1298

2
            throw CppRuntimeException("DynamicSignedBitFieldReflectable - dynamic bit size '") <<
1299

2
                    dynamicBitSize << "' is greater than max bit size '" << maxBitSize << "'!";
1300
        }
1301
2
    }
1302
1303
1
    size_t bitSizeOf(size_t) const override
1304
    {
1305
1
        return m_dynamicBitSize;
1306
    }
1307
1308
1
    void write(BitStreamWriter& writer) const override
1309
    {
1310
1
        writer.writeBits64(Base::getValue(), m_dynamicBitSize);
1311
1
    }
1312
1313
private:
1314
    uint8_t m_dynamicBitSize;
1315
};
1316
1317
/**
1318
 * Reflectable for varint16 type.
1319
 */
1320
template <typename ALLOC>
1321
10
class VarInt16Reflectable : public Int16ReflectableBase<ALLOC>
1322
{
1323
private:
1324
    using Base = Int16ReflectableBase<ALLOC>;
1325
1326
public:
1327
12
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1328
    {
1329
12
        return BuiltinTypeInfo<ALLOC>::getVarInt16();
1330
    }
1331
1332
10
    explicit VarInt16Reflectable(int16_t value) :
1333
10
            Base(typeInfo(), value)
1334
10
    {}
1335
1336
9
    size_t bitSizeOf(size_t) const override
1337
    {
1338
9
        return zserio::bitSizeOfVarInt16(Base::getValue());
1339
    }
1340
1341
9
    void write(BitStreamWriter& writer) const override
1342
    {
1343
9
        writer.writeVarInt16(Base::getValue());
1344
9
    }
1345
};
1346
1347
/**
1348
 * Reflectable for varint32 type.
1349
 */
1350
template <typename ALLOC>
1351
10
class VarInt32Reflectable : public Int32ReflectableBase<ALLOC>
1352
{
1353
private:
1354
    using Base = Int32ReflectableBase<ALLOC>;
1355
1356
public:
1357
12
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1358
    {
1359
12
        return BuiltinTypeInfo<ALLOC>::getVarInt32();
1360
    }
1361
1362
10
    explicit VarInt32Reflectable(int32_t value) :
1363
10
            Base(typeInfo(), value)
1364
10
    {}
1365
1366
9
    size_t bitSizeOf(size_t) const override
1367
    {
1368
9
        return zserio::bitSizeOfVarInt32(Base::getValue());
1369
    }
1370
1371
9
    void write(BitStreamWriter& writer) const override
1372
    {
1373
9
        writer.writeVarInt32(Base::getValue());
1374
9
    }
1375
};
1376
1377
/**
1378
 * Reflectable for varint64 type.
1379
 */
1380
template <typename ALLOC>
1381
10
class VarInt64Reflectable : public Int64ReflectableBase<ALLOC>
1382
{
1383
private:
1384
    using Base = Int64ReflectableBase<ALLOC>;
1385
1386
public:
1387
12
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1388
    {
1389
12
        return BuiltinTypeInfo<ALLOC>::getVarInt64();
1390
    }
1391
1392
10
    explicit VarInt64Reflectable(int64_t value) :
1393
10
            Base(typeInfo(), value)
1394
10
    {}
1395
1396
9
    size_t bitSizeOf(size_t) const override
1397
    {
1398
9
        return zserio::bitSizeOfVarInt64(Base::getValue());
1399
    }
1400
1401
9
    void write(BitStreamWriter& writer) const override
1402
    {
1403
9
        writer.writeVarInt64(Base::getValue());
1404
9
    }
1405
};
1406
1407
/**
1408
 * Reflectable for varint type.
1409
 */
1410
template <typename ALLOC>
1411
11
class VarIntReflectable : public Int64ReflectableBase<ALLOC>
1412
{
1413
private:
1414
    using Base = Int64ReflectableBase<ALLOC>;
1415
1416
public:
1417
13
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1418
    {
1419
13
        return BuiltinTypeInfo<ALLOC>::getVarInt();
1420
    }
1421
1422
11
    explicit VarIntReflectable(int64_t value) :
1423
11
            Base(typeInfo(), value)
1424
11
    {}
1425
1426
9
    size_t bitSizeOf(size_t) const override
1427
    {
1428
9
        return zserio::bitSizeOfVarInt(Base::getValue());
1429
    }
1430
1431
9
    void write(BitStreamWriter& writer) const override
1432
    {
1433
9
        writer.writeVarInt(Base::getValue());
1434
9
    }
1435
};
1436
1437
/**
1438
 * Reflectable for varuint16 type.
1439
 */
1440
template <typename ALLOC>
1441
10
class VarUInt16Reflectable : public UInt16ReflectableBase<ALLOC>
1442
{
1443
private:
1444
    using Base = UInt16ReflectableBase<ALLOC>;
1445
1446
public:
1447
12
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1448
    {
1449
12
        return BuiltinTypeInfo<ALLOC>::getVarUInt16();
1450
    }
1451
1452
10
    explicit VarUInt16Reflectable(uint16_t value) :
1453
10
            Base(typeInfo(), value)
1454
10
    {}
1455
1456
9
    size_t bitSizeOf(size_t) const override
1457
    {
1458
9
        return zserio::bitSizeOfVarUInt16(Base::getValue());
1459
    }
1460
1461
9
    void write(BitStreamWriter& writer) const override
1462
    {
1463
9
        writer.writeVarUInt16(Base::getValue());
1464
9
    }
1465
};
1466
1467
/**
1468
 * Reflectable for varuint32 type.
1469
 */
1470
template <typename ALLOC>
1471
10
class VarUInt32Reflectable : public UInt32ReflectableBase<ALLOC>
1472
{
1473
private:
1474
    using Base = UInt32ReflectableBase<ALLOC>;
1475
1476
public:
1477
12
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1478
    {
1479
12
        return BuiltinTypeInfo<ALLOC>::getVarUInt32();
1480
    }
1481
1482
10
    explicit VarUInt32Reflectable(uint32_t value) :
1483
10
            Base(typeInfo(), value)
1484
10
    {}
1485
1486
9
    size_t bitSizeOf(size_t) const override
1487
    {
1488
9
        return zserio::bitSizeOfVarUInt32(Base::getValue());
1489
    }
1490
1491
9
    void write(BitStreamWriter& writer) const override
1492
    {
1493
9
        writer.writeVarUInt32(Base::getValue());
1494
9
    }
1495
};
1496
1497
/**
1498
 * Reflectable for varuint64 type.
1499
 */
1500
template <typename ALLOC>
1501
10
class VarUInt64Reflectable : public UInt64ReflectableBase<ALLOC>
1502
{
1503
private:
1504
    using Base = UInt64ReflectableBase<ALLOC>;
1505
1506
public:
1507
12
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1508
    {
1509
12
        return BuiltinTypeInfo<ALLOC>::getVarUInt64();
1510
    }
1511
1512
10
    explicit VarUInt64Reflectable(uint64_t value) :
1513
10
            Base(typeInfo(), value)
1514
10
    {}
1515
1516
9
    size_t bitSizeOf(size_t) const override
1517
    {
1518
9
        return zserio::bitSizeOfVarUInt64(Base::getValue());
1519
    }
1520
1521
9
    void write(BitStreamWriter& writer) const override
1522
    {
1523
9
        writer.writeVarUInt64(Base::getValue());
1524
9
    }
1525
};
1526
1527
/**
1528
 * Reflectable for varuint type.
1529
 */
1530
template <typename ALLOC>
1531
10
class VarUIntReflectable : public UInt64ReflectableBase<ALLOC>
1532
{
1533
private:
1534
    using Base = UInt64ReflectableBase<ALLOC>;
1535
1536
public:
1537
12
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1538
    {
1539
12
        return BuiltinTypeInfo<ALLOC>::getVarUInt();
1540
    }
1541
1542
10
    explicit VarUIntReflectable(uint64_t value) :
1543
10
            Base(typeInfo(), value)
1544
10
    {}
1545
1546
9
    size_t bitSizeOf(size_t) const override
1547
    {
1548
9
        return zserio::bitSizeOfVarUInt(Base::getValue());
1549
    }
1550
1551
9
    void write(BitStreamWriter& writer) const override
1552
    {
1553
9
        writer.writeVarUInt(Base::getValue());
1554
9
    }
1555
};
1556
1557
/**
1558
 * Reflectable for varsize type.
1559
 */
1560
template <typename ALLOC>
1561
11
class VarSizeReflectable : public UInt32ReflectableBase<ALLOC>
1562
{
1563
private:
1564
    using Base = UInt32ReflectableBase<ALLOC>;
1565
1566
public:
1567
13
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1568
    {
1569
13
        return BuiltinTypeInfo<ALLOC>::getVarSize();
1570
    }
1571
1572
11
    explicit VarSizeReflectable(uint32_t value) :
1573
11
            Base(typeInfo(), value)
1574
11
    {}
1575
1576
9
    size_t bitSizeOf(size_t) const override
1577
    {
1578
9
        return zserio::bitSizeOfVarUInt(Base::getValue());
1579
    }
1580
1581
9
    void write(BitStreamWriter& writer) const override
1582
    {
1583
9
        writer.writeVarSize(Base::getValue());
1584
9
    }
1585
};
1586
1587
/**
1588
 * Base class for floating point reflectables.
1589
 */
1590
template <typename ALLOC, typename T>
1591

69
class FloatingPointReflectableBase : public BuiltinReflectableBase<ALLOC, T>
1592
{
1593
protected:
1594
    static_assert(std::is_floating_point<T>::value, "T must be a floating point type!");
1595
1596
    using BuiltinReflectableBase<ALLOC, T>::getValue;
1597
69
    using BuiltinReflectableBase<ALLOC, T>::BuiltinReflectableBase;
1598
1599
public:
1600
61
    double toDouble() const override
1601
    {
1602
61
        return static_cast<double>(getValue());
1603
    }
1604
};
1605
1606
/**
1607
 * Reflectable for values of 16-bit float type.
1608
 */
1609
template <typename ALLOC>
1610
11
class Float16Reflectable : public FloatingPointReflectableBase<ALLOC, float>
1611
{
1612
private:
1613
    using Base = FloatingPointReflectableBase<ALLOC, float>;
1614
1615
public:
1616
13
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1617
    {
1618
13
        return BuiltinTypeInfo<ALLOC>::getFloat16();
1619
    }
1620
1621
11
    explicit Float16Reflectable(float value) :
1622
11
            Base(typeInfo(), value)
1623
11
    {}
1624
1625
5
    size_t bitSizeOf(size_t) const override
1626
    {
1627
5
        return 16;
1628
    }
1629
1630
5
    void write(BitStreamWriter& writer) const override
1631
    {
1632
5
        writer.writeFloat16(Base::getValue());
1633
5
    }
1634
1635
10
    float getFloat() const override
1636
    {
1637
10
        return Base::getValue();
1638
    }
1639
};
1640
1641
/**
1642
 * Reflectable for values of 32-bit float type.
1643
 */
1644
template <typename ALLOC>
1645
15
class Float32Reflectable : public FloatingPointReflectableBase<ALLOC, float>
1646
{
1647
private:
1648
    using Base = FloatingPointReflectableBase<ALLOC, float>;
1649
1650
public:
1651
17
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1652
    {
1653
17
        return BuiltinTypeInfo<ALLOC>::getFloat32();
1654
    }
1655
1656
15
    explicit Float32Reflectable(float value) :
1657
15
            Base(typeInfo(), value)
1658
15
    {}
1659
1660
7
    size_t bitSizeOf(size_t) const override
1661
    {
1662
7
        return 32;
1663
    }
1664
1665
7
    void write(BitStreamWriter& writer) const override
1666
    {
1667
7
        writer.writeFloat32(Base::getValue());
1668
7
    }
1669
1670
15
    float getFloat() const override
1671
    {
1672
15
        return Base::getValue();
1673
    }
1674
};
1675
1676
/**
1677
 * Reflectable for values of double type.
1678
 */
1679
template <typename ALLOC>
1680
43
class Float64Reflectable : public FloatingPointReflectableBase<ALLOC, double>
1681
{
1682
private:
1683
    using Base = FloatingPointReflectableBase<ALLOC, double>;
1684
1685
public:
1686
45
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1687
    {
1688
45
        return BuiltinTypeInfo<ALLOC>::getFloat64();
1689
    }
1690
1691
43
    explicit Float64Reflectable(double value) :
1692
43
            Base(typeInfo(), value)
1693
43
    {}
1694
1695
7
    size_t bitSizeOf(size_t) const override
1696
    {
1697
7
        return 64;
1698
    }
1699
1700
7
    void write(BitStreamWriter& writer) const override
1701
    {
1702
7
        writer.writeFloat64(Base::getValue());
1703
7
    }
1704
1705
15
    double getDouble() const override
1706
    {
1707
15
        return Base::getValue();
1708
    }
1709
};
1710
1711
/**
1712
 * Reflectable for values of bytes type.
1713
 */
1714
template <typename ALLOC>
1715
31
class BytesReflectable : public BuiltinReflectableBase<ALLOC, Span<const uint8_t>>
1716
{
1717
private:
1718
    using Base = BuiltinReflectableBase<ALLOC, Span<const uint8_t>>;
1719
1720
public:
1721
44
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1722
    {
1723
44
        return BuiltinTypeInfo<ALLOC>::getBytes();
1724
    }
1725
1726
31
    explicit BytesReflectable(Span<const uint8_t> value) :
1727
31
            Base(typeInfo(), value)
1728
31
    {}
1729
1730
7
    size_t bitSizeOf(size_t) const override
1731
    {
1732
7
        return zserio::bitSizeOfBytes(Base::getValue());
1733
    }
1734
1735
7
    void write(BitStreamWriter& writer) const override
1736
    {
1737
7
        writer.writeBytes(Base::getValue());
1738
7
    }
1739
1740
52
    Span<const uint8_t> getBytes() const override
1741
    {
1742
52
        return Base::getValue();
1743
    }
1744
};
1745
1746
/**
1747
 * Reflectable for values of string type.
1748
 */
1749
template <typename ALLOC>
1750
155
class StringReflectable : public BuiltinReflectableBase<ALLOC, StringView>
1751
{
1752
private:
1753
    using Base = BuiltinReflectableBase<ALLOC, StringView>;
1754
1755
public:
1756
176
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1757
    {
1758
176
        return BuiltinTypeInfo<ALLOC>::getString();
1759
    }
1760
1761
155
    explicit StringReflectable(StringView value) :
1762
155
            Base(typeInfo(), value)
1763
155
    {}
1764
1765
11
    size_t bitSizeOf(size_t) const override
1766
    {
1767
11
        return zserio::bitSizeOfString(Base::getValue());
1768
    }
1769
1770
11
    void write(BitStreamWriter& writer) const override
1771
    {
1772
11
        writer.writeString(Base::getValue());
1773
11
    }
1774
1775
105
    StringView getStringView() const override
1776
    {
1777
105
        return Base::getValue();
1778
    }
1779
1780
34
    string<ALLOC> toString(const ALLOC& allocator) const override
1781
    {
1782
34
        return zserio::toString(Base::getValue(), allocator);
1783
    }
1784
};
1785
1786
/**
1787
 * Reflectable for values of bit buffer type.
1788
 */
1789
template <typename ALLOC>
1790
30
class BitBufferReflectable : public BuiltinReflectableBase<ALLOC, BasicBitBuffer<ALLOC>>
1791
{
1792
private:
1793
    using Base = BuiltinReflectableBase<ALLOC, BasicBitBuffer<ALLOC>>;
1794
1795
public:
1796
42
    static const IBasicTypeInfo<ALLOC>& typeInfo()
1797
    {
1798
42
        return BuiltinTypeInfo<ALLOC>::getBitBuffer();
1799
    }
1800
1801
30
    explicit BitBufferReflectable(const BasicBitBuffer<ALLOC>& value) :
1802
30
            Base(typeInfo(), value)
1803
30
    {}
1804
1805
7
    size_t bitSizeOf(size_t) const override
1806
    {
1807
7
        return zserio::bitSizeOfBitBuffer(Base::getValue());
1808
    }
1809
1810
7
    void write(BitStreamWriter& writer) const override
1811
    {
1812
7
        writer.writeBitBuffer(Base::getValue());
1813
7
    }
1814
1815
28
    const BasicBitBuffer<ALLOC>& getBitBuffer() const override
1816
    {
1817
28
        return Base::getValue();
1818
    }
1819
};
1820
1821
namespace detail
1822
{
1823
1824
template <typename ALLOC>
1825
626
IBasicReflectableConstPtr<ALLOC> getFieldFromObject(const IBasicReflectable<ALLOC>& object, StringView name)
1826
{
1827
626
    const auto& typeInfo = object.getTypeInfo();
1828
626
    if (TypeInfoUtil::isCompound(typeInfo.getSchemaType()))
1829
    {
1830
176
        const auto& fields = typeInfo.getFields();
1831
176
        auto fieldsIt = std::find_if(fields.begin(), fields.end(),
1832
446
                [name](const BasicFieldInfo<ALLOC>& fieldInfo) { return fieldInfo.schemaName == name; });
1833
176
        if (fieldsIt != fields.end())
1834
106
            return object.getField(name);
1835
    }
1836
1837
520
    return nullptr;
1838
}
1839
1840
template <typename ALLOC>
1841
464
IBasicReflectablePtr<ALLOC> getFieldFromObject(IBasicReflectable<ALLOC>& object, StringView name)
1842
{
1843
464
    const auto& typeInfo = object.getTypeInfo();
1844
464
    if (TypeInfoUtil::isCompound(typeInfo.getSchemaType()))
1845
    {
1846
151
        const auto& fields = typeInfo.getFields();
1847
151
        auto fieldsIt = std::find_if(fields.begin(), fields.end(),
1848
496
                [name](const BasicFieldInfo<ALLOC>& fieldInfo) { return fieldInfo.schemaName == name; });
1849
151
        if (fieldsIt != fields.end())
1850
119
            return object.getField(name);
1851
    }
1852
1853
345
    return nullptr;
1854
}
1855
1856
template <typename ALLOC>
1857
520
IBasicReflectableConstPtr<ALLOC> getParameterFromObject(const IBasicReflectable<ALLOC>& object, StringView name)
1858
{
1859
520
    const auto& typeInfo = object.getTypeInfo();
1860
520
    if (TypeInfoUtil::isCompound(typeInfo.getSchemaType()))
1861
    {
1862
70
        const auto& parameters = typeInfo.getParameters();
1863
70
        auto parametersIt = std::find_if(parameters.begin(), parameters.end(),
1864
100
                [name](const BasicParameterInfo<ALLOC>& parameterInfo)
1865
170
                        { return parameterInfo.schemaName == name; });
1866
70
        if (parametersIt != parameters.end())
1867
26
            return object.getParameter(name);
1868
    }
1869
1870
494
    return nullptr;
1871
}
1872
1873
template <typename ALLOC>
1874
345
IBasicReflectablePtr<ALLOC> getParameterFromObject(IBasicReflectable<ALLOC>& object, StringView name)
1875
{
1876
345
    const auto& typeInfo = object.getTypeInfo();
1877
345
    if (TypeInfoUtil::isCompound(typeInfo.getSchemaType()))
1878
    {
1879
32
        const auto& parameters = typeInfo.getParameters();
1880
32
        auto parametersIt = std::find_if(parameters.begin(), parameters.end(),
1881
39
                [name](const BasicParameterInfo<ALLOC>& parameterInfo)
1882
71
                        { return parameterInfo.schemaName == name; });
1883
32
        if (parametersIt != parameters.end())
1884
11
            return object.getParameter(name);
1885
    }
1886
1887
334
    return nullptr;
1888
}
1889
1890
template <typename ALLOC>
1891
494
IBasicReflectableConstPtr<ALLOC> callFunctionInObject(const IBasicReflectable<ALLOC>& object, StringView name)
1892
{
1893
494
    const auto& typeInfo = object.getTypeInfo();
1894
494
    if (TypeInfoUtil::isCompound(typeInfo.getSchemaType()))
1895
    {
1896
44
        const auto& functions = typeInfo.getFunctions();
1897
44
        auto functionsIt = std::find_if(functions.begin(), functions.end(),
1898
32
                [name](const BasicFunctionInfo<ALLOC>& functionInfo)
1899
76
                        { return functionInfo.schemaName == name; });
1900
44
        if (functionsIt != functions.end())
1901
16
            return object.callFunction(name);
1902
    }
1903
1904
478
    return nullptr;
1905
}
1906
1907
template <typename ALLOC>
1908
334
IBasicReflectablePtr<ALLOC> callFunctionInObject(IBasicReflectable<ALLOC>& object, StringView name)
1909
{
1910
334
    const auto& typeInfo = object.getTypeInfo();
1911
334
    if (TypeInfoUtil::isCompound(typeInfo.getSchemaType()))
1912
    {
1913
21
        const auto& functions = typeInfo.getFunctions();
1914
21
        auto functionsIt = std::find_if(functions.begin(), functions.end(),
1915
12
                [name](const BasicFunctionInfo<ALLOC>& functionInfo)
1916
                {
1917
                    return functionInfo.schemaName == name;
1918
12
                }
1919
21
        );
1920
21
        if (functionsIt != functions.end())
1921
6
            return object.callFunction(name);
1922
    }
1923
1924
328
    return nullptr;
1925
}
1926
1927
template <typename ALLOC>
1928
626
IBasicReflectableConstPtr<ALLOC> getFromObject(
1929
        const IBasicReflectable<ALLOC>& object, StringView path, size_t pos)
1930
{
1931
    try
1932
    {
1933
626
        const size_t dotPos = path.find('.', pos);
1934
626
        const bool isLast = dotPos == StringView::npos;
1935

626
        const StringView name = path.substr(pos, dotPos == StringView::npos ? StringView::npos : dotPos - pos);
1936
1937

1106
        auto field = getFieldFromObject(object, name);
1938
626
        if (field)
1939

106
            return isLast ? field : getFromObject(*field, path, dotPos + 1);
1940
1941

998
        auto parameter = getParameterFromObject(object, name);
1942
518
        if (parameter)
1943

24
            return isLast ? parameter : getFromObject(*parameter, path, dotPos + 1);
1944
1945

972
        auto functionResult = callFunctionInObject(object, name);
1946
494
        if (functionResult)
1947

16
            return isLast ? functionResult : getFromObject(*functionResult, path, dotPos + 1);
1948
    }
1949
2
    catch (const CppRuntimeException&)
1950
    {}
1951
1952
480
    return nullptr;
1953
}
1954
1955
template <typename ALLOC>
1956
464
IBasicReflectablePtr<ALLOC> getFromObject(IBasicReflectable<ALLOC>& object, StringView path, size_t pos)
1957
{
1958
    try
1959
    {
1960
464
        const size_t dotPos = path.find('.', pos);
1961
464
        const bool isLast = dotPos == StringView::npos;
1962

464
        const StringView name = path.substr(pos, dotPos == StringView::npos ? StringView::npos : dotPos - pos);
1963
1964

793
        auto field = getFieldFromObject(object, name);
1965
464
        if (field)
1966

119
            return isLast ? field : getFromObject(*field, path, dotPos + 1);
1967
1968

673
        auto parameter = getParameterFromObject(object, name);
1969
344
        if (parameter)
1970

10
            return isLast ? parameter : getFromObject(*parameter, path, dotPos + 1);
1971
1972

662
        auto functionResult = callFunctionInObject(object, name);
1973
334
        if (functionResult)
1974

6
            return isLast ? functionResult : getFromObject(*functionResult, path, dotPos + 1);
1975
    }
1976
1
    catch (const CppRuntimeException&)
1977
    {}
1978
1979
329
    return nullptr;
1980
}
1981
1982
} // namespace detail
1983
1984
/**
1985
 * Base class for reflectable which needs to hold an allocator.
1986
 */
1987
template <typename ALLOC>
1988
689
class ReflectableAllocatorHolderBase : public ReflectableBase<ALLOC>, public AllocatorHolder<ALLOC>
1989
{
1990
public:
1991
689
    ReflectableAllocatorHolderBase(const IBasicTypeInfo<ALLOC>& typeInfo, const ALLOC& allocator) :
1992
689
            ReflectableBase<ALLOC>(typeInfo), AllocatorHolder<ALLOC>(allocator)
1993
689
    {}
1994
};
1995
1996
/**
1997
 * Base class for constant reflectable which needs to hold an allocator.
1998
 *
1999
 * Overrides non constant methods and throws exception with info about constness.
2000
 */
2001
template <typename ALLOC>
2002
95
class ReflectableConstAllocatorHolderBase : public ReflectableAllocatorHolderBase<ALLOC>
2003
{
2004
private:
2005
    using Base = ReflectableAllocatorHolderBase<ALLOC>;
2006
2007
public:
2008
95
    using Base::Base;
2009
    using Base::getTypeInfo;
2010
2011
    void initializeChildren() override;
2012
    void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) override;
2013
    size_t initializeOffsets(size_t bitPosition) override;
2014
2015
    IBasicReflectablePtr<ALLOC> getField(StringView name) override;
2016
    void setField(StringView name, const AnyHolder<ALLOC>& value) override;
2017
    IBasicReflectablePtr<ALLOC> getParameter(StringView name) override;
2018
    IBasicReflectablePtr<ALLOC> callFunction(StringView name) override;
2019
2020
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override;
2021
};
2022
2023
/**
2024
 * Base class for reflectable arrays.
2025
 *
2026
 * Overrides all generic methods with default throw behaviour.
2027
 */
2028
template <typename ALLOC>
2029
153
class ReflectableArrayBase : public ReflectableAllocatorHolderBase<ALLOC>
2030
{
2031
private:
2032
    using Base = ReflectableAllocatorHolderBase<ALLOC>;
2033
2034
public:
2035
153
    using Base::Base;
2036
    using Base::getTypeInfo;
2037
2038
98
    bool isArray() const override
2039
    {
2040
98
        return true;
2041
    }
2042
2043
    void initializeChildren() override;
2044
    void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) override;
2045
    size_t initializeOffsets(size_t bitPosition) override;
2046
    size_t bitSizeOf(size_t bitPosition) const override;
2047
    void write(BitStreamWriter& writer) const override;
2048
2049
    IBasicReflectableConstPtr<ALLOC> getField(StringView name) const override;
2050
    IBasicReflectablePtr<ALLOC> getField(StringView name) override;
2051
    IBasicReflectablePtr<ALLOC> createField(StringView name) override;
2052
    void setField(StringView name, const AnyHolder<ALLOC>& value) override;
2053
    IBasicReflectableConstPtr<ALLOC> getParameter(StringView name) const override;
2054
    IBasicReflectablePtr<ALLOC> getParameter(StringView name) override;
2055
    IBasicReflectableConstPtr<ALLOC> callFunction(StringView name) const override;
2056
    IBasicReflectablePtr<ALLOC> callFunction(StringView name) override;
2057
2058
    StringView getChoice() const override;
2059
2060
    IBasicReflectableConstPtr<ALLOC> operator[](size_t index) const override;
2061
    IBasicReflectablePtr<ALLOC> operator[](size_t index) override;
2062
2063
    bool getBool() const override;
2064
    int8_t getInt8() const override;
2065
    int16_t getInt16() const override;
2066
    int32_t getInt32() const override;
2067
    int64_t getInt64() const override;
2068
    uint8_t getUInt8() const override;
2069
    uint16_t getUInt16() const override;
2070
    uint32_t getUInt32() const override;
2071
    uint64_t getUInt64() const override;
2072
    float getFloat() const override;
2073
    double getDouble() const override;
2074
    Span<const uint8_t> getBytes() const override;
2075
    StringView getStringView() const override;
2076
    const BasicBitBuffer<ALLOC>& getBitBuffer() const override;
2077
2078
    int64_t toInt() const override;
2079
    uint64_t toUInt() const override;
2080
    double toDouble() const override;
2081
    string<ALLOC> toString(const ALLOC& allocator) const override;
2082
};
2083
2084
/**
2085
 * Base class for constant reflectable arrays.
2086
 *
2087
 * Overrides non constant methods and throws exception with info about constness.
2088
 */
2089
template <typename ALLOC>
2090
32
class ReflectableConstArrayBase : public ReflectableArrayBase<ALLOC>
2091
{
2092
private:
2093
    using Base = ReflectableArrayBase<ALLOC>;
2094
2095
public:
2096
32
    using Base::Base;
2097
    using Base::getTypeInfo;
2098
2099
    void resize(size_t index) override;
2100
    IBasicReflectablePtr<ALLOC> at(size_t index) override;
2101
    IBasicReflectablePtr<ALLOC> operator[](size_t index) override;
2102
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override;
2103
    void append(const AnyHolder<ALLOC>& value) override;
2104
2105
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override;
2106
};
2107
2108
/**
2109
 * Reflectable for arrays of builtin types (except bit field arrays).
2110
 */
2111
/** \{ */
2112
template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE>
2113












25
class BuiltinReflectableConstArray : public ReflectableConstArrayBase<ALLOC>
2114
{
2115
private:
2116
    using Base = ReflectableConstArrayBase<ALLOC>;
2117
2118
    using ElementReflectable = ELEMENT_REFLECTABLE;
2119
2120
public:
2121
    using Base::getTypeInfo;
2122
    using Base::at;
2123
    using Base::operator[];
2124
    using Base::getAnyValue;
2125
2126
25
    BuiltinReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) :
2127
25
            Base(ElementReflectable::typeInfo(), allocator), m_rawArray(rawArray)
2128
25
    {}
2129
2130
207
    size_t size() const override
2131
    {
2132
207
        return m_rawArray.size();
2133
    }
2134
2135
135
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2136
    {
2137












135
        if (index >= size())
2138
        {
2139




























































192
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2140




























































192
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2141
        }
2142
2143














87
        return std::allocate_shared<ElementReflectable>(Base::get_allocator(), m_rawArray[index]);
2144
    }
2145
2146
25
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2147
    {
2148












25
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2149
    }
2150
2151
private:
2152
    const RAW_ARRAY& m_rawArray;
2153
};
2154
2155
template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE>
2156












74
class BuiltinReflectableArray : public ReflectableArrayBase<ALLOC>
2157
{
2158
private:
2159
    using Base = ReflectableArrayBase<ALLOC>;
2160
2161
    using ElementReflectable = ELEMENT_REFLECTABLE;
2162
2163
public:
2164
    using Base::getTypeInfo;
2165
2166
74
    BuiltinReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) :
2167
74
            Base(ElementReflectable::typeInfo(), allocator), m_rawArray(rawArray)
2168
74
    {}
2169
2170
367
    size_t size() const override
2171
    {
2172
367
        return m_rawArray.size();
2173
    }
2174
2175
8
    void resize(size_t size) override
2176
    {
2177
8
        m_rawArray.resize(size);
2178
8
    }
2179
2180
47
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2181
    {
2182












47
        if (index >= size())
2183
        {
2184




























































32
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2185




























































32
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2186
        }
2187
2188














39
        return std::allocate_shared<ElementReflectable>(Base::get_allocator(), m_rawArray[index]);
2189
    }
2190
2191
164
    IBasicReflectablePtr<ALLOC> at(size_t index) override
2192
    {
2193












164
        if (index >= size())
2194
        {
2195




























































192
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2196




























































192
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2197
        }
2198
2199














116
        return std::allocate_shared<ElementReflectable>(Base::get_allocator(), m_rawArray[index]);
2200
    }
2201
2202
8
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override
2203
    {
2204












8
        if (index >= size())
2205
        {
2206




























































16
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2207




























































16
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2208
        }
2209
2210
4
        m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>();
2211
4
    }
2212
2213
22
    void append(const AnyHolder<ALLOC>& value) override
2214
    {
2215
22
        m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>());
2216
22
    }
2217
2218
4
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2219
    {
2220












4
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2221
    }
2222
2223
25
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
2224
    {
2225












25
        return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator);
2226
    }
2227
2228
private:
2229
    RAW_ARRAY& m_rawArray;
2230
};
2231
/** \} */
2232
2233
/**
2234
 * Reflectable for arrays of fixed bit fields.
2235
 */
2236
/** \{ */
2237
template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE>
2238

2
class FixedBitFieldReflectableConstArray : public ReflectableConstArrayBase<ALLOC>
2239
{
2240
private:
2241
    using Base = ReflectableConstArrayBase<ALLOC>;
2242
2243
    using ElementReflectable = ELEMENT_REFLECTABLE;
2244
2245
public:
2246
    using Base::getTypeInfo;
2247
    using Base::at;
2248
    using Base::operator[];
2249
    using Base::getAnyValue;
2250
2251
2
    FixedBitFieldReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray, uint8_t bitSize) :
2252
2
            Base(ElementReflectable::typeInfo(bitSize), allocator), m_rawArray(rawArray)
2253
2
    {}
2254
2255
20
    size_t size() const override
2256
    {
2257
20
        return m_rawArray.size();
2258
    }
2259
2260
14
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2261
    {
2262

14
        if (index >= size())
2263
        {
2264





16
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2265





16
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2266
        }
2267
2268
20
        return std::allocate_shared<ElementReflectable>(
2269


20
                Base::get_allocator(), m_rawArray[index], getTypeInfo().getBitSize());
2270
    }
2271
2272
2
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2273
    {
2274

2
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2275
    }
2276
2277
private:
2278
    const RAW_ARRAY& m_rawArray;
2279
};
2280
2281
template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE>
2282

2
class FixedBitFieldReflectableArray : public ReflectableArrayBase<ALLOC>
2283
{
2284
private:
2285
    using Base = ReflectableArrayBase<ALLOC>;
2286
2287
    using ElementReflectable = ELEMENT_REFLECTABLE;
2288
2289
public:
2290
    using Base::getTypeInfo;
2291
2292
2
    FixedBitFieldReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray, uint8_t bitSize) :
2293
2
            Base(ElementReflectable::typeInfo(bitSize), allocator), m_rawArray(rawArray)
2294
2
    {}
2295
2296
39
    size_t size() const override
2297
    {
2298
39
        return m_rawArray.size();
2299
    }
2300
2301
2
    void resize(size_t size) override
2302
    {
2303
2
        m_rawArray.resize(size);
2304
2
    }
2305
2306
7
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2307
    {
2308

7
        if (index >= size())
2309
        {
2310





8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2311





8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2312
        }
2313
2314
10
        return std::allocate_shared<ElementReflectable>(
2315


10
                Base::get_allocator(), m_rawArray[index], getTypeInfo().getBitSize());
2316
    }
2317
2318
16
    IBasicReflectablePtr<ALLOC> at(size_t index) override
2319
    {
2320

16
        if (index >= size())
2321
        {
2322





16
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2323





16
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2324
        }
2325
2326
24
        return std::allocate_shared<ElementReflectable>(
2327


24
                Base::get_allocator(), m_rawArray[index], getTypeInfo().getBitSize());
2328
    }
2329
2330
2
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override
2331
    {
2332

2
        if (index >= size())
2333
        {
2334





4
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2335





4
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2336
        }
2337
2338
1
        m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>();
2339
1
    }
2340
2341
1
    void append(const AnyHolder<ALLOC>& value) override
2342
    {
2343
1
        m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>());
2344
1
    }
2345
2346
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2347
    {
2348

1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2349
    }
2350
2351
2
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
2352
    {
2353

2
        return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator);
2354
    }
2355
2356
private:
2357
    RAW_ARRAY& m_rawArray;
2358
};
2359
/** \} */
2360
2361
/**
2362
 * Reflectable for arrays of dynamic bit fields.
2363
 */
2364
/** \{ */
2365
template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE>
2366

2
class DynamicBitFieldReflectableConstArray : public ReflectableConstArrayBase<ALLOC>
2367
{
2368
private:
2369
    using Base = ReflectableConstArrayBase<ALLOC>;
2370
2371
    using ElementReflectable = ELEMENT_REFLECTABLE;
2372
2373
public:
2374
    using Base::getTypeInfo;
2375
    using Base::at;
2376
    using Base::operator[];
2377
    using Base::getAnyValue;
2378
2379
2
    DynamicBitFieldReflectableConstArray(const ALLOC& allocator,
2380
            const RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize) :
2381
2
            Base(ElementReflectable::typeInfo(maxBitSize), allocator),
2382
2
            m_rawArray(rawArray), m_maxBitSize(maxBitSize), m_dynamicBitSize(dynamicBitSize)
2383
2
    {}
2384
2385
20
    size_t size() const override
2386
    {
2387
20
        return m_rawArray.size();
2388
    }
2389
2390
14
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2391
    {
2392

14
        if (index >= size())
2393
        {
2394





16
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2395





16
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2396
        }
2397
2398
        return std::allocate_shared<ElementReflectable>(
2399

10
                Base::get_allocator(), m_rawArray[index], m_maxBitSize, m_dynamicBitSize);
2400
    }
2401
2402
2
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2403
    {
2404

2
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2405
    }
2406
2407
private:
2408
    const RAW_ARRAY& m_rawArray;
2409
    const uint8_t m_maxBitSize;
2410
    const uint8_t m_dynamicBitSize;
2411
};
2412
2413
template <typename ALLOC, typename RAW_ARRAY, typename ELEMENT_REFLECTABLE>
2414

2
class DynamicBitFieldReflectableArray : public ReflectableArrayBase<ALLOC>
2415
{
2416
private:
2417
    using Base = ReflectableArrayBase<ALLOC>;
2418
2419
    using ElementReflectable = ELEMENT_REFLECTABLE;
2420
2421
public:
2422
    using Base::getTypeInfo;
2423
2424
2
    DynamicBitFieldReflectableArray(const ALLOC& allocator,
2425
            RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize) :
2426
2
            Base(ElementReflectable::typeInfo(maxBitSize), allocator),
2427
2
            m_rawArray(rawArray), m_maxBitSize(maxBitSize), m_dynamicBitSize(dynamicBitSize)
2428
2
    {}
2429
2430
39
    size_t size() const override
2431
    {
2432
39
        return m_rawArray.size();
2433
    }
2434
2435
2
    void resize(size_t size) override
2436
    {
2437
2
        m_rawArray.resize(size);
2438
2
    }
2439
2440
7
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2441
    {
2442

7
        if (index >= size())
2443
        {
2444





8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2445





8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2446
        }
2447
2448
        return std::allocate_shared<ElementReflectable>(
2449

5
                Base::get_allocator(), m_rawArray[index], m_maxBitSize, m_dynamicBitSize);
2450
    }
2451
2452
16
    IBasicReflectablePtr<ALLOC> at(size_t index) override
2453
    {
2454

16
        if (index >= size())
2455
        {
2456





16
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2457





16
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2458
        }
2459
2460
        return std::allocate_shared<ElementReflectable>(
2461

12
                Base::get_allocator(), m_rawArray[index], m_maxBitSize, m_dynamicBitSize);
2462
    }
2463
2464
2
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override
2465
    {
2466

2
        if (index >= size())
2467
        {
2468





4
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2469





4
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2470
        }
2471
2472
1
        m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>();
2473
1
    }
2474
2475
1
    void append(const AnyHolder<ALLOC>& value) override
2476
    {
2477
1
        m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>());
2478
1
    }
2479
2480
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2481
    {
2482

1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2483
    }
2484
2485
2
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
2486
    {
2487

2
        return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator);
2488
    }
2489
2490
private:
2491
    RAW_ARRAY& m_rawArray;
2492
    const uint8_t m_maxBitSize;
2493
    const uint8_t m_dynamicBitSize;
2494
};
2495
/** \} */
2496
2497
/**
2498
 * Typedef to a builtin array.
2499
 */
2500
/** \{ */
2501
template <typename ALLOC, typename RAW_ARRAY>
2502
using BoolReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, BoolReflectable<ALLOC>>;
2503
template <typename ALLOC, typename RAW_ARRAY>
2504
using BoolReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, BoolReflectable<ALLOC>>;
2505
2506
template <typename ALLOC, typename RAW_ARRAY>
2507
using Int8ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int8Reflectable<ALLOC>>;
2508
template <typename ALLOC, typename RAW_ARRAY>
2509
using Int8ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int8Reflectable<ALLOC>>;
2510
2511
template <typename ALLOC, typename RAW_ARRAY>
2512
using Int16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int16Reflectable<ALLOC>>;
2513
template <typename ALLOC, typename RAW_ARRAY>
2514
using Int16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int16Reflectable<ALLOC>>;
2515
2516
template <typename ALLOC, typename RAW_ARRAY>
2517
using Int32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int32Reflectable<ALLOC>>;
2518
template <typename ALLOC, typename RAW_ARRAY>
2519
using Int32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int32Reflectable<ALLOC>>;
2520
2521
template <typename ALLOC, typename RAW_ARRAY>
2522
using Int64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, Int64Reflectable<ALLOC>>;
2523
template <typename ALLOC, typename RAW_ARRAY>
2524
using Int64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Int64Reflectable<ALLOC>>;
2525
2526
template <typename ALLOC, typename RAW_ARRAY>
2527
using UInt8ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt8Reflectable<ALLOC>>;
2528
template <typename ALLOC, typename RAW_ARRAY>
2529
using UInt8ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt8Reflectable<ALLOC>>;
2530
2531
template <typename ALLOC, typename RAW_ARRAY>
2532
using UInt16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt16Reflectable<ALLOC>>;
2533
template <typename ALLOC, typename RAW_ARRAY>
2534
using UInt16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt16Reflectable<ALLOC>>;
2535
2536
template <typename ALLOC, typename RAW_ARRAY>
2537
using UInt32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt32Reflectable<ALLOC>>;
2538
template <typename ALLOC, typename RAW_ARRAY>
2539
using UInt32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt32Reflectable<ALLOC>>;
2540
2541
template <typename ALLOC, typename RAW_ARRAY>
2542
using UInt64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, UInt64Reflectable<ALLOC>>;
2543
template <typename ALLOC, typename RAW_ARRAY>
2544
using UInt64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, UInt64Reflectable<ALLOC>>;
2545
2546
template <typename ALLOC, typename RAW_ARRAY>
2547
using FixedSignedBitFieldReflectableConstArray = FixedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY,
2548
        FixedSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2549
template <typename ALLOC, typename RAW_ARRAY>
2550
using FixedSignedBitFieldReflectableArray = FixedBitFieldReflectableArray<ALLOC, RAW_ARRAY,
2551
        FixedSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2552
2553
template <typename ALLOC, typename RAW_ARRAY>
2554
using FixedUnsignedBitFieldReflectableConstArray = FixedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY,
2555
        FixedUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2556
template <typename ALLOC, typename RAW_ARRAY>
2557
using FixedUnsignedBitFieldReflectableArray = FixedBitFieldReflectableArray<ALLOC, RAW_ARRAY,
2558
        FixedUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2559
2560
template <typename ALLOC, typename RAW_ARRAY>
2561
using DynamicSignedBitFieldReflectableConstArray = DynamicBitFieldReflectableConstArray<ALLOC, RAW_ARRAY,
2562
        DynamicSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2563
template <typename ALLOC, typename RAW_ARRAY>
2564
using DynamicSignedBitFieldReflectableArray = DynamicBitFieldReflectableArray<ALLOC, RAW_ARRAY,
2565
        DynamicSignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2566
2567
template <typename ALLOC, typename RAW_ARRAY>
2568
using DynamicUnsignedBitFieldReflectableConstArray = DynamicBitFieldReflectableConstArray<ALLOC, RAW_ARRAY,
2569
        DynamicUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2570
template <typename ALLOC, typename RAW_ARRAY>
2571
using DynamicUnsignedBitFieldReflectableArray = DynamicBitFieldReflectableArray<ALLOC, RAW_ARRAY,
2572
        DynamicUnsignedBitFieldReflectable<ALLOC, typename RAW_ARRAY::value_type>>;
2573
2574
template <typename ALLOC, typename RAW_ARRAY>
2575
using VarInt16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2576
        VarInt16Reflectable<ALLOC>>;
2577
template <typename ALLOC, typename RAW_ARRAY>
2578
using VarInt16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarInt16Reflectable<ALLOC>>;
2579
2580
template <typename ALLOC, typename RAW_ARRAY>
2581
using VarInt32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2582
        VarInt32Reflectable<ALLOC>>;
2583
template <typename ALLOC, typename RAW_ARRAY>
2584
using VarInt32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarInt32Reflectable<ALLOC>>;
2585
2586
template <typename ALLOC, typename RAW_ARRAY>
2587
using VarInt64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2588
        VarInt64Reflectable<ALLOC>>;
2589
template <typename ALLOC, typename RAW_ARRAY>
2590
using VarInt64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarInt64Reflectable<ALLOC>>;
2591
2592
template <typename ALLOC, typename RAW_ARRAY>
2593
using VarIntReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY, VarIntReflectable<ALLOC>>;
2594
template <typename ALLOC, typename RAW_ARRAY>
2595
using VarIntReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarIntReflectable<ALLOC>>;
2596
2597
template <typename ALLOC, typename RAW_ARRAY>
2598
using VarUInt16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2599
        VarUInt16Reflectable<ALLOC>>;
2600
template <typename ALLOC, typename RAW_ARRAY>
2601
using VarUInt16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUInt16Reflectable<ALLOC>>;
2602
2603
template <typename ALLOC, typename RAW_ARRAY>
2604
using VarUInt32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2605
        VarUInt32Reflectable<ALLOC>>;
2606
template <typename ALLOC, typename RAW_ARRAY>
2607
using VarUInt32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUInt32Reflectable<ALLOC>>;
2608
2609
template <typename ALLOC, typename RAW_ARRAY>
2610
using VarUInt64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2611
        VarUInt64Reflectable<ALLOC>>;
2612
template <typename ALLOC, typename RAW_ARRAY>
2613
using VarUInt64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUInt64Reflectable<ALLOC>>;
2614
2615
template <typename ALLOC, typename RAW_ARRAY>
2616
using VarUIntReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2617
        VarUIntReflectable<ALLOC>>;
2618
template <typename ALLOC, typename RAW_ARRAY>
2619
using VarUIntReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarUIntReflectable<ALLOC>>;
2620
2621
template <typename ALLOC, typename RAW_ARRAY>
2622
using VarSizeReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2623
        VarSizeReflectable<ALLOC>>;
2624
template <typename ALLOC, typename RAW_ARRAY>
2625
using VarSizeReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, VarSizeReflectable<ALLOC>>;
2626
2627
template <typename ALLOC, typename RAW_ARRAY>
2628
using Float16ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2629
        Float16Reflectable<ALLOC>>;
2630
template <typename ALLOC, typename RAW_ARRAY>
2631
using Float16ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Float16Reflectable<ALLOC>>;
2632
2633
template <typename ALLOC, typename RAW_ARRAY>
2634
using Float32ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2635
        Float32Reflectable<ALLOC>>;
2636
template <typename ALLOC, typename RAW_ARRAY>
2637
using Float32ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Float32Reflectable<ALLOC>>;
2638
2639
template <typename ALLOC, typename RAW_ARRAY>
2640
using Float64ReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2641
        Float64Reflectable<ALLOC>>;
2642
template <typename ALLOC, typename RAW_ARRAY>
2643
using Float64ReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, Float64Reflectable<ALLOC>>;
2644
2645
template <typename ALLOC, typename RAW_ARRAY>
2646
using BytesReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2647
        BytesReflectable<ALLOC>>;
2648
template <typename ALLOC, typename RAW_ARRAY>
2649
using BytesReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, BytesReflectable<ALLOC>>;
2650
2651
template <typename ALLOC, typename RAW_ARRAY>
2652
using StringReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2653
        StringReflectable<ALLOC>>;
2654
template <typename ALLOC, typename RAW_ARRAY>
2655
using StringReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, StringReflectable<ALLOC>>;
2656
2657
template <typename ALLOC, typename RAW_ARRAY>
2658
using BitBufferReflectableConstArray = BuiltinReflectableConstArray<ALLOC, RAW_ARRAY,
2659
        BitBufferReflectable<ALLOC>>;
2660
template <typename ALLOC, typename RAW_ARRAY>
2661
using BitBufferReflectableArray = BuiltinReflectableArray<ALLOC, RAW_ARRAY, BitBufferReflectable<ALLOC>>;
2662
/** \} */
2663
2664
/**
2665
 * Reflectable for arrays of compound types.
2666
 */
2667
/** \{ */
2668
template <typename ALLOC, typename RAW_ARRAY>
2669
1
class CompoundReflectableConstArray : public ReflectableConstArrayBase<ALLOC>
2670
{
2671
private:
2672
    using Base = ReflectableConstArrayBase<ALLOC>;
2673
2674
    using ElementType = typename RAW_ARRAY::value_type;
2675
2676
public:
2677
    using Base::getTypeInfo;
2678
    using Base::at;
2679
    using Base::operator[];
2680
    using Base::getAnyValue;
2681
2682
1
    CompoundReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) :
2683
1
            Base(ElementType::typeInfo(), allocator), m_rawArray(rawArray)
2684
1
    {}
2685
2686
8
    size_t size() const override
2687
    {
2688
8
        return m_rawArray.size();
2689
    }
2690
2691
4
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2692
    {
2693
4
        if (index >= size())
2694
        {
2695


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2696


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2697
        }
2698
2699
2
        return m_rawArray[index].reflectable(Base::get_allocator());
2700
    }
2701
2702
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2703
    {
2704
1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2705
    }
2706
2707
private:
2708
    const RAW_ARRAY& m_rawArray;
2709
};
2710
2711
template <typename ALLOC, typename RAW_ARRAY>
2712
41
class CompoundReflectableArray : public ReflectableArrayBase<ALLOC>
2713
{
2714
private:
2715
    using Base = ReflectableArrayBase<ALLOC>;
2716
2717
    using ElementType = typename RAW_ARRAY::value_type;
2718
2719
public:
2720
    using Base::getTypeInfo;
2721
2722
41
    CompoundReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) :
2723
41
            Base(ElementType::typeInfo(), allocator), m_rawArray(rawArray)
2724
41
    {}
2725
2726
112
    size_t size() const override
2727
    {
2728
112
        return m_rawArray.size();
2729
    }
2730
2731
5
    void resize(size_t size) override
2732
    {
2733
5
        m_rawArray.resize(size);
2734
5
    }
2735
2736
31
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2737
    {
2738
31
        if (index >= size())
2739
        {
2740


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2741


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2742
        }
2743
2744
29
        return m_rawArray[index].reflectable(Base::get_allocator());
2745
    }
2746
2747
27
    IBasicReflectablePtr<ALLOC> at(size_t index) override
2748
    {
2749
27
        if (index >= size())
2750
        {
2751


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2752


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2753
        }
2754
2755
25
        return m_rawArray[index].reflectable(Base::get_allocator());
2756
    }
2757
2758
2
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override
2759
    {
2760
2
        if (index >= size())
2761
        {
2762


4
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2763


4
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2764
        }
2765
2766
1
        m_rawArray[index] = value.template get<typename RAW_ARRAY::value_type>();
2767
1
    }
2768
2769
2
    void append(const AnyHolder<ALLOC>& value) override
2770
    {
2771
2
        m_rawArray.push_back(value.template get<typename RAW_ARRAY::value_type>());
2772
1
    }
2773
2774
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2775
    {
2776
1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2777
    }
2778
2779
2
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
2780
    {
2781
2
        return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator);
2782
    }
2783
2784
private:
2785
    RAW_ARRAY& m_rawArray;
2786
};
2787
/** \} */
2788
2789
/** Reflectable for arrays of bitmask types. */
2790
/** \{ */
2791
template <typename ALLOC, typename RAW_ARRAY>
2792
1
class BitmaskReflectableConstArray : public ReflectableConstArrayBase<ALLOC>
2793
{
2794
private:
2795
    using Base = ReflectableConstArrayBase<ALLOC>;
2796
2797
    using ElementType = typename RAW_ARRAY::value_type;
2798
2799
public:
2800
    using Base::getTypeInfo;
2801
    using Base::at;
2802
    using Base::operator[];
2803
    using Base::getAnyValue;
2804
2805
1
    BitmaskReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) :
2806
1
            Base(ElementType::typeInfo(), allocator), m_rawArray(rawArray)
2807
1
    {}
2808
2809
8
    size_t size() const override
2810
    {
2811
8
        return m_rawArray.size();
2812
    }
2813
2814
5
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2815
    {
2816
5
        if (index >= size())
2817
        {
2818


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2819


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2820
        }
2821
2822
3
        return m_rawArray[index].reflectable(Base::get_allocator());
2823
    }
2824
2825
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2826
    {
2827
1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2828
    }
2829
2830
private:
2831
    const RAW_ARRAY& m_rawArray;
2832
};
2833
2834
template <typename ALLOC, typename RAW_ARRAY>
2835
1
class BitmaskReflectableArray : public ReflectableArrayBase<ALLOC>
2836
{
2837
private:
2838
    using Base = ReflectableArrayBase<ALLOC>;
2839
2840
    using ElementType = typename RAW_ARRAY::value_type;
2841
    using UnderlyingElementType = typename ElementType::underlying_type;
2842
2843
public:
2844
    using Base::getTypeInfo;
2845
2846
1
    BitmaskReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) :
2847
1
            Base(ElementType::typeInfo(), allocator), m_rawArray(rawArray)
2848
1
    {}
2849
2850
30
    size_t size() const override
2851
    {
2852
30
        return m_rawArray.size();
2853
    }
2854
2855
2
    void resize(size_t size) override
2856
    {
2857
2
        m_rawArray.resize(size);
2858
2
    }
2859
2860
5
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2861
    {
2862
5
        if (index >= size())
2863
        {
2864


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2865


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2866
        }
2867
2868
3
        return m_rawArray[index].reflectable(Base::get_allocator());
2869
    }
2870
2871
9
    IBasicReflectablePtr<ALLOC> at(size_t index) override
2872
    {
2873
9
        if (index >= size())
2874
        {
2875


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2876


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2877
        }
2878
2879
7
        return m_rawArray[index].reflectable(Base::get_allocator());
2880
    }
2881
2882
3
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override
2883
    {
2884
3
        if (index >= size())
2885
        {
2886


4
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2887


4
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2888
        }
2889
2890
2
        if (value.template isType<ElementType>())
2891
1
            m_rawArray[index] = value.template get<ElementType>();
2892
        else
2893
1
            m_rawArray[index] = ElementType(value.template get<UnderlyingElementType>());
2894
2
    }
2895
2896
2
    void append(const AnyHolder<ALLOC>& value) override
2897
    {
2898
2
        if (value.template isType<ElementType>())
2899
1
            m_rawArray.push_back(value.template get<ElementType>());
2900
        else
2901
1
            m_rawArray.push_back(ElementType(value.template get<UnderlyingElementType>()));
2902
2
    }
2903
2904
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2905
    {
2906
1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2907
    }
2908
2909
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
2910
    {
2911
1
        return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator);
2912
    }
2913
2914
private:
2915
    RAW_ARRAY& m_rawArray;
2916
};
2917
/** \} */
2918
2919
/** Reflectable for arrays of enum types. */
2920
/** \{ */
2921
template <typename ALLOC, typename RAW_ARRAY>
2922
1
class EnumReflectableConstArray : public ReflectableConstArrayBase<ALLOC>
2923
{
2924
private:
2925
    using Base = ReflectableConstArrayBase<ALLOC>;
2926
2927
    using ElementType = typename RAW_ARRAY::value_type;
2928
2929
public:
2930
    using Base::getTypeInfo;
2931
    using Base::at;
2932
    using Base::operator[];
2933
    using Base::getAnyValue;
2934
2935
1
    EnumReflectableConstArray(const ALLOC& allocator, const RAW_ARRAY& rawArray) :
2936
1
            Base(enumTypeInfo<ElementType, ALLOC>(), allocator), m_rawArray(rawArray)
2937
1
    {}
2938
2939
8
    size_t size() const override
2940
    {
2941
8
        return m_rawArray.size();
2942
    }
2943
2944
5
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2945
    {
2946
5
        if (index >= size())
2947
        {
2948


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2949


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2950
        }
2951
2952
3
        return enumReflectable(m_rawArray[index], Base::get_allocator());
2953
    }
2954
2955
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
2956
    {
2957
1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
2958
    }
2959
2960
private:
2961
    const RAW_ARRAY& m_rawArray;
2962
};
2963
2964
template <typename ALLOC, typename RAW_ARRAY>
2965
1
class EnumReflectableArray : public ReflectableArrayBase<ALLOC>
2966
{
2967
private:
2968
    using Base = ReflectableArrayBase<ALLOC>;
2969
2970
    using ElementType = typename RAW_ARRAY::value_type;
2971
    using UnderlyingElementType = typename std::underlying_type<ElementType>::type;
2972
2973
public:
2974
    using Base::getTypeInfo;
2975
2976
1
    EnumReflectableArray(const ALLOC& allocator, RAW_ARRAY& rawArray) :
2977
1
            Base(enumTypeInfo<ElementType, ALLOC>(), allocator), m_rawArray(rawArray)
2978
1
    {}
2979
2980
30
    size_t size() const override
2981
    {
2982
30
        return m_rawArray.size();
2983
    }
2984
2985
2
    void resize(size_t size) override
2986
    {
2987
2
        m_rawArray.resize(size);
2988
2
    }
2989
2990
5
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
2991
    {
2992
5
        if (index >= size())
2993
        {
2994


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
2995


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
2996
        }
2997
2998
3
        return enumReflectable(m_rawArray[index], Base::get_allocator());
2999
    }
3000
3001
9
    IBasicReflectablePtr<ALLOC> at(size_t index) override
3002
    {
3003
9
        if (index >= size())
3004
        {
3005


8
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
3006


8
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
3007
        }
3008
3009
7
        return enumReflectable(m_rawArray[index], Base::get_allocator());
3010
    }
3011
3012
3
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override
3013
    {
3014
3
        if (index >= size())
3015
        {
3016


4
            throw CppRuntimeException("Index ") << index << " out of range for reflectable array '" <<
3017


4
                    getTypeInfo().getSchemaName() << "' of size " << size() << "!";
3018
        }
3019
3020
2
        if (value.template isType<ElementType>())
3021
1
            m_rawArray[index] = value.template get<ElementType>();
3022
        else
3023
1
            m_rawArray[index] = valueToEnum<ElementType>(value.template get<UnderlyingElementType>());
3024
2
    }
3025
3026
2
    void append(const AnyHolder<ALLOC>& value) override
3027
    {
3028
2
        if (value.template isType<ElementType>())
3029
1
            m_rawArray.push_back(value.template get<ElementType>());
3030
        else
3031
1
            m_rawArray.push_back(valueToEnum<ElementType>(value.template get<UnderlyingElementType>()));
3032
2
    }
3033
3034
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
3035
    {
3036
1
        return AnyHolder<ALLOC>(std::cref(m_rawArray), allocator);
3037
    }
3038
3039
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
3040
    {
3041
1
        return AnyHolder<ALLOC>(std::ref(m_rawArray), allocator);
3042
    }
3043
3044
private:
3045
    RAW_ARRAY& m_rawArray;
3046
};
3047
/** \} */
3048
3049
/**
3050
 * Wrapper around reflectable which actually owns the reflected object.
3051
 *
3052
 * This is needed in ZserioTreeCreator to be able to generically create the new instance of a zserio object.
3053
 */
3054
template <typename T, typename ALLOC = typename T::allocator_type>
3055
83
class ReflectableOwner : public IBasicReflectable<ALLOC>
3056
{
3057
public:
3058
    ReflectableOwner() :
3059
            ReflectableOwner(ALLOC())
3060
    {}
3061
3062
83
    explicit ReflectableOwner(const ALLOC& allocator) :
3063
            m_object(allocator),
3064
83
            m_reflectable(m_object.reflectable(allocator))
3065
83
    {}
3066
3067
2
    const IBasicTypeInfo<ALLOC>& getTypeInfo() const override
3068
    {
3069
2
        return m_reflectable->getTypeInfo();
3070
    }
3071
3072
1
    bool isArray() const override
3073
    {
3074
1
        return m_reflectable->isArray();
3075
    }
3076
3077
6
    void initializeChildren() override
3078
    {
3079
6
        m_reflectable->initializeChildren();
3080
6
    }
3081
3082
6
    void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) override
3083
    {
3084
6
        m_reflectable->initialize(typeArguments);
3085
5
    }
3086
3087
1
    size_t initializeOffsets(size_t bitPosition) override
3088
    {
3089
1
        return m_reflectable->initializeOffsets(bitPosition);
3090
    }
3091
3092
1
    size_t initializeOffsets() override
3093
    {
3094
1
        return initializeOffsets(0);
3095
    }
3096
3097
2
    size_t bitSizeOf(size_t bitPosition) const override
3098
    {
3099
2
        return m_reflectable->bitSizeOf(bitPosition);
3100
    }
3101
3102
2
    size_t bitSizeOf() const override
3103
    {
3104
2
        return bitSizeOf(0);
3105
    }
3106
3107
1
    void write(BitStreamWriter& writer) const override
3108
    {
3109
1
        m_reflectable->write(writer);
3110
1
    }
3111
3112
1
    IBasicReflectableConstPtr<ALLOC> getField(StringView name) const override
3113
    {
3114
1
        return m_reflectable->getField(name);
3115
    }
3116
3117
126
    IBasicReflectablePtr<ALLOC> getField(StringView name) override
3118
    {
3119
126
        return m_reflectable->getField(name);
3120
    }
3121
3122
18
    IBasicReflectablePtr<ALLOC> createField(StringView name) override
3123
    {
3124
18
        return m_reflectable->createField(name);
3125
    }
3126
3127
60
    void setField(StringView name, const AnyHolder<ALLOC>& value) override
3128
    {
3129
60
        m_reflectable->setField(name, value);
3130
60
    }
3131
3132
1
    IBasicReflectableConstPtr<ALLOC> getParameter(StringView name) const override
3133
    {
3134
1
        return m_reflectable->getParameter(name);
3135
    }
3136
3137
10
    IBasicReflectablePtr<ALLOC> getParameter(StringView name) override
3138
    {
3139
10
        return m_reflectable->getParameter(name);
3140
    }
3141
3142
1
    IBasicReflectableConstPtr<ALLOC> callFunction(StringView name) const override
3143
    {
3144
1
        return m_reflectable->callFunction(name);
3145
    }
3146
3147
1
    IBasicReflectablePtr<ALLOC> callFunction(StringView name) override
3148
    {
3149
1
        return m_reflectable->callFunction(name);
3150
    }
3151
3152
2
    StringView getChoice() const override
3153
    {
3154
2
        return m_reflectable->getChoice();
3155
    }
3156
3157
1
    IBasicReflectableConstPtr<ALLOC> find(StringView path) const override
3158
    {
3159
1
        return m_reflectable->find(path);
3160
    }
3161
3162
36
    IBasicReflectablePtr<ALLOC> find(StringView path) override
3163
    {
3164
36
        return m_reflectable->find(path);
3165
    }
3166
3167
1
    IBasicReflectableConstPtr<ALLOC> operator[](StringView path) const override
3168
    {
3169
1
        return m_reflectable->operator[](path);
3170
    }
3171
3172
1
    IBasicReflectablePtr<ALLOC> operator[](StringView path) override
3173
    {
3174
1
        return m_reflectable->operator[](path);
3175
    }
3176
3177
1
    size_t size() const override
3178
    {
3179
1
        return m_reflectable->size();
3180
    }
3181
3182
1
    void resize(size_t size) override
3183
    {
3184
1
        m_reflectable->resize(size);
3185
    }
3186
3187
1
    IBasicReflectableConstPtr<ALLOC> at(size_t index) const override
3188
    {
3189
1
        return m_reflectable->at(index);
3190
    }
3191
3192
1
    IBasicReflectablePtr<ALLOC> at(size_t index) override
3193
    {
3194
1
        return m_reflectable->at(index);
3195
    }
3196
3197
1
    IBasicReflectableConstPtr<ALLOC> operator[](size_t index) const override
3198
    {
3199
1
        return m_reflectable->operator[](index);
3200
    }
3201
3202
1
    IBasicReflectablePtr<ALLOC> operator[](size_t index) override
3203
    {
3204
1
        return m_reflectable->operator[](index);
3205
    }
3206
3207
1
    void setAt(const AnyHolder<ALLOC>& value, size_t index) override
3208
    {
3209
1
        m_reflectable->setAt(value, index);
3210
    }
3211
3212
1
    void append(const AnyHolder<ALLOC>& value) override
3213
    {
3214
1
        m_reflectable->append(value);
3215
    }
3216
3217
1
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const override
3218
    {
3219
1
        return m_reflectable->getAnyValue(allocator);
3220
    }
3221
3222
17
    AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) override
3223
    {
3224
17
        return m_reflectable->getAnyValue(allocator);
3225
    }
3226
3227
1
    AnyHolder<ALLOC> getAnyValue() const override
3228
    {
3229
1
        return getAnyValue(ALLOC());
3230
    }
3231
3232
1
    AnyHolder<ALLOC> getAnyValue() override
3233
    {
3234
1
        return getAnyValue(ALLOC());
3235
    }
3236
3237
    // exact checked getters
3238
1
    bool getBool() const override { return m_reflectable->getBool(); }
3239
1
    int8_t getInt8() const override { return m_reflectable->getInt8(); }
3240
1
    int16_t getInt16() const override { return m_reflectable->getInt16(); }
3241
1
    int32_t getInt32() const override { return m_reflectable->getInt32(); }
3242
1
    int64_t getInt64() const override { return m_reflectable->getInt64(); }
3243
1
    uint8_t getUInt8() const override { return m_reflectable->getUInt8(); }
3244
1
    uint16_t getUInt16() const override { return m_reflectable->getUInt16(); }
3245
1
    uint32_t getUInt32() const override { return m_reflectable->getUInt32(); }
3246
1
    uint64_t getUInt64() const override { return m_reflectable->getUInt64(); }
3247
1
    float getFloat() const override { return m_reflectable->getFloat(); }
3248
1
    double getDouble() const override { return m_reflectable->getDouble(); }
3249
1
    Span<const uint8_t> getBytes() const override { return m_reflectable->getBytes(); }
3250
1
    StringView getStringView() const override { return m_reflectable->getStringView(); }
3251
1
    const BasicBitBuffer<ALLOC>& getBitBuffer() const override { return m_reflectable->getBitBuffer(); }
3252
3253
    // convenience conversions
3254
1
    int64_t toInt() const override { return m_reflectable->toInt(); }
3255
1
    uint64_t toUInt() const override { return m_reflectable->toUInt(); }
3256
1
    double toDouble() const override { return m_reflectable->toDouble(); }
3257
1
    string<RebindAlloc<ALLOC, char>> toString(const ALLOC& allocator) const override
3258
    {
3259
1
        return m_reflectable->toString(allocator);
3260
    }
3261
1
    string<RebindAlloc<ALLOC, char>> toString() const override
3262
    {
3263
1
        return toString(ALLOC());
3264
    }
3265
3266
private:
3267
    T m_object;
3268
    IBasicReflectablePtr<ALLOC> m_reflectable;
3269
};
3270
3271
/**
3272
 * Factory used to make it easier to create reflectable instances.
3273
 *
3274
 * Creates reflectables for all builtin types and for arrays.
3275
 */
3276
template <typename ALLOC>
3277
class BasicReflectableFactory
3278
{
3279
public:
3280
13
    static IBasicReflectablePtr<ALLOC> getBool(bool value, const ALLOC& allocator = ALLOC())
3281
    {
3282
13
        return std::allocate_shared<BoolReflectable<ALLOC>>(allocator, value);
3283
    }
3284
3285
16
    static IBasicReflectablePtr<ALLOC> getInt8(int8_t value, const ALLOC& allocator = ALLOC())
3286
    {
3287
16
        return std::allocate_shared<Int8Reflectable<ALLOC>>(allocator, value);
3288
    }
3289
3290
12
    static IBasicReflectablePtr<ALLOC> getInt16(int16_t value, const ALLOC& allocator = ALLOC())
3291
    {
3292
12
        return std::allocate_shared<Int16Reflectable<ALLOC>>(allocator, value);
3293
    }
3294
3295
15
    static IBasicReflectablePtr<ALLOC> getInt32(int32_t value, const ALLOC& allocator = ALLOC())
3296
    {
3297
15
        return std::allocate_shared<Int32Reflectable<ALLOC>>(allocator, value);
3298
    }
3299
3300
11
    static IBasicReflectablePtr<ALLOC> getInt64(int64_t value, const ALLOC& allocator = ALLOC())
3301
    {
3302
11
        return std::allocate_shared<Int64Reflectable<ALLOC>>(allocator, value);
3303
    }
3304
3305
35
    static IBasicReflectablePtr<ALLOC> getUInt8(uint8_t value, const ALLOC& allocator = ALLOC())
3306
    {
3307
35
        return std::allocate_shared<UInt8Reflectable<ALLOC>>(allocator, value);
3308
    }
3309
3310
11
    static IBasicReflectablePtr<ALLOC> getUInt16(uint16_t value, const ALLOC& allocator = ALLOC())
3311
    {
3312
11
        return std::allocate_shared<UInt16Reflectable<ALLOC>>(allocator, value);
3313
    }
3314
3315
54
    static IBasicReflectablePtr<ALLOC> getUInt32(uint32_t value, const ALLOC& allocator = ALLOC())
3316
    {
3317
54
        return std::allocate_shared<UInt32Reflectable<ALLOC>>(allocator, value);
3318
    }
3319
3320
12
    static IBasicReflectablePtr<ALLOC> getUInt64(uint64_t value, const ALLOC& allocator = ALLOC())
3321
    {
3322
12
        return std::allocate_shared<UInt64Reflectable<ALLOC>>(allocator, value);
3323
    }
3324
3325
    template <typename T, typename std::enable_if<std::is_signed<T>::value, int>::type = 0>
3326
45
    static IBasicReflectablePtr<ALLOC> getFixedSignedBitField(
3327
            T value, uint8_t bitSize, const ALLOC& allocator = ALLOC())
3328
    {
3329
45
        return std::allocate_shared<FixedSignedBitFieldReflectable<ALLOC, T>>(allocator, value, bitSize);
3330
    }
3331
3332
    template <typename T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
3333
82
    static IBasicReflectablePtr<ALLOC> getFixedUnsignedBitField(
3334
            T value, uint8_t bitSize, const ALLOC& allocator = ALLOC())
3335
    {
3336
82
        return std::allocate_shared<FixedUnsignedBitFieldReflectable<ALLOC, T>>(allocator, value, bitSize);
3337
    }
3338
3339
    template <typename T, typename std::enable_if<std::is_signed<T>::value, int>::type = 0>
3340
16
    static IBasicReflectablePtr<ALLOC> getDynamicSignedBitField(
3341
            T value, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC())
3342
    {
3343
        return std::allocate_shared<DynamicSignedBitFieldReflectable<ALLOC, T>>(
3344
16
                allocator, value, maxBitSize, dynamicBitSize);
3345
    }
3346
3347
    // for dynamic signed bit field given by a type reference (e.g. parameter, function return type)
3348
2
    static IBasicReflectablePtr<ALLOC> getDynamicSignedBitField(
3349
            int64_t value, uint8_t maxBitSize, const ALLOC& allocator = ALLOC())
3350
    {
3351
2
        if (maxBitSize != 64)
3352
        {
3353

2
            throw CppRuntimeException("ReflectableFactory::getDynamicSignedBitField - ") <<
3354
2
                    "maxBitSize != 64 for referenced dynamic bit field!";
3355
        }
3356
3357
1
        return getDynamicSignedBitField(value, maxBitSize, maxBitSize, allocator);
3358
    }
3359
3360
    template <typename T, typename std::enable_if<std::is_unsigned<T>::value, int>::type = 0>
3361
16
    static IBasicReflectablePtr<ALLOC> getDynamicUnsignedBitField(
3362
            T value, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC())
3363
    {
3364
        return std::allocate_shared<DynamicUnsignedBitFieldReflectable<ALLOC, T>>(
3365
16
                allocator, value, maxBitSize, dynamicBitSize);
3366
    }
3367
3368
    // for dynamic unsigned bit field given a by type reference (e.g. parameter, function return type)
3369
2
    static IBasicReflectablePtr<ALLOC> getDynamicUnsignedBitField(
3370
            uint64_t value, uint8_t maxBitSize, const ALLOC& allocator = ALLOC())
3371
    {
3372
2
        if (maxBitSize != 64)
3373
        {
3374

2
            throw CppRuntimeException("ReflectableFactory::getDynamicUnsignedBitField - ") <<
3375
2
                    "maxBitSize != 64 for referenced dynamic bit field!";
3376
        }
3377
3378
1
        return getDynamicUnsignedBitField(value, maxBitSize, maxBitSize, allocator);
3379
    }
3380
3381
2
    static IBasicReflectablePtr<ALLOC> getVarInt16(
3382
            int16_t value, const ALLOC& allocator = ALLOC())
3383
    {
3384
2
        return std::allocate_shared<VarInt16Reflectable<ALLOC>>(allocator, value);
3385
    }
3386
3387
2
    static IBasicReflectablePtr<ALLOC> getVarInt32(
3388
            int32_t value, const ALLOC& allocator = ALLOC())
3389
    {
3390
2
        return std::allocate_shared<VarInt32Reflectable<ALLOC>>(allocator, value);
3391
    }
3392
3393
2
    static IBasicReflectablePtr<ALLOC> getVarInt64(
3394
            int64_t value, const ALLOC& allocator = ALLOC())
3395
    {
3396
2
        return std::allocate_shared<VarInt64Reflectable<ALLOC>>(allocator, value);
3397
    }
3398
3399
3
    static IBasicReflectablePtr<ALLOC> getVarInt(int64_t value, const ALLOC& allocator = ALLOC())
3400
    {
3401
3
        return std::allocate_shared<VarIntReflectable<ALLOC>>(allocator, value);
3402
    }
3403
3404
2
    static IBasicReflectablePtr<ALLOC> getVarUInt16(
3405
            uint16_t value, const ALLOC& allocator = ALLOC())
3406
    {
3407
2
        return std::allocate_shared<VarUInt16Reflectable<ALLOC>>(allocator, value);
3408
    }
3409
3410
2
    static IBasicReflectablePtr<ALLOC> getVarUInt32(
3411
            uint32_t value, const ALLOC& allocator = ALLOC())
3412
    {
3413
2
        return std::allocate_shared<VarUInt32Reflectable<ALLOC>>(allocator, value);
3414
    }
3415
3416
2
    static IBasicReflectablePtr<ALLOC> getVarUInt64(
3417
            uint64_t value, const ALLOC& allocator = ALLOC())
3418
    {
3419
2
        return std::allocate_shared<VarUInt64Reflectable<ALLOC>>(allocator, value);
3420
    }
3421
3422
2
    static IBasicReflectablePtr<ALLOC> getVarUInt(
3423
            uint64_t value, const ALLOC& allocator = ALLOC())
3424
    {
3425
2
        return std::allocate_shared<VarUIntReflectable<ALLOC>>(allocator, value);
3426
    }
3427
3428
3
    static IBasicReflectablePtr<ALLOC> getVarSize(
3429
            uint32_t value, const ALLOC& allocator = ALLOC())
3430
    {
3431
3
        return std::allocate_shared<VarSizeReflectable<ALLOC>>(allocator, value);
3432
    }
3433
3434
7
    static IBasicReflectablePtr<ALLOC> getFloat16(float value, const ALLOC& allocator = ALLOC())
3435
    {
3436
7
        return std::allocate_shared<Float16Reflectable<ALLOC>>(allocator, value);
3437
    }
3438
3439
9
    static IBasicReflectablePtr<ALLOC> getFloat32(float value, const ALLOC& allocator = ALLOC())
3440
    {
3441
9
        return std::allocate_shared<Float32Reflectable<ALLOC>>(allocator, value);
3442
    }
3443
3444
37
    static IBasicReflectablePtr<ALLOC> getFloat64(double value, const ALLOC& allocator = ALLOC())
3445
    {
3446
37
        return std::allocate_shared<Float64Reflectable<ALLOC>>(allocator, value);
3447
    }
3448
3449
18
    static IBasicReflectablePtr<ALLOC> getBytes(Span<const uint8_t> value, const ALLOC& allocator = ALLOC())
3450
    {
3451
18
        return std::allocate_shared<BytesReflectable<ALLOC>>(allocator, value);
3452
    }
3453
3454
132
    static IBasicReflectablePtr<ALLOC> getString(StringView value, const ALLOC& allocator = ALLOC())
3455
    {
3456
132
        return std::allocate_shared<StringReflectable<ALLOC>>(allocator, value);
3457
    }
3458
3459
18
    static IBasicReflectablePtr<ALLOC> getBitBuffer(
3460
            const BasicBitBuffer<ALLOC>& value, const ALLOC& allocator = ALLOC())
3461
    {
3462
18
        return std::allocate_shared<BitBufferReflectable<ALLOC>>(allocator, value);
3463
    }
3464
3465
    template <typename RAW_ARRAY>
3466
1
    static IBasicReflectableConstPtr<ALLOC> getBoolArray(
3467
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3468
    {
3469
        return std::allocate_shared<BoolReflectableConstArray<ALLOC, RAW_ARRAY>>(
3470
1
                allocator, allocator, rawArray);
3471
    }
3472
3473
    template <typename RAW_ARRAY>
3474
1
    static IBasicReflectablePtr<ALLOC> getBoolArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3475
    {
3476
        return std::allocate_shared<BoolReflectableArray<ALLOC, RAW_ARRAY>>(
3477
1
                allocator, allocator, rawArray);
3478
    }
3479
3480
    template <typename RAW_ARRAY>
3481
1
    static IBasicReflectableConstPtr<ALLOC> getInt8Array(
3482
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3483
    {
3484
        return std::allocate_shared<Int8ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3485
1
                allocator, allocator, rawArray);
3486
    }
3487
3488
    template <typename RAW_ARRAY>
3489
1
    static IBasicReflectablePtr<ALLOC> getInt8Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3490
    {
3491
        return std::allocate_shared<Int8ReflectableArray<ALLOC, RAW_ARRAY>>(
3492
1
                allocator, allocator, rawArray);
3493
    }
3494
3495
    template <typename RAW_ARRAY>
3496
1
    static IBasicReflectableConstPtr<ALLOC> getInt16Array(
3497
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3498
    {
3499
        return std::allocate_shared<Int16ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3500
1
                allocator, allocator, rawArray);
3501
    }
3502
3503
    template <typename RAW_ARRAY>
3504
1
    static IBasicReflectablePtr<ALLOC> getInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3505
    {
3506
        return std::allocate_shared<Int16ReflectableArray<ALLOC, RAW_ARRAY>>(
3507
1
                allocator, allocator, rawArray);
3508
    }
3509
3510
    template <typename RAW_ARRAY>
3511
1
    static IBasicReflectableConstPtr<ALLOC> getInt32Array(
3512
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3513
    {
3514
        return std::allocate_shared<Int32ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3515
1
                allocator, allocator, rawArray);
3516
    }
3517
3518
    template <typename RAW_ARRAY>
3519
1
    static IBasicReflectablePtr<ALLOC> getInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3520
    {
3521
        return std::allocate_shared<Int32ReflectableArray<ALLOC, RAW_ARRAY>>(
3522
1
                allocator, allocator, rawArray);
3523
    }
3524
3525
    template <typename RAW_ARRAY>
3526
1
    static IBasicReflectableConstPtr<ALLOC> getInt64Array(
3527
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3528
    {
3529
        return std::allocate_shared<Int64ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3530
1
                allocator, allocator, rawArray);
3531
    }
3532
3533
    template <typename RAW_ARRAY>
3534
1
    static IBasicReflectablePtr<ALLOC> getInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3535
    {
3536
        return std::allocate_shared<Int64ReflectableArray<ALLOC, RAW_ARRAY>>(
3537
1
                allocator, allocator, rawArray);
3538
    }
3539
3540
    template <typename RAW_ARRAY>
3541
2
    static IBasicReflectableConstPtr<ALLOC> getUInt8Array(
3542
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3543
    {
3544
        return std::allocate_shared<UInt8ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3545
2
                allocator, allocator, rawArray);
3546
    }
3547
3548
    template <typename RAW_ARRAY>
3549
2
    static IBasicReflectablePtr<ALLOC> getUInt8Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3550
    {
3551
        return std::allocate_shared<UInt8ReflectableArray<ALLOC, RAW_ARRAY>>(
3552
2
                allocator, allocator, rawArray);
3553
    }
3554
3555
    template <typename RAW_ARRAY>
3556
1
    static IBasicReflectableConstPtr<ALLOC> getUInt16Array(
3557
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3558
    {
3559
        return std::allocate_shared<UInt16ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3560
1
                allocator, allocator, rawArray);
3561
    }
3562
3563
    template <typename RAW_ARRAY>
3564
1
    static IBasicReflectablePtr<ALLOC> getUInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3565
    {
3566
        return std::allocate_shared<UInt16ReflectableArray<ALLOC, RAW_ARRAY>>(
3567
1
                allocator, allocator, rawArray);
3568
    }
3569
3570
    template <typename RAW_ARRAY>
3571
1
    static IBasicReflectableConstPtr<ALLOC> getUInt32Array(
3572
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3573
    {
3574
        return std::allocate_shared<UInt32ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3575
1
                allocator, allocator, rawArray);
3576
    }
3577
3578
    template <typename RAW_ARRAY>
3579
10
    static IBasicReflectablePtr<ALLOC> getUInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3580
    {
3581
        return std::allocate_shared<UInt32ReflectableArray<ALLOC, RAW_ARRAY>>(
3582
10
                allocator, allocator, rawArray);
3583
    }
3584
3585
    template <typename RAW_ARRAY>
3586
1
    static IBasicReflectableConstPtr<ALLOC> getUInt64Array(
3587
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3588
    {
3589
        return std::allocate_shared<UInt64ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3590
1
                allocator, allocator, rawArray);
3591
    }
3592
3593
    template <typename RAW_ARRAY>
3594
1
    static IBasicReflectablePtr<ALLOC> getUInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3595
    {
3596
        return std::allocate_shared<UInt64ReflectableArray<ALLOC, RAW_ARRAY>>(
3597
1
                allocator, allocator, rawArray);
3598
    }
3599
3600
    template <typename RAW_ARRAY>
3601
1
    static IBasicReflectableConstPtr<ALLOC> getFixedSignedBitFieldArray(
3602
            const RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC())
3603
    {
3604
        return std::allocate_shared<FixedSignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>(
3605
1
                allocator, allocator, rawArray, bitSize);
3606
    }
3607
3608
    template <typename RAW_ARRAY>
3609
1
    static IBasicReflectablePtr<ALLOC> getFixedSignedBitFieldArray(
3610
                RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC())
3611
    {
3612
        return std::allocate_shared<FixedSignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>(
3613
1
                allocator, allocator, rawArray, bitSize);
3614
    }
3615
3616
    template <typename RAW_ARRAY>
3617
1
    static IBasicReflectableConstPtr<ALLOC> getFixedUnsignedBitFieldArray(
3618
            const RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC())
3619
    {
3620
        return std::allocate_shared<FixedUnsignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>(
3621
1
                allocator, allocator, rawArray, bitSize);
3622
    }
3623
3624
    template <typename RAW_ARRAY>
3625
1
    static IBasicReflectablePtr<ALLOC> getFixedUnsignedBitFieldArray(
3626
            RAW_ARRAY& rawArray, uint8_t bitSize, const ALLOC& allocator = ALLOC())
3627
    {
3628
        return std::allocate_shared<FixedUnsignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>(
3629
1
                allocator, allocator, rawArray, bitSize);
3630
    }
3631
3632
    template <typename RAW_ARRAY>
3633
1
    static IBasicReflectableConstPtr<ALLOC> getDynamicSignedBitFieldArray(
3634
            const RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize,
3635
            const ALLOC& allocator = ALLOC())
3636
    {
3637
        return std::allocate_shared<DynamicSignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>(
3638
1
                allocator, allocator, rawArray, maxBitSize, dynamicBitSize);
3639
    }
3640
3641
    template <typename RAW_ARRAY>
3642
1
    static IBasicReflectablePtr<ALLOC> getDynamicSignedBitFieldArray(
3643
            RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC())
3644
    {
3645
        return std::allocate_shared<DynamicSignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>(
3646
1
                allocator, allocator, rawArray, maxBitSize, dynamicBitSize);
3647
    }
3648
3649
    template <typename RAW_ARRAY>
3650
1
    static IBasicReflectableConstPtr<ALLOC> getDynamicUnsignedBitFieldArray(
3651
            const RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize,
3652
            const ALLOC& allocator = ALLOC())
3653
    {
3654
        return std::allocate_shared<DynamicUnsignedBitFieldReflectableConstArray<ALLOC, RAW_ARRAY>>(
3655
1
                allocator, allocator, rawArray, maxBitSize, dynamicBitSize);
3656
    }
3657
3658
    template <typename RAW_ARRAY>
3659
1
    static IBasicReflectablePtr<ALLOC> getDynamicUnsignedBitFieldArray(
3660
            RAW_ARRAY& rawArray, uint8_t maxBitSize, uint8_t dynamicBitSize, const ALLOC& allocator = ALLOC())
3661
    {
3662
        return std::allocate_shared<DynamicUnsignedBitFieldReflectableArray<ALLOC, RAW_ARRAY>>(
3663
1
                allocator, allocator, rawArray, maxBitSize, dynamicBitSize);
3664
    }
3665
3666
    template <typename RAW_ARRAY>
3667
1
    static IBasicReflectableConstPtr<ALLOC> getVarInt16Array(
3668
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3669
    {
3670
        return std::allocate_shared<VarInt16ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3671
1
                allocator, allocator, rawArray);
3672
    }
3673
3674
    template <typename RAW_ARRAY>
3675
1
    static IBasicReflectablePtr<ALLOC> getVarInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3676
    {
3677
        return std::allocate_shared<VarInt16ReflectableArray<ALLOC, RAW_ARRAY>>(
3678
1
                allocator, allocator, rawArray);
3679
    }
3680
3681
    template <typename RAW_ARRAY>
3682
1
    static IBasicReflectableConstPtr<ALLOC> getVarInt32Array(
3683
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3684
    {
3685
        return std::allocate_shared<VarInt32ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3686
1
                allocator, allocator, rawArray);
3687
    }
3688
3689
    template <typename RAW_ARRAY>
3690
1
    static IBasicReflectablePtr<ALLOC> getVarInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3691
    {
3692
        return std::allocate_shared<VarInt32ReflectableArray<ALLOC, RAW_ARRAY>>(
3693
1
                allocator, allocator, rawArray);
3694
    }
3695
3696
    template <typename RAW_ARRAY>
3697
1
    static IBasicReflectableConstPtr<ALLOC> getVarInt64Array(
3698
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3699
    {
3700
        return std::allocate_shared<VarInt64ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3701
1
                allocator, allocator, rawArray);
3702
    }
3703
3704
    template <typename RAW_ARRAY>
3705
1
    static IBasicReflectablePtr<ALLOC> getVarInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3706
    {
3707
        return std::allocate_shared<VarInt64ReflectableArray<ALLOC, RAW_ARRAY>>(
3708
1
                allocator, allocator, rawArray);
3709
    }
3710
3711
    template <typename RAW_ARRAY>
3712
1
    static IBasicReflectableConstPtr<ALLOC> getVarIntArray(
3713
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3714
    {
3715
        return std::allocate_shared<VarIntReflectableConstArray<ALLOC, RAW_ARRAY>>(
3716
1
                allocator, allocator, rawArray);
3717
    }
3718
3719
    template <typename RAW_ARRAY>
3720
1
    static IBasicReflectablePtr<ALLOC> getVarIntArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3721
    {
3722
        return std::allocate_shared<VarIntReflectableArray<ALLOC, RAW_ARRAY>>(
3723
1
                allocator, allocator, rawArray);
3724
    }
3725
3726
    template <typename RAW_ARRAY>
3727
1
    static IBasicReflectableConstPtr<ALLOC> getVarUInt16Array(
3728
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3729
    {
3730
        return std::allocate_shared<VarUInt16ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3731
1
                allocator, allocator, rawArray);
3732
    }
3733
3734
    template <typename RAW_ARRAY>
3735
1
    static IBasicReflectablePtr<ALLOC> getVarUInt16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3736
    {
3737
        return std::allocate_shared<VarUInt16ReflectableArray<ALLOC, RAW_ARRAY>>(
3738
1
                allocator, allocator, rawArray);
3739
    }
3740
3741
    template <typename RAW_ARRAY>
3742
1
    static IBasicReflectableConstPtr<ALLOC> getVarUInt32Array(
3743
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3744
    {
3745
        return std::allocate_shared<VarUInt32ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3746
1
                allocator, allocator, rawArray);
3747
    }
3748
3749
    template <typename RAW_ARRAY>
3750
1
    static IBasicReflectablePtr<ALLOC> getVarUInt32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3751
    {
3752
        return std::allocate_shared<VarUInt32ReflectableArray<ALLOC, RAW_ARRAY>>(
3753
1
                allocator, allocator, rawArray);
3754
    }
3755
3756
    template <typename RAW_ARRAY>
3757
1
    static IBasicReflectableConstPtr<ALLOC> getVarUInt64Array(
3758
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3759
    {
3760
        return std::allocate_shared<VarUInt64ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3761
1
                allocator, allocator, rawArray);
3762
    }
3763
3764
    template <typename RAW_ARRAY>
3765
1
    static IBasicReflectablePtr<ALLOC> getVarUInt64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3766
    {
3767
        return std::allocate_shared<VarUInt64ReflectableArray<ALLOC, RAW_ARRAY>>(
3768
1
                allocator, allocator, rawArray);
3769
    }
3770
3771
    template <typename RAW_ARRAY>
3772
1
    static IBasicReflectableConstPtr<ALLOC> getVarUIntArray(
3773
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3774
    {
3775
        return std::allocate_shared<VarUIntReflectableConstArray<ALLOC, RAW_ARRAY>>(
3776
1
                allocator, allocator, rawArray);
3777
    }
3778
3779
    template <typename RAW_ARRAY>
3780
1
    static IBasicReflectablePtr<ALLOC> getVarUIntArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3781
    {
3782
        return std::allocate_shared<VarUIntReflectableArray<ALLOC, RAW_ARRAY>>(
3783
1
                allocator, allocator, rawArray);
3784
    }
3785
3786
    template <typename RAW_ARRAY>
3787
1
    static IBasicReflectableConstPtr<ALLOC> getVarSizeArray(
3788
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3789
    {
3790
        return std::allocate_shared<VarSizeReflectableConstArray<ALLOC, RAW_ARRAY>>(
3791
1
                allocator, allocator, rawArray);
3792
    }
3793
3794
    template <typename RAW_ARRAY>
3795
1
    static IBasicReflectablePtr<ALLOC> getVarSizeArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3796
    {
3797
        return std::allocate_shared<VarSizeReflectableArray<ALLOC, RAW_ARRAY>>(
3798
1
                allocator, allocator, rawArray);
3799
    }
3800
3801
    template <typename RAW_ARRAY>
3802
1
    static IBasicReflectableConstPtr<ALLOC> getFloat16Array(
3803
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3804
    {
3805
        return std::allocate_shared<Float16ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3806
1
                allocator, allocator, rawArray);
3807
    }
3808
3809
    template <typename RAW_ARRAY>
3810
1
    static IBasicReflectablePtr<ALLOC> getFloat16Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3811
    {
3812
        return std::allocate_shared<Float16ReflectableArray<ALLOC, RAW_ARRAY>>(
3813
1
                allocator, allocator, rawArray);
3814
    }
3815
3816
    template <typename RAW_ARRAY>
3817
1
    static IBasicReflectableConstPtr<ALLOC> getFloat32Array(
3818
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3819
    {
3820
        return std::allocate_shared<Float32ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3821
1
                allocator, allocator, rawArray);
3822
    }
3823
3824
    template <typename RAW_ARRAY>
3825
1
    static IBasicReflectablePtr<ALLOC> getFloat32Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3826
    {
3827
        return std::allocate_shared<Float32ReflectableArray<ALLOC, RAW_ARRAY>>(
3828
1
                allocator, allocator, rawArray);
3829
    }
3830
3831
    template <typename RAW_ARRAY>
3832
1
    static IBasicReflectableConstPtr<ALLOC> getFloat64Array(
3833
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3834
    {
3835
        return std::allocate_shared<Float64ReflectableConstArray<ALLOC, RAW_ARRAY>>(
3836
1
                allocator, allocator, rawArray);
3837
    }
3838
3839
    template <typename RAW_ARRAY>
3840
1
    static IBasicReflectablePtr<ALLOC> getFloat64Array(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3841
    {
3842
        return std::allocate_shared<Float64ReflectableArray<ALLOC, RAW_ARRAY>>(
3843
1
                allocator, allocator, rawArray);
3844
    }
3845
3846
    template <typename RAW_ARRAY>
3847
1
    static IBasicReflectableConstPtr<ALLOC> getBytesArray(
3848
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3849
    {
3850
        return std::allocate_shared<BytesReflectableConstArray<ALLOC, RAW_ARRAY>>(
3851
1
                allocator, allocator, rawArray);
3852
    }
3853
3854
    template <typename RAW_ARRAY>
3855
12
    static IBasicReflectablePtr<ALLOC> getBytesArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3856
    {
3857
        return std::allocate_shared<BytesReflectableArray<ALLOC, RAW_ARRAY>>(
3858
12
                allocator, allocator, rawArray);
3859
    }
3860
3861
    template <typename RAW_ARRAY>
3862
1
    static IBasicReflectableConstPtr<ALLOC> getStringArray(
3863
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3864
    {
3865
        return std::allocate_shared<StringReflectableConstArray<ALLOC, RAW_ARRAY>>(
3866
1
                allocator, allocator, rawArray);
3867
    }
3868
3869
    template <typename RAW_ARRAY>
3870
20
    static IBasicReflectablePtr<ALLOC> getStringArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3871
    {
3872
        return std::allocate_shared<StringReflectableArray<ALLOC, RAW_ARRAY>>(
3873
20
                allocator, allocator, rawArray);
3874
    }
3875
3876
    template <typename RAW_ARRAY>
3877
1
    static IBasicReflectableConstPtr<ALLOC> getBitBufferArray(
3878
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3879
    {
3880
        return std::allocate_shared<BitBufferReflectableConstArray<ALLOC, RAW_ARRAY>>(
3881
1
                allocator, allocator, rawArray);
3882
    }
3883
3884
    template <typename RAW_ARRAY>
3885
11
    static IBasicReflectablePtr<ALLOC> getBitBufferArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3886
    {
3887
        return std::allocate_shared<BitBufferReflectableArray<ALLOC, RAW_ARRAY>>(
3888
11
                allocator, allocator, rawArray);
3889
    }
3890
3891
    template <typename RAW_ARRAY>
3892
1
    static IBasicReflectableConstPtr<ALLOC> getCompoundArray(
3893
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3894
    {
3895
        return std::allocate_shared<CompoundReflectableConstArray<ALLOC, RAW_ARRAY>>(
3896
1
                allocator, allocator, rawArray);
3897
    }
3898
3899
    template <typename RAW_ARRAY>
3900
41
    static IBasicReflectablePtr<ALLOC> getCompoundArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3901
    {
3902
41
        return std::allocate_shared<CompoundReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray);
3903
    }
3904
3905
    template <typename RAW_ARRAY>
3906
1
    static IBasicReflectableConstPtr<ALLOC> getBitmaskArray(
3907
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3908
    {
3909
        return std::allocate_shared<BitmaskReflectableConstArray<ALLOC, RAW_ARRAY>>(
3910
1
                allocator, allocator, rawArray);
3911
    }
3912
3913
    template <typename RAW_ARRAY>
3914
1
    static IBasicReflectablePtr<ALLOC> getBitmaskArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3915
    {
3916
1
        return std::allocate_shared<BitmaskReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray);
3917
    }
3918
3919
    template <typename RAW_ARRAY>
3920
1
    static IBasicReflectableConstPtr<ALLOC> getEnumArray(
3921
            const RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3922
    {
3923
        return std::allocate_shared<EnumReflectableConstArray<ALLOC, RAW_ARRAY>>(
3924
1
                allocator, allocator, rawArray);
3925
    }
3926
3927
    template <typename RAW_ARRAY>
3928
1
    static IBasicReflectablePtr<ALLOC> getEnumArray(RAW_ARRAY& rawArray, const ALLOC& allocator = ALLOC())
3929
    {
3930
1
        return std::allocate_shared<EnumReflectableArray<ALLOC, RAW_ARRAY>>(allocator, allocator, rawArray);
3931
    }
3932
};
3933
3934
/** Typedef to the reflectable factory provided for convenience - using default std::allocator<uint8_t>. */
3935
using ReflectableFactory = BasicReflectableFactory<std::allocator<uint8_t>>;
3936
3937
template <typename ALLOC>
3938
1646
ReflectableBase<ALLOC>::ReflectableBase(const IBasicTypeInfo<ALLOC>& typeInfo) :
3939
1646
        m_typeInfo(typeInfo)
3940
1646
{}
3941
3942
template <typename ALLOC>
3943
ReflectableBase<ALLOC>::~ReflectableBase() = default;
3944
3945
template <typename ALLOC>
3946
13283
const IBasicTypeInfo<ALLOC>& ReflectableBase<ALLOC>::getTypeInfo() const
3947
{
3948
13283
    return m_typeInfo;
3949
}
3950
3951
template <typename ALLOC>
3952
558
bool ReflectableBase<ALLOC>::isArray() const
3953
{
3954
558
    return false;
3955
}
3956
3957
template <typename ALLOC>
3958
122
void ReflectableBase<ALLOC>::initializeChildren()
3959
{
3960


122
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not a compound type!";
3961
}
3962
3963
template <typename ALLOC>
3964
123
void ReflectableBase<ALLOC>::initialize(const vector<AnyHolder<ALLOC>, ALLOC>&)
3965
{
3966


123
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no type arguments!";
3967
}
3968
3969
template <typename ALLOC>
3970
122
size_t ReflectableBase<ALLOC>::initializeOffsets(size_t)
3971
{
3972


122
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not a compound type!";
3973
}
3974
3975
template <typename ALLOC>
3976
153
size_t ReflectableBase<ALLOC>::initializeOffsets()
3977
{
3978
153
    return initializeOffsets(0);
3979
}
3980
3981
template <typename ALLOC>
3982
1
size_t ReflectableBase<ALLOC>::bitSizeOf(size_t) const
3983
{
3984


1
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!";
3985
}
3986
3987
template <typename ALLOC>
3988
308
size_t ReflectableBase<ALLOC>::bitSizeOf() const
3989
{
3990
308
    return bitSizeOf(0);
3991
}
3992
3993
template <typename ALLOC>
3994
1
void ReflectableBase<ALLOC>::write(BitStreamWriter&) const
3995
{
3996


1
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!";
3997
}
3998
3999
template <typename ALLOC>
4000
175
IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::getField(StringView) const
4001
{
4002


175
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to get!";
4003
}
4004
4005
template <typename ALLOC>
4006
122
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::getField(StringView)
4007
{
4008


122
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to get!";
4009
}
4010
4011
template <typename ALLOC>
4012
122
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::createField(StringView)
4013
{
4014


122
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to create!";
4015
}
4016
4017
template <typename ALLOC>
4018
122
void ReflectableBase<ALLOC>::setField(StringView, const AnyHolder<ALLOC>&)
4019
{
4020


122
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no fields to set!";
4021
}
4022
4023
template <typename ALLOC>
4024
175
IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::getParameter(StringView) const
4025
{
4026


175
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no parameters to get!";
4027
}
4028
4029
template <typename ALLOC>
4030
124
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::getParameter(StringView)
4031
{
4032


124
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no parameters to get!";
4033
}
4034
4035
template <typename ALLOC>
4036
175
IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::callFunction(StringView) const
4037
{
4038


175
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no functions to call!";
4039
}
4040
4041
template <typename ALLOC>
4042
124
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::callFunction(StringView)
4043
{
4044


124
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' has no functions to call!";
4045
}
4046
4047
template <typename ALLOC>
4048
299
StringView ReflectableBase<ALLOC>::getChoice() const
4049
{
4050


299
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is neither choice nor union!";
4051
}
4052
4053
template <typename ALLOC>
4054
520
IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::find(StringView path) const
4055
{
4056
520
    return detail::getFromObject(*this, path, 0);
4057
}
4058
4059
template <typename ALLOC>
4060
387
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::find(StringView path)
4061
{
4062
387
    return detail::getFromObject(*this, path, 0);
4063
}
4064
4065
template <typename ALLOC>
4066
247
IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::operator[](StringView path) const
4067
{
4068
247
    return find(path);
4069
}
4070
4071
template <typename ALLOC>
4072
167
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::operator[](StringView path)
4073
{
4074
167
    return find(path);
4075
}
4076
4077
template <typename ALLOC>
4078
309
size_t ReflectableBase<ALLOC>::size() const
4079
{
4080


309
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4081
}
4082
4083
template <typename ALLOC>
4084
126
void ReflectableBase<ALLOC>::resize(size_t)
4085
{
4086


126
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4087
}
4088
4089
template <typename ALLOC>
4090
308
IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::at(size_t) const
4091
{
4092


308
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4093
}
4094
4095
template <typename ALLOC>
4096
127
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::at(size_t)
4097
{
4098


127
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4099
}
4100
4101
template <typename ALLOC>
4102
308
IBasicReflectableConstPtr<ALLOC> ReflectableBase<ALLOC>::operator[](size_t) const
4103
{
4104


308
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4105
}
4106
4107
template <typename ALLOC>
4108
127
IBasicReflectablePtr<ALLOC> ReflectableBase<ALLOC>::operator[](size_t)
4109
{
4110


127
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4111
}
4112
4113
template <typename ALLOC>
4114
126
void ReflectableBase<ALLOC>::setAt(const AnyHolder<ALLOC>&, size_t)
4115
{
4116


126
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4117
}
4118
4119
template <typename ALLOC>
4120
1
void ReflectableBase<ALLOC>::append(const AnyHolder<ALLOC>&)
4121
{
4122


1
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not an array!";
4123
}
4124
4125
template <typename ALLOC>
4126
1
AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue(const ALLOC&) const
4127
{
4128


1
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!";
4129
}
4130
4131
template <typename ALLOC>
4132
1
AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue(const ALLOC&)
4133
{
4134


1
    throw CppRuntimeException("Type '") << getTypeInfo().getSchemaName() << "' is not implemented!";
4135
}
4136
4137
template <typename ALLOC>
4138
225
AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue() const
4139
{
4140
225
    return getAnyValue(ALLOC());
4141
}
4142
4143
template <typename ALLOC>
4144
159
AnyHolder<ALLOC> ReflectableBase<ALLOC>::getAnyValue()
4145
{
4146
159
    return getAnyValue(ALLOC());
4147
}
4148
4149
template <typename ALLOC>
4150
300
bool ReflectableBase<ALLOC>::getBool() const
4151
{
4152


300
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not boolean type!";
4153
}
4154
4155
template <typename ALLOC>
4156
254
int8_t ReflectableBase<ALLOC>::getInt8() const
4157
{
4158


254
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int8 type!";
4159
}
4160
4161
template <typename ALLOC>
4162
289
int16_t ReflectableBase<ALLOC>::getInt16() const
4163
{
4164


289
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int16 type!";
4165
}
4166
4167
template <typename ALLOC>
4168
289
int32_t ReflectableBase<ALLOC>::getInt32() const
4169
{
4170


289
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int32 type!";
4171
}
4172
4173
template <typename ALLOC>
4174
280
int64_t ReflectableBase<ALLOC>::getInt64() const
4175
{
4176


280
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not int64 type!";
4177
}
4178
4179
template <typename ALLOC>
4180
267
uint8_t ReflectableBase<ALLOC>::getUInt8() const
4181
{
4182


267
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint8 type!";
4183
}
4184
4185
template <typename ALLOC>
4186
289
uint16_t ReflectableBase<ALLOC>::getUInt16() const
4187
{
4188


289
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint16 type!";
4189
}
4190
4191
template <typename ALLOC>
4192
280
uint32_t ReflectableBase<ALLOC>::getUInt32() const
4193
{
4194


280
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint32 type!";
4195
}
4196
4197
template <typename ALLOC>
4198
280
uint64_t ReflectableBase<ALLOC>::getUInt64() const
4199
{
4200


280
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not uint64 type!";
4201
}
4202
4203
template <typename ALLOC>
4204
297
float ReflectableBase<ALLOC>::getFloat() const
4205
{
4206


297
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not float type!";
4207
}
4208
4209
template <typename ALLOC>
4210
302
double ReflectableBase<ALLOC>::getDouble() const
4211
{
4212


302
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not double type!";
4213
}
4214
4215
template <typename ALLOC>
4216
302
Span<const uint8_t> ReflectableBase<ALLOC>::getBytes() const
4217
{
4218


302
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not bytes type!";
4219
}
4220
4221
template <typename ALLOC>
4222
298
StringView ReflectableBase<ALLOC>::getStringView() const
4223
{
4224


298
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not string type!";
4225
}
4226
4227
template <typename ALLOC>
4228
302
const BasicBitBuffer<ALLOC>& ReflectableBase<ALLOC>::getBitBuffer() const
4229
{
4230


302
    throw CppRuntimeException("'") << getTypeInfo().getSchemaName() << "' is not an extern type!";
4231
}
4232
4233
template <typename ALLOC>
4234
185
int64_t ReflectableBase<ALLOC>::toInt() const
4235
{
4236


370
    throw CppRuntimeException("Conversion from '") << getTypeInfo().getSchemaName() <<
4237
370
            "' to signed integer is not available!";
4238
}
4239
4240
template <typename ALLOC>
4241
180
uint64_t ReflectableBase<ALLOC>::toUInt() const
4242
{
4243


360
    throw CppRuntimeException("Conversion from '") << getTypeInfo().getSchemaName() <<
4244
360
            "' to unsigned integer is not available!";
4245
}
4246
4247
template <typename ALLOC>
4248
37
double ReflectableBase<ALLOC>::toDouble() const
4249
{
4250


74
    throw CppRuntimeException("Conversion from '") << getTypeInfo().getSchemaName() <<
4251
74
            "' to double is not available!";
4252
}
4253
4254
template <typename ALLOC>
4255
45
string<ALLOC> ReflectableBase<ALLOC>::toString(const ALLOC&) const
4256
{
4257


90
    throw CppRuntimeException("Conversion from '") << getTypeInfo().getSchemaName() <<
4258
90
            "' to string is not available!";
4259
}
4260
4261
template <typename ALLOC>
4262
402
string<ALLOC> ReflectableBase<ALLOC>::toString() const
4263
{
4264
402
    return toString(ALLOC());
4265
}
4266
4267
template <typename ALLOC>
4268
1
void ReflectableConstAllocatorHolderBase<ALLOC>::initializeChildren()
4269
{
4270


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4271
}
4272
4273
template <typename ALLOC>
4274
1
void ReflectableConstAllocatorHolderBase<ALLOC>::initialize(const vector<AnyHolder<ALLOC>, ALLOC>&)
4275
{
4276


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4277
}
4278
4279
template <typename ALLOC>
4280
1
size_t ReflectableConstAllocatorHolderBase<ALLOC>::initializeOffsets(size_t)
4281
{
4282


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4283
}
4284
4285
template <typename ALLOC>
4286
1
IBasicReflectablePtr<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::getField(StringView)
4287
{
4288


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4289
}
4290
4291
template <typename ALLOC>
4292
1
void ReflectableConstAllocatorHolderBase<ALLOC>::setField(StringView, const AnyHolder<ALLOC>&)
4293
{
4294


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4295
}
4296
4297
template <typename ALLOC>
4298
1
IBasicReflectablePtr<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::getParameter(StringView)
4299
{
4300


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4301
}
4302
4303
template <typename ALLOC>
4304
1
IBasicReflectablePtr<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::callFunction(StringView)
4305
{
4306


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4307
}
4308
4309
template <typename ALLOC>
4310
1
AnyHolder<ALLOC> ReflectableConstAllocatorHolderBase<ALLOC>::getAnyValue(const ALLOC&)
4311
{
4312


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is constant!";
4313
}
4314
4315
template <typename ALLOC>
4316
31
void ReflectableArrayBase<ALLOC>::initializeChildren()
4317
{
4318


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4319
}
4320
4321
template <typename ALLOC>
4322
31
void ReflectableArrayBase<ALLOC>::initialize(const vector<AnyHolder<ALLOC>, ALLOC>&)
4323
{
4324


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4325
}
4326
4327
template <typename ALLOC>
4328
31
size_t ReflectableArrayBase<ALLOC>::initializeOffsets(size_t)
4329
{
4330


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4331
}
4332
4333
template <typename ALLOC>
4334
71
size_t ReflectableArrayBase<ALLOC>::bitSizeOf(size_t) const
4335
{
4336


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4337
}
4338
4339
template <typename ALLOC>
4340
71
void ReflectableArrayBase<ALLOC>::write(BitStreamWriter&) const
4341
{
4342


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4343
}
4344
4345
template <typename ALLOC>
4346
40
IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::getField(StringView) const
4347
{
4348


40
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4349
}
4350
4351
template <typename ALLOC>
4352
31
IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::getField(StringView)
4353
{
4354


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4355
}
4356
4357
template <typename ALLOC>
4358
31
IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::createField(StringView)
4359
{
4360


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4361
}
4362
4363
template <typename ALLOC>
4364
31
void ReflectableArrayBase<ALLOC>::setField(StringView, const AnyHolder<ALLOC>&)
4365
{
4366


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4367
}
4368
4369
template <typename ALLOC>
4370
40
IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::getParameter(StringView) const
4371
{
4372


40
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4373
}
4374
4375
template <typename ALLOC>
4376
31
IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::getParameter(StringView)
4377
{
4378


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4379
}
4380
4381
template <typename ALLOC>
4382
40
IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::callFunction(StringView) const
4383
{
4384


40
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4385
}
4386
4387
template <typename ALLOC>
4388
31
IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::callFunction(StringView)
4389
{
4390


31
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4391
}
4392
4393
template <typename ALLOC>
4394
71
StringView ReflectableArrayBase<ALLOC>::getChoice() const
4395
{
4396


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4397
}
4398
4399
template <typename ALLOC>
4400
105
IBasicReflectableConstPtr<ALLOC> ReflectableArrayBase<ALLOC>::operator[](size_t index) const
4401
{
4402
105
    return this->at(index);
4403
}
4404
4405
template <typename ALLOC>
4406
84
IBasicReflectablePtr<ALLOC> ReflectableArrayBase<ALLOC>::operator[](size_t index)
4407
{
4408
84
    return this->at(index);
4409
}
4410
4411
template <typename ALLOC>
4412
71
bool ReflectableArrayBase<ALLOC>::getBool() const
4413
{
4414


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4415
}
4416
4417
template <typename ALLOC>
4418
71
int8_t ReflectableArrayBase<ALLOC>::getInt8() const
4419
{
4420


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4421
}
4422
4423
template <typename ALLOC>
4424
71
int16_t ReflectableArrayBase<ALLOC>::getInt16() const
4425
{
4426


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4427
}
4428
4429
template <typename ALLOC>
4430
71
int32_t ReflectableArrayBase<ALLOC>::getInt32() const
4431
{
4432


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4433
}
4434
4435
template <typename ALLOC>
4436
71
int64_t ReflectableArrayBase<ALLOC>::getInt64() const
4437
{
4438


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4439
}
4440
4441
template <typename ALLOC>
4442
71
uint8_t ReflectableArrayBase<ALLOC>::getUInt8() const
4443
{
4444


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4445
}
4446
4447
template <typename ALLOC>
4448
71
uint16_t ReflectableArrayBase<ALLOC>::getUInt16() const
4449
{
4450


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4451
}
4452
4453
template <typename ALLOC>
4454
71
uint32_t ReflectableArrayBase<ALLOC>::getUInt32() const
4455
{
4456


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4457
}
4458
4459
template <typename ALLOC>
4460
71
uint64_t ReflectableArrayBase<ALLOC>::getUInt64() const
4461
{
4462


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4463
}
4464
4465
template <typename ALLOC>
4466
71
float ReflectableArrayBase<ALLOC>::getFloat() const
4467
{
4468


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4469
}
4470
4471
template <typename ALLOC>
4472
71
double ReflectableArrayBase<ALLOC>::getDouble() const
4473
{
4474


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4475
}
4476
4477
template <typename ALLOC>
4478
71
Span<const uint8_t> ReflectableArrayBase<ALLOC>::getBytes() const
4479
{
4480


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4481
}
4482
4483
template <typename ALLOC>
4484
71
StringView ReflectableArrayBase<ALLOC>::getStringView() const
4485
{
4486


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4487
}
4488
4489
template <typename ALLOC>
4490
71
const BasicBitBuffer<ALLOC>& ReflectableArrayBase<ALLOC>::getBitBuffer() const
4491
{
4492


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4493
}
4494
4495
template <typename ALLOC>
4496
71
int64_t ReflectableArrayBase<ALLOC>::toInt() const
4497
{
4498


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4499
}
4500
4501
template <typename ALLOC>
4502
71
uint64_t ReflectableArrayBase<ALLOC>::toUInt() const
4503
{
4504


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4505
}
4506
4507
template <typename ALLOC>
4508
71
double ReflectableArrayBase<ALLOC>::toDouble() const
4509
{
4510


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4511
}
4512
4513
template <typename ALLOC>
4514
71
string<ALLOC> ReflectableArrayBase<ALLOC>::toString(const ALLOC&) const
4515
{
4516


71
    throw CppRuntimeException("Reflectable is an array '") << getTypeInfo().getSchemaName() << "[]'!";
4517
}
4518
4519
template <typename ALLOC>
4520
1
void ReflectableConstArrayBase<ALLOC>::resize(size_t)
4521
{
4522


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!";
4523
}
4524
4525
template <typename ALLOC>
4526
1
IBasicReflectablePtr<ALLOC> ReflectableConstArrayBase<ALLOC>::at(size_t)
4527
{
4528


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!";
4529
}
4530
4531
template <typename ALLOC>
4532
1
IBasicReflectablePtr<ALLOC> ReflectableConstArrayBase<ALLOC>::operator[](size_t)
4533
{
4534


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!";
4535
}
4536
4537
template <typename ALLOC>
4538
1
void ReflectableConstArrayBase<ALLOC>::setAt(const AnyHolder<ALLOC>&, size_t)
4539
{
4540


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!";
4541
}
4542
4543
template <typename ALLOC>
4544
1
void ReflectableConstArrayBase<ALLOC>::append(const AnyHolder<ALLOC>&)
4545
{
4546


1
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!";
4547
}
4548
4549
template <typename ALLOC>
4550
6
AnyHolder<ALLOC> ReflectableConstArrayBase<ALLOC>::getAnyValue(const ALLOC&)
4551
{
4552


6
    throw CppRuntimeException("Reflectable '") << getTypeInfo().getSchemaName() << "' is a constant array!";
4553
}
4554
4555
} // namespace zserio
4556
4557
#endif // ZSERIO_REFLECTABLE_H_INC