![]() |
CUGL 2.5
Cornell University Game Library
|
#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< LWDeserializer > | alloc () |
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.
|
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.
|
inlinestatic |
Returns a newly allocated LWDeserializer.
This method is solely include for convenience purposes.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
msg | The byte vector serialized by LWSerializer |
|
inline |
Resets the deserializer and clears the loaded byte vector.