/[svn]/libgig/trunk/src/Serialization.h
ViewVC logotype

Diff of /libgig/trunk/src/Serialization.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3770 by schoenebeck, Wed Feb 20 19:12:49 2019 UTC revision 3771 by schoenebeck, Sun May 17 17:14:31 2020 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2017-2019 Christian Schoenebeck                         *   *   Copyright (C) 2017-2020 Christian Schoenebeck                         *
4   *                           <cuse@users.sourceforge.net>                  *   *                           <cuse@users.sourceforge.net>                  *
5   *                                                                         *   *                                                                         *
6   *   This library is part of libgig.                                       *   *   This library is part of libgig.                                       *
# Line 360  namespace Serialization { Line 360  namespace Serialization {
360          bool isPointer() const;          bool isPointer() const;
361          bool isClass() const;          bool isClass() const;
362          bool isPrimitive() const;          bool isPrimitive() const;
363            bool isString() const;
364          bool isInteger() const;          bool isInteger() const;
365          bool isReal() const;          bool isReal() const;
366          bool isBool() const;          bool isBool() const;
# Line 413  namespace Serialization { Line 414  namespace Serialization {
414                  if (type == typeid(bool))     return DataType(T_isPointer, sz, "bool");                  if (type == typeid(bool))     return DataType(T_isPointer, sz, "bool");
415                  if (type == typeid(float))    return DataType(T_isPointer, sz, "real32");                  if (type == typeid(float))    return DataType(T_isPointer, sz, "real32");
416                  if (type == typeid(double))   return DataType(T_isPointer, sz, "real64");                  if (type == typeid(double))   return DataType(T_isPointer, sz, "real64");
417                    if (type == typeid(String))   return DataType(T_isPointer, sz, "String");
418    
419                  if (IsEnum(data)) return DataType(T_isPointer, sz, "enum", rawCppTypeNameOf(data));                  if (IsEnum(data)) return DataType(T_isPointer, sz, "enum", rawCppTypeNameOf(data));
420                  if (IsUnion(data)) return DataType(T_isPointer, sz, "union", rawCppTypeNameOf(data));                  if (IsUnion(data)) return DataType(T_isPointer, sz, "union", rawCppTypeNameOf(data));
# Line 1036  namespace Serialization { Line 1038  namespace Serialization {
1038          void setRealValue(Object& object, double value);          void setRealValue(Object& object, double value);
1039          void setBoolValue(Object& object, bool value);          void setBoolValue(Object& object, bool value);
1040          void setEnumValue(Object& object, uint64_t value);          void setEnumValue(Object& object, uint64_t value);
1041            void setStringValue(Object& object, String value);
1042          String valueAsString(const Object& object);          String valueAsString(const Object& object);
1043          int64_t valueAsInt(const Object& object);          int64_t valueAsInt(const Object& object);
1044          double valueAsReal(const Object& object);          double valueAsReal(const Object& object);
# Line 1114  namespace Serialization { Line 1117  namespace Serialization {
1117              static void serializeObject(Archive* archive, const T*& obj) {}              static void serializeObject(Archive* archive, const T*& obj) {}
1118          };          };
1119    
1120            // NOOP SerializationRecursion for String objects.
1121            template<>
1122            struct SerializationRecursionImpl<String,true> {
1123                static void serializeObject(Archive* archive, const String& obj) {}
1124            };
1125    
1126            // NOOP SerializationRecursion for String pointers (of 1st degree).
1127            template<>
1128            struct SerializationRecursionImpl<String*,true> {
1129                static void serializeObject(Archive* archive, const String*& obj) {}
1130            };
1131    
1132          // Automatically handles recursion for class/struct types, while ignoring all primitive types.          // Automatically handles recursion for class/struct types, while ignoring all primitive types.
1133          template<typename T>          template<typename T>
1134          struct SerializationRecursion : SerializationRecursionImpl<T, LIBGIG_IS_CLASS(T)> {          struct SerializationRecursion : SerializationRecursionImpl<T, LIBGIG_IS_CLASS(T)> {
# Line 1146  namespace Serialization { Line 1161  namespace Serialization {
1161          protected:          protected:
1162              void syncObject(const Object& dst, const Object& src);              void syncObject(const Object& dst, const Object& src);
1163              void syncPrimitive(const Object& dst, const Object& src);              void syncPrimitive(const Object& dst, const Object& src);
1164                void syncString(const Object& dst, const Object& src);
1165              void syncPointer(const Object& dst, const Object& src);              void syncPointer(const Object& dst, const Object& src);
1166              void syncMember(const Member& dstMember, const Member& srcMember);              void syncMember(const Member& dstMember, const Member& srcMember);
1167              static Member dstMemberMatching(const Object& dstObj, const Object& srcObj, const Member& srcMember);              static Member dstMemberMatching(const Object& dstObj, const Object& srcObj, const Member& srcMember);

Legend:
Removed from v.3770  
changed lines
  Added in v.3771

  ViewVC Help
Powered by ViewVC