GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/zserio/TypeInfo.h Lines: 345 345 100.0 %
Date: 2023-12-13 14:51:09 Branches: 408 792 51.5 %

Line Branch Exec Source
1
#ifndef ZSERIO_TYPE_INFO_INC_H
2
#define ZSERIO_TYPE_INFO_INC_H
3
4
#include <algorithm>
5
#include <memory>
6
#include <string>
7
8
#include "zserio/AnyHolder.h"
9
#include "zserio/BitBuffer.h"
10
#include "zserio/CppRuntimeException.h"
11
#include "zserio/ITypeInfo.h"
12
13
namespace zserio
14
{
15
16
/**
17
 * Type information abstract base class.
18
 *
19
 * This base class implements fully the methods getSchemaName(), getSchemaName() and getCppType(). All other
20
 * interface methods just throw an exception.
21
 */
22
template <typename ALLOC>
23
3084
class TypeInfoBase : public IBasicTypeInfo<ALLOC>
24
{
25
public:
26
    /**
27
     * Constructor.
28
     *
29
     * \param schemaName The schema name to be stored in type information.
30
     * \param schemaType The schema type to be stored in type information.
31
     * \param cppType The C++ type to be stored in type information.
32
     */
33
    TypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType);
34
35
    /**
36
     * Copying and moving is disallowed!
37
     * \{
38
     */
39
    TypeInfoBase(const TypeInfoBase&) = delete;
40
    TypeInfoBase& operator=(const TypeInfoBase&) = delete;
41
42
    TypeInfoBase(const TypeInfoBase&&) = delete;
43
    TypeInfoBase& operator=(const TypeInfoBase&&) = delete;
44
    /**
45
     * \}
46
     */
47
48
    ~TypeInfoBase() override = 0;
49
50
    StringView getSchemaName() const override;
51
    SchemaType getSchemaType() const override;
52
    CppType getCppType() const override;
53
    uint8_t getBitSize() const override;
54
55
    Span<const BasicFieldInfo<ALLOC>> getFields() const override;
56
    Span<const BasicParameterInfo<ALLOC>> getParameters() const override;
57
    Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override;
58
59
    StringView getSelector() const override;
60
    Span<const BasicCaseInfo<ALLOC>> getCases() const override;
61
62
    const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override;
63
    Span<const StringView> getUnderlyingTypeArguments() const override;
64
    Span<const ItemInfo> getEnumItems() const override;
65
    Span<const ItemInfo> getBitmaskValues() const override;
66
67
    Span<const BasicColumnInfo<ALLOC>> getColumns() const override;
68
    StringView getSqlConstraint() const override;
69
    StringView getVirtualTableUsing() const override;
70
    bool isWithoutRowId() const override;
71
72
    Span<const BasicTableInfo<ALLOC>> getTables() const override;
73
74
    StringView getTemplateName() const override;
75
    Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override;
76
77
    Span<const BasicMessageInfo<ALLOC>> getMessages() const override;
78
    Span<const BasicMethodInfo<ALLOC>> getMethods() const override;
79
80
    IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override;
81
    IBasicReflectablePtr<ALLOC> createInstance() const override;
82
83
private:
84
    StringView m_schemaName;
85
    SchemaType m_schemaType;
86
    CppType m_cppType;
87
};
88
89
/**
90
 * Type information abstract base class for builtin types.
91
 */
92
template <typename ALLOC = std::allocator<uint8_t>>
93
2609
class BuiltinTypeInfo : public TypeInfoBase<ALLOC>
94
{
95
protected:
96
    /**
97
     * Constructor.
98
     *
99
     * \param schemaName The schema name to be stored in type information.
100
     * \param schemaType The schema type to be stored in type information.
101
     * \param cppType The C++ type to be stored in type information.
102
     */
103
    BuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType);
104
105
public:
106
    /**
107
     * Gets the type information of bool schema type.
108
     *
109
     * \return Reference to the type information of bool schema type.
110
     */
111
    static const IBasicTypeInfo<ALLOC>& getBool();
112
113
    /**
114
     * Gets the type information of int8 schema type.
115
     *
116
     * \return Reference to the type information of int8 schema type.
117
     */
118
    static const IBasicTypeInfo<ALLOC>& getInt8();
119
120
    /**
121
     * Gets the type information of int16 schema type.
122
     *
123
     * \return Reference to the type information of int16 schema type.
124
     */
125
    static const IBasicTypeInfo<ALLOC>& getInt16();
126
127
    /**
128
     * Gets the type information of int32 schema type.
129
     *
130
     * \return Reference to the type information of int32 schema type.
131
     */
132
    static const IBasicTypeInfo<ALLOC>& getInt32();
133
134
    /**
135
     * Gets the type information of int64 schema type.
136
     *
137
     * \return Reference to the type information of int64 schema type.
138
     */
139
    static const IBasicTypeInfo<ALLOC>& getInt64();
140
141
    /**
142
     * Gets the type information of uint8 schema type.
143
     *
144
     * \return Reference to the type information of uint8 schema type.
145
     */
146
    static const IBasicTypeInfo<ALLOC>& getUInt8();
147
148
    /**
149
     * Gets the type information of uint16 schema type.
150
     *
151
     * \return Reference to the type information of uint16 schema type.
152
     */
153
    static const IBasicTypeInfo<ALLOC>& getUInt16();
154
155
    /**
156
     * Gets the type information of uint32 schema type.
157
     *
158
     * \return Reference to the type information of uint32 schema type.
159
     */
160
    static const IBasicTypeInfo<ALLOC>& getUInt32();
161
162
    /**
163
     * Gets the type information of uint64 schema type.
164
     *
165
     * \return Reference to the type information of uint64 schema type.
166
     */
167
    static const IBasicTypeInfo<ALLOC>& getUInt64();
168
169
    /**
170
     * Gets the type information of varint16 schema type.
171
     *
172
     * \return Reference to the type information of varint16 schema type.
173
     */
174
    static const IBasicTypeInfo<ALLOC>& getVarInt16();
175
176
    /**
177
     * Gets the type information of varint32 schema type.
178
     *
179
     * \return Reference to the type information of varint32 schema type.
180
     */
181
    static const IBasicTypeInfo<ALLOC>& getVarInt32();
182
183
    /**
184
     * Gets the type information of varint64 schema type.
185
     *
186
     * \return Reference to the type information of varint64 schema type.
187
     */
188
    static const IBasicTypeInfo<ALLOC>& getVarInt64();
189
190
    /**
191
     * Gets the type information of varint schema type.
192
     *
193
     * \return Reference to the type information of varint schema type.
194
     */
195
    static const IBasicTypeInfo<ALLOC>& getVarInt();
196
197
    /**
198
     * Gets the type information of varuint16 schema type.
199
     *
200
     * \return Reference to the type information of varuint16 schema type.
201
     */
202
    static const IBasicTypeInfo<ALLOC>& getVarUInt16();
203
204
    /**
205
     * Gets the type information of varuint32 schema type.
206
     *
207
     * \return Reference to the type information of varuint32 schema type.
208
     */
209
    static const IBasicTypeInfo<ALLOC>& getVarUInt32();
210
211
    /**
212
     * Gets the type information of varuint64 schema type.
213
     *
214
     * \return Reference to the type information of varuint64 schema type.
215
     */
216
    static const IBasicTypeInfo<ALLOC>& getVarUInt64();
217
218
    /**
219
     * Gets the type information of varuint schema type.
220
     *
221
     * \return Reference to the type information of varuint schema type.
222
     */
223
    static const IBasicTypeInfo<ALLOC>& getVarUInt();
224
225
    /**
226
     * Gets the type information of varsize schema type.
227
     *
228
     * \return Reference to the type information of varsize schema type.
229
     */
230
    static const IBasicTypeInfo<ALLOC>& getVarSize();
231
232
    /**
233
     * Gets the type information of float16 schema type.
234
     *
235
     * \return Reference to the type information of float16 schema type.
236
     */
237
    static const IBasicTypeInfo<ALLOC>& getFloat16();
238
239
    /**
240
     * Gets the type information of float32 schema type.
241
     *
242
     * \return Reference to the type information of float32 schema type.
243
     */
244
    static const IBasicTypeInfo<ALLOC>& getFloat32();
245
246
    /**
247
     * Gets the type information of float64 schema type.
248
     *
249
     * \return Reference to the type information of float64 schema type.
250
     */
251
    static const IBasicTypeInfo<ALLOC>& getFloat64();
252
253
    /**
254
     * Gets the type information of bytes schema type.
255
     *
256
     * \return Reference to the type information of bytes schema type.
257
     */
258
    static const IBasicTypeInfo<ALLOC>& getBytes();
259
260
    /**
261
     * Gets the type information of string schema type.
262
     *
263
     * \return Reference to the type information of string schema type.
264
     */
265
    static const IBasicTypeInfo<ALLOC>& getString();
266
267
    /**
268
     * Gets the type information of extern schema type.
269
     *
270
     * \return Reference to the type information of extern schema type.
271
     */
272
    static const IBasicTypeInfo<ALLOC>& getBitBuffer();
273
274
    /**
275
     * Gets the type information of fixed signed bit field schema type.
276
     *
277
     * \param bitSize The bit size of the bit field.
278
     *
279
     * \return Reference to the type information of fixed signed bit field schema type.
280
     */
281
    static const IBasicTypeInfo<ALLOC>& getFixedSignedBitField(uint8_t bitSize);
282
283
    /**
284
     * Gets the type information of fixed unsigned bit field schema type.
285
     *
286
     * \param bitSize The bit size of the bit field.
287
     *
288
     * \return Reference to the type information of fixed unsigned bit field schema type.
289
     */
290
    static const IBasicTypeInfo<ALLOC>& getFixedUnsignedBitField(uint8_t bitSize);
291
292
    /**
293
     * Gets the type information of dynamic signed bit field schema type.
294
     *
295
     * \param maxBitSize The maximum bit size of the dynamic bit field.
296
     *
297
     * \return Reference to the type information of dynamic signed bit field schema type.
298
     */
299
    static const IBasicTypeInfo<ALLOC>& getDynamicSignedBitField(uint8_t maxBitSize);
300
301
    /**
302
     * Gets the type information of dynamic unsigned bit field schema type.
303
     *
304
     * \param maxBitSize The maximum bit size of the dynamic bit field.
305
     *
306
     * \return Reference to the type information of dynamic unsigned bit field schema type.
307
     */
308
    static const IBasicTypeInfo<ALLOC>& getDynamicUnsignedBitField(uint8_t maxBitSize);
309
};
310
311
/**
312
 * Type information abstract base class for fixed size builtin types.
313
 */
314
template <typename ALLOC>
315
2218
class FixedSizeBuiltinTypeInfo : public BuiltinTypeInfo<ALLOC>
316
{
317
protected:
318
    /**
319
     * Constructor.
320
     *
321
     * \param schemaName The schema name to be stored in type information.
322
     * \param schemaType The schema type to be stored in type information.
323
     * \param cppType The C++ type to be stored in type information.
324
     * \param bitSize The bit size of the fixed size integral schema type.
325
     */
326
    FixedSizeBuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType,
327
            uint8_t bitSize);
328
329
public:
330
    uint8_t getBitSize() const override;
331
332
    /**
333
     * Gets the type information of bool schema type.
334
     *
335
     * \return Reference to the type information of bool schema type.
336
     */
337
    static const IBasicTypeInfo<ALLOC>& getBool();
338
339
    /**
340
     * Gets the type information of int8 schema type.
341
     *
342
     * \return Reference to the type information of int8 schema type.
343
     */
344
    static const IBasicTypeInfo<ALLOC>& getInt8();
345
346
    /**
347
     * Gets the type information of int16 schema type.
348
     *
349
     * \return Reference to the type information of int16 schema type.
350
     */
351
    static const IBasicTypeInfo<ALLOC>& getInt16();
352
353
    /**
354
     * Gets the type information of int32 schema type.
355
     *
356
     * \return Reference to the type information of int32 schema type.
357
     */
358
    static const IBasicTypeInfo<ALLOC>& getInt32();
359
360
    /**
361
     * Gets the type information of int64 schema type.
362
     *
363
     * \return Reference to the type information of int64 schema type.
364
     */
365
    static const IBasicTypeInfo<ALLOC>& getInt64();
366
367
    /**
368
     * Gets the type information of uint8 schema type.
369
     *
370
     * \return Reference to the type information of uint8 schema type.
371
     */
372
    static const IBasicTypeInfo<ALLOC>& getUInt8();
373
374
    /**
375
     * Gets the type information of uint16 schema type.
376
     *
377
     * \return Reference to the type information of uint16 schema type.
378
     */
379
    static const IBasicTypeInfo<ALLOC>& getUInt16();
380
381
    /**
382
     * Gets the type information of uint32 schema type.
383
     *
384
     * \return Reference to the type information of uint32 schema type.
385
     */
386
    static const IBasicTypeInfo<ALLOC>& getUInt32();
387
388
    /**
389
     * Gets the type information of uint64 schema type.
390
     *
391
     * \return Reference to the type information of uint64 schema type.
392
     */
393
    static const IBasicTypeInfo<ALLOC>& getUInt64();
394
395
    /**
396
     * Gets the type information of float16 schema type.
397
     *
398
     * \return Reference to the type information of float16 schema type.
399
     */
400
    static const IBasicTypeInfo<ALLOC>& getFloat16();
401
402
    /**
403
     * Gets the type information of float32 schema type.
404
     *
405
     * \return Reference to the type information of float32 schema type.
406
     */
407
    static const IBasicTypeInfo<ALLOC>& getFloat32();
408
409
    /**
410
     * Gets the type information of float64 schema type.
411
     *
412
     * \return Reference to the type information of float64 schema type.
413
     */
414
    static const IBasicTypeInfo<ALLOC>& getFloat64();
415
416
    /**
417
     * Gets the type information of fixed signed bit field schema type.
418
     *
419
     * \param bitSize The bit size of the bit field.
420
     *
421
     * \return Reference to the type information of fixed signed bit field schema type.
422
     */
423
    static const IBasicTypeInfo<ALLOC>& getFixedSignedBitField(uint8_t bitSize);
424
425
    /**
426
     * Gets the type information of fixed unsigned bit field schema type.
427
     *
428
     * \param bitSize The bit size of the bit field.
429
     *
430
     * \return Reference to the type information of fixed unsigned bit field schema type.
431
     */
432
    static const IBasicTypeInfo<ALLOC>& getFixedUnsignedBitField(uint8_t bitSize);
433
434
private:
435
    uint8_t m_bitSize;
436
};
437
438
/**
439
 * Type information abstract base class for templatable types.
440
 */
441
template <typename ALLOC>
442
287
class TemplatableTypeInfoBase : public TypeInfoBase<ALLOC>
443
{
444
public:
445
    /**
446
     * Constructor.
447
     *
448
     * \param schemaName The schema name to be stored in type information.
449
     * \param schemaType The schema type to be stored in type information.
450
     * \param cppType The C++ type to be stored in type information.
451
     * \param templateName The full schema template name.
452
     * \param templateArguments The sequence of type informations for template arguments.
453
     */
454
    TemplatableTypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType,
455
            StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments);
456
457
    ~TemplatableTypeInfoBase() override = 0;
458
459
    TemplatableTypeInfoBase(const TemplatableTypeInfoBase&) = default;
460
    TemplatableTypeInfoBase& operator=(const TemplatableTypeInfoBase&) = default;
461
462
    TemplatableTypeInfoBase(TemplatableTypeInfoBase&&) = default;
463
    TemplatableTypeInfoBase& operator=(TemplatableTypeInfoBase&&) = default;
464
465
    StringView getTemplateName() const override;
466
    Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override;
467
468
private:
469
    StringView m_templateName;
470
    Span<const BasicTemplateArgumentInfo<ALLOC>> m_templateArguments;
471
};
472
473
/**
474
 * Type information abstract base class for compound types.
475
 */
476
template <typename ALLOC>
477
286
class CompoundTypeInfoBase : public TemplatableTypeInfoBase<ALLOC>
478
{
479
public:
480
    using TypeInfoBase<ALLOC>::getSchemaName;
481
    using CreateInstanceFunc = IBasicReflectablePtr<ALLOC> (*)(const ALLOC&);
482
483
    /**
484
     * Constructor.
485
     *
486
     * \param schemaName The schema name to be stored in type information.
487
     * \param schemaType The schema type to be stored in type information.
488
     * \param cppType The C++ type to be stored in type information.
489
     * \param templateName The full schema template name.
490
     * \param templateArguments The sequence of type informations for template arguments.
491
     * \param fields The sequence of type informations for fields.
492
     * \param parameters The sequence of type informations for parameters.
493
     * \param functions The sequence of type informations for functions.
494
     */
495
    CompoundTypeInfoBase(StringView schemaName, CreateInstanceFunc createInstanceFunc,
496
            SchemaType schemaType, CppType cppType,
497
            StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
498
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
499
            Span<const BasicFunctionInfo<ALLOC>> functions);
500
501
    ~CompoundTypeInfoBase() override = 0;
502
503
    CompoundTypeInfoBase(const CompoundTypeInfoBase&) = default;
504
    CompoundTypeInfoBase& operator=(const CompoundTypeInfoBase&) = default;
505
506
    CompoundTypeInfoBase(CompoundTypeInfoBase&&) = default;
507
    CompoundTypeInfoBase& operator=(CompoundTypeInfoBase&&) = default;
508
509
    Span<const BasicFieldInfo<ALLOC>> getFields() const override;
510
    Span<const BasicParameterInfo<ALLOC>> getParameters() const override;
511
    Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override;
512
513
    IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override;
514
515
private:
516
    CreateInstanceFunc m_createInstanceFunc;
517
    Span<const BasicFieldInfo<ALLOC>> m_fields;
518
    Span<const BasicParameterInfo<ALLOC>> m_parameters;
519
    Span<const BasicFunctionInfo<ALLOC>> m_functions;
520
};
521
522
/**
523
 * Type information class for structure types.
524
 */
525
template <typename ALLOC>
526
231
class StructTypeInfo : public CompoundTypeInfoBase<ALLOC>
527
{
528
public:
529
    using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc;
530
531
    /**
532
     * Constructor.
533
     *
534
     * \param schemaName The schema name to be stored in type information.
535
     * \param templateName The full schema template name.
536
     * \param templateArguments The sequence of type informations for template arguments.
537
     * \param fields The sequence of type informations for fields.
538
     * \param parameters The sequence of type informations for parameters.
539
     * \param functions The sequence of type informations for functions.
540
     */
541
    StructTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
542
            StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
543
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
544
            Span<const BasicFunctionInfo<ALLOC>> functions);
545
};
546
547
/**
548
 * Type information class for union types.
549
 */
550
template <typename ALLOC>
551
28
class UnionTypeInfo : public CompoundTypeInfoBase<ALLOC>
552
{
553
public:
554
    using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc;
555
556
    /**
557
     * Constructor.
558
     *
559
     * \param schemaName The schema name to be stored in type information.
560
     * \param templateName The full schema template name.
561
     * \param templateArguments The sequence of type informations for template arguments.
562
     * \param fields The sequence of type informations for fields.
563
     * \param parameters The sequence of type informations for parameters.
564
     * \param functions The sequence of type informations for functions.
565
     */
566
    UnionTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
567
            StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
568
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
569
            Span<const BasicFunctionInfo<ALLOC>> functions);
570
};
571
572
/**
573
 * Type information class for choice types.
574
 */
575
template <typename ALLOC>
576
27
class ChoiceTypeInfo : public CompoundTypeInfoBase<ALLOC>
577
{
578
public:
579
    using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc;
580
581
    /**
582
     * Constructor.
583
     *
584
     * \param schemaName The schema name to be stored in type information.
585
     * \param templateName The full schema template name.
586
     * \param templateArguments The sequence of type informations for template arguments.
587
     * \param fields The sequence of type informations for fields.
588
     * \param parameters The sequence of type informations for parameters.
589
     * \param functions The sequence of type informations for functions.
590
     * \param selector The selector expression.
591
     * \param cases The sequence of type informations for cases.
592
     */
593
    ChoiceTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
594
            StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
595
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
596
            Span<const BasicFunctionInfo<ALLOC>> functions, StringView selector,
597
            Span<const BasicCaseInfo<ALLOC>> cases);
598
599
    StringView getSelector() const override;
600
    Span<const BasicCaseInfo<ALLOC>> getCases() const override;
601
602
private:
603
    StringView m_selector;
604
    Span<const BasicCaseInfo<ALLOC>> m_cases;
605
};
606
607
/**
608
 * Type information abstract base class for enumeration and bitmask types.
609
 */
610
template <typename ALLOC>
611
183
class TypeInfoWithUnderlyingTypeBase : public TypeInfoBase<ALLOC>
612
{
613
public:
614
    /**
615
     * Constructor.
616
     *
617
     * \param schemaName The schema name to be stored in type information.
618
     * \param schemaType The schema type to be stored in type information.
619
     * \param cppType The C++ type to be stored in type information.
620
     * \param underlyingType The reference to type information of underlying zserio type.
621
     * \param underlyingTypeArguments The underlying zserio type arguments.
622
     */
623
    TypeInfoWithUnderlyingTypeBase(StringView schemaName, SchemaType schemaType, CppType cppType,
624
            const IBasicTypeInfo<ALLOC>& underlyingType, Span<const StringView> underlyingTypeArguments);
625
626
    const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override;
627
    Span<const StringView> getUnderlyingTypeArguments() const override;
628
629
private:
630
    const IBasicTypeInfo<ALLOC>& m_underlyingType;
631
    Span<const StringView> m_underlyingTypeArguments;
632
};
633
634
/**
635
 * Type information class for enumeration types.
636
 */
637
template <typename ALLOC>
638
105
class EnumTypeInfo : public TypeInfoWithUnderlyingTypeBase<ALLOC>
639
{
640
public:
641
    /**
642
     * Constructor.
643
     *
644
     * \param schemaName The schema name to be stored in type information.
645
     * \param underlyingType The reference to type information of underlying zserio type.
646
     * \param underlyingTypeArguments The underlying zserio type arguments.
647
     * \param enumItems The sequence of type informations for enumeration items.
648
     */
649
    EnumTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
650
            Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> enumItems);
651
652
    Span<const ItemInfo> getEnumItems() const override;
653
654
private:
655
    Span<const ItemInfo> m_enumItems;
656
};
657
658
/**
659
 * Type information class for bitmask types.
660
 */
661
template <typename ALLOC>
662
78
class BitmaskTypeInfo : public TypeInfoWithUnderlyingTypeBase<ALLOC>
663
{
664
public:
665
    /**
666
     * Constructor.
667
     *
668
     * \param schemaName The schema name to be stored in type information.
669
     * \param underlyingType The reference to type information of underlying zserio type.
670
     * \param underlyingTypeArguments The underlying zserio type arguments.
671
     * \param bitmaskValues The sequence of type informations for bitmask values.
672
     */
673
    BitmaskTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
674
            Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> bitmaskValues);
675
676
    Span<const ItemInfo> getBitmaskValues() const override;
677
678
private:
679
    Span<const ItemInfo> m_bitmaskValues;
680
};
681
682
/**
683
 * Type information class for SQL table types.
684
 */
685
template <typename ALLOC>
686
1
class SqlTableTypeInfo : public TemplatableTypeInfoBase<ALLOC>
687
{
688
public:
689
    /**
690
     * Constructor.
691
     *
692
     * \param schemaName The schema name to be stored in type information.
693
     * \param templateName The full schema template name.
694
     * \param templateArguments The sequence of type informations for template arguments.
695
     * \param columns The sequence of type informations for columns.
696
     * \param sqlConstraint The SQL table constraint.
697
     * \param virtualTableUsing The SQL virtual table using specification.
698
     * \param isWithoutRowId true if SQL table is without row id table, otherwise false.
699
     */
700
    SqlTableTypeInfo(StringView schemaName,
701
            StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
702
            Span<const BasicColumnInfo<ALLOC>> columns, StringView sqlConstraint, StringView virtualTableUsing,
703
            bool isWithoutRowId);
704
705
    Span<const BasicColumnInfo<ALLOC>> getColumns() const override;
706
    StringView getSqlConstraint() const override;
707
    StringView getVirtualTableUsing() const override;
708
    bool isWithoutRowId() const override;
709
710
private:
711
    Span<const BasicColumnInfo<ALLOC>> m_columns;
712
    StringView m_sqlConstraint;
713
    StringView m_virtualTableUsing;
714
    bool m_isWithoutRowId;
715
};
716
717
/**
718
 * Type information class for SQL database types.
719
 */
720
template <typename ALLOC>
721
1
class SqlDatabaseTypeInfo : public TypeInfoBase<ALLOC>
722
{
723
public:
724
    /**
725
     * Constructor.
726
     *
727
     * \param schemaName The schema name to be stored in type information.
728
     * \param tables The sequence of type informations for tables.
729
     */
730
    SqlDatabaseTypeInfo(StringView schemaName, Span<const BasicTableInfo<ALLOC>> tables);
731
732
    Span<const BasicTableInfo<ALLOC>> getTables() const override;
733
734
private:
735
    Span<const BasicTableInfo<ALLOC>> m_tables;
736
};
737
738
/**
739
 * Type information class for pubsub types.
740
 */
741
template <typename ALLOC>
742
1
class PubsubTypeInfo : public TypeInfoBase<ALLOC>
743
{
744
public:
745
    /**
746
     * Constructor.
747
     *
748
     * \param schemaName The schema name to be stored in type information.
749
     * \param messages The sequence of type informations for pubsub messages.
750
     */
751
    PubsubTypeInfo(StringView schemaName, Span<const BasicMessageInfo<ALLOC>> messages);
752
753
    Span<const BasicMessageInfo<ALLOC>> getMessages() const override;
754
755
private:
756
    Span<const BasicMessageInfo<ALLOC>> m_messages;
757
};
758
759
/**
760
 * Type information class for service types.
761
 */
762
template <typename ALLOC>
763
1
class ServiceTypeInfo : public TypeInfoBase<ALLOC>
764
{
765
public:
766
    /**
767
     * Constructor.
768
     *
769
     * \param schemaName The schema name to be stored in type information.
770
     * \param methods The sequence of type informations for service methods.
771
     */
772
    ServiceTypeInfo(StringView schemaName, Span<const BasicMethodInfo<ALLOC>> methods);
773
774
    Span<const BasicMethodInfo<ALLOC>> getMethods() const override;
775
776
private:
777
    Span<const BasicMethodInfo<ALLOC>> m_methods;
778
};
779
780
/**
781
 * Type info for recursive types used as a wrapper around generated static typeInfo method to prevent
782
 * infinite recursion in type info definition.
783
 */
784
template <typename ALLOC>
785
class RecursiveTypeInfo : public IBasicTypeInfo<ALLOC>
786
{
787
public:
788
    /** Typedef to pointer to static typeInfo method on generated objects. */
789
    using TypeInfoFunc = const IBasicTypeInfo<ALLOC>& (*)();
790
791
    /**
792
     * Constructor.
793
     *
794
     * \param typeInfoFunc Pointer to static typeInfo method.
795
     */
796
1
    explicit RecursiveTypeInfo(TypeInfoFunc typeInfoFunc) :
797
1
            m_typeInfoFunc(typeInfoFunc)
798
1
    {}
799
800
1
    ~RecursiveTypeInfo() override = default;
801
802
    /**
803
     * Copying and moving is disallowed!
804
     * \{
805
     */
806
    RecursiveTypeInfo(const RecursiveTypeInfo&) = delete;
807
    RecursiveTypeInfo& operator=(const RecursiveTypeInfo&) = delete;
808
809
    RecursiveTypeInfo(const RecursiveTypeInfo&&) = delete;
810
    RecursiveTypeInfo& operator=(const RecursiveTypeInfo&&) = delete;
811
    /**
812
     * \}
813
     */
814
815
    StringView getSchemaName() const override;
816
    SchemaType getSchemaType() const override;
817
    CppType getCppType() const override;
818
    uint8_t getBitSize() const override;
819
820
    Span<const BasicFieldInfo<ALLOC>> getFields() const override;
821
    Span<const BasicParameterInfo<ALLOC>> getParameters() const override;
822
    Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override;
823
824
    StringView getSelector() const override;
825
    Span<const BasicCaseInfo<ALLOC>> getCases() const override;
826
827
    const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override;
828
    Span<const StringView> getUnderlyingTypeArguments() const override;
829
    Span<const ItemInfo> getEnumItems() const override;
830
    Span<const ItemInfo> getBitmaskValues() const override;
831
832
    Span<const BasicColumnInfo<ALLOC>> getColumns() const override;
833
    StringView getSqlConstraint() const override;
834
    StringView getVirtualTableUsing() const override;
835
    bool isWithoutRowId() const override;
836
837
    Span<const BasicTableInfo<ALLOC>> getTables() const override;
838
839
    StringView getTemplateName() const override;
840
    Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override;
841
842
    Span<const BasicMessageInfo<ALLOC>> getMessages() const override;
843
    Span<const BasicMethodInfo<ALLOC>> getMethods() const override;
844
845
    IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override;
846
    IBasicReflectablePtr<ALLOC> createInstance() const override;
847
848
private:
849
    TypeInfoFunc m_typeInfoFunc;
850
};
851
852
template <typename ALLOC>
853
3084
TypeInfoBase<ALLOC>::TypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType) :
854
3084
        m_schemaName(schemaName), m_schemaType(schemaType), m_cppType(cppType)
855
3084
{}
856
857
template <typename ALLOC>
858
TypeInfoBase<ALLOC>::~TypeInfoBase() = default;
859
860
template <typename ALLOC>
861
16032
StringView TypeInfoBase<ALLOC>::getSchemaName() const
862
{
863
16032
    return m_schemaName;
864
}
865
866
template <typename ALLOC>
867
3743
SchemaType TypeInfoBase<ALLOC>::getSchemaType() const
868
{
869
3743
    return m_schemaType;
870
}
871
872
template <typename ALLOC>
873
946
CppType TypeInfoBase<ALLOC>::getCppType() const
874
{
875
946
    return m_cppType;
876
}
877
878
template <typename ALLOC>
879
150
uint8_t TypeInfoBase<ALLOC>::getBitSize() const
880
{
881


150
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a fixed size type!";
882
}
883
884
template <typename ALLOC>
885
286
Span<const BasicFieldInfo<ALLOC>> TypeInfoBase<ALLOC>::getFields() const
886
{
887


286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
888
}
889
890
template <typename ALLOC>
891
286
Span<const BasicParameterInfo<ALLOC>> TypeInfoBase<ALLOC>::getParameters() const
892
{
893


286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
894
}
895
896
template <typename ALLOC>
897
286
Span<const BasicFunctionInfo<ALLOC>> TypeInfoBase<ALLOC>::getFunctions() const
898
{
899


286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
900
}
901
902
template <typename ALLOC>
903
289
StringView TypeInfoBase<ALLOC>::getSelector() const
904
{
905


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a choice type!";
906
}
907
908
template <typename ALLOC>
909
289
Span<const BasicCaseInfo<ALLOC>> TypeInfoBase<ALLOC>::getCases() const
910
{
911


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a choice type!";
912
}
913
914
template <typename ALLOC>
915
288
const IBasicTypeInfo<ALLOC>& TypeInfoBase<ALLOC>::getUnderlyingType() const
916
{
917


288
    throw CppRuntimeException("Type '") << getSchemaName() << "' does not have underlying type!";
918
}
919
920
template <typename ALLOC>
921
288
Span<const StringView> TypeInfoBase<ALLOC>::getUnderlyingTypeArguments() const
922
{
923


288
    throw CppRuntimeException("Type '") << getSchemaName() << "' does not have underlying type!";
924
}
925
926
template <typename ALLOC>
927
289
Span<const ItemInfo> TypeInfoBase<ALLOC>::getEnumItems() const
928
{
929


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not an enum type!";
930
}
931
932
template <typename ALLOC>
933
289
Span<const ItemInfo> TypeInfoBase<ALLOC>::getBitmaskValues() const
934
{
935


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a bitmask type!";
936
}
937
938
template <typename ALLOC>
939
289
Span<const BasicColumnInfo<ALLOC>> TypeInfoBase<ALLOC>::getColumns() const
940
{
941


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
942
}
943
944
template <typename ALLOC>
945
289
StringView TypeInfoBase<ALLOC>::getSqlConstraint() const
946
{
947


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
948
}
949
950
template <typename ALLOC>
951
289
StringView TypeInfoBase<ALLOC>::getVirtualTableUsing() const
952
{
953


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
954
}
955
956
template <typename ALLOC>
957
289
bool TypeInfoBase<ALLOC>::isWithoutRowId() const
958
{
959


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
960
}
961
962
template <typename ALLOC>
963
289
Span<const BasicTableInfo<ALLOC>> TypeInfoBase<ALLOC>::getTables() const
964
{
965


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL database type!";
966
}
967
968
template <typename ALLOC>
969
285
StringView TypeInfoBase<ALLOC>::getTemplateName() const
970
{
971


285
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a templatable type!";
972
}
973
974
template <typename ALLOC>
975
285
Span<const BasicTemplateArgumentInfo<ALLOC>> TypeInfoBase<ALLOC>::getTemplateArguments() const
976
{
977


285
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a templatable type!";
978
}
979
980
template <typename ALLOC>
981
289
Span<const BasicMessageInfo<ALLOC>> TypeInfoBase<ALLOC>::getMessages() const
982
{
983


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a pubsub type!";
984
}
985
986
template <typename ALLOC>
987
289
Span<const BasicMethodInfo<ALLOC>> TypeInfoBase<ALLOC>::getMethods() const
988
{
989


289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a service type!";
990
}
991
992
template <typename ALLOC>
993
286
IBasicReflectablePtr<ALLOC> TypeInfoBase<ALLOC>::createInstance(const ALLOC&) const
994
{
995


286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
996
}
997
998
template <typename ALLOC>
999
281
IBasicReflectablePtr<ALLOC> TypeInfoBase<ALLOC>::createInstance() const
1000
{
1001
281
    return createInstance(ALLOC());
1002
}
1003
1004
template <typename ALLOC>
1005
2609
BuiltinTypeInfo<ALLOC>::BuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType) :
1006
2609
        TypeInfoBase<ALLOC>(schemaName, schemaType, cppType)
1007
2609
{}
1008
1009
template <typename ALLOC>
1010
93
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBool()
1011
{
1012
93
    return FixedSizeBuiltinTypeInfo<ALLOC>::getBool();
1013
}
1014
1015
template <typename ALLOC>
1016
145
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt8()
1017
{
1018
145
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt8();
1019
}
1020
1021
template <typename ALLOC>
1022
59
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt16()
1023
{
1024
59
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt16();
1025
}
1026
1027
template <typename ALLOC>
1028
70
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt32()
1029
{
1030
70
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt32();
1031
}
1032
1033
template <typename ALLOC>
1034
57
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt64()
1035
{
1036
57
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt64();
1037
}
1038
1039
template <typename ALLOC>
1040
237
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt8()
1041
{
1042
237
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt8();
1043
}
1044
1045
template <typename ALLOC>
1046
81
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt16()
1047
{
1048
81
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt16();
1049
}
1050
1051
template <typename ALLOC>
1052
406
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt32()
1053
{
1054
406
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt32();
1055
}
1056
1057
template <typename ALLOC>
1058
81
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt64()
1059
{
1060
81
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt64();
1061
}
1062
1063
template <typename ALLOC>
1064
13
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt16()
1065
{
1066
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1067
        makeStringView("varint16"), SchemaType::VARINT16, CppType::INT16
1068


13
    };
1069
13
    return typeInfo;
1070
}
1071
1072
template <typename ALLOC>
1073
13
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt32()
1074
{
1075
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1076
        makeStringView("varint32"), SchemaType::VARINT32, CppType::INT32
1077


13
    };
1078
13
    return typeInfo;
1079
}
1080
1081
template <typename ALLOC>
1082
13
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt64()
1083
{
1084
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1085
        makeStringView("varint64"), SchemaType::VARINT64, CppType::INT64
1086


13
    };
1087
13
    return typeInfo;
1088
}
1089
1090
template <typename ALLOC>
1091
14
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt()
1092
{
1093
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1094
        makeStringView("varint"), SchemaType::VARINT, CppType::INT64
1095


14
    };
1096
14
    return typeInfo;
1097
}
1098
1099
template <typename ALLOC>
1100
13
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt16()
1101
{
1102
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1103
        makeStringView("varuint16"), SchemaType::VARUINT16, CppType::UINT16
1104


13
    };
1105
13
    return typeInfo;
1106
}
1107
1108
template <typename ALLOC>
1109
13
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt32()
1110
{
1111
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1112
        makeStringView("varuint32"), SchemaType::VARUINT32, CppType::UINT32
1113


13
    };
1114
13
    return typeInfo;
1115
}
1116
1117
template <typename ALLOC>
1118
13
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt64()
1119
{
1120
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1121
        makeStringView("varuint64"), SchemaType::VARUINT64, CppType::UINT64
1122


13
    };
1123
13
    return typeInfo;
1124
}
1125
1126
template <typename ALLOC>
1127
13
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt()
1128
{
1129
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1130
        makeStringView("varuint"), SchemaType::VARUINT, CppType::UINT64
1131


13
    };
1132
13
    return typeInfo;
1133
}
1134
1135
template <typename ALLOC>
1136
14
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarSize()
1137
{
1138
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1139
        makeStringView("varsize"), SchemaType::VARSIZE, CppType::UINT32
1140


14
    };
1141
14
    return typeInfo;
1142
}
1143
1144
template <typename ALLOC>
1145
14
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat16()
1146
{
1147
14
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat16();
1148
}
1149
1150
template <typename ALLOC>
1151
53
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat32()
1152
{
1153
53
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat32();
1154
}
1155
1156
template <typename ALLOC>
1157
81
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat64()
1158
{
1159
81
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat64();
1160
}
1161
1162
template <typename ALLOC>
1163
145
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBytes()
1164
{
1165
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1166
        makeStringView("bytes"), SchemaType::BYTES, CppType::BYTES
1167


145
    };
1168
145
    return typeInfo;
1169
}
1170
1171
template <typename ALLOC>
1172
469
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getString()
1173
{
1174
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1175
        makeStringView("string"), SchemaType::STRING, CppType::STRING
1176


469
    };
1177
469
    return typeInfo;
1178
}
1179
1180
template <typename ALLOC>
1181
143
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBitBuffer()
1182
{
1183
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1184
        makeStringView("extern"), SchemaType::EXTERN, CppType::BIT_BUFFER
1185


143
    };
1186
143
    return typeInfo;
1187
}
1188
1189
template <typename ALLOC>
1190
325
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(uint8_t bitSize)
1191
{
1192
325
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize);
1193
}
1194
1195
template <typename ALLOC>
1196
360
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(uint8_t bitSize)
1197
{
1198
360
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize);
1199
}
1200
1201
template <typename ALLOC>
1202
291
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(uint8_t maxBitSize)
1203
{
1204

291
    if (maxBitSize == 0 || maxBitSize > 64)
1205
    {
1206

386
        throw CppRuntimeException("BuiltinTypeInfo::getDynamicSignedBitField: Invalid max bit size '") <<
1207
386
                maxBitSize << "'!";
1208
    }
1209
1210
98
    if (maxBitSize <= 8)
1211
    {
1212
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1213
            "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT8
1214


30
        };
1215
30
        return typeInfo;
1216
    }
1217
68
    else if (maxBitSize <= 16)
1218
    {
1219
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1220
            "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT16
1221


12
        };
1222
12
        return typeInfo;
1223
    }
1224
56
    else if (maxBitSize <= 32)
1225
    {
1226
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1227
            "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT32
1228


20
        };
1229
20
        return typeInfo;
1230
    }
1231
    else
1232
    {
1233
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1234
            "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT64
1235


36
        };
1236
36
        return typeInfo;
1237
    }
1238
}
1239
1240
template <typename ALLOC>
1241
284
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(uint8_t maxBitSize)
1242
{
1243

284
    if (maxBitSize == 0 || maxBitSize > 64)
1244
    {
1245

386
        throw CppRuntimeException("BuiltinTypeInfo::getDynamicUnsignedBitField: Invalid max bit size '") <<
1246
386
                maxBitSize << "'!";
1247
    }
1248
1249
91
    if (maxBitSize <= 8)
1250
    {
1251
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1252
            "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT8
1253


23
        };
1254
23
        return typeInfo;
1255
    }
1256
68
    else if (maxBitSize <= 16)
1257
    {
1258
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1259
            "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT16
1260


12
        };
1261
12
        return typeInfo;
1262
    }
1263
56
    else if (maxBitSize <= 32)
1264
    {
1265
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1266
            "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT32
1267


20
        };
1268
20
        return typeInfo;
1269
    }
1270
    else
1271
    {
1272
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1273
            "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT64
1274


36
        };
1275
36
        return typeInfo;
1276
    }
1277
}
1278
1279
template <typename ALLOC>
1280
2218
FixedSizeBuiltinTypeInfo<ALLOC>::FixedSizeBuiltinTypeInfo(StringView schemaName, SchemaType schemaType,
1281
        CppType cppType, uint8_t bitSize) :
1282
2218
        BuiltinTypeInfo<ALLOC>(schemaName, schemaType, cppType), m_bitSize(bitSize)
1283
2218
{}
1284
1285
template <typename ALLOC>
1286
233
uint8_t FixedSizeBuiltinTypeInfo<ALLOC>::getBitSize() const
1287
{
1288
233
    return m_bitSize;
1289
}
1290
1291
template <typename ALLOC>
1292
93
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getBool()
1293
{
1294
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1295
        makeStringView("bool"), SchemaType::BOOL, CppType::BOOL, 1
1296


93
    };
1297
93
    return typeInfo;
1298
}
1299
1300
template <typename ALLOC>
1301
145
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt8()
1302
{
1303
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1304
        makeStringView("int8"), SchemaType::INT8, CppType::INT8, 8
1305


145
    };
1306
145
    return typeInfo;
1307
}
1308
1309
template <typename ALLOC>
1310
59
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt16()
1311
{
1312
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1313
        makeStringView("int16"), SchemaType::INT16, CppType::INT16, 16
1314


59
    };
1315
59
    return typeInfo;
1316
}
1317
1318
template <typename ALLOC>
1319
70
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt32()
1320
{
1321
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1322
        makeStringView("int32"), SchemaType::INT32, CppType::INT32, 32
1323


70
    };
1324
70
    return typeInfo;
1325
}
1326
1327
template <typename ALLOC>
1328
57
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt64()
1329
{
1330
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1331
        makeStringView("int64"), SchemaType::INT64, CppType::INT64, 64
1332


57
    };
1333
57
    return typeInfo;
1334
}
1335
1336
template <typename ALLOC>
1337
237
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt8()
1338
{
1339
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1340
        makeStringView("uint8"), SchemaType::UINT8, CppType::UINT8, 8
1341


237
    };
1342
237
    return typeInfo;
1343
}
1344
1345
template <typename ALLOC>
1346
81
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt16()
1347
{
1348
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1349
        makeStringView("uint16"), SchemaType::UINT16, CppType::UINT16, 16
1350


81
    };
1351
81
    return typeInfo;
1352
}
1353
1354
template <typename ALLOC>
1355
406
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt32()
1356
{
1357
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1358
        makeStringView("uint32"), SchemaType::UINT32, CppType::UINT32, 32
1359


406
    };
1360
406
    return typeInfo;
1361
}
1362
1363
template <typename ALLOC>
1364
81
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt64()
1365
{
1366
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1367
        makeStringView("uint64"), SchemaType::UINT64, CppType::UINT64, 64
1368


81
    };
1369
81
    return typeInfo;
1370
}
1371
1372
template <typename ALLOC>
1373
14
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat16()
1374
{
1375
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1376
        makeStringView("float16"), SchemaType::FLOAT16, CppType::FLOAT, 16
1377


14
    };
1378
14
    return typeInfo;
1379
}
1380
1381
template <typename ALLOC>
1382
53
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat32()
1383
{
1384
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1385
        makeStringView("float32"), SchemaType::FLOAT32, CppType::FLOAT, 32
1386


53
    };
1387
53
    return typeInfo;
1388
}
1389
1390
template <typename ALLOC>
1391
81
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat64()
1392
{
1393
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1394
        makeStringView("float64"), SchemaType::FLOAT64, CppType::DOUBLE, 64
1395


81
    };
1396
81
    return typeInfo;
1397
}
1398
1399
template <typename ALLOC>
1400
325
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFixedSignedBitField(uint8_t bitSize)
1401
{
1402

325
    if (bitSize == 0 || bitSize > 64)
1403
    {
1404

386
        throw CppRuntimeException("FixedSizeBuiltinTypeInfo::getFixedSignedBitField: Invalid bit size '") <<
1405

386
                bitSize << "'!";
1406
    }
1407
1408
    static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {{
1409
        { "int:1"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 1 },
1410
        { "int:2"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 2 },
1411
        { "int:3"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 3 },
1412
        { "int:4"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 4 },
1413
        { "int:5"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 5 },
1414
        { "int:6"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 6 },
1415
        { "int:7"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 7 },
1416
        { "int:8"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 8 },
1417
        { "int:9"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 9 },
1418
        { "int:10"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 10 },
1419
        { "int:11"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 11 },
1420
        { "int:12"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 12 },
1421
        { "int:13"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 13 },
1422
        { "int:14"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 14 },
1423
        { "int:15"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 15 },
1424
        { "int:16"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 16 },
1425
        { "int:17"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 17 },
1426
        { "int:18"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 18 },
1427
        { "int:19"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 19 },
1428
        { "int:20"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 20 },
1429
        { "int:21"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 21 },
1430
        { "int:22"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 22 },
1431
        { "int:23"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 23 },
1432
        { "int:24"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 24 },
1433
        { "int:25"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 25 },
1434
        { "int:26"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 26 },
1435
        { "int:27"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 27 },
1436
        { "int:28"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 28 },
1437
        { "int:29"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 29 },
1438
        { "int:30"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 30 },
1439
        { "int:31"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 31 },
1440
        { "int:32"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 32 },
1441
        { "int:33"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 33 },
1442
        { "int:34"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 34 },
1443
        { "int:35"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 35 },
1444
        { "int:36"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 36 },
1445
        { "int:37"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 37 },
1446
        { "int:38"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 38 },
1447
        { "int:39"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 39 },
1448
        { "int:40"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 40 },
1449
        { "int:41"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 41 },
1450
        { "int:42"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 42 },
1451
        { "int:43"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 43 },
1452
        { "int:44"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 44 },
1453
        { "int:45"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 45 },
1454
        { "int:46"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 46 },
1455
        { "int:47"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 47 },
1456
        { "int:48"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 48 },
1457
        { "int:49"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 49 },
1458
        { "int:50"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 50 },
1459
        { "int:51"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 51 },
1460
        { "int:52"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 52 },
1461
        { "int:53"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 53 },
1462
        { "int:54"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 54 },
1463
        { "int:55"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 55 },
1464
        { "int:56"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 56 },
1465
        { "int:57"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 57 },
1466
        { "int:58"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 58 },
1467
        { "int:59"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 59 },
1468
        { "int:60"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 60 },
1469
        { "int:61"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 61 },
1470
        { "int:62"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 62 },
1471
        { "int:63"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 63 },
1472
        { "int:64"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 64 }
1473


































132
    }};
1474
1475
132
    return bitFieldTypeInfoArray[bitSize - 1];
1476
}
1477
1478
template <typename ALLOC>
1479
360
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(uint8_t bitSize)
1480
{
1481

360
    if (bitSize == 0 || bitSize > 64)
1482
    {
1483

386
        throw CppRuntimeException("FixedSizeBuiltinTypeInfo::getFixedUnsignedBitField: Invalid bit size '") <<
1484

386
                bitSize << "'!";
1485
    }
1486
1487
    static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {{
1488
        { "bit:1"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 1 },
1489
        { "bit:2"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 2 },
1490
        { "bit:3"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 3 },
1491
        { "bit:4"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 4 },
1492
        { "bit:5"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 5 },
1493
        { "bit:6"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 6 },
1494
        { "bit:7"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 7 },
1495
        { "bit:8"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 8 },
1496
        { "bit:9"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 9 },
1497
        { "bit:10"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 10 },
1498
        { "bit:11"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 11 },
1499
        { "bit:12"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 12 },
1500
        { "bit:13"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 13 },
1501
        { "bit:14"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 14 },
1502
        { "bit:15"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 15 },
1503
        { "bit:16"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 16 },
1504
        { "bit:17"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 17 },
1505
        { "bit:18"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 18 },
1506
        { "bit:19"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 19 },
1507
        { "bit:20"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 20 },
1508
        { "bit:21"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 21 },
1509
        { "bit:22"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 22 },
1510
        { "bit:23"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 23 },
1511
        { "bit:24"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 24 },
1512
        { "bit:25"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 25 },
1513
        { "bit:26"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 26 },
1514
        { "bit:27"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 27 },
1515
        { "bit:28"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 28 },
1516
        { "bit:29"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 29 },
1517
        { "bit:30"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 30 },
1518
        { "bit:31"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 31 },
1519
        { "bit:32"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 32 },
1520
        { "bit:33"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 33 },
1521
        { "bit:34"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 34 },
1522
        { "bit:35"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 35 },
1523
        { "bit:36"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 36 },
1524
        { "bit:37"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 37 },
1525
        { "bit:38"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 38 },
1526
        { "bit:39"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 39 },
1527
        { "bit:40"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 40 },
1528
        { "bit:41"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 41 },
1529
        { "bit:42"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 42 },
1530
        { "bit:43"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 43 },
1531
        { "bit:44"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 44 },
1532
        { "bit:45"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 45 },
1533
        { "bit:46"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 46 },
1534
        { "bit:47"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 47 },
1535
        { "bit:48"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 48 },
1536
        { "bit:49"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 49 },
1537
        { "bit:50"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 50 },
1538
        { "bit:51"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 51 },
1539
        { "bit:52"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 52 },
1540
        { "bit:53"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 53 },
1541
        { "bit:54"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 54 },
1542
        { "bit:55"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 55 },
1543
        { "bit:56"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 56 },
1544
        { "bit:57"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 57 },
1545
        { "bit:58"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 58 },
1546
        { "bit:59"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 59 },
1547
        { "bit:60"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 60 },
1548
        { "bit:61"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 61 },
1549
        { "bit:62"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 62 },
1550
        { "bit:63"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 63 },
1551
        { "bit:64"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 64 }
1552


































167
    }};
1553
1554
167
    return bitFieldTypeInfoArray[bitSize - 1];
1555
}
1556
1557
template <typename ALLOC>
1558
287
TemplatableTypeInfoBase<ALLOC>::TemplatableTypeInfoBase(StringView schemaName,
1559
        SchemaType schemaType, CppType cppType,
1560
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments) :
1561
        TypeInfoBase<ALLOC>(schemaName, schemaType, cppType),
1562
287
        m_templateName(templateName), m_templateArguments(templateArguments)
1563
287
{}
1564
1565
template <typename ALLOC>
1566
TemplatableTypeInfoBase<ALLOC>::~TemplatableTypeInfoBase() = default;
1567
1568
template <typename ALLOC>
1569
6
StringView TemplatableTypeInfoBase<ALLOC>::getTemplateName() const
1570
{
1571
6
    return m_templateName;
1572
}
1573
1574
template <typename ALLOC>
1575
5
Span<const BasicTemplateArgumentInfo<ALLOC>> TemplatableTypeInfoBase<ALLOC>::getTemplateArguments() const
1576
{
1577
5
    return m_templateArguments;
1578
}
1579
1580
template <typename ALLOC>
1581
286
CompoundTypeInfoBase<ALLOC>::CompoundTypeInfoBase(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1582
        SchemaType schemaType, CppType cppType,
1583
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1584
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1585
        Span<const BasicFunctionInfo<ALLOC>> functions) :
1586
        TemplatableTypeInfoBase<ALLOC>(schemaName, schemaType, cppType, templateName, templateArguments),
1587
        m_createInstanceFunc(createInstanceFunc),
1588
286
        m_fields(fields), m_parameters(parameters), m_functions(functions)
1589
286
{}
1590
1591
template <typename ALLOC>
1592
CompoundTypeInfoBase<ALLOC>::~CompoundTypeInfoBase() = default;
1593
1594
template <typename ALLOC>
1595
685
Span<const BasicFieldInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getFields() const
1596
{
1597
685
    return m_fields;
1598
}
1599
1600
template <typename ALLOC>
1601
127
Span<const BasicParameterInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getParameters() const
1602
{
1603
127
    return m_parameters;
1604
}
1605
1606
template <typename ALLOC>
1607
69
Span<const BasicFunctionInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getFunctions() const
1608
{
1609
69
    return m_functions;
1610
}
1611
1612
template <typename ALLOC>
1613
88
IBasicReflectablePtr<ALLOC> CompoundTypeInfoBase<ALLOC>::createInstance(const ALLOC& allocator) const
1614
{
1615
88
    if (!m_createInstanceFunc)
1616
    {
1617


10
        throw CppRuntimeException("Reflectable '") << getSchemaName() << "': Cannot create instance, " <<
1618
10
                "either '-withoutWriterCode' or '-withoutReflectionCode' zserio option is used!";
1619
    }
1620
83
    return m_createInstanceFunc(allocator);
1621
}
1622
1623
template <typename ALLOC>
1624
231
StructTypeInfo<ALLOC>::StructTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1625
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1626
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1627
        Span<const BasicFunctionInfo<ALLOC>> functions) :
1628
        CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::STRUCT, CppType::STRUCT,
1629
231
                templateName, templateArguments, fields, parameters, functions)
1630
231
{}
1631
1632
template <typename ALLOC>
1633
28
UnionTypeInfo<ALLOC>::UnionTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1634
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1635
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1636
        Span<const BasicFunctionInfo<ALLOC>> functions) :
1637
        CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::UNION, CppType::UNION,
1638
28
                templateName, templateArguments, fields, parameters, functions)
1639
28
{}
1640
1641
template <typename ALLOC>
1642
27
ChoiceTypeInfo<ALLOC>::ChoiceTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1643
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1644
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1645
        Span<const BasicFunctionInfo<ALLOC>> functions,
1646
        StringView selector, Span<const BasicCaseInfo<ALLOC>> cases) :
1647
        CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::CHOICE, CppType::CHOICE,
1648
                templateName, templateArguments, fields, parameters, functions),
1649
27
        m_selector(selector), m_cases(cases)
1650
27
{}
1651
1652
template <typename ALLOC>
1653
1
StringView ChoiceTypeInfo<ALLOC>::getSelector() const
1654
{
1655
1
    return m_selector;
1656
}
1657
1658
template <typename ALLOC>
1659
1
Span<const BasicCaseInfo<ALLOC>> ChoiceTypeInfo<ALLOC>::getCases() const
1660
{
1661
1
    return m_cases;
1662
}
1663
1664
template <typename ALLOC>
1665
1
SqlTableTypeInfo<ALLOC>::SqlTableTypeInfo(StringView schemaName,
1666
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1667
        Span<const BasicColumnInfo<ALLOC>> columns, StringView sqlConstraint, StringView virtualTableUsing,
1668
        bool isWithoutRowId) :
1669
        TemplatableTypeInfoBase<ALLOC>(schemaName, SchemaType::SQL_TABLE, CppType::SQL_TABLE,
1670
                templateName, templateArguments),
1671
        m_columns(columns), m_sqlConstraint(sqlConstraint), m_virtualTableUsing(virtualTableUsing),
1672
1
        m_isWithoutRowId(isWithoutRowId)
1673
1
{}
1674
1675
template <typename ALLOC>
1676
1
Span<const BasicColumnInfo<ALLOC>> SqlTableTypeInfo<ALLOC>::getColumns() const
1677
{
1678
1
    return m_columns;
1679
}
1680
1681
template <typename ALLOC>
1682
1
StringView SqlTableTypeInfo<ALLOC>::getSqlConstraint() const
1683
{
1684
1
    return m_sqlConstraint;
1685
}
1686
1687
template <typename ALLOC>
1688
1
StringView SqlTableTypeInfo<ALLOC>::getVirtualTableUsing() const
1689
{
1690
1
    return m_virtualTableUsing;
1691
}
1692
1693
template <typename ALLOC>
1694
1
bool SqlTableTypeInfo<ALLOC>::isWithoutRowId() const
1695
{
1696
1
    return m_isWithoutRowId;
1697
}
1698
1699
template <typename ALLOC>
1700
1
SqlDatabaseTypeInfo<ALLOC>::SqlDatabaseTypeInfo(StringView schemaName,
1701
        Span<const BasicTableInfo<ALLOC>> tables) :
1702
        TypeInfoBase<ALLOC>(schemaName, SchemaType::SQL_DATABASE, CppType::SQL_DATABASE),
1703
1
        m_tables(tables)
1704
1
{}
1705
1706
template <typename ALLOC>
1707
1
Span<const BasicTableInfo<ALLOC>> SqlDatabaseTypeInfo<ALLOC>::getTables() const
1708
{
1709
1
    return m_tables;
1710
}
1711
1712
template <typename ALLOC>
1713
183
TypeInfoWithUnderlyingTypeBase<ALLOC>::TypeInfoWithUnderlyingTypeBase(
1714
        StringView schemaName, SchemaType schemaType, CppType cppType,
1715
        const IBasicTypeInfo<ALLOC>& underlyingType, Span<const StringView> underlyingTypeArguments) :
1716
        TypeInfoBase<ALLOC>(schemaName, schemaType, cppType),
1717
183
        m_underlyingType(underlyingType), m_underlyingTypeArguments(underlyingTypeArguments)
1718
183
{}
1719
1720
template <typename ALLOC>
1721
75
const IBasicTypeInfo<ALLOC>& TypeInfoWithUnderlyingTypeBase<ALLOC>::getUnderlyingType() const
1722
{
1723
75
    return m_underlyingType;
1724
}
1725
1726
template <typename ALLOC>
1727
2
Span<const StringView> TypeInfoWithUnderlyingTypeBase<ALLOC>::getUnderlyingTypeArguments() const
1728
{
1729
2
    return m_underlyingTypeArguments;
1730
}
1731
1732
template <typename ALLOC>
1733
105
EnumTypeInfo<ALLOC>::EnumTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
1734
        Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> enumItems) :
1735
        TypeInfoWithUnderlyingTypeBase<ALLOC>(schemaName, SchemaType::ENUM, CppType::ENUM,
1736
                underlyingType, underlyingTypeArguments),
1737
105
        m_enumItems(enumItems)
1738
105
{}
1739
1740
template <typename ALLOC>
1741
23
Span<const ItemInfo> EnumTypeInfo<ALLOC>::getEnumItems() const
1742
{
1743
23
    return m_enumItems;
1744
}
1745
1746
template <typename ALLOC>
1747
78
BitmaskTypeInfo<ALLOC>::BitmaskTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
1748
        Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> bitmaskValues) :
1749
        TypeInfoWithUnderlyingTypeBase<ALLOC>(schemaName, SchemaType::BITMASK, CppType::BITMASK,
1750
                underlyingType, underlyingTypeArguments),
1751
78
        m_bitmaskValues(bitmaskValues)
1752
78
{}
1753
1754
template <typename ALLOC>
1755
48
Span<const ItemInfo> BitmaskTypeInfo<ALLOC>::getBitmaskValues() const
1756
{
1757
48
    return m_bitmaskValues;
1758
}
1759
1760
template <typename ALLOC>
1761
1
PubsubTypeInfo<ALLOC>::PubsubTypeInfo(StringView schemaName, Span<const BasicMessageInfo<ALLOC>> messages) :
1762
1
        TypeInfoBase<ALLOC>(schemaName, SchemaType::PUBSUB, CppType::PUBSUB), m_messages(messages)
1763
1
{}
1764
1765
template <typename ALLOC>
1766
1
Span<const BasicMessageInfo<ALLOC>> PubsubTypeInfo<ALLOC>::getMessages() const
1767
{
1768
1
    return m_messages;
1769
}
1770
1771
template <typename ALLOC>
1772
1
ServiceTypeInfo<ALLOC>::ServiceTypeInfo(StringView schemaName, Span<const BasicMethodInfo<ALLOC>> methods) :
1773
1
        TypeInfoBase<ALLOC>(schemaName, SchemaType::SERVICE, CppType::SERVICE), m_methods(methods)
1774
1
{}
1775
1776
template <typename ALLOC>
1777
1
Span<const BasicMethodInfo<ALLOC>> ServiceTypeInfo<ALLOC>::getMethods() const
1778
{
1779
1
    return m_methods;
1780
}
1781
1782
template <typename ALLOC>
1783
1
StringView RecursiveTypeInfo<ALLOC>::getSchemaName() const
1784
{
1785
1
    return m_typeInfoFunc().getSchemaName();
1786
}
1787
1788
template <typename ALLOC>
1789
1
SchemaType RecursiveTypeInfo<ALLOC>::getSchemaType() const
1790
{
1791
1
    return m_typeInfoFunc().getSchemaType();
1792
}
1793
1794
template <typename ALLOC>
1795
1
CppType RecursiveTypeInfo<ALLOC>::getCppType() const
1796
{
1797
1
    return m_typeInfoFunc().getCppType();
1798
}
1799
1800
template <typename ALLOC>
1801
1
uint8_t RecursiveTypeInfo<ALLOC>::getBitSize() const
1802
{
1803
1
    return m_typeInfoFunc().getBitSize();
1804
}
1805
1806
template <typename ALLOC>
1807
1
Span<const BasicFieldInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getFields() const
1808
{
1809
1
    return m_typeInfoFunc().getFields();
1810
}
1811
1812
template <typename ALLOC>
1813
1
Span<const BasicParameterInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getParameters() const
1814
{
1815
1
    return m_typeInfoFunc().getParameters();
1816
}
1817
1818
template <typename ALLOC>
1819
1
Span<const BasicFunctionInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getFunctions() const
1820
{
1821
1
    return m_typeInfoFunc().getFunctions();
1822
}
1823
1824
template <typename ALLOC>
1825
1
StringView RecursiveTypeInfo<ALLOC>::getSelector() const
1826
{
1827
1
    return m_typeInfoFunc().getSelector();
1828
}
1829
1830
template <typename ALLOC>
1831
1
Span<const BasicCaseInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getCases() const
1832
{
1833
1
    return m_typeInfoFunc().getCases();
1834
}
1835
1836
template <typename ALLOC>
1837
1
const IBasicTypeInfo<ALLOC>& RecursiveTypeInfo<ALLOC>::getUnderlyingType() const
1838
{
1839
1
    return m_typeInfoFunc().getUnderlyingType();
1840
}
1841
1842
template <typename ALLOC>
1843
1
Span<const StringView> RecursiveTypeInfo<ALLOC>::getUnderlyingTypeArguments() const
1844
{
1845
1
    return m_typeInfoFunc().getUnderlyingTypeArguments();
1846
}
1847
1848
template <typename ALLOC>
1849
1
Span<const ItemInfo> RecursiveTypeInfo<ALLOC>::getEnumItems() const
1850
{
1851
1
    return m_typeInfoFunc().getEnumItems();
1852
}
1853
1854
template <typename ALLOC>
1855
1
Span<const ItemInfo> RecursiveTypeInfo<ALLOC>::getBitmaskValues() const
1856
{
1857
1
    return m_typeInfoFunc().getBitmaskValues();
1858
}
1859
1860
template <typename ALLOC>
1861
1
Span<const BasicColumnInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getColumns() const
1862
{
1863
1
    return m_typeInfoFunc().getColumns();
1864
}
1865
1866
template <typename ALLOC>
1867
1
StringView RecursiveTypeInfo<ALLOC>::getSqlConstraint() const
1868
{
1869
1
    return m_typeInfoFunc().getSqlConstraint();
1870
}
1871
1872
template <typename ALLOC>
1873
1
StringView RecursiveTypeInfo<ALLOC>::getVirtualTableUsing() const
1874
{
1875
1
    return m_typeInfoFunc().getVirtualTableUsing();
1876
}
1877
1878
template <typename ALLOC>
1879
1
bool RecursiveTypeInfo<ALLOC>::isWithoutRowId() const
1880
{
1881
1
    return m_typeInfoFunc().isWithoutRowId();
1882
}
1883
1884
template <typename ALLOC>
1885
1
Span<const BasicTableInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getTables() const
1886
{
1887
1
    return m_typeInfoFunc().getTables();
1888
}
1889
1890
template <typename ALLOC>
1891
1
StringView RecursiveTypeInfo<ALLOC>::getTemplateName() const
1892
{
1893
1
    return m_typeInfoFunc().getTemplateName();
1894
}
1895
1896
template <typename ALLOC>
1897
1
Span<const BasicTemplateArgumentInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getTemplateArguments() const
1898
{
1899
1
    return m_typeInfoFunc().getTemplateArguments();
1900
}
1901
1902
template <typename ALLOC>
1903
1
Span<const BasicMessageInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getMessages() const
1904
{
1905
1
    return m_typeInfoFunc().getMessages();
1906
}
1907
1908
template <typename ALLOC>
1909
1
Span<const BasicMethodInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getMethods() const
1910
{
1911
1
    return m_typeInfoFunc().getMethods();
1912
}
1913
1914
template <typename ALLOC>
1915
2
IBasicReflectablePtr<ALLOC> RecursiveTypeInfo<ALLOC>::createInstance(const ALLOC& allocator) const
1916
{
1917
2
    return m_typeInfoFunc().createInstance(allocator);
1918
}
1919
1920
template <typename ALLOC>
1921
1
IBasicReflectablePtr<ALLOC> RecursiveTypeInfo<ALLOC>::createInstance() const
1922
{
1923
1
    return createInstance(ALLOC());
1924
}
1925
1926
} // namespace zserio
1927
1928
#endif // ZSERIO_TYPE_INFO_INC_H