31 #if !defined(THEOLIZER_INTERNAL_CORE_SERIALIZER_H) 32 #define THEOLIZER_INTERNAL_CORE_SERIALIZER_H 34 #include "core_type_info.h" 35 #include "version_array.h" 47 #pragma warning(disable:4100 4127 4251) 54 #ifndef THEOLIZER_INTERNAL_DOXYGEN 65 #define THEOLIZER_INTERNAL_NON_INTRUSIVE(dClass) \ 67 struct TheolizerNonIntrusive<dClass> : public dClass \ 69 THEOLIZER_INTERNAL_SERIALIZABLE_AUTO(, \ 70 (TheolizerNonIntrusive<dClass>), (dClass), 1, \ 71 (), theolizer::internal::emName, true, true); \ 77 #define THEOLIZER_INTERNAL_NON_INTRUSIVE_TEMPLATE(dList, dClass, dUniqueClass)\ 78 THEOLIZER_INTERNAL_UNPAREN dList \ 79 struct TheolizerNonIntrusive<THEOLIZER_INTERNAL_UNPAREN dClass> : \ 80 public THEOLIZER_INTERNAL_UNPAREN dClass \ 83 TS:THEOLIZER_INTERNAL_UNPAREN dList;THEOLIZER_INTERNAL_UNPAREN dClass)\ 84 THEOLIZER_INTERNAL_SERIALIZABLE_AUTO(, \ 85 (TheolizerNonIntrusive<THEOLIZER_INTERNAL_UNPAREN dClass>), dClass, 1,\ 86 (friend struct dUniqueClass;), theolizer::internal::emName, true, true);\ 101 #define THEOLIZER_INTERNAL_SERIALIZABLE() \ 102 static const bool kIsTheolizer=true; \ 103 template<class> friend struct theolizer::internal::IsTheolizerNonKeepStep;\ 104 template<class, class> friend struct theolizer::internal::IsTheolizerNonKeepStepImpl;\ 105 template<class, typename, bool, theolizer::internal::TrackingMode, class>\ 106 friend struct theolizer::internal::Switcher; \ 107 template<typename, bool> friend struct theolizer::internal::RegisterToBaseClassEntrance;\ 108 template<class> friend class theolizer::internal::ClassTypeInfo 110 #define THEOLIZER_INTERNAL_SERIALIZABLE_AUTO(dAttribute, dClass, dTarget, dLastVersionNo,\ 111 dDefineUnique, dMap, dIsNonIntrusive, dIsFullAuto)\ 112 typedef THEOLIZER_INTERNAL_UNPAREN dTarget TheolizerTarget; \ 114 typedef THEOLIZER_INTERNAL_UNPAREN dClass TheolizerClass; \ 117 THEOLIZER_INTERNAL_UNPAREN dDefineUnique \ 118 static const bool kIsFullAuto=dIsFullAuto; \ 119 static const unsigned kLastVersionNo=dLastVersionNo; \ 120 static const theolizer::internal::ElementsMapping kElementsMapping=dMap;\ 121 struct DefineUniqueName; \ 123 static const bool kIsNonIntrusive=dIsNonIntrusive; \ 124 static const bool kIsAuto=true; \ 125 static const bool kIsVersion=false; \ 127 static std::string getClassName( \ 128 theolizer::internal::VersionNoList const&, unsigned); \ 129 static char const* getUniqueName(); \ 130 static theolizer::internal::ElementsMapping getElementsMapping(unsigned);\ 131 static theolizer::internal::ElementRange getElementRange(unsigned); \ 132 static unsigned getTypeFlags(unsigned); \ 133 static void registerToBaseClass(theolizer::internal::BaseTypeInfo*);\ 135 static void saveClass(theolizer::internal::BaseSerializer&, \ 136 TheolizerClass*&, unsigned); \ 137 static void loadClass(theolizer::internal::BaseSerializer&, \ 138 TheolizerClass*&, unsigned); \ 140 template<class tTheolizerVersion, class tNextVersion, unsigned tVersionNo>\ 141 struct TheolizerUserDefine \ 143 static const unsigned kTheolizerVersionNo=tVersionNo; \ 144 static void downVersion(tNextVersion const&, tTheolizerVersion&) { }\ 145 static void upVersion(tTheolizerVersion const&, tNextVersion&) { } \ 147 template<class tBaseSerializer, unsigned tVersionNo> \ 148 struct TheolizerSpecials { }; \ 149 THEOLIZER_INTERNAL_SERIALIZABLE(); \ 151 template<class tBaseSerializer, unsigned tVersionNo> \ 152 struct TheolizerVersion { } 154 #define THEOLIZER_INTERNAL_SERIALIZABLE_MANUAL(dClass, dLastVersionNo, \ 155 dDefineUnique, dMap, dIsNonIntrusive)\ 156 typedef THEOLIZER_INTERNAL_UNPAREN dClass TheolizerTarget; \ 157 typedef TheolizerNonIntrusive<THEOLIZER_INTERNAL_UNPAREN dClass> TheolizerClass;\ 160 THEOLIZER_INTERNAL_UNPAREN dDefineUnique \ 161 static const bool kIsFullAuto=false; \ 162 static const unsigned kLastVersionNo=dLastVersionNo; \ 163 static const theolizer::internal::ElementsMapping kElementsMapping=dMap;\ 164 struct DefineUniqueName; \ 166 static const bool kIsNonIntrusive=dIsNonIntrusive; \ 167 static const bool kIsAuto=false; \ 168 static const bool kIsVersion=false; \ 170 static std::string getClassName( \ 171 theolizer::internal::VersionNoList const&, unsigned); \ 172 static char const* getUniqueName(); \ 173 static theolizer::internal::ElementsMapping getElementsMapping(unsigned);\ 174 static theolizer::internal::ElementRange getElementRange(unsigned); \ 175 static unsigned getTypeFlags(unsigned) {return 0;} \ 176 static void registerToBaseClass(theolizer::internal::BaseTypeInfo*);\ 178 static void saveClass(theolizer::internal::BaseSerializer&, \ 179 TheolizerClass*&, unsigned); \ 180 static void loadClass(theolizer::internal::BaseSerializer&, \ 181 TheolizerClass*&, unsigned); \ 183 template<class tBaseSerializer, class tTheolizerVersion, unsigned tVersionNo>\ 184 struct TheolizerUserDefine \ 186 static const unsigned kTheolizerVersionNo=tVersionNo; \ 187 static void saveClassManual \ 188 (tBaseSerializer&, typename tTheolizerVersion::TheolizerTarget const*const&)\ 190 static_assert(theolizer::internal::Ignore<tBaseSerializer>::kFalse,\ 191 "saveClassManual() is undefined"); \ 193 static void loadClassManual \ 194 (tBaseSerializer&, typename tTheolizerVersion::TheolizerClass*&)\ 196 static_assert(theolizer::internal::Ignore<tBaseSerializer>::kFalse,\ 197 "loadClassManual() is undefined"); \ 200 THEOLIZER_INTERNAL_SERIALIZABLE(); \ 202 template<class tBaseSerializer, unsigned tVersionNo> \ 203 struct TheolizerVersion { } 205 #define THEOLIZER_INTERNAL_TEMPLATE_PARAMETER(dClass, dName, dParam, dUniqueClass)\ 206 typedef void NoGenerate; \ 207 typedef THEOLIZER_INTERNAL_UNPAREN dClass TheolizerTarget; \ 208 typedef TheolizerNonIntrusive<THEOLIZER_INTERNAL_UNPAREN dClass> TheolizerClass;\ 211 friend struct dUniqueClass; \ 212 static const bool kIsFullAuto=false; \ 213 static const unsigned kLastVersionNo=1; \ 214 static const theolizer::internal::ElementsMapping kElementsMapping= \ 215 theolizer::internal::emOrder; \ 216 struct DefineUniqueName {typedef dUniqueClass UniqueClass;}; \ 217 static const bool kIsNonIntrusive=true; \ 218 static const bool kIsAuto=false; \ 219 static const bool kIsVersion=false; \ 221 static std::string getClassName( \ 222 theolizer::internal::VersionNoList const& iVersionNoList, unsigned)\ 223 {return THEOLIZER_INTERNAL_MAKE_TEMPLATE_NAME( \ 224 u8"" #dName,THEOLIZER_INTERNAL_UNPAREN dParam);} \ 225 static char const* getUniqueName() {return #dUniqueClass;} \ 226 static theolizer::internal::ElementsMapping getElementsMapping(unsigned)\ 227 {return kElementsMapping;} \ 228 static theolizer::internal::ElementRange getElementRange(unsigned) \ 229 {return theolizer::internal::ElementRange();} \ 230 static unsigned getTypeFlags(unsigned) {return 0;} \ 232 static void saveClass(theolizer::internal::BaseSerializer&,TheolizerClass*&, unsigned)\ 233 {THEOLIZER_INTERNAL_ABORT("use THEOLIZER_NON_INTRUSIVE_XXX, if serialize this class.");}\ 234 static void loadClass(theolizer::internal::BaseSerializer&,TheolizerClass*&, unsigned)\ 235 {THEOLIZER_INTERNAL_ABORT("use THEOLIZER_NON_INTRUSIVE_XXX, if serialize this class.");}\ 237 template<class tBaseSerializer, class tTheolizerVersion, unsigned tVersionNo>\ 238 struct TheolizerUserDefine \ 240 static const unsigned kTheolizerVersionNo=tVersionNo; \ 241 static void saveClassManual \ 242 (tBaseSerializer&, typename tTheolizerVersion::TheolizerTarget const*const&)\ 244 static void loadClassManual \ 245 (tBaseSerializer&, typename tTheolizerVersion::TheolizerClass*&)\ 248 THEOLIZER_INTERNAL_SERIALIZABLE() 258 #define THEOLIZER_INTERNAL_ENUM_FULL_AUTO(dEnum) \ 259 THEOLIZER_INTERNAL_ENUM(dEnum, 1, theolizer::internal::estName, true) 261 #define THEOLIZER_INTERNAL_ENUM(dEnum, dLastVersionNo, dEnumSaveType, dIsFullAuto)\ 263 struct TheolizerNonIntrusive<dEnum> \ 265 typedef dEnum TheolizerTarget; \ 268 static const bool kIsFullAuto=dIsFullAuto; \ 269 static const unsigned kVersionNo=dLastVersionNo; \ 270 static const unsigned kLastVersionNo=dLastVersionNo; \ 271 static const theolizer::internal::EnumSaveType kEnumSaveType=dEnumSaveType;\ 272 static const bool kIsNonIntrusive=true; \ 274 static char const* getEnumName(unsigned iVersionNo); \ 275 static unsigned getTypeFlags(unsigned); \ 276 static theolizer::internal::ElementRange getElementRange(unsigned);\ 278 static void saveEnum(theolizer::internal::BaseSerializer& iSerializer,\ 279 dEnum& iInstance, unsigned iVersionNo); \ 280 static void loadEnum(theolizer::internal::BaseSerializer& iSerializer,\ 281 dEnum& iInstance, unsigned iVersionNo); \ 283 typedef TheolizerNonIntrusive<dEnum> TheolizerClass; \ 284 template<class tBaseSerializer, unsigned tVersionNo> \ 285 struct TheolizerVersion { }; \ 299 #if defined(_MSC_VER) && !defined(__clang__) 300 #define THEOLIZER_INTERNAL_TYPENAME 301 #define THEOLIZER_INTERNAL_TEMPLATE 303 #define THEOLIZER_INTERNAL_TYPENAME typename 304 #define THEOLIZER_INTERNAL_TEMPLATE template 314 #define THEOLIZER_INTERNAL_SAVE(dMidSerializer, dInstance, dTrackingMode) \ 316 THEOLIZER_INTERNAL_SETUP(dMidSerializer, dInstance); \ 317 theolizer::internal::Switcher< \ 318 Serializer, Type, true, theolizer::internal::dTrackingMode \ 319 >::save(dMidSerializer, dInstance); \ 324 #define THEOLIZER_INTERNAL_LOAD(dMidSerializer, dInstance, dTrackingMode) \ 326 THEOLIZER_INTERNAL_SETUP(dMidSerializer, dInstance); \ 327 theolizer::internal::Switcher< \ 328 Serializer, Type, true, theolizer::internal::dTrackingMode \ 329 >::load(dMidSerializer, dInstance); \ 334 #define THEOLIZER_INTERNAL_SETUP(dSerializer, dInstance) \ 335 typedef THEOLIZER_INTERNAL_TYPENAME \ 336 std::remove_reference<decltype(dSerializer)>::type Serializer; \ 337 typedef decltype(dInstance) TypeTemp; \ 338 typedef THEOLIZER_INTERNAL_TYPENAME std::remove_reference<TypeTemp>::type Type;\ 339 typedef THEOLIZER_INTERNAL_TYPENAME std::remove_pointer<Type>::type TypeRemoved;\ 340 static_assert(!std::is_pointer<TypeRemoved>::value, "Not support Pointer to Pointer.") 354 class BaseSerializer;
356 class THEOLIZER_INTERNAL_DLL AdditionalInfo :
public BaseAdditionalInfo
360 std::unique_ptr<Indep> mIndep;
363 BaseSerializer& mBaseSerializer;
367 AdditionalInfo(BaseSerializer& iBaseSerializer) noexcept;
368 ~AdditionalInfo() noexcept;
371 void pushInstanceInfo
375 bool iIsPointer=false,
376 char const* iFileName=
nullptr,
379 void popInstanceInfo();
382 u8string getString();
385 void setError(ErrorInfo const& iErrorInfo,
bool iConstructor);
431 TrackingStatus mStatus;
441 TrackingStatus iStatus
442 ) : mObjectId(iObjectId),
451 struct DeserializeInfo
454 TrackingStatus mStatus;
468 struct SharedPtrTable
475 virtual void clear() = 0;
476 virtual ~HolderBase() { }
481 template<
typename tListType>
482 struct Holder :
public HolderBase
497 std::unique_ptr<HolderBase> mHolder;
515 #define THEOLIZER_INTERNAL_FRIENDS_FOR_INTERNAL \ 516 template<TrackingMode, class, class, typename, class> friend struct BranchedProcess; \ 517 template<TrackingMode, class, class tSerializer, typename tType> \ 518 friend void process(tSerializer&, tType const&, char const*, char const*, size_t); \ 519 template<TrackingMode, class, class tSerializer, typename tType> \ 520 friend void process(tSerializer&, tType&, char const*, char const*, size_t); \ 521 template<typename> friend class ArrayTypeInfo; \ 522 template<typename> friend class ClassTypeInfo; \ 523 template<typename> friend class EnumTypeInfo; \ 524 template<typename> friend class PrimitiveTypeInfo;\ 525 template<class, typename, bool, TrackingMode, class> friend struct Switcher; \ 526 template<class, typename, class> friend struct SavePointer; \ 527 template<class, typename, class> friend struct LoadPointer; \ 528 template<typename...> friend struct ParameterName; \ 529 template<class> friend struct ::TheolizerNonIntrusive; \ 530 template<class, class> friend struct ::TheolizerNonKeepStep; \ 531 template<class> friend class TypeFunctions; \ 532 template<class, class, class, bool, bool> friend class RegisterType; \ 533 friend class BaseTypeInfo; \ 534 template<typename> friend class Element; \ 535 template<typename> friend struct EnumElement; \ 536 friend struct MetaDeserializer; \ 537 friend class AdditionalInfo; \ 538 friend class AutoRestoreIsShared 541 #define THEOLIZER_INTERNAL_FRIENDS \ 542 template<internal::TrackingMode, class, class, typename, class> \ 543 friend struct internal::BranchedProcess; \ 544 template<internal::TrackingMode, class, class tSerializer, typename tType> \ 545 friend void internal::process(tSerializer&,tType const&,char const*,char const*,size_t);\ 546 template<internal::TrackingMode, class, class tSerializer, typename tType> \ 547 friend void internal::process(tSerializer&,tType&,char const*,char const*,size_t); \ 548 template<class> friend class internal::TypeFunctions; \ 549 template<class, class, class, bool, bool> friend class internal::RegisterType; \ 550 template<class> friend int internal::registerMidSerializer() 552 #endif // THEOLIZER_INTERNAL_DOXYGEN 567 THEOLIZER_INTERNAL_FRIENDS_FOR_INTERNAL;
569 virtual void AbstructSerializer() = 0;
574 Destinations
const& mDestinations;
576 bool mNoThrowException;
578 GlobalVersionNoTableBase
const*
const mGlobalVersionNoTable;
579 unsigned mGlobalVersionNo;
580 unsigned mLastGlobalVersionNo;
581 TypeInfoListImpl& mTypeInfoList;
584 size_t mTypeIndexCount;
585 bool mRequireClearTracking;
588 #ifndef THEOLIZER_INTERNAL_DOXYGEN 590 static const bool kHasDestination=
false;
591 #endif // THEOLIZER_INTERNAL_DOXYGEN 598 bool getRequireClearTracking() {
return mRequireClearTracking; }
601 constexpr
static GlobalVersionNoTableBase
const*
const*
const 602 kPtrGlobalVersionNoTable=
nullptr;
603 static internal::Destinations getDestinations()
605 return internal::Destinations{};
610 Destinations
const& iDestinations,
611 GlobalVersionNoTableBase
const*
const iGlobalVersionNoTable,
612 unsigned iGlobalVersionNo,
613 unsigned iLastGlobalVersionNo,
616 std::ostream* iOStream,
617 bool mNoThrowException
638 using ErrorBase::setError;
643 AdditionalInfo mAdditionalInfo;
647 struct AutoRestoreSerializeInfo
649 AdditionalInfo& mAdditionalInfo;
651 AutoRestoreSerializeInfo
656 bool iIsPointer=
false,
657 char const* iFileName=
nullptr,
659 ) noexcept : mAdditionalInfo(iSerializer.mAdditionalInfo)
661 mAdditionalInfo.pushInstanceInfo(iName, iIndex, iIsPointer, iFileName, iLineNo);
663 ~AutoRestoreSerializeInfo() noexcept
665 mAdditionalInfo.popInstanceInfo();
670 bool getNoThrowException()
const {
return mNoThrowException;}
673 void checkStreamError(std::ios::iostate iIoState);
686 bool mBaseProcessing;
687 struct AutoBaseProcessing
689 bool mBaseProcessingBack;
690 bool& mBaseProcessing;
692 mBaseProcessingBack(iSerializer.mBaseProcessing),
693 mBaseProcessing( iSerializer.mBaseProcessing)
695 mBaseProcessing=
true;
697 ~AutoBaseProcessing()
699 mBaseProcessing=mBaseProcessingBack;
705 struct AutoClassTracking
707 bool mClassTrackingBack;
708 bool& mClassTracking;
710 mClassTrackingBack(iSerializer.mClassTracking),
711 mClassTracking( iSerializer.mClassTracking)
717 mClassTracking=mClassTrackingBack;
723 struct AutoRefProcessing
725 bool mRefProcessingBack;
726 bool& mRefProcessing;
728 mRefProcessingBack(iSerializer.mRefProcessing),
729 mRefProcessing( iSerializer.mRefProcessing)
735 mRefProcessing=mRefProcessingBack;
748 void clearTrackingImpl();
752 void clearTracking();
759 struct SharedPtrTables;
760 std::unique_ptr<SharedPtrTables> mSharedPtrTables;
762 SharedPtrTable& registerSharedPtrTable(std::type_index iTypeIndex);
766 template<
typename tTypeList>
769 SharedPtrTable& aSharedPtrTable=registerSharedPtrTable(iTypeIndex);
772 if (!aSharedPtrTable.mHolder)
774 aSharedPtrTable.mHolder.reset(
new SharedPtrTable::Holder<tTypeList>);
777 SharedPtrTable::Holder<tTypeList>* aHolder=
778 dynamic_cast<SharedPtrTable::Holder<tTypeList>*
>(aSharedPtrTable.mHolder.get());
779 return aHolder->mList;
788 friend THEOLIZER_INTERNAL_DLL
bool isLastVersion();
789 friend THEOLIZER_INTERNAL_DLL
bool isSaver();
790 friend THEOLIZER_INTERNAL_DLL
unsigned& getUpVersionCount();
793 bool isLastVersion()
const {
return mGlobalVersionNo == mLastGlobalVersionNo;}
796 bool isSaver()
const {
return mIsSaver;}
801 unsigned mUpVersionCount;
809 ElementsMapping mElementsMapping;
812 bool mCancelPrettyPrint;
823 struct THEOLIZER_INTERNAL_DLL AutoRestoreSaveProcess
826 ElementsMapping mElementsMapping;
828 bool mCancelPrettyPrint;
830 AutoRestoreSaveProcess(
BaseSerializer& iSerializer,
size_t iTypeIndex);
831 ~AutoRestoreSaveProcess() noexcept(
false);
838 struct THEOLIZER_INTERNAL_DLL AutoRestoreSave
841 ElementsMapping mElementsMapping;
843 bool mCancelPrettyPrint;
847 ElementsMapping iElementsMapping=emOrder,
848 bool iCancelPrettyPrint=
false 850 ~AutoRestoreSave() noexcept(
false);
863 struct THEOLIZER_INTERNAL_DLL AutoRestoreSaveStructure
866 ElementsMapping mElementsMapping;
867 Structure mStructure;
868 std::unique_ptr<std::string> mTypeName;
870 bool mCancelPrettyPrint;
872 AutoRestoreSaveStructure
875 ElementsMapping iElementsMapping,
876 Structure iStructure,
877 std::size_t iTypeIndex=kInvalidSize,
878 std::size_t iObjectId=kInvalidSize,
879 bool iCancelPrettyPrint=
false 881 ~AutoRestoreSaveStructure() noexcept(
false);
890 unsigned mSerializerVersionNo;
894 VersionNoList mVersionNoList;
904 void createVersionNoTable();
909 void writeHeaderTypeInfo();
913 std::string getTypeName(std::size_t iTypeIndex);
914 void saveProcessStart(std::size_t iTypeIndex);
915 void saveProcessEnd();
925 virtual void writePreElement(
bool iDoProcess=
false) {THEOLIZER_INTERNAL_ABORT(
"");}
926 virtual void saveGroupStart(
bool iIsTop=
false) {THEOLIZER_INTERNAL_ABORT(
"");}
927 virtual void saveGroupEnd(
bool iIsTop=
false) {THEOLIZER_INTERNAL_ABORT(
"");}
928 virtual void saveStructureStart
929 (Structure iStructure, std::string& ioTypeName, std::size_t iObjectId)
931 virtual void saveStructureEnd(Structure iStructure, std::string
const& iTypeName)
933 virtual void saveObjectId(std::size_t iObjectId, std::size_t iTypeIndex)
934 {saveControl(iObjectId);}
935 virtual void saveControl(
int iControl) {THEOLIZER_INTERNAL_ABORT(
"");}
936 virtual void saveControl(
long iControl) {THEOLIZER_INTERNAL_ABORT(
"");}
937 virtual void saveControl(
long long iControl) {THEOLIZER_INTERNAL_ABORT(
"");}
938 virtual void saveControl(
unsigned iControl) {THEOLIZER_INTERNAL_ABORT(
"");}
939 virtual void saveControl(
unsigned long iControl) {THEOLIZER_INTERNAL_ABORT(
"");}
940 virtual void saveControl(
unsigned long long iControl) {THEOLIZER_INTERNAL_ABORT(
"");}
941 virtual void saveControl(std::string
const& iControl) {THEOLIZER_INTERNAL_ABORT(
"");}
942 virtual void saveElementName(ElementsMapping iElementsMapping,
char const* iElementName)
943 {THEOLIZER_INTERNAL_ABORT(
"");}
947 #define THEOLIZER_INTERNAL_DEF_PRIMITIVE(dType, dSymbol) \ 948 virtual void savePrimitive(dType const& iPrimitive) {THEOLIZER_INTERNAL_ABORT("");} 950 #include "primitive.inc" 958 template<
typename tBaseSerializer,
typename tArrayType, TrackingMode tTrackingMode>
959 void saveArray(tArrayType& iArray)
961 AutoRestoreSaveStructure aAutoRestoreSaveStructure(*
this, emOrder, Structure::Array);
962 for (
size_t i=0; i < std::extent<tArrayType>::value; ++i)
964 AutoRestoreSerializeInfo aAutoRestoreSerializeInfo(*
this,
nullptr, i);
970 typename std::remove_extent<tArrayType>::type,
973 >::save(*
this, iArray[i]);
984 template<
class tVersionType>
friend void saveClass(
BaseSerializer&, tVersionType&);
986 template<
class tVersionType>
987 void saveClassImpl(tVersionType& iVersion)
989 ElementsMapping aElementsMapping = tVersionType::Theolizer::kElementsMapping;
993 aElementsMapping=emOrder;
997 std::size_t aTypeIndex = kInvalidSize;
998 if (mCheckMode == CheckMode::TypeCheckInData)
1000 aTypeIndex = getTypeIndex<typename tVersionType::TheolizerTarget>();
1003 AutoRestoreSaveStructure aAutoRestoreSaveStructure
1004 (*
this, aElementsMapping, Structure::Class, aTypeIndex);
1005 BaseSerializer::AutoBaseProcessing aAutoBaseProcessing(*
this);
1006 for (
size_t i=0; !tVersionType::getElementTheolizer(i).isSentinel() ; ++i)
1008 if (!mDestinations.isMatch(tVersionType::getElementTheolizer(i).getDestinations()))
1012 if (!tVersionType::getElementTheolizer(i).isBaseClass())
1014 mBaseProcessing=
false;
1017 char const* aElementName=tVersionType::getElementTheolizer(i).getName();
1018 AutoRestoreSerializeInfo aAutoRestoreSerializeInfo(*
this, aElementName);
1020 saveElementName(aElementsMapping, aElementName);
1021 tVersionType::getElementTheolizer(i).saveElement(*
this, iVersion);
1035 struct THEOLIZER_INTERNAL_DLL AutoRestoreLoadProcess
1039 AutoRestoreLoadProcess(
BaseSerializer& iSerializer,
size_t iTypeIndex);
1040 ~AutoRestoreLoadProcess() noexcept(
false);
1047 struct THEOLIZER_INTERNAL_DLL AutoRestoreLoad
1050 ElementsMapping mElementsMapping;
1053 ElementsMapping iElementsMapping=emOrder);
1054 ~AutoRestoreLoad() noexcept(
false);
1067 struct THEOLIZER_INTERNAL_DLL AutoRestoreLoadStructure
1070 ElementsMapping mElementsMapping;
1071 Structure mStructure;
1072 std::unique_ptr<std::string> mTypeName;
1074 bool mCancelPrettyPrint;
1076 AutoRestoreLoadStructure
1079 ElementsMapping iElementsMapping,
1080 Structure iStructure,
1081 std::size_t iTypeIndex=kInvalidSize,
1082 std::size_t* oObjectId=
nullptr 1084 ~AutoRestoreLoadStructure() noexcept(
false);
1093 struct SerializedTypeListI;
1094 std::unique_ptr<SerializedTypeListI> mSerializedTypeListI;
1097 struct SerializedTypeListN;
1098 std::unique_ptr<SerializedTypeListN> mSerializedTypeListN;
1102 std::unique_ptr<TypeNameMap> mTypeNameMap;
1106 std::vector<std::size_t> mTypeIndexTable;
1110 void createTypeNameMap(
bool iIsClassOnly=
false);
1115 void readHeaderTypeInfo();
1119 bool isMatchTypeIndex(
size_t iSerializedTypeIndex,
1120 size_t iProgramTypeIndex);
1124 void loadProcessStart(
size_t iTypeIndex);
1125 void loadProcessEnd();
1135 virtual ReadStat readPreElement(
bool iDoProcess=
false) {THEOLIZER_INTERNAL_ABORT(
"");}
1136 virtual void disposeElement() {THEOLIZER_INTERNAL_ABORT(
"");}
1137 virtual void loadGroupStart(
bool iIsTop=
false) {THEOLIZER_INTERNAL_ABORT(
"");}
1138 virtual void loadGroupEnd(
bool iIsTop=
false) {THEOLIZER_INTERNAL_ABORT(
"");}
1139 virtual void loadStructureStart
1140 (Structure iStructure, std::string& ioTypeName, std::size_t* oObjectId)
1141 {THEOLIZER_INTERNAL_ABORT(
"");}
1142 virtual void loadStructureEnd(Structure iStructure, std::string
const& iTypeName)
1143 {THEOLIZER_INTERNAL_ABORT(
"");}
1144 virtual void loadObjectId(std::size_t& oObjectId, std::size_t iTypeIndex)
1145 {loadControl(oObjectId);}
1146 virtual void loadTypeName(std::string& oTypeName) {loadControl(oTypeName);}
1147 virtual void loadControl(
int& oControl) {THEOLIZER_INTERNAL_ABORT(
"");}
1148 virtual void loadControl(
long& oControl) {THEOLIZER_INTERNAL_ABORT(
"");}
1149 virtual void loadControl(
long long& oControl) {THEOLIZER_INTERNAL_ABORT(
"");}
1150 virtual void loadControl(
unsigned& oControl) {THEOLIZER_INTERNAL_ABORT(
"");}
1151 virtual void loadControl(
unsigned long& oControl) {THEOLIZER_INTERNAL_ABORT(
"");}
1152 virtual void loadControl(
unsigned long long& oControl) {THEOLIZER_INTERNAL_ABORT(
"");}
1153 virtual void loadControl(std::string& oControl) {THEOLIZER_INTERNAL_ABORT(
"");}
1154 virtual std::string loadElementName(ElementsMapping iElementsMapping)
1155 {THEOLIZER_INTERNAL_ABORT(
"");}
1159 #define THEOLIZER_INTERNAL_DEF_PRIMITIVE(dType, dSymbol) \ 1160 virtual void loadPrimitive(dType& iPrimitive) {THEOLIZER_INTERNAL_ABORT("");} 1162 #include "primitive.inc" 1170 template<
typename tBaseSerializer,
typename tArrayType, TrackingMode tTrackingMode>
1171 void loadArray(tArrayType& oArray)
1173 AutoRestoreLoadStructure aAutoRestoreLoadStructure(*
this, emOrder, Structure::Array);
1174 for (
size_t i=0;
true; ++i)
1176 ReadStat aReadStat=readPreElement();
1180 AutoRestoreSerializeInfo aAutoRestoreSerializeInfo(*
this,
nullptr, i);
1182 if (i < std::extent<tArrayType>::value)
1187 typename std::remove_extent<tArrayType>::type,
1190 >::load(*
this, oArray[i]);
1194 if (aReadStat == DontCare)
1208 std::string getDataElementName(std::size_t iDataTypeIndex, std::size_t iDataIndex);
1212 template<
class tVersionType>
friend void loadClass(
BaseSerializer&, tVersionType&);
1214 template<
class tVersionType>
1215 void loadClassImpl(tVersionType& iVersion)
1218 auto& aClassTypeInfo=ClassTypeInfo<typename tVersionType::TheolizerClass>::getInstance();
1219 std::cout <<
"loadClassImpl(" << aClassTypeInfo.getCName() <<
") --- start\n";
1222 ElementsMapping aElementsMapping = tVersionType::Theolizer::kElementsMapping;
1226 aElementsMapping=emOrder;
1230 std::size_t aTypeIndex = kInvalidSize;
1231 if (mCheckMode == CheckMode::TypeCheckInData)
1233 aTypeIndex = getTypeIndex<typename tVersionType::TheolizerTarget>();
1236 AutoRestoreLoadStructure aAutoRestoreLoadStructure
1237 (*
this, aElementsMapping, Structure::Class, aTypeIndex);
1238 BaseSerializer::AutoBaseProcessing aAutoBaseProcessing(*
this);
1240 if (tVersionType::getElementTheolizer(0).isSentinel())
1243 std::size_t aDataTypeIndex=0;
1244 if ((tVersionType::Theolizer::kElementsMapping == emName)
1247 if (aTypeIndex == kInvalidSize)
1249 aTypeIndex = getTypeIndex<typename tVersionType::TheolizerTarget>();
1251 aDataTypeIndex=mTypeIndexTable[aTypeIndex];
1252 THEOLIZER_INTERNAL_ASSERT(aDataTypeIndex != kInvalidSize,
1253 "aTypeIndex=%d aDataTypeIndex=%d TypeName=%s", aTypeIndex, aDataTypeIndex,
1254 THEOLIZER_INTERNAL_TYPE_NAME(
typename tVersionType::TheolizerTarget));
1256 std::size_t aDataIndex=0;
1260 ReadStat aReadStat=readPreElement();
1264 std::string aElementName;
1265 if ((tVersionType::Theolizer::kElementsMapping == emName)
1268 aElementName=getDataElementName(aDataTypeIndex, aDataIndex++);
1272 aElementName=loadElementName(aElementsMapping);
1275 AutoRestoreSerializeInfo aAutoRestoreSerializeInfo(*
this, aElementName.c_str());
1283 if (aElementName.empty())
1286 if (tVersionType::getElementTheolizer(i).isSentinel())
1293 if (mDestinations.isMatch
1295 tVersionType::getElementTheolizer(i).getDestinations()
1306 else if (aElementName == tVersionType::getElementTheolizer(i).getName())
1315 if (tVersionType::getElementTheolizer(i).isSentinel())
1318 if (!aElementName.empty())
1335 if (!tVersionType::getElementTheolizer(aIndex).isBaseClass())
1337 mBaseProcessing=
false;
1341 tVersionType::getElementTheolizer(aIndex).loadElement(*
this, iVersion);
1346 if (tVersionType::getElementTheolizer(aIndex).isSentinel())
1349 if (aReadStat == DontCare)
1352 if (!aElementName.empty())
1361 if (aReadStat == DontCare)
1369 std::cout <<
"loadClassImpl(" << aClassTypeInfo.getCName() <<
") --- end\n";
1378 void disposeClass(ElementsMapping iElementsMapping);
1391 struct SerializeList;
1392 std::unique_ptr<SerializeList> mSerializeList;
1393 void initSerializeList();
1400 SerializeInfo& registerObject
1403 std::type_info
const& iTypeInfo,
1404 TrackingMode iTrackingMode,
1413 struct DeserializeList;
1414 std::unique_ptr<DeserializeList> mDeserializeList;
1421 bool isLoadedObject(
size_t iObjectId,
void*& oPointer);
1434 std::type_info
const& iTypeInfo,
1435 TrackingMode iTrackingMode,
1436 bool* oIsLoaded=
nullptr 1447 virtual TypeIndexList& getProgramTypeIndex();
1453 #ifdef THEOLIZER_INTERNAL_ENABLE_META_SERIALIZER 1460 std::ostream* mOStream;
1464 void writeMetaData();
1468 void judgeWriteTypes
1470 std::size_t iTypeIndex,
1471 BaseTypeInfo* iTypeInfo,
1472 TypeInfoListImpl
const& iTypeInfoList,
1473 std::vector<SaveStat>& ioSaveStatList
1477 void writeMetaPrimitive();
1482 std::vector<VersionNoList>
const& iVersionNoLists,
1483 TypeInfoListImpl
const& iTypeInfoList,
1484 std::vector<SaveStat>& ioSaveStatList
1488 struct UniqueNameSet;
1491 std::vector<VersionNoList>
const& iVersionNoLists,
1492 TypeInfoListImpl
const& iTypeInfoList,
1493 std::vector<SaveStat>& ioSaveStatList,
1494 UniqueNameSet& ioUniqueNameSet
1503 void readMetaData();
1505 static char const* getCppName(std::string
const& iPrimitiveName,
unsigned iSerializerVersionNo)
1509 #endif // THEOLIZER_INTERNAL_ENABLE_META_SERIALIZER 1511 #ifndef THEOLIZER_INTERNAL_DOXYGEN 1521 template<
class tVersionType>
1522 void saveClass(
BaseSerializer& iBaseSerializer, tVersionType& iVersion)
1524 iBaseSerializer.saveClassImpl(iVersion);
1527 template<
class tVersionType>
1528 void loadClass(
BaseSerializer& iBaseSerializer, tVersionType& iVersion)
1530 iBaseSerializer.loadClassImpl(iVersion);
1537 THEOLIZER_INTERNAL_DLL
bool isLastVersion();
1538 THEOLIZER_INTERNAL_DLL
bool isSaver();
1539 THEOLIZER_INTERNAL_DLL
unsigned& getUpVersionCount();
1549 class AutoRestoreIsShared
1555 explicit AutoRestoreIsShared(
BaseSerializer& iSerializer,
bool iIsShared) :
1556 mSerializer(iSerializer),
1557 mIsShared(iSerializer.mIsShared)
1559 mSerializer.mIsShared=iIsShared;
1561 ~AutoRestoreIsShared()
1563 mSerializer.mIsShared=mIsShared;
1565 AutoRestoreIsShared(AutoRestoreIsShared
const&) =
delete;
1566 AutoRestoreIsShared& operator=(AutoRestoreIsShared
const&) =
delete;
1573 #endif // THEOLIZER_INTERNAL_DOXYGEN 1582 #pragma warning(pop) 1585 #endif // THEOLIZER_INTERNAL_CORE_SERIALIZER_H tTypeList & getSharedPtrTable(std::type_index iTypeIndex)
共有ポインタ(例えばstd::shared_ptr)回復用のテーブル
unsigned getGlobalVersionNo() const
処理中のグローバル・バージョン番号返却(3-1-2.メンバ関数 参照)
virtual void setCharIsMultiByte(bool)
std::stringをマルチ・パイト文字コードとして処理することを指定する(NOP)
CheckMode getCheckMode()
現在のCheckMode返却(3-1-2.メンバ関数 参照)