Zserio C++17 runtime library 1.3.0
Built for Zserio 2.20.0
Loading...
Searching...
No Matches
IReflectableData.h
Go to the documentation of this file.
1#ifndef ZSERIO_I_REFLECTABLE_DATA_H_INC
2#define ZSERIO_I_REFLECTABLE_DATA_H_INC
3
4#include <memory>
5#include <string_view>
6
8
9namespace zserio
10{
11
18template <typename ALLOC = std::allocator<uint8_t>>
19class IBasicReflectableData : public IIntrospectableData<IBasicReflectableData<ALLOC>, ALLOC>
20{
21public:
23 using Ptr = std::shared_ptr<IBasicReflectableData>;
24
27
33
37 ~IBasicReflectableData() override = default;
38
51 virtual Ptr getField(std::string_view name) = 0;
52
66 virtual void setField(std::string_view name, const BasicAny<ALLOC>& value) = 0;
67
80 virtual Ptr createField(std::string_view name) = 0;
81
91 virtual void resize(size_t size) = 0;
92
103 virtual Ptr at(size_t index) = 0;
104
110 virtual Ptr operator[](size_t index) = 0;
111
120 virtual void setAt(const BasicAny<ALLOC>& value, size_t index) = 0;
121
129 virtual void append(const BasicAny<ALLOC>& value) = 0;
130
169 virtual Ptr find(std::string_view path) = 0;
170
176 virtual Ptr operator[](std::string_view path) = 0;
177};
178
181template <typename ALLOC = std::allocator<uint8_t>>
183
184template <typename ALLOC = std::allocator<uint8_t>>
195namespace detail
196{
197
198template <typename T, typename ALLOC>
199struct Reflectable;
200
201} // namespace detail
202
212template <typename T, typename ALLOC = typename T::allocator_type,
213 std::enable_if_t<is_complete_v<View<T>> && has_allocator_v<std::decay_t<T>>, int> = 0>
215{
216 return detail::Reflectable<T, ALLOC>::create(value, allocator);
217}
218
219template <typename T, typename ALLOC = typename T::allocator_type,
220 std::enable_if_t<is_complete_v<View<T>> && has_allocator_v<std::decay_t<T>>, int> = 0>
222{
223 return detail::Reflectable<T, ALLOC>::create(value, allocator);
224}
225
226template <typename T, typename ALLOC = std::allocator<uint8_t>,
227 std::enable_if_t<(std::is_enum_v<T> || is_bitmask_v<T>) && !has_allocator_v<std::decay_t<T>>, int> = 0>
229{
230 return detail::Reflectable<T, ALLOC>::create(value, allocator);
231}
234} // namespace zserio
235
236#endif // ZSERIO_I_REFLECTABLE_DATA_H_INC
typename IIntrospectableData< IBasicReflectableData< ALLOC >, ALLOC >::ConstPtr ConstPtr
~IBasicReflectableData() override=default
virtual Ptr createField(std::string_view name)=0
virtual Ptr find(std::string_view path)=0
virtual void append(const BasicAny< ALLOC > &value)=0
virtual Ptr at(size_t index)=0
virtual BasicAny< ALLOC > getAnyValue()=0
virtual BasicAny< ALLOC > getAnyValue(const ALLOC &allocator)=0
virtual void setAt(const BasicAny< ALLOC > &value, size_t index)=0
virtual Ptr operator[](std::string_view path)=0
virtual void resize(size_t size)=0
virtual Ptr operator[](size_t index)=0
std::shared_ptr< IBasicReflectableData > Ptr
virtual void setField(std::string_view name, const BasicAny< ALLOC > &value)=0
virtual Ptr getField(std::string_view name)=0
virtual size_t size() const =0
typename IBasicReflectableData< ALLOC >::ConstPtr IBasicReflectableDataConstPtr
typename IBasicReflectableData< ALLOC >::Ptr IBasicReflectableDataPtr
IBasicReflectableDataConstPtr< ALLOC > reflectable(const T &value, const ALLOC &allocator=ALLOC())