From e21ccb692ba0c959f038ce53b79b2e0fa309861e Mon Sep 17 00:00:00 2001 From: Johannes Wolf Date: Thu, 18 Jul 2024 11:54:13 +0200 Subject: [PATCH] cpp-rt: Add bitPosition unit tests --- .../cpp/runtime/test/CMakeLists.txt | 9 + .../polymorphic_allocator/ArrayBitmask.cpp | 2 +- .../polymorphic_allocator/ArrayBitmask.h | 8 +- .../polymorphic_allocator/ArrayEnum.cpp | 2 +- .../polymorphic_allocator/ArrayEnum.h | 8 +- .../polymorphic_allocator/ArrayHolder.cpp | 69 ++-- .../polymorphic_allocator/ArrayHolder.h | 17 +- .../polymorphic_allocator/ArrayObject.cpp | 31 +- .../polymorphic_allocator/ArrayObject.h | 17 +- .../ArrayParamObject.cpp | 72 +++- .../polymorphic_allocator/ArrayParamObject.h | 17 +- .../BitPositionObject.cpp | 384 ++++++++++++++++++ .../polymorphic_allocator/BitPositionObject.h | 112 +++++ .../BitPositionSubObject.cpp | 303 ++++++++++++++ .../BitPositionSubObject.h | 99 +++++ .../polymorphic_allocator/CreatorBitmask.cpp | 2 +- .../polymorphic_allocator/CreatorBitmask.h | 8 +- .../polymorphic_allocator/CreatorEnum.cpp | 2 +- .../polymorphic_allocator/CreatorEnum.h | 8 +- .../polymorphic_allocator/CreatorNested.cpp | 145 ++++--- .../polymorphic_allocator/CreatorNested.h | 17 +- .../polymorphic_allocator/CreatorObject.cpp | 119 +++--- .../polymorphic_allocator/CreatorObject.h | 17 +- .../CreatorUnsignedEnum.cpp | 2 +- .../CreatorUnsignedEnum.h | 8 +- .../DebugStringObject.cpp | 28 +- .../polymorphic_allocator/DebugStringObject.h | 17 +- .../DebugStringParamObject.cpp | 65 ++- .../DebugStringParamObject.h | 17 +- .../ReflectableBitmask.cpp | 2 +- .../ReflectableBitmask.h | 8 +- .../polymorphic_allocator/ReflectableEnum.cpp | 2 +- .../polymorphic_allocator/ReflectableEnum.h | 8 +- .../ReflectableNested.cpp | 67 ++- .../polymorphic_allocator/ReflectableNested.h | 17 +- .../ReflectableObject.cpp | 49 ++- .../polymorphic_allocator/ReflectableObject.h | 17 +- .../ReflectableUtilBitmask.cpp | 2 +- .../ReflectableUtilBitmask.h | 8 +- .../ReflectableUtilChoice.cpp | 66 ++- .../ReflectableUtilChoice.h | 17 +- .../ReflectableUtilEnum.cpp | 2 +- .../ReflectableUtilEnum.h | 8 +- .../ReflectableUtilObject.cpp | 49 ++- .../ReflectableUtilObject.h | 17 +- .../ReflectableUtilUnion.cpp | 25 +- .../ReflectableUtilUnion.h | 18 +- .../polymorphic_allocator/SerializeEnum.cpp | 2 +- .../polymorphic_allocator/SerializeEnum.h | 8 +- .../polymorphic_allocator/SerializeNested.cpp | 81 ++-- .../polymorphic_allocator/SerializeNested.h | 17 +- .../polymorphic_allocator/SerializeObject.cpp | 49 ++- .../polymorphic_allocator/SerializeObject.h | 17 +- .../polymorphic_allocator/WalkerBitmask.cpp | 2 +- .../polymorphic_allocator/WalkerBitmask.h | 8 +- .../polymorphic_allocator/WalkerChoice.cpp | 66 ++- .../polymorphic_allocator/WalkerChoice.h | 17 +- .../polymorphic_allocator/WalkerNested.cpp | 28 +- .../polymorphic_allocator/WalkerNested.h | 17 +- .../polymorphic_allocator/WalkerObject.cpp | 99 +++-- .../polymorphic_allocator/WalkerObject.h | 17 +- .../polymorphic_allocator/WalkerUnion.cpp | 25 +- .../polymorphic_allocator/WalkerUnion.h | 18 +- .../std_allocator/ArrayBitmask.cpp | 2 +- .../test_object/std_allocator/ArrayBitmask.h | 8 +- .../test_object/std_allocator/ArrayEnum.cpp | 2 +- .../test_object/std_allocator/ArrayEnum.h | 8 +- .../test_object/std_allocator/ArrayHolder.cpp | 69 ++-- .../test_object/std_allocator/ArrayHolder.h | 17 +- .../test_object/std_allocator/ArrayObject.cpp | 31 +- .../test_object/std_allocator/ArrayObject.h | 17 +- .../std_allocator/ArrayParamObject.cpp | 72 +++- .../std_allocator/ArrayParamObject.h | 17 +- .../std_allocator/BitPositionObject.cpp | 384 ++++++++++++++++++ .../std_allocator/BitPositionObject.h | 112 +++++ .../std_allocator/BitPositionSubObject.cpp | 303 ++++++++++++++ .../std_allocator/BitPositionSubObject.h | 99 +++++ .../std_allocator/CreatorBitmask.cpp | 2 +- .../std_allocator/CreatorBitmask.h | 8 +- .../test_object/std_allocator/CreatorEnum.cpp | 2 +- .../test_object/std_allocator/CreatorEnum.h | 8 +- .../std_allocator/CreatorNested.cpp | 145 ++++--- .../test_object/std_allocator/CreatorNested.h | 17 +- .../std_allocator/CreatorObject.cpp | 119 +++--- .../test_object/std_allocator/CreatorObject.h | 17 +- .../std_allocator/CreatorUnsignedEnum.cpp | 2 +- .../std_allocator/CreatorUnsignedEnum.h | 8 +- .../std_allocator/DebugStringObject.cpp | 28 +- .../std_allocator/DebugStringObject.h | 17 +- .../std_allocator/DebugStringParamObject.cpp | 65 ++- .../std_allocator/DebugStringParamObject.h | 17 +- .../std_allocator/ReflectableBitmask.cpp | 2 +- .../std_allocator/ReflectableBitmask.h | 8 +- .../std_allocator/ReflectableEnum.cpp | 2 +- .../std_allocator/ReflectableEnum.h | 8 +- .../std_allocator/ReflectableNested.cpp | 67 ++- .../std_allocator/ReflectableNested.h | 17 +- .../std_allocator/ReflectableObject.cpp | 49 ++- .../std_allocator/ReflectableObject.h | 17 +- .../std_allocator/ReflectableUtilBitmask.cpp | 2 +- .../std_allocator/ReflectableUtilBitmask.h | 8 +- .../std_allocator/ReflectableUtilChoice.cpp | 66 ++- .../std_allocator/ReflectableUtilChoice.h | 17 +- .../std_allocator/ReflectableUtilEnum.cpp | 2 +- .../std_allocator/ReflectableUtilEnum.h | 8 +- .../std_allocator/ReflectableUtilObject.cpp | 49 ++- .../std_allocator/ReflectableUtilObject.h | 17 +- .../std_allocator/ReflectableUtilUnion.cpp | 25 +- .../std_allocator/ReflectableUtilUnion.h | 18 +- .../std_allocator/SerializeEnum.cpp | 2 +- .../test_object/std_allocator/SerializeEnum.h | 8 +- .../std_allocator/SerializeNested.cpp | 81 ++-- .../std_allocator/SerializeNested.h | 17 +- .../std_allocator/SerializeObject.cpp | 49 ++- .../std_allocator/SerializeObject.h | 17 +- .../std_allocator/WalkerBitmask.cpp | 2 +- .../test_object/std_allocator/WalkerBitmask.h | 8 +- .../std_allocator/WalkerChoice.cpp | 66 ++- .../test_object/std_allocator/WalkerChoice.h | 17 +- .../std_allocator/WalkerNested.cpp | 28 +- .../test_object/std_allocator/WalkerNested.h | 17 +- .../std_allocator/WalkerObject.cpp | 99 +++-- .../test_object/std_allocator/WalkerObject.h | 17 +- .../test_object/std_allocator/WalkerUnion.cpp | 25 +- .../test_object/std_allocator/WalkerUnion.h | 18 +- .../runtime/test/test_object/test_object.zs | 19 +- .../runtime/test/zserio/BitPositionTest.cpp | 49 +++ 127 files changed, 4181 insertions(+), 794 deletions(-) create mode 100644 compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.cpp create mode 100644 compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.h create mode 100644 compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.cpp create mode 100644 compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.h create mode 100644 compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.cpp create mode 100644 compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.h create mode 100644 compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.cpp create mode 100644 compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.h create mode 100644 compiler/extensions/cpp/runtime/test/zserio/BitPositionTest.cpp diff --git a/compiler/extensions/cpp/runtime/test/CMakeLists.txt b/compiler/extensions/cpp/runtime/test/CMakeLists.txt index cb5ba02f0..08fce0327 100644 --- a/compiler/extensions/cpp/runtime/test/CMakeLists.txt +++ b/compiler/extensions/cpp/runtime/test/CMakeLists.txt @@ -30,6 +30,10 @@ set(TEST_OBJECT_SRCS test_object/polymorphic_allocator/ArrayObject.h test_object/polymorphic_allocator/ArrayParamObject.cpp test_object/polymorphic_allocator/ArrayParamObject.h + test_object/polymorphic_allocator/BitPositionObject.cpp + test_object/polymorphic_allocator/BitPositionObject.h + test_object/polymorphic_allocator/BitPositionSubObject.h + test_object/polymorphic_allocator/BitPositionSubObject.cpp test_object/polymorphic_allocator/CreatorBitmask.cpp test_object/polymorphic_allocator/CreatorBitmask.h test_object/polymorphic_allocator/CreatorEnum.cpp @@ -87,6 +91,10 @@ set(TEST_OBJECT_SRCS test_object/std_allocator/ArrayObject.h test_object/std_allocator/ArrayParamObject.cpp test_object/std_allocator/ArrayParamObject.h + test_object/std_allocator/BitPositionObject.cpp + test_object/std_allocator/BitPositionObject.h + test_object/std_allocator/BitPositionSubObject.cpp + test_object/std_allocator/BitPositionSubObject.h test_object/std_allocator/CreatorBitmask.cpp test_object/std_allocator/CreatorBitmask.h test_object/std_allocator/CreatorEnum.cpp @@ -187,6 +195,7 @@ set(ZSERIO_CPP_RUNTIME_TEST_SRCS zserio/SizeConvertUtilTest.cpp zserio/WalkerTest.cpp zserio/ZserioTreeCreatorTest.cpp + zserio/BitPositionTest.cpp ) set(ZSERIO_CPP_RUNTIME_TEST_HEADERS diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.cpp index 413976030..64fb110b2 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.h index 9a38d4cd4..16d7184dd 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_BITMASK_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.cpp index 0bf5e04e6..db1042212 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.h index fac0dcd30..0ddba5e75 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_ENUM_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.cpp index 9589bc573..9ef961b55 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,28 +21,30 @@ namespace polymorphic_allocator { ArrayHolder::ArrayHolder(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_enumArray_(allocator), - m_bitmaskArray_(allocator), - m_packedArray_(allocator), - m_packedParamArray_(allocator) + m_areChildrenInitialized(false), + m_enumArray_(allocator), + m_bitmaskArray_(allocator), + m_packedArray_(allocator), + m_packedParamArray_(allocator) { } ArrayHolder::ArrayHolder(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_enumArray_(readEnumArray(in, allocator)), - m_bitmaskArray_(readBitmaskArray(in, allocator)), - m_packedArray_(readPackedArray(in, allocator)), - m_packedParamArray_(readPackedParamArray(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_enumArray_(readEnumArray(in, allocator)), + m_bitmaskArray_(readBitmaskArray(in, allocator)), + m_packedArray_(readPackedArray(in, allocator)), + m_packedParamArray_(readPackedParamArray(in, allocator)) { } ArrayHolder::ArrayHolder(const ArrayHolder& other) : - m_enumArray_(other.m_enumArray_), - m_bitmaskArray_(other.m_bitmaskArray_), - m_packedArray_(other.m_packedArray_), - m_packedParamArray_(::zserio::NoInit, other.m_packedParamArray_) + m_bitPosition(other.m_bitPosition), + m_enumArray_(other.m_enumArray_), + m_bitmaskArray_(other.m_bitmaskArray_), + m_packedArray_(other.m_packedArray_), + m_packedParamArray_(::zserio::NoInit, other.m_packedParamArray_) { if (other.m_areChildrenInitialized) { @@ -73,10 +75,11 @@ ArrayHolder& ArrayHolder::operator=(const ArrayHolder& other) } ArrayHolder::ArrayHolder(ArrayHolder&& other) : - m_enumArray_(::std::move(other.m_enumArray_)), - m_bitmaskArray_(::std::move(other.m_bitmaskArray_)), - m_packedArray_(::std::move(other.m_packedArray_)), - m_packedParamArray_(::zserio::NoInit, ::std::move(other.m_packedParamArray_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_enumArray_(::std::move(other.m_enumArray_)), + m_bitmaskArray_(::std::move(other.m_bitmaskArray_)), + m_packedArray_(::std::move(other.m_packedArray_)), + m_packedParamArray_(::zserio::NoInit, ::std::move(other.m_packedParamArray_)) { if (other.m_areChildrenInitialized) { @@ -90,6 +93,7 @@ ArrayHolder::ArrayHolder(ArrayHolder&& other) : ArrayHolder& ArrayHolder::operator=(ArrayHolder&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_enumArray_ = ::std::move(other.m_enumArray_); m_bitmaskArray_ = ::std::move(other.m_bitmaskArray_); m_packedArray_ = ::std::move(other.m_packedArray_); @@ -107,11 +111,13 @@ ArrayHolder& ArrayHolder::operator=(ArrayHolder&& other) } ArrayHolder::ArrayHolder(::zserio::PropagateAllocatorT, - const ArrayHolder& other, const allocator_type& allocator) : - m_enumArray_(::zserio::allocatorPropagatingCopy(other.m_enumArray_, allocator)), - m_bitmaskArray_(::zserio::allocatorPropagatingCopy(other.m_bitmaskArray_, allocator)), - m_packedArray_(::zserio::allocatorPropagatingCopy(other.m_packedArray_, allocator)), - m_packedParamArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_packedParamArray_, allocator)) +const ArrayHolder& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_enumArray_(::zserio::allocatorPropagatingCopy(other.m_enumArray_, allocator)), + m_bitmaskArray_(::zserio::allocatorPropagatingCopy(other.m_bitmaskArray_, allocator)), + m_packedArray_(::zserio::allocatorPropagatingCopy(other.m_packedArray_, allocator)), + m_packedParamArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_packedParamArray_, allocator)) { if (other.m_areChildrenInitialized) { @@ -121,6 +127,7 @@ ArrayHolder::ArrayHolder(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::pmr::ITypeInfo& ArrayHolder::typeInfo() @@ -266,6 +273,11 @@ ::zserio::pmr::IReflectableConstPtr ArrayHolder::reflectable(const allocator_typ return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ArrayHolder& m_object; }; @@ -406,6 +418,11 @@ ::zserio::pmr::IReflectablePtr ArrayHolder::reflectable(const allocator_type& al return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ArrayHolder& m_object; }; @@ -598,6 +615,10 @@ void ArrayHolder::write(::zserio::BitStreamWriter& out) const m_packedArray_.writePacked(*this, out); m_packedParamArray_.writePacked(*this, out); } +size_t ArrayHolder::bitPosition() const +{ + return m_bitPosition; +} void ArrayHolder::ZserioElementFactory_packedArray::create(ArrayHolder&, ::zserio::pmr::vector<::test_object::polymorphic_allocator::ArrayObject>& array, diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.h index 55faaa7e0..4e2ee5251 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayHolder.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_HOLDER_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_HOLDER_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -108,6 +114,14 @@ class ArrayHolder void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioElementFactory_packedArray { @@ -162,6 +176,7 @@ class ArrayHolder ZserioArrayType_packedParamArray readPackedParamArray(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; ZserioArrayType_enumArray m_enumArray_; ZserioArrayType_bitmaskArray m_bitmaskArray_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.cpp index 13ade8fde..8da55c3b3 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,24 +21,29 @@ namespace polymorphic_allocator { ArrayObject::ArrayObject(const allocator_type&) noexcept : - m_value_(uint32_t()) + m_value_(uint32_t()) { } ArrayObject::ArrayObject(::zserio::BitStreamReader& in, const allocator_type&) : - m_value_(readValue(in)) + m_bitPosition(in.getBitPosition()), + m_value_(readValue(in)) { } ArrayObject::ArrayObject(ArrayObject::ZserioPackingContext& context, ::zserio::BitStreamReader& in, const allocator_type&) : - m_value_(readValue(context, in)) + m_bitPosition(in.getBitPosition()), + m_value_(readValue(context, in)) { } ArrayObject::ArrayObject(::zserio::PropagateAllocatorT, - const ArrayObject& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +const ArrayObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& ArrayObject::typeInfo() @@ -121,6 +126,11 @@ ::zserio::pmr::IReflectableConstPtr ArrayObject::reflectable(const allocator_typ return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ArrayObject& m_object; }; @@ -206,6 +216,11 @@ ::zserio::pmr::IReflectablePtr ArrayObject::reflectable(const allocator_type& al return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ArrayObject& m_object; }; @@ -307,6 +322,10 @@ void ArrayObject::write(ArrayObject::ZserioPackingContext& context, ::zserio::Bi { context.getValue().write<::zserio::BitFieldArrayTraits>(out, m_value_); } +size_t ArrayObject::bitPosition() const +{ + return m_bitPosition; +} uint32_t ArrayObject::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.h index 76149c4df..106e67925 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -92,11 +98,20 @@ class ArrayObject void write(::zserio::BitStreamWriter& out) const; void write(ZserioPackingContext& context, ::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); uint32_t readValue(ZserioPackingContext& context, ::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; uint32_t m_value_; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.cpp index 3743c65fb..143231167 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -23,29 +23,32 @@ namespace polymorphic_allocator { ArrayParamObject::ArrayParamObject(const allocator_type&) noexcept : - m_isInitialized(false), - m_value_(uint32_t()) + m_isInitialized(false), + m_value_(uint32_t()) { } ArrayParamObject::ArrayParamObject(::zserio::BitStreamReader& in, ::test_object::polymorphic_allocator::ArrayObject& param_, const allocator_type&) : - m_param_(¶m_), - m_isInitialized(true), - m_value_(readValue(in)) + m_bitPosition(in.getBitPosition()), + m_param_(¶m_), + m_isInitialized(true), + m_value_(readValue(in)) { } ArrayParamObject::ArrayParamObject(ArrayParamObject::ZserioPackingContext& context, ::zserio::BitStreamReader& in, ::test_object::polymorphic_allocator::ArrayObject& param_, const allocator_type&) : - m_param_(¶m_), - m_isInitialized(true), - m_value_(readValue(context, in)) + m_bitPosition(in.getBitPosition()), + m_param_(¶m_), + m_isInitialized(true), + m_value_(readValue(context, in)) { } ArrayParamObject::ArrayParamObject(const ArrayParamObject& other) : - m_value_(other.m_value_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_) { if (other.m_isInitialized) { @@ -73,7 +76,8 @@ ArrayParamObject& ArrayParamObject::operator=(const ArrayParamObject& other) } ArrayParamObject::ArrayParamObject(ArrayParamObject&& other) : - m_value_(::std::move(other.m_value_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)) { if (other.m_isInitialized) { @@ -87,6 +91,7 @@ ArrayParamObject::ArrayParamObject(ArrayParamObject&& other) : ArrayParamObject& ArrayParamObject::operator=(ArrayParamObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); if (other.m_isInitialized) { @@ -101,10 +106,12 @@ ArrayParamObject& ArrayParamObject::operator=(ArrayParamObject&& other) } ArrayParamObject::ArrayParamObject(::zserio::NoInitT, - const ArrayParamObject& other) : + const ArrayParamObject& other) + : m_isInitialized(false), - m_value_(other.m_value_) + m_value_(other.m_value_) { + (void)other; } ArrayParamObject& ArrayParamObject::assign(::zserio::NoInitT, @@ -113,28 +120,35 @@ ArrayParamObject& ArrayParamObject::assign(::zserio::NoInitT, m_isInitialized = false; m_value_ = other.m_value_; + (void)other; return *this; } ArrayParamObject::ArrayParamObject(::zserio::NoInitT, - ArrayParamObject&& other) : +ArrayParamObject&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_value_(::std::move(other.m_value_)) + m_value_(::std::move(other.m_value_)) { + (void)other; } ArrayParamObject& ArrayParamObject::assign(::zserio::NoInitT, - ArrayParamObject&& other) +ArrayParamObject&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_value_ = ::std::move(other.m_value_); + (void)other; return *this; } ArrayParamObject::ArrayParamObject(::zserio::PropagateAllocatorT, - const ArrayParamObject& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +const ArrayParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { if (other.m_isInitialized) { @@ -144,13 +158,17 @@ ArrayParamObject::ArrayParamObject(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } ArrayParamObject::ArrayParamObject(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const ArrayParamObject& other, const allocator_type& allocator) : +const ArrayParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& ArrayParamObject::typeInfo() @@ -247,6 +265,11 @@ ::zserio::pmr::IReflectableConstPtr ArrayParamObject::reflectable(const allocato return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ArrayParamObject& m_object; }; @@ -364,6 +387,11 @@ ::zserio::pmr::IReflectablePtr ArrayParamObject::reflectable(const allocator_typ return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ArrayParamObject& m_object; }; @@ -518,6 +546,10 @@ void ArrayParamObject::write(ArrayParamObject::ZserioPackingContext& context, :: } context.getValue().write<::zserio::StdIntArrayTraits>(out, m_value_); } +size_t ArrayParamObject::bitPosition() const +{ + return m_bitPosition; +} uint32_t ArrayParamObject::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.h index a9f9c4a10..6c15d1977 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ArrayParamObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_PARAM_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_ARRAY_PARAM_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -114,11 +120,20 @@ class ArrayParamObject void write(::zserio::BitStreamWriter& out) const; void write(ZserioPackingContext& context, ::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); uint32_t readValue(ZserioPackingContext& context, ::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; ::test_object::polymorphic_allocator::ArrayObject* m_param_; bool m_isInitialized; uint32_t m_value_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.cpp new file mode 100644 index 000000000..2bc4a43b9 --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.cpp @@ -0,0 +1,384 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace test_object +{ +namespace polymorphic_allocator +{ + +BitPositionObject::BitPositionObject(const allocator_type& allocator) noexcept : + m_pad_(uint8_t()), + m_sub_(allocator) +{ +} + +BitPositionObject::BitPositionObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : + m_bitPosition(in.getBitPosition()), + m_pad_(readPad(in)), + m_sub_(readSub(in, allocator)) +{ +} + +BitPositionObject::BitPositionObject(::zserio::PropagateAllocatorT, +const BitPositionObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_pad_(::zserio::allocatorPropagatingCopy(other.m_pad_, allocator)), + m_sub_(::zserio::allocatorPropagatingCopy(other.m_sub_, allocator)) +{ + (void)other; +} + +const ::zserio::pmr::ITypeInfo& BitPositionObject::typeInfo() +{ + static const ::zserio::StringView templateName; + static const ::zserio::Span<::zserio::BasicTemplateArgumentInfo> templateArguments; + + static const ::std::array<::zserio::BasicFieldInfo, 2> fields = { + ::zserio::BasicFieldInfo{ + ::zserio::makeStringView("pad"), // schemaName + ::zserio::BuiltinTypeInfo::getFixedUnsignedBitField(UINT8_C(3)), // typeInfo + {}, // typeArguments + false, // isExtended + {}, // alignment + {}, // offset + {}, // initializer + false, // isOptional + {}, // optionalClause + {}, // constraint + false, // isArray + {}, // arrayLength + false, // isPacked + false // isImplicit + }, + ::zserio::BasicFieldInfo{ + ::zserio::makeStringView("sub"), // schemaName + ::test_object::polymorphic_allocator::BitPositionSubObject::typeInfo(), // typeInfo + {}, // typeArguments + false, // isExtended + {}, // alignment + {}, // offset + {}, // initializer + false, // isOptional + {}, // optionalClause + {}, // constraint + false, // isArray + {}, // arrayLength + false, // isPacked + false // isImplicit + } + }; + + static const ::zserio::Span<::zserio::BasicParameterInfo> parameters; + + static const ::zserio::Span<::zserio::BasicFunctionInfo> functions; + + static const ::zserio::StructTypeInfo typeInfo = { + ::zserio::makeStringView("test_object.polymorphic_allocator.BitPositionObject"), + [](const allocator_type& allocator) -> ::zserio::pmr::IReflectablePtr + { + return std::allocate_shared<::zserio::ReflectableOwner>(allocator, allocator); + }, + templateName, templateArguments, + fields, parameters, functions + }; + + return typeInfo; +} + +::zserio::pmr::IReflectableConstPtr BitPositionObject::reflectable(const allocator_type& allocator) const +{ + class Reflectable : public ::zserio::ReflectableConstAllocatorHolderBase + { + public: + using ::zserio::ReflectableConstAllocatorHolderBase::getField; + using ::zserio::ReflectableConstAllocatorHolderBase::getParameter; + using ::zserio::ReflectableConstAllocatorHolderBase::callFunction; + using ::zserio::ReflectableConstAllocatorHolderBase::getAnyValue; + + explicit Reflectable(const ::test_object::polymorphic_allocator::BitPositionObject& object, const allocator_type& alloc) : + ::zserio::ReflectableConstAllocatorHolderBase(::test_object::polymorphic_allocator::BitPositionObject::typeInfo(), alloc), + m_object(object) + {} + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::pmr::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("pad")) + { + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::pmr::AnyHolder getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + const ::test_object::polymorphic_allocator::BitPositionObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +::zserio::pmr::IReflectablePtr BitPositionObject::reflectable(const allocator_type& allocator) +{ + class Reflectable : public ::zserio::ReflectableAllocatorHolderBase + { + public: + explicit Reflectable(::test_object::polymorphic_allocator::BitPositionObject& object, const allocator_type& alloc) : + ::zserio::ReflectableAllocatorHolderBase(::test_object::polymorphic_allocator::BitPositionObject::typeInfo(), alloc), + m_object(object) + {} + + void initializeChildren() override + { + } + + size_t initializeOffsets(size_t bitPosition) override + { + return m_object.initializeOffsets(bitPosition); + } + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::pmr::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("pad")) + { + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::pmr::IReflectablePtr getField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("pad")) + { + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + void setField(::zserio::StringView name, + const ::zserio::AnyHolder& value) override + { + if (name == ::zserio::makeStringView("pad")) + { + m_object.setPad(value.get()); + return; + } + if (name == ::zserio::makeStringView("sub")) + { + m_object.setSub(value.get<::test_object::polymorphic_allocator::BitPositionSubObject>()); + return; + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::pmr::IReflectablePtr createField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("pad")) + { + m_object.setPad(uint8_t()); + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + m_object.setSub(::test_object::polymorphic_allocator::BitPositionSubObject(get_allocator())); + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::pmr::AnyHolder getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); + } + + ::zserio::pmr::AnyHolder getAnyValue(const allocator_type& alloc) override + { + return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + ::test_object::polymorphic_allocator::BitPositionObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +uint8_t BitPositionObject::getPad() const +{ + return m_pad_; +} + +void BitPositionObject::setPad(uint8_t pad_) +{ + m_pad_ = pad_; +} + +::test_object::polymorphic_allocator::BitPositionSubObject& BitPositionObject::getSub() +{ + return m_sub_; +} + +const ::test_object::polymorphic_allocator::BitPositionSubObject& BitPositionObject::getSub() const +{ + return m_sub_; +} + +void BitPositionObject::setSub(const ::test_object::polymorphic_allocator::BitPositionSubObject& sub_) +{ + m_sub_ = sub_; +} + +void BitPositionObject::setSub(::test_object::polymorphic_allocator::BitPositionSubObject&& sub_) +{ + m_sub_ = ::std::move(sub_); +} + +size_t BitPositionObject::bitSizeOf(size_t bitPosition) const +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(3); + endBitPosition += m_sub_.bitSizeOf(endBitPosition); + + return endBitPosition - bitPosition; +} + +size_t BitPositionObject::initializeOffsets(size_t bitPosition) +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(3); + endBitPosition = m_sub_.initializeOffsets(endBitPosition); + + return endBitPosition; +} + +bool BitPositionObject::operator==(const BitPositionObject& other) const +{ + if (this != &other) + { + return + (m_pad_ == other.m_pad_) && + (m_sub_ == other.m_sub_); + } + + return true; +} + +bool BitPositionObject::operator<(const BitPositionObject& other) const +{ + if (m_pad_ < other.m_pad_) + { + return true; + } + if (other.m_pad_ < m_pad_) + { + return false; + } + + if (m_sub_ < other.m_sub_) + { + return true; + } + if (other.m_sub_ < m_sub_) + { + return false; + } + + return false; +} + +uint32_t BitPositionObject::hashCode() const +{ + uint32_t result = ::zserio::HASH_SEED; + + result = ::zserio::calcHashCode(result, m_pad_); + result = ::zserio::calcHashCode(result, m_sub_); + + return result; +} + +void BitPositionObject::write(::zserio::BitStreamWriter& out) const +{ + out.writeBits(m_pad_, UINT8_C(3)); + m_sub_.write(out); +} +size_t BitPositionObject::bitPosition() const +{ + return m_bitPosition; +} + +uint8_t BitPositionObject::readPad(::zserio::BitStreamReader& in) +{ + return static_cast(in.readBits(UINT8_C(3))); +} + +::test_object::polymorphic_allocator::BitPositionSubObject BitPositionObject::readSub(::zserio::BitStreamReader& in, + const allocator_type& allocator) +{ + return ::test_object::polymorphic_allocator::BitPositionSubObject(in, allocator); +} + + +} // namespace polymorphic_allocator +} // namespace test_object diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.h new file mode 100644 index 000000000..f1d4fba4b --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionObject.h @@ -0,0 +1,112 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. + */ + +#ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_BIT_POSITION_OBJECT_H +#define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_BIT_POSITION_OBJECT_H + +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace test_object +{ +namespace polymorphic_allocator +{ + +class BitPositionObject +{ +public: + using allocator_type = ::zserio::pmr::PropagatingPolymorphicAllocator<>; + + BitPositionObject() noexcept : + BitPositionObject(allocator_type()) + {} + + explicit BitPositionObject(const allocator_type& allocator) noexcept; + + template + BitPositionObject( + uint8_t pad_, + ZSERIO_T_sub&& sub_, + const allocator_type& allocator = allocator_type()) : + BitPositionObject(allocator) + { + m_pad_ = pad_; + m_sub_ = ::std::forward(sub_); + } + + explicit BitPositionObject(::zserio::BitStreamReader& in, const allocator_type& allocator = allocator_type()); + + ~BitPositionObject() = default; + + BitPositionObject(const BitPositionObject&) = default; + BitPositionObject& operator=(const BitPositionObject&) = default; + + BitPositionObject(BitPositionObject&&) = default; + BitPositionObject& operator=(BitPositionObject&&) = default; + + BitPositionObject(::zserio::PropagateAllocatorT, + const BitPositionObject& other, const allocator_type& allocator); + + static const ::zserio::pmr::ITypeInfo& typeInfo(); + ::zserio::pmr::IReflectableConstPtr reflectable(const allocator_type& allocator = allocator_type()) const; + ::zserio::pmr::IReflectablePtr reflectable(const allocator_type& allocator = allocator_type()); + + uint8_t getPad() const; + void setPad(uint8_t pad_); + + const ::test_object::polymorphic_allocator::BitPositionSubObject& getSub() const; + ::test_object::polymorphic_allocator::BitPositionSubObject& getSub(); + void setSub(const ::test_object::polymorphic_allocator::BitPositionSubObject& sub_); + void setSub(::test_object::polymorphic_allocator::BitPositionSubObject&& sub_); + + size_t bitSizeOf(size_t bitPosition = 0) const; + + size_t initializeOffsets(size_t bitPosition = 0); + + bool operator==(const BitPositionObject& other) const; + + bool operator<(const BitPositionObject& other) const; + + uint32_t hashCode() const; + + void write(::zserio::BitStreamWriter& out) const; + + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + +private: + uint8_t readPad(::zserio::BitStreamReader& in); + ::test_object::polymorphic_allocator::BitPositionSubObject readSub(::zserio::BitStreamReader& in, + const allocator_type& allocator); + + size_t m_bitPosition = 0; + uint8_t m_pad_; + ::test_object::polymorphic_allocator::BitPositionSubObject m_sub_; +}; + +} // namespace polymorphic_allocator +} // namespace test_object + +#endif // TEST_OBJECT_POLYMORPHIC_ALLOCATOR_BIT_POSITION_OBJECT_H diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.cpp new file mode 100644 index 000000000..90d0ec488 --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.cpp @@ -0,0 +1,303 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace test_object +{ +namespace polymorphic_allocator +{ + +BitPositionSubObject::BitPositionSubObject(const allocator_type&) noexcept : + m_value_(uint8_t()) +{ +} + +BitPositionSubObject::BitPositionSubObject(::zserio::BitStreamReader& in, const allocator_type&) : + m_bitPosition(in.getBitPosition()), + m_value_(readValue(in)) +{ +} + +BitPositionSubObject::BitPositionSubObject(::zserio::PropagateAllocatorT, +const BitPositionSubObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +{ + (void)other; +} + +const ::zserio::pmr::ITypeInfo& BitPositionSubObject::typeInfo() +{ + static const ::zserio::StringView templateName; + static const ::zserio::Span<::zserio::BasicTemplateArgumentInfo> templateArguments; + + static const ::std::array<::zserio::BasicFieldInfo, 1> fields = { + ::zserio::BasicFieldInfo{ + ::zserio::makeStringView("value"), // schemaName + ::zserio::BuiltinTypeInfo::getFixedUnsignedBitField(UINT8_C(7)), // typeInfo + {}, // typeArguments + false, // isExtended + {}, // alignment + {}, // offset + {}, // initializer + false, // isOptional + {}, // optionalClause + {}, // constraint + false, // isArray + {}, // arrayLength + false, // isPacked + false // isImplicit + } + }; + + static const ::zserio::Span<::zserio::BasicParameterInfo> parameters; + + static const ::zserio::Span<::zserio::BasicFunctionInfo> functions; + + static const ::zserio::StructTypeInfo typeInfo = { + ::zserio::makeStringView("test_object.polymorphic_allocator.BitPositionSubObject"), + [](const allocator_type& allocator) -> ::zserio::pmr::IReflectablePtr + { + return std::allocate_shared<::zserio::ReflectableOwner>(allocator, allocator); + }, + templateName, templateArguments, + fields, parameters, functions + }; + + return typeInfo; +} + +::zserio::pmr::IReflectableConstPtr BitPositionSubObject::reflectable(const allocator_type& allocator) const +{ + class Reflectable : public ::zserio::ReflectableConstAllocatorHolderBase + { + public: + using ::zserio::ReflectableConstAllocatorHolderBase::getField; + using ::zserio::ReflectableConstAllocatorHolderBase::getParameter; + using ::zserio::ReflectableConstAllocatorHolderBase::callFunction; + using ::zserio::ReflectableConstAllocatorHolderBase::getAnyValue; + + explicit Reflectable(const ::test_object::polymorphic_allocator::BitPositionSubObject& object, const allocator_type& alloc) : + ::zserio::ReflectableConstAllocatorHolderBase(::test_object::polymorphic_allocator::BitPositionSubObject::typeInfo(), alloc), + m_object(object) + {} + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::pmr::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("value")) + { + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::pmr::AnyHolder getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + const ::test_object::polymorphic_allocator::BitPositionSubObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +::zserio::pmr::IReflectablePtr BitPositionSubObject::reflectable(const allocator_type& allocator) +{ + class Reflectable : public ::zserio::ReflectableAllocatorHolderBase + { + public: + explicit Reflectable(::test_object::polymorphic_allocator::BitPositionSubObject& object, const allocator_type& alloc) : + ::zserio::ReflectableAllocatorHolderBase(::test_object::polymorphic_allocator::BitPositionSubObject::typeInfo(), alloc), + m_object(object) + {} + + void initializeChildren() override + { + } + + size_t initializeOffsets(size_t bitPosition) override + { + return m_object.initializeOffsets(bitPosition); + } + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::pmr::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("value")) + { + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::pmr::IReflectablePtr getField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("value")) + { + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + void setField(::zserio::StringView name, + const ::zserio::AnyHolder& value) override + { + if (name == ::zserio::makeStringView("value")) + { + m_object.setValue(value.get()); + return; + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::pmr::IReflectablePtr createField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("value")) + { + m_object.setValue(uint8_t()); + return ::zserio::pmr::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::pmr::AnyHolder getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); + } + + ::zserio::pmr::AnyHolder getAnyValue(const allocator_type& alloc) override + { + return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + ::test_object::polymorphic_allocator::BitPositionSubObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +uint8_t BitPositionSubObject::getValue() const +{ + return m_value_; +} + +void BitPositionSubObject::setValue(uint8_t value_) +{ + m_value_ = value_; +} + +size_t BitPositionSubObject::bitSizeOf(size_t bitPosition) const +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(7); + + return endBitPosition - bitPosition; +} + +size_t BitPositionSubObject::initializeOffsets(size_t bitPosition) +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(7); + + return endBitPosition; +} + +bool BitPositionSubObject::operator==(const BitPositionSubObject& other) const +{ + if (this != &other) + { + return + (m_value_ == other.m_value_); + } + + return true; +} + +bool BitPositionSubObject::operator<(const BitPositionSubObject& other) const +{ + if (m_value_ < other.m_value_) + { + return true; + } + if (other.m_value_ < m_value_) + { + return false; + } + + return false; +} + +uint32_t BitPositionSubObject::hashCode() const +{ + uint32_t result = ::zserio::HASH_SEED; + + result = ::zserio::calcHashCode(result, m_value_); + + return result; +} + +void BitPositionSubObject::write(::zserio::BitStreamWriter& out) const +{ + out.writeBits(m_value_, UINT8_C(7)); +} +size_t BitPositionSubObject::bitPosition() const +{ + return m_bitPosition; +} + +uint8_t BitPositionSubObject::readValue(::zserio::BitStreamReader& in) +{ + return static_cast(in.readBits(UINT8_C(7))); +} + + +} // namespace polymorphic_allocator +} // namespace test_object diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.h new file mode 100644 index 000000000..a39f34ba4 --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/BitPositionSubObject.h @@ -0,0 +1,99 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. + */ + +#ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_BIT_POSITION_SUB_OBJECT_H +#define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_BIT_POSITION_SUB_OBJECT_H + +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace test_object +{ +namespace polymorphic_allocator +{ + +class BitPositionSubObject +{ +public: + using allocator_type = ::zserio::pmr::PropagatingPolymorphicAllocator<>; + + BitPositionSubObject() noexcept : + BitPositionSubObject(allocator_type()) + {} + + explicit BitPositionSubObject(const allocator_type& allocator) noexcept; + + explicit BitPositionSubObject( + uint8_t value_, + const allocator_type& allocator = allocator_type()) : + BitPositionSubObject(allocator) + { + m_value_ = value_; + } + + explicit BitPositionSubObject(::zserio::BitStreamReader& in, const allocator_type& allocator = allocator_type()); + + ~BitPositionSubObject() = default; + + BitPositionSubObject(const BitPositionSubObject&) = default; + BitPositionSubObject& operator=(const BitPositionSubObject&) = default; + + BitPositionSubObject(BitPositionSubObject&&) = default; + BitPositionSubObject& operator=(BitPositionSubObject&&) = default; + + BitPositionSubObject(::zserio::PropagateAllocatorT, + const BitPositionSubObject& other, const allocator_type& allocator); + + static const ::zserio::pmr::ITypeInfo& typeInfo(); + ::zserio::pmr::IReflectableConstPtr reflectable(const allocator_type& allocator = allocator_type()) const; + ::zserio::pmr::IReflectablePtr reflectable(const allocator_type& allocator = allocator_type()); + + uint8_t getValue() const; + void setValue(uint8_t value_); + + size_t bitSizeOf(size_t bitPosition = 0) const; + + size_t initializeOffsets(size_t bitPosition = 0); + + bool operator==(const BitPositionSubObject& other) const; + + bool operator<(const BitPositionSubObject& other) const; + + uint32_t hashCode() const; + + void write(::zserio::BitStreamWriter& out) const; + + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + +private: + uint8_t readValue(::zserio::BitStreamReader& in); + + size_t m_bitPosition = 0; + uint8_t m_value_; +}; + +} // namespace polymorphic_allocator +} // namespace test_object + +#endif // TEST_OBJECT_POLYMORPHIC_ALLOCATOR_BIT_POSITION_SUB_OBJECT_H diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.cpp index bb4e4a33b..a5b27492a 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.h index 60f7905d0..6a2da1cfc 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_BITMASK_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.cpp index 36b43642d..9bb168cc4 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.h index f8d805903..3c2186e11 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_ENUM_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.cpp index fe76ca881..4a2b24bac 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,36 +21,38 @@ namespace polymorphic_allocator { CreatorNested::CreatorNested(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_value_(uint32_t()), - m_text_(allocator), - m_externData_(allocator), - m_bytesData_(allocator), - m_creatorEnum_(::test_object::polymorphic_allocator::CreatorEnum()), - m_creatorBitmask_(::test_object::polymorphic_allocator::CreatorBitmask()) + m_isInitialized(false), + m_value_(uint32_t()), + m_text_(allocator), + m_externData_(allocator), + m_bytesData_(allocator), + m_creatorEnum_(::test_object::polymorphic_allocator::CreatorEnum()), + m_creatorBitmask_(::test_object::polymorphic_allocator::CreatorBitmask()) { } CreatorNested::CreatorNested(::zserio::BitStreamReader& in, uint32_t param_, const allocator_type& allocator) : - m_param_(param_), - m_isInitialized(true), - m_value_(readValue(in)), - m_text_(readText(in, allocator)), - m_externData_(readExternData(in, allocator)), - m_bytesData_(readBytesData(in, allocator)), - m_creatorEnum_(readCreatorEnum(in)), - m_creatorBitmask_(readCreatorBitmask(in)) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_value_(readValue(in)), + m_text_(readText(in, allocator)), + m_externData_(readExternData(in, allocator)), + m_bytesData_(readBytesData(in, allocator)), + m_creatorEnum_(readCreatorEnum(in)), + m_creatorBitmask_(readCreatorBitmask(in)) { } CreatorNested::CreatorNested(const CreatorNested& other) : - m_value_(other.m_value_), - m_text_(other.m_text_), - m_externData_(other.m_externData_), - m_bytesData_(other.m_bytesData_), - m_creatorEnum_(other.m_creatorEnum_), - m_creatorBitmask_(other.m_creatorBitmask_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_), + m_text_(other.m_text_), + m_externData_(other.m_externData_), + m_bytesData_(other.m_bytesData_), + m_creatorEnum_(other.m_creatorEnum_), + m_creatorBitmask_(other.m_creatorBitmask_) { if (other.m_isInitialized) { @@ -83,12 +85,13 @@ CreatorNested& CreatorNested::operator=(const CreatorNested& other) } CreatorNested::CreatorNested(CreatorNested&& other) : - m_value_(::std::move(other.m_value_)), - m_text_(::std::move(other.m_text_)), - m_externData_(::std::move(other.m_externData_)), - m_bytesData_(::std::move(other.m_bytesData_)), - m_creatorEnum_(::std::move(other.m_creatorEnum_)), - m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)), + m_text_(::std::move(other.m_text_)), + m_externData_(::std::move(other.m_externData_)), + m_bytesData_(::std::move(other.m_bytesData_)), + m_creatorEnum_(::std::move(other.m_creatorEnum_)), + m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) { if (other.m_isInitialized) { @@ -102,6 +105,7 @@ CreatorNested::CreatorNested(CreatorNested&& other) : CreatorNested& CreatorNested::operator=(CreatorNested&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); m_text_ = ::std::move(other.m_text_); m_externData_ = ::std::move(other.m_externData_); @@ -121,15 +125,17 @@ CreatorNested& CreatorNested::operator=(CreatorNested&& other) } CreatorNested::CreatorNested(::zserio::NoInitT, - const CreatorNested& other) : + const CreatorNested& other) + : m_isInitialized(false), - m_value_(other.m_value_), - m_text_(other.m_text_), - m_externData_(other.m_externData_), - m_bytesData_(other.m_bytesData_), - m_creatorEnum_(other.m_creatorEnum_), - m_creatorBitmask_(other.m_creatorBitmask_) + m_value_(other.m_value_), + m_text_(other.m_text_), + m_externData_(other.m_externData_), + m_bytesData_(other.m_bytesData_), + m_creatorEnum_(other.m_creatorEnum_), + m_creatorBitmask_(other.m_creatorBitmask_) { + (void)other; } CreatorNested& CreatorNested::assign(::zserio::NoInitT, @@ -143,24 +149,28 @@ CreatorNested& CreatorNested::assign(::zserio::NoInitT, m_creatorEnum_ = other.m_creatorEnum_; m_creatorBitmask_ = other.m_creatorBitmask_; + (void)other; return *this; } CreatorNested::CreatorNested(::zserio::NoInitT, - CreatorNested&& other) : +CreatorNested&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_value_(::std::move(other.m_value_)), - m_text_(::std::move(other.m_text_)), - m_externData_(::std::move(other.m_externData_)), - m_bytesData_(::std::move(other.m_bytesData_)), - m_creatorEnum_(::std::move(other.m_creatorEnum_)), - m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) + m_value_(::std::move(other.m_value_)), + m_text_(::std::move(other.m_text_)), + m_externData_(::std::move(other.m_externData_)), + m_bytesData_(::std::move(other.m_bytesData_)), + m_creatorEnum_(::std::move(other.m_creatorEnum_)), + m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) { + (void)other; } CreatorNested& CreatorNested::assign(::zserio::NoInitT, - CreatorNested&& other) +CreatorNested&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_value_ = ::std::move(other.m_value_); m_text_ = ::std::move(other.m_text_); @@ -169,17 +179,20 @@ CreatorNested& CreatorNested::assign(::zserio::NoInitT, m_creatorEnum_ = ::std::move(other.m_creatorEnum_); m_creatorBitmask_ = ::std::move(other.m_creatorBitmask_); + (void)other; return *this; } CreatorNested::CreatorNested(::zserio::PropagateAllocatorT, - const CreatorNested& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), - m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), - m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), - m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) +const CreatorNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), + m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), + m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), + m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) { if (other.m_isInitialized) { @@ -189,18 +202,22 @@ CreatorNested::CreatorNested(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } CreatorNested::CreatorNested(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const CreatorNested& other, const allocator_type& allocator) : +const CreatorNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), - m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), - m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), - m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), + m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), + m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), + m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& CreatorNested::typeInfo() @@ -397,6 +414,11 @@ ::zserio::pmr::IReflectableConstPtr CreatorNested::reflectable(const allocator_t return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::CreatorNested& m_object; }; @@ -620,6 +642,11 @@ ::zserio::pmr::IReflectablePtr CreatorNested::reflectable(const allocator_type& return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::CreatorNested& m_object; }; @@ -876,6 +903,10 @@ void CreatorNested::write(::zserio::BitStreamWriter& out) const ::zserio::write(out, m_creatorEnum_); m_creatorBitmask_.write(out); } +size_t CreatorNested::bitPosition() const +{ + return m_bitPosition; +} uint32_t CreatorNested::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.h index b25cef4e8..a28ab18bd 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_NESTED_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -131,6 +137,14 @@ class CreatorNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); ::zserio::pmr::string readText(::zserio::BitStreamReader& in, @@ -142,6 +156,7 @@ class CreatorNested ::test_object::polymorphic_allocator::CreatorEnum readCreatorEnum(::zserio::BitStreamReader& in); ::test_object::polymorphic_allocator::CreatorBitmask readCreatorBitmask(::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; uint32_t m_param_; bool m_isInitialized; uint32_t m_value_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.cpp index 7c6c2e2f2..1944f88c5 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,43 +21,45 @@ namespace polymorphic_allocator { CreatorObject::CreatorObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_value_(uint32_t()), - m_nested_(allocator), - m_text_(allocator), - m_nestedArray_(allocator), - m_textArray_(allocator), - m_externArray_(::zserio::NullOpt), - m_bytesArray_(::zserio::NullOpt), - m_optionalBool_(::zserio::NullOpt), - m_optionalNested_(::zserio::NullOpt) + m_areChildrenInitialized(false), + m_value_(uint32_t()), + m_nested_(allocator), + m_text_(allocator), + m_nestedArray_(allocator), + m_textArray_(allocator), + m_externArray_(::zserio::NullOpt), + m_bytesArray_(::zserio::NullOpt), + m_optionalBool_(::zserio::NullOpt), + m_optionalNested_(::zserio::NullOpt) { } CreatorObject::CreatorObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_value_(readValue(in)), - m_nested_(readNested(in, allocator)), - m_text_(readText(in, allocator)), - m_nestedArray_(readNestedArray(in, allocator)), - m_textArray_(readTextArray(in, allocator)), - m_externArray_(readExternArray(in, allocator)), - m_bytesArray_(readBytesArray(in, allocator)), - m_optionalBool_(readOptionalBool(in)), - m_optionalNested_(readOptionalNested(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_value_(readValue(in)), + m_nested_(readNested(in, allocator)), + m_text_(readText(in, allocator)), + m_nestedArray_(readNestedArray(in, allocator)), + m_textArray_(readTextArray(in, allocator)), + m_externArray_(readExternArray(in, allocator)), + m_bytesArray_(readBytesArray(in, allocator)), + m_optionalBool_(readOptionalBool(in)), + m_optionalNested_(readOptionalNested(in, allocator)) { } CreatorObject::CreatorObject(const CreatorObject& other) : - m_value_(other.m_value_), - m_nested_(::zserio::NoInit, other.m_nested_), - m_text_(other.m_text_), - m_nestedArray_(::zserio::NoInit, other.m_nestedArray_), - m_textArray_(other.m_textArray_), - m_externArray_(other.m_externArray_), - m_bytesArray_(other.m_bytesArray_), - m_optionalBool_(other.m_optionalBool_), - m_optionalNested_(::zserio::NoInit, other.m_optionalNested_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_), + m_nested_(::zserio::NoInit, other.m_nested_), + m_text_(other.m_text_), + m_nestedArray_(::zserio::NoInit, other.m_nestedArray_), + m_textArray_(other.m_textArray_), + m_externArray_(other.m_externArray_), + m_bytesArray_(other.m_bytesArray_), + m_optionalBool_(other.m_optionalBool_), + m_optionalNested_(::zserio::NoInit, other.m_optionalNested_) { if (other.m_areChildrenInitialized) { @@ -93,15 +95,16 @@ CreatorObject& CreatorObject::operator=(const CreatorObject& other) } CreatorObject::CreatorObject(CreatorObject&& other) : - m_value_(::std::move(other.m_value_)), - m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)), - m_text_(::std::move(other.m_text_)), - m_nestedArray_(::zserio::NoInit, ::std::move(other.m_nestedArray_)), - m_textArray_(::std::move(other.m_textArray_)), - m_externArray_(::std::move(other.m_externArray_)), - m_bytesArray_(::std::move(other.m_bytesArray_)), - m_optionalBool_(::std::move(other.m_optionalBool_)), - m_optionalNested_(::zserio::NoInit, ::std::move(other.m_optionalNested_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)), + m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)), + m_text_(::std::move(other.m_text_)), + m_nestedArray_(::zserio::NoInit, ::std::move(other.m_nestedArray_)), + m_textArray_(::std::move(other.m_textArray_)), + m_externArray_(::std::move(other.m_externArray_)), + m_bytesArray_(::std::move(other.m_bytesArray_)), + m_optionalBool_(::std::move(other.m_optionalBool_)), + m_optionalNested_(::zserio::NoInit, ::std::move(other.m_optionalNested_)) { if (other.m_areChildrenInitialized) { @@ -115,6 +118,7 @@ CreatorObject::CreatorObject(CreatorObject&& other) : CreatorObject& CreatorObject::operator=(CreatorObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); (void)m_nested_.assign(::zserio::NoInit, ::std::move(other.m_nested_)); m_text_ = ::std::move(other.m_text_); @@ -137,16 +141,18 @@ CreatorObject& CreatorObject::operator=(CreatorObject&& other) } CreatorObject::CreatorObject(::zserio::PropagateAllocatorT, - const CreatorObject& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), - m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_nestedArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nestedArray_, allocator)), - m_textArray_(::zserio::allocatorPropagatingCopy(other.m_textArray_, allocator)), - m_externArray_(::zserio::allocatorPropagatingCopy(other.m_externArray_, allocator)), - m_bytesArray_(::zserio::allocatorPropagatingCopy(other.m_bytesArray_, allocator)), - m_optionalBool_(::zserio::allocatorPropagatingCopy(other.m_optionalBool_, allocator)), - m_optionalNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_optionalNested_, allocator)) +const CreatorObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), + m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_nestedArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nestedArray_, allocator)), + m_textArray_(::zserio::allocatorPropagatingCopy(other.m_textArray_, allocator)), + m_externArray_(::zserio::allocatorPropagatingCopy(other.m_externArray_, allocator)), + m_bytesArray_(::zserio::allocatorPropagatingCopy(other.m_bytesArray_, allocator)), + m_optionalBool_(::zserio::allocatorPropagatingCopy(other.m_optionalBool_, allocator)), + m_optionalNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_optionalNested_, allocator)) { if (other.m_areChildrenInitialized) { @@ -156,6 +162,7 @@ CreatorObject::CreatorObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::pmr::ITypeInfo& CreatorObject::typeInfo() @@ -427,6 +434,11 @@ ::zserio::pmr::IReflectableConstPtr CreatorObject::reflectable(const allocator_t return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::CreatorObject& m_object; }; @@ -721,6 +733,11 @@ ::zserio::pmr::IReflectablePtr CreatorObject::reflectable(const allocator_type& return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::CreatorObject& m_object; }; @@ -1252,6 +1269,10 @@ void CreatorObject::write(::zserio::BitStreamWriter& out) const out.writeBool(false); } } +size_t CreatorObject::bitPosition() const +{ + return m_bitPosition; +} void CreatorObject::ZserioArrayExpressions_nestedArray::initializeElement(CreatorObject& owner, ::test_object::polymorphic_allocator::CreatorNested& element, size_t) diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.h index b4eeb874e..87c4381b2 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -156,6 +162,14 @@ class CreatorObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioArrayExpressions_nestedArray { @@ -198,6 +212,7 @@ class CreatorObject ::zserio::InplaceOptionalHolder<::test_object::polymorphic_allocator::CreatorNested> readOptionalNested(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; uint32_t m_value_; ::test_object::polymorphic_allocator::CreatorNested m_nested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.cpp index c36bf7f99..84a5ca5c3 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.h index e597676c5..259fb7230 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/CreatorUnsignedEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_UNSIGNED_ENUM_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_CREATOR_UNSIGNED_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.cpp index 24ae3b314..6a418a96f 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -22,19 +22,23 @@ namespace polymorphic_allocator { DebugStringObject::DebugStringObject(const allocator_type& allocator) noexcept : - m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) + m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) { } DebugStringObject::DebugStringObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_text_(readText(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_text_(readText(in, allocator)) { } DebugStringObject::DebugStringObject(::zserio::PropagateAllocatorT, - const DebugStringObject& other, const allocator_type& allocator) : - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) +const DebugStringObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& DebugStringObject::typeInfo() @@ -117,6 +121,11 @@ ::zserio::pmr::IReflectableConstPtr DebugStringObject::reflectable(const allocat return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::DebugStringObject& m_object; }; @@ -202,6 +211,11 @@ ::zserio::pmr::IReflectablePtr DebugStringObject::reflectable(const allocator_ty return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::DebugStringObject& m_object; }; @@ -285,6 +299,10 @@ void DebugStringObject::write(::zserio::BitStreamWriter& out) const { out.writeString(m_text_); } +size_t DebugStringObject::bitPosition() const +{ + return m_bitPosition; +} ::zserio::pmr::string DebugStringObject::readText(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.h index 4c0c8733d..4b1c67f05 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_DEBUG_STRING_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_DEBUG_STRING_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -76,10 +82,19 @@ class DebugStringObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::pmr::string readText(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; ::zserio::pmr::string m_text_; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.cpp index 163ce6eee..2d7b706a3 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -22,21 +22,23 @@ namespace polymorphic_allocator { DebugStringParamObject::DebugStringParamObject(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) + m_isInitialized(false), + m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) { } DebugStringParamObject::DebugStringParamObject(::zserio::BitStreamReader& in, int32_t param_, const allocator_type& allocator) : - m_param_(param_), - m_isInitialized(true), - m_text_(readText(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_text_(readText(in, allocator)) { } DebugStringParamObject::DebugStringParamObject(const DebugStringParamObject& other) : - m_text_(other.m_text_) + m_bitPosition(other.m_bitPosition), + m_text_(other.m_text_) { if (other.m_isInitialized) { @@ -64,7 +66,8 @@ DebugStringParamObject& DebugStringParamObject::operator=(const DebugStringParam } DebugStringParamObject::DebugStringParamObject(DebugStringParamObject&& other) : - m_text_(::std::move(other.m_text_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_text_(::std::move(other.m_text_)) { if (other.m_isInitialized) { @@ -78,6 +81,7 @@ DebugStringParamObject::DebugStringParamObject(DebugStringParamObject&& other) : DebugStringParamObject& DebugStringParamObject::operator=(DebugStringParamObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_text_ = ::std::move(other.m_text_); if (other.m_isInitialized) { @@ -92,10 +96,12 @@ DebugStringParamObject& DebugStringParamObject::operator=(DebugStringParamObject } DebugStringParamObject::DebugStringParamObject(::zserio::NoInitT, - const DebugStringParamObject& other) : + const DebugStringParamObject& other) + : m_isInitialized(false), - m_text_(other.m_text_) + m_text_(other.m_text_) { + (void)other; } DebugStringParamObject& DebugStringParamObject::assign(::zserio::NoInitT, @@ -104,28 +110,35 @@ DebugStringParamObject& DebugStringParamObject::assign(::zserio::NoInitT, m_isInitialized = false; m_text_ = other.m_text_; + (void)other; return *this; } DebugStringParamObject::DebugStringParamObject(::zserio::NoInitT, - DebugStringParamObject&& other) : +DebugStringParamObject&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_text_(::std::move(other.m_text_)) + m_text_(::std::move(other.m_text_)) { + (void)other; } DebugStringParamObject& DebugStringParamObject::assign(::zserio::NoInitT, - DebugStringParamObject&& other) +DebugStringParamObject&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_text_ = ::std::move(other.m_text_); + (void)other; return *this; } DebugStringParamObject::DebugStringParamObject(::zserio::PropagateAllocatorT, - const DebugStringParamObject& other, const allocator_type& allocator) : - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) +const DebugStringParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { if (other.m_isInitialized) { @@ -135,13 +148,17 @@ DebugStringParamObject::DebugStringParamObject(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } DebugStringParamObject::DebugStringParamObject(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const DebugStringParamObject& other, const allocator_type& allocator) : +const DebugStringParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& DebugStringParamObject::typeInfo() @@ -238,6 +255,11 @@ ::zserio::pmr::IReflectableConstPtr DebugStringParamObject::reflectable(const al return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::DebugStringParamObject& m_object; }; @@ -355,6 +377,11 @@ ::zserio::pmr::IReflectablePtr DebugStringParamObject::reflectable(const allocat return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::DebugStringParamObject& m_object; }; @@ -471,6 +498,10 @@ void DebugStringParamObject::write(::zserio::BitStreamWriter& out) const { out.writeString(m_text_); } +size_t DebugStringParamObject::bitPosition() const +{ + return m_bitPosition; +} ::zserio::pmr::string DebugStringParamObject::readText(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.h index 4297875ac..c14e94e04 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/DebugStringParamObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_DEBUG_STRING_PARAM_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_DEBUG_STRING_PARAM_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -96,10 +102,19 @@ class DebugStringParamObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::pmr::string readText(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; int32_t m_param_; bool m_isInitialized; ::zserio::pmr::string m_text_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.cpp index cc2e4fed5..c7a1c808c 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.h index 74950f19a..908d9c5ba 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_BITMASK_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.cpp index 8617fd0d9..e2e20247a 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.h index c32953bcb..39a36c151 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_ENUM_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.cpp index 4951d5516..c03a217dc 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -22,23 +22,25 @@ namespace polymorphic_allocator { ReflectableNested::ReflectableNested(const allocator_type&) noexcept : - m_isInitialized(false), - m_value_(uint32_t()) + m_isInitialized(false), + m_value_(uint32_t()) { } ReflectableNested::ReflectableNested(::zserio::BitStreamReader& in, int32_t dummyParam_, ::zserio::pmr::string& stringParam_, const allocator_type&) : - m_dummyParam_(dummyParam_), - m_stringParam_(&stringParam_), - m_isInitialized(true), - m_value_(readValue(in)) + m_bitPosition(in.getBitPosition()), + m_dummyParam_(dummyParam_), + m_stringParam_(&stringParam_), + m_isInitialized(true), + m_value_(readValue(in)) { } ReflectableNested::ReflectableNested(const ReflectableNested& other) : - m_value_(other.m_value_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_) { if (other.m_isInitialized) { @@ -66,7 +68,8 @@ ReflectableNested& ReflectableNested::operator=(const ReflectableNested& other) } ReflectableNested::ReflectableNested(ReflectableNested&& other) : - m_value_(::std::move(other.m_value_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)) { if (other.m_isInitialized) { @@ -80,6 +83,7 @@ ReflectableNested::ReflectableNested(ReflectableNested&& other) : ReflectableNested& ReflectableNested::operator=(ReflectableNested&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); if (other.m_isInitialized) { @@ -94,10 +98,12 @@ ReflectableNested& ReflectableNested::operator=(ReflectableNested&& other) } ReflectableNested::ReflectableNested(::zserio::NoInitT, - const ReflectableNested& other) : + const ReflectableNested& other) + : m_isInitialized(false), - m_value_(other.m_value_) + m_value_(other.m_value_) { + (void)other; } ReflectableNested& ReflectableNested::assign(::zserio::NoInitT, @@ -106,28 +112,35 @@ ReflectableNested& ReflectableNested::assign(::zserio::NoInitT, m_isInitialized = false; m_value_ = other.m_value_; + (void)other; return *this; } ReflectableNested::ReflectableNested(::zserio::NoInitT, - ReflectableNested&& other) : +ReflectableNested&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_value_(::std::move(other.m_value_)) + m_value_(::std::move(other.m_value_)) { + (void)other; } ReflectableNested& ReflectableNested::assign(::zserio::NoInitT, - ReflectableNested&& other) +ReflectableNested&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_value_ = ::std::move(other.m_value_); + (void)other; return *this; } ReflectableNested::ReflectableNested(::zserio::PropagateAllocatorT, - const ReflectableNested& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +const ReflectableNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { if (other.m_isInitialized) { @@ -137,13 +150,17 @@ ReflectableNested::ReflectableNested(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } ReflectableNested::ReflectableNested(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const ReflectableNested& other, const allocator_type& allocator) : +const ReflectableNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& ReflectableNested::typeInfo() @@ -263,6 +280,11 @@ ::zserio::pmr::IReflectableConstPtr ReflectableNested::reflectable(const allocat return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ReflectableNested& m_object; }; @@ -407,6 +429,11 @@ ::zserio::pmr::IReflectablePtr ReflectableNested::reflectable(const allocator_ty return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ReflectableNested& m_object; }; @@ -551,6 +578,10 @@ void ReflectableNested::write(::zserio::BitStreamWriter& out) const { out.writeBits(m_value_, UINT8_C(31)); } +size_t ReflectableNested::bitPosition() const +{ + return m_bitPosition; +} uint32_t ReflectableNested::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.h index 366b2b408..12b94c076 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_NESTED_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -99,9 +105,18 @@ class ReflectableNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; int32_t m_dummyParam_; ::zserio::pmr::string* m_stringParam_; bool m_isInitialized; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.cpp index 709fc55fa..21635320a 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,22 +21,24 @@ namespace polymorphic_allocator { ReflectableObject::ReflectableObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_stringField_(allocator), - m_reflectableNested_(allocator) + m_areChildrenInitialized(false), + m_stringField_(allocator), + m_reflectableNested_(allocator) { } ReflectableObject::ReflectableObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_stringField_(readStringField(in, allocator)), - m_reflectableNested_(readReflectableNested(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_stringField_(readStringField(in, allocator)), + m_reflectableNested_(readReflectableNested(in, allocator)) { } ReflectableObject::ReflectableObject(const ReflectableObject& other) : - m_stringField_(other.m_stringField_), - m_reflectableNested_(::zserio::NoInit, other.m_reflectableNested_) + m_bitPosition(other.m_bitPosition), + m_stringField_(other.m_stringField_), + m_reflectableNested_(::zserio::NoInit, other.m_reflectableNested_) { if (other.m_areChildrenInitialized) { @@ -65,8 +67,9 @@ ReflectableObject& ReflectableObject::operator=(const ReflectableObject& other) } ReflectableObject::ReflectableObject(ReflectableObject&& other) : - m_stringField_(::std::move(other.m_stringField_)), - m_reflectableNested_(::zserio::NoInit, ::std::move(other.m_reflectableNested_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_stringField_(::std::move(other.m_stringField_)), + m_reflectableNested_(::zserio::NoInit, ::std::move(other.m_reflectableNested_)) { if (other.m_areChildrenInitialized) { @@ -80,6 +83,7 @@ ReflectableObject::ReflectableObject(ReflectableObject&& other) : ReflectableObject& ReflectableObject::operator=(ReflectableObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_stringField_ = ::std::move(other.m_stringField_); (void)m_reflectableNested_.assign(::zserio::NoInit, ::std::move(other.m_reflectableNested_)); if (other.m_areChildrenInitialized) @@ -95,9 +99,11 @@ ReflectableObject& ReflectableObject::operator=(ReflectableObject&& other) } ReflectableObject::ReflectableObject(::zserio::PropagateAllocatorT, - const ReflectableObject& other, const allocator_type& allocator) : - m_stringField_(::zserio::allocatorPropagatingCopy(other.m_stringField_, allocator)), - m_reflectableNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableNested_, allocator)) +const ReflectableObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_stringField_(::zserio::allocatorPropagatingCopy(other.m_stringField_, allocator)), + m_reflectableNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableNested_, allocator)) { if (other.m_areChildrenInitialized) { @@ -107,6 +113,7 @@ ReflectableObject::ReflectableObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::pmr::ITypeInfo& ReflectableObject::typeInfo() @@ -213,6 +220,11 @@ ::zserio::pmr::IReflectableConstPtr ReflectableObject::reflectable(const allocat return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ReflectableObject& m_object; }; @@ -317,6 +329,11 @@ ::zserio::pmr::IReflectablePtr ReflectableObject::reflectable(const allocator_ty return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ReflectableObject& m_object; }; @@ -452,6 +469,10 @@ void ReflectableObject::write(::zserio::BitStreamWriter& out) const } m_reflectableNested_.write(out); } +size_t ReflectableObject::bitPosition() const +{ + return m_bitPosition; +} ::zserio::pmr::string ReflectableObject::readStringField(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.h index 5208f9032..8f2b892f5 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -90,12 +96,21 @@ class ReflectableObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::pmr::string readStringField(::zserio::BitStreamReader& in, const allocator_type& allocator); ::test_object::polymorphic_allocator::ReflectableNested readReflectableNested(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; ::zserio::pmr::string m_stringField_; ::test_object::polymorphic_allocator::ReflectableNested m_reflectableNested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.cpp index 182b7ccb4..8372a3020 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.h index 502cba5e5..101c0a2b1 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_BITMASK_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.cpp index 725d42128..3ce7b7830 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -20,21 +20,23 @@ namespace polymorphic_allocator { ReflectableUtilChoice::ReflectableUtilChoice(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_objectChoice(allocator) + m_isInitialized(false), + m_objectChoice(allocator) { } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::BitStreamReader& in, uint8_t param_, const allocator_type& allocator) : - m_param_(param_), - m_isInitialized(true), - m_objectChoice(readObject(in, allocator), allocator) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_objectChoice(readObject(in, allocator), allocator) { } ReflectableUtilChoice::ReflectableUtilChoice(const ReflectableUtilChoice& other) : - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { if (other.m_isInitialized) { @@ -62,7 +64,8 @@ ReflectableUtilChoice& ReflectableUtilChoice::operator=(const ReflectableUtilCho } ReflectableUtilChoice::ReflectableUtilChoice(ReflectableUtilChoice&& other) : - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { if (other.m_isInitialized) { @@ -76,6 +79,7 @@ ReflectableUtilChoice::ReflectableUtilChoice(ReflectableUtilChoice&& other) : ReflectableUtilChoice& ReflectableUtilChoice::operator=(ReflectableUtilChoice&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); if (other.m_isInitialized) { @@ -90,10 +94,12 @@ ReflectableUtilChoice& ReflectableUtilChoice::operator=(ReflectableUtilChoice&& } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::NoInitT, - const ReflectableUtilChoice& other) : + const ReflectableUtilChoice& other) + : m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { + (void)other; } ReflectableUtilChoice& ReflectableUtilChoice::assign(::zserio::NoInitT, @@ -102,28 +108,35 @@ ReflectableUtilChoice& ReflectableUtilChoice::assign(::zserio::NoInitT, m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, other.m_objectChoice); + (void)other; return *this; } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::NoInitT, - ReflectableUtilChoice&& other) : +ReflectableUtilChoice&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { + (void)other; } ReflectableUtilChoice& ReflectableUtilChoice::assign(::zserio::NoInitT, - ReflectableUtilChoice&& other) +ReflectableUtilChoice&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); + (void)other; return *this; } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::PropagateAllocatorT, - const ReflectableUtilChoice& other, const allocator_type& allocator) : - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) +const ReflectableUtilChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { if (other.m_isInitialized) { @@ -133,13 +146,17 @@ ReflectableUtilChoice::ReflectableUtilChoice(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const ReflectableUtilChoice& other, const allocator_type& allocator) : +const ReflectableUtilChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& ReflectableUtilChoice::typeInfo() @@ -262,6 +279,11 @@ ::zserio::pmr::IReflectableConstPtr ReflectableUtilChoice::reflectable(const all return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ReflectableUtilChoice& m_object; }; @@ -391,13 +413,17 @@ ::zserio::pmr::IReflectablePtr ReflectableUtilChoice::reflectable(const allocato return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ReflectableUtilChoice& m_object; }; return std::allocate_shared(allocator, *this, allocator); } - void ReflectableUtilChoice::initialize( uint8_t param_) { @@ -575,6 +601,10 @@ void ReflectableUtilChoice::write(::zserio::BitStreamWriter& out) const break; } } +size_t ReflectableUtilChoice::bitPosition() const +{ + return m_bitPosition; +} ::zserio::pmr::AnyHolder ReflectableUtilChoice::readObject(::zserio::BitStreamReader& in, const allocator_type& allocator) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.h index 51b57a80c..bd258c0a8 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilChoice.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_CHOICE_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_CHOICE_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -95,12 +101,21 @@ class ReflectableUtilChoice void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: using ZserioArrayType_array = ::zserio::Array<::zserio::pmr::vector, ::zserio::StdIntArrayTraits, ::zserio::ArrayType::AUTO>; ::zserio::pmr::AnyHolder readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::pmr::AnyHolder copyObject(const allocator_type& allocator) const; + size_t m_bitPosition = 0; uint8_t m_param_; bool m_isInitialized; ::zserio::pmr::AnyHolder m_objectChoice; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.cpp index c014d8b88..9d4b475d7 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.h index b6344b537..7dba390b4 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_ENUM_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.cpp index c96d27cae..bfbfb98c4 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,22 +21,24 @@ namespace polymorphic_allocator { ReflectableUtilObject::ReflectableUtilObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_choiceParam_(uint8_t()), - m_reflectableUtilChoice_(allocator) + m_areChildrenInitialized(false), + m_choiceParam_(uint8_t()), + m_reflectableUtilChoice_(allocator) { } ReflectableUtilObject::ReflectableUtilObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_choiceParam_(readChoiceParam(in)), - m_reflectableUtilChoice_(readReflectableUtilChoice(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_choiceParam_(readChoiceParam(in)), + m_reflectableUtilChoice_(readReflectableUtilChoice(in, allocator)) { } ReflectableUtilObject::ReflectableUtilObject(const ReflectableUtilObject& other) : - m_choiceParam_(other.m_choiceParam_), - m_reflectableUtilChoice_(::zserio::NoInit, other.m_reflectableUtilChoice_) + m_bitPosition(other.m_bitPosition), + m_choiceParam_(other.m_choiceParam_), + m_reflectableUtilChoice_(::zserio::NoInit, other.m_reflectableUtilChoice_) { if (other.m_areChildrenInitialized) { @@ -65,8 +67,9 @@ ReflectableUtilObject& ReflectableUtilObject::operator=(const ReflectableUtilObj } ReflectableUtilObject::ReflectableUtilObject(ReflectableUtilObject&& other) : - m_choiceParam_(::std::move(other.m_choiceParam_)), - m_reflectableUtilChoice_(::zserio::NoInit, ::std::move(other.m_reflectableUtilChoice_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_choiceParam_(::std::move(other.m_choiceParam_)), + m_reflectableUtilChoice_(::zserio::NoInit, ::std::move(other.m_reflectableUtilChoice_)) { if (other.m_areChildrenInitialized) { @@ -80,6 +83,7 @@ ReflectableUtilObject::ReflectableUtilObject(ReflectableUtilObject&& other) : ReflectableUtilObject& ReflectableUtilObject::operator=(ReflectableUtilObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_choiceParam_ = ::std::move(other.m_choiceParam_); (void)m_reflectableUtilChoice_.assign(::zserio::NoInit, ::std::move(other.m_reflectableUtilChoice_)); if (other.m_areChildrenInitialized) @@ -95,9 +99,11 @@ ReflectableUtilObject& ReflectableUtilObject::operator=(ReflectableUtilObject&& } ReflectableUtilObject::ReflectableUtilObject(::zserio::PropagateAllocatorT, - const ReflectableUtilObject& other, const allocator_type& allocator) : - m_choiceParam_(::zserio::allocatorPropagatingCopy(other.m_choiceParam_, allocator)), - m_reflectableUtilChoice_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableUtilChoice_, allocator)) +const ReflectableUtilObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_choiceParam_(::zserio::allocatorPropagatingCopy(other.m_choiceParam_, allocator)), + m_reflectableUtilChoice_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableUtilChoice_, allocator)) { if (other.m_areChildrenInitialized) { @@ -107,6 +113,7 @@ ReflectableUtilObject::ReflectableUtilObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::pmr::ITypeInfo& ReflectableUtilObject::typeInfo() @@ -212,6 +219,11 @@ ::zserio::pmr::IReflectableConstPtr ReflectableUtilObject::reflectable(const all return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ReflectableUtilObject& m_object; }; @@ -316,6 +328,11 @@ ::zserio::pmr::IReflectablePtr ReflectableUtilObject::reflectable(const allocato return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ReflectableUtilObject& m_object; }; @@ -437,6 +454,10 @@ void ReflectableUtilObject::write(::zserio::BitStreamWriter& out) const } m_reflectableUtilChoice_.write(out); } +size_t ReflectableUtilObject::bitPosition() const +{ + return m_bitPosition; +} uint8_t ReflectableUtilObject::readChoiceParam(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.h index 5a2a25aa6..08865f393 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -84,11 +90,20 @@ class ReflectableUtilObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint8_t readChoiceParam(::zserio::BitStreamReader& in); ::test_object::polymorphic_allocator::ReflectableUtilChoice readReflectableUtilChoice(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; uint8_t m_choiceParam_; ::test_object::polymorphic_allocator::ReflectableUtilChoice m_reflectableUtilChoice_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.cpp index 09ab31d53..32bc2f0a3 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -20,14 +20,15 @@ namespace polymorphic_allocator { ReflectableUtilUnion::ReflectableUtilUnion(const allocator_type& allocator) noexcept : - m_choiceTag(UNDEFINED_CHOICE), - m_objectChoice(allocator) + m_choiceTag(UNDEFINED_CHOICE), + m_objectChoice(allocator) { } ReflectableUtilUnion::ReflectableUtilUnion(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_choiceTag(readChoiceTag(in)), - m_objectChoice(readObject(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_choiceTag(readChoiceTag(in)), + m_objectChoice(readObject(in, allocator)) { } @@ -173,6 +174,11 @@ ::zserio::pmr::IReflectableConstPtr ReflectableUtilUnion::reflectable(const allo return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::ReflectableUtilUnion& m_object; }; @@ -326,6 +332,11 @@ ::zserio::pmr::IReflectablePtr ReflectableUtilUnion::reflectable(const allocator return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::ReflectableUtilUnion& m_object; }; @@ -574,6 +585,10 @@ void ReflectableUtilUnion::write(::zserio::BitStreamWriter& out) const throw ::zserio::CppRuntimeException("No match in union ReflectableUtilUnion!"); } } +size_t ReflectableUtilUnion::bitPosition() const +{ + return m_bitPosition; +} ReflectableUtilUnion::ChoiceTag ReflectableUtilUnion::readChoiceTag(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.h index a3f2d965a..4c4e7e5d5 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/ReflectableUtilUnion.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_UNION_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_REFLECTABLE_UTIL_UNION_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -88,11 +94,19 @@ class ReflectableUtilUnion void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ChoiceTag readChoiceTag(::zserio::BitStreamReader& in); ::zserio::pmr::AnyHolder readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::pmr::AnyHolder copyObject(const allocator_type& allocator) const; - + size_t m_bitPosition = 0; ChoiceTag m_choiceTag; ::zserio::pmr::AnyHolder m_objectChoice; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.cpp index ad97e9d7c..4ee93102b 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.h index deaca9be2..af45e2ebc 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_SERIALIZE_ENUM_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_SERIALIZE_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.cpp index b331c5b9c..dbd91a5f2 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,24 +21,26 @@ namespace polymorphic_allocator { SerializeNested::SerializeNested(const allocator_type&) noexcept : - m_isInitialized(false), - m_offset_(uint8_t()), - m_optionalValue_(::zserio::NullOpt) + m_isInitialized(false), + m_offset_(uint8_t()), + m_optionalValue_(::zserio::NullOpt) { } SerializeNested::SerializeNested(::zserio::BitStreamReader& in, int8_t param_, const allocator_type&) : - m_param_(param_), - m_isInitialized(true), - m_offset_(readOffset(in)), - m_optionalValue_(readOptionalValue(in)) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_offset_(readOffset(in)), + m_optionalValue_(readOptionalValue(in)) { } SerializeNested::SerializeNested(const SerializeNested& other) : - m_offset_(other.m_offset_), - m_optionalValue_(other.m_optionalValue_) + m_bitPosition(other.m_bitPosition), + m_offset_(other.m_offset_), + m_optionalValue_(other.m_optionalValue_) { if (other.m_isInitialized) { @@ -67,8 +69,9 @@ SerializeNested& SerializeNested::operator=(const SerializeNested& other) } SerializeNested::SerializeNested(SerializeNested&& other) : - m_offset_(::std::move(other.m_offset_)), - m_optionalValue_(::std::move(other.m_optionalValue_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_offset_(::std::move(other.m_offset_)), + m_optionalValue_(::std::move(other.m_optionalValue_)) { if (other.m_isInitialized) { @@ -82,6 +85,7 @@ SerializeNested::SerializeNested(SerializeNested&& other) : SerializeNested& SerializeNested::operator=(SerializeNested&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_offset_ = ::std::move(other.m_offset_); m_optionalValue_ = ::std::move(other.m_optionalValue_); if (other.m_isInitialized) @@ -97,11 +101,13 @@ SerializeNested& SerializeNested::operator=(SerializeNested&& other) } SerializeNested::SerializeNested(::zserio::NoInitT, - const SerializeNested& other) : + const SerializeNested& other) + : m_isInitialized(false), - m_offset_(other.m_offset_), - m_optionalValue_(other.m_optionalValue_) + m_offset_(other.m_offset_), + m_optionalValue_(other.m_optionalValue_) { + (void)other; } SerializeNested& SerializeNested::assign(::zserio::NoInitT, @@ -111,31 +117,38 @@ SerializeNested& SerializeNested::assign(::zserio::NoInitT, m_offset_ = other.m_offset_; m_optionalValue_ = other.m_optionalValue_; + (void)other; return *this; } SerializeNested::SerializeNested(::zserio::NoInitT, - SerializeNested&& other) : +SerializeNested&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_offset_(::std::move(other.m_offset_)), - m_optionalValue_(::std::move(other.m_optionalValue_)) + m_offset_(::std::move(other.m_offset_)), + m_optionalValue_(::std::move(other.m_optionalValue_)) { + (void)other; } SerializeNested& SerializeNested::assign(::zserio::NoInitT, - SerializeNested&& other) +SerializeNested&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_offset_ = ::std::move(other.m_offset_); m_optionalValue_ = ::std::move(other.m_optionalValue_); + (void)other; return *this; } SerializeNested::SerializeNested(::zserio::PropagateAllocatorT, - const SerializeNested& other, const allocator_type& allocator) : - m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), - m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) +const SerializeNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), + m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) { if (other.m_isInitialized) { @@ -145,14 +158,18 @@ SerializeNested::SerializeNested(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } SerializeNested::SerializeNested(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const SerializeNested& other, const allocator_type& allocator) : +const SerializeNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), - m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) + m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), + m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& SerializeNested::typeInfo() @@ -274,6 +291,11 @@ ::zserio::pmr::IReflectableConstPtr SerializeNested::reflectable(const allocator return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::SerializeNested& m_object; }; @@ -425,6 +447,11 @@ ::zserio::pmr::IReflectablePtr SerializeNested::reflectable(const allocator_type return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::SerializeNested& m_object; }; @@ -604,6 +631,10 @@ void SerializeNested::write(::zserio::BitStreamWriter& out) const out.writeBits(m_optionalValue_.value(), UINT8_C(32)); } } +size_t SerializeNested::bitPosition() const +{ + return m_bitPosition; +} uint8_t SerializeNested::readOffset(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.h index 5c5536b63..d38130d36 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_SERIALIZE_NESTED_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_SERIALIZE_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -100,10 +106,19 @@ class SerializeNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint8_t readOffset(::zserio::BitStreamReader& in); ::zserio::InplaceOptionalHolder readOptionalValue(::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; int8_t m_param_; bool m_isInitialized; uint8_t m_offset_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.cpp index e6bb86f72..af370fdb8 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,22 +21,24 @@ namespace polymorphic_allocator { SerializeObject::SerializeObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_param_(int8_t()), - m_nested_(allocator) + m_areChildrenInitialized(false), + m_param_(int8_t()), + m_nested_(allocator) { } SerializeObject::SerializeObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_param_(readParam(in)), - m_nested_(readNested(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_param_(readParam(in)), + m_nested_(readNested(in, allocator)) { } SerializeObject::SerializeObject(const SerializeObject& other) : - m_param_(other.m_param_), - m_nested_(::zserio::NoInit, other.m_nested_) + m_bitPosition(other.m_bitPosition), + m_param_(other.m_param_), + m_nested_(::zserio::NoInit, other.m_nested_) { if (other.m_areChildrenInitialized) { @@ -65,8 +67,9 @@ SerializeObject& SerializeObject::operator=(const SerializeObject& other) } SerializeObject::SerializeObject(SerializeObject&& other) : - m_param_(::std::move(other.m_param_)), - m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_param_(::std::move(other.m_param_)), + m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)) { if (other.m_areChildrenInitialized) { @@ -80,6 +83,7 @@ SerializeObject::SerializeObject(SerializeObject&& other) : SerializeObject& SerializeObject::operator=(SerializeObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_param_ = ::std::move(other.m_param_); (void)m_nested_.assign(::zserio::NoInit, ::std::move(other.m_nested_)); if (other.m_areChildrenInitialized) @@ -95,9 +99,11 @@ SerializeObject& SerializeObject::operator=(SerializeObject&& other) } SerializeObject::SerializeObject(::zserio::PropagateAllocatorT, - const SerializeObject& other, const allocator_type& allocator) : - m_param_(::zserio::allocatorPropagatingCopy(other.m_param_, allocator)), - m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)) +const SerializeObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_param_(::zserio::allocatorPropagatingCopy(other.m_param_, allocator)), + m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)) { if (other.m_areChildrenInitialized) { @@ -107,6 +113,7 @@ SerializeObject::SerializeObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::pmr::ITypeInfo& SerializeObject::typeInfo() @@ -212,6 +219,11 @@ ::zserio::pmr::IReflectableConstPtr SerializeObject::reflectable(const allocator return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::SerializeObject& m_object; }; @@ -316,6 +328,11 @@ ::zserio::pmr::IReflectablePtr SerializeObject::reflectable(const allocator_type return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::SerializeObject& m_object; }; @@ -437,6 +454,10 @@ void SerializeObject::write(::zserio::BitStreamWriter& out) const } m_nested_.write(out); } +size_t SerializeObject::bitPosition() const +{ + return m_bitPosition; +} int8_t SerializeObject::readParam(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.h index 4ddfac646..1755b4cc6 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/SerializeObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_SERIALIZE_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_SERIALIZE_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -84,11 +90,20 @@ class SerializeObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: int8_t readParam(::zserio::BitStreamReader& in); ::test_object::polymorphic_allocator::SerializeNested readNested(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; int8_t m_param_; ::test_object::polymorphic_allocator::SerializeNested m_nested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.cpp index 88949781b..3e63d1806 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.h index 71310e5cf..2f86ad410 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_BITMASK_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.cpp index 1c9d32784..7102b5129 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -20,21 +20,23 @@ namespace polymorphic_allocator { WalkerChoice::WalkerChoice(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_objectChoice(allocator) + m_isInitialized(false), + m_objectChoice(allocator) { } WalkerChoice::WalkerChoice(::zserio::BitStreamReader& in, uint8_t selector_, const allocator_type& allocator) : - m_selector_(selector_), - m_isInitialized(true), - m_objectChoice(readObject(in, allocator), allocator) + m_bitPosition(in.getBitPosition()), + m_selector_(selector_), + m_isInitialized(true), + m_objectChoice(readObject(in, allocator), allocator) { } WalkerChoice::WalkerChoice(const WalkerChoice& other) : - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { if (other.m_isInitialized) { @@ -62,7 +64,8 @@ WalkerChoice& WalkerChoice::operator=(const WalkerChoice& other) } WalkerChoice::WalkerChoice(WalkerChoice&& other) : - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { if (other.m_isInitialized) { @@ -76,6 +79,7 @@ WalkerChoice::WalkerChoice(WalkerChoice&& other) : WalkerChoice& WalkerChoice::operator=(WalkerChoice&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); if (other.m_isInitialized) { @@ -90,10 +94,12 @@ WalkerChoice& WalkerChoice::operator=(WalkerChoice&& other) } WalkerChoice::WalkerChoice(::zserio::NoInitT, - const WalkerChoice& other) : + const WalkerChoice& other) + : m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { + (void)other; } WalkerChoice& WalkerChoice::assign(::zserio::NoInitT, @@ -102,28 +108,35 @@ WalkerChoice& WalkerChoice::assign(::zserio::NoInitT, m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, other.m_objectChoice); + (void)other; return *this; } WalkerChoice::WalkerChoice(::zserio::NoInitT, - WalkerChoice&& other) : +WalkerChoice&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { + (void)other; } WalkerChoice& WalkerChoice::assign(::zserio::NoInitT, - WalkerChoice&& other) +WalkerChoice&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); + (void)other; return *this; } WalkerChoice::WalkerChoice(::zserio::PropagateAllocatorT, - const WalkerChoice& other, const allocator_type& allocator) : - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) +const WalkerChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { if (other.m_isInitialized) { @@ -133,13 +146,17 @@ WalkerChoice::WalkerChoice(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } WalkerChoice::WalkerChoice(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const WalkerChoice& other, const allocator_type& allocator) : +const WalkerChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& WalkerChoice::typeInfo() @@ -347,6 +364,11 @@ ::zserio::pmr::IReflectableConstPtr WalkerChoice::reflectable(const allocator_ty return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::WalkerChoice& m_object; }; @@ -535,13 +557,17 @@ ::zserio::pmr::IReflectablePtr WalkerChoice::reflectable(const allocator_type& a return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::WalkerChoice& m_object; }; return std::allocate_shared(allocator, *this, allocator); } - void WalkerChoice::initialize( uint8_t selector_) { @@ -813,6 +839,10 @@ void WalkerChoice::write(::zserio::BitStreamWriter& out) const break; } } +size_t WalkerChoice::bitPosition() const +{ + return m_bitPosition; +} ::zserio::pmr::AnyHolder WalkerChoice::readObject(::zserio::BitStreamReader& in, const allocator_type& allocator) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.h index 09346f219..4d280dcaa 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerChoice.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_CHOICE_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_CHOICE_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -103,10 +109,19 @@ class WalkerChoice void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::pmr::AnyHolder readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::pmr::AnyHolder copyObject(const allocator_type& allocator) const; + size_t m_bitPosition = 0; uint8_t m_selector_; bool m_isInitialized; ::zserio::pmr::AnyHolder m_objectChoice; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.cpp index e83e6bb73..881938fea 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,19 +21,23 @@ namespace polymorphic_allocator { WalkerNested::WalkerNested(const allocator_type& allocator) noexcept : - m_text_(allocator) + m_text_(allocator) { } WalkerNested::WalkerNested(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_text_(readText(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_text_(readText(in, allocator)) { } WalkerNested::WalkerNested(::zserio::PropagateAllocatorT, - const WalkerNested& other, const allocator_type& allocator) : - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) +const WalkerNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { + (void)other; } const ::zserio::pmr::ITypeInfo& WalkerNested::typeInfo() @@ -116,6 +120,11 @@ ::zserio::pmr::IReflectableConstPtr WalkerNested::reflectable(const allocator_ty return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::WalkerNested& m_object; }; @@ -201,6 +210,11 @@ ::zserio::pmr::IReflectablePtr WalkerNested::reflectable(const allocator_type& a return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::WalkerNested& m_object; }; @@ -284,6 +298,10 @@ void WalkerNested::write(::zserio::BitStreamWriter& out) const { out.writeString(m_text_); } +size_t WalkerNested::bitPosition() const +{ + return m_bitPosition; +} ::zserio::pmr::string WalkerNested::readText(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.h index 24cdb5579..834872b3e 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_NESTED_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -76,10 +82,19 @@ class WalkerNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::pmr::string readText(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; ::zserio::pmr::string m_text_; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.cpp index bfdfe09a1..908698980 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -21,37 +21,39 @@ namespace polymorphic_allocator { WalkerObject::WalkerObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_identifier_(uint32_t()), - m_nested_(::zserio::NullOpt), - m_text_(allocator), - m_unionArray_(allocator), - m_optionalUnionArray_(::zserio::NullOpt), - m_choiceSelector_(uint8_t()), - m_choiceField_(allocator) + m_areChildrenInitialized(false), + m_identifier_(uint32_t()), + m_nested_(::zserio::NullOpt), + m_text_(allocator), + m_unionArray_(allocator), + m_optionalUnionArray_(::zserio::NullOpt), + m_choiceSelector_(uint8_t()), + m_choiceField_(allocator) { } WalkerObject::WalkerObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_identifier_(readIdentifier(in)), - m_nested_(readNested(in, allocator)), - m_text_(readText(in, allocator)), - m_unionArray_(readUnionArray(in, allocator)), - m_optionalUnionArray_(readOptionalUnionArray(in, allocator)), - m_choiceSelector_(readChoiceSelector(in)), - m_choiceField_(readChoiceField(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_identifier_(readIdentifier(in)), + m_nested_(readNested(in, allocator)), + m_text_(readText(in, allocator)), + m_unionArray_(readUnionArray(in, allocator)), + m_optionalUnionArray_(readOptionalUnionArray(in, allocator)), + m_choiceSelector_(readChoiceSelector(in)), + m_choiceField_(readChoiceField(in, allocator)) { } WalkerObject::WalkerObject(const WalkerObject& other) : - m_identifier_(other.m_identifier_), - m_nested_(other.m_nested_), - m_text_(other.m_text_), - m_unionArray_(other.m_unionArray_), - m_optionalUnionArray_(other.m_optionalUnionArray_), - m_choiceSelector_(other.m_choiceSelector_), - m_choiceField_(::zserio::NoInit, other.m_choiceField_) + m_bitPosition(other.m_bitPosition), + m_identifier_(other.m_identifier_), + m_nested_(other.m_nested_), + m_text_(other.m_text_), + m_unionArray_(other.m_unionArray_), + m_optionalUnionArray_(other.m_optionalUnionArray_), + m_choiceSelector_(other.m_choiceSelector_), + m_choiceField_(::zserio::NoInit, other.m_choiceField_) { if (other.m_areChildrenInitialized) { @@ -85,13 +87,14 @@ WalkerObject& WalkerObject::operator=(const WalkerObject& other) } WalkerObject::WalkerObject(WalkerObject&& other) : - m_identifier_(::std::move(other.m_identifier_)), - m_nested_(::std::move(other.m_nested_)), - m_text_(::std::move(other.m_text_)), - m_unionArray_(::std::move(other.m_unionArray_)), - m_optionalUnionArray_(::std::move(other.m_optionalUnionArray_)), - m_choiceSelector_(::std::move(other.m_choiceSelector_)), - m_choiceField_(::zserio::NoInit, ::std::move(other.m_choiceField_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_identifier_(::std::move(other.m_identifier_)), + m_nested_(::std::move(other.m_nested_)), + m_text_(::std::move(other.m_text_)), + m_unionArray_(::std::move(other.m_unionArray_)), + m_optionalUnionArray_(::std::move(other.m_optionalUnionArray_)), + m_choiceSelector_(::std::move(other.m_choiceSelector_)), + m_choiceField_(::zserio::NoInit, ::std::move(other.m_choiceField_)) { if (other.m_areChildrenInitialized) { @@ -105,6 +108,7 @@ WalkerObject::WalkerObject(WalkerObject&& other) : WalkerObject& WalkerObject::operator=(WalkerObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_identifier_ = ::std::move(other.m_identifier_); m_nested_ = ::std::move(other.m_nested_); m_text_ = ::std::move(other.m_text_); @@ -125,14 +129,16 @@ WalkerObject& WalkerObject::operator=(WalkerObject&& other) } WalkerObject::WalkerObject(::zserio::PropagateAllocatorT, - const WalkerObject& other, const allocator_type& allocator) : - m_identifier_(::zserio::allocatorPropagatingCopy(other.m_identifier_, allocator)), - m_nested_(::zserio::allocatorPropagatingCopy(other.m_nested_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_unionArray_(::zserio::allocatorPropagatingCopy(other.m_unionArray_, allocator)), - m_optionalUnionArray_(::zserio::allocatorPropagatingCopy(other.m_optionalUnionArray_, allocator)), - m_choiceSelector_(::zserio::allocatorPropagatingCopy(other.m_choiceSelector_, allocator)), - m_choiceField_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_choiceField_, allocator)) +const WalkerObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_identifier_(::zserio::allocatorPropagatingCopy(other.m_identifier_, allocator)), + m_nested_(::zserio::allocatorPropagatingCopy(other.m_nested_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_unionArray_(::zserio::allocatorPropagatingCopy(other.m_unionArray_, allocator)), + m_optionalUnionArray_(::zserio::allocatorPropagatingCopy(other.m_optionalUnionArray_, allocator)), + m_choiceSelector_(::zserio::allocatorPropagatingCopy(other.m_choiceSelector_, allocator)), + m_choiceField_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_choiceField_, allocator)) { if (other.m_areChildrenInitialized) { @@ -142,6 +148,7 @@ WalkerObject::WalkerObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::pmr::ITypeInfo& WalkerObject::typeInfo() @@ -357,6 +364,11 @@ ::zserio::pmr::IReflectableConstPtr WalkerObject::reflectable(const allocator_ty return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::WalkerObject& m_object; }; @@ -583,6 +595,11 @@ ::zserio::pmr::IReflectablePtr WalkerObject::reflectable(const allocator_type& a return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::WalkerObject& m_object; }; @@ -944,6 +961,10 @@ void WalkerObject::write(::zserio::BitStreamWriter& out) const } m_choiceField_.write(out); } +size_t WalkerObject::bitPosition() const +{ + return m_bitPosition; +} void WalkerObject::ZserioElementFactory_unionArray::create(WalkerObject&, ::zserio::pmr::vector<::test_object::polymorphic_allocator::WalkerUnion>& array, diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.h index 7b3b3cea1..ab1088cf2 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_OBJECT_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -134,6 +140,14 @@ class WalkerObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioElementFactory_unionArray { @@ -171,6 +185,7 @@ class WalkerObject ::test_object::polymorphic_allocator::WalkerChoice readChoiceField(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; uint32_t m_identifier_; ::zserio::InplaceOptionalHolder<::test_object::polymorphic_allocator::WalkerNested> m_nested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.cpp b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.cpp index 4ba157553..446ef3bdc 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #include @@ -20,14 +20,15 @@ namespace polymorphic_allocator { WalkerUnion::WalkerUnion(const allocator_type& allocator) noexcept : - m_choiceTag(UNDEFINED_CHOICE), - m_objectChoice(allocator) + m_choiceTag(UNDEFINED_CHOICE), + m_objectChoice(allocator) { } WalkerUnion::WalkerUnion(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_choiceTag(readChoiceTag(in)), - m_objectChoice(readObject(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_choiceTag(readChoiceTag(in)), + m_objectChoice(readObject(in, allocator)) { } @@ -173,6 +174,11 @@ ::zserio::pmr::IReflectableConstPtr WalkerUnion::reflectable(const allocator_typ return ::zserio::pmr::AnyHolder(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::polymorphic_allocator::WalkerUnion& m_object; }; @@ -309,6 +315,11 @@ ::zserio::pmr::IReflectablePtr WalkerUnion::reflectable(const allocator_type& al return ::zserio::pmr::AnyHolder(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::polymorphic_allocator::WalkerUnion& m_object; }; @@ -550,6 +561,10 @@ void WalkerUnion::write(::zserio::BitStreamWriter& out) const throw ::zserio::CppRuntimeException("No match in union WalkerUnion!"); } } +size_t WalkerUnion::bitPosition() const +{ + return m_bitPosition; +} void WalkerUnion::ZserioElementFactory_nestedArray::create(WalkerUnion&, ::zserio::pmr::vector<::test_object::polymorphic_allocator::WalkerNested>& array, diff --git a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.h b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.h index 9fefeee35..7f63eb1a0 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.h +++ b/compiler/extensions/cpp/runtime/test/test_object/polymorphic_allocator/WalkerUnion.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, polymorphicAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, polymorphicAllocator. */ #ifndef TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_UNION_H #define TEST_OBJECT_POLYMORPHIC_ALLOCATOR_WALKER_UNION_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -91,6 +97,14 @@ class WalkerUnion void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioElementFactory_nestedArray { @@ -107,7 +121,7 @@ class WalkerUnion ChoiceTag readChoiceTag(::zserio::BitStreamReader& in); ::zserio::pmr::AnyHolder readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::pmr::AnyHolder copyObject(const allocator_type& allocator) const; - + size_t m_bitPosition = 0; ChoiceTag m_choiceTag; ::zserio::pmr::AnyHolder m_objectChoice; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.cpp index 7780bbcaa..2fe80fcbf 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.h index ac6cb4196..d361f1db5 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_ARRAY_BITMASK_H #define TEST_OBJECT_STD_ALLOCATOR_ARRAY_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.cpp index 46192cd59..e58e4da3b 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.h index ee2b9bfc4..35f84d65c 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_ARRAY_ENUM_H #define TEST_OBJECT_STD_ALLOCATOR_ARRAY_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.cpp index 5f699d63c..e4f3b4c83 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,28 +21,30 @@ namespace std_allocator { ArrayHolder::ArrayHolder(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_enumArray_(allocator), - m_bitmaskArray_(allocator), - m_packedArray_(allocator), - m_packedParamArray_(allocator) + m_areChildrenInitialized(false), + m_enumArray_(allocator), + m_bitmaskArray_(allocator), + m_packedArray_(allocator), + m_packedParamArray_(allocator) { } ArrayHolder::ArrayHolder(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_enumArray_(readEnumArray(in, allocator)), - m_bitmaskArray_(readBitmaskArray(in, allocator)), - m_packedArray_(readPackedArray(in, allocator)), - m_packedParamArray_(readPackedParamArray(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_enumArray_(readEnumArray(in, allocator)), + m_bitmaskArray_(readBitmaskArray(in, allocator)), + m_packedArray_(readPackedArray(in, allocator)), + m_packedParamArray_(readPackedParamArray(in, allocator)) { } ArrayHolder::ArrayHolder(const ArrayHolder& other) : - m_enumArray_(other.m_enumArray_), - m_bitmaskArray_(other.m_bitmaskArray_), - m_packedArray_(other.m_packedArray_), - m_packedParamArray_(::zserio::NoInit, other.m_packedParamArray_) + m_bitPosition(other.m_bitPosition), + m_enumArray_(other.m_enumArray_), + m_bitmaskArray_(other.m_bitmaskArray_), + m_packedArray_(other.m_packedArray_), + m_packedParamArray_(::zserio::NoInit, other.m_packedParamArray_) { if (other.m_areChildrenInitialized) { @@ -73,10 +75,11 @@ ArrayHolder& ArrayHolder::operator=(const ArrayHolder& other) } ArrayHolder::ArrayHolder(ArrayHolder&& other) : - m_enumArray_(::std::move(other.m_enumArray_)), - m_bitmaskArray_(::std::move(other.m_bitmaskArray_)), - m_packedArray_(::std::move(other.m_packedArray_)), - m_packedParamArray_(::zserio::NoInit, ::std::move(other.m_packedParamArray_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_enumArray_(::std::move(other.m_enumArray_)), + m_bitmaskArray_(::std::move(other.m_bitmaskArray_)), + m_packedArray_(::std::move(other.m_packedArray_)), + m_packedParamArray_(::zserio::NoInit, ::std::move(other.m_packedParamArray_)) { if (other.m_areChildrenInitialized) { @@ -90,6 +93,7 @@ ArrayHolder::ArrayHolder(ArrayHolder&& other) : ArrayHolder& ArrayHolder::operator=(ArrayHolder&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_enumArray_ = ::std::move(other.m_enumArray_); m_bitmaskArray_ = ::std::move(other.m_bitmaskArray_); m_packedArray_ = ::std::move(other.m_packedArray_); @@ -107,11 +111,13 @@ ArrayHolder& ArrayHolder::operator=(ArrayHolder&& other) } ArrayHolder::ArrayHolder(::zserio::PropagateAllocatorT, - const ArrayHolder& other, const allocator_type& allocator) : - m_enumArray_(::zserio::allocatorPropagatingCopy(other.m_enumArray_, allocator)), - m_bitmaskArray_(::zserio::allocatorPropagatingCopy(other.m_bitmaskArray_, allocator)), - m_packedArray_(::zserio::allocatorPropagatingCopy(other.m_packedArray_, allocator)), - m_packedParamArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_packedParamArray_, allocator)) +const ArrayHolder& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_enumArray_(::zserio::allocatorPropagatingCopy(other.m_enumArray_, allocator)), + m_bitmaskArray_(::zserio::allocatorPropagatingCopy(other.m_bitmaskArray_, allocator)), + m_packedArray_(::zserio::allocatorPropagatingCopy(other.m_packedArray_, allocator)), + m_packedParamArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_packedParamArray_, allocator)) { if (other.m_areChildrenInitialized) { @@ -121,6 +127,7 @@ ArrayHolder::ArrayHolder(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::ITypeInfo& ArrayHolder::typeInfo() @@ -266,6 +273,11 @@ ::zserio::IReflectableConstPtr ArrayHolder::reflectable(const allocator_type& al return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ArrayHolder& m_object; }; @@ -406,6 +418,11 @@ ::zserio::IReflectablePtr ArrayHolder::reflectable(const allocator_type& allocat return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ArrayHolder& m_object; }; @@ -598,6 +615,10 @@ void ArrayHolder::write(::zserio::BitStreamWriter& out) const m_packedArray_.writePacked(*this, out); m_packedParamArray_.writePacked(*this, out); } +size_t ArrayHolder::bitPosition() const +{ + return m_bitPosition; +} void ArrayHolder::ZserioElementFactory_packedArray::create(ArrayHolder&, ::zserio::vector<::test_object::std_allocator::ArrayObject>& array, diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.h index 9bf4208ac..ee1449dd2 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayHolder.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_ARRAY_HOLDER_H #define TEST_OBJECT_STD_ALLOCATOR_ARRAY_HOLDER_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -108,6 +114,14 @@ class ArrayHolder void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioElementFactory_packedArray { @@ -162,6 +176,7 @@ class ArrayHolder ZserioArrayType_packedParamArray readPackedParamArray(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; ZserioArrayType_enumArray m_enumArray_; ZserioArrayType_bitmaskArray m_bitmaskArray_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.cpp index 0fa58d767..7c5969d6c 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,24 +21,29 @@ namespace std_allocator { ArrayObject::ArrayObject(const allocator_type&) noexcept : - m_value_(uint32_t()) + m_value_(uint32_t()) { } ArrayObject::ArrayObject(::zserio::BitStreamReader& in, const allocator_type&) : - m_value_(readValue(in)) + m_bitPosition(in.getBitPosition()), + m_value_(readValue(in)) { } ArrayObject::ArrayObject(ArrayObject::ZserioPackingContext& context, ::zserio::BitStreamReader& in, const allocator_type&) : - m_value_(readValue(context, in)) + m_bitPosition(in.getBitPosition()), + m_value_(readValue(context, in)) { } ArrayObject::ArrayObject(::zserio::PropagateAllocatorT, - const ArrayObject& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +const ArrayObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& ArrayObject::typeInfo() @@ -121,6 +126,11 @@ ::zserio::IReflectableConstPtr ArrayObject::reflectable(const allocator_type& al return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ArrayObject& m_object; }; @@ -206,6 +216,11 @@ ::zserio::IReflectablePtr ArrayObject::reflectable(const allocator_type& allocat return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ArrayObject& m_object; }; @@ -307,6 +322,10 @@ void ArrayObject::write(ArrayObject::ZserioPackingContext& context, ::zserio::Bi { context.getValue().write<::zserio::BitFieldArrayTraits>(out, m_value_); } +size_t ArrayObject::bitPosition() const +{ + return m_bitPosition; +} uint32_t ArrayObject::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.h index 19b074894..f61945258 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_ARRAY_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_ARRAY_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -92,11 +98,20 @@ class ArrayObject void write(::zserio::BitStreamWriter& out) const; void write(ZserioPackingContext& context, ::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); uint32_t readValue(ZserioPackingContext& context, ::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; uint32_t m_value_; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.cpp index 40914e50d..0d7ca223b 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -23,29 +23,32 @@ namespace std_allocator { ArrayParamObject::ArrayParamObject(const allocator_type&) noexcept : - m_isInitialized(false), - m_value_(uint32_t()) + m_isInitialized(false), + m_value_(uint32_t()) { } ArrayParamObject::ArrayParamObject(::zserio::BitStreamReader& in, ::test_object::std_allocator::ArrayObject& param_, const allocator_type&) : - m_param_(¶m_), - m_isInitialized(true), - m_value_(readValue(in)) + m_bitPosition(in.getBitPosition()), + m_param_(¶m_), + m_isInitialized(true), + m_value_(readValue(in)) { } ArrayParamObject::ArrayParamObject(ArrayParamObject::ZserioPackingContext& context, ::zserio::BitStreamReader& in, ::test_object::std_allocator::ArrayObject& param_, const allocator_type&) : - m_param_(¶m_), - m_isInitialized(true), - m_value_(readValue(context, in)) + m_bitPosition(in.getBitPosition()), + m_param_(¶m_), + m_isInitialized(true), + m_value_(readValue(context, in)) { } ArrayParamObject::ArrayParamObject(const ArrayParamObject& other) : - m_value_(other.m_value_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_) { if (other.m_isInitialized) { @@ -73,7 +76,8 @@ ArrayParamObject& ArrayParamObject::operator=(const ArrayParamObject& other) } ArrayParamObject::ArrayParamObject(ArrayParamObject&& other) : - m_value_(::std::move(other.m_value_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)) { if (other.m_isInitialized) { @@ -87,6 +91,7 @@ ArrayParamObject::ArrayParamObject(ArrayParamObject&& other) : ArrayParamObject& ArrayParamObject::operator=(ArrayParamObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); if (other.m_isInitialized) { @@ -101,10 +106,12 @@ ArrayParamObject& ArrayParamObject::operator=(ArrayParamObject&& other) } ArrayParamObject::ArrayParamObject(::zserio::NoInitT, - const ArrayParamObject& other) : + const ArrayParamObject& other) + : m_isInitialized(false), - m_value_(other.m_value_) + m_value_(other.m_value_) { + (void)other; } ArrayParamObject& ArrayParamObject::assign(::zserio::NoInitT, @@ -113,28 +120,35 @@ ArrayParamObject& ArrayParamObject::assign(::zserio::NoInitT, m_isInitialized = false; m_value_ = other.m_value_; + (void)other; return *this; } ArrayParamObject::ArrayParamObject(::zserio::NoInitT, - ArrayParamObject&& other) : +ArrayParamObject&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_value_(::std::move(other.m_value_)) + m_value_(::std::move(other.m_value_)) { + (void)other; } ArrayParamObject& ArrayParamObject::assign(::zserio::NoInitT, - ArrayParamObject&& other) +ArrayParamObject&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_value_ = ::std::move(other.m_value_); + (void)other; return *this; } ArrayParamObject::ArrayParamObject(::zserio::PropagateAllocatorT, - const ArrayParamObject& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +const ArrayParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { if (other.m_isInitialized) { @@ -144,13 +158,17 @@ ArrayParamObject::ArrayParamObject(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } ArrayParamObject::ArrayParamObject(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const ArrayParamObject& other, const allocator_type& allocator) : +const ArrayParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& ArrayParamObject::typeInfo() @@ -247,6 +265,11 @@ ::zserio::IReflectableConstPtr ArrayParamObject::reflectable(const allocator_typ return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ArrayParamObject& m_object; }; @@ -364,6 +387,11 @@ ::zserio::IReflectablePtr ArrayParamObject::reflectable(const allocator_type& al return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ArrayParamObject& m_object; }; @@ -518,6 +546,10 @@ void ArrayParamObject::write(ArrayParamObject::ZserioPackingContext& context, :: } context.getValue().write<::zserio::StdIntArrayTraits>(out, m_value_); } +size_t ArrayParamObject::bitPosition() const +{ + return m_bitPosition; +} uint32_t ArrayParamObject::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.h index 76c16cfdc..0633ebad6 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ArrayParamObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_ARRAY_PARAM_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_ARRAY_PARAM_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -114,11 +120,20 @@ class ArrayParamObject void write(::zserio::BitStreamWriter& out) const; void write(ZserioPackingContext& context, ::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); uint32_t readValue(ZserioPackingContext& context, ::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; ::test_object::std_allocator::ArrayObject* m_param_; bool m_isInitialized; uint32_t m_value_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.cpp new file mode 100644 index 000000000..27be4a4b7 --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.cpp @@ -0,0 +1,384 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace test_object +{ +namespace std_allocator +{ + +BitPositionObject::BitPositionObject(const allocator_type& allocator) noexcept : + m_pad_(uint8_t()), + m_sub_(allocator) +{ +} + +BitPositionObject::BitPositionObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : + m_bitPosition(in.getBitPosition()), + m_pad_(readPad(in)), + m_sub_(readSub(in, allocator)) +{ +} + +BitPositionObject::BitPositionObject(::zserio::PropagateAllocatorT, +const BitPositionObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_pad_(::zserio::allocatorPropagatingCopy(other.m_pad_, allocator)), + m_sub_(::zserio::allocatorPropagatingCopy(other.m_sub_, allocator)) +{ + (void)other; +} + +const ::zserio::ITypeInfo& BitPositionObject::typeInfo() +{ + static const ::zserio::StringView templateName; + static const ::zserio::Span<::zserio::BasicTemplateArgumentInfo> templateArguments; + + static const ::std::array<::zserio::BasicFieldInfo, 2> fields = { + ::zserio::BasicFieldInfo{ + ::zserio::makeStringView("pad"), // schemaName + ::zserio::BuiltinTypeInfo::getFixedUnsignedBitField(UINT8_C(3)), // typeInfo + {}, // typeArguments + false, // isExtended + {}, // alignment + {}, // offset + {}, // initializer + false, // isOptional + {}, // optionalClause + {}, // constraint + false, // isArray + {}, // arrayLength + false, // isPacked + false // isImplicit + }, + ::zserio::BasicFieldInfo{ + ::zserio::makeStringView("sub"), // schemaName + ::test_object::std_allocator::BitPositionSubObject::typeInfo(), // typeInfo + {}, // typeArguments + false, // isExtended + {}, // alignment + {}, // offset + {}, // initializer + false, // isOptional + {}, // optionalClause + {}, // constraint + false, // isArray + {}, // arrayLength + false, // isPacked + false // isImplicit + } + }; + + static const ::zserio::Span<::zserio::BasicParameterInfo> parameters; + + static const ::zserio::Span<::zserio::BasicFunctionInfo> functions; + + static const ::zserio::StructTypeInfo typeInfo = { + ::zserio::makeStringView("test_object.std_allocator.BitPositionObject"), + [](const allocator_type& allocator) -> ::zserio::IReflectablePtr + { + return std::allocate_shared<::zserio::ReflectableOwner>(allocator, allocator); + }, + templateName, templateArguments, + fields, parameters, functions + }; + + return typeInfo; +} + +::zserio::IReflectableConstPtr BitPositionObject::reflectable(const allocator_type& allocator) const +{ + class Reflectable : public ::zserio::ReflectableConstAllocatorHolderBase + { + public: + using ::zserio::ReflectableConstAllocatorHolderBase::getField; + using ::zserio::ReflectableConstAllocatorHolderBase::getParameter; + using ::zserio::ReflectableConstAllocatorHolderBase::callFunction; + using ::zserio::ReflectableConstAllocatorHolderBase::getAnyValue; + + explicit Reflectable(const ::test_object::std_allocator::BitPositionObject& object, const allocator_type& alloc) : + ::zserio::ReflectableConstAllocatorHolderBase(::test_object::std_allocator::BitPositionObject::typeInfo(), alloc), + m_object(object) + {} + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("pad")) + { + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::AnyHolder<> getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + const ::test_object::std_allocator::BitPositionObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +::zserio::IReflectablePtr BitPositionObject::reflectable(const allocator_type& allocator) +{ + class Reflectable : public ::zserio::ReflectableAllocatorHolderBase + { + public: + explicit Reflectable(::test_object::std_allocator::BitPositionObject& object, const allocator_type& alloc) : + ::zserio::ReflectableAllocatorHolderBase(::test_object::std_allocator::BitPositionObject::typeInfo(), alloc), + m_object(object) + {} + + void initializeChildren() override + { + } + + size_t initializeOffsets(size_t bitPosition) override + { + return m_object.initializeOffsets(bitPosition); + } + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("pad")) + { + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::IReflectablePtr getField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("pad")) + { + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + void setField(::zserio::StringView name, + const ::zserio::AnyHolder& value) override + { + if (name == ::zserio::makeStringView("pad")) + { + m_object.setPad(value.get()); + return; + } + if (name == ::zserio::makeStringView("sub")) + { + m_object.setSub(value.get<::test_object::std_allocator::BitPositionSubObject>()); + return; + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::IReflectablePtr createField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("pad")) + { + m_object.setPad(uint8_t()); + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getPad(), UINT8_C(3), get_allocator()); + } + if (name == ::zserio::makeStringView("sub")) + { + m_object.setSub(::test_object::std_allocator::BitPositionSubObject(get_allocator())); + return m_object.getSub().reflectable(get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionObject'!"; + } + + ::zserio::AnyHolder<> getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); + } + + ::zserio::AnyHolder<> getAnyValue(const allocator_type& alloc) override + { + return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + ::test_object::std_allocator::BitPositionObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +uint8_t BitPositionObject::getPad() const +{ + return m_pad_; +} + +void BitPositionObject::setPad(uint8_t pad_) +{ + m_pad_ = pad_; +} + +::test_object::std_allocator::BitPositionSubObject& BitPositionObject::getSub() +{ + return m_sub_; +} + +const ::test_object::std_allocator::BitPositionSubObject& BitPositionObject::getSub() const +{ + return m_sub_; +} + +void BitPositionObject::setSub(const ::test_object::std_allocator::BitPositionSubObject& sub_) +{ + m_sub_ = sub_; +} + +void BitPositionObject::setSub(::test_object::std_allocator::BitPositionSubObject&& sub_) +{ + m_sub_ = ::std::move(sub_); +} + +size_t BitPositionObject::bitSizeOf(size_t bitPosition) const +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(3); + endBitPosition += m_sub_.bitSizeOf(endBitPosition); + + return endBitPosition - bitPosition; +} + +size_t BitPositionObject::initializeOffsets(size_t bitPosition) +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(3); + endBitPosition = m_sub_.initializeOffsets(endBitPosition); + + return endBitPosition; +} + +bool BitPositionObject::operator==(const BitPositionObject& other) const +{ + if (this != &other) + { + return + (m_pad_ == other.m_pad_) && + (m_sub_ == other.m_sub_); + } + + return true; +} + +bool BitPositionObject::operator<(const BitPositionObject& other) const +{ + if (m_pad_ < other.m_pad_) + { + return true; + } + if (other.m_pad_ < m_pad_) + { + return false; + } + + if (m_sub_ < other.m_sub_) + { + return true; + } + if (other.m_sub_ < m_sub_) + { + return false; + } + + return false; +} + +uint32_t BitPositionObject::hashCode() const +{ + uint32_t result = ::zserio::HASH_SEED; + + result = ::zserio::calcHashCode(result, m_pad_); + result = ::zserio::calcHashCode(result, m_sub_); + + return result; +} + +void BitPositionObject::write(::zserio::BitStreamWriter& out) const +{ + out.writeBits(m_pad_, UINT8_C(3)); + m_sub_.write(out); +} +size_t BitPositionObject::bitPosition() const +{ + return m_bitPosition; +} + +uint8_t BitPositionObject::readPad(::zserio::BitStreamReader& in) +{ + return static_cast(in.readBits(UINT8_C(3))); +} + +::test_object::std_allocator::BitPositionSubObject BitPositionObject::readSub(::zserio::BitStreamReader& in, + const allocator_type& allocator) +{ + return ::test_object::std_allocator::BitPositionSubObject(in, allocator); +} + + +} // namespace std_allocator +} // namespace test_object diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.h new file mode 100644 index 000000000..d0a3c2aa3 --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionObject.h @@ -0,0 +1,112 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. + */ + +#ifndef TEST_OBJECT_STD_ALLOCATOR_BIT_POSITION_OBJECT_H +#define TEST_OBJECT_STD_ALLOCATOR_BIT_POSITION_OBJECT_H + +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace test_object +{ +namespace std_allocator +{ + +class BitPositionObject +{ +public: + using allocator_type = ::std::allocator; + + BitPositionObject() noexcept : + BitPositionObject(allocator_type()) + {} + + explicit BitPositionObject(const allocator_type& allocator) noexcept; + + template + BitPositionObject( + uint8_t pad_, + ZSERIO_T_sub&& sub_, + const allocator_type& allocator = allocator_type()) : + BitPositionObject(allocator) + { + m_pad_ = pad_; + m_sub_ = ::std::forward(sub_); + } + + explicit BitPositionObject(::zserio::BitStreamReader& in, const allocator_type& allocator = allocator_type()); + + ~BitPositionObject() = default; + + BitPositionObject(const BitPositionObject&) = default; + BitPositionObject& operator=(const BitPositionObject&) = default; + + BitPositionObject(BitPositionObject&&) = default; + BitPositionObject& operator=(BitPositionObject&&) = default; + + BitPositionObject(::zserio::PropagateAllocatorT, + const BitPositionObject& other, const allocator_type& allocator); + + static const ::zserio::ITypeInfo& typeInfo(); + ::zserio::IReflectableConstPtr reflectable(const allocator_type& allocator = allocator_type()) const; + ::zserio::IReflectablePtr reflectable(const allocator_type& allocator = allocator_type()); + + uint8_t getPad() const; + void setPad(uint8_t pad_); + + const ::test_object::std_allocator::BitPositionSubObject& getSub() const; + ::test_object::std_allocator::BitPositionSubObject& getSub(); + void setSub(const ::test_object::std_allocator::BitPositionSubObject& sub_); + void setSub(::test_object::std_allocator::BitPositionSubObject&& sub_); + + size_t bitSizeOf(size_t bitPosition = 0) const; + + size_t initializeOffsets(size_t bitPosition = 0); + + bool operator==(const BitPositionObject& other) const; + + bool operator<(const BitPositionObject& other) const; + + uint32_t hashCode() const; + + void write(::zserio::BitStreamWriter& out) const; + + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + +private: + uint8_t readPad(::zserio::BitStreamReader& in); + ::test_object::std_allocator::BitPositionSubObject readSub(::zserio::BitStreamReader& in, + const allocator_type& allocator); + + size_t m_bitPosition = 0; + uint8_t m_pad_; + ::test_object::std_allocator::BitPositionSubObject m_sub_; +}; + +} // namespace std_allocator +} // namespace test_object + +#endif // TEST_OBJECT_STD_ALLOCATOR_BIT_POSITION_OBJECT_H diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.cpp new file mode 100644 index 000000000..2ba76f464 --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.cpp @@ -0,0 +1,303 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace test_object +{ +namespace std_allocator +{ + +BitPositionSubObject::BitPositionSubObject(const allocator_type&) noexcept : + m_value_(uint8_t()) +{ +} + +BitPositionSubObject::BitPositionSubObject(::zserio::BitStreamReader& in, const allocator_type&) : + m_bitPosition(in.getBitPosition()), + m_value_(readValue(in)) +{ +} + +BitPositionSubObject::BitPositionSubObject(::zserio::PropagateAllocatorT, +const BitPositionSubObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +{ + (void)other; +} + +const ::zserio::ITypeInfo& BitPositionSubObject::typeInfo() +{ + static const ::zserio::StringView templateName; + static const ::zserio::Span<::zserio::BasicTemplateArgumentInfo> templateArguments; + + static const ::std::array<::zserio::BasicFieldInfo, 1> fields = { + ::zserio::BasicFieldInfo{ + ::zserio::makeStringView("value"), // schemaName + ::zserio::BuiltinTypeInfo::getFixedUnsignedBitField(UINT8_C(7)), // typeInfo + {}, // typeArguments + false, // isExtended + {}, // alignment + {}, // offset + {}, // initializer + false, // isOptional + {}, // optionalClause + {}, // constraint + false, // isArray + {}, // arrayLength + false, // isPacked + false // isImplicit + } + }; + + static const ::zserio::Span<::zserio::BasicParameterInfo> parameters; + + static const ::zserio::Span<::zserio::BasicFunctionInfo> functions; + + static const ::zserio::StructTypeInfo typeInfo = { + ::zserio::makeStringView("test_object.std_allocator.BitPositionSubObject"), + [](const allocator_type& allocator) -> ::zserio::IReflectablePtr + { + return std::allocate_shared<::zserio::ReflectableOwner>(allocator, allocator); + }, + templateName, templateArguments, + fields, parameters, functions + }; + + return typeInfo; +} + +::zserio::IReflectableConstPtr BitPositionSubObject::reflectable(const allocator_type& allocator) const +{ + class Reflectable : public ::zserio::ReflectableConstAllocatorHolderBase + { + public: + using ::zserio::ReflectableConstAllocatorHolderBase::getField; + using ::zserio::ReflectableConstAllocatorHolderBase::getParameter; + using ::zserio::ReflectableConstAllocatorHolderBase::callFunction; + using ::zserio::ReflectableConstAllocatorHolderBase::getAnyValue; + + explicit Reflectable(const ::test_object::std_allocator::BitPositionSubObject& object, const allocator_type& alloc) : + ::zserio::ReflectableConstAllocatorHolderBase(::test_object::std_allocator::BitPositionSubObject::typeInfo(), alloc), + m_object(object) + {} + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("value")) + { + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::AnyHolder<> getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + const ::test_object::std_allocator::BitPositionSubObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +::zserio::IReflectablePtr BitPositionSubObject::reflectable(const allocator_type& allocator) +{ + class Reflectable : public ::zserio::ReflectableAllocatorHolderBase + { + public: + explicit Reflectable(::test_object::std_allocator::BitPositionSubObject& object, const allocator_type& alloc) : + ::zserio::ReflectableAllocatorHolderBase(::test_object::std_allocator::BitPositionSubObject::typeInfo(), alloc), + m_object(object) + {} + + void initializeChildren() override + { + } + + size_t initializeOffsets(size_t bitPosition) override + { + return m_object.initializeOffsets(bitPosition); + } + + size_t bitSizeOf(size_t bitPosition) const override + { + return m_object.bitSizeOf(bitPosition); + } + + void write(::zserio::BitStreamWriter& writer) const override + { + m_object.write(writer); + } + + ::zserio::IReflectableConstPtr getField(::zserio::StringView name) const override + { + if (name == ::zserio::makeStringView("value")) + { + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::IReflectablePtr getField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("value")) + { + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + void setField(::zserio::StringView name, + const ::zserio::AnyHolder& value) override + { + if (name == ::zserio::makeStringView("value")) + { + m_object.setValue(value.get()); + return; + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::IReflectablePtr createField(::zserio::StringView name) override + { + if (name == ::zserio::makeStringView("value")) + { + m_object.setValue(uint8_t()); + return ::zserio::ReflectableFactory::getFixedUnsignedBitField(m_object.getValue(), UINT8_C(7), get_allocator()); + } + throw ::zserio::CppRuntimeException("Field '") << name << "' doesn't exist in 'BitPositionSubObject'!"; + } + + ::zserio::AnyHolder<> getAnyValue(const allocator_type& alloc) const override + { + return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); + } + + ::zserio::AnyHolder<> getAnyValue(const allocator_type& alloc) override + { + return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); + } + + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + + private: + ::test_object::std_allocator::BitPositionSubObject& m_object; + }; + + return std::allocate_shared(allocator, *this, allocator); +} + +uint8_t BitPositionSubObject::getValue() const +{ + return m_value_; +} + +void BitPositionSubObject::setValue(uint8_t value_) +{ + m_value_ = value_; +} + +size_t BitPositionSubObject::bitSizeOf(size_t bitPosition) const +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(7); + + return endBitPosition - bitPosition; +} + +size_t BitPositionSubObject::initializeOffsets(size_t bitPosition) +{ + size_t endBitPosition = bitPosition; + + endBitPosition += UINT8_C(7); + + return endBitPosition; +} + +bool BitPositionSubObject::operator==(const BitPositionSubObject& other) const +{ + if (this != &other) + { + return + (m_value_ == other.m_value_); + } + + return true; +} + +bool BitPositionSubObject::operator<(const BitPositionSubObject& other) const +{ + if (m_value_ < other.m_value_) + { + return true; + } + if (other.m_value_ < m_value_) + { + return false; + } + + return false; +} + +uint32_t BitPositionSubObject::hashCode() const +{ + uint32_t result = ::zserio::HASH_SEED; + + result = ::zserio::calcHashCode(result, m_value_); + + return result; +} + +void BitPositionSubObject::write(::zserio::BitStreamWriter& out) const +{ + out.writeBits(m_value_, UINT8_C(7)); +} +size_t BitPositionSubObject::bitPosition() const +{ + return m_bitPosition; +} + +uint8_t BitPositionSubObject::readValue(::zserio::BitStreamReader& in) +{ + return static_cast(in.readBits(UINT8_C(7))); +} + + +} // namespace std_allocator +} // namespace test_object diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.h new file mode 100644 index 000000000..27a5b3a4a --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/BitPositionSubObject.h @@ -0,0 +1,99 @@ +/** + * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. + */ + +#ifndef TEST_OBJECT_STD_ALLOCATOR_BIT_POSITION_SUB_OBJECT_H +#define TEST_OBJECT_STD_ALLOCATOR_BIT_POSITION_SUB_OBJECT_H + +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace test_object +{ +namespace std_allocator +{ + +class BitPositionSubObject +{ +public: + using allocator_type = ::std::allocator; + + BitPositionSubObject() noexcept : + BitPositionSubObject(allocator_type()) + {} + + explicit BitPositionSubObject(const allocator_type& allocator) noexcept; + + explicit BitPositionSubObject( + uint8_t value_, + const allocator_type& allocator = allocator_type()) : + BitPositionSubObject(allocator) + { + m_value_ = value_; + } + + explicit BitPositionSubObject(::zserio::BitStreamReader& in, const allocator_type& allocator = allocator_type()); + + ~BitPositionSubObject() = default; + + BitPositionSubObject(const BitPositionSubObject&) = default; + BitPositionSubObject& operator=(const BitPositionSubObject&) = default; + + BitPositionSubObject(BitPositionSubObject&&) = default; + BitPositionSubObject& operator=(BitPositionSubObject&&) = default; + + BitPositionSubObject(::zserio::PropagateAllocatorT, + const BitPositionSubObject& other, const allocator_type& allocator); + + static const ::zserio::ITypeInfo& typeInfo(); + ::zserio::IReflectableConstPtr reflectable(const allocator_type& allocator = allocator_type()) const; + ::zserio::IReflectablePtr reflectable(const allocator_type& allocator = allocator_type()); + + uint8_t getValue() const; + void setValue(uint8_t value_); + + size_t bitSizeOf(size_t bitPosition = 0) const; + + size_t initializeOffsets(size_t bitPosition = 0); + + bool operator==(const BitPositionSubObject& other) const; + + bool operator<(const BitPositionSubObject& other) const; + + uint32_t hashCode() const; + + void write(::zserio::BitStreamWriter& out) const; + + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + +private: + uint8_t readValue(::zserio::BitStreamReader& in); + + size_t m_bitPosition = 0; + uint8_t m_value_; +}; + +} // namespace std_allocator +} // namespace test_object + +#endif // TEST_OBJECT_STD_ALLOCATOR_BIT_POSITION_SUB_OBJECT_H diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.cpp index 70468a557..60104db5e 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.h index af266be20..319f171c0 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_CREATOR_BITMASK_H #define TEST_OBJECT_STD_ALLOCATOR_CREATOR_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.cpp index 399ca0648..f2b7ef4af 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.h index 2cd189d8f..0710699f0 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_CREATOR_ENUM_H #define TEST_OBJECT_STD_ALLOCATOR_CREATOR_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.cpp index fa89f6e09..b3d8648ff 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,36 +21,38 @@ namespace std_allocator { CreatorNested::CreatorNested(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_value_(uint32_t()), - m_text_(allocator), - m_externData_(allocator), - m_bytesData_(allocator), - m_creatorEnum_(::test_object::std_allocator::CreatorEnum()), - m_creatorBitmask_(::test_object::std_allocator::CreatorBitmask()) + m_isInitialized(false), + m_value_(uint32_t()), + m_text_(allocator), + m_externData_(allocator), + m_bytesData_(allocator), + m_creatorEnum_(::test_object::std_allocator::CreatorEnum()), + m_creatorBitmask_(::test_object::std_allocator::CreatorBitmask()) { } CreatorNested::CreatorNested(::zserio::BitStreamReader& in, uint32_t param_, const allocator_type& allocator) : - m_param_(param_), - m_isInitialized(true), - m_value_(readValue(in)), - m_text_(readText(in, allocator)), - m_externData_(readExternData(in, allocator)), - m_bytesData_(readBytesData(in, allocator)), - m_creatorEnum_(readCreatorEnum(in)), - m_creatorBitmask_(readCreatorBitmask(in)) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_value_(readValue(in)), + m_text_(readText(in, allocator)), + m_externData_(readExternData(in, allocator)), + m_bytesData_(readBytesData(in, allocator)), + m_creatorEnum_(readCreatorEnum(in)), + m_creatorBitmask_(readCreatorBitmask(in)) { } CreatorNested::CreatorNested(const CreatorNested& other) : - m_value_(other.m_value_), - m_text_(other.m_text_), - m_externData_(other.m_externData_), - m_bytesData_(other.m_bytesData_), - m_creatorEnum_(other.m_creatorEnum_), - m_creatorBitmask_(other.m_creatorBitmask_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_), + m_text_(other.m_text_), + m_externData_(other.m_externData_), + m_bytesData_(other.m_bytesData_), + m_creatorEnum_(other.m_creatorEnum_), + m_creatorBitmask_(other.m_creatorBitmask_) { if (other.m_isInitialized) { @@ -83,12 +85,13 @@ CreatorNested& CreatorNested::operator=(const CreatorNested& other) } CreatorNested::CreatorNested(CreatorNested&& other) : - m_value_(::std::move(other.m_value_)), - m_text_(::std::move(other.m_text_)), - m_externData_(::std::move(other.m_externData_)), - m_bytesData_(::std::move(other.m_bytesData_)), - m_creatorEnum_(::std::move(other.m_creatorEnum_)), - m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)), + m_text_(::std::move(other.m_text_)), + m_externData_(::std::move(other.m_externData_)), + m_bytesData_(::std::move(other.m_bytesData_)), + m_creatorEnum_(::std::move(other.m_creatorEnum_)), + m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) { if (other.m_isInitialized) { @@ -102,6 +105,7 @@ CreatorNested::CreatorNested(CreatorNested&& other) : CreatorNested& CreatorNested::operator=(CreatorNested&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); m_text_ = ::std::move(other.m_text_); m_externData_ = ::std::move(other.m_externData_); @@ -121,15 +125,17 @@ CreatorNested& CreatorNested::operator=(CreatorNested&& other) } CreatorNested::CreatorNested(::zserio::NoInitT, - const CreatorNested& other) : + const CreatorNested& other) + : m_isInitialized(false), - m_value_(other.m_value_), - m_text_(other.m_text_), - m_externData_(other.m_externData_), - m_bytesData_(other.m_bytesData_), - m_creatorEnum_(other.m_creatorEnum_), - m_creatorBitmask_(other.m_creatorBitmask_) + m_value_(other.m_value_), + m_text_(other.m_text_), + m_externData_(other.m_externData_), + m_bytesData_(other.m_bytesData_), + m_creatorEnum_(other.m_creatorEnum_), + m_creatorBitmask_(other.m_creatorBitmask_) { + (void)other; } CreatorNested& CreatorNested::assign(::zserio::NoInitT, @@ -143,24 +149,28 @@ CreatorNested& CreatorNested::assign(::zserio::NoInitT, m_creatorEnum_ = other.m_creatorEnum_; m_creatorBitmask_ = other.m_creatorBitmask_; + (void)other; return *this; } CreatorNested::CreatorNested(::zserio::NoInitT, - CreatorNested&& other) : +CreatorNested&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_value_(::std::move(other.m_value_)), - m_text_(::std::move(other.m_text_)), - m_externData_(::std::move(other.m_externData_)), - m_bytesData_(::std::move(other.m_bytesData_)), - m_creatorEnum_(::std::move(other.m_creatorEnum_)), - m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) + m_value_(::std::move(other.m_value_)), + m_text_(::std::move(other.m_text_)), + m_externData_(::std::move(other.m_externData_)), + m_bytesData_(::std::move(other.m_bytesData_)), + m_creatorEnum_(::std::move(other.m_creatorEnum_)), + m_creatorBitmask_(::std::move(other.m_creatorBitmask_)) { + (void)other; } CreatorNested& CreatorNested::assign(::zserio::NoInitT, - CreatorNested&& other) +CreatorNested&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_value_ = ::std::move(other.m_value_); m_text_ = ::std::move(other.m_text_); @@ -169,17 +179,20 @@ CreatorNested& CreatorNested::assign(::zserio::NoInitT, m_creatorEnum_ = ::std::move(other.m_creatorEnum_); m_creatorBitmask_ = ::std::move(other.m_creatorBitmask_); + (void)other; return *this; } CreatorNested::CreatorNested(::zserio::PropagateAllocatorT, - const CreatorNested& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), - m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), - m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), - m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) +const CreatorNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), + m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), + m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), + m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) { if (other.m_isInitialized) { @@ -189,18 +202,22 @@ CreatorNested::CreatorNested(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } CreatorNested::CreatorNested(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const CreatorNested& other, const allocator_type& allocator) : +const CreatorNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), - m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), - m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), - m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_externData_(::zserio::allocatorPropagatingCopy(other.m_externData_, allocator)), + m_bytesData_(::zserio::allocatorPropagatingCopy(other.m_bytesData_, allocator)), + m_creatorEnum_(::zserio::allocatorPropagatingCopy(other.m_creatorEnum_, allocator)), + m_creatorBitmask_(::zserio::allocatorPropagatingCopy(other.m_creatorBitmask_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& CreatorNested::typeInfo() @@ -397,6 +414,11 @@ ::zserio::IReflectableConstPtr CreatorNested::reflectable(const allocator_type& return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::CreatorNested& m_object; }; @@ -620,6 +642,11 @@ ::zserio::IReflectablePtr CreatorNested::reflectable(const allocator_type& alloc return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::CreatorNested& m_object; }; @@ -876,6 +903,10 @@ void CreatorNested::write(::zserio::BitStreamWriter& out) const ::zserio::write(out, m_creatorEnum_); m_creatorBitmask_.write(out); } +size_t CreatorNested::bitPosition() const +{ + return m_bitPosition; +} uint32_t CreatorNested::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.h index b984af64e..35e4dad71 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_CREATOR_NESTED_H #define TEST_OBJECT_STD_ALLOCATOR_CREATOR_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -130,6 +136,14 @@ class CreatorNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); ::zserio::string<> readText(::zserio::BitStreamReader& in, @@ -141,6 +155,7 @@ class CreatorNested ::test_object::std_allocator::CreatorEnum readCreatorEnum(::zserio::BitStreamReader& in); ::test_object::std_allocator::CreatorBitmask readCreatorBitmask(::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; uint32_t m_param_; bool m_isInitialized; uint32_t m_value_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.cpp index a62b60681..45e121db2 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,43 +21,45 @@ namespace std_allocator { CreatorObject::CreatorObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_value_(uint32_t()), - m_nested_(allocator), - m_text_(allocator), - m_nestedArray_(allocator), - m_textArray_(allocator), - m_externArray_(::zserio::NullOpt), - m_bytesArray_(::zserio::NullOpt), - m_optionalBool_(::zserio::NullOpt), - m_optionalNested_(::zserio::NullOpt) + m_areChildrenInitialized(false), + m_value_(uint32_t()), + m_nested_(allocator), + m_text_(allocator), + m_nestedArray_(allocator), + m_textArray_(allocator), + m_externArray_(::zserio::NullOpt), + m_bytesArray_(::zserio::NullOpt), + m_optionalBool_(::zserio::NullOpt), + m_optionalNested_(::zserio::NullOpt) { } CreatorObject::CreatorObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_value_(readValue(in)), - m_nested_(readNested(in, allocator)), - m_text_(readText(in, allocator)), - m_nestedArray_(readNestedArray(in, allocator)), - m_textArray_(readTextArray(in, allocator)), - m_externArray_(readExternArray(in, allocator)), - m_bytesArray_(readBytesArray(in, allocator)), - m_optionalBool_(readOptionalBool(in)), - m_optionalNested_(readOptionalNested(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_value_(readValue(in)), + m_nested_(readNested(in, allocator)), + m_text_(readText(in, allocator)), + m_nestedArray_(readNestedArray(in, allocator)), + m_textArray_(readTextArray(in, allocator)), + m_externArray_(readExternArray(in, allocator)), + m_bytesArray_(readBytesArray(in, allocator)), + m_optionalBool_(readOptionalBool(in)), + m_optionalNested_(readOptionalNested(in, allocator)) { } CreatorObject::CreatorObject(const CreatorObject& other) : - m_value_(other.m_value_), - m_nested_(::zserio::NoInit, other.m_nested_), - m_text_(other.m_text_), - m_nestedArray_(::zserio::NoInit, other.m_nestedArray_), - m_textArray_(other.m_textArray_), - m_externArray_(other.m_externArray_), - m_bytesArray_(other.m_bytesArray_), - m_optionalBool_(other.m_optionalBool_), - m_optionalNested_(::zserio::NoInit, other.m_optionalNested_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_), + m_nested_(::zserio::NoInit, other.m_nested_), + m_text_(other.m_text_), + m_nestedArray_(::zserio::NoInit, other.m_nestedArray_), + m_textArray_(other.m_textArray_), + m_externArray_(other.m_externArray_), + m_bytesArray_(other.m_bytesArray_), + m_optionalBool_(other.m_optionalBool_), + m_optionalNested_(::zserio::NoInit, other.m_optionalNested_) { if (other.m_areChildrenInitialized) { @@ -93,15 +95,16 @@ CreatorObject& CreatorObject::operator=(const CreatorObject& other) } CreatorObject::CreatorObject(CreatorObject&& other) : - m_value_(::std::move(other.m_value_)), - m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)), - m_text_(::std::move(other.m_text_)), - m_nestedArray_(::zserio::NoInit, ::std::move(other.m_nestedArray_)), - m_textArray_(::std::move(other.m_textArray_)), - m_externArray_(::std::move(other.m_externArray_)), - m_bytesArray_(::std::move(other.m_bytesArray_)), - m_optionalBool_(::std::move(other.m_optionalBool_)), - m_optionalNested_(::zserio::NoInit, ::std::move(other.m_optionalNested_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)), + m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)), + m_text_(::std::move(other.m_text_)), + m_nestedArray_(::zserio::NoInit, ::std::move(other.m_nestedArray_)), + m_textArray_(::std::move(other.m_textArray_)), + m_externArray_(::std::move(other.m_externArray_)), + m_bytesArray_(::std::move(other.m_bytesArray_)), + m_optionalBool_(::std::move(other.m_optionalBool_)), + m_optionalNested_(::zserio::NoInit, ::std::move(other.m_optionalNested_)) { if (other.m_areChildrenInitialized) { @@ -115,6 +118,7 @@ CreatorObject::CreatorObject(CreatorObject&& other) : CreatorObject& CreatorObject::operator=(CreatorObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); (void)m_nested_.assign(::zserio::NoInit, ::std::move(other.m_nested_)); m_text_ = ::std::move(other.m_text_); @@ -137,16 +141,18 @@ CreatorObject& CreatorObject::operator=(CreatorObject&& other) } CreatorObject::CreatorObject(::zserio::PropagateAllocatorT, - const CreatorObject& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), - m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_nestedArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nestedArray_, allocator)), - m_textArray_(::zserio::allocatorPropagatingCopy(other.m_textArray_, allocator)), - m_externArray_(::zserio::allocatorPropagatingCopy(other.m_externArray_, allocator)), - m_bytesArray_(::zserio::allocatorPropagatingCopy(other.m_bytesArray_, allocator)), - m_optionalBool_(::zserio::allocatorPropagatingCopy(other.m_optionalBool_, allocator)), - m_optionalNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_optionalNested_, allocator)) +const CreatorObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)), + m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_nestedArray_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nestedArray_, allocator)), + m_textArray_(::zserio::allocatorPropagatingCopy(other.m_textArray_, allocator)), + m_externArray_(::zserio::allocatorPropagatingCopy(other.m_externArray_, allocator)), + m_bytesArray_(::zserio::allocatorPropagatingCopy(other.m_bytesArray_, allocator)), + m_optionalBool_(::zserio::allocatorPropagatingCopy(other.m_optionalBool_, allocator)), + m_optionalNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_optionalNested_, allocator)) { if (other.m_areChildrenInitialized) { @@ -156,6 +162,7 @@ CreatorObject::CreatorObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::ITypeInfo& CreatorObject::typeInfo() @@ -427,6 +434,11 @@ ::zserio::IReflectableConstPtr CreatorObject::reflectable(const allocator_type& return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::CreatorObject& m_object; }; @@ -721,6 +733,11 @@ ::zserio::IReflectablePtr CreatorObject::reflectable(const allocator_type& alloc return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::CreatorObject& m_object; }; @@ -1252,6 +1269,10 @@ void CreatorObject::write(::zserio::BitStreamWriter& out) const out.writeBool(false); } } +size_t CreatorObject::bitPosition() const +{ + return m_bitPosition; +} void CreatorObject::ZserioArrayExpressions_nestedArray::initializeElement(CreatorObject& owner, ::test_object::std_allocator::CreatorNested& element, size_t) diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.h index 37e1c8d02..90c7735a7 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_CREATOR_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_CREATOR_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -155,6 +161,14 @@ class CreatorObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioArrayExpressions_nestedArray { @@ -197,6 +211,7 @@ class CreatorObject ::zserio::InplaceOptionalHolder<::test_object::std_allocator::CreatorNested> readOptionalNested(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; uint32_t m_value_; ::test_object::std_allocator::CreatorNested m_nested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.cpp index 78638cbb6..5c8e515ad 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.h index 3b01d8031..40980fb8d 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/CreatorUnsignedEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_CREATOR_UNSIGNED_ENUM_H #define TEST_OBJECT_STD_ALLOCATOR_CREATOR_UNSIGNED_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.cpp index f957429b9..fbe8f53ca 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -22,19 +22,23 @@ namespace std_allocator { DebugStringObject::DebugStringObject(const allocator_type& allocator) noexcept : - m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) + m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) { } DebugStringObject::DebugStringObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_text_(readText(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_text_(readText(in, allocator)) { } DebugStringObject::DebugStringObject(::zserio::PropagateAllocatorT, - const DebugStringObject& other, const allocator_type& allocator) : - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) +const DebugStringObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& DebugStringObject::typeInfo() @@ -117,6 +121,11 @@ ::zserio::IReflectableConstPtr DebugStringObject::reflectable(const allocator_ty return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::DebugStringObject& m_object; }; @@ -202,6 +211,11 @@ ::zserio::IReflectablePtr DebugStringObject::reflectable(const allocator_type& a return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::DebugStringObject& m_object; }; @@ -285,6 +299,10 @@ void DebugStringObject::write(::zserio::BitStreamWriter& out) const { out.writeString(m_text_); } +size_t DebugStringObject::bitPosition() const +{ + return m_bitPosition; +} ::zserio::string<> DebugStringObject::readText(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.h index e52424fb5..e8a70366d 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_DEBUG_STRING_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_DEBUG_STRING_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -76,10 +82,19 @@ class DebugStringObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::string<> readText(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; ::zserio::string<> m_text_; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.cpp index adfb531db..ffa5b1295 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -22,21 +22,23 @@ namespace std_allocator { DebugStringParamObject::DebugStringParamObject(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) + m_isInitialized(false), + m_text_(::zserio::stringViewToString(::zserio::makeStringView("test"), allocator)) { } DebugStringParamObject::DebugStringParamObject(::zserio::BitStreamReader& in, int32_t param_, const allocator_type& allocator) : - m_param_(param_), - m_isInitialized(true), - m_text_(readText(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_text_(readText(in, allocator)) { } DebugStringParamObject::DebugStringParamObject(const DebugStringParamObject& other) : - m_text_(other.m_text_) + m_bitPosition(other.m_bitPosition), + m_text_(other.m_text_) { if (other.m_isInitialized) { @@ -64,7 +66,8 @@ DebugStringParamObject& DebugStringParamObject::operator=(const DebugStringParam } DebugStringParamObject::DebugStringParamObject(DebugStringParamObject&& other) : - m_text_(::std::move(other.m_text_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_text_(::std::move(other.m_text_)) { if (other.m_isInitialized) { @@ -78,6 +81,7 @@ DebugStringParamObject::DebugStringParamObject(DebugStringParamObject&& other) : DebugStringParamObject& DebugStringParamObject::operator=(DebugStringParamObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_text_ = ::std::move(other.m_text_); if (other.m_isInitialized) { @@ -92,10 +96,12 @@ DebugStringParamObject& DebugStringParamObject::operator=(DebugStringParamObject } DebugStringParamObject::DebugStringParamObject(::zserio::NoInitT, - const DebugStringParamObject& other) : + const DebugStringParamObject& other) + : m_isInitialized(false), - m_text_(other.m_text_) + m_text_(other.m_text_) { + (void)other; } DebugStringParamObject& DebugStringParamObject::assign(::zserio::NoInitT, @@ -104,28 +110,35 @@ DebugStringParamObject& DebugStringParamObject::assign(::zserio::NoInitT, m_isInitialized = false; m_text_ = other.m_text_; + (void)other; return *this; } DebugStringParamObject::DebugStringParamObject(::zserio::NoInitT, - DebugStringParamObject&& other) : +DebugStringParamObject&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_text_(::std::move(other.m_text_)) + m_text_(::std::move(other.m_text_)) { + (void)other; } DebugStringParamObject& DebugStringParamObject::assign(::zserio::NoInitT, - DebugStringParamObject&& other) +DebugStringParamObject&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_text_ = ::std::move(other.m_text_); + (void)other; return *this; } DebugStringParamObject::DebugStringParamObject(::zserio::PropagateAllocatorT, - const DebugStringParamObject& other, const allocator_type& allocator) : - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) +const DebugStringParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { if (other.m_isInitialized) { @@ -135,13 +148,17 @@ DebugStringParamObject::DebugStringParamObject(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } DebugStringParamObject::DebugStringParamObject(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const DebugStringParamObject& other, const allocator_type& allocator) : +const DebugStringParamObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& DebugStringParamObject::typeInfo() @@ -238,6 +255,11 @@ ::zserio::IReflectableConstPtr DebugStringParamObject::reflectable(const allocat return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::DebugStringParamObject& m_object; }; @@ -355,6 +377,11 @@ ::zserio::IReflectablePtr DebugStringParamObject::reflectable(const allocator_ty return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::DebugStringParamObject& m_object; }; @@ -471,6 +498,10 @@ void DebugStringParamObject::write(::zserio::BitStreamWriter& out) const { out.writeString(m_text_); } +size_t DebugStringParamObject::bitPosition() const +{ + return m_bitPosition; +} ::zserio::string<> DebugStringParamObject::readText(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.h index ff552e3a7..fdb9798b9 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/DebugStringParamObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_DEBUG_STRING_PARAM_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_DEBUG_STRING_PARAM_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -95,10 +101,19 @@ class DebugStringParamObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::string<> readText(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; int32_t m_param_; bool m_isInitialized; ::zserio::string<> m_text_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.cpp index 40b2f7103..151cc084b 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.h index b565c00fe..6114985b1 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_BITMASK_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.cpp index 828b91f77..a3740ee73 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.h index fc49c1527..4a8b9e45c 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_ENUM_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.cpp index f756e7c64..e822f7c5f 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -22,23 +22,25 @@ namespace std_allocator { ReflectableNested::ReflectableNested(const allocator_type&) noexcept : - m_isInitialized(false), - m_value_(uint32_t()) + m_isInitialized(false), + m_value_(uint32_t()) { } ReflectableNested::ReflectableNested(::zserio::BitStreamReader& in, int32_t dummyParam_, ::zserio::string<>& stringParam_, const allocator_type&) : - m_dummyParam_(dummyParam_), - m_stringParam_(&stringParam_), - m_isInitialized(true), - m_value_(readValue(in)) + m_bitPosition(in.getBitPosition()), + m_dummyParam_(dummyParam_), + m_stringParam_(&stringParam_), + m_isInitialized(true), + m_value_(readValue(in)) { } ReflectableNested::ReflectableNested(const ReflectableNested& other) : - m_value_(other.m_value_) + m_bitPosition(other.m_bitPosition), + m_value_(other.m_value_) { if (other.m_isInitialized) { @@ -66,7 +68,8 @@ ReflectableNested& ReflectableNested::operator=(const ReflectableNested& other) } ReflectableNested::ReflectableNested(ReflectableNested&& other) : - m_value_(::std::move(other.m_value_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_value_(::std::move(other.m_value_)) { if (other.m_isInitialized) { @@ -80,6 +83,7 @@ ReflectableNested::ReflectableNested(ReflectableNested&& other) : ReflectableNested& ReflectableNested::operator=(ReflectableNested&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_value_ = ::std::move(other.m_value_); if (other.m_isInitialized) { @@ -94,10 +98,12 @@ ReflectableNested& ReflectableNested::operator=(ReflectableNested&& other) } ReflectableNested::ReflectableNested(::zserio::NoInitT, - const ReflectableNested& other) : + const ReflectableNested& other) + : m_isInitialized(false), - m_value_(other.m_value_) + m_value_(other.m_value_) { + (void)other; } ReflectableNested& ReflectableNested::assign(::zserio::NoInitT, @@ -106,28 +112,35 @@ ReflectableNested& ReflectableNested::assign(::zserio::NoInitT, m_isInitialized = false; m_value_ = other.m_value_; + (void)other; return *this; } ReflectableNested::ReflectableNested(::zserio::NoInitT, - ReflectableNested&& other) : +ReflectableNested&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_value_(::std::move(other.m_value_)) + m_value_(::std::move(other.m_value_)) { + (void)other; } ReflectableNested& ReflectableNested::assign(::zserio::NoInitT, - ReflectableNested&& other) +ReflectableNested&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_value_ = ::std::move(other.m_value_); + (void)other; return *this; } ReflectableNested::ReflectableNested(::zserio::PropagateAllocatorT, - const ReflectableNested& other, const allocator_type& allocator) : - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) +const ReflectableNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { if (other.m_isInitialized) { @@ -137,13 +150,17 @@ ReflectableNested::ReflectableNested(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } ReflectableNested::ReflectableNested(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const ReflectableNested& other, const allocator_type& allocator) : +const ReflectableNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) + m_value_(::zserio::allocatorPropagatingCopy(other.m_value_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& ReflectableNested::typeInfo() @@ -263,6 +280,11 @@ ::zserio::IReflectableConstPtr ReflectableNested::reflectable(const allocator_ty return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ReflectableNested& m_object; }; @@ -407,6 +429,11 @@ ::zserio::IReflectablePtr ReflectableNested::reflectable(const allocator_type& a return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ReflectableNested& m_object; }; @@ -551,6 +578,10 @@ void ReflectableNested::write(::zserio::BitStreamWriter& out) const { out.writeBits(m_value_, UINT8_C(31)); } +size_t ReflectableNested::bitPosition() const +{ + return m_bitPosition; +} uint32_t ReflectableNested::readValue(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.h index 150d3063c..627be2c3a 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_NESTED_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -98,9 +104,18 @@ class ReflectableNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint32_t readValue(::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; int32_t m_dummyParam_; ::zserio::string<>* m_stringParam_; bool m_isInitialized; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.cpp index d7c778b89..75af0f655 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,22 +21,24 @@ namespace std_allocator { ReflectableObject::ReflectableObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_stringField_(allocator), - m_reflectableNested_(allocator) + m_areChildrenInitialized(false), + m_stringField_(allocator), + m_reflectableNested_(allocator) { } ReflectableObject::ReflectableObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_stringField_(readStringField(in, allocator)), - m_reflectableNested_(readReflectableNested(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_stringField_(readStringField(in, allocator)), + m_reflectableNested_(readReflectableNested(in, allocator)) { } ReflectableObject::ReflectableObject(const ReflectableObject& other) : - m_stringField_(other.m_stringField_), - m_reflectableNested_(::zserio::NoInit, other.m_reflectableNested_) + m_bitPosition(other.m_bitPosition), + m_stringField_(other.m_stringField_), + m_reflectableNested_(::zserio::NoInit, other.m_reflectableNested_) { if (other.m_areChildrenInitialized) { @@ -65,8 +67,9 @@ ReflectableObject& ReflectableObject::operator=(const ReflectableObject& other) } ReflectableObject::ReflectableObject(ReflectableObject&& other) : - m_stringField_(::std::move(other.m_stringField_)), - m_reflectableNested_(::zserio::NoInit, ::std::move(other.m_reflectableNested_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_stringField_(::std::move(other.m_stringField_)), + m_reflectableNested_(::zserio::NoInit, ::std::move(other.m_reflectableNested_)) { if (other.m_areChildrenInitialized) { @@ -80,6 +83,7 @@ ReflectableObject::ReflectableObject(ReflectableObject&& other) : ReflectableObject& ReflectableObject::operator=(ReflectableObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_stringField_ = ::std::move(other.m_stringField_); (void)m_reflectableNested_.assign(::zserio::NoInit, ::std::move(other.m_reflectableNested_)); if (other.m_areChildrenInitialized) @@ -95,9 +99,11 @@ ReflectableObject& ReflectableObject::operator=(ReflectableObject&& other) } ReflectableObject::ReflectableObject(::zserio::PropagateAllocatorT, - const ReflectableObject& other, const allocator_type& allocator) : - m_stringField_(::zserio::allocatorPropagatingCopy(other.m_stringField_, allocator)), - m_reflectableNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableNested_, allocator)) +const ReflectableObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_stringField_(::zserio::allocatorPropagatingCopy(other.m_stringField_, allocator)), + m_reflectableNested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableNested_, allocator)) { if (other.m_areChildrenInitialized) { @@ -107,6 +113,7 @@ ReflectableObject::ReflectableObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::ITypeInfo& ReflectableObject::typeInfo() @@ -213,6 +220,11 @@ ::zserio::IReflectableConstPtr ReflectableObject::reflectable(const allocator_ty return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ReflectableObject& m_object; }; @@ -317,6 +329,11 @@ ::zserio::IReflectablePtr ReflectableObject::reflectable(const allocator_type& a return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ReflectableObject& m_object; }; @@ -452,6 +469,10 @@ void ReflectableObject::write(::zserio::BitStreamWriter& out) const } m_reflectableNested_.write(out); } +size_t ReflectableObject::bitPosition() const +{ + return m_bitPosition; +} ::zserio::string<> ReflectableObject::readStringField(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.h index 4c8f9def9..d5d4070c9 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -89,12 +95,21 @@ class ReflectableObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::string<> readStringField(::zserio::BitStreamReader& in, const allocator_type& allocator); ::test_object::std_allocator::ReflectableNested readReflectableNested(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; ::zserio::string<> m_stringField_; ::test_object::std_allocator::ReflectableNested m_reflectableNested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.cpp index 580cd43e3..461443f80 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.h index e28031bf4..9953724a6 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_BITMASK_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.cpp index 6120c187f..291220bdf 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -20,21 +20,23 @@ namespace std_allocator { ReflectableUtilChoice::ReflectableUtilChoice(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_objectChoice(allocator) + m_isInitialized(false), + m_objectChoice(allocator) { } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::BitStreamReader& in, uint8_t param_, const allocator_type& allocator) : - m_param_(param_), - m_isInitialized(true), - m_objectChoice(readObject(in, allocator), allocator) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_objectChoice(readObject(in, allocator), allocator) { } ReflectableUtilChoice::ReflectableUtilChoice(const ReflectableUtilChoice& other) : - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { if (other.m_isInitialized) { @@ -62,7 +64,8 @@ ReflectableUtilChoice& ReflectableUtilChoice::operator=(const ReflectableUtilCho } ReflectableUtilChoice::ReflectableUtilChoice(ReflectableUtilChoice&& other) : - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { if (other.m_isInitialized) { @@ -76,6 +79,7 @@ ReflectableUtilChoice::ReflectableUtilChoice(ReflectableUtilChoice&& other) : ReflectableUtilChoice& ReflectableUtilChoice::operator=(ReflectableUtilChoice&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); if (other.m_isInitialized) { @@ -90,10 +94,12 @@ ReflectableUtilChoice& ReflectableUtilChoice::operator=(ReflectableUtilChoice&& } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::NoInitT, - const ReflectableUtilChoice& other) : + const ReflectableUtilChoice& other) + : m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { + (void)other; } ReflectableUtilChoice& ReflectableUtilChoice::assign(::zserio::NoInitT, @@ -102,28 +108,35 @@ ReflectableUtilChoice& ReflectableUtilChoice::assign(::zserio::NoInitT, m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, other.m_objectChoice); + (void)other; return *this; } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::NoInitT, - ReflectableUtilChoice&& other) : +ReflectableUtilChoice&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { + (void)other; } ReflectableUtilChoice& ReflectableUtilChoice::assign(::zserio::NoInitT, - ReflectableUtilChoice&& other) +ReflectableUtilChoice&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); + (void)other; return *this; } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::PropagateAllocatorT, - const ReflectableUtilChoice& other, const allocator_type& allocator) : - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) +const ReflectableUtilChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { if (other.m_isInitialized) { @@ -133,13 +146,17 @@ ReflectableUtilChoice::ReflectableUtilChoice(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } ReflectableUtilChoice::ReflectableUtilChoice(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const ReflectableUtilChoice& other, const allocator_type& allocator) : +const ReflectableUtilChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { + (void)other; } const ::zserio::ITypeInfo& ReflectableUtilChoice::typeInfo() @@ -262,6 +279,11 @@ ::zserio::IReflectableConstPtr ReflectableUtilChoice::reflectable(const allocato return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ReflectableUtilChoice& m_object; }; @@ -391,13 +413,17 @@ ::zserio::IReflectablePtr ReflectableUtilChoice::reflectable(const allocator_typ return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ReflectableUtilChoice& m_object; }; return std::allocate_shared(allocator, *this, allocator); } - void ReflectableUtilChoice::initialize( uint8_t param_) { @@ -575,6 +601,10 @@ void ReflectableUtilChoice::write(::zserio::BitStreamWriter& out) const break; } } +size_t ReflectableUtilChoice::bitPosition() const +{ + return m_bitPosition; +} ::zserio::AnyHolder<> ReflectableUtilChoice::readObject(::zserio::BitStreamReader& in, const allocator_type& allocator) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.h index f0a95761d..bf4a81913 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilChoice.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_CHOICE_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_CHOICE_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -95,12 +101,21 @@ class ReflectableUtilChoice void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: using ZserioArrayType_array = ::zserio::Array<::zserio::vector, ::zserio::StdIntArrayTraits, ::zserio::ArrayType::AUTO>; ::zserio::AnyHolder<> readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::AnyHolder<> copyObject(const allocator_type& allocator) const; + size_t m_bitPosition = 0; uint8_t m_param_; bool m_isInitialized; ::zserio::AnyHolder<> m_objectChoice; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.cpp index 544b4c4ca..30175a181 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.h index 63167f62e..3fd7ec8dc 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_ENUM_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.cpp index 654addfd9..a49798b3a 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,22 +21,24 @@ namespace std_allocator { ReflectableUtilObject::ReflectableUtilObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_choiceParam_(uint8_t()), - m_reflectableUtilChoice_(allocator) + m_areChildrenInitialized(false), + m_choiceParam_(uint8_t()), + m_reflectableUtilChoice_(allocator) { } ReflectableUtilObject::ReflectableUtilObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_choiceParam_(readChoiceParam(in)), - m_reflectableUtilChoice_(readReflectableUtilChoice(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_choiceParam_(readChoiceParam(in)), + m_reflectableUtilChoice_(readReflectableUtilChoice(in, allocator)) { } ReflectableUtilObject::ReflectableUtilObject(const ReflectableUtilObject& other) : - m_choiceParam_(other.m_choiceParam_), - m_reflectableUtilChoice_(::zserio::NoInit, other.m_reflectableUtilChoice_) + m_bitPosition(other.m_bitPosition), + m_choiceParam_(other.m_choiceParam_), + m_reflectableUtilChoice_(::zserio::NoInit, other.m_reflectableUtilChoice_) { if (other.m_areChildrenInitialized) { @@ -65,8 +67,9 @@ ReflectableUtilObject& ReflectableUtilObject::operator=(const ReflectableUtilObj } ReflectableUtilObject::ReflectableUtilObject(ReflectableUtilObject&& other) : - m_choiceParam_(::std::move(other.m_choiceParam_)), - m_reflectableUtilChoice_(::zserio::NoInit, ::std::move(other.m_reflectableUtilChoice_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_choiceParam_(::std::move(other.m_choiceParam_)), + m_reflectableUtilChoice_(::zserio::NoInit, ::std::move(other.m_reflectableUtilChoice_)) { if (other.m_areChildrenInitialized) { @@ -80,6 +83,7 @@ ReflectableUtilObject::ReflectableUtilObject(ReflectableUtilObject&& other) : ReflectableUtilObject& ReflectableUtilObject::operator=(ReflectableUtilObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_choiceParam_ = ::std::move(other.m_choiceParam_); (void)m_reflectableUtilChoice_.assign(::zserio::NoInit, ::std::move(other.m_reflectableUtilChoice_)); if (other.m_areChildrenInitialized) @@ -95,9 +99,11 @@ ReflectableUtilObject& ReflectableUtilObject::operator=(ReflectableUtilObject&& } ReflectableUtilObject::ReflectableUtilObject(::zserio::PropagateAllocatorT, - const ReflectableUtilObject& other, const allocator_type& allocator) : - m_choiceParam_(::zserio::allocatorPropagatingCopy(other.m_choiceParam_, allocator)), - m_reflectableUtilChoice_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableUtilChoice_, allocator)) +const ReflectableUtilObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_choiceParam_(::zserio::allocatorPropagatingCopy(other.m_choiceParam_, allocator)), + m_reflectableUtilChoice_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_reflectableUtilChoice_, allocator)) { if (other.m_areChildrenInitialized) { @@ -107,6 +113,7 @@ ReflectableUtilObject::ReflectableUtilObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::ITypeInfo& ReflectableUtilObject::typeInfo() @@ -212,6 +219,11 @@ ::zserio::IReflectableConstPtr ReflectableUtilObject::reflectable(const allocato return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ReflectableUtilObject& m_object; }; @@ -316,6 +328,11 @@ ::zserio::IReflectablePtr ReflectableUtilObject::reflectable(const allocator_typ return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ReflectableUtilObject& m_object; }; @@ -437,6 +454,10 @@ void ReflectableUtilObject::write(::zserio::BitStreamWriter& out) const } m_reflectableUtilChoice_.write(out); } +size_t ReflectableUtilObject::bitPosition() const +{ + return m_bitPosition; +} uint8_t ReflectableUtilObject::readChoiceParam(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.h index 689111350..dc8aa9374 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -84,11 +90,20 @@ class ReflectableUtilObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint8_t readChoiceParam(::zserio::BitStreamReader& in); ::test_object::std_allocator::ReflectableUtilChoice readReflectableUtilChoice(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; uint8_t m_choiceParam_; ::test_object::std_allocator::ReflectableUtilChoice m_reflectableUtilChoice_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.cpp index c8b18607a..05c9aede7 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -20,14 +20,15 @@ namespace std_allocator { ReflectableUtilUnion::ReflectableUtilUnion(const allocator_type& allocator) noexcept : - m_choiceTag(UNDEFINED_CHOICE), - m_objectChoice(allocator) + m_choiceTag(UNDEFINED_CHOICE), + m_objectChoice(allocator) { } ReflectableUtilUnion::ReflectableUtilUnion(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_choiceTag(readChoiceTag(in)), - m_objectChoice(readObject(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_choiceTag(readChoiceTag(in)), + m_objectChoice(readObject(in, allocator)) { } @@ -173,6 +174,11 @@ ::zserio::IReflectableConstPtr ReflectableUtilUnion::reflectable(const allocator return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::ReflectableUtilUnion& m_object; }; @@ -326,6 +332,11 @@ ::zserio::IReflectablePtr ReflectableUtilUnion::reflectable(const allocator_type return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::ReflectableUtilUnion& m_object; }; @@ -574,6 +585,10 @@ void ReflectableUtilUnion::write(::zserio::BitStreamWriter& out) const throw ::zserio::CppRuntimeException("No match in union ReflectableUtilUnion!"); } } +size_t ReflectableUtilUnion::bitPosition() const +{ + return m_bitPosition; +} ReflectableUtilUnion::ChoiceTag ReflectableUtilUnion::readChoiceTag(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.h index b441686f6..0c70395bc 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/ReflectableUtilUnion.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_UNION_H #define TEST_OBJECT_STD_ALLOCATOR_REFLECTABLE_UTIL_UNION_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -88,11 +94,19 @@ class ReflectableUtilUnion void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ChoiceTag readChoiceTag(::zserio::BitStreamReader& in); ::zserio::AnyHolder<> readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::AnyHolder<> copyObject(const allocator_type& allocator) const; - + size_t m_bitPosition = 0; ChoiceTag m_choiceTag; ::zserio::AnyHolder<> m_objectChoice; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.cpp index d2a4f8dac..442632399 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.h index baad30db5..39dbaff9b 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeEnum.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_SERIALIZE_ENUM_H #define TEST_OBJECT_STD_ALLOCATOR_SERIALIZE_ENUM_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.cpp index bd669fb40..7b63ca34b 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,24 +21,26 @@ namespace std_allocator { SerializeNested::SerializeNested(const allocator_type&) noexcept : - m_isInitialized(false), - m_offset_(uint8_t()), - m_optionalValue_(::zserio::NullOpt) + m_isInitialized(false), + m_offset_(uint8_t()), + m_optionalValue_(::zserio::NullOpt) { } SerializeNested::SerializeNested(::zserio::BitStreamReader& in, int8_t param_, const allocator_type&) : - m_param_(param_), - m_isInitialized(true), - m_offset_(readOffset(in)), - m_optionalValue_(readOptionalValue(in)) + m_bitPosition(in.getBitPosition()), + m_param_(param_), + m_isInitialized(true), + m_offset_(readOffset(in)), + m_optionalValue_(readOptionalValue(in)) { } SerializeNested::SerializeNested(const SerializeNested& other) : - m_offset_(other.m_offset_), - m_optionalValue_(other.m_optionalValue_) + m_bitPosition(other.m_bitPosition), + m_offset_(other.m_offset_), + m_optionalValue_(other.m_optionalValue_) { if (other.m_isInitialized) { @@ -67,8 +69,9 @@ SerializeNested& SerializeNested::operator=(const SerializeNested& other) } SerializeNested::SerializeNested(SerializeNested&& other) : - m_offset_(::std::move(other.m_offset_)), - m_optionalValue_(::std::move(other.m_optionalValue_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_offset_(::std::move(other.m_offset_)), + m_optionalValue_(::std::move(other.m_optionalValue_)) { if (other.m_isInitialized) { @@ -82,6 +85,7 @@ SerializeNested::SerializeNested(SerializeNested&& other) : SerializeNested& SerializeNested::operator=(SerializeNested&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_offset_ = ::std::move(other.m_offset_); m_optionalValue_ = ::std::move(other.m_optionalValue_); if (other.m_isInitialized) @@ -97,11 +101,13 @@ SerializeNested& SerializeNested::operator=(SerializeNested&& other) } SerializeNested::SerializeNested(::zserio::NoInitT, - const SerializeNested& other) : + const SerializeNested& other) + : m_isInitialized(false), - m_offset_(other.m_offset_), - m_optionalValue_(other.m_optionalValue_) + m_offset_(other.m_offset_), + m_optionalValue_(other.m_optionalValue_) { + (void)other; } SerializeNested& SerializeNested::assign(::zserio::NoInitT, @@ -111,31 +117,38 @@ SerializeNested& SerializeNested::assign(::zserio::NoInitT, m_offset_ = other.m_offset_; m_optionalValue_ = other.m_optionalValue_; + (void)other; return *this; } SerializeNested::SerializeNested(::zserio::NoInitT, - SerializeNested&& other) : +SerializeNested&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_offset_(::std::move(other.m_offset_)), - m_optionalValue_(::std::move(other.m_optionalValue_)) + m_offset_(::std::move(other.m_offset_)), + m_optionalValue_(::std::move(other.m_optionalValue_)) { + (void)other; } SerializeNested& SerializeNested::assign(::zserio::NoInitT, - SerializeNested&& other) +SerializeNested&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; m_offset_ = ::std::move(other.m_offset_); m_optionalValue_ = ::std::move(other.m_optionalValue_); + (void)other; return *this; } SerializeNested::SerializeNested(::zserio::PropagateAllocatorT, - const SerializeNested& other, const allocator_type& allocator) : - m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), - m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) +const SerializeNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), + m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) { if (other.m_isInitialized) { @@ -145,14 +158,18 @@ SerializeNested::SerializeNested(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } SerializeNested::SerializeNested(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const SerializeNested& other, const allocator_type& allocator) : +const SerializeNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), - m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) + m_offset_(::zserio::allocatorPropagatingCopy(other.m_offset_, allocator)), + m_optionalValue_(::zserio::allocatorPropagatingCopy(other.m_optionalValue_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& SerializeNested::typeInfo() @@ -274,6 +291,11 @@ ::zserio::IReflectableConstPtr SerializeNested::reflectable(const allocator_type return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::SerializeNested& m_object; }; @@ -425,6 +447,11 @@ ::zserio::IReflectablePtr SerializeNested::reflectable(const allocator_type& all return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::SerializeNested& m_object; }; @@ -604,6 +631,10 @@ void SerializeNested::write(::zserio::BitStreamWriter& out) const out.writeBits(m_optionalValue_.value(), UINT8_C(32)); } } +size_t SerializeNested::bitPosition() const +{ + return m_bitPosition; +} uint8_t SerializeNested::readOffset(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.h index 298a0f17f..547eafebb 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_SERIALIZE_NESTED_H #define TEST_OBJECT_STD_ALLOCATOR_SERIALIZE_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -100,10 +106,19 @@ class SerializeNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: uint8_t readOffset(::zserio::BitStreamReader& in); ::zserio::InplaceOptionalHolder readOptionalValue(::zserio::BitStreamReader& in); + size_t m_bitPosition = 0; int8_t m_param_; bool m_isInitialized; uint8_t m_offset_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.cpp index f92df8a76..a8c29e6f2 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,22 +21,24 @@ namespace std_allocator { SerializeObject::SerializeObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_param_(int8_t()), - m_nested_(allocator) + m_areChildrenInitialized(false), + m_param_(int8_t()), + m_nested_(allocator) { } SerializeObject::SerializeObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_param_(readParam(in)), - m_nested_(readNested(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_param_(readParam(in)), + m_nested_(readNested(in, allocator)) { } SerializeObject::SerializeObject(const SerializeObject& other) : - m_param_(other.m_param_), - m_nested_(::zserio::NoInit, other.m_nested_) + m_bitPosition(other.m_bitPosition), + m_param_(other.m_param_), + m_nested_(::zserio::NoInit, other.m_nested_) { if (other.m_areChildrenInitialized) { @@ -65,8 +67,9 @@ SerializeObject& SerializeObject::operator=(const SerializeObject& other) } SerializeObject::SerializeObject(SerializeObject&& other) : - m_param_(::std::move(other.m_param_)), - m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_param_(::std::move(other.m_param_)), + m_nested_(::zserio::NoInit, ::std::move(other.m_nested_)) { if (other.m_areChildrenInitialized) { @@ -80,6 +83,7 @@ SerializeObject::SerializeObject(SerializeObject&& other) : SerializeObject& SerializeObject::operator=(SerializeObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_param_ = ::std::move(other.m_param_); (void)m_nested_.assign(::zserio::NoInit, ::std::move(other.m_nested_)); if (other.m_areChildrenInitialized) @@ -95,9 +99,11 @@ SerializeObject& SerializeObject::operator=(SerializeObject&& other) } SerializeObject::SerializeObject(::zserio::PropagateAllocatorT, - const SerializeObject& other, const allocator_type& allocator) : - m_param_(::zserio::allocatorPropagatingCopy(other.m_param_, allocator)), - m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)) +const SerializeObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_param_(::zserio::allocatorPropagatingCopy(other.m_param_, allocator)), + m_nested_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_nested_, allocator)) { if (other.m_areChildrenInitialized) { @@ -107,6 +113,7 @@ SerializeObject::SerializeObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::ITypeInfo& SerializeObject::typeInfo() @@ -212,6 +219,11 @@ ::zserio::IReflectableConstPtr SerializeObject::reflectable(const allocator_type return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::SerializeObject& m_object; }; @@ -316,6 +328,11 @@ ::zserio::IReflectablePtr SerializeObject::reflectable(const allocator_type& all return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::SerializeObject& m_object; }; @@ -437,6 +454,10 @@ void SerializeObject::write(::zserio::BitStreamWriter& out) const } m_nested_.write(out); } +size_t SerializeObject::bitPosition() const +{ + return m_bitPosition; +} int8_t SerializeObject::readParam(::zserio::BitStreamReader& in) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.h index 7770a7024..6ff91adc6 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/SerializeObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_SERIALIZE_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_SERIALIZE_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -84,11 +90,20 @@ class SerializeObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: int8_t readParam(::zserio::BitStreamReader& in); ::test_object::std_allocator::SerializeNested readNested(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; int8_t m_param_; ::test_object::std_allocator::SerializeNested m_nested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.cpp index 7048f2414..a52940440 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.h index 1f35a46fa..4ca43c0da 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerBitmask.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_WALKER_BITMASK_H #define TEST_OBJECT_STD_ALLOCATOR_WALKER_BITMASK_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.cpp index 5786f7e30..2f5d1b667 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -20,21 +20,23 @@ namespace std_allocator { WalkerChoice::WalkerChoice(const allocator_type& allocator) noexcept : - m_isInitialized(false), - m_objectChoice(allocator) + m_isInitialized(false), + m_objectChoice(allocator) { } WalkerChoice::WalkerChoice(::zserio::BitStreamReader& in, uint8_t selector_, const allocator_type& allocator) : - m_selector_(selector_), - m_isInitialized(true), - m_objectChoice(readObject(in, allocator), allocator) + m_bitPosition(in.getBitPosition()), + m_selector_(selector_), + m_isInitialized(true), + m_objectChoice(readObject(in, allocator), allocator) { } WalkerChoice::WalkerChoice(const WalkerChoice& other) : - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { if (other.m_isInitialized) { @@ -62,7 +64,8 @@ WalkerChoice& WalkerChoice::operator=(const WalkerChoice& other) } WalkerChoice::WalkerChoice(WalkerChoice&& other) : - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { if (other.m_isInitialized) { @@ -76,6 +79,7 @@ WalkerChoice::WalkerChoice(WalkerChoice&& other) : WalkerChoice& WalkerChoice::operator=(WalkerChoice&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); if (other.m_isInitialized) { @@ -90,10 +94,12 @@ WalkerChoice& WalkerChoice::operator=(WalkerChoice&& other) } WalkerChoice::WalkerChoice(::zserio::NoInitT, - const WalkerChoice& other) : + const WalkerChoice& other) + : m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.m_objectChoice) + m_objectChoice(::zserio::NoInit, other.m_objectChoice) { + (void)other; } WalkerChoice& WalkerChoice::assign(::zserio::NoInitT, @@ -102,28 +108,35 @@ WalkerChoice& WalkerChoice::assign(::zserio::NoInitT, m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, other.m_objectChoice); + (void)other; return *this; } WalkerChoice::WalkerChoice(::zserio::NoInitT, - WalkerChoice&& other) : +WalkerChoice&& other) : + m_bitPosition(::std::move(other.m_bitPosition)), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) + m_objectChoice(::zserio::NoInit, ::std::move(other.m_objectChoice)) { + (void)other; } WalkerChoice& WalkerChoice::assign(::zserio::NoInitT, - WalkerChoice&& other) +WalkerChoice&& other) { + m_bitPosition = other.m_bitPosition; m_isInitialized = false; (void)m_objectChoice.assign(::zserio::NoInit, ::std::move(other.m_objectChoice)); + (void)other; return *this; } WalkerChoice::WalkerChoice(::zserio::PropagateAllocatorT, - const WalkerChoice& other, const allocator_type& allocator) : - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) +const WalkerChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { if (other.m_isInitialized) { @@ -133,13 +146,17 @@ WalkerChoice::WalkerChoice(::zserio::PropagateAllocatorT, { m_isInitialized = false; } + (void)other; } WalkerChoice::WalkerChoice(::zserio::PropagateAllocatorT, ::zserio::NoInitT, - const WalkerChoice& other, const allocator_type& allocator) : +const WalkerChoice& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), m_isInitialized(false), - m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) + m_objectChoice(::zserio::NoInit, other.copyObject(allocator)) { + (void)other; } const ::zserio::ITypeInfo& WalkerChoice::typeInfo() @@ -347,6 +364,11 @@ ::zserio::IReflectableConstPtr WalkerChoice::reflectable(const allocator_type& a return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::WalkerChoice& m_object; }; @@ -535,13 +557,17 @@ ::zserio::IReflectablePtr WalkerChoice::reflectable(const allocator_type& alloca return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::WalkerChoice& m_object; }; return std::allocate_shared(allocator, *this, allocator); } - void WalkerChoice::initialize( uint8_t selector_) { @@ -813,6 +839,10 @@ void WalkerChoice::write(::zserio::BitStreamWriter& out) const break; } } +size_t WalkerChoice::bitPosition() const +{ + return m_bitPosition; +} ::zserio::AnyHolder<> WalkerChoice::readObject(::zserio::BitStreamReader& in, const allocator_type& allocator) { diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.h index 8fc4bc187..2090015d7 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerChoice.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_WALKER_CHOICE_H #define TEST_OBJECT_STD_ALLOCATOR_WALKER_CHOICE_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -103,10 +109,19 @@ class WalkerChoice void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::AnyHolder<> readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::AnyHolder<> copyObject(const allocator_type& allocator) const; + size_t m_bitPosition = 0; uint8_t m_selector_; bool m_isInitialized; ::zserio::AnyHolder<> m_objectChoice; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.cpp index 62bc3e7f7..ad998fe4f 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,19 +21,23 @@ namespace std_allocator { WalkerNested::WalkerNested(const allocator_type& allocator) noexcept : - m_text_(allocator) + m_text_(allocator) { } WalkerNested::WalkerNested(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_text_(readText(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_text_(readText(in, allocator)) { } WalkerNested::WalkerNested(::zserio::PropagateAllocatorT, - const WalkerNested& other, const allocator_type& allocator) : - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) +const WalkerNested& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)) { + (void)other; } const ::zserio::ITypeInfo& WalkerNested::typeInfo() @@ -116,6 +120,11 @@ ::zserio::IReflectableConstPtr WalkerNested::reflectable(const allocator_type& a return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::WalkerNested& m_object; }; @@ -201,6 +210,11 @@ ::zserio::IReflectablePtr WalkerNested::reflectable(const allocator_type& alloca return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::WalkerNested& m_object; }; @@ -284,6 +298,10 @@ void WalkerNested::write(::zserio::BitStreamWriter& out) const { out.writeString(m_text_); } +size_t WalkerNested::bitPosition() const +{ + return m_bitPosition; +} ::zserio::string<> WalkerNested::readText(::zserio::BitStreamReader& in, const allocator_type& allocator) diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.h index 8080ee573..1940970ec 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerNested.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_WALKER_NESTED_H #define TEST_OBJECT_STD_ALLOCATOR_WALKER_NESTED_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -76,10 +82,19 @@ class WalkerNested void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: ::zserio::string<> readText(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; ::zserio::string<> m_text_; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.cpp index 4ddd381e5..b9787608f 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -21,37 +21,39 @@ namespace std_allocator { WalkerObject::WalkerObject(const allocator_type& allocator) noexcept : - m_areChildrenInitialized(false), - m_identifier_(uint32_t()), - m_nested_(::zserio::NullOpt), - m_text_(allocator), - m_unionArray_(allocator), - m_optionalUnionArray_(::zserio::NullOpt), - m_choiceSelector_(uint8_t()), - m_choiceField_(allocator) + m_areChildrenInitialized(false), + m_identifier_(uint32_t()), + m_nested_(::zserio::NullOpt), + m_text_(allocator), + m_unionArray_(allocator), + m_optionalUnionArray_(::zserio::NullOpt), + m_choiceSelector_(uint8_t()), + m_choiceField_(allocator) { } WalkerObject::WalkerObject(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_areChildrenInitialized(true), - m_identifier_(readIdentifier(in)), - m_nested_(readNested(in, allocator)), - m_text_(readText(in, allocator)), - m_unionArray_(readUnionArray(in, allocator)), - m_optionalUnionArray_(readOptionalUnionArray(in, allocator)), - m_choiceSelector_(readChoiceSelector(in)), - m_choiceField_(readChoiceField(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_areChildrenInitialized(true), + m_identifier_(readIdentifier(in)), + m_nested_(readNested(in, allocator)), + m_text_(readText(in, allocator)), + m_unionArray_(readUnionArray(in, allocator)), + m_optionalUnionArray_(readOptionalUnionArray(in, allocator)), + m_choiceSelector_(readChoiceSelector(in)), + m_choiceField_(readChoiceField(in, allocator)) { } WalkerObject::WalkerObject(const WalkerObject& other) : - m_identifier_(other.m_identifier_), - m_nested_(other.m_nested_), - m_text_(other.m_text_), - m_unionArray_(other.m_unionArray_), - m_optionalUnionArray_(other.m_optionalUnionArray_), - m_choiceSelector_(other.m_choiceSelector_), - m_choiceField_(::zserio::NoInit, other.m_choiceField_) + m_bitPosition(other.m_bitPosition), + m_identifier_(other.m_identifier_), + m_nested_(other.m_nested_), + m_text_(other.m_text_), + m_unionArray_(other.m_unionArray_), + m_optionalUnionArray_(other.m_optionalUnionArray_), + m_choiceSelector_(other.m_choiceSelector_), + m_choiceField_(::zserio::NoInit, other.m_choiceField_) { if (other.m_areChildrenInitialized) { @@ -85,13 +87,14 @@ WalkerObject& WalkerObject::operator=(const WalkerObject& other) } WalkerObject::WalkerObject(WalkerObject&& other) : - m_identifier_(::std::move(other.m_identifier_)), - m_nested_(::std::move(other.m_nested_)), - m_text_(::std::move(other.m_text_)), - m_unionArray_(::std::move(other.m_unionArray_)), - m_optionalUnionArray_(::std::move(other.m_optionalUnionArray_)), - m_choiceSelector_(::std::move(other.m_choiceSelector_)), - m_choiceField_(::zserio::NoInit, ::std::move(other.m_choiceField_)) + m_bitPosition(::std::move(other.m_bitPosition)), + m_identifier_(::std::move(other.m_identifier_)), + m_nested_(::std::move(other.m_nested_)), + m_text_(::std::move(other.m_text_)), + m_unionArray_(::std::move(other.m_unionArray_)), + m_optionalUnionArray_(::std::move(other.m_optionalUnionArray_)), + m_choiceSelector_(::std::move(other.m_choiceSelector_)), + m_choiceField_(::zserio::NoInit, ::std::move(other.m_choiceField_)) { if (other.m_areChildrenInitialized) { @@ -105,6 +108,7 @@ WalkerObject::WalkerObject(WalkerObject&& other) : WalkerObject& WalkerObject::operator=(WalkerObject&& other) { + m_bitPosition = ::std::move(other.m_bitPosition); m_identifier_ = ::std::move(other.m_identifier_); m_nested_ = ::std::move(other.m_nested_); m_text_ = ::std::move(other.m_text_); @@ -125,14 +129,16 @@ WalkerObject& WalkerObject::operator=(WalkerObject&& other) } WalkerObject::WalkerObject(::zserio::PropagateAllocatorT, - const WalkerObject& other, const allocator_type& allocator) : - m_identifier_(::zserio::allocatorPropagatingCopy(other.m_identifier_, allocator)), - m_nested_(::zserio::allocatorPropagatingCopy(other.m_nested_, allocator)), - m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), - m_unionArray_(::zserio::allocatorPropagatingCopy(other.m_unionArray_, allocator)), - m_optionalUnionArray_(::zserio::allocatorPropagatingCopy(other.m_optionalUnionArray_, allocator)), - m_choiceSelector_(::zserio::allocatorPropagatingCopy(other.m_choiceSelector_, allocator)), - m_choiceField_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_choiceField_, allocator)) +const WalkerObject& other, +const allocator_type& allocator) : + m_bitPosition(other.m_bitPosition), + m_identifier_(::zserio::allocatorPropagatingCopy(other.m_identifier_, allocator)), + m_nested_(::zserio::allocatorPropagatingCopy(other.m_nested_, allocator)), + m_text_(::zserio::allocatorPropagatingCopy(other.m_text_, allocator)), + m_unionArray_(::zserio::allocatorPropagatingCopy(other.m_unionArray_, allocator)), + m_optionalUnionArray_(::zserio::allocatorPropagatingCopy(other.m_optionalUnionArray_, allocator)), + m_choiceSelector_(::zserio::allocatorPropagatingCopy(other.m_choiceSelector_, allocator)), + m_choiceField_(::zserio::NoInit, ::zserio::allocatorPropagatingCopy(::zserio::NoInit, other.m_choiceField_, allocator)) { if (other.m_areChildrenInitialized) { @@ -142,6 +148,7 @@ WalkerObject::WalkerObject(::zserio::PropagateAllocatorT, { m_areChildrenInitialized = false; } + (void)other; } const ::zserio::ITypeInfo& WalkerObject::typeInfo() @@ -357,6 +364,11 @@ ::zserio::IReflectableConstPtr WalkerObject::reflectable(const allocator_type& a return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::WalkerObject& m_object; }; @@ -583,6 +595,11 @@ ::zserio::IReflectablePtr WalkerObject::reflectable(const allocator_type& alloca return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::WalkerObject& m_object; }; @@ -944,6 +961,10 @@ void WalkerObject::write(::zserio::BitStreamWriter& out) const } m_choiceField_.write(out); } +size_t WalkerObject::bitPosition() const +{ + return m_bitPosition; +} void WalkerObject::ZserioElementFactory_unionArray::create(WalkerObject&, ::zserio::vector<::test_object::std_allocator::WalkerUnion>& array, diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.h index 4916037f4..b46aea369 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerObject.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_WALKER_OBJECT_H #define TEST_OBJECT_STD_ALLOCATOR_WALKER_OBJECT_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -133,6 +139,14 @@ class WalkerObject void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioElementFactory_unionArray { @@ -170,6 +184,7 @@ class WalkerObject ::test_object::std_allocator::WalkerChoice readChoiceField(::zserio::BitStreamReader& in, const allocator_type& allocator); + size_t m_bitPosition = 0; bool m_areChildrenInitialized; uint32_t m_identifier_; ::zserio::InplaceOptionalHolder<::test_object::std_allocator::WalkerNested> m_nested_; diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.cpp b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.cpp index 3dea5058b..66c5fa2d5 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.cpp +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.cpp @@ -1,6 +1,6 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #include @@ -20,14 +20,15 @@ namespace std_allocator { WalkerUnion::WalkerUnion(const allocator_type& allocator) noexcept : - m_choiceTag(UNDEFINED_CHOICE), - m_objectChoice(allocator) + m_choiceTag(UNDEFINED_CHOICE), + m_objectChoice(allocator) { } WalkerUnion::WalkerUnion(::zserio::BitStreamReader& in, const allocator_type& allocator) : - m_choiceTag(readChoiceTag(in)), - m_objectChoice(readObject(in, allocator)) + m_bitPosition(in.getBitPosition()), + m_choiceTag(readChoiceTag(in)), + m_objectChoice(readObject(in, allocator)) { } @@ -173,6 +174,11 @@ ::zserio::IReflectableConstPtr WalkerUnion::reflectable(const allocator_type& al return ::zserio::AnyHolder<>(::std::cref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: const ::test_object::std_allocator::WalkerUnion& m_object; }; @@ -309,6 +315,11 @@ ::zserio::IReflectablePtr WalkerUnion::reflectable(const allocator_type& allocat return ::zserio::AnyHolder<>(::std::ref(m_object), alloc); } + size_t bitPosition() const override + { + return m_object.bitPosition(); + } + private: ::test_object::std_allocator::WalkerUnion& m_object; }; @@ -550,6 +561,10 @@ void WalkerUnion::write(::zserio::BitStreamWriter& out) const throw ::zserio::CppRuntimeException("No match in union WalkerUnion!"); } } +size_t WalkerUnion::bitPosition() const +{ + return m_bitPosition; +} void WalkerUnion::ZserioElementFactory_nestedArray::create(WalkerUnion&, ::zserio::vector<::test_object::std_allocator::WalkerNested>& array, diff --git a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.h b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.h index 397386547..6f95a0970 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.h +++ b/compiler/extensions/cpp/runtime/test/test_object/std_allocator/WalkerUnion.h @@ -1,11 +1,17 @@ /** * Automatically generated by Zserio C++ generator version 1.0.2 using Zserio core 2.14.1. - * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, stdAllocator. + * Generator setup: writerCode, pubsubCode, serviceCode, sqlCode, typeInfoCode, reflectionCode, bitPosition, stdAllocator. */ #ifndef TEST_OBJECT_STD_ALLOCATOR_WALKER_UNION_H #define TEST_OBJECT_STD_ALLOCATOR_WALKER_UNION_H +#include +#if CPP_EXTENSION_RUNTIME_VERSION_NUMBER != 1000002 + #error Version mismatch between Zserio runtime library and Zserio C++ generator! + #error Please update your Zserio runtime library to the version 1.0.2. +#endif + #include #include #include @@ -90,6 +96,14 @@ class WalkerUnion void write(::zserio::BitStreamWriter& out) const; + /** + * Get the source offset and size of the structure in bits. + * For objects not loaded from a blob, the offest is 0. + * + * \return Tuple of the objects offset and size in bits. + */ + size_t bitPosition() const; + private: class ZserioElementFactory_nestedArray { @@ -106,7 +120,7 @@ class WalkerUnion ChoiceTag readChoiceTag(::zserio::BitStreamReader& in); ::zserio::AnyHolder<> readObject(::zserio::BitStreamReader& in, const allocator_type& allocator); ::zserio::AnyHolder<> copyObject(const allocator_type& allocator) const; - + size_t m_bitPosition = 0; ChoiceTag m_choiceTag; ::zserio::AnyHolder<> m_objectChoice; }; diff --git a/compiler/extensions/cpp/runtime/test/test_object/test_object.zs b/compiler/extensions/cpp/runtime/test/test_object/test_object.zs index 344209a3e..2bff6fb9c 100644 --- a/compiler/extensions/cpp/runtime/test/test_object/test_object.zs +++ b/compiler/extensions/cpp/runtime/test/test_object/test_object.zs @@ -1,10 +1,10 @@ /* * Compiled twice from the 'test' directory using the following command line options: * - * 1. -src test_object test_object.zs -cpp . -withTypeInfoCode -withReflectionCode -withoutSourcesAmalgamation - * -setCppAllocator std -setTopLevelPackage test_object.std_allocator - * 2. -src test_object test_object.zs -cpp . -withTypeInfoCode -withReflectionCode -withoutSourcesAmalgamation - * -setCppAllocator polymorphic -setTopLevelPackage test_object.polymorphic_allocator + * 1. -src test_object test_object.zs -cpp . -withTypeInfoCode -withReflectionCode -withBitPosition + * -withoutSourcesAmalgamation -setCppAllocator std -setTopLevelPackage test_object.std_allocator + * 2. -src test_object test_object.zs -cpp . -withTypeInfoCode -withReflectionCode -withBitPosition + * -withoutSourcesAmalgamation -setCppAllocator polymorphic -setTopLevelPackage test_object.polymorphic_allocator */ enum int8 CreatorEnum @@ -221,3 +221,14 @@ struct ArrayHolder packed ArrayObject packedArray[]; packed ArrayParamObject(packedArray[@index]) packedParamArray[]; }; + +struct BitPositionSubObject +{ + bit:7 value; +}; + +struct BitPositionObject +{ + bit:3 pad; + BitPositionSubObject sub; +}; diff --git a/compiler/extensions/cpp/runtime/test/zserio/BitPositionTest.cpp b/compiler/extensions/cpp/runtime/test/zserio/BitPositionTest.cpp new file mode 100644 index 000000000..ee263400b --- /dev/null +++ b/compiler/extensions/cpp/runtime/test/zserio/BitPositionTest.cpp @@ -0,0 +1,49 @@ +#include "gtest/gtest.h" +#include "test_object/std_allocator/BitPositionObject.h" +#include "test_object/std_allocator/BitPositionSubObject.h" +#include "zserio/BitStreamReader.h" +#include "zserio/BitStreamWriter.h" + +using test_object::std_allocator::BitPositionObject; +using test_object::std_allocator::BitPositionSubObject; + +// Return a buffer with a single encoded BitPostionObject. +static std::array getObjectBuffer() +{ + BitPositionObject object; + + std::array tmp; + zserio::BitStreamWriter writer(tmp.data(), tmp.size()); + object.write(writer); + + return tmp; +} + +namespace zserio +{ + +TEST(BitPositionTest, StructDefaultContructor) +{ + BitPositionObject object; + + // Default constructed objects must have a + // bit position of 0. + ASSERT_EQ(object.bitPosition(), 0); + ASSERT_EQ(object.getSub().bitPosition(), 0); +} + +TEST(BitPositionTest, StructReadPosition) +{ + auto buffer = getObjectBuffer(); + + zserio::BitStreamReader reader(buffer.data(), buffer.size()); + BitPositionObject object(reader); + + // The root object is expected at 0 + ASSERT_EQ(object.bitPosition(), 0); + + // The padded sub-object is expected at 3 + ASSERT_EQ(object.getSub().bitPosition(), 3); +} + +} // namespace zserio