HDK
|
#include "UT_Array.h"
#include "UT_IStream.h"
#include "UT_OStream.h"
#include "UT_String.h"
#include "UT_StringHolder.h"
#include "UT_Tuple.h"
#include "UT_TupleUtil.h"
#include "UT_ValArray.h"
#include "UT_WorkBuffer.h"
#include <SYS/SYS_Types.h>
#include <tuple>
#include <type_traits>
#include <utility>
#include <stddef.h>
#include <string.h>
Go to the source code of this file.
Classes | |
struct | UT_SaveSerializable< OBJ_T > |
struct | UT_LoadSerializable< OBJ_T > |
struct | UT_ArraySaveSerializable< T, ARRAY > |
struct | UT_ArrayLoadSerializable< T, ARRAY > |
struct | UT_PairSerializable< V1, V2, PairT > |
struct | UT_StringMapSaveSerializable< V, StringMapT > |
struct | UT_StringMapLoadSerializable< V, StringMapT > |
class | UT_StringMap< T > |
class | UT_ArrayStringMap< ITEM_T > |
class | UT_SaveArchiver< ARCHIVER_T > |
Base class for archivers. More... | |
class | UT_LoadArchiver< ARCHIVER_T > |
class | UT_SaveArchiverManip< OBJ_T, ARCHIVER_T > |
Manipulators for streaming archivers. More... | |
class | UT_LoadArchiverManip< OBJ_T, ARCHIVER_T > |
Macros | |
#define | UT_DECLARE_SERIALIZABLE(OBJ_T) |
#define | UT_DECLARE_ARRAY_SERIALIZABLE(ARRAY_T) |
#define | UT_DECLARE_PAIR_SERIALIZABLE(PAIR_T) |
#define | UT_DECLARE_STRINGMAP_SERIALIZABLE(MAP_T) |
Functions | |
template<typename ARCHIVER_T , typename OBJ_T > | |
bool | UTserialize (ARCHIVER_T &archiver, OBJ_T &obj) |
UT_DECLARE_SERIALIZABLE (bool) | |
UT_DECLARE_SERIALIZABLE (int8) | |
UT_DECLARE_SERIALIZABLE (int16) | |
UT_DECLARE_SERIALIZABLE (int32) | |
UT_DECLARE_SERIALIZABLE (int64) | |
UT_DECLARE_SERIALIZABLE (fpreal16) | |
UT_DECLARE_SERIALIZABLE (fpreal32) | |
UT_DECLARE_SERIALIZABLE (fpreal64) | |
template<typename ARCHIVER_T > | |
bool | UTserializeSave (ARCHIVER_T &archiver, UT_String &str) |
template<typename ARCHIVER_T > | |
bool | UTserializeLoad (ARCHIVER_T &archiver, UT_String &str) |
template<typename ARCHIVER_T > | |
bool | UTserializeSave (ARCHIVER_T &archiver, UT_WorkBuffer &str) |
template<typename ARCHIVER_T > | |
bool | UTserializeLoad (ARCHIVER_T &archiver, UT_WorkBuffer &str) |
template<typename ARCHIVER_T > | |
bool | UTserializeSave (ARCHIVER_T &archiver, UT_StringHolder &str) |
template<typename ARCHIVER_T > | |
bool | UTserializeLoad (ARCHIVER_T &archiver, UT_StringHolder &str) |
template<typename OBJ_T , typename ARCHIVER_T > | |
UT_OStream & | operator<< (UT_OStream &out, UT_SaveArchiverManip< OBJ_T, ARCHIVER_T > manip) |
UT_OStream manipulator << overload. More... | |
template<typename OBJ_T , typename ARCHIVER_T > | |
UT_IStream & | operator>> (UT_IStream &in, UT_LoadArchiverManip< OBJ_T, ARCHIVER_T > manip) |
UT_IStream manipulator >> overload. More... | |
template<typename ARCHIVER_T , typename OBJ_T > | |
bool | UTserializeSave (ARCHIVER_T &archiver, OBJ_T &obj) |
template<typename ARCHIVER_T , typename OBJ_T > | |
bool | UTserializeLoad (ARCHIVER_T &archiver, OBJ_T &obj) |
Generic class serialization support
Support structure for generic class serialization.If you just want to save/load to/from classes that already have serialize() methods, then see UT_JSONArchive.h.
To add support for serializing your data, you have two choices for implementation:
-# Implement instrusive serialize() class methods. eg.
To implement serialization for custom types that need different handling between saving and loading, you specialize UTserializeSave/UTserializeLoad instead. For member serialize() methods, you can also call archiver.isLoading() or archiver.isSaving().
To create a new archive type for serialization to a specific format, see UT_JSONArchive.h as an example. There are some requirements:
Definition in file UT_Serialization.h.
#define UT_DECLARE_ARRAY_SERIALIZABLE | ( | ARRAY_T | ) |
Definition at line 269 of file UT_Serialization.h.
#define UT_DECLARE_PAIR_SERIALIZABLE | ( | PAIR_T | ) |
Definition at line 302 of file UT_Serialization.h.
#define UT_DECLARE_SERIALIZABLE | ( | OBJ_T | ) |
Definition at line 169 of file UT_Serialization.h.
#define UT_DECLARE_STRINGMAP_SERIALIZABLE | ( | MAP_T | ) |
Definition at line 367 of file UT_Serialization.h.
UT_OStream& operator<< | ( | UT_OStream & | out, |
UT_SaveArchiverManip< OBJ_T, ARCHIVER_T > | manip | ||
) |
UT_OStream manipulator << overload.
Definition at line 586 of file UT_Serialization.h.
UT_IStream& operator>> | ( | UT_IStream & | in, |
UT_LoadArchiverManip< OBJ_T, ARCHIVER_T > | manip | ||
) |
UT_IStream manipulator >> overload.
Definition at line 593 of file UT_Serialization.h.
UT_DECLARE_SERIALIZABLE | ( | bool | ) |
UT_DECLARE_SERIALIZABLE | ( | int8 | ) |
UT_DECLARE_SERIALIZABLE | ( | int16 | ) |
UT_DECLARE_SERIALIZABLE | ( | int32 | ) |
UT_DECLARE_SERIALIZABLE | ( | int64 | ) |
UT_DECLARE_SERIALIZABLE | ( | fpreal16 | ) |
UT_DECLARE_SERIALIZABLE | ( | fpreal32 | ) |
UT_DECLARE_SERIALIZABLE | ( | fpreal64 | ) |
bool UTserialize | ( | ARCHIVER_T & | archiver, |
OBJ_T & | obj | ||
) |
Default function for non-instrusive serialization of classes. Specialize this when you can perform the same code using the archiver for serialization. If it isn't specialized, then it will call the intrusive version, which you must supply.
Definition at line 117 of file UT_Serialization.h.
bool UTserializeLoad | ( | ARCHIVER_T & | archiver, |
OBJ_T & | obj | ||
) |
Specialize UTserializeSave/UTserializeLoad for serialization when saving/loading needs to be different. By default, they just forward to the regular UTserialize() method.
Definition at line 136 of file UT_Serialization.h.
bool UTserializeLoad | ( | ARCHIVER_T & | archiver, |
UT_String & | str | ||
) |
Definition at line 195 of file UT_Serialization.h.
bool UTserializeLoad | ( | ARCHIVER_T & | archiver, |
UT_WorkBuffer & | str | ||
) |
Definition at line 211 of file UT_Serialization.h.
bool UTserializeLoad | ( | ARCHIVER_T & | archiver, |
UT_StringHolder & | str | ||
) |
Definition at line 223 of file UT_Serialization.h.
bool UTserializeSave | ( | ARCHIVER_T & | archiver, |
OBJ_T & | obj | ||
) |
Specialize UTserializeSave/UTserializeLoad for serialization when saving/loading needs to be different. By default, they just forward to the regular UTserialize() method.
Definition at line 128 of file UT_Serialization.h.
bool UTserializeSave | ( | ARCHIVER_T & | archiver, |
UT_String & | str | ||
) |
Definition at line 189 of file UT_Serialization.h.
bool UTserializeSave | ( | ARCHIVER_T & | archiver, |
UT_WorkBuffer & | str | ||
) |
Definition at line 205 of file UT_Serialization.h.
bool UTserializeSave | ( | ARCHIVER_T & | archiver, |
UT_StringHolder & | str | ||
) |
Definition at line 217 of file UT_Serialization.h.