Data deserializer. More...
#include <SerDes.h>
Classes | |
| class | SizeTracker |
| RAII tracker of advance position. More... | |
Public Member Functions | |
| DataDeserializer (const char *externalStore, size_t storeLength) | |
| Construct a Deserializer *. More... | |
| DataDeserializer (const uint8_t *externalStore, size_t storeLength) | |
| Construct a Deserializer. More... | |
| DataDeserializer (const DataSerializer &serializer) | |
| Construct a new Deserializer reading data from a Serializer. More... | |
| void | skipPadding (size_t bytes) |
| Skips padding in the input. More... | |
| DataDeserializer & | operator>> (uint8_t &c) |
| Read an uint8_t from the buffer. More... | |
| DataDeserializer & | operator>> (int8_t &c) |
| Read an int8_t from the buffer. More... | |
| DataDeserializer & | operator>> (uint16_t &val) |
| Read an uint16_t from the buffer. More... | |
| DataDeserializer & | operator>> (int16_t &val) |
| Read an int16_t from the buffer. More... | |
| DataDeserializer & | operator>> (uint32_t &val) |
| Read an uint32_t from the buffer. More... | |
| DataDeserializer & | operator>> (int32_t &val) |
| Read an int32_t from the buffer. More... | |
| DataDeserializer & | operator>> (uint64_t &val) |
| Read an uint64_t from the buffer. More... | |
| DataDeserializer & | operator>> (int64_t &val) |
| Read an int64_t from the buffer. More... | |
| DataDeserializer & | operator>> (float &val) |
| Read an float from the buffer. More... | |
| DataDeserializer & | operator>> (glm::vec3 &val) |
| Read a glm::vec3 from the buffer. More... | |
| DataDeserializer & | operator>> (glm::vec4 &val) |
| Read a glm::vec4 from the buffer. More... | |
| DataDeserializer & | operator>> (glm::ivec2 &val) |
| Read a glm::ivec2 from the buffer. More... | |
| const char * | buffer () const |
| Pointer to the start of the internal buffer. More... | |
| size_t | pos () const |
| Current position in the buffer. Starts at 0. More... | |
| size_t | length () const |
| Last position that was written to in the buffer. Starts at 0. More... | |
| bool | isEmpty () const |
| Whether there's any data in the buffer. More... | |
| bool | isOverflow () const |
| The buffer size limit has been reached. More... | |
| void | rewind () |
| Reset the serializer to the start, clear overflow bit. | |
| size_t | lastAdvance () const |
| Size of the last advance. More... | |
Friends | |
| QDebug | operator<< (QDebug debug, const DataDeserializer &ds) |
| Dump the contents of this object into QDebug. More... | |
Data deserializer.
This class operates on a fixed size buffer. If an attempt to read past the end is made, the read fails, and the overflow flag is set.
The class was written for the maximum simplicity possible and inline friendliness.
Example of decoding:
This object should be modified directly to add support for any primitive and common datatypes in the code. To support deserializing classes and structures, implement an operator>> function for that object, eg:
|
inline |
Construct a Deserializer *.
| externalStore | External data store |
| storeLength | Length of the data store |
|
inline |
Construct a Deserializer.
| externalStore | External data store |
| storeLength | Length of the data store |
|
inline |
Construct a new Deserializer reading data from a Serializer.
This is a convenience function for testing.
| serializer | Serializer with data |
|
inline |
Pointer to the start of the internal buffer.
The allocated amount can be found with capacity().
The end of the stored data can be found with length().
|
inline |
Whether there's any data in the buffer.
|
inline |
The buffer size limit has been reached.
This can only return true for a statically allocated buffer.
|
inline |
Size of the last advance.
This can be used to get how many bytes were added in the last operation. It is reset on rewind()
|
inline |
Last position that was written to in the buffer. Starts at 0.
|
inline |
Read an float from the buffer.
| val | Value to read |
|
inline |
Read a glm::ivec2 from the buffer.
| val | Value to read |
|
inline |
Read a glm::vec3 from the buffer.
| val | Value to read |
|
inline |
Read a glm::vec4 from the buffer.
| val | Value to read |
|
inline |
Read an int16_t from the buffer.
| val | Value to read |
|
inline |
Read an int32_t from the buffer.
| val | Value to read |
|
inline |
Read an int64_t from the buffer.
| val | Value to read |
|
inline |
Read an int8_t from the buffer.
| c | Character to read |
|
inline |
Read an uint16_t from the buffer.
| val | Value to read |
|
inline |
Read an uint32_t from the buffer.
| val | Value to read |
|
inline |
Read an uint64_t from the buffer.
| val | Value to read |
|
inline |
Read an uint8_t from the buffer.
| c | Character to read |
|
inline |
Current position in the buffer. Starts at 0.
|
inline |
Skips padding in the input.
| bytes | Number of bytes to skip |
|
friend |
Dump the contents of this object into QDebug.
This produces a dump of the internal state, and an ASCII/hex dump of the contents, for debugging.
| debug | Qt QDebug stream |
| ds | This object |