10 #ifndef ZSERIO_SERIALIZE_UTIL_H_INC
11 #define ZSERIO_SERIALIZE_UTIL_H_INC
26 void initializeChildrenImpl(std::true_type, T&
object)
28 object.initializeChildren();
32 void initializeChildrenImpl(std::false_type, T&)
36 void initializeChildren(T&
object)
38 initializeChildrenImpl(has_initialize_children<T>(),
object);
41 template <
typename T,
typename... ARGS>
42 void initializeImpl(std::true_type, T&
object, ARGS&&... arguments)
44 object.initialize(std::forward<ARGS>(arguments)...);
48 void initializeImpl(std::false_type, T&
object)
50 initializeChildren(
object);
53 template <
typename T,
typename... ARGS>
54 void initialize(T&
object, ARGS&&... arguments)
56 initializeImpl(has_initialize<T>(),
object, std::forward<ARGS>(arguments)...);
59 template <
typename T,
typename =
void>
60 struct allocator_chooser
62 using type = std::allocator<uint8_t>;
66 struct allocator_chooser<T, detail::void_t<typename T::allocator_type>>
68 using type =
typename T::allocator_type;
72 template <
typename T,
typename ALLOC,
typename... ARGS>
73 BasicBitBuffer<ALLOC>
serialize(T&
object,
const ALLOC& allocator, ARGS&&... arguments)
75 detail::initialize(
object, std::forward<ARGS>(arguments)...);
77 BitStreamWriter writer(bitBuffer);
109 template <
typename T,
typename ALLOC,
typename... ARGS,
110 typename std::enable_if<!std::is_enum<T>::value && is_allocator<ALLOC>::value,
int>::type = 0>
137 template <typename T, typename ALLOC = typename detail::allocator_chooser<T>::type,
typename... ARGS,
138 typename std::enable_if<!std::is_enum<T>::value &&
139 !is_first_allocator<typename std::decay<ARGS>::type...>::value,
164 template <
typename T,
typename ALLOC = std::allocator<u
int8_t>,
165 typename std::enable_if<std::is_enum<T>::value,
int>::type = 0>
193 template <
typename T,
typename ALLOC,
typename... ARGS>
194 typename std::enable_if<!std::is_enum<T>::value, T>::type
deserialize(
198 return T(reader, std::forward<ARGS>(arguments)...);
219 template <
typename T,
typename ALLOC>
223 return zserio::read<T>(reader);
251 template <
typename T,
typename ALLOC,
typename... ARGS,
252 typename std::enable_if<!std::is_enum<T>::value && is_allocator<ALLOC>::value,
int>::type = 0>
285 template <typename T, typename ALLOC = typename detail::allocator_chooser<T>::type,
typename... ARGS,
286 typename std::enable_if<!std::is_enum<T>::value &&
287 !is_first_allocator<typename std::decay<ARGS>::type...>::value,
315 template <
typename T,
typename ALLOC = std::allocator<u
int8_t>,
316 typename std::enable_if<std::is_enum<T>::value,
int>::type = 0>
347 template <
typename T,
typename... ARGS>
352 return T(reader, std::forward<ARGS>(arguments)...);
373 template <
typename T>
377 return zserio::read<T>(reader);
396 template <
typename T,
typename... ARGS>
399 const auto bitBuffer =
serialize(
object, std::forward<ARGS>(arguments)...);
425 template <
typename T,
typename... ARGS>
429 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)