|
template<typename... Ts, typename = std::enable_if_t<std::is_constructible_v<Policy, Ts...>>> |
| bit_writer (Ts &&... args) noexcept(std::is_nothrow_constructible_v< Policy, Ts... >) |
| Construct a writer with the parameters passed to the underlying policy. More...
|
|
| bit_writer (const bit_writer &)=delete |
|
| bit_writer (bit_writer &&other) noexcept |
|
bit_writer & | operator= (const bit_writer &)=delete |
|
bit_writer & | operator= (bit_writer &&rhs) noexcept |
|
uint8_t * | get_buffer () const noexcept |
| Returns the buffer that this writer is currently serializing into. More...
|
|
uint32_t | get_num_bits_serialized () const noexcept |
| Returns the number of bits which have been written to the buffer. More...
|
|
uint32_t | get_num_bytes_serialized () const noexcept |
| Returns the number of bytes which have been written to the buffer. More...
|
|
bool | can_serialize_bits (uint32_t num_bits) const noexcept |
| Returns whether the num_bits can fit in the buffer. More...
|
|
uint32_t | get_remaining_bits () const noexcept |
| Returns the number of bits which have not been written yet. More...
|
|
uint32_t | get_total_bits () const noexcept |
| Returns the size of the buffer, in bits. More...
|
|
uint32_t | flush () noexcept |
| Flushes any remaining bits into the buffer. Use this when you no longer intend to write anything to the buffer. More...
|
|
bool | prepend_checksum () noexcept |
| Instructs the writer that you intend to use serialize_checksum() later on, and to reserve the first 32 bits. More...
|
|
uint32_t | serialize_checksum (uint32_t protocol_version) noexcept |
| Writes a checksum of the protocol_version and the rest of the buffer as the first 32 bits. More...
|
|
bool | pad_to_size (uint32_t num_bytes) noexcept |
| Pads the buffer up to the given number of bytes with zeros. More...
|
|
bool | pad (uint32_t num_bytes) noexcept |
| Pads the buffer up with the given number of bytes. More...
|
|
bool | align () noexcept |
| Pads the buffer with up to 8 zeros, so that the next write is byte-aligned. More...
|
|
bool | serialize_bits (uint32_t value, uint32_t num_bits) noexcept |
| Writes the first num_bits bits of value into the buffer. More...
|
|
bool | serialize_bytes (const uint8_t *bytes, uint32_t num_bits) noexcept |
| Writes the first num_bits bits of the given byte array, 32 bits at a time. More...
|
|
bool | serialize_into (bit_writer &writer) const noexcept |
| Writes the contents of the buffer into the given writer . Essentially copies the entire buffer without modifying it. More...
|
|
template<typename Trait , typename... Args, typename = utility::has_serialize_t<Trait, bit_writer, Args...>> |
bool | serialize (Args &&... args) noexcept(utility::is_serialize_noexcept_v< Trait, bit_writer, Args... >) |
| Writes to the buffer, using the given Trait . More...
|
|
template<typename... Args, typename Trait , typename = utility::has_deduce_serialize_t<Trait, bit_writer, Args...>> |
bool | serialize (Trait &&arg, Args &&... args) noexcept(utility::is_deduce_serialize_noexcept_v< Trait, bit_writer, Args... >) |
| Writes to the buffer, by trying to deduce the trait. More...
|
|
template<typename Policy>
class bitstream::bit_writer< Policy >
A stream for writing objects tightly into a buffer.
- Template Parameters
-
Policy | The underlying representation of the buffer |
template<typename Policy >
template<typename Trait , typename... Args, typename = utility::has_serialize_t<Trait, bit_writer, Args...>>
Writes to the buffer, using the given Trait
.
- Note
- The Trait type in this function must always be explicitly declared
- Template Parameters
-
Trait | A template specialization of serialize_trait<> |
...Args | The types of the arguments to pass to the serialize function |
- Parameters
-
...args | The arguments to pass to the serialize function |
- Returns
- Whether successful or not
template<typename Policy >
template<typename... Args, typename Trait , typename = utility::has_deduce_serialize_t<Trait, bit_writer, Args...>>
Writes to the buffer, by trying to deduce the trait.
- Note
- The Trait type in this function is always implicit and will be deduced from the first argument if possible. If the trait cannot be deduced it will not compile.
- Template Parameters
-
Trait | The type of the first argument, which will be used to deduce the trait specialization |
...Args | The types of the arguments to pass to the serialize function |
- Parameters
-
arg | The first argument to pass to the serialize function |
...args | The rest of the arguments to pass to the serialize function |
- Returns
- Whether successful or not