HDK
|
#include "UT_IStream.h"
#include "UT_OStream.h"
#include "UT_Array.h"
#include "UT_String.h"
#include "UT_StringHolder.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 > |
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) |
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 265 of file UT_Serialization.h.
#define UT_DECLARE_SERIALIZABLE | ( | OBJ_T | ) |
Definition at line 166 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 475 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 482 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 114 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 133 of file UT_Serialization.h.
bool UTserializeLoad | ( | ARCHIVER_T & | archiver, |
UT_String & | str | ||
) |
Definition at line 192 of file UT_Serialization.h.
bool UTserializeLoad | ( | ARCHIVER_T & | archiver, |
UT_WorkBuffer & | str | ||
) |
Definition at line 208 of file UT_Serialization.h.
bool UTserializeLoad | ( | ARCHIVER_T & | archiver, |
UT_StringHolder & | str | ||
) |
Definition at line 220 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 125 of file UT_Serialization.h.
bool UTserializeSave | ( | ARCHIVER_T & | archiver, |
UT_String & | str | ||
) |
Definition at line 186 of file UT_Serialization.h.
bool UTserializeSave | ( | ARCHIVER_T & | archiver, |
UT_WorkBuffer & | str | ||
) |
Definition at line 202 of file UT_Serialization.h.
bool UTserializeSave | ( | ARCHIVER_T & | archiver, |
UT_StringHolder & | str | ||
) |
Definition at line 214 of file UT_Serialization.h.