25 #ifndef CPP3DS_PACKET_HPP
26 #define CPP3DS_PACKET_HPP
31 #include <cpp3ds/Config.hpp>
50 typedef bool (
Packet::*BoolType)(std::size_t);
77 void append(
const void* data, std::size_t sizeInBytes);
171 operator BoolType()
const;
238 virtual const void*
onSend(std::size_t& size);
257 virtual void onReceive(
const void* data, std::size_t size);
265 bool operator ==(
const Packet& right)
const;
266 bool operator !=(
const Packet& right)
const;
278 bool checkSize(std::size_t size);
283 std::vector<char> m_data;
284 std::size_t m_readPos;
285 std::size_t m_sendPos;
292 #endif // CPP3DS_PACKET_HPP
Packet & operator<<(bool data)
Overloads of operator << to write data into the packet.
Specialized socket using the UDP protocol.
void clear()
Clear the packet.
virtual ~Packet()
Virtual destructor.
Packet()
Default constructor.
Utility string class that automatically handles conversions between types and encodings.
Utility class to build blocks of data to transfer over the network.
std::size_t getDataSize() const
Get the size of the data contained in the packet.
virtual const void * onSend(std::size_t &size)
Called before the packet is sent over the network.
Packet & operator>>(bool &data)
Overloads of operator >> to read data from the packet.
const void * getData() const
Get a pointer to the data contained in the packet.
bool endOfPacket() const
Tell if the reading position has reached the end of the packet.
Specialized socket using the TCP protocol.
void append(const void *data, std::size_t sizeInBytes)
Append data to the end of the packet.
virtual void onReceive(const void *data, std::size_t size)
Called after the packet is received over the network.