Binary writer that is useful for binary serialization.
More...
Definition at line 20 of file write_stream.hpp.
#include <write_stream.hpp>
|
| WriteStream (size_t size) |
|
| WriteStream (WriteStream &&)=default |
|
WriteStream & | operator= (WriteStream &&)=default |
|
void | write (const void *buf, size_t size) |
|
template<typename T , typename = typename std::enable_if<sizeof(typename T::value_type) == 1>::type> |
void | write (const T &t) |
|
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type> |
void | writeBE (T num, size_t bytes=sizeof(T)) |
|
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type> |
void | writeLE (T num) |
|
uint32_t | getVersion () const noexcept |
|
void | setVersion (uint32_t version) noexcept |
|
const storage_t & | data () const noexcept |
|
std::string | hex () const noexcept |
|
◆ storage_t
using altintegration::WriteStream::storage_t = std::vector<uint8_t> |
◆ write()
template<typename T , typename = typename std::enable_if<sizeof(typename T::value_type) == 1>::type>
void altintegration::WriteStream::write |
( |
const T & |
t | ) |
|
|
inline |
◆ writeBE()
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
void altintegration::WriteStream::writeBE |
( |
T |
num, |
|
|
size_t |
bytes = sizeof(T) |
|
) |
| |
|
inline |
Definition at line 44 of file write_stream.hpp.
44 {
45 VBK_ASSERT(bytes <= sizeof(T));
46
47 for (size_t i = 0, shift = (sizeof(T) - 1) * 8; i < sizeof(T);
48 i++, shift -= 8) {
49
50 if (i < (sizeof(T) - bytes)) {
51 continue;
52 }
53 m_data.push_back((num >> shift) & 0xffu);
54 }
55 }
◆ writeLE()
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value>::type>
void altintegration::WriteStream::writeLE |
( |
T |
num | ) |
|
|
inline |
Definition at line 60 of file write_stream.hpp.
60 {
61 for (size_t i = 0, shift = 0; i < sizeof(T); i++, shift += 8) {
62 m_data.push_back((num >> shift) & 0xffu);
63 }
64 }
The documentation for this class was generated from the following file: