Zserio C++ runtime library  1.1.0
Built for Zserio 2.15.0
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 "zserio/IReflectable.h"
5 #include "zserio/Span.h"
6 #include "zserio/StringView.h"
7 
8 namespace zserio
9 {
10 
12 enum class CppType
13 {
14  BOOL,
15  INT8,
16  INT16,
17  INT32,
18  INT64,
19  UINT8,
20  UINT16,
21  UINT32,
22  UINT64,
23  FLOAT,
24  DOUBLE,
25  BYTES,
26  STRING,
27  BIT_BUFFER,
28  ENUM,
29  BITMASK,
30  STRUCT,
31  CHOICE,
32  UNION,
33  SQL_TABLE,
34  SQL_DATABASE,
35  SERVICE,
36  PUBSUB
37 };
38 
40 enum class SchemaType
41 {
42  BOOL,
43  INT8,
44  INT16,
45  INT32,
46  INT64,
47  UINT8,
48  UINT16,
49  UINT32,
50  UINT64,
51  VARINT16,
52  VARINT32,
53  VARINT64,
54  VARINT,
55  VARUINT16,
56  VARUINT32,
57  VARUINT64,
58  VARUINT,
59  VARSIZE,
64  FLOAT16,
65  FLOAT32,
66  FLOAT64,
67  BYTES,
68  STRING,
69  EXTERN,
70  ENUM,
71  BITMASK,
72  STRUCT,
73  CHOICE,
74  UNION,
75  SQL_TABLE,
76  SQL_DATABASE,
77  SERVICE,
78  PUBSUB
79 };
80 
81 // forward declarations
82 template <typename ALLOC>
83 struct BasicFieldInfo;
84 template <typename ALLOC>
85 struct BasicParameterInfo;
86 template <typename ALLOC>
87 struct BasicFunctionInfo;
88 template <typename ALLOC>
89 struct BasicCaseInfo;
90 template <typename ALLOC>
91 struct BasicColumnInfo;
92 template <typename ALLOC>
93 struct BasicTableInfo;
94 struct ItemInfo;
95 template <typename ALLOC>
96 struct BasicTemplateArgumentInfo;
97 template <typename ALLOC>
98 struct BasicMessageInfo;
99 template <typename ALLOC>
100 struct BasicMethodInfo;
101 
111 template <typename ALLOC = std::allocator<uint8_t>>
113 {
114 public:
118  virtual ~IBasicTypeInfo() = default;
119 
125  virtual StringView getSchemaName() const = 0;
126 
132  virtual SchemaType getSchemaType() const = 0;
133 
139  virtual CppType getCppType() const = 0;
140 
141  // method for fixed size integral types
142 
150  virtual uint8_t getBitSize() const = 0;
151 
152  // methods for compound types
153 
162 
171 
180 
181  // methods for choice type
182 
190  virtual StringView getSelector() const = 0;
191 
200 
201  // methods for enumeration and bitmask types
202 
210  virtual const IBasicTypeInfo<ALLOC>& getUnderlyingType() const = 0;
211 
220 
228  virtual Span<const ItemInfo> getEnumItems() const = 0;
229 
238 
239  // methods for SQL table types
240 
249 
257  virtual StringView getSqlConstraint() const = 0;
258 
266  virtual StringView getVirtualTableUsing() const = 0;
267 
275  virtual bool isWithoutRowId() const = 0;
276 
277  // method for SQL database type
278 
287 
288  // methods for templatable types
289 
297  virtual StringView getTemplateName() const = 0;
298 
307 
308  // method for pubsub type
309 
318 
319  // method for service type
320 
329 
339  virtual IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const = 0;
340 
351 };
352 
356 template <typename ALLOC = std::allocator<uint8_t>>
358 {
359  BasicFieldInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_,
360  Span<const StringView> typeArguments_, bool isExtended_, StringView alignment_, StringView offset_,
361  StringView initializer_, bool isOptional_, StringView optionalCondition_, StringView constraint_,
362  bool isArray_, StringView arrayLength_, bool isPacked_, bool isImplicit_) :
363  schemaName(schemaName_),
364  typeInfo(typeInfo_),
365  typeArguments(typeArguments_),
366  isExtended(isExtended_),
367  alignment(alignment_),
368  offset(offset_),
369  initializer(initializer_),
370  isOptional(isOptional_),
371  optionalCondition(optionalCondition_),
372  constraint(constraint_),
373  isArray(isArray_),
374  arrayLength(arrayLength_),
375  isPacked(isPacked_),
376  isImplicit(isImplicit_)
377  {}
378 
382  bool isExtended;
386  bool isOptional;
389  bool isArray;
391  bool isPacked;
392  bool isImplicit;
393 };
394 
398 template <typename ALLOC = std::allocator<uint8_t>>
400 {
403 };
404 
408 template <typename ALLOC = std::allocator<uint8_t>>
410 {
414 };
415 
419 template <typename ALLOC = std::allocator<uint8_t>>
421 {
424 };
425 
429 struct ItemInfo
430 {
431  ItemInfo(StringView schemaName_, uint64_t value_, bool isDeprecated_, bool isRemoved_) :
432  schemaName(schemaName_),
433  value(value_),
434  isDeprecated(isDeprecated_),
435  isRemoved(isRemoved_)
436  {}
437 
439  uint64_t value;
441  bool isRemoved;
442 };
443 
447 template <typename ALLOC = std::allocator<uint8_t>>
449 {
450  BasicColumnInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_,
451  Span<const StringView> typeArguments_, StringView sqlTypeName_, StringView sqlConstraint_,
452  bool isVirtual_) :
453  schemaName(schemaName_),
454  typeInfo(typeInfo_),
455  typeArguments(typeArguments_),
456  sqlTypeName(sqlTypeName_),
457  sqlConstraint(sqlConstraint_),
458  isVirtual(isVirtual_)
459  {}
460 
466  bool isVirtual;
467 };
468 
472 template <typename ALLOC = std::allocator<uint8_t>>
474 {
477 };
478 
482 template <typename ALLOC = std::allocator<uint8_t>>
484 {
486 };
487 
491 template <typename ALLOC = std::allocator<uint8_t>>
493 {
494  BasicMessageInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_, bool isPublished_,
495  bool isSubscribed_, StringView topic_) :
496  schemaName(schemaName_),
497  typeInfo(typeInfo_),
498  isPublished(isPublished_),
499  isSubscribed(isSubscribed_),
500  topic(topic_)
501  {}
502 
505  bool isPublished;
508 };
509 
513 template <typename ALLOC = std::allocator<uint8_t>>
515 {
522 };
523 
529 template <typename T, typename ALLOC = std::allocator<uint8_t>>
531 
546 } // namespace zserio
547 
548 #endif // ZSERIO_I_TYPE_INFO_INC_H
virtual Span< const BasicMethodInfo< ALLOC > > getMethods() const =0
virtual StringView getSchemaName() const =0
virtual Span< const BasicTemplateArgumentInfo< ALLOC > > getTemplateArguments() const =0
virtual Span< const BasicCaseInfo< ALLOC > > getCases() const =0
virtual StringView getSelector() const =0
virtual ~IBasicTypeInfo()=default
virtual Span< const BasicFieldInfo< ALLOC > > getFields() const =0
virtual IBasicReflectablePtr< ALLOC > createInstance() const =0
virtual uint8_t getBitSize() const =0
virtual bool isWithoutRowId() const =0
virtual Span< const BasicParameterInfo< ALLOC > > getParameters() const =0
virtual const IBasicTypeInfo< ALLOC > & getUnderlyingType() const =0
virtual Span< const BasicMessageInfo< ALLOC > > getMessages() const =0
virtual StringView getSqlConstraint() const =0
virtual Span< const BasicTableInfo< ALLOC > > getTables() const =0
virtual StringView getVirtualTableUsing() const =0
virtual StringView getTemplateName() const =0
virtual Span< const BasicFunctionInfo< ALLOC > > getFunctions() const =0
virtual Span< const BasicColumnInfo< ALLOC > > getColumns() const =0
virtual CppType getCppType() const =0
virtual Span< const ItemInfo > getEnumItems() const =0
virtual IBasicReflectablePtr< ALLOC > createInstance(const ALLOC &allocator) const =0
virtual SchemaType getSchemaType() const =0
virtual Span< const ItemInfo > getBitmaskValues() const =0
virtual Span< const StringView > getUnderlyingTypeArguments() const =0
const IBasicTypeInfo< ALLOC > & enumTypeInfo()
SchemaType
Definition: ITypeInfo.h:41
typename IBasicReflectable< ALLOC >::Ptr IBasicReflectablePtr
Definition: IReflectable.h:531
const BasicFieldInfo< ALLOC > * field
Definition: ITypeInfo.h:423
Span< const StringView > caseExpressions
Definition: ITypeInfo.h:422
Span< const StringView > typeArguments
Definition: ITypeInfo.h:463
StringView sqlTypeName
Definition: ITypeInfo.h:464
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:462
BasicColumnInfo(StringView schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, Span< const StringView > typeArguments_, StringView sqlTypeName_, StringView sqlConstraint_, bool isVirtual_)
Definition: ITypeInfo.h:450
StringView sqlConstraint
Definition: ITypeInfo.h:465
StringView alignment
Definition: ITypeInfo.h:383
StringView schemaName
Definition: ITypeInfo.h:379
Span< const StringView > typeArguments
Definition: ITypeInfo.h:381
StringView optionalCondition
Definition: ITypeInfo.h:387
StringView initializer
Definition: ITypeInfo.h:385
StringView constraint
Definition: ITypeInfo.h:388
BasicFieldInfo(StringView schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, Span< const StringView > typeArguments_, bool isExtended_, StringView alignment_, StringView offset_, StringView initializer_, bool isOptional_, StringView optionalCondition_, StringView constraint_, bool isArray_, StringView arrayLength_, bool isPacked_, bool isImplicit_)
Definition: ITypeInfo.h:359
StringView arrayLength
Definition: ITypeInfo.h:390
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:380
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:412
BasicMessageInfo(StringView schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, bool isPublished_, bool isSubscribed_, StringView topic_)
Definition: ITypeInfo.h:494
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:504
const IBasicTypeInfo< ALLOC > & requestTypeInfo
Definition: ITypeInfo.h:521
const IBasicTypeInfo< ALLOC > & responseTypeInfo
Definition: ITypeInfo.h:519
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:402
StringView schemaName
Definition: ITypeInfo.h:475
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:476
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:485
uint64_t value
Definition: ITypeInfo.h:439
ItemInfo(StringView schemaName_, uint64_t value_, bool isDeprecated_, bool isRemoved_)
Definition: ITypeInfo.h:431
StringView schemaName
Definition: ITypeInfo.h:438