CUGL 2.5
Cornell University Game Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
cugl::physics2::net::LWDeserializer Class Reference

#include <CULWDeserializer.h>

Public Member Functions

 LWDeserializer ()
 
void receive (const std::vector< std::byte > &msg)
 
bool readBool ()
 
std::byte readByte ()
 
float readFloat ()
 
Sint32 readSint32 ()
 
Uint16 readUint16 ()
 
Uint32 readUint32 ()
 
Uint64 readUint64 ()
 
void reset ()
 

Static Public Member Functions

static std::shared_ptr< LWDeserializeralloc ()
 

Detailed Description

A lightweight deserializer for networked physics.

This class removes the type safety of cugl::net::NetcodeDeserializer, and requires that the user know the type of the data. However, it is a more space efficient serializer, and is more appropriate for networked physics.

This class is to be paired with LWSerializer for serialization.

Constructor & Destructor Documentation

◆ LWDeserializer()

cugl::physics2::net::LWDeserializer::LWDeserializer ( )
inline

Creates a new Deserializer on the stack.

Deserializers do not have any nontrivial state and so it is unnecessary to use an init method. However, we do include a static alloc method for creating shared pointers.

Member Function Documentation

◆ alloc()

static std::shared_ptr< LWDeserializer > cugl::physics2::net::LWDeserializer::alloc ( )
inlinestatic

Returns a newly allocated LWDeserializer.

This method is solely include for convenience purposes.

Returns
a newly allocated LWDeserializer.

◆ readBool()

bool cugl::physics2::net::LWDeserializer::readBool ( )
inline

Returns a boolean read from the loaded byte vector.

The method advances the read position. If called when no more data is available, this method will return false.

Returns
a boolean read from the loaded byte vector.

◆ readByte()

std::byte cugl::physics2::net::LWDeserializer::readByte ( )
inline

Returns a byte from the loaded byte vector.

The method advances the read position. If called when no more data is available, this method will return 0.

Returns
a byte from the loaded byte vector.

◆ readFloat()

float cugl::physics2::net::LWDeserializer::readFloat ( )
inline

Returns a float from the loaded byte vector.

The method advances the read position. If called when no more data is available, this method will return 0.

Returns
a float from the loaded byte vector.

◆ readSint32()

Sint32 cugl::physics2::net::LWDeserializer::readSint32 ( )
inline

Returns a signed (32 bit) int from the loaded byte vector.

The method advances the read position. If called when no more data is available, this method will return 0.

Returns
a signed (32 bit) int from the loaded byte vector.

◆ readUint16()

Uint16 cugl::physics2::net::LWDeserializer::readUint16 ( )
inline

Returns an unsigned short from the loaded byte vector.

The method advances the read position. If called when no more data is available, this method will return 0.

Returns
an unsigned short from the loaded byte vector.

◆ readUint32()

Uint32 cugl::physics2::net::LWDeserializer::readUint32 ( )
inline

Returns an unsigned (32 bit) int from the loaded byte vector.

The method advances the read position. If called when no more data is available, this method will return 0.

Returns
an unsigned (32 bit) int from the loaded byte vector.

◆ readUint64()

Uint64 cugl::physics2::net::LWDeserializer::readUint64 ( )
inline

Returns an unsigned (64 bit) long from the loaded byte vector.

The method advances the read position. If called when no more data is available, this method will return 0.

Returns
an unsigned (64 bit) long from the loaded byte vector.

◆ receive()

void cugl::physics2::net::LWDeserializer::receive ( const std::vector< std::byte > &  msg)
inline

Loads a new message to be read.

Calling this method will discard any previously loaded messages. The message must be serialized by LWSerializer. Otherwise, the results are unspecified.

Once loaded, call the various read methods to get the data. It is up to the user to know the correct methods to be called. The values are guaranteed to be delievered in the same order they were written.

Parameters
msgThe byte vector serialized by LWSerializer

◆ reset()

void cugl::physics2::net::LWDeserializer::reset ( )
inline

Resets the deserializer and clears the loaded byte vector.


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