1 #ifndef ZSERIO_TYPE_INFO_INC_H
2 #define ZSERIO_TYPE_INFO_INC_H
22 template <
typename ALLOC>
92 template <
typename ALLOC = std::allocator<u
int8_t>>
314 template <
typename ALLOC>
440 template <
typename ALLOC>
475 template <
typename ALLOC>
524 template <
typename ALLOC>
549 template <
typename ALLOC>
574 template <
typename ALLOC>
609 template <
typename ALLOC>
636 template <
typename ALLOC>
660 template <
typename ALLOC>
684 template <
typename ALLOC>
713 bool m_isWithoutRowId;
719 template <
typename ALLOC>
740 template <
typename ALLOC>
761 template <
typename ALLOC>
783 template <
typename ALLOC>
796 m_typeInfoFunc(typeInfoFunc)
851 template <
typename ALLOC>
853 m_schemaName(schemaName),
854 m_schemaType(schemaType),
858 template <
typename ALLOC>
861 template <
typename ALLOC>
867 template <
typename ALLOC>
873 template <
typename ALLOC>
879 template <
typename ALLOC>
885 template <
typename ALLOC>
891 template <
typename ALLOC>
897 template <
typename ALLOC>
903 template <
typename ALLOC>
909 template <
typename ALLOC>
915 template <
typename ALLOC>
918 throw CppRuntimeException(
"Type '") << getSchemaName() <<
"' does not have underlying type!";
921 template <
typename ALLOC>
924 throw CppRuntimeException(
"Type '") << getSchemaName() <<
"' does not have underlying type!";
927 template <
typename ALLOC>
933 template <
typename ALLOC>
939 template <
typename ALLOC>
945 template <
typename ALLOC>
951 template <
typename ALLOC>
957 template <
typename ALLOC>
963 template <
typename ALLOC>
969 template <
typename ALLOC>
975 template <
typename ALLOC>
981 template <
typename ALLOC>
987 template <
typename ALLOC>
993 template <
typename ALLOC>
999 template <
typename ALLOC>
1002 return createInstance(ALLOC());
1005 template <
typename ALLOC>
1010 template <
typename ALLOC>
1016 template <
typename ALLOC>
1022 template <
typename ALLOC>
1028 template <
typename ALLOC>
1034 template <
typename ALLOC>
1040 template <
typename ALLOC>
1046 template <
typename ALLOC>
1052 template <
typename ALLOC>
1058 template <
typename ALLOC>
1064 template <
typename ALLOC>
1068 makeStringView(
"varint16"), SchemaType::VARINT16, CppType::INT16};
1072 template <
typename ALLOC>
1076 makeStringView(
"varint32"), SchemaType::VARINT32, CppType::INT32};
1080 template <
typename ALLOC>
1084 makeStringView(
"varint64"), SchemaType::VARINT64, CppType::INT64};
1088 template <
typename ALLOC>
1096 template <
typename ALLOC>
1100 makeStringView(
"varuint16"), SchemaType::VARUINT16, CppType::UINT16};
1104 template <
typename ALLOC>
1108 makeStringView(
"varuint32"), SchemaType::VARUINT32, CppType::UINT32};
1112 template <
typename ALLOC>
1116 makeStringView(
"varuint64"), SchemaType::VARUINT64, CppType::UINT64};
1120 template <
typename ALLOC>
1124 makeStringView(
"varuint"), SchemaType::VARUINT, CppType::UINT64};
1128 template <
typename ALLOC>
1132 makeStringView(
"varsize"), SchemaType::VARSIZE, CppType::UINT32};
1136 template <
typename ALLOC>
1142 template <
typename ALLOC>
1148 template <
typename ALLOC>
1154 template <
typename ALLOC>
1161 template <
typename ALLOC>
1169 template <
typename ALLOC>
1173 makeStringView(
"extern"), SchemaType::EXTERN, CppType::BIT_BUFFER};
1177 template <
typename ALLOC>
1183 template <
typename ALLOC>
1189 template <
typename ALLOC>
1192 if (maxBitSize == 0 || maxBitSize > 64)
1194 throw CppRuntimeException(
"BuiltinTypeInfo::getDynamicSignedBitField: Invalid max bit size '")
1195 << maxBitSize <<
"'!";
1198 if (maxBitSize <= 8)
1201 "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT8};
1204 else if (maxBitSize <= 16)
1207 "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT16};
1210 else if (maxBitSize <= 32)
1213 "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT32};
1219 "int<>"_sv, SchemaType::DYNAMIC_SIGNED_BITFIELD, CppType::INT64};
1224 template <
typename ALLOC>
1227 if (maxBitSize == 0 || maxBitSize > 64)
1229 throw CppRuntimeException(
"BuiltinTypeInfo::getDynamicUnsignedBitField: Invalid max bit size '")
1230 << maxBitSize <<
"'!";
1233 if (maxBitSize <= 8)
1236 "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT8};
1239 else if (maxBitSize <= 16)
1242 "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT16};
1245 else if (maxBitSize <= 32)
1248 "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT32};
1254 "bit<>"_sv, SchemaType::DYNAMIC_UNSIGNED_BITFIELD, CppType::UINT64};
1259 template <
typename ALLOC>
1266 template <
typename ALLOC>
1272 template <
typename ALLOC>
1280 template <
typename ALLOC>
1288 template <
typename ALLOC>
1296 template <
typename ALLOC>
1304 template <
typename ALLOC>
1312 template <
typename ALLOC>
1320 template <
typename ALLOC>
1328 template <
typename ALLOC>
1336 template <
typename ALLOC>
1344 template <
typename ALLOC>
1352 template <
typename ALLOC>
1360 template <
typename ALLOC>
1368 template <
typename ALLOC>
1371 if (bitSize == 0 || bitSize > 64)
1373 throw CppRuntimeException(
"FixedSizeBuiltinTypeInfo::getFixedSignedBitField: Invalid bit size '")
1377 static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {
1443 return bitFieldTypeInfoArray[bitSize - 1U];
1446 template <
typename ALLOC>
1449 if (bitSize == 0 || bitSize > 64)
1451 throw CppRuntimeException(
"FixedSizeBuiltinTypeInfo::getFixedUnsignedBitField: Invalid bit size '")
1455 static const std::array<FixedSizeBuiltinTypeInfo<ALLOC>, 64> bitFieldTypeInfoArray = {
1521 return bitFieldTypeInfoArray[
static_cast<size_t>(bitSize - 1)];
1524 template <
typename ALLOC>
1529 m_templateName(templateName),
1530 m_templateArguments(templateArguments)
1533 template <
typename ALLOC>
1536 template <
typename ALLOC>
1539 return m_templateName;
1542 template <
typename ALLOC>
1545 return m_templateArguments;
1548 template <
typename ALLOC>
1555 m_createInstanceFunc(createInstanceFunc),
1557 m_parameters(parameters),
1558 m_functions(functions)
1561 template <
typename ALLOC>
1564 template <
typename ALLOC>
1570 template <
typename ALLOC>
1573 return m_parameters;
1576 template <
typename ALLOC>
1582 template <
typename ALLOC>
1585 if (!m_createInstanceFunc)
1588 << getSchemaName() <<
"': Cannot create instance, "
1589 <<
"either '-withoutWriterCode' or '-withoutReflectionCode' zserio option is used!";
1591 return m_createInstanceFunc(allocator);
1594 template <
typename ALLOC>
1600 templateName, templateArguments, fields, parameters, functions)
1603 template <
typename ALLOC>
1609 templateName, templateArguments, fields, parameters, functions)
1612 template <
typename ALLOC>
1619 templateName, templateArguments, fields, parameters, functions),
1620 m_selector(selector),
1624 template <
typename ALLOC>
1630 template <
typename ALLOC>
1636 template <
typename ALLOC>
1640 bool isWithoutRowId) :
1644 m_sqlConstraint(sqlConstraint),
1645 m_virtualTableUsing(virtualTableUsing),
1646 m_isWithoutRowId(isWithoutRowId)
1649 template <
typename ALLOC>
1655 template <
typename ALLOC>
1658 return m_sqlConstraint;
1661 template <
typename ALLOC>
1664 return m_virtualTableUsing;
1667 template <
typename ALLOC>
1670 return m_isWithoutRowId;
1673 template <
typename ALLOC>
1680 template <
typename ALLOC>
1686 template <
typename ALLOC>
1691 m_underlyingType(underlyingType),
1692 m_underlyingTypeArguments(underlyingTypeArguments)
1695 template <
typename ALLOC>
1698 return m_underlyingType;
1701 template <
typename ALLOC>
1704 return m_underlyingTypeArguments;
1707 template <
typename ALLOC>
1712 m_enumItems(enumItems)
1715 template <
typename ALLOC>
1721 template <
typename ALLOC>
1726 m_bitmaskValues(bitmaskValues)
1729 template <
typename ALLOC>
1732 return m_bitmaskValues;
1735 template <
typename ALLOC>
1738 m_messages(messages)
1741 template <
typename ALLOC>
1747 template <
typename ALLOC>
1753 template <
typename ALLOC>
1759 template <
typename ALLOC>
1762 return m_typeInfoFunc().getSchemaName();
1765 template <
typename ALLOC>
1768 return m_typeInfoFunc().getSchemaType();
1771 template <
typename ALLOC>
1774 return m_typeInfoFunc().getCppType();
1777 template <
typename ALLOC>
1780 return m_typeInfoFunc().getBitSize();
1783 template <
typename ALLOC>
1786 return m_typeInfoFunc().getFields();
1789 template <
typename ALLOC>
1792 return m_typeInfoFunc().getParameters();
1795 template <
typename ALLOC>
1798 return m_typeInfoFunc().getFunctions();
1801 template <
typename ALLOC>
1804 return m_typeInfoFunc().getSelector();
1807 template <
typename ALLOC>
1810 return m_typeInfoFunc().getCases();
1813 template <
typename ALLOC>
1819 template <
typename ALLOC>
1822 return m_typeInfoFunc().getUnderlyingTypeArguments();
1825 template <
typename ALLOC>
1828 return m_typeInfoFunc().getEnumItems();
1831 template <
typename ALLOC>
1834 return m_typeInfoFunc().getBitmaskValues();
1837 template <
typename ALLOC>
1840 return m_typeInfoFunc().getColumns();
1843 template <
typename ALLOC>
1846 return m_typeInfoFunc().getSqlConstraint();
1849 template <
typename ALLOC>
1852 return m_typeInfoFunc().getVirtualTableUsing();
1855 template <
typename ALLOC>
1858 return m_typeInfoFunc().isWithoutRowId();
1861 template <
typename ALLOC>
1864 return m_typeInfoFunc().getTables();
1867 template <
typename ALLOC>
1870 return m_typeInfoFunc().getTemplateName();
1873 template <
typename ALLOC>
1876 return m_typeInfoFunc().getTemplateArguments();
1879 template <
typename ALLOC>
1882 return m_typeInfoFunc().getMessages();
1885 template <
typename ALLOC>
1888 return m_typeInfoFunc().getMethods();
1891 template <
typename ALLOC>
1894 return m_typeInfoFunc().createInstance(allocator);
1897 template <
typename ALLOC>
1900 return createInstance(ALLOC());
Span< const ItemInfo > getBitmaskValues() const override
BitmaskTypeInfo(StringView schemaName, const IBasicTypeInfo< ALLOC > &underlyingType, Span< const StringView > underlyingTypeArguments, Span< const ItemInfo > bitmaskValues)
static const IBasicTypeInfo< ALLOC > & getDynamicUnsignedBitField(uint8_t maxBitSize)
static const IBasicTypeInfo< ALLOC > & getFloat32()
static const IBasicTypeInfo< ALLOC > & getVarUInt64()
static const IBasicTypeInfo< ALLOC > & getUInt32()
static const IBasicTypeInfo< ALLOC > & getBool()
static const IBasicTypeInfo< ALLOC > & getVarInt64()
static const IBasicTypeInfo< ALLOC > & getVarUInt()
static const IBasicTypeInfo< ALLOC > & getVarInt32()
static const IBasicTypeInfo< ALLOC > & getFixedUnsignedBitField(uint8_t bitSize)
static const IBasicTypeInfo< ALLOC > & getInt32()
static const IBasicTypeInfo< ALLOC > & getInt16()
static const IBasicTypeInfo< ALLOC > & getVarInt()
static const IBasicTypeInfo< ALLOC > & getString()
static const IBasicTypeInfo< ALLOC > & getInt8()
static const IBasicTypeInfo< ALLOC > & getVarInt16()
static const IBasicTypeInfo< ALLOC > & getUInt8()
static const IBasicTypeInfo< ALLOC > & getBitBuffer()
BuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType)
static const IBasicTypeInfo< ALLOC > & getUInt64()
static const IBasicTypeInfo< ALLOC > & getInt64()
static const IBasicTypeInfo< ALLOC > & getUInt16()
static const IBasicTypeInfo< ALLOC > & getVarSize()
static const IBasicTypeInfo< ALLOC > & getFloat16()
static const IBasicTypeInfo< ALLOC > & getVarUInt32()
static const IBasicTypeInfo< ALLOC > & getBytes()
static const IBasicTypeInfo< ALLOC > & getVarUInt16()
static const IBasicTypeInfo< ALLOC > & getDynamicSignedBitField(uint8_t maxBitSize)
static const IBasicTypeInfo< ALLOC > & getFixedSignedBitField(uint8_t bitSize)
static const IBasicTypeInfo< ALLOC > & getFloat64()
StringView getSelector() const override
Span< const BasicCaseInfo< ALLOC > > getCases() const override
ChoiceTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, StringView templateName, Span< const BasicTemplateArgumentInfo< ALLOC >> templateArguments, Span< const BasicFieldInfo< ALLOC >> fields, Span< const BasicParameterInfo< ALLOC >> parameters, Span< const BasicFunctionInfo< ALLOC >> functions, StringView selector, Span< const BasicCaseInfo< ALLOC >> cases)
CompoundTypeInfoBase(const CompoundTypeInfoBase &)=default
Span< const BasicFunctionInfo< ALLOC > > getFunctions() const override
~CompoundTypeInfoBase() override=0
CompoundTypeInfoBase(CompoundTypeInfoBase &&)=default
IBasicReflectablePtr< ALLOC >(*)(const ALLOC &) CreateInstanceFunc
CompoundTypeInfoBase & operator=(const CompoundTypeInfoBase &)=default
CompoundTypeInfoBase(StringView schemaName, CreateInstanceFunc createInstanceFunc, SchemaType schemaType, CppType cppType, StringView templateName, Span< const BasicTemplateArgumentInfo< ALLOC >> templateArguments, Span< const BasicFieldInfo< ALLOC >> fields, Span< const BasicParameterInfo< ALLOC >> parameters, Span< const BasicFunctionInfo< ALLOC >> functions)
Span< const BasicParameterInfo< ALLOC > > getParameters() const override
Span< const BasicFieldInfo< ALLOC > > getFields() const override
CompoundTypeInfoBase & operator=(CompoundTypeInfoBase &&)=default
Span< const ItemInfo > getEnumItems() const override
EnumTypeInfo(StringView schemaName, const IBasicTypeInfo< ALLOC > &underlyingType, Span< const StringView > underlyingTypeArguments, Span< const ItemInfo > enumItems)
static const IBasicTypeInfo< ALLOC > & getFloat64()
static const IBasicTypeInfo< ALLOC > & getUInt64()
static const IBasicTypeInfo< ALLOC > & getInt32()
static const IBasicTypeInfo< ALLOC > & getFloat32()
uint8_t getBitSize() const override
static const IBasicTypeInfo< ALLOC > & getUInt16()
static const IBasicTypeInfo< ALLOC > & getFixedSignedBitField(uint8_t bitSize)
static const IBasicTypeInfo< ALLOC > & getBool()
static const IBasicTypeInfo< ALLOC > & getInt64()
static const IBasicTypeInfo< ALLOC > & getFixedUnsignedBitField(uint8_t bitSize)
static const IBasicTypeInfo< ALLOC > & getUInt8()
static const IBasicTypeInfo< ALLOC > & getFloat16()
static const IBasicTypeInfo< ALLOC > & getInt8()
static const IBasicTypeInfo< ALLOC > & getUInt32()
static const IBasicTypeInfo< ALLOC > & getInt16()
FixedSizeBuiltinTypeInfo(StringView schemaName, SchemaType schemaType, CppType cppType, uint8_t bitSize)
virtual const IBasicTypeInfo< ALLOC > & getUnderlyingType() const =0
PubsubTypeInfo(StringView schemaName, Span< const BasicMessageInfo< ALLOC >> messages)
Span< const BasicMessageInfo< ALLOC > > getMessages() const override
Span< const BasicMethodInfo< ALLOC > > getMethods() const override
StringView getTemplateName() const override
Span< const BasicMessageInfo< ALLOC > > getMessages() const override
StringView getSqlConstraint() const override
Span< const BasicTableInfo< ALLOC > > getTables() const override
RecursiveTypeInfo(const RecursiveTypeInfo &)=delete
Span< const BasicFunctionInfo< ALLOC > > getFunctions() const override
RecursiveTypeInfo(const RecursiveTypeInfo &&)=delete
bool isWithoutRowId() const override
StringView getVirtualTableUsing() const override
uint8_t getBitSize() const override
IBasicReflectablePtr< ALLOC > createInstance() const override
StringView getSchemaName() const override
~RecursiveTypeInfo() override=default
Span< const ItemInfo > getEnumItems() const override
StringView getSelector() const override
Span< const BasicColumnInfo< ALLOC > > getColumns() const override
Span< const BasicCaseInfo< ALLOC > > getCases() const override
CppType getCppType() const override
RecursiveTypeInfo & operator=(const RecursiveTypeInfo &&)=delete
SchemaType getSchemaType() const override
const IBasicTypeInfo< ALLOC > & getUnderlyingType() const override
RecursiveTypeInfo & operator=(const RecursiveTypeInfo &)=delete
Span< const BasicFieldInfo< ALLOC > > getFields() const override
RecursiveTypeInfo(TypeInfoFunc typeInfoFunc)
Span< const BasicTemplateArgumentInfo< ALLOC > > getTemplateArguments() const override
Span< const ItemInfo > getBitmaskValues() const override
Span< const StringView > getUnderlyingTypeArguments() const override
Span< const BasicParameterInfo< ALLOC > > getParameters() const override
Span< const BasicMethodInfo< ALLOC > > getMethods() const override
ServiceTypeInfo(StringView schemaName, Span< const BasicMethodInfo< ALLOC >> methods)
SqlDatabaseTypeInfo(StringView schemaName, Span< const BasicTableInfo< ALLOC >> tables)
Span< const BasicTableInfo< ALLOC > > getTables() const override
StringView getVirtualTableUsing() const override
bool isWithoutRowId() const override
SqlTableTypeInfo(StringView schemaName, StringView templateName, Span< const BasicTemplateArgumentInfo< ALLOC >> templateArguments, Span< const BasicColumnInfo< ALLOC >> columns, StringView sqlConstraint, StringView virtualTableUsing, bool isWithoutRowId)
Span< const BasicColumnInfo< ALLOC > > getColumns() const override
StringView getSqlConstraint() const override
StructTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, StringView templateName, Span< const BasicTemplateArgumentInfo< ALLOC >> templateArguments, Span< const BasicFieldInfo< ALLOC >> fields, Span< const BasicParameterInfo< ALLOC >> parameters, Span< const BasicFunctionInfo< ALLOC >> functions)
TemplatableTypeInfoBase & operator=(TemplatableTypeInfoBase &&)=default
TemplatableTypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType, StringView templateName, Span< const BasicTemplateArgumentInfo< ALLOC >> templateArguments)
Span< const BasicTemplateArgumentInfo< ALLOC > > getTemplateArguments() const override
TemplatableTypeInfoBase & operator=(const TemplatableTypeInfoBase &)=default
TemplatableTypeInfoBase(const TemplatableTypeInfoBase &)=default
TemplatableTypeInfoBase(TemplatableTypeInfoBase &&)=default
~TemplatableTypeInfoBase() override=0
StringView getTemplateName() const override
CppType getCppType() const override
Span< const BasicFieldInfo< ALLOC > > getFields() const override
TypeInfoBase & operator=(const TypeInfoBase &&)=delete
const IBasicTypeInfo< ALLOC > & getUnderlyingType() const override
Span< const BasicTableInfo< ALLOC > > getTables() const override
bool isWithoutRowId() const override
TypeInfoBase(const TypeInfoBase &&)=delete
Span< const BasicColumnInfo< ALLOC > > getColumns() const override
StringView getSelector() const override
IBasicReflectablePtr< ALLOC > createInstance(const ALLOC &allocator) const override
Span< const StringView > getUnderlyingTypeArguments() const override
StringView getVirtualTableUsing() const override
Span< const BasicMethodInfo< ALLOC > > getMethods() const override
Span< const ItemInfo > getBitmaskValues() const override
StringView getSqlConstraint() const override
StringView getTemplateName() const override
~TypeInfoBase() override=0
Span< const BasicTemplateArgumentInfo< ALLOC > > getTemplateArguments() const override
Span< const ItemInfo > getEnumItems() const override
Span< const BasicMessageInfo< ALLOC > > getMessages() const override
Span< const BasicCaseInfo< ALLOC > > getCases() const override
SchemaType getSchemaType() const override
TypeInfoBase(StringView schemaName, SchemaType schemaType, CppType cppType)
uint8_t getBitSize() const override
Span< const BasicParameterInfo< ALLOC > > getParameters() const override
TypeInfoBase(const TypeInfoBase &)=delete
Span< const BasicFunctionInfo< ALLOC > > getFunctions() const override
StringView getSchemaName() const override
IBasicReflectablePtr< ALLOC > createInstance() const override
TypeInfoBase & operator=(const TypeInfoBase &)=delete
Span< const StringView > getUnderlyingTypeArguments() const override
TypeInfoWithUnderlyingTypeBase(StringView schemaName, SchemaType schemaType, CppType cppType, const IBasicTypeInfo< ALLOC > &underlyingType, Span< const StringView > underlyingTypeArguments)
const IBasicTypeInfo< ALLOC > & getUnderlyingType() const override
UnionTypeInfo(StringView schemaName, CreateInstanceFunc createInstanceFunc, StringView templateName, Span< const BasicTemplateArgumentInfo< ALLOC >> templateArguments, Span< const BasicFieldInfo< ALLOC >> fields, Span< const BasicParameterInfo< ALLOC >> parameters, Span< const BasicFunctionInfo< ALLOC >> functions)
@ FIXED_UNSIGNED_BITFIELD
constexpr BasicStringView< CharT > makeStringView(const CharT(&str)[N])
typename IBasicReflectable< ALLOC >::Ptr IBasicReflectablePtr