Zserio C++ runtime library  1.3.0
Built for Zserio 2.18.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 #include "zserio/Types.h"
8 
9 namespace zserio
10 {
11 
13 enum class CppType
14 {
15  BOOL,
16  INT8,
17  INT16,
18  INT32,
19  INT64,
20  UINT8,
21  UINT16,
22  UINT32,
23  UINT64,
24  FLOAT,
25  DOUBLE,
26  BYTES,
27  STRING,
28  BIT_BUFFER,
29  ENUM,
30  BITMASK,
31  STRUCT,
32  CHOICE,
33  UNION,
34  SQL_TABLE,
35  SQL_DATABASE,
36  SERVICE,
37  PUBSUB
38 };
39 
41 enum class SchemaType
42 {
43  BOOL,
44  INT8,
45  INT16,
46  INT32,
47  INT64,
48  UINT8,
49  UINT16,
50  UINT32,
51  UINT64,
52  VARINT16,
53  VARINT32,
54  VARINT64,
55  VARINT,
56  VARUINT16,
57  VARUINT32,
58  VARUINT64,
59  VARUINT,
60  VARSIZE,
65  FLOAT16,
66  FLOAT32,
67  FLOAT64,
68  BYTES,
69  STRING,
70  EXTERN,
71  ENUM,
72  BITMASK,
73  STRUCT,
74  CHOICE,
75  UNION,
76  SQL_TABLE,
77  SQL_DATABASE,
78  SERVICE,
79  PUBSUB
80 };
81 
82 // forward declarations
83 template <typename ALLOC>
84 struct BasicFieldInfo;
85 template <typename ALLOC>
86 struct BasicParameterInfo;
87 template <typename ALLOC>
88 struct BasicFunctionInfo;
89 template <typename ALLOC>
90 struct BasicCaseInfo;
91 template <typename ALLOC>
92 struct BasicColumnInfo;
93 template <typename ALLOC>
94 struct BasicTableInfo;
95 struct ItemInfo;
96 template <typename ALLOC>
97 struct BasicTemplateArgumentInfo;
98 template <typename ALLOC>
99 struct BasicMessageInfo;
100 template <typename ALLOC>
101 struct BasicMethodInfo;
102 
112 template <typename ALLOC = std::allocator<uint8_t>>
114 {
115 public:
119  virtual ~IBasicTypeInfo() = default;
120 
126  virtual StringView getSchemaName() const = 0;
127 
133  virtual SchemaType getSchemaType() const = 0;
134 
140  virtual CppType getCppType() const = 0;
141 
142  // method for fixed size integral types
143 
151  virtual uint8_t getBitSize() const = 0;
152 
153  // methods for compound types
154 
163 
172 
181 
182  // methods for choice type
183 
191  virtual StringView getSelector() const = 0;
192 
201 
202  // methods for enumeration and bitmask types
203 
211  virtual const IBasicTypeInfo<ALLOC>& getUnderlyingType() const = 0;
212 
221 
229  virtual Span<const ItemInfo> getEnumItems() const = 0;
230 
239 
240  // methods for SQL table types
241 
250 
258  virtual StringView getSqlConstraint() const = 0;
259 
267  virtual StringView getVirtualTableUsing() const = 0;
268 
276  virtual bool isWithoutRowId() const = 0;
277 
278  // method for SQL database type
279 
288 
289  // methods for templatable types
290 
298  virtual StringView getTemplateName() const = 0;
299 
308 
309  // method for pubsub type
310 
319 
320  // method for service type
321 
330 
340  virtual IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const = 0;
341 
352 };
353 
357 template <typename ALLOC = std::allocator<uint8_t>>
359 {
360  BasicFieldInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_,
361  Span<const StringView> typeArguments_, bool isExtended_, StringView alignment_, StringView offset_,
362  StringView initializer_, bool isOptional_, StringView optionalCondition_, StringView constraint_,
363  bool isArray_, StringView arrayLength_, bool isPacked_, bool isImplicit_) :
364  schemaName(schemaName_),
365  typeInfo(typeInfo_),
366  typeArguments(typeArguments_),
367  isExtended(isExtended_),
368  alignment(alignment_),
369  offset(offset_),
370  initializer(initializer_),
371  isOptional(isOptional_),
372  optionalCondition(optionalCondition_),
373  constraint(constraint_),
374  isArray(isArray_),
375  arrayLength(arrayLength_),
376  isPacked(isPacked_),
377  isImplicit(isImplicit_)
378  {}
379 
383  bool isExtended;
387  bool isOptional;
390  bool isArray;
392  bool isPacked;
393  bool isImplicit;
394 };
395 
399 template <typename ALLOC = std::allocator<uint8_t>>
401 {
404 };
405 
409 template <typename ALLOC = std::allocator<uint8_t>>
411 {
415 };
416 
420 template <typename ALLOC = std::allocator<uint8_t>>
422 {
425 };
426 
430 struct ItemInfo
431 {
432  ItemInfo(StringView schemaName_, uint64_t value_, bool isDeprecated_, bool isRemoved_) :
433  schemaName(schemaName_),
434  value(value_),
435  isDeprecated(isDeprecated_),
436  isRemoved(isRemoved_)
437  {}
438 
440  uint64_t value;
442  bool isRemoved;
443 };
444 
448 template <typename ALLOC = std::allocator<uint8_t>>
450 {
451  BasicColumnInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_,
452  Span<const StringView> typeArguments_, StringView sqlTypeName_, StringView sqlConstraint_,
453  bool isVirtual_) :
454  schemaName(schemaName_),
455  typeInfo(typeInfo_),
456  typeArguments(typeArguments_),
457  sqlTypeName(sqlTypeName_),
458  sqlConstraint(sqlConstraint_),
459  isVirtual(isVirtual_)
460  {}
461 
467  bool isVirtual;
468 };
469 
473 template <typename ALLOC = std::allocator<uint8_t>>
475 {
478 };
479 
483 template <typename ALLOC = std::allocator<uint8_t>>
485 {
487 };
488 
492 template <typename ALLOC = std::allocator<uint8_t>>
494 {
495  BasicMessageInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_, bool isPublished_,
496  bool isSubscribed_, StringView topic_) :
497  schemaName(schemaName_),
498  typeInfo(typeInfo_),
499  isPublished(isPublished_),
500  isSubscribed(isSubscribed_),
501  topic(topic_)
502  {}
503 
506  bool isPublished;
509 };
510 
514 template <typename ALLOC = std::allocator<uint8_t>>
516 {
523 };
524 
530 template <typename T, typename ALLOC = std::allocator<uint8_t>>
532 
547 } // namespace zserio
548 
549 #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:42
typename IBasicReflectable< ALLOC >::Ptr IBasicReflectablePtr
Definition: IReflectable.h:532
const BasicFieldInfo< ALLOC > * field
Definition: ITypeInfo.h:424
Span< const StringView > caseExpressions
Definition: ITypeInfo.h:423
Span< const StringView > typeArguments
Definition: ITypeInfo.h:464
StringView sqlTypeName
Definition: ITypeInfo.h:465
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:463
BasicColumnInfo(StringView schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, Span< const StringView > typeArguments_, StringView sqlTypeName_, StringView sqlConstraint_, bool isVirtual_)
Definition: ITypeInfo.h:451
StringView sqlConstraint
Definition: ITypeInfo.h:466
StringView alignment
Definition: ITypeInfo.h:384
StringView schemaName
Definition: ITypeInfo.h:380
Span< const StringView > typeArguments
Definition: ITypeInfo.h:382
StringView optionalCondition
Definition: ITypeInfo.h:388
StringView initializer
Definition: ITypeInfo.h:386
StringView constraint
Definition: ITypeInfo.h:389
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:360
StringView arrayLength
Definition: ITypeInfo.h:391
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:381
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:413
BasicMessageInfo(StringView schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, bool isPublished_, bool isSubscribed_, StringView topic_)
Definition: ITypeInfo.h:495
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:505
const IBasicTypeInfo< ALLOC > & requestTypeInfo
Definition: ITypeInfo.h:522
const IBasicTypeInfo< ALLOC > & responseTypeInfo
Definition: ITypeInfo.h:520
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:403
StringView schemaName
Definition: ITypeInfo.h:476
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:477
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:486
uint64_t value
Definition: ITypeInfo.h:440
ItemInfo(StringView schemaName_, uint64_t value_, bool isDeprecated_, bool isRemoved_)
Definition: ITypeInfo.h:432
StringView schemaName
Definition: ITypeInfo.h:439