8 #ifndef ZSERIO_SERIALIZE_UTIL_H_INC
9 #define ZSERIO_SERIALIZE_UTIL_H_INC
11 #include <string_view>
12 #include <type_traits>
52 template <
typename T,
typename ALLOC,
typename... ARGS, std::enable_if_t<is_allocator_v<ALLOC>,
int> = 0>
55 const View<T> view(data, std::forward<ARGS>(arguments)...);
86 template <
typename T,
typename ALLOC,
typename... ARGS, std::enable_if_t<is_allocator_v<ALLOC>,
int> = 0>
89 const View<T> view(data, std::forward<ARGS>(arguments)...);
117 template <
typename T,
typename... ARGS,
typename std::enable_if_t<!
is_first_allocator_v<ARGS...>,
int> = 0>
120 return serialize(data,
typename T::allocator_type(), std::forward<ARGS>(arguments)...);
148 template <
typename T,
typename... ARGS,
typename std::enable_if_t<!
is_first_allocator_v<ARGS...>,
int> = 0>
151 return serializeToBytes(data,
typename T::allocator_type(), std::forward<ARGS>(arguments)...);
174 template <
typename T,
typename ALLOC,
typename... ARGS>
179 return detail::read(reader, data, std::forward<ARGS>(arguments)...);
202 template <
typename T,
typename... ARGS>
207 return detail::read(reader, data, std::forward<ARGS>(arguments)...);
235 template <
typename T,
typename ALLOC>
238 detail::validate(view,
"");
239 const BitSize bitSize = detail::initializeOffsets(view, 0);
242 detail::write(writer, view);
272 template <
typename T,
typename ALLOC>
275 detail::validate(view,
"");
276 const BitSize bitSize = detail::initializeOffsets(view, 0);
279 detail::write(writer, view);
307 template <
typename T>
310 return serialize(view,
typename T::allocator_type());
334 template <
typename T>
364 template <
typename T,
typename ALLOC>
368 size_t bitSize = detail::bitSizeOf(dataView, 0);
372 detail::write(writer, dataView);
400 template <
typename T,
typename ALLOC>
404 size_t bitSize = detail::bitSizeOf(dataView, 0);
408 detail::write(writer, dataView);
434 template <
typename T>
437 return serialize(dataView,
typename T::allocator_type());
461 template <
typename T>
488 template <
typename T,
typename ALLOC,
typename... ARGS>
490 const BasicBitBuffer<ALLOC>& buffer,
const typename T::allocator_type& allocator, ARGS&&... arguments)
495 return DataView<T>(reader, std::move(data), std::forward<ARGS>(arguments)...);
519 template <
typename T,
typename... ARGS>
521 Span<const uint8_t> buffer,
const typename T::allocator_type& allocator, ARGS&&... arguments)
526 return DataView<T>(reader, std::move(data), std::forward<ARGS>(arguments)...);
549 template <
typename T,
typename ALLOC,
typename... ARGS,
553 return deserialize<T>(buffer,
typename T::allocator_type(), std::forward<ARGS>(arguments)...);
574 template <
typename T,
typename... ARGS, std::enable_if_t<!
is_first_allocator_v<ARGS...>,
int> = 0>
577 return deserializeFromBytes<T>(buffer,
typename T::allocator_type(), std::forward<ARGS>(arguments)...);
597 template <
typename T>
621 template <
typename T>
624 const auto bitBuffer =
serialize(dataView);
645 template <
typename T,
typename... ARGS>
648 const View<T> view(data, std::forward<ARGS>(arguments)...);
674 template <
typename T,
typename... ARGS>
678 return deserialize(bitBuffer, data, std::forward<ARGS>(arguments)...);
703 template <
typename T,
typename... ARGS>
707 return deserialize<T>(bitBuffer, std::forward<ARGS>(arguments)...);
View< T > deserializeFromFile(std::string_view fileName, T &data, ARGS &&... arguments)
View< T > deserializeFromBytes(Span< const uint8_t > buffer, T &data, ARGS &&... arguments)
std::vector< T, ALLOC > Vector
void serializeToFile(const View< T > &view, std::string_view fileName)
BasicBitBuffer< ALLOC > serialize(const T &data, const ALLOC &allocator, ARGS &&... arguments)
void writeBufferToFile(const uint8_t *buffer, size_t bitSize, BitsTag, std::string_view fileName)
Vector< uint8_t, ALLOC > serializeToBytes(const T &data, const ALLOC &allocator, ARGS &&... arguments)
View< T > deserialize(const BasicBitBuffer< ALLOC > &buffer, T &data, ARGS &&... arguments)
BitBuffer readBufferFromFile(std::string_view fileName)
constexpr bool is_first_allocator_v