Zserio C++17 runtime library 1.3.0
Built for Zserio 2.20.0
Loading...
Searching...
No Matches
ITypeInfo.h
Go to the documentation of this file.
1#ifndef ZSERIO_I_TYPE_INFO_INC_H
2#define ZSERIO_I_TYPE_INFO_INC_H
3
4#include <string_view>
5
7#include "zserio/Span.h"
8#include "zserio/Traits.h"
9
10namespace zserio
11{
12
14enum class CppType
15{
16 BOOL,
17 INT8,
18 INT16,
19 INT32,
20 INT64,
21 UINT8,
22 UINT16,
23 UINT32,
24 UINT64,
25 FLOAT,
26 DOUBLE,
27 BYTES,
28 STRING,
30 ENUM,
31 BITMASK,
32 STRUCT,
33 CHOICE,
34 UNION,
35 SQL_TABLE,
37 SERVICE,
38 PUBSUB
39};
40
41// TODO[Mi-L@]: Do we still need STD integers?
42// Currently not used since runtime won't recognize bit:16 and uint16.
44enum class SchemaType
45{
46 BOOL,
47 INT1,
48 INT2,
49 INT3,
50 INT4,
51 INT5,
52 INT6,
53 INT7,
54 INT8,
55 INT9,
56 INT10,
57 INT11,
58 INT12,
59 INT13,
60 INT14,
61 INT15,
62 INT16,
63 INT17,
64 INT18,
65 INT19,
66 INT20,
67 INT21,
68 INT22,
69 INT23,
70 INT24,
71 INT25,
72 INT26,
73 INT27,
74 INT28,
75 INT29,
76 INT30,
77 INT31,
78 INT32,
79 INT33,
80 INT34,
81 INT35,
82 INT36,
83 INT37,
84 INT38,
85 INT39,
86 INT40,
87 INT41,
88 INT42,
89 INT43,
90 INT44,
91 INT45,
92 INT46,
93 INT47,
94 INT48,
95 INT49,
96 INT50,
97 INT51,
98 INT52,
99 INT53,
100 INT54,
101 INT55,
102 INT56,
103 INT57,
104 INT58,
105 INT59,
106 INT60,
107 INT61,
108 INT62,
109 INT63,
110 INT64,
111 UINT1,
112 UINT2,
113 UINT3,
114 UINT4,
115 UINT5,
116 UINT6,
117 UINT7,
118 UINT8,
119 UINT9,
120 UINT10,
121 UINT11,
122 UINT12,
123 UINT13,
124 UINT14,
125 UINT15,
126 UINT16,
127 UINT17,
128 UINT18,
129 UINT19,
130 UINT20,
131 UINT21,
132 UINT22,
133 UINT23,
134 UINT24,
135 UINT25,
136 UINT26,
137 UINT27,
138 UINT28,
139 UINT29,
140 UINT30,
141 UINT31,
142 UINT32,
143 UINT33,
144 UINT34,
145 UINT35,
146 UINT36,
147 UINT37,
148 UINT38,
149 UINT39,
150 UINT40,
151 UINT41,
152 UINT42,
153 UINT43,
154 UINT44,
155 UINT45,
156 UINT46,
157 UINT47,
158 UINT48,
159 UINT49,
160 UINT50,
161 UINT51,
162 UINT52,
163 UINT53,
164 UINT54,
165 UINT55,
166 UINT56,
167 UINT57,
168 UINT58,
169 UINT59,
170 UINT60,
171 UINT61,
172 UINT62,
173 UINT63,
174 UINT64,
175 VARINT16,
176 VARINT32,
177 VARINT64,
178 VARINT,
179 VARUINT16,
180 VARUINT32,
181 VARUINT64,
182 VARUINT,
183 VARSIZE,
186 FLOAT16,
187 FLOAT32,
188 FLOAT64,
189 BYTES,
190 STRING,
191 EXTERN,
192 ENUM,
193 BITMASK,
194 STRUCT,
195 CHOICE,
196 UNION,
197 SQL_TABLE,
199 SERVICE,
200 PUBSUB
201};
202
203// forward declarations
204template <typename ALLOC>
205struct BasicFieldInfo;
206template <typename ALLOC>
207struct BasicParameterInfo;
208template <typename ALLOC>
209struct BasicFunctionInfo;
210template <typename ALLOC>
211struct BasicCaseInfo;
212template <typename ALLOC>
213struct BasicColumnInfo;
214template <typename ALLOC>
215struct BasicTableInfo;
216struct ItemInfo;
217template <typename ALLOC>
218struct BasicTemplateArgumentInfo;
219template <typename ALLOC>
220struct BasicMessageInfo;
221template <typename ALLOC>
222struct BasicMethodInfo;
223
233template <typename ALLOC = std::allocator<uint8_t>>
235{
236public:
240 virtual ~IBasicTypeInfo() = default;
241
247 virtual std::string_view getSchemaName() const = 0;
248
254 virtual SchemaType getSchemaType() const = 0;
255
261 virtual CppType getCppType() const = 0;
262
263 // method for fixed size integral types
264
272 virtual uint8_t getBitSize() const = 0;
273
274 // methods for compound types
275
284
293
302
303 // methods for choice type
304
312 virtual std::string_view getSelector() const = 0;
313
322
323 // methods for enumeration and bitmask types
324
332 virtual const IBasicTypeInfo<ALLOC>& getUnderlyingType() const = 0;
333
342
351
352 // methods for SQL table types
353
362
370 virtual std::string_view getSqlConstraint() const = 0;
371
379 virtual std::string_view getVirtualTableUsing() const = 0;
380
388 virtual bool isWithoutRowId() const = 0;
389
390 // method for SQL database type
391
400
401 // methods for templatable types
402
410 virtual std::string_view getTemplateName() const = 0;
411
420
421 // method for pubsub type
422
431
432 // method for service type
433
442
453
464};
465
469template <typename ALLOC = std::allocator<uint8_t>>
471{
492
493 std::string_view schemaName;
497 std::string_view alignment;
498 std::string_view offset;
499 std::string_view initializer;
501 std::string_view optionalCondition;
502 std::string_view constraint;
503 bool isArray;
504 std::string_view arrayLength;
505 bool isPacked;
507};
508
512template <typename ALLOC = std::allocator<uint8_t>>
514{
515 std::string_view schemaName;
517};
518
522template <typename ALLOC = std::allocator<uint8_t>>
524{
525 std::string_view schemaName;
527 std::string_view functionResult;
528};
529
533template <typename ALLOC = std::allocator<uint8_t>>
539
557
561template <typename ALLOC = std::allocator<uint8_t>>
582
586template <typename ALLOC = std::allocator<uint8_t>>
588{
589 std::string_view schemaName;
591};
592
596template <typename ALLOC = std::allocator<uint8_t>>
601
605template <typename ALLOC = std::allocator<uint8_t>>
607{
616
617 std::string_view schemaName;
621 std::string_view topic;
622};
623
627template <typename ALLOC = std::allocator<uint8_t>>
637
638namespace detail
639{
640
642template <typename T, typename ALLOC>
643struct TypeInfo;
644
645template <typename T, typename V = void>
646struct type_info_default_alloc
647{
648 using type = std::allocator<uint8_t>;
649};
650
651template <typename T>
652struct type_info_default_alloc<T, std::enable_if_t<has_allocator_v<T>>>
653{
654 using type = RebindAlloc<typename T::allocator_type, uint8_t>;
655};
656
657template <typename T, typename V = void>
658using type_info_default_alloc_t = typename type_info_default_alloc<T, V>::type;
659
660} // namespace detail
661
667template <typename T, typename ALLOC = detail::type_info_default_alloc_t<T>>
669{
670 return detail::TypeInfo<T, ALLOC>::get();
671}
672
687} // namespace zserio
688
689#endif // ZSERIO_I_TYPE_INFO_INC_H
virtual IBasicReflectableDataPtr< ALLOC > createInstance(const ALLOC &allocator) const =0
virtual Span< const BasicFunctionInfo< ALLOC > > getFunctions() const =0
virtual ~IBasicTypeInfo()=default
virtual std::string_view getVirtualTableUsing() const =0
virtual uint8_t getBitSize() const =0
virtual Span< const ItemInfo > getBitmaskValues() const =0
virtual bool isWithoutRowId() const =0
virtual IBasicReflectableDataPtr< ALLOC > createInstance() const =0
virtual Span< const BasicColumnInfo< ALLOC > > getColumns() const =0
virtual Span< const BasicMethodInfo< ALLOC > > getMethods() const =0
virtual std::string_view getSqlConstraint() const =0
virtual Span< const BasicMessageInfo< ALLOC > > getMessages() const =0
virtual Span< const BasicFieldInfo< ALLOC > > getFields() const =0
virtual Span< const BasicParameterInfo< ALLOC > > getParameters() const =0
virtual Span< const ItemInfo > getEnumItems() const =0
virtual Span< const BasicTableInfo< ALLOC > > getTables() const =0
virtual std::string_view getTemplateName() const =0
virtual CppType getCppType() const =0
virtual Span< const BasicTemplateArgumentInfo< ALLOC > > getTemplateArguments() const =0
virtual const IBasicTypeInfo< ALLOC > & getUnderlyingType() const =0
virtual SchemaType getSchemaType() const =0
virtual Span< const BasicCaseInfo< ALLOC > > getCases() const =0
virtual std::string_view getSelector() const =0
virtual std::string_view getSchemaName() const =0
const IBasicTypeInfo< ALLOC > & typeInfo()
Definition ITypeInfo.h:668
const BasicFieldInfo< ALLOC > * field
Definition ITypeInfo.h:537
Span< const std::string_view > caseExpressions
Definition ITypeInfo.h:536
std::string_view schemaName
Definition ITypeInfo.h:575
Span< const std::string_view > typeArguments
Definition ITypeInfo.h:577
const IBasicTypeInfo< ALLOC > & typeInfo
Definition ITypeInfo.h:576
std::string_view sqlConstraint
Definition ITypeInfo.h:579
BasicColumnInfo(std::string_view schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, Span< const std::string_view > typeArguments_, std::string_view sqlTypeName_, std::string_view sqlConstraint_, bool isVirtual_)
Definition ITypeInfo.h:564
std::string_view sqlTypeName
Definition ITypeInfo.h:578
std::string_view arrayLength
Definition ITypeInfo.h:504
std::string_view constraint
Definition ITypeInfo.h:502
BasicFieldInfo(std::string_view schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, Span< const std::string_view > typeArguments_, bool isExtended_, std::string_view alignment_, std::string_view offset_, std::string_view initializer_, bool isOptional_, std::string_view optionalCondition_, std::string_view constraint_, bool isArray_, std::string_view arrayLength_, bool isPacked_, bool isImplicit_)
Definition ITypeInfo.h:472
std::string_view offset
Definition ITypeInfo.h:498
std::string_view schemaName
Definition ITypeInfo.h:493
std::string_view initializer
Definition ITypeInfo.h:499
Span< const std::string_view > typeArguments
Definition ITypeInfo.h:495
std::string_view optionalCondition
Definition ITypeInfo.h:501
std::string_view alignment
Definition ITypeInfo.h:497
const IBasicTypeInfo< ALLOC > & typeInfo
Definition ITypeInfo.h:494
const IBasicTypeInfo< ALLOC > & typeInfo
Definition ITypeInfo.h:526
std::string_view schemaName
Definition ITypeInfo.h:525
std::string_view functionResult
Definition ITypeInfo.h:527
std::string_view schemaName
Definition ITypeInfo.h:617
BasicMessageInfo(std::string_view schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, bool isPublished_, bool isSubscribed_, std::string_view topic_)
Definition ITypeInfo.h:608
const IBasicTypeInfo< ALLOC > & typeInfo
Definition ITypeInfo.h:618
std::string_view topic
Definition ITypeInfo.h:621
std::string_view schemaName
Definition ITypeInfo.h:631
const IBasicTypeInfo< ALLOC > & requestTypeInfo
Definition ITypeInfo.h:635
const IBasicTypeInfo< ALLOC > & responseTypeInfo
Definition ITypeInfo.h:633
std::string_view schemaName
Definition ITypeInfo.h:515
const IBasicTypeInfo< ALLOC > & typeInfo
Definition ITypeInfo.h:516
std::string_view schemaName
Definition ITypeInfo.h:589
const IBasicTypeInfo< ALLOC > & typeInfo
Definition ITypeInfo.h:590
const IBasicTypeInfo< ALLOC > & typeInfo
Definition ITypeInfo.h:599
ItemInfo(std::string_view schemaName_, uint64_t value_, bool isDeprecated_, bool isRemoved_)
Definition ITypeInfo.h:545
std::string_view schemaName
Definition ITypeInfo.h:552