7#include "../utility/utility.hpp"
8#include "../macros.hpp"
11hi_export_module(hikogui.net.packet);
13hi_export
namespace hi::inline
v1 {
29 data =
new std::byte[nrBytes];
30 data_end = data + nrBytes;
40 packet(packet
const &rhs)
noexcept =
delete;
41 packet operator=(packet
const &rhs)
noexcept =
delete;
43 packet(packet &&rhs) noexcept : data(rhs.data), data_end(rhs.data_end), first(rhs.first), last(rhs.last)
48 [[nodiscard]] std::byte *
begin() noexcept
53 [[nodiscard]] std::byte *
end() noexcept
60 [[nodiscard]] ptrdiff_t
readSize() const noexcept
69 return data_end - last;
74 [[nodiscard]]
bool pushed() const noexcept
89 void write(ptrdiff_t nrBytes)
noexcept
92 hi_assert(last <= data_end);
98 void read(ptrdiff_t nrBytes)
noexcept
101 hi_assert(first <= last);
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
A network message or stream buffer.
Definition packet.hpp:17
packet(ptrdiff_t nrBytes) noexcept
Allocate an empty packet of a certain size.
Definition packet.hpp:27
ptrdiff_t writeSize() const noexcept
How many bytes can still be written to this buffer.
Definition packet.hpp:67
ptrdiff_t readSize() const noexcept
How many bytes can be read from this buffer.
Definition packet.hpp:60
bool pushed() const noexcept
Should this packet be pushed onto the network.
Definition packet.hpp:74
void push() noexcept
Mark this packet to be pushed to the network.
Definition packet.hpp:81
void write(ptrdiff_t nrBytes) noexcept
Commit a write.
Definition packet.hpp:89
void read(ptrdiff_t nrBytes) noexcept
Consume a read.
Definition packet.hpp:98