Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Public Member Functions | Public Attributes | List of all members
gf::Packet Struct Reference

A packet of bytes. More...

#include <gf/Packet.h>

Public Member Functions

Id getType ()
 Get the type of the underlying bytes. More...
 
template<typename T >
as ()
 Deserialize the underlying bytes into an object. More...
 
template<typename T >
void is (const T &data)
 Serialize the object into bytes. More...
 

Public Attributes

Id type = InvalidId
 The type of the packet. More...
 
std::vector< uint8_t > bytes
 The bytes representing the object. More...
 

Detailed Description

A packet of bytes.

Member Function Documentation

◆ as()

template<typename T >
T gf::Packet::as ( )
inline

Deserialize the underlying bytes into an object.

◆ getType()

Id gf::Packet::getType ( )
inline

Get the type of the underlying bytes.

◆ is()

template<typename T >
void gf::Packet::is ( const T &  data)
inline

Serialize the object into bytes.

Member Data Documentation

◆ bytes

std::vector<uint8_t> gf::Packet::bytes

The bytes representing the object.

◆ type

Id gf::Packet::type = InvalidId

The type of the packet.