| 117 | |
| 118 | template <class Derived, class Container, bool IsMutable = Container::isMutable> |
| 119 | class DynamicStruct |
| 120 | : public DynamicStructBase<Derived, Container, Container::isMutable> { |
| 121 | |
| 122 | public: |
| 123 | typedef DynamicStructBase<Derived, Container> Base; |
| 124 | typedef typename Base::Storage_type Storage_type; |
| 125 | typedef typename Base::Container_type Container_type; |
| 126 | typedef typename Base::RootContainer_type RootContainer_type; |
| 127 | typedef typename Base::ByteStream_type ByteStream_type; |
| 128 | typedef typename Base::Init_type Init_type; |
| 129 | typedef typename ByteStream_type::char_type char_type; |
| 130 | enum { isMutable = Container_type::isMutable }; |
| 131 | |
| 132 | DynamicStruct(Init_type& inInitialization); |
| 133 | |
| 134 | using Base::rootContainer; |
| 135 | RootContainer_type& rootContainer(); |
| 136 | using Base::storage; |
| 137 | Storage_type& storage(); |
| 138 | using Base::byteStream; |
| 139 | ByteStream_type& byteStream(); |
| 140 | |
| 141 | size_t begin() const; |
| 142 | size_t end() const; |
| 143 | const char_type* ptr() const; |
| 144 | char_type* ptr(); |
| 145 | size_t size() const; |
| 146 | |
| 147 | void bindToStream(ByteStream_type& inStream); |
| 148 | |
| 149 | /** |
| 150 | * @brief Bind a DynamicStruct object to the current position in the stream |
| 151 | * |
| 152 | * The following idiom (in-class friend function together with static |
| 153 | * polymorphicsm) is called the "Barton-Nackman trick". Essentially, we only |
| 154 | * make operator>> visible if type Derived is involved. |
| 155 | * |
| 156 | * Subclasses have to implement the bind() function. |
| 157 | */ |
| 158 | friend |
| 159 | ByteStream_type& |
| 160 | operator>>(ByteStream_type& inStream, Derived& inStruct) { |
| 161 | inStruct.bindToStream(inStream); |
| 162 | return inStream; |
| 163 | } |
| 164 | |
| 165 | protected: |
| 166 | size_t mBegin; |
| 167 | size_t mEnd; |
| 168 | }; |
| 169 | |
| 170 | template <class Derived, class Container> |
| 171 | class DynamicStruct<Derived, Container, Mutable> |
nothing calls this directly
no test coverage detected