99 void append(const
void* data, std::
size_t sizeInBytes);
203 explicit operator
bool() const;
350 Packet& operator<<(const std::
string& data);
360 Packet& operator<<(const std::wstring& data);
389 virtual const
void*
onSend(std::
size_t& size);
408 virtual
void onReceive(const
void* data, std::
size_t size);
421 bool checkSize(std::
size_t size);
426 std::vector<std::
byte> m_data;
427 std::
size_t m_readPos{};
428 std::size_t m_sendPos{};
429 bool m_isValid{
true};
Packet & operator=(const Packet &)=default
Copy assignment.
std::size_t getDataSize() const
Get the size of the data contained in the packet.
void clear()
Clear the packet.
Packet(Packet &&) noexcept=default
Move constructor.
std::size_t getReadPosition() const
Get the current reading position in the packet.
bool endOfPacket() const
Tell if the reading position has reached the end of the packet.
Packet()=default
Default constructor.
void append(const void *data, std::size_t sizeInBytes)
Append data to the end of the packet.
const void * getData() const
Get a pointer to the data contained in the packet.
virtual ~Packet()=default
Virtual destructor.
virtual void onReceive(const void *data, std::size_t size)
Called after the packet is received over the network.
Packet(const Packet &)=default
Copy constructor.
virtual const void * onSend(std::size_t &size)
Called before the packet is sent over the network.
Utility string class that automatically handles conversions between types and encodings.