Growable buffer of big-endian values, capped at MAX_PAYLOAD_SIZE.
More...
#include <protocol/PacketWriter.hpp>
|
|
| PacketWriter () |
| | Creates an empty writer with the full capacity reserved.
|
| |
| bool | writeUInt8 (std::uint8_t value) |
| | Appends one byte.
|
| |
| bool | writeUInt16 (std::uint16_t value) |
| | Appends a 16-bit unsigned integer in big-endian order.
|
| |
| bool | writeUInt32 (std::uint32_t value) |
| | Appends a 32-bit unsigned integer in big-endian order.
|
| |
| bool | writeBytes (const std::uint8_t *data, std::size_t size) |
| | Appends raw bytes.
|
| |
| bool | empty () const |
| | Tells whether nothing has been written yet.
|
| |
|
void | clear () |
| | Discards every written byte.
|
| |
| const std::vector< std::uint8_t > & | getData () const |
| | Returns the written bytes.
|
| |
| std::size_t | getSize () const |
| | Returns the number of written bytes.
|
| |
Growable buffer of big-endian values, capped at MAX_PAYLOAD_SIZE.
◆ writeUInt8()
| bool PacketWriter::writeUInt8 |
( |
std::uint8_t | value | ) |
|
Appends one byte.
- Parameters
-
- Returns
- True on success, false if the buffer is full.
◆ writeUInt16()
| bool PacketWriter::writeUInt16 |
( |
std::uint16_t | value | ) |
|
Appends a 16-bit unsigned integer in big-endian order.
- Parameters
-
- Returns
- True on success, false if the buffer is full.
◆ writeUInt32()
| bool PacketWriter::writeUInt32 |
( |
std::uint32_t | value | ) |
|
Appends a 32-bit unsigned integer in big-endian order.
- Parameters
-
- Returns
- True on success, false if the buffer is full.
◆ writeBytes()
| bool PacketWriter::writeBytes |
( |
const std::uint8_t * | data, |
|
|
std::size_t | size ) |
Appends raw bytes.
- Parameters
-
| data | Bytes to append. |
| size | Number of bytes to append. |
- Returns
- True on success, false if the buffer would overflow.
◆ empty()
| bool PacketWriter::empty |
( |
| ) |
const |
Tells whether nothing has been written yet.
- Returns
- True if the buffer is empty.
◆ getData()
| const std::vector< std::uint8_t > & PacketWriter::getData |
( |
| ) |
const |
Returns the written bytes.
- Returns
- The underlying buffer.
◆ getSize()
| std::size_t PacketWriter::getSize |
( |
| ) |
const |
Returns the number of written bytes.
- Returns
- The buffer size.