5#include "../macros.hpp"
24 data =
new std::byte[nrBytes];
25 data_end = data + nrBytes;
35 packet(packet
const &rhs)
noexcept =
delete;
36 packet operator=(packet
const &rhs)
noexcept =
delete;
38 packet(packet &&rhs) noexcept : data(rhs.data), data_end(rhs.data_end), first(rhs.first), last(rhs.last)
43 [[nodiscard]] std::byte *
begin() noexcept
48 [[nodiscard]] std::byte *
end() noexcept
55 [[nodiscard]] ssize_t
readSize() const noexcept
64 return data_end - last;
69 [[nodiscard]]
bool pushed() const noexcept
84 void write(ssize_t nrBytes)
noexcept
87 hi_assert(last <= data_end);
93 void read(ssize_t nrBytes)
noexcept
96 hi_assert(first <= last);
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
A network message or stream buffer.
Definition packet.hpp:12
packet(ssize_t nrBytes) noexcept
Allocate an empty packet of a certain size.
Definition packet.hpp:22
void read(ssize_t nrBytes) noexcept
Consume a read.
Definition packet.hpp:93
ssize_t readSize() const noexcept
How many bytes can be read from this buffer.
Definition packet.hpp:55
void write(ssize_t nrBytes) noexcept
Commit a write.
Definition packet.hpp:84
bool pushed() const noexcept
Should this packet be pushed onto the network.
Definition packet.hpp:69
void push() noexcept
Mark this packet to be pushed to the network.
Definition packet.hpp:76
ssize_t writeSize() const noexcept
How many bytes can still be written to this buffer.
Definition packet.hpp:62