Zserio C++ runtime library  1.0.0
Built for Zserio 2.13.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/Span.h"
5 #include "zserio/StringView.h"
6 #include "zserio/IReflectable.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>
84 template <typename ALLOC>
86 template <typename ALLOC>
88 template <typename ALLOC>
90 template <typename ALLOC>
92 template <typename ALLOC>
94 struct ItemInfo;
95 template <typename ALLOC>
97 template <typename ALLOC>
99 template <typename ALLOC>
101 
111 template <typename ALLOC = std::allocator<uint8_t>>
112 class IBasicTypeInfo
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 
161  virtual Span<const BasicFieldInfo<ALLOC>> getFields() const = 0;
162 
170  virtual Span<const BasicParameterInfo<ALLOC>> getParameters() const = 0;
171 
179  virtual Span<const BasicFunctionInfo<ALLOC>> getFunctions() const = 0;
180 
181  // methods for choice type
182 
190  virtual StringView getSelector() const = 0;
191 
199  virtual Span<const BasicCaseInfo<ALLOC>> getCases() const = 0;
200 
201  // methods for enumeration and bitmask types
202 
210  virtual const IBasicTypeInfo<ALLOC>& getUnderlyingType() const = 0;
211 
219  virtual Span<const StringView> getUnderlyingTypeArguments() const = 0;
220 
228  virtual Span<const ItemInfo> getEnumItems() const = 0;
229 
237  virtual Span<const ItemInfo> getBitmaskValues() const = 0;
238 
239  // methods for SQL table types
240 
248  virtual Span<const BasicColumnInfo<ALLOC>> getColumns() const = 0;
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 
286  virtual Span<const BasicTableInfo<ALLOC>> getTables() const = 0;
287 
288  // methods for templatable types
289 
297  virtual StringView getTemplateName() const = 0;
298 
306  virtual Span<const BasicTemplateArgumentInfo<ALLOC>> getTemplateArguments() const = 0;
307 
308  // method for pubsub type
309 
317  virtual Span<const BasicMessageInfo<ALLOC>> getMessages() const = 0;
318 
319  // method for service type
320 
328  virtual Span<const BasicMethodInfo<ALLOC>> getMethods() const = 0;
329 
339  virtual IBasicReflectablePtr<ALLOC> createInstance(const ALLOC& allocator) const = 0;
340 
350  virtual IBasicReflectablePtr<ALLOC> createInstance() const = 0;
351 };
352 
356 template <typename ALLOC = std::allocator<uint8_t>>
357 struct BasicFieldInfo
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_,
362  StringView constraint_, bool isArray_, StringView arrayLength_, bool isPacked_ ,bool isImplicit_) :
363  schemaName(schemaName_), typeInfo(typeInfo_), typeArguments(typeArguments_),
364  isExtended(isExtended_), alignment(alignment_), offset(offset_), initializer(initializer_),
365  isOptional(isOptional_), optionalCondition(optionalCondition_), constraint(constraint_),
366  isArray(isArray_), arrayLength(arrayLength_), isPacked(isPacked_), isImplicit(isImplicit_)
367  {}
368 
372  bool isExtended;
376  bool isOptional;
379  bool isArray;
381  bool isPacked;
382  bool isImplicit;
383 };
384 
388 template <typename ALLOC = std::allocator<uint8_t>>
389 struct BasicParameterInfo
390 {
393 };
394 
398 template <typename ALLOC = std::allocator<uint8_t>>
399 struct BasicFunctionInfo
400 {
404 };
405 
409 template <typename ALLOC = std::allocator<uint8_t>>
410 struct BasicCaseInfo
411 {
414 };
415 
419 struct ItemInfo
420 {
421  ItemInfo(StringView schemaName_, uint64_t value_, bool isDeprecated_, bool isRemoved_) :
422  schemaName(schemaName_), value(value_), isDeprecated(isDeprecated_), isRemoved(isRemoved_)
423  {}
424 
426  uint64_t value;
428  bool isRemoved;
429 };
430 
434 template <typename ALLOC = std::allocator<uint8_t>>
435 struct BasicColumnInfo
436 {
437  BasicColumnInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_,
438  Span<const StringView> typeArguments_, StringView sqlTypeName_, StringView sqlConstraint_,
439  bool isVirtual_) :
440  schemaName(schemaName_), typeInfo(typeInfo_), typeArguments(typeArguments_),
441  sqlTypeName(sqlTypeName_), sqlConstraint(sqlConstraint_), isVirtual(isVirtual_)
442  {}
443 
449  bool isVirtual;
450 };
451 
455 template <typename ALLOC = std::allocator<uint8_t>>
456 struct BasicTableInfo
457 {
460 };
461 
465 template <typename ALLOC = std::allocator<uint8_t>>
467 {
469 };
470 
474 template <typename ALLOC = std::allocator<uint8_t>>
475 struct BasicMessageInfo
476 {
477  BasicMessageInfo(StringView schemaName_, const IBasicTypeInfo<ALLOC>& typeInfo_,
478  bool isPublished_, bool isSubscribed_, StringView topic_) :
479  schemaName(schemaName_), typeInfo(typeInfo_),
480  isPublished(isPublished_), isSubscribed(isSubscribed_), topic(topic_)
481  {}
482 
485  bool isPublished;
488 };
489 
493 template <typename ALLOC = std::allocator<uint8_t>>
494 struct BasicMethodInfo
495 {
502 };
503 
509 template <typename T, typename ALLOC = std::allocator<uint8_t>>
511 
526 } // namespace zserio
527 
528 #endif // ZSERIO_I_TYPE_INFO_INC_H
BasicMessageInfo(StringView schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, bool isPublished_, bool isSubscribed_, StringView topic_)
Definition: ITypeInfo.h:477
typename IBasicReflectable< ALLOC >::Ptr IBasicReflectablePtr
Definition: IReflectable.h:516
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:468
StringView constraint
Definition: ITypeInfo.h:378
SchemaType
Definition: ITypeInfo.h:40
StringView schemaName
Definition: ITypeInfo.h:425
StringView schemaName
Definition: ITypeInfo.h:458
const BasicFieldInfo< ALLOC > * field
Definition: ITypeInfo.h:413
StringView initializer
Definition: ITypeInfo.h:375
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:392
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:484
const IBasicTypeInfo< ALLOC > & requestTypeInfo
Definition: ITypeInfo.h:501
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:459
StringView schemaName
Definition: ITypeInfo.h:369
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:445
const IBasicTypeInfo< ALLOC > & responseTypeInfo
Definition: ITypeInfo.h:499
Span< const StringView > typeArguments
Definition: ITypeInfo.h:446
StringView sqlTypeName
Definition: ITypeInfo.h:447
ItemInfo(StringView schemaName_, uint64_t value_, bool isDeprecated_, bool isRemoved_)
Definition: ITypeInfo.h:421
const IBasicTypeInfo< ALLOC > & enumTypeInfo()
uint64_t value
Definition: ITypeInfo.h:426
StringView optionalCondition
Definition: ITypeInfo.h:377
StringView alignment
Definition: ITypeInfo.h:373
Span< const StringView > caseExpressions
Definition: ITypeInfo.h:412
StringView arrayLength
Definition: ITypeInfo.h:380
StringView sqlConstraint
Definition: ITypeInfo.h:448
Span< const StringView > typeArguments
Definition: ITypeInfo.h:371
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
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:402
const IBasicTypeInfo< ALLOC > & typeInfo
Definition: ITypeInfo.h:370
BasicColumnInfo(StringView schemaName_, const IBasicTypeInfo< ALLOC > &typeInfo_, Span< const StringView > typeArguments_, StringView sqlTypeName_, StringView sqlConstraint_, bool isVirtual_)
Definition: ITypeInfo.h:437