A wrapper around std::vector with some facilities for writing different types to it in different byte orders.
More...
#include <byte_buffer.hpp>
|
| | ByteBuffer ()=default |
| | ByteBuffer (const size_t size) |
| | ByteBuffer (const ByteBuffer &)=default |
| ByteBuffer & | operator= (const ByteBuffer &)=default |
| | ByteBuffer (ByteBuffer &&) noexcept=default |
| ByteBuffer & | operator= (ByteBuffer &&) noexcept=default |
| const uint8_t * | data () const |
| size_t | size () const |
| void | clear () |
| | Clears the data.
|
| void | write (const uint8_t *data, const size_t size) |
| | Appends given data to the buffer.
|
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> |
| void | write_ne (const Type value) |
| | Writes a value to the stream in native byte order (not to be confused with network-endian).
|
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> |
| void | write_be (const Type value) |
| | Writes a big-endian value to the stream.
|
| template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true> |
| void | write_le (const Type value) |
| | Writes a little-endian value to the stream.
|
A wrapper around std::vector with some facilities for writing different types to it in different byte orders.
Definition at line 36 of file byte_buffer.hpp.
◆ ByteBuffer() [1/4]
| rav::ByteBuffer::ByteBuffer |
( |
| ) |
|
|
default |
◆ ByteBuffer() [2/4]
| rav::ByteBuffer::ByteBuffer |
( |
const size_t | size | ) |
|
|
inlineexplicit |
◆ ByteBuffer() [3/4]
| rav::ByteBuffer::ByteBuffer |
( |
const ByteBuffer & | | ) |
|
|
default |
◆ ByteBuffer() [4/4]
| rav::ByteBuffer::ByteBuffer |
( |
ByteBuffer && | | ) |
|
|
defaultnoexcept |
◆ clear()
| void rav::ByteBuffer::clear |
( |
| ) |
|
|
inline |
◆ data()
| const uint8_t * rav::ByteBuffer::data |
( |
| ) |
const |
|
inlinenodiscard |
- Returns
- A pointer to the data in the buffer.
Definition at line 51 of file byte_buffer.hpp.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ size()
| size_t rav::ByteBuffer::size |
( |
| ) |
const |
|
inlinenodiscard |
- Returns
- The current size of the buffer.
Definition at line 58 of file byte_buffer.hpp.
◆ write()
| void rav::ByteBuffer::write |
( |
const uint8_t * | data, |
|
|
const size_t | size ) |
|
inline |
Appends given data to the buffer.
- Parameters
-
| data | The data to append. |
| size | The size of the data. |
Definition at line 74 of file byte_buffer.hpp.
◆ write_be()
template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true>
| void rav::ByteBuffer::write_be |
( |
const Type | value | ) |
|
|
inline |
Writes a big-endian value to the stream.
- Template Parameters
-
| Type | The type of the value to write. |
- Parameters
-
- Returns
- An expected indicating success or failure.
Definition at line 96 of file byte_buffer.hpp.
◆ write_le()
template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true>
| void rav::ByteBuffer::write_le |
( |
const Type | value | ) |
|
|
inline |
Writes a little-endian value to the stream.
- Template Parameters
-
| Type | The type of the value to write. |
- Parameters
-
- Returns
- An expected indicating success or failure.
Definition at line 107 of file byte_buffer.hpp.
◆ write_ne()
template<typename Type, std::enable_if_t< std::is_trivially_copyable_v< Type >, bool > = true>
| void rav::ByteBuffer::write_ne |
( |
const Type | value | ) |
|
|
inline |
Writes a value to the stream in native byte order (not to be confused with network-endian).
- Template Parameters
-
| Type | The type of the value to write. |
- Parameters
-
- Returns
- An expected indicating success or failure.
Definition at line 85 of file byte_buffer.hpp.
The documentation for this class was generated from the following file: