10 #ifndef ZSERIO_SERIALIZE_UTIL_H_INC
11 #define ZSERIO_SERIALIZE_UTIL_H_INC
27 void initializeChildrenImpl(std::true_type, T&
object)
29 object.initializeChildren();
33 void initializeChildrenImpl(std::false_type, T&)
37 void initializeChildren(T&
object)
39 initializeChildrenImpl(has_initialize_children<T>(),
object);
42 template <
typename T,
typename... ARGS>
43 void initializeImpl(std::true_type, T&
object, ARGS&&... arguments)
45 object.initialize(std::forward<ARGS>(arguments)...);
49 void initializeImpl(std::false_type, T&
object)
51 initializeChildren(
object);
54 template <
typename T,
typename... ARGS>
55 void initialize(T&
object, ARGS&&... arguments)
57 initializeImpl(has_initialize<T>(),
object, std::forward<ARGS>(arguments)...);
60 template <
typename T,
typename =
void>
61 struct allocator_chooser
63 using type = std::allocator<uint8_t>;
67 struct allocator_chooser<T, detail::void_t<typename T::allocator_type>>
69 using type =
typename T::allocator_type;
73 template <
typename T,
typename ALLOC,
typename... ARGS>
74 BasicBitBuffer<ALLOC>
serialize(T&
object,
const ALLOC& allocator, ARGS&&... arguments)
76 detail::initialize(
object, std::forward<ARGS>(arguments)...);
78 BitStreamWriter writer(bitBuffer);
110 template <
typename T,
typename ALLOC,
typename... ARGS,
111 typename std::enable_if<!std::is_enum<T>::value && is_allocator<ALLOC>::value,
int>::type = 0>
138 template <typename T, typename ALLOC = typename detail::allocator_chooser<T>::type,
typename... ARGS,
139 typename std::enable_if<!std::is_enum<T>::value &&
140 !is_first_allocator<typename std::decay<ARGS>::type...>::value,
165 template <
typename T,
typename ALLOC = std::allocator<u
int8_t>,
166 typename std::enable_if<std::is_enum<T>::value,
int>::type = 0>
194 template <
typename T,
typename ALLOC,
typename... ARGS>
195 typename std::enable_if<!std::is_enum<T>::value, T>::type
deserialize(
199 return T(reader, std::forward<ARGS>(arguments)...);
220 template <
typename T,
typename ALLOC>
224 return zserio::read<T>(reader);
252 template <
typename T,
typename ALLOC,
typename... ARGS,
253 typename std::enable_if<!std::is_enum<T>::value && is_allocator<ALLOC>::value,
int>::type = 0>
286 template <typename T, typename ALLOC = typename detail::allocator_chooser<T>::type,
typename... ARGS,
287 typename std::enable_if<!std::is_enum<T>::value &&
288 !is_first_allocator<typename std::decay<ARGS>::type...>::value,
316 template <
typename T,
typename ALLOC = std::allocator<u
int8_t>,
317 typename std::enable_if<std::is_enum<T>::value,
int>::type = 0>
348 template <
typename T,
typename... ARGS>
353 return T(reader, std::forward<ARGS>(arguments)...);
374 template <
typename T>
378 return zserio::read<T>(reader);
397 template <
typename T,
typename... ARGS>
400 const auto bitBuffer =
serialize(
object, std::forward<ARGS>(arguments)...);
426 template <
typename T,
typename... ARGS>
430 return deserialize<T>(bitBuffer, std::forward<ARGS>(arguments)...);
const vector< uint8_t, ALLOC > & getBytes() const
zserio::string< PropagatingPolymorphicAllocator< char > > string
std::enable_if<!std::is_enum< T >::value, T >::type deserializeFromBytes(Span< const uint8_t > buffer, ARGS &&... arguments)
vector< uint8_t, ALLOC > serializeToBytes(T &object, const ALLOC &allocator, ARGS &&... arguments)
void write(BitStreamWriter &out, T value)
void writeBufferToFile(const uint8_t *buffer, size_t bitSize, BitsTag, const std::string &fileName)
std::enable_if<!std::is_enum< T >::value, T >::type deserialize(const BasicBitBuffer< ALLOC > &bitBuffer, ARGS &&... arguments)
BitBuffer readBufferFromFile(const std::string &fileName)
void serializeToFile(T &object, const std::string &fileName, ARGS &&... arguments)
std::vector< T, RebindAlloc< ALLOC, T > > vector
BasicBitBuffer< ALLOC > serialize(T &object, const ALLOC &allocator, ARGS &&... arguments)
size_t initializeOffsets(size_t bitPosition, T value)
T deserializeFromFile(const std::string &fileName, ARGS &&... arguments)
BasicBitBuffer< ALLOC > serialize(T enumValue, const ALLOC &allocator=ALLOC())
size_t bitSizeOf(T value)