|
| Serializer (SeekableReadStream *in, WriteStream *out) |
|
bool | isSaving () |
|
bool | isLoading () |
|
template<typename T > |
void | syncAsByte (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsSByte (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsUint16LE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsUint16BE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsSint16LE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsSint16BE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsUint32LE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsUint32BE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsSint32LE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsSint32BE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsFloatLE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsFloatBE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsDoubleLE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncAsDoubleBE (T &val, Version minVersion=0, Version maxVersion=kLastVersion) |
|
bool | err () const |
|
void | clearErr () |
|
bool | syncVersion (Version currentVersion) |
|
Version | getVersion () const |
|
void | setVersion (Version version) |
|
uint | bytesSynced () const |
|
void | skip (uint32 size, Version minVersion=0, Version maxVersion=kLastVersion) |
|
void | syncBytes (byte *buf, uint32 size, Version minVersion=0, Version maxVersion=kLastVersion) |
|
bool | matchBytes (const char *magic, byte size, Version minVersion=0, Version maxVersion=kLastVersion) |
|
void | syncString (String &str, Version minVersion=0, Version maxVersion=kLastVersion) |
|
void | syncString32 (U32String &str, Version minVersion=0, Version maxVersion=kLastVersion) |
|
template<typename T > |
void | syncArray (T *arr, size_t entries, void(*serializer)(Serializer &, T &), Version minVersion=0, Version maxVersion=kLastVersion) |
|
|
template<typename T > |
static void | Uint32LE (Serializer &s, T &value) |
|
template<typename T > |
static void | Uint32BE (Serializer &s, T &value) |
|
template<typename T > |
static void | Sint32LE (Serializer &s, T &value) |
|
template<typename T > |
static void | Sint32BE (Serializer &s, T &value) |
|
template<typename T > |
static void | FloatLE (Serializer &s, T &value) |
|
template<typename T > |
static void | FloatBE (Serializer &s, T &value) |
|
template<typename T > |
static void | DoubleLE (Serializer &s, T &value) |
|
template<typename T > |
static void | DoubleBE (Serializer &s, T &value) |
|
template<typename T > |
static void | Uint16LE (Serializer &s, T &value) |
|
template<typename T > |
static void | Uint16BE (Serializer &s, T &value) |
|
template<typename T > |
static void | Sint16LE (Serializer &s, T &value) |
|
template<typename T > |
static void | Sint16BE (Serializer &s, T &value) |
|
template<typename T > |
static void | Byte (Serializer &s, T &value) |
|
template<typename T > |
static void | SByte (Serializer &s, T &value) |
|
This class allows syncing / serializing data (primarily game savestates) between memory and Read/WriteStreams. It optionally supports versioning the serialized data (client code must use the syncVersion() method for this). This makes it possible to support multiple versions of a savegame format with a single codepath
This class was heavily inspired by the save/load code in the SCUMM engine.
bool Common::Serializer::matchBytes |
( |
const char * |
magic, |
|
|
byte |
size, |
|
|
Version |
minVersion = 0 , |
|
|
Version |
maxVersion = kLastVersion |
|
) |
| |
|
inline |
Sync a 'magic id' of up to 256 bytes, and return whether it matched. When saving, this will simply write out the magic id and return true. When loading, this will read the specified number of bytes, compare it to the given magic id and return true on a match, false otherwise.
A typical magic id is a FOURCC like 'MAGI'.
- Parameters
-
magic | magic id as a byte sequence |
size | length of the magic id in bytes |
- Returns
- true if the magic id matched, false otherwise