28 #ifndef HPL_SERIALIZE_CLASS_H 29 #define HPL_SERIALIZE_CLASS_H 31 #include "hpl1/engine/system/MemoryManager.h" 32 #include "hpl1/engine/system/SystemTypes.h" 33 #include "hpl1/static_string.h" 34 #include "common/stablemap.h" 44 typedef unsigned int eSerializeType;
46 #define eSerializeType_Bool (1) 47 #define eSerializeType_Int32 (2) 48 #define eSerializeType_Float32 (3) 50 #define eSerializeType_String (4) 52 #define eSerializeType_Vector2l (5) 53 #define eSerializeType_Vector2f (6) 54 #define eSerializeType_Vector3l (7) 55 #define eSerializeType_Vector3f (8) 57 #define eSerializeType_Matrixf (9) 59 #define eSerializeType_Color (10) 61 #define eSerializeType_Rect2l (11) 62 #define eSerializeType_Rect2f (12) 64 #define eSerializeType_Planef (13) 66 #define eSerializeType_WString (14) 68 #define eSerializeType_Class (100) 76 #define eSerializeType_ClassPointer (101) 79 #define eSerializeType_Last (200) 81 #define eSerializeType_NULL (0xFFFF) 87 typedef unsigned int eSerializeMainType;
89 #define eSerializeMainType_Variable (1) 90 #define eSerializeMainType_Array (2) 91 #define eSerializeMainType_Container (3) 93 #define eSerializeMainType_NULL (0xFFFF) 99 #define ClassMemberOffset(aClass, aMember) (size_t(&(((aClass *)1)->aMember)) - 1) 100 #define ClassMemberSize(aClass, aMember) (sizeof(((aClass *)1)->aMember)) 105 #define kSerializableClassInit(aClass) \ 107 const static char *msSerialize_Name; \ 108 const static char *msSerialize_ParentName; \ 109 static cSerializeMemberField *mpSerialize_MemberFields; \ 110 virtual ~aClass() = default; \ 111 virtual tString Serialize_GetTopClass() { return #aClass; } 113 #define kSerializableClassInit_nodestructor(aClass) \ 115 const static char *msSerialize_Name; \ 116 const static char *msSerialize_ParentName; \ 117 static cSerializeMemberField *mpSerialize_MemberFields; \ 118 virtual tString Serialize_GetTopClass() { return #aClass; } 123 #define kBeginSerialize(aClass, aParent) \ 124 namespace SerializeNamespace_##aClass { \ 125 extern cSerializeMemberField mvTempMemberFields[]; \ 127 const char *aClass::msSerialize_Name = #aClass; \ 128 const char *aClass::msSerialize_ParentName = #aParent; \ 129 cSerializeMemberField *aClass::mpSerialize_MemberFields = SerializeNamespace_##aClass::mvTempMemberFields; \ 130 namespace SerializeNamespace_##aClass { \ 131 typedef aClass tVarClass; \ 132 cSerializeMemberField mvTempMemberFields[] = { 134 #define kBeginSerializeBase(aClass) \ 135 namespace SerializeNamespace_##aClass { \ 136 extern cSerializeMemberField mvTempMemberFields[]; \ 138 const char *aClass::msSerialize_Name = #aClass; \ 139 const char *aClass::msSerialize_ParentName = ""; \ 140 cSerializeMemberField *aClass::mpSerialize_MemberFields = SerializeNamespace_##aClass::mvTempMemberFields; \ 141 namespace SerializeNamespace_##aClass { \ 142 typedef aClass tVarClass; \ 143 cSerializeMemberField mvTempMemberFields[] = { 145 #define kBeginSerializeVirtual(aClass, aParent) \ 146 namespace SerializeNamespace_##aClass { \ 147 extern cSerializeMemberField mvTempMemberFields[]; \ 149 const char *aClass::msSerialize_Name = #aClass; \ 150 const char *aClass::msSerialize_ParentName = #aParent; \ 151 cSerializeMemberField *aClass::mpSerialize_MemberFields = SerializeNamespace_##aClass::mvTempMemberFields; \ 152 namespace SerializeNamespace_##aClass { \ 153 typedef aClass tVarClass; \ 154 cSerializeMemberField mvTempMemberFields[] = { 156 #define kBeginSerializeBaseVirtual(aClass) \ 157 namespace SerializeNamespace_##aClass { \ 158 extern cSerializeMemberField mvTempMemberFields[]; \ 160 const char *aClass::msSerialize_Name = #aClass; \ 161 const char *aClass::msSerialize_ParentName = ""; \ 162 cSerializeMemberField *aClass::mpSerialize_MemberFields = SerializeNamespace_##aClass::mvTempMemberFields; \ 163 namespace SerializeNamespace_##aClass { \ 164 typedef aClass tVarClass; \ 165 cSerializeMemberField mvTempMemberFields[] = { 170 #define kEndSerialize() \ 171 cSerializeMemberField("", 0, 0, eSerializeType_NULL, 0) \ 179 #define kSerializeVar(aVar, aType) \ 180 cSerializeMemberField(#aVar, ClassMemberOffset(tVarClass, aVar), ClassMemberSize(tVarClass, aVar), aType, eSerializeMainType_Variable), 185 #define kSerializeVarArray(aVar, aType, aArraySize) \ 186 cSerializeMemberField(#aVar, ClassMemberOffset(tVarClass, aVar), ClassMemberSize(tVarClass, aVar), aType, eSerializeMainType_Array, aArraySize), 191 #define kSerializeVarContainer(aVar, aType) \ 192 cSerializeMemberField(#aVar, ClassMemberOffset(tVarClass, aVar), ClassMemberSize(tVarClass, aVar), aType, eSerializeMainType_Container), 196 #define kSerializeClassContainer(aVar, aClass, aType) \ 197 cSerializeMemberField(#aVar, ClassMemberOffset(tVarClass, aVar), ClassMemberSize(tVarClass, aVar), aType, eSerializeMainType_Container, #aClass), 208 eSerializeMainType aMainType) : msName(asName), msClassName(
""), mlOffset(alOffset), mlSize(alSize), mType(alType), mMainType(aMainType), mlArraySize(0) {
211 constexpr cSerializeMemberField(
Hpl1::StaticString asName,
size_t alOffset,
size_t alSize, eSerializeType alType,
212 eSerializeMainType aMainType,
size_t alArraySize) : msName(asName), msClassName(
""), mlOffset(alOffset), mlSize(alSize), mType(alType), mMainType(aMainType), mlArraySize(alArraySize) {
215 constexpr cSerializeMemberField(
Hpl1::StaticString asName,
size_t alOffset,
size_t alSize, eSerializeType alType,
216 eSerializeMainType aMainType,
Hpl1::StaticString asClassName) : msName(asName), msClassName(asClassName), mlOffset(alOffset), mlSize(alSize), mType(alType), mMainType(aMainType), mlArraySize(0) {
223 eSerializeType mType;
224 eSerializeMainType mMainType;
233 virtual tString Serialize_GetTopClass() {
return ""; }
241 virtual char *ValueToString(
void *apVal) = 0;
242 virtual void ValueFromString(
char *apString,
void *apVal) = 0;
252 iSerializable *(*apCreateFunc)()) : msName(asName), msParentName(asParent), mpMemberFields(apMemberFields),
253 mlSize(alSize), mpCreateFunc(apCreateFunc) {}
255 const char *msName =
"";
256 const char *msParentName =
"";
286 static void initSaveClassesMap();
287 static void finalizeSaveClassesMap();
289 static void SetLog(
bool abX);
290 static bool GetLog();
304 static tString ValueToString(
void *apData,
size_t alOffset, eSerializeType aType);
305 static void StringToValue(
void *apData,
size_t alOffset, eSerializeType aType,
319 static void FillSaveClassMembersList(tSerializeSavedClassList *apList,
cSerializeSavedClass *apClass);
324 static size_t SizeOfType(eSerializeType aType);
326 static void SetUpData();
328 static char msTempCharArray[2048];
330 static bool mbDataSetup;
331 static tSerializeSavedClassMap *m_mapSavedClasses;
338 #endif // HPL_SERIALIZE_CLASS_H
Definition: SerializeClass.h:238
Definition: SerializeClass.h:264
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: stablemap.h:43
Definition: SerializeClass.h:230
Definition: SerializeClass.h:284
Definition: SerializeClass.h:247
Definition: SerializeClass.h:205
Definition: tinyxml.h:864
Definition: list_intern.h:51
Definition: static_string.h:27