6#ifndef ALT_INTEGRATION_VERIBLOCK_WRITE_STREAM_HPP
7#define ALT_INTEGRATION_VERIBLOCK_WRITE_STREAM_HPP
24 using storage_t = std::vector<uint8_t>;
32 void write(
const void *buf,
size_t size);
35 typename =
typename std::enable_if<
sizeof(
typename T::value_type) ==
37 void write(
const T &t) {
38 write(t.data(), t.size());
43 typename =
typename std::enable_if<std::is_integral<T>::value>::type>
44 void writeBE(T num,
size_t bytes =
sizeof(T)) {
45 VBK_ASSERT(bytes <=
sizeof(T));
47 for (
size_t i = 0, shift = (
sizeof(T) - 1) * 8; i <
sizeof(T);
50 if (i < (
sizeof(T) - bytes)) {
53 m_data.push_back((num >> shift) & 0xffu);
59 typename =
typename std::enable_if<std::is_integral<T>::value>::type>
61 for (
size_t i = 0, shift = 0; i <
sizeof(T); i++, shift += 8) {
62 m_data.push_back((num >> shift) & 0xffu);
66 uint32_t getVersion()
const noexcept;
68 void setVersion(uint32_t version)
noexcept;
70 const storage_t &data()
const noexcept;
72 std::string hex()
const noexcept;
80 uint32_t m_version{0};
Binary writer that is useful for binary serialization.