sf::Packet Class Reference

Packet wraps data to send / to receive through the network. More...

#include <Packet.hpp>

Public Member Functions

 Packet ()
 Default constructor.
virtual ~Packet ()
 Virtual destructor.
void Append (const void *Data, std::size_t SizeInBytes)
 Append data to the end of the packet.
void Clear ()
 Clear the packet data.
const char * GetData () const
 Get a pointer to the data contained in the packet Warning : the returned pointer may be invalid after you append data to the packet.
std::size_t GetDataSize () const
 Get the size of the data contained in the packet.
bool EndOfPacket () const
 Tell if the reading position has reached the end of the packet.
 operator bool () const
 Return the validity of packet.
Packetoperator>> (bool &Data)
 Operator >> overloads to extract data from the packet.
Packetoperator>> (Int8 &Data)
Packetoperator>> (Uint8 &Data)
Packetoperator>> (Int16 &Data)
Packetoperator>> (Uint16 &Data)
Packetoperator>> (Int32 &Data)
Packetoperator>> (Uint32 &Data)
Packetoperator>> (float &Data)
Packetoperator>> (double &Data)
Packetoperator>> (char *Data)
Packetoperator>> (std::string &Data)
Packetoperator>> (wchar_t *Data)
Packetoperator>> (std::wstring &Data)
Packetoperator<< (bool Data)
 Operator << overloads to put data into the packet.
Packetoperator<< (Int8 Data)
Packetoperator<< (Uint8 Data)
Packetoperator<< (Int16 Data)
Packetoperator<< (Uint16 Data)
Packetoperator<< (Int32 Data)
Packetoperator<< (Uint32 Data)
Packetoperator<< (float Data)
Packetoperator<< (double Data)
Packetoperator<< (const char *Data)
Packetoperator<< (const std::string &Data)
Packetoperator<< (const wchar_t *Data)
Packetoperator<< (const std::wstring &Data)

Friends

class SocketTCP
class SocketUDP

Detailed Description

Packet wraps data to send / to receive through the network.

Definition at line 41 of file Packet.hpp.

Constructor & Destructor Documentation

◆ Packet()

sf::Packet::Packet ( )

Default constructor.

Definition at line 38 of file Packet.cpp.

◆ ~Packet()

sf::Packet::~Packet ( )
virtual

Virtual destructor.

Definition at line 49 of file Packet.cpp.

Member Function Documentation

◆ Append()

void sf::Packet::Append ( const void * Data,
std::size_t SizeInBytes )

Append data to the end of the packet.

Parameters
Data: Pointer to the bytes to append
SizeInBytes: Number of bytes to append

Definition at line 58 of file Packet.cpp.

◆ Clear()

void sf::Packet::Clear ( )

Clear the packet data.

Definition at line 72 of file Packet.cpp.

◆ EndOfPacket()

bool sf::Packet::EndOfPacket ( ) const

Tell if the reading position has reached the end of the packet.

Returns
True if all data have been read into the packet

Definition at line 103 of file Packet.cpp.

◆ GetData()

const char * sf::Packet::GetData ( ) const

Get a pointer to the data contained in the packet Warning : the returned pointer may be invalid after you append data to the packet.

Returns
Pointer to the data

Definition at line 85 of file Packet.cpp.

◆ GetDataSize()

std::size_t sf::Packet::GetDataSize ( ) const

Get the size of the data contained in the packet.

Returns
Data size, in bytes

Definition at line 94 of file Packet.cpp.

◆ operator bool()

sf::Packet::operator bool ( ) const

Return the validity of packet.

Tell if the packet is valid for reading.

Returns
True if last data extraction from packet was successful

Definition at line 112 of file Packet.cpp.

◆ operator<<() [1/13]

Packet & sf::Packet::operator<< ( bool Data)

Operator << overloads to put data into the packet.

Definition at line 290 of file Packet.cpp.

◆ operator<<() [2/13]

Packet & sf::Packet::operator<< ( const char * Data)

Definition at line 339 of file Packet.cpp.

◆ operator<<() [3/13]

Packet & sf::Packet::operator<< ( const std::string & Data)

Definition at line 352 of file Packet.cpp.

◆ operator<<() [4/13]

Packet & sf::Packet::operator<< ( const std::wstring & Data)

Definition at line 380 of file Packet.cpp.

◆ operator<<() [5/13]

Packet & sf::Packet::operator<< ( const wchar_t * Data)

Definition at line 366 of file Packet.cpp.

◆ operator<<() [6/13]

Packet & sf::Packet::operator<< ( double Data)

Definition at line 334 of file Packet.cpp.

◆ operator<<() [7/13]

Packet & sf::Packet::operator<< ( float Data)

Definition at line 329 of file Packet.cpp.

◆ operator<<() [8/13]

Packet & sf::Packet::operator<< ( Int16 Data)

Definition at line 305 of file Packet.cpp.

◆ operator<<() [9/13]

Packet & sf::Packet::operator<< ( Int32 Data)

Definition at line 317 of file Packet.cpp.

◆ operator<<() [10/13]

Packet & sf::Packet::operator<< ( Int8 Data)

Definition at line 295 of file Packet.cpp.

◆ operator<<() [11/13]

Packet & sf::Packet::operator<< ( Uint16 Data)

Definition at line 311 of file Packet.cpp.

◆ operator<<() [12/13]

Packet & sf::Packet::operator<< ( Uint32 Data)

Definition at line 323 of file Packet.cpp.

◆ operator<<() [13/13]

Packet & sf::Packet::operator<< ( Uint8 Data)

Definition at line 300 of file Packet.cpp.

◆ operator>>() [1/13]

Packet & sf::Packet::operator>> ( bool & Data)

Operator >> overloads to extract data from the packet.

Definition at line 121 of file Packet.cpp.

◆ operator>>() [2/13]

Packet & sf::Packet::operator>> ( char * Data)

Definition at line 209 of file Packet.cpp.

◆ operator>>() [3/13]

Packet & sf::Packet::operator>> ( double & Data)

Definition at line 199 of file Packet.cpp.

◆ operator>>() [4/13]

Packet & sf::Packet::operator>> ( float & Data)

Definition at line 189 of file Packet.cpp.

◆ operator>>() [5/13]

Packet & sf::Packet::operator>> ( Int16 & Data)

Definition at line 149 of file Packet.cpp.

◆ operator>>() [6/13]

Packet & sf::Packet::operator>> ( Int32 & Data)

Definition at line 169 of file Packet.cpp.

◆ operator>>() [7/13]

Packet & sf::Packet::operator>> ( Int8 & Data)

Definition at line 129 of file Packet.cpp.

◆ operator>>() [8/13]

Packet & sf::Packet::operator>> ( std::string & Data)

Definition at line 227 of file Packet.cpp.

◆ operator>>() [9/13]

Packet & sf::Packet::operator>> ( std::wstring & Data)

Definition at line 265 of file Packet.cpp.

◆ operator>>() [10/13]

Packet & sf::Packet::operator>> ( Uint16 & Data)

Definition at line 159 of file Packet.cpp.

◆ operator>>() [11/13]

Packet & sf::Packet::operator>> ( Uint32 & Data)

Definition at line 179 of file Packet.cpp.

◆ operator>>() [12/13]

Packet & sf::Packet::operator>> ( Uint8 & Data)

Definition at line 139 of file Packet.cpp.

◆ operator>>() [13/13]

Packet & sf::Packet::operator>> ( wchar_t * Data)

Definition at line 245 of file Packet.cpp.

◆ SocketTCP

friend class SocketTCP
friend

Definition at line 144 of file Packet.hpp.

◆ SocketUDP

friend class SocketUDP
friend

Definition at line 145 of file Packet.hpp.


The documentation for this class was generated from the following files: