Coverage Report

Created: 2024-07-18 11:41

src/zserio/TypeInfo.h
Line
Count
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
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
315
    ~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
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
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, uint8_t bitSize);
327
328
public:
329
    uint8_t getBitSize() const override;
330
331
    /**
332
     * Gets the type information of bool schema type.
333
     *
334
     * \return Reference to the type information of bool schema type.
335
     */
336
    static const IBasicTypeInfo<ALLOC>& getBool();
337
338
    /**
339
     * Gets the type information of int8 schema type.
340
     *
341
     * \return Reference to the type information of int8 schema type.
342
     */
343
    static const IBasicTypeInfo<ALLOC>& getInt8();
344
345
    /**
346
     * Gets the type information of int16 schema type.
347
     *
348
     * \return Reference to the type information of int16 schema type.
349
     */
350
    static const IBasicTypeInfo<ALLOC>& getInt16();
351
352
    /**
353
     * Gets the type information of int32 schema type.
354
     *
355
     * \return Reference to the type information of int32 schema type.
356
     */
357
    static const IBasicTypeInfo<ALLOC>& getInt32();
358
359
    /**
360
     * Gets the type information of int64 schema type.
361
     *
362
     * \return Reference to the type information of int64 schema type.
363
     */
364
    static const IBasicTypeInfo<ALLOC>& getInt64();
365
366
    /**
367
     * Gets the type information of uint8 schema type.
368
     *
369
     * \return Reference to the type information of uint8 schema type.
370
     */
371
    static const IBasicTypeInfo<ALLOC>& getUInt8();
372
373
    /**
374
     * Gets the type information of uint16 schema type.
375
     *
376
     * \return Reference to the type information of uint16 schema type.
377
     */
378
    static const IBasicTypeInfo<ALLOC>& getUInt16();
379
380
    /**
381
     * Gets the type information of uint32 schema type.
382
     *
383
     * \return Reference to the type information of uint32 schema type.
384
     */
385
    static const IBasicTypeInfo<ALLOC>& getUInt32();
386
387
    /**
388
     * Gets the type information of uint64 schema type.
389
     *
390
     * \return Reference to the type information of uint64 schema type.
391
     */
392
    static const IBasicTypeInfo<ALLOC>& getUInt64();
393
394
    /**
395
     * Gets the type information of float16 schema type.
396
     *
397
     * \return Reference to the type information of float16 schema type.
398
     */
399
    static const IBasicTypeInfo<ALLOC>& getFloat16();
400
401
    /**
402
     * Gets the type information of float32 schema type.
403
     *
404
     * \return Reference to the type information of float32 schema type.
405
     */
406
    static const IBasicTypeInfo<ALLOC>& getFloat32();
407
408
    /**
409
     * Gets the type information of float64 schema type.
410
     *
411
     * \return Reference to the type information of float64 schema type.
412
     */
413
    static const IBasicTypeInfo<ALLOC>& getFloat64();
414
415
    /**
416
     * Gets the type information of fixed signed bit field schema type.
417
     *
418
     * \param bitSize The bit size of the bit field.
419
     *
420
     * \return Reference to the type information of fixed signed bit field schema type.
421
     */
422
    static const IBasicTypeInfo<ALLOC>& getFixedSignedBitField(uint8_t bitSize);
423
424
    /**
425
     * Gets the type information of fixed unsigned bit field schema type.
426
     *
427
     * \param bitSize The bit size of the bit field.
428
     *
429
     * \return Reference to the type information of fixed unsigned bit field schema type.
430
     */
431
    static const IBasicTypeInfo<ALLOC>& getFixedUnsignedBitField(uint8_t bitSize);
432
433
private:
434
    uint8_t m_bitSize;
435
};
436
437
/**
438
 * Type information abstract base class for templatable types.
439
 */
440
template <typename ALLOC>
441
class TemplatableTypeInfoBase : public TypeInfoBase<ALLOC>
442
{
443
public:
444
    /**
445
     * Constructor.
446
     *
447
     * \param schemaName The schema name to be stored in type information.
448
     * \param schemaType The schema type to be stored in type information.
449
     * \param cppType The C++ type to be stored in type information.
450
     * \param templateName The full schema template name.
451
     * \param templateArguments The sequence of type information for template arguments.
452
     */
453
    TemplatableTypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType,
454
            StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments);
455
456
50
    ~TemplatableTypeInfoBase() override = 0;
457
458
    TemplatableTypeInfoBase(const TemplatableTypeInfoBase&) = default;
459
    TemplatableTypeInfoBase& operator=(const TemplatableTypeInfoBase&) = default;
460
461
    TemplatableTypeInfoBase(TemplatableTypeInfoBase&&) = default;
462
    TemplatableTypeInfoBase& operator=(TemplatableTypeInfoBase&&) = default;
463
464
    StringView getTemplateName() const override;
465
    Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override;
466
467
private:
468
    StringView m_templateName;
469
    Span<const BasicTemplateArgumentInfo<ALLOC>> m_templateArguments;
470
};
471
472
/**
473
 * Type information abstract base class for compound types.
474
 */
475
template <typename ALLOC>
476
class CompoundTypeInfoBase : public TemplatableTypeInfoBase<ALLOC>
477
{
478
public:
479
    using TypeInfoBase<ALLOC>::getSchemaName;
480
    using CreateInstanceFunc = IBasicReflectablePtr<ALLOC> (*)(const ALLOC&);
481
482
    /**
483
     * Constructor.
484
     *
485
     * \param schemaName The schema name to be stored in type information.
486
     * \param schemaType The schema type to be stored in type information.
487
     * \param cppType The C++ type to be stored in type information.
488
     * \param templateName The full schema template name.
489
     * \param templateArguments The sequence of type information for template arguments.
490
     * \param fields The sequence of type information for fields.
491
     * \param parameters The sequence of type information for parameters.
492
     * \param functions The sequence of type information for functions.
493
     */
494
    CompoundTypeInfoBase(StringView schemaName, CreateInstanceFunc createInstanceFunc, SchemaType schemaType,
495
            CppType cppType, StringView templateName,
496
            Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
497
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
498
            Span<const BasicFunctionInfo<ALLOC>> functions);
499
500
49
    ~CompoundTypeInfoBase() override = 0;
501
502
    CompoundTypeInfoBase(const CompoundTypeInfoBase&) = default;
503
    CompoundTypeInfoBase& operator=(const CompoundTypeInfoBase&) = default;
504
505
    CompoundTypeInfoBase(CompoundTypeInfoBase&&) = default;
506
    CompoundTypeInfoBase& operator=(CompoundTypeInfoBase&&) = default;
507
508
    Span<const BasicFieldInfo<ALLOC>> getFields() const override;
509
    Span<const BasicParameterInfo<ALLOC>> getParameters() const override;
510
    Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override;
511
512
    IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override;
513
514
private:
515
    CreateInstanceFunc m_createInstanceFunc;
516
    Span<const BasicFieldInfo<ALLOC>> m_fields;
517
    Span<const BasicParameterInfo<ALLOC>> m_parameters;
518
    Span<const BasicFunctionInfo<ALLOC>> m_functions;
519
};
520
521
/**
522
 * Type information class for structure types.
523
 */
524
template <typename ALLOC>
525
class StructTypeInfo : public CompoundTypeInfoBase<ALLOC>
526
{
527
public:
528
    using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc;
529
530
    /**
531
     * Constructor.
532
     *
533
     * \param schemaName The schema name to be stored in type information.
534
     * \param templateName The full schema template name.
535
     * \param templateArguments The sequence of type information for template arguments.
536
     * \param fields The sequence of type information for fields.
537
     * \param parameters The sequence of type information for parameters.
538
     * \param functions The sequence of type information for functions.
539
     */
540
    StructTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, StringView templateName,
541
            Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
542
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
543
            Span<const BasicFunctionInfo<ALLOC>> functions);
544
};
545
546
/**
547
 * Type information class for union types.
548
 */
549
template <typename ALLOC>
550
class UnionTypeInfo : public CompoundTypeInfoBase<ALLOC>
551
{
552
public:
553
    using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc;
554
555
    /**
556
     * Constructor.
557
     *
558
     * \param schemaName The schema name to be stored in type information.
559
     * \param templateName The full schema template name.
560
     * \param templateArguments The sequence of type information for template arguments.
561
     * \param fields The sequence of type information for fields.
562
     * \param parameters The sequence of type information for parameters.
563
     * \param functions The sequence of type information for functions.
564
     */
565
    UnionTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, StringView templateName,
566
            Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
567
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
568
            Span<const BasicFunctionInfo<ALLOC>> functions);
569
};
570
571
/**
572
 * Type information class for choice types.
573
 */
574
template <typename ALLOC>
575
class ChoiceTypeInfo : public CompoundTypeInfoBase<ALLOC>
576
{
577
public:
578
    using CreateInstanceFunc = typename CompoundTypeInfoBase<ALLOC>::CreateInstanceFunc;
579
580
    /**
581
     * Constructor.
582
     *
583
     * \param schemaName The schema name to be stored in type information.
584
     * \param templateName The full schema template name.
585
     * \param templateArguments The sequence of type information for template arguments.
586
     * \param fields The sequence of type information for fields.
587
     * \param parameters The sequence of type information for parameters.
588
     * \param functions The sequence of type information for functions.
589
     * \param selector The selector expression.
590
     * \param cases The sequence of type information for cases.
591
     */
592
    ChoiceTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, StringView templateName,
593
            Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
594
            Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
595
            Span<const BasicFunctionInfo<ALLOC>> functions, StringView selector,
596
            Span<const BasicCaseInfo<ALLOC>> cases);
597
598
    StringView getSelector() const override;
599
    Span<const BasicCaseInfo<ALLOC>> getCases() const override;
600
601
private:
602
    StringView m_selector;
603
    Span<const BasicCaseInfo<ALLOC>> m_cases;
604
};
605
606
/**
607
 * Type information abstract base class for enumeration and bitmask types.
608
 */
609
template <typename ALLOC>
610
class TypeInfoWithUnderlyingTypeBase : public TypeInfoBase<ALLOC>
611
{
612
public:
613
    /**
614
     * Constructor.
615
     *
616
     * \param schemaName The schema name to be stored in type information.
617
     * \param schemaType The schema type to be stored in type information.
618
     * \param cppType The C++ type to be stored in type information.
619
     * \param underlyingType The reference to type information of underlying zserio type.
620
     * \param underlyingTypeArguments The underlying zserio type arguments.
621
     */
622
    TypeInfoWithUnderlyingTypeBase(StringView schemaName, SchemaType schemaType, CppType cppType,
623
            const IBasicTypeInfo<ALLOC>& underlyingType, Span<const StringView> underlyingTypeArguments);
624
625
    const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override;
626
    Span<const StringView> getUnderlyingTypeArguments() const override;
627
628
private:
629
    const IBasicTypeInfo<ALLOC>& m_underlyingType;
630
    Span<const StringView> m_underlyingTypeArguments;
631
};
632
633
/**
634
 * Type information class for enumeration types.
635
 */
636
template <typename ALLOC>
637
class EnumTypeInfo : public TypeInfoWithUnderlyingTypeBase<ALLOC>
638
{
639
public:
640
    /**
641
     * Constructor.
642
     *
643
     * \param schemaName The schema name to be stored in type information.
644
     * \param underlyingType The reference to type information of underlying zserio type.
645
     * \param underlyingTypeArguments The underlying zserio type arguments.
646
     * \param enumItems The sequence of type information for enumeration items.
647
     */
648
    EnumTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
649
            Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> enumItems);
650
651
    Span<const ItemInfo> getEnumItems() const override;
652
653
private:
654
    Span<const ItemInfo> m_enumItems;
655
};
656
657
/**
658
 * Type information class for bitmask types.
659
 */
660
template <typename ALLOC>
661
class BitmaskTypeInfo : public TypeInfoWithUnderlyingTypeBase<ALLOC>
662
{
663
public:
664
    /**
665
     * Constructor.
666
     *
667
     * \param schemaName The schema name to be stored in type information.
668
     * \param underlyingType The reference to type information of underlying zserio type.
669
     * \param underlyingTypeArguments The underlying zserio type arguments.
670
     * \param bitmaskValues The sequence of type information for bitmask values.
671
     */
672
    BitmaskTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
673
            Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> bitmaskValues);
674
675
    Span<const ItemInfo> getBitmaskValues() const override;
676
677
private:
678
    Span<const ItemInfo> m_bitmaskValues;
679
};
680
681
/**
682
 * Type information class for SQL table types.
683
 */
684
template <typename ALLOC>
685
class SqlTableTypeInfo : public TemplatableTypeInfoBase<ALLOC>
686
{
687
public:
688
    /**
689
     * Constructor.
690
     *
691
     * \param schemaName The schema name to be stored in type information.
692
     * \param templateName The full schema template name.
693
     * \param templateArguments The sequence of type information for template arguments.
694
     * \param columns The sequence of type information for columns.
695
     * \param sqlConstraint The SQL table constraint.
696
     * \param virtualTableUsing The SQL virtual table using specification.
697
     * \param isWithoutRowId true if SQL table is without row id table, otherwise false.
698
     */
699
    SqlTableTypeInfo(StringView schemaName, StringView templateName,
700
            Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
701
            Span<const BasicColumnInfo<ALLOC>> columns, StringView sqlConstraint, StringView virtualTableUsing,
702
            bool isWithoutRowId);
703
704
    Span<const BasicColumnInfo<ALLOC>> getColumns() const override;
705
    StringView getSqlConstraint() const override;
706
    StringView getVirtualTableUsing() const override;
707
    bool isWithoutRowId() const override;
708
709
private:
710
    Span<const BasicColumnInfo<ALLOC>> m_columns;
711
    StringView m_sqlConstraint;
712
    StringView m_virtualTableUsing;
713
    bool m_isWithoutRowId;
714
};
715
716
/**
717
 * Type information class for SQL database types.
718
 */
719
template <typename ALLOC>
720
class SqlDatabaseTypeInfo : public TypeInfoBase<ALLOC>
721
{
722
public:
723
    /**
724
     * Constructor.
725
     *
726
     * \param schemaName The schema name to be stored in type information.
727
     * \param tables The sequence of type information for tables.
728
     */
729
    SqlDatabaseTypeInfo(StringView schemaName, Span<const BasicTableInfo<ALLOC>> tables);
730
731
    Span<const BasicTableInfo<ALLOC>> getTables() const override;
732
733
private:
734
    Span<const BasicTableInfo<ALLOC>> m_tables;
735
};
736
737
/**
738
 * Type information class for pubsub types.
739
 */
740
template <typename ALLOC>
741
class PubsubTypeInfo : public TypeInfoBase<ALLOC>
742
{
743
public:
744
    /**
745
     * Constructor.
746
     *
747
     * \param schemaName The schema name to be stored in type information.
748
     * \param messages The sequence of type information for pubsub messages.
749
     */
750
    PubsubTypeInfo(StringView schemaName, Span<const BasicMessageInfo<ALLOC>> messages);
751
752
    Span<const BasicMessageInfo<ALLOC>> getMessages() const override;
753
754
private:
755
    Span<const BasicMessageInfo<ALLOC>> m_messages;
756
};
757
758
/**
759
 * Type information class for service types.
760
 */
761
template <typename ALLOC>
762
class ServiceTypeInfo : public TypeInfoBase<ALLOC>
763
{
764
public:
765
    /**
766
     * Constructor.
767
     *
768
     * \param schemaName The schema name to be stored in type information.
769
     * \param methods The sequence of type information for service methods.
770
     */
771
    ServiceTypeInfo(StringView schemaName, Span<const BasicMethodInfo<ALLOC>> methods);
772
773
    Span<const BasicMethodInfo<ALLOC>> getMethods() const override;
774
775
private:
776
    Span<const BasicMethodInfo<ALLOC>> m_methods;
777
};
778
779
/**
780
 * Type info for recursive types used as a wrapper around generated static typeInfo method to prevent
781
 * infinite recursion in type info definition.
782
 */
783
template <typename ALLOC>
784
class RecursiveTypeInfo : public IBasicTypeInfo<ALLOC>
785
{
786
public:
787
    /** Typedef to pointer to static typeInfo method on generated objects. */
788
    using TypeInfoFunc = const IBasicTypeInfo<ALLOC>& (*)();
789
790
    /**
791
     * Constructor.
792
     *
793
     * \param typeInfoFunc Pointer to static typeInfo method.
794
     */
795
    explicit RecursiveTypeInfo(TypeInfoFunc typeInfoFunc) :
796
            m_typeInfoFunc(typeInfoFunc)
797
1
    {}
798
799
1
    ~RecursiveTypeInfo() override = default;
800
801
    /**
802
     * Copying and moving is disallowed!
803
     * \{
804
     */
805
    RecursiveTypeInfo(const RecursiveTypeInfo&) = delete;
806
    RecursiveTypeInfo& operator=(const RecursiveTypeInfo&) = delete;
807
808
    RecursiveTypeInfo(const RecursiveTypeInfo&&) = delete;
809
    RecursiveTypeInfo& operator=(const RecursiveTypeInfo&&) = delete;
810
    /**
811
     * \}
812
     */
813
814
    StringView getSchemaName() const override;
815
    SchemaType getSchemaType() const override;
816
    CppType getCppType() const override;
817
    uint8_t getBitSize() const override;
818
819
    Span<const BasicFieldInfo<ALLOC>> getFields() const override;
820
    Span<const BasicParameterInfo<ALLOC>> getParameters() const override;
821
    Span<const BasicFunctionInfo<ALLOC>> getFunctions() const override;
822
823
    StringView getSelector() const override;
824
    Span<const BasicCaseInfo<ALLOC>> getCases() const override;
825
826
    const IBasicTypeInfo<ALLOC>& getUnderlyingType() const override;
827
    Span<const StringView> getUnderlyingTypeArguments() const override;
828
    Span<const ItemInfo> getEnumItems() const override;
829
    Span<const ItemInfo> getBitmaskValues() const override;
830
831
    Span<const BasicColumnInfo<ALLOC>> getColumns() const override;
832
    StringView getSqlConstraint() const override;
833
    StringView getVirtualTableUsing() const override;
834
    bool isWithoutRowId() const override;
835
836
    Span<const BasicTableInfo<ALLOC>> getTables() const override;
837
838
    StringView getTemplateName() const override;
839
    Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const override;
840
841
    Span<const BasicMessageInfo<ALLOC>> getMessages() const override;
842
    Span<const BasicMethodInfo<ALLOC>> getMethods() const override;
843
844
    IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const override;
845
    IBasicReflectablePtr<ALLOC> createInstance() const override;
846
847
private:
848
    TypeInfoFunc m_typeInfoFunc;
849
};
850
851
template <typename ALLOC>
852
TypeInfoBase<ALLOC>::TypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType) :
853
        m_schemaName(schemaName),
854
        m_schemaType(schemaType),
855
        m_cppType(cppType)
856
315
{}
857
858
template <typename ALLOC>
859
TypeInfoBase<ALLOC>::~TypeInfoBase() = default;
860
861
template <typename ALLOC>
862
StringView TypeInfoBase<ALLOC>::getSchemaName() const
863
16.0k
{
864
16.0k
    return m_schemaName;
865
16.0k
}
866
867
template <typename ALLOC>
868
SchemaType TypeInfoBase<ALLOC>::getSchemaType() const
869
3.76k
{
870
3.76k
    return m_schemaType;
871
3.76k
}
872
873
template <typename ALLOC>
874
CppType TypeInfoBase<ALLOC>::getCppType() const
875
970
{
876
970
    return m_cppType;
877
970
}
878
879
template <typename ALLOC>
880
uint8_t TypeInfoBase<ALLOC>::getBitSize() const
881
150
{
882
150
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a fixed size type!";
883
150
}
884
885
template <typename ALLOC>
886
Span<const BasicFieldInfo<ALLOC>> TypeInfoBase<ALLOC>::getFields() const
887
286
{
888
286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
889
286
}
890
891
template <typename ALLOC>
892
Span<const BasicParameterInfo<ALLOC>> TypeInfoBase<ALLOC>::getParameters() const
893
286
{
894
286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
895
286
}
896
897
template <typename ALLOC>
898
Span<const BasicFunctionInfo<ALLOC>> TypeInfoBase<ALLOC>::getFunctions() const
899
286
{
900
286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
901
286
}
902
903
template <typename ALLOC>
904
StringView TypeInfoBase<ALLOC>::getSelector() const
905
289
{
906
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a choice type!";
907
289
}
908
909
template <typename ALLOC>
910
Span<const BasicCaseInfo<ALLOC>> TypeInfoBase<ALLOC>::getCases() const
911
289
{
912
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a choice type!";
913
289
}
914
915
template <typename ALLOC>
916
const IBasicTypeInfo<ALLOC>& TypeInfoBase<ALLOC>::getUnderlyingType() const
917
288
{
918
288
    throw CppRuntimeException("Type '") << getSchemaName() << "' does not have underlying type!";
919
288
}
920
921
template <typename ALLOC>
922
Span<const StringView> TypeInfoBase<ALLOC>::getUnderlyingTypeArguments() const
923
288
{
924
288
    throw CppRuntimeException("Type '") << getSchemaName() << "' does not have underlying type!";
925
288
}
926
927
template <typename ALLOC>
928
Span<const ItemInfo> TypeInfoBase<ALLOC>::getEnumItems() const
929
289
{
930
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not an enum type!";
931
289
}
932
933
template <typename ALLOC>
934
Span<const ItemInfo> TypeInfoBase<ALLOC>::getBitmaskValues() const
935
289
{
936
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a bitmask type!";
937
289
}
938
939
template <typename ALLOC>
940
Span<const BasicColumnInfo<ALLOC>> TypeInfoBase<ALLOC>::getColumns() const
941
289
{
942
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
943
289
}
944
945
template <typename ALLOC>
946
StringView TypeInfoBase<ALLOC>::getSqlConstraint() const
947
289
{
948
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
949
289
}
950
951
template <typename ALLOC>
952
StringView TypeInfoBase<ALLOC>::getVirtualTableUsing() const
953
289
{
954
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
955
289
}
956
957
template <typename ALLOC>
958
bool TypeInfoBase<ALLOC>::isWithoutRowId() const
959
289
{
960
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL table type!";
961
289
}
962
963
template <typename ALLOC>
964
Span<const BasicTableInfo<ALLOC>> TypeInfoBase<ALLOC>::getTables() const
965
289
{
966
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a SQL database type!";
967
289
}
968
969
template <typename ALLOC>
970
StringView TypeInfoBase<ALLOC>::getTemplateName() const
971
285
{
972
285
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a templatable type!";
973
285
}
974
975
template <typename ALLOC>
976
Span<const BasicTemplateArgumentInfo<ALLOC>> TypeInfoBase<ALLOC>::getTemplateArguments() const
977
285
{
978
285
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a templatable type!";
979
285
}
980
981
template <typename ALLOC>
982
Span<const BasicMessageInfo<ALLOC>> TypeInfoBase<ALLOC>::getMessages() const
983
289
{
984
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a pubsub type!";
985
289
}
986
987
template <typename ALLOC>
988
Span<const BasicMethodInfo<ALLOC>> TypeInfoBase<ALLOC>::getMethods() const
989
289
{
990
289
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a service type!";
991
289
}
992
993
template <typename ALLOC>
994
IBasicReflectablePtr<ALLOC> TypeInfoBase<ALLOC>::createInstance(const ALLOC&) const
995
286
{
996
286
    throw CppRuntimeException("Type '") << getSchemaName() << "' is not a compound type!";
997
286
}
998
999
template <typename ALLOC>
1000
IBasicReflectablePtr<ALLOC> TypeInfoBase<ALLOC>::createInstance() const
1001
281
{
1002
281
    return createInstance(ALLOC());
1003
281
}
1004
1005
template <typename ALLOC>
1006
BuiltinTypeInfo<ALLOC>::BuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType) :
1007
        TypeInfoBase<ALLOC>(schemaName, schemaType, cppType)
1008
162
{}
1009
1010
template <typename ALLOC>
1011
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBool()
1012
59
{
1013
59
    return FixedSizeBuiltinTypeInfo<ALLOC>::getBool();
1014
59
}
1015
1016
template <typename ALLOC>
1017
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt8()
1018
103
{
1019
103
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt8();
1020
103
}
1021
1022
template <typename ALLOC>
1023
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt16()
1024
59
{
1025
59
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt16();
1026
59
}
1027
1028
template <typename ALLOC>
1029
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt32()
1030
64
{
1031
64
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt32();
1032
64
}
1033
1034
template <typename ALLOC>
1035
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getInt64()
1036
57
{
1037
57
    return FixedSizeBuiltinTypeInfo<ALLOC>::getInt64();
1038
57
}
1039
1040
template <typename ALLOC>
1041
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt8()
1042
124
{
1043
124
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt8();
1044
124
}
1045
1046
template <typename ALLOC>
1047
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt16()
1048
59
{
1049
59
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt16();
1050
59
}
1051
1052
template <typename ALLOC>
1053
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt32()
1054
239
{
1055
239
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt32();
1056
239
}
1057
1058
template <typename ALLOC>
1059
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getUInt64()
1060
59
{
1061
59
    return FixedSizeBuiltinTypeInfo<ALLOC>::getUInt64();
1062
59
}
1063
1064
template <typename ALLOC>
1065
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt16()
1066
13
{
1067
13
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1068
13
            makeStringView("varint16"), SchemaType::VARINT16, CppType::INT16};
1069
13
    return typeInfo;
1070
13
}
1071
1072
template <typename ALLOC>
1073
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt32()
1074
13
{
1075
13
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1076
13
            makeStringView("varint32"), SchemaType::VARINT32, CppType::INT32};
1077
13
    return typeInfo;
1078
13
}
1079
1080
template <typename ALLOC>
1081
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt64()
1082
13
{
1083
13
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1084
13
            makeStringView("varint64"), SchemaType::VARINT64, CppType::INT64};
1085
13
    return typeInfo;
1086
13
}
1087
1088
template <typename ALLOC>
1089
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarInt()
1090
14
{
1091
14
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1092
14
            makeStringView("varint"), SchemaType::VARINT, CppType::INT64};
1093
14
    return typeInfo;
1094
14
}
1095
1096
template <typename ALLOC>
1097
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt16()
1098
13
{
1099
13
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1100
13
            makeStringView("varuint16"), SchemaType::VARUINT16, CppType::UINT16};
1101
13
    return typeInfo;
1102
13
}
1103
1104
template <typename ALLOC>
1105
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt32()
1106
13
{
1107
13
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1108
13
            makeStringView("varuint32"), SchemaType::VARUINT32, CppType::UINT32};
1109
13
    return typeInfo;
1110
13
}
1111
1112
template <typename ALLOC>
1113
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt64()
1114
13
{
1115
13
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1116
13
            makeStringView("varuint64"), SchemaType::VARUINT64, CppType::UINT64};
1117
13
    return typeInfo;
1118
13
}
1119
1120
template <typename ALLOC>
1121
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarUInt()
1122
13
{
1123
13
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1124
13
            makeStringView("varuint"), SchemaType::VARUINT, CppType::UINT64};
1125
13
    return typeInfo;
1126
13
}
1127
1128
template <typename ALLOC>
1129
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getVarSize()
1130
14
{
1131
14
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1132
14
            makeStringView("varsize"), SchemaType::VARSIZE, CppType::UINT32};
1133
14
    return typeInfo;
1134
14
}
1135
1136
template <typename ALLOC>
1137
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat16()
1138
14
{
1139
14
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat16();
1140
14
}
1141
1142
template <typename ALLOC>
1143
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat32()
1144
53
{
1145
53
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat32();
1146
53
}
1147
1148
template <typename ALLOC>
1149
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFloat64()
1150
81
{
1151
81
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFloat64();
1152
81
}
1153
1154
template <typename ALLOC>
1155
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBytes()
1156
78
{
1157
78
    static const BuiltinTypeInfo<ALLOC> typeInfo = {makeStringView("bytes"), SchemaType::BYTES, CppType::BYTES};
1158
78
    return typeInfo;
1159
78
}
1160
1161
template <typename ALLOC>
1162
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getString()
1163
228
{
1164
228
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1165
228
            makeStringView("string"), SchemaType::STRING, CppType::STRING};
1166
228
    return typeInfo;
1167
228
}
1168
1169
template <typename ALLOC>
1170
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getBitBuffer()
1171
76
{
1172
76
    static const BuiltinTypeInfo<ALLOC> typeInfo = {
1173
76
            makeStringView("extern"), SchemaType::EXTERN, CppType::BIT_BUFFER};
1174
76
    return typeInfo;
1175
76
}
1176
1177
template <typename ALLOC>
1178
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFixedSignedBitField(uint8_t bitSize)
1179
321
{
1180
321
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFixedSignedBitField(bitSize);
1181
321
}
1182
1183
template <typename ALLOC>
1184
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(uint8_t bitSize)
1185
352
{
1186
352
    return FixedSizeBuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(bitSize);
1187
352
}
1188
1189
template <typename ALLOC>
1190
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getDynamicSignedBitField(uint8_t maxBitSize)
1191
291
{
1192
291
    if (maxBitSize == 0 || 
maxBitSize > 64290
)
1193
193
    {
1194
193
        throw CppRuntimeException("BuiltinTypeInfo::getDynamicSignedBitField: Invalid max bit size '")
1195
193
                << maxBitSize << "'!";
1196
193
    }
1197
1198
98
    if (maxBitSize <= 8)
1199
30
    {
1200
30
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1201
30
                "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT8};
1202
30
        return typeInfo;
1203
30
    }
1204
68
    else if (maxBitSize <= 16)
1205
12
    {
1206
12
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1207
12
                "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT16};
1208
12
        return typeInfo;
1209
12
    }
1210
56
    else if (maxBitSize <= 32)
1211
20
    {
1212
20
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1213
20
                "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT32};
1214
20
        return typeInfo;
1215
20
    }
1216
36
    else
1217
36
    {
1218
36
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1219
36
                "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT64};
1220
36
        return typeInfo;
1221
36
    }
1222
98
}
1223
1224
template <typename ALLOC>
1225
const IBasicTypeInfo<ALLOC>& BuiltinTypeInfo<ALLOC>::getDynamicUnsignedBitField(uint8_t maxBitSize)
1226
284
{
1227
284
    if (maxBitSize == 0 || 
maxBitSize > 64283
)
1228
193
    {
1229
193
        throw CppRuntimeException("BuiltinTypeInfo::getDynamicUnsignedBitField: Invalid max bit size '")
1230
193
                << maxBitSize << "'!";
1231
193
    }
1232
1233
91
    if (maxBitSize <= 8)
1234
23
    {
1235
23
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1236
23
                "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT8};
1237
23
        return typeInfo;
1238
23
    }
1239
68
    else if (maxBitSize <= 16)
1240
12
    {
1241
12
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1242
12
                "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT16};
1243
12
        return typeInfo;
1244
12
    }
1245
56
    else if (maxBitSize <= 32)
1246
20
    {
1247
20
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1248
20
                "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT32};
1249
20
        return typeInfo;
1250
20
    }
1251
36
    else
1252
36
    {
1253
36
        static const BuiltinTypeInfo<ALLOC> typeInfo = {
1254
36
                "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT64};
1255
36
        return typeInfo;
1256
36
    }
1257
91
}
1258
1259
template <typename ALLOC>
1260
FixedSizeBuiltinTypeInfo<ALLOC>::FixedSizeBuiltinTypeInfo(
1261
        StringView schemaName, SchemaType schemaType, CppType cppType, uint8_t bitSize) :
1262
        BuiltinTypeInfo<ALLOC>(schemaName, schemaType, cppType),
1263
        m_bitSize(bitSize)
1264
141
{}
1265
1266
template <typename ALLOC>
1267
uint8_t FixedSizeBuiltinTypeInfo<ALLOC>::getBitSize() const
1268
233
{
1269
233
    return m_bitSize;
1270
233
}
1271
1272
template <typename ALLOC>
1273
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getBool()
1274
59
{
1275
59
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1276
59
            makeStringView("bool"), SchemaType::BOOL, CppType::BOOL, 1};
1277
59
    return typeInfo;
1278
59
}
1279
1280
template <typename ALLOC>
1281
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt8()
1282
103
{
1283
103
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1284
103
            makeStringView("int8"), SchemaType::INT8, CppType::INT8, 8};
1285
103
    return typeInfo;
1286
103
}
1287
1288
template <typename ALLOC>
1289
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt16()
1290
59
{
1291
59
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1292
59
            makeStringView("int16"), SchemaType::INT16, CppType::INT16, 16};
1293
59
    return typeInfo;
1294
59
}
1295
1296
template <typename ALLOC>
1297
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt32()
1298
64
{
1299
64
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1300
64
            makeStringView("int32"), SchemaType::INT32, CppType::INT32, 32};
1301
64
    return typeInfo;
1302
64
}
1303
1304
template <typename ALLOC>
1305
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getInt64()
1306
57
{
1307
57
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1308
57
            makeStringView("int64"), SchemaType::INT64, CppType::INT64, 64};
1309
57
    return typeInfo;
1310
57
}
1311
1312
template <typename ALLOC>
1313
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt8()
1314
124
{
1315
124
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1316
124
            makeStringView("uint8"), SchemaType::UINT8, CppType::UINT8, 8};
1317
124
    return typeInfo;
1318
124
}
1319
1320
template <typename ALLOC>
1321
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt16()
1322
59
{
1323
59
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1324
59
            makeStringView("uint16"), SchemaType::UINT16, CppType::UINT16, 16};
1325
59
    return typeInfo;
1326
59
}
1327
1328
template <typename ALLOC>
1329
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt32()
1330
239
{
1331
239
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1332
239
            makeStringView("uint32"), SchemaType::UINT32, CppType::UINT32, 32};
1333
239
    return typeInfo;
1334
239
}
1335
1336
template <typename ALLOC>
1337
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getUInt64()
1338
59
{
1339
59
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1340
59
            makeStringView("uint64"), SchemaType::UINT64, CppType::UINT64, 64};
1341
59
    return typeInfo;
1342
59
}
1343
1344
template <typename ALLOC>
1345
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat16()
1346
14
{
1347
14
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1348
14
            makeStringView("float16"), SchemaType::FLOAT16, CppType::FLOAT, 16};
1349
14
    return typeInfo;
1350
14
}
1351
1352
template <typename ALLOC>
1353
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat32()
1354
53
{
1355
53
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1356
53
            makeStringView("float32"), SchemaType::FLOAT32, CppType::FLOAT, 32};
1357
53
    return typeInfo;
1358
53
}
1359
1360
template <typename ALLOC>
1361
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFloat64()
1362
81
{
1363
81
    static const FixedSizeBuiltinTypeInfo<ALLOC> typeInfo = {
1364
81
            makeStringView("float64"), SchemaType::FLOAT64, CppType::DOUBLE, 64};
1365
81
    return typeInfo;
1366
81
}
1367
1368
template <typename ALLOC>
1369
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFixedSignedBitField(uint8_t bitSize)
1370
321
{
1371
321
    if (bitSize == 0 || 
bitSize > 64320
)
1372
193
    {
1373
193
        throw CppRuntimeException("FixedSizeBuiltinTypeInfo::getFixedSignedBitField: Invalid bit size '")
1374
193
                << bitSize << "'!";
1375
193
    }
1376
1377
128
    static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {
1378
128
            {{"int:1"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 1},
1379
128
                    {"int:2"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 2},
1380
128
                    {"int:3"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 3},
1381
128
                    {"int:4"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 4},
1382
128
                    {"int:5"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 5},
1383
128
                    {"int:6"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 6},
1384
128
                    {"int:7"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 7},
1385
128
                    {"int:8"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT8, 8},
1386
128
                    {"int:9"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 9},
1387
128
                    {"int:10"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 10},
1388
128
                    {"int:11"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 11},
1389
128
                    {"int:12"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 12},
1390
128
                    {"int:13"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 13},
1391
128
                    {"int:14"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 14},
1392
128
                    {"int:15"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 15},
1393
128
                    {"int:16"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT16, 16},
1394
128
                    {"int:17"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 17},
1395
128
                    {"int:18"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 18},
1396
128
                    {"int:19"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 19},
1397
128
                    {"int:20"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 20},
1398
128
                    {"int:21"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 21},
1399
128
                    {"int:22"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 22},
1400
128
                    {"int:23"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 23},
1401
128
                    {"int:24"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 24},
1402
128
                    {"int:25"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 25},
1403
128
                    {"int:26"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 26},
1404
128
                    {"int:27"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 27},
1405
128
                    {"int:28"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 28},
1406
128
                    {"int:29"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 29},
1407
128
                    {"int:30"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 30},
1408
128
                    {"int:31"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 31},
1409
128
                    {"int:32"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT32, 32},
1410
128
                    {"int:33"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 33},
1411
128
                    {"int:34"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 34},
1412
128
                    {"int:35"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 35},
1413
128
                    {"int:36"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 36},
1414
128
                    {"int:37"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 37},
1415
128
                    {"int:38"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 38},
1416
128
                    {"int:39"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 39},
1417
128
                    {"int:40"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 40},
1418
128
                    {"int:41"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 41},
1419
128
                    {"int:42"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 42},
1420
128
                    {"int:43"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 43},
1421
128
                    {"int:44"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 44},
1422
128
                    {"int:45"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 45},
1423
128
                    {"int:46"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 46},
1424
128
                    {"int:47"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 47},
1425
128
                    {"int:48"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 48},
1426
128
                    {"int:49"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 49},
1427
128
                    {"int:50"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 50},
1428
128
                    {"int:51"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 51},
1429
128
                    {"int:52"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 52},
1430
128
                    {"int:53"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 53},
1431
128
                    {"int:54"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 54},
1432
128
                    {"int:55"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 55},
1433
128
                    {"int:56"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 56},
1434
128
                    {"int:57"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 57},
1435
128
                    {"int:58"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 58},
1436
128
                    {"int:59"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 59},
1437
128
                    {"int:60"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 60},
1438
128
                    {"int:61"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 61},
1439
128
                    {"int:62"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 62},
1440
128
                    {"int:63"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 63},
1441
128
                    {"int:64"_sv, SchemaType::FIXED_SIGNED_BITFIELD, CppType::INT64, 64}}};
1442
1443
128
    return bitFieldTypeInfoArray[bitSize - 1U];
1444
321
}
1445
1446
template <typename ALLOC>
1447
const IBasicTypeInfo<ALLOC>& FixedSizeBuiltinTypeInfo<ALLOC>::getFixedUnsignedBitField(uint8_t bitSize)
1448
352
{
1449
352
    if (bitSize == 0 || 
bitSize > 64351
)
1450
193
    {
1451
193
        throw CppRuntimeException("FixedSizeBuiltinTypeInfo::getFixedUnsignedBitField: Invalid bit size '")
1452
193
                << bitSize << "'!";
1453
193
    }
1454
1455
159
    static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {
1456
159
            {{"bit:1"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 1},
1457
159
                    {"bit:2"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 2},
1458
159
                    {"bit:3"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 3},
1459
159
                    {"bit:4"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 4},
1460
159
                    {"bit:5"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 5},
1461
159
                    {"bit:6"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 6},
1462
159
                    {"bit:7"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 7},
1463
159
                    {"bit:8"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT8, 8},
1464
159
                    {"bit:9"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 9},
1465
159
                    {"bit:10"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 10},
1466
159
                    {"bit:11"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 11},
1467
159
                    {"bit:12"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 12},
1468
159
                    {"bit:13"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 13},
1469
159
                    {"bit:14"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 14},
1470
159
                    {"bit:15"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 15},
1471
159
                    {"bit:16"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT16, 16},
1472
159
                    {"bit:17"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 17},
1473
159
                    {"bit:18"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 18},
1474
159
                    {"bit:19"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 19},
1475
159
                    {"bit:20"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 20},
1476
159
                    {"bit:21"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 21},
1477
159
                    {"bit:22"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 22},
1478
159
                    {"bit:23"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 23},
1479
159
                    {"bit:24"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 24},
1480
159
                    {"bit:25"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 25},
1481
159
                    {"bit:26"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 26},
1482
159
                    {"bit:27"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 27},
1483
159
                    {"bit:28"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 28},
1484
159
                    {"bit:29"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 29},
1485
159
                    {"bit:30"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 30},
1486
159
                    {"bit:31"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 31},
1487
159
                    {"bit:32"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT32, 32},
1488
159
                    {"bit:33"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 33},
1489
159
                    {"bit:34"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 34},
1490
159
                    {"bit:35"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 35},
1491
159
                    {"bit:36"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 36},
1492
159
                    {"bit:37"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 37},
1493
159
                    {"bit:38"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 38},
1494
159
                    {"bit:39"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 39},
1495
159
                    {"bit:40"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 40},
1496
159
                    {"bit:41"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 41},
1497
159
                    {"bit:42"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 42},
1498
159
                    {"bit:43"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 43},
1499
159
                    {"bit:44"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 44},
1500
159
                    {"bit:45"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 45},
1501
159
                    {"bit:46"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 46},
1502
159
                    {"bit:47"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 47},
1503
159
                    {"bit:48"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 48},
1504
159
                    {"bit:49"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 49},
1505
159
                    {"bit:50"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 50},
1506
159
                    {"bit:51"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 51},
1507
159
                    {"bit:52"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 52},
1508
159
                    {"bit:53"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 53},
1509
159
                    {"bit:54"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 54},
1510
159
                    {"bit:55"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 55},
1511
159
                    {"bit:56"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 56},
1512
159
                    {"bit:57"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 57},
1513
159
                    {"bit:58"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 58},
1514
159
                    {"bit:59"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 59},
1515
159
                    {"bit:60"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 60},
1516
159
                    {"bit:61"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 61},
1517
159
                    {"bit:62"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 62},
1518
159
                    {"bit:63"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 63},
1519
159
                    {"bit:64"_sv, SchemaType::FIXED_UNSIGNED_BITFIELD, CppType::UINT64, 64}}};
1520
1521
159
    return bitFieldTypeInfoArray[static_cast<size_t>(bitSize - 1)];
1522
352
}
1523
1524
template <typename ALLOC>
1525
TemplatableTypeInfoBase<ALLOC>::TemplatableTypeInfoBase(StringView schemaName, SchemaType schemaType,
1526
        CppType cppType, StringView templateName,
1527
        Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments) :
1528
        TypeInfoBase<ALLOC>(schemaName, schemaType, cppType),
1529
        m_templateName(templateName),
1530
        m_templateArguments(templateArguments)
1531
50
{}
1532
1533
template <typename ALLOC>
1534
TemplatableTypeInfoBase<ALLOC>::~TemplatableTypeInfoBase() = default;
1535
1536
template <typename ALLOC>
1537
StringView TemplatableTypeInfoBase<ALLOC>::getTemplateName() const
1538
6
{
1539
6
    return m_templateName;
1540
6
}
1541
1542
template <typename ALLOC>
1543
Span<const BasicTemplateArgumentInfo<ALLOC>> TemplatableTypeInfoBase<ALLOC>::getTemplateArguments() const
1544
5
{
1545
5
    return m_templateArguments;
1546
5
}
1547
1548
template <typename ALLOC>
1549
CompoundTypeInfoBase<ALLOC>::CompoundTypeInfoBase(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1550
        SchemaType schemaType, CppType cppType, StringView templateName,
1551
        Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1552
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1553
        Span<const BasicFunctionInfo<ALLOC>> functions) :
1554
        TemplatableTypeInfoBase<ALLOC>(schemaName, schemaType, cppType, templateName, templateArguments),
1555
        m_createInstanceFunc(createInstanceFunc),
1556
        m_fields(fields),
1557
        m_parameters(parameters),
1558
        m_functions(functions)
1559
49
{}
1560
1561
template <typename ALLOC>
1562
CompoundTypeInfoBase<ALLOC>::~CompoundTypeInfoBase() = default;
1563
1564
template <typename ALLOC>
1565
Span<const BasicFieldInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getFields() const
1566
731
{
1567
731
    return m_fields;
1568
731
}
1569
1570
template <typename ALLOC>
1571
Span<const BasicParameterInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getParameters() const
1572
127
{
1573
127
    return m_parameters;
1574
127
}
1575
1576
template <typename ALLOC>
1577
Span<const BasicFunctionInfo<ALLOC>> CompoundTypeInfoBase<ALLOC>::getFunctions() const
1578
69
{
1579
69
    return m_functions;
1580
69
}
1581
1582
template <typename ALLOC>
1583
IBasicReflectablePtr<ALLOC> CompoundTypeInfoBase<ALLOC>::createInstance(const ALLOC& allocator) const
1584
90
{
1585
90
    if (!m_createInstanceFunc)
1586
5
    {
1587
5
        throw CppRuntimeException("Reflectable '")
1588
5
                << getSchemaName() << "': Cannot create instance, "
1589
5
                << "either '-withoutWriterCode' or '-withoutReflectionCode' zserio option is used!";
1590
5
    }
1591
85
    return m_createInstanceFunc(allocator);
1592
90
}
1593
1594
template <typename ALLOC>
1595
StructTypeInfo<ALLOC>::StructTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1596
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1597
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1598
        Span<const BasicFunctionInfo<ALLOC>> functions) :
1599
        CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::STRUCT, CppType::STRUCT,
1600
                templateName, templateArguments, fields, parameters, functions)
1601
43
{}
1602
1603
template <typename ALLOC>
1604
UnionTypeInfo<ALLOC>::UnionTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1605
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1606
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1607
        Span<const BasicFunctionInfo<ALLOC>> functions) :
1608
        CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::UNION, CppType::UNION,
1609
                templateName, templateArguments, fields, parameters, functions)
1610
3
{}
1611
1612
template <typename ALLOC>
1613
ChoiceTypeInfo<ALLOC>::ChoiceTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc,
1614
        StringView templateName, Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1615
        Span<const BasicFieldInfo<ALLOC>> fields, Span<const BasicParameterInfo<ALLOC>> parameters,
1616
        Span<const BasicFunctionInfo<ALLOC>> functions, StringView selector,
1617
        Span<const BasicCaseInfo<ALLOC>> cases) :
1618
        CompoundTypeInfoBase<ALLOC>(schemaName, createInstanceFunc, SchemaType::CHOICE, CppType::CHOICE,
1619
                templateName, templateArguments, fields, parameters, functions),
1620
        m_selector(selector),
1621
        m_cases(cases)
1622
3
{}
1623
1624
template <typename ALLOC>
1625
StringView ChoiceTypeInfo<ALLOC>::getSelector() const
1626
1
{
1627
1
    return m_selector;
1628
1
}
1629
1630
template <typename ALLOC>
1631
Span<const BasicCaseInfo<ALLOC>> ChoiceTypeInfo<ALLOC>::getCases() const
1632
1
{
1633
1
    return m_cases;
1634
1
}
1635
1636
template <typename ALLOC>
1637
SqlTableTypeInfo<ALLOC>::SqlTableTypeInfo(StringView schemaName, StringView templateName,
1638
        Span<const BasicTemplateArgumentInfo<ALLOC>> templateArguments,
1639
        Span<const BasicColumnInfo<ALLOC>> columns, StringView sqlConstraint, StringView virtualTableUsing,
1640
        bool isWithoutRowId) :
1641
        TemplatableTypeInfoBase<ALLOC>(
1642
                schemaName, SchemaType::SQL_TABLE, CppType::SQL_TABLE, templateName, templateArguments),
1643
        m_columns(columns),
1644
        m_sqlConstraint(sqlConstraint),
1645
        m_virtualTableUsing(virtualTableUsing),
1646
        m_isWithoutRowId(isWithoutRowId)
1647
1
{}
1648
1649
template <typename ALLOC>
1650
Span<const BasicColumnInfo<ALLOC>> SqlTableTypeInfo<ALLOC>::getColumns() const
1651
1
{
1652
1
    return m_columns;
1653
1
}
1654
1655
template <typename ALLOC>
1656
StringView SqlTableTypeInfo<ALLOC>::getSqlConstraint() const
1657
1
{
1658
1
    return m_sqlConstraint;
1659
1
}
1660
1661
template <typename ALLOC>
1662
StringView SqlTableTypeInfo<ALLOC>::getVirtualTableUsing() const
1663
1
{
1664
1
    return m_virtualTableUsing;
1665
1
}
1666
1667
template <typename ALLOC>
1668
bool SqlTableTypeInfo<ALLOC>::isWithoutRowId() const
1669
1
{
1670
1
    return m_isWithoutRowId;
1671
1
}
1672
1673
template <typename ALLOC>
1674
SqlDatabaseTypeInfo<ALLOC>::SqlDatabaseTypeInfo(
1675
        StringView schemaName, Span<const BasicTableInfo<ALLOC>> tables) :
1676
        TypeInfoBase<ALLOC>(schemaName, SchemaType::SQL_DATABASE, CppType::SQL_DATABASE),
1677
        m_tables(tables)
1678
1
{}
1679
1680
template <typename ALLOC>
1681
Span<const BasicTableInfo<ALLOC>> SqlDatabaseTypeInfo<ALLOC>::getTables() const
1682
1
{
1683
1
    return m_tables;
1684
1
}
1685
1686
template <typename ALLOC>
1687
TypeInfoWithUnderlyingTypeBase<ALLOC>::TypeInfoWithUnderlyingTypeBase(StringView schemaName,
1688
        SchemaType schemaType, CppType cppType, const IBasicTypeInfo<ALLOC>& underlyingType,
1689
        Span<const StringView> underlyingTypeArguments) :
1690
        TypeInfoBase<ALLOC>(schemaName, schemaType, cppType),
1691
        m_underlyingType(underlyingType),
1692
        m_underlyingTypeArguments(underlyingTypeArguments)
1693
98
{}
1694
1695
template <typename ALLOC>
1696
const IBasicTypeInfo<ALLOC>& TypeInfoWithUnderlyingTypeBase<ALLOC>::getUnderlyingType() const
1697
79
{
1698
79
    return m_underlyingType;
1699
79
}
1700
1701
template <typename ALLOC>
1702
Span<const StringView> TypeInfoWithUnderlyingTypeBase<ALLOC>::getUnderlyingTypeArguments() const
1703
2
{
1704
2
    return m_underlyingTypeArguments;
1705
2
}
1706
1707
template <typename ALLOC>
1708
EnumTypeInfo<ALLOC>::EnumTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
1709
        Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> enumItems) :
1710
        TypeInfoWithUnderlyingTypeBase<ALLOC>(
1711
                schemaName, SchemaType::ENUM, CppType::ENUM, underlyingType, underlyingTypeArguments),
1712
        m_enumItems(enumItems)
1713
63
{}
1714
1715
template <typename ALLOC>
1716
Span<const ItemInfo> EnumTypeInfo<ALLOC>::getEnumItems() const
1717
23
{
1718
23
    return m_enumItems;
1719
23
}
1720
1721
template <typename ALLOC>
1722
BitmaskTypeInfo<ALLOC>::BitmaskTypeInfo(StringView schemaName, const IBasicTypeInfo<ALLOC>& underlyingType,
1723
        Span<const StringView> underlyingTypeArguments, Span<const ItemInfo> bitmaskValues) :
1724
        TypeInfoWithUnderlyingTypeBase<ALLOC>(
1725
                schemaName, SchemaType::BITMASK, CppType::BITMASK, underlyingType, underlyingTypeArguments),
1726
        m_bitmaskValues(bitmaskValues)
1727
35
{}
1728
1729
template <typename ALLOC>
1730
Span<const ItemInfo> BitmaskTypeInfo<ALLOC>::getBitmaskValues() const
1731
48
{
1732
48
    return m_bitmaskValues;
1733
48
}
1734
1735
template <typename ALLOC>
1736
PubsubTypeInfo<ALLOC>::PubsubTypeInfo(StringView schemaName, Span<const BasicMessageInfo<ALLOC>> messages) :
1737
        TypeInfoBase<ALLOC>(schemaName, SchemaType::PUBSUB, CppType::PUBSUB),
1738
        m_messages(messages)
1739
1
{}
1740
1741
template <typename ALLOC>
1742
Span<const BasicMessageInfo<ALLOC>> PubsubTypeInfo<ALLOC>::getMessages() const
1743
1
{
1744
1
    return m_messages;
1745
1
}
1746
1747
template <typename ALLOC>
1748
ServiceTypeInfo<ALLOC>::ServiceTypeInfo(StringView schemaName, Span<const BasicMethodInfo<ALLOC>> methods) :
1749
        TypeInfoBase<ALLOC>(schemaName, SchemaType::SERVICE, CppType::SERVICE),
1750
        m_methods(methods)
1751
1
{}
1752
1753
template <typename ALLOC>
1754
Span<const BasicMethodInfo<ALLOC>> ServiceTypeInfo<ALLOC>::getMethods() const
1755
1
{
1756
1
    return m_methods;
1757
1
}
1758
1759
template <typename ALLOC>
1760
StringView RecursiveTypeInfo<ALLOC>::getSchemaName() const
1761
1
{
1762
1
    return m_typeInfoFunc().getSchemaName();
1763
1
}
1764
1765
template <typename ALLOC>
1766
SchemaType RecursiveTypeInfo<ALLOC>::getSchemaType() const
1767
1
{
1768
1
    return m_typeInfoFunc().getSchemaType();
1769
1
}
1770
1771
template <typename ALLOC>
1772
CppType RecursiveTypeInfo<ALLOC>::getCppType() const
1773
1
{
1774
1
    return m_typeInfoFunc().getCppType();
1775
1
}
1776
1777
template <typename ALLOC>
1778
uint8_t RecursiveTypeInfo<ALLOC>::getBitSize() const
1779
1
{
1780
1
    return m_typeInfoFunc().getBitSize();
1781
1
}
1782
1783
template <typename ALLOC>
1784
Span<const BasicFieldInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getFields() const
1785
1
{
1786
1
    return m_typeInfoFunc().getFields();
1787
1
}
1788
1789
template <typename ALLOC>
1790
Span<const BasicParameterInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getParameters() const
1791
1
{
1792
1
    return m_typeInfoFunc().getParameters();
1793
1
}
1794
1795
template <typename ALLOC>
1796
Span<const BasicFunctionInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getFunctions() const
1797
1
{
1798
1
    return m_typeInfoFunc().getFunctions();
1799
1
}
1800
1801
template <typename ALLOC>
1802
StringView RecursiveTypeInfo<ALLOC>::getSelector() const
1803
1
{
1804
1
    return m_typeInfoFunc().getSelector();
1805
1
}
1806
1807
template <typename ALLOC>
1808
Span<const BasicCaseInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getCases() const
1809
1
{
1810
1
    return m_typeInfoFunc().getCases();
1811
1
}
1812
1813
template <typename ALLOC>
1814
const IBasicTypeInfo<ALLOC>& RecursiveTypeInfo<ALLOC>::getUnderlyingType() const
1815
1
{
1816
1
    return m_typeInfoFunc().getUnderlyingType();
1817
1
}
1818
1819
template <typename ALLOC>
1820
Span<const StringView> RecursiveTypeInfo<ALLOC>::getUnderlyingTypeArguments() const
1821
1
{
1822
1
    return m_typeInfoFunc().getUnderlyingTypeArguments();
1823
1
}
1824
1825
template <typename ALLOC>
1826
Span<const ItemInfo> RecursiveTypeInfo<ALLOC>::getEnumItems() const
1827
1
{
1828
1
    return m_typeInfoFunc().getEnumItems();
1829
1
}
1830
1831
template <typename ALLOC>
1832
Span<const ItemInfo> RecursiveTypeInfo<ALLOC>::getBitmaskValues() const
1833
1
{
1834
1
    return m_typeInfoFunc().getBitmaskValues();
1835
1
}
1836
1837
template <typename ALLOC>
1838
Span<const BasicColumnInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getColumns() const
1839
1
{
1840
1
    return m_typeInfoFunc().getColumns();
1841
1
}
1842
1843
template <typename ALLOC>
1844
StringView RecursiveTypeInfo<ALLOC>::getSqlConstraint() const
1845
1
{
1846
1
    return m_typeInfoFunc().getSqlConstraint();
1847
1
}
1848
1849
template <typename ALLOC>
1850
StringView RecursiveTypeInfo<ALLOC>::getVirtualTableUsing() const
1851
1
{
1852
1
    return m_typeInfoFunc().getVirtualTableUsing();
1853
1
}
1854
1855
template <typename ALLOC>
1856
bool RecursiveTypeInfo<ALLOC>::isWithoutRowId() const
1857
1
{
1858
1
    return m_typeInfoFunc().isWithoutRowId();
1859
1
}
1860
1861
template <typename ALLOC>
1862
Span<const BasicTableInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getTables() const
1863
1
{
1864
1
    return m_typeInfoFunc().getTables();
1865
1
}
1866
1867
template <typename ALLOC>
1868
StringView RecursiveTypeInfo<ALLOC>::getTemplateName() const
1869
1
{
1870
1
    return m_typeInfoFunc().getTemplateName();
1871
1
}
1872
1873
template <typename ALLOC>
1874
Span<const BasicTemplateArgumentInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getTemplateArguments() const
1875
1
{
1876
1
    return m_typeInfoFunc().getTemplateArguments();
1877
1
}
1878
1879
template <typename ALLOC>
1880
Span<const BasicMessageInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getMessages() const
1881
1
{
1882
1
    return m_typeInfoFunc().getMessages();
1883
1
}
1884
1885
template <typename ALLOC>
1886
Span<const BasicMethodInfo<ALLOC>> RecursiveTypeInfo<ALLOC>::getMethods() const
1887
1
{
1888
1
    return m_typeInfoFunc().getMethods();
1889
1
}
1890
1891
template <typename ALLOC>
1892
IBasicReflectablePtr<ALLOC> RecursiveTypeInfo<ALLOC>::createInstance(const ALLOC& allocator) const
1893
2
{
1894
2
    return m_typeInfoFunc().createInstance(allocator);
1895
2
}
1896
1897
template <typename ALLOC>
1898
IBasicReflectablePtr<ALLOC> RecursiveTypeInfo<ALLOC>::createInstance() const
1899
1
{
1900
1
    return createInstance(ALLOC());
1901
1
}
1902
1903
} // namespace zserio
1904
1905
#endif // ZSERIO_TYPE_INFO_INC_H