Zserio C++17 runtime library  0.5.0
Built for Zserio 2.17.0
DataView.h
Go to the documentation of this file.
1 #ifndef ZSERIO_DATA_VIEW_H_INC
2 #define ZSERIO_DATA_VIEW_H_INC
3 
5 #include <zserio/View.h>
6 
7 namespace zserio
8 {
9 
14 template <class T>
15 class DataView : public View<T>
16 {
17 public:
25  template <typename... ARGS>
26  DataView(BitStreamReader& reader, T&& data, ARGS&&... arguments) :
27  View<T>(m_ownData, arguments...),
28  m_ownData(std::move(data))
29  {
30  detail::read(reader, m_ownData, std::forward<ARGS>(arguments)...);
31  }
32 
39  template <typename... ARGS>
40  explicit DataView(const T& data, ARGS&&... arguments) :
41  View<T>(m_ownData, std::forward<ARGS>(arguments)...),
42  m_ownData(data)
43  {
44  detail::validate(*this);
45  (void)detail::initializeOffsets(*this, 0);
46  }
47 
54  template <typename... ARGS>
55  explicit DataView(T&& data, ARGS&&... arguments) :
56  View<T>(m_ownData, std::forward<ARGS>(arguments)...),
57  m_ownData(std::move(data))
58  {
59  detail::validate(*this);
60  (void)detail::initializeOffsets(*this, 0);
61  }
62 
68  DataView(const DataView& other) :
69  View<T>(m_ownData, other),
70  m_ownData(other.m_ownData)
71  {}
72 
78  DataView(DataView&& other) :
79  View<T>(m_ownData, other),
80  m_ownData(std::move(other.m_ownData))
81  {}
82 
87  DataView& operator=(const DataView& other) = delete;
88  DataView& operator=(DataView&& other) = delete;
91  ~DataView() = default;
92 
93 private:
94  T m_ownData;
95 };
96 
97 // template argument deduction guide for DataView constructor
98 template <typename T, typename... ARGS>
99 DataView(T, ARGS&&...) -> DataView<T>;
100 
101 } // namespace zserio
102 
103 #endif // ZSERIO_DATA_VIEW_H_INC
DataView & operator=(DataView &&other)=delete
~DataView()=default
DataView(const T &data, ARGS &&... arguments)
Definition: DataView.h:40
DataView(T &&data, ARGS &&... arguments)
Definition: DataView.h:55
DataView(const DataView &other)
Definition: DataView.h:68
DataView(BitStreamReader &reader, T &&data, ARGS &&... arguments)
Definition: DataView.h:26
DataView & operator=(const DataView &other)=delete
DataView(DataView &&other)
Definition: DataView.h:78
Definition: BitBuffer.h:602
DataView(T, ARGS &&...) -> DataView< T >