Zserio C++ runtime library  1.2.0
Built for Zserio 2.16.0
IReflectable.h
Go to the documentation of this file.
1 #ifndef ZSERIO_I_REFLECTABLE_H_INC
2 #define ZSERIO_I_REFLECTABLE_H_INC
3 
4 #include <memory>
5 
6 #include "zserio/AnyHolder.h"
7 #include "zserio/BitBuffer.h"
9 #include "zserio/ParsingInfo.h"
10 #include "zserio/RebindAlloc.h"
11 #include "zserio/Span.h"
12 #include "zserio/String.h"
13 #include "zserio/StringView.h"
14 #include "zserio/Vector.h"
15 
16 namespace zserio
17 {
18 
19 // forward declaration
20 template <typename ALLOC>
21 class IBasicTypeInfo;
22 
31 template <typename ALLOC = std::allocator<uint8_t>>
33 {
34 public:
36  using Ptr = std::shared_ptr<IBasicReflectable>;
37 
39  using ConstPtr = std::shared_ptr<const IBasicReflectable>;
40 
44  virtual ~IBasicReflectable() = default;
45 
51  virtual const IBasicTypeInfo<ALLOC>& getTypeInfo() const = 0;
52 
58  virtual bool isArray() const = 0;
59 
69  virtual void initializeChildren() = 0;
70 
79  virtual void initialize(const vector<AnyHolder<ALLOC>, ALLOC>& typeArguments) = 0;
80 
90  virtual size_t initializeOffsets(size_t bitPosition) = 0;
91 
101  virtual size_t initializeOffsets() = 0;
102 
114  virtual size_t bitSizeOf(size_t bitPosition) const = 0;
115 
127  virtual size_t bitSizeOf() const = 0;
128 
138  virtual void write(BitStreamWriter& writer) const = 0;
139 
153  virtual ConstPtr getField(StringView name) const = 0;
154  virtual Ptr getField(StringView name) = 0;
170  virtual void setField(StringView name, const AnyHolder<ALLOC>& value) = 0;
171 
184  virtual Ptr createField(StringView name) = 0;
185 
199  virtual ConstPtr getParameter(StringView name) const = 0;
200  virtual Ptr getParameter(StringView name) = 0;
217  virtual ConstPtr callFunction(StringView name) const = 0;
218  virtual Ptr callFunction(StringView name) = 0;
230  virtual StringView getChoice() const = 0;
231 
249  virtual ConstPtr find(StringView path) const = 0;
250  virtual Ptr find(StringView path) = 0;
259  virtual ConstPtr operator[](StringView path) const = 0;
260  virtual Ptr operator[](StringView path) = 0;
272  virtual size_t size() const = 0;
273 
283  virtual void resize(size_t size) = 0;
284 
296  virtual ConstPtr at(size_t index) const = 0;
297  virtual Ptr at(size_t index) = 0;
306  virtual ConstPtr operator[](size_t index) const = 0;
307  virtual Ptr operator[](size_t index) = 0;
318  virtual void setAt(const AnyHolder<ALLOC>& value, size_t index) = 0;
319 
327  virtual void append(const AnyHolder<ALLOC>& value) = 0;
328 
346  virtual AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) const = 0;
347  virtual AnyHolder<ALLOC> getAnyValue(const ALLOC& allocator) = 0;
348  virtual AnyHolder<ALLOC> getAnyValue() const = 0;
358  virtual bool getBool() const = 0;
359 
366  virtual int8_t getInt8() const = 0;
367 
374  virtual int16_t getInt16() const = 0;
375 
382  virtual int32_t getInt32() const = 0;
383 
390  virtual int64_t getInt64() const = 0;
391 
398  virtual uint8_t getUInt8() const = 0;
399 
406  virtual uint16_t getUInt16() const = 0;
407 
414  virtual uint32_t getUInt32() const = 0;
415 
422  virtual uint64_t getUInt64() const = 0;
423 
430  virtual float getFloat() const = 0;
431 
438  virtual double getDouble() const = 0;
439 
446  virtual Span<const uint8_t> getBytes() const = 0;
447 
454  virtual StringView getStringView() const = 0;
455 
462  virtual const BasicBitBuffer<ALLOC>& getBitBuffer() const = 0;
463 
472  virtual int64_t toInt() const = 0;
473 
483  virtual uint64_t toUInt() const = 0;
484 
493  virtual double toDouble() const = 0;
494 
509  virtual string<ALLOC> toString(const ALLOC& allocator) const = 0;
510  virtual string<ALLOC> toString() const = 0;
525  virtual const ParsingInfo& parsingInfo() const = 0;
526 };
527 
530 template <typename ALLOC = std::allocator<uint8_t>>
532 
533 template <typename ALLOC = std::allocator<uint8_t>>
552 template <typename T, typename ALLOC = std::allocator<uint8_t>>
553 IBasicReflectablePtr<ALLOC> enumReflectable(T value, const ALLOC& allocator = ALLOC());
554 
555 } // namespace zserio
556 
557 #endif // ZSERIO_I_REFLECTABLE_H_INC
virtual double getDouble() const =0
virtual Ptr callFunction(StringView name)=0
virtual Span< const uint8_t > getBytes() const =0
virtual string< ALLOC > toString() const =0
virtual void write(BitStreamWriter &writer) const =0
virtual Ptr getParameter(StringView name)=0
virtual size_t bitSizeOf(size_t bitPosition) const =0
virtual StringView getStringView() const =0
virtual void initialize(const vector< AnyHolder< ALLOC >, ALLOC > &typeArguments)=0
virtual ConstPtr getParameter(StringView name) const =0
virtual AnyHolder< ALLOC > getAnyValue(const ALLOC &allocator)=0
virtual int8_t getInt8() const =0
virtual bool isArray() const =0
virtual Ptr find(StringView path)=0
virtual bool getBool() const =0
virtual AnyHolder< ALLOC > getAnyValue() const =0
virtual void resize(size_t size)=0
virtual void setAt(const AnyHolder< ALLOC > &value, size_t index)=0
virtual AnyHolder< ALLOC > getAnyValue(const ALLOC &allocator) const =0
std::shared_ptr< const IBasicReflectable > ConstPtr
Definition: IReflectable.h:39
virtual Ptr getField(StringView name)=0
virtual Ptr operator[](size_t index)=0
virtual int16_t getInt16() const =0
virtual size_t size() const =0
virtual size_t initializeOffsets()=0
virtual const IBasicTypeInfo< ALLOC > & getTypeInfo() const =0
virtual Ptr createField(StringView name)=0
virtual double toDouble() const =0
virtual void setField(StringView name, const AnyHolder< ALLOC > &value)=0
virtual AnyHolder< ALLOC > getAnyValue()=0
virtual ConstPtr operator[](StringView path) const =0
virtual ConstPtr at(size_t index) const =0
virtual const ParsingInfo & parsingInfo() const =0
virtual uint64_t toUInt() const =0
virtual void append(const AnyHolder< ALLOC > &value)=0
virtual uint32_t getUInt32() const =0
virtual float getFloat() const =0
virtual Ptr at(size_t index)=0
virtual Ptr operator[](StringView path)=0
virtual int32_t getInt32() const =0
virtual int64_t getInt64() const =0
virtual ~IBasicReflectable()=default
virtual uint8_t getUInt8() const =0
virtual ConstPtr getField(StringView name) const =0
virtual uint64_t getUInt64() const =0
virtual size_t initializeOffsets(size_t bitPosition)=0
virtual string< ALLOC > toString(const ALLOC &allocator) const =0
virtual ConstPtr find(StringView path) const =0
virtual StringView getChoice() const =0
virtual const BasicBitBuffer< ALLOC > & getBitBuffer() const =0
std::shared_ptr< IBasicReflectable > Ptr
Definition: IReflectable.h:36
virtual uint16_t getUInt16() const =0
virtual void initializeChildren()=0
virtual ConstPtr callFunction(StringView name) const =0
virtual int64_t toInt() const =0
virtual ConstPtr operator[](size_t index) const =0
virtual size_t bitSizeOf() const =0
IBasicReflectablePtr<> IReflectablePtr
Definition: IReflectable.h:540
std::basic_string< char, std::char_traits< char >, RebindAlloc< ALLOC, char > > string
Definition: String.h:17
std::vector< T, RebindAlloc< ALLOC, T > > vector
Definition: Vector.h:17
IBasicReflectablePtr< ALLOC > enumReflectable(T value, const ALLOC &allocator=ALLOC())
IBasicReflectableConstPtr<> IReflectableConstPtr
Definition: IReflectable.h:541
typename IBasicReflectable< ALLOC >::Ptr IBasicReflectablePtr
Definition: IReflectable.h:531
typename IBasicReflectable< ALLOC >::ConstPtr IBasicReflectableConstPtr
Definition: IReflectable.h:534