MCPcopy Create free account
hub / github.com/bgrimstad/splinter / deserialize

Method deserialize

include/serializer.h:167–183  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165
166template <class T>
167void Serializer::deserialize(T &obj)
168{
169 // This should really be used to avoid simply copying complex objects that are not trivially copyable
170 // std::is_trivially_copyable is shipped with GCC 5
171// static_assert(std::is_trivially_copyable<T>::value, "Missing Serializer::deserialize overload for T = "/* __PRETTY_FUNCTION__*/);
172
173 if (read + sizeof(T) > stream.cend()) {
174 throw Exception("Serializer::deserialize: Stream is missing bytes!");
175 }
176
177 auto objPtr = reinterpret_cast<uint8_t *>(&obj);
178
179 // Copy the data into val
180 std::copy(read, read + sizeof(T), objPtr);
181
182 read += sizeof(T);
183}
184
185template <class T>
186size_t Serializer::get_size(const T &obj)

Callers

nothing calls this directly

Calls 2

ExceptionClass · 0.85
cendMethod · 0.80

Tested by

no test coverage detected