/[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 3150 by schoenebeck, Fri May 5 18:42:06 2017 UTC revision 3165 by schoenebeck, Tue May 9 15:24:45 2017 UTC
# Line 34  Line 34 
34  #include <string>  #include <string>
35  #include <vector>  #include <vector>
36  #include <map>  #include <map>
37    #include <time.h>
38    #if __cplusplus < 201103L
39    # include <tr1/type_traits>
40    #endif
41    
42  /** @brief Serialization / deserialization framework.  /** @brief Serialization / deserialization framework.
43   *   *
# Line 102  namespace Serialization { Line 106  namespace Serialization {
106          OPERATION_DESERIALIZE          OPERATION_DESERIALIZE
107      };      };
108    
109        enum time_base_t {
110            LOCAL_TIME,
111            UTC_TIME
112        };
113    
114      template<typename T>      template<typename T>
115      bool IsEnum(const T& data) {      bool IsEnum(const T& data) {
116            #if __cplusplus < 201103L
117            return std::tr1::is_enum<T>::value;
118            #else
119          return __is_enum(T);          return __is_enum(T);
120            #endif
121      }      }
122    
123      template<typename T>      template<typename T>
124      bool IsUnion(const T& data) {      bool IsUnion(const T& data) {
125            #if __cplusplus < 201103L
126            return std::tr1::is_union<T>::value;
127            #else
128          return __is_union(T);          return __is_union(T);
129            #endif
130      }      }
131    
132      template<typename T>      template<typename T>
133      bool IsClass(const T& data) {      bool IsClass(const T& data) {
134            #if __cplusplus < 201103L
135            return std::tr1::is_class<T>::value;
136            #else
137          return __is_class(T);          return __is_class(T);
138            #endif
139      }      }
140    
141      /*template<typename T>      /*template<typename T>
# Line 362  namespace Serialization { Line 383  namespace Serialization {
383          std::vector<Member>& members() { return m_members; }          std::vector<Member>& members() { return m_members; }
384          const std::vector<Member>& members() const { return m_members; }          const std::vector<Member>& members() const { return m_members; }
385          Member memberNamed(String name) const;          Member memberNamed(String name) const;
386          void remove(const Member& member);          Member memberByUID(const UID& uid) const;
387          std::vector<Member> membersOfType(const DataType& type) const;          std::vector<Member> membersOfType(const DataType& type) const;
388          int sequenceIndexOf(const Member& member) const;          int sequenceIndexOf(const Member& member) const;
389          bool isValid() const;          bool isValid() const;
# Line 373  namespace Serialization { Line 394  namespace Serialization {
394          bool operator<(const Object& other) const;          bool operator<(const Object& other) const;
395          bool operator>(const Object& other) const;          bool operator>(const Object& other) const;
396    
397        protected:
398            void remove(const Member& member);
399    
400      private:      private:
401          DataType m_type;          DataType m_type;
402          UIDChain m_uid;          UIDChain m_uid;
# Line 574  namespace Serialization { Line 598  namespace Serialization {
598          virtual void decode(const uint8_t* data, size_t size);          virtual void decode(const uint8_t* data, size_t size);
599          void clear();          void clear();
600          bool isModified() const;          bool isModified() const;
601            void removeMember(Object& parent, const Member& member);
602          void remove(const Object& obj);          void remove(const Object& obj);
603          Object& rootObject();          Object& rootObject();
604          Object& objectByUID(const UID& uid);          Object& objectByUID(const UID& uid);
# Line 583  namespace Serialization { Line 608  namespace Serialization {
608          void setBoolValue(Object& object, bool value);          void setBoolValue(Object& object, bool value);
609          void setEnumValue(Object& object, uint64_t value);          void setEnumValue(Object& object, uint64_t value);
610          String valueAsString(const Object& object);          String valueAsString(const Object& object);
611            String name() const;
612            void setName(String name);
613            String comment() const;
614            void setComment(String comment);
615            time_t timeStampCreated() const;
616            time_t timeStampModified() const;
617            tm dateTimeCreated(time_base_t base = LOCAL_TIME) const;
618            tm dateTimeModified(time_base_t base = LOCAL_TIME) const;
619    
620      protected:      protected:
621          // UID resolver for non-pointer types          // UID resolver for non-pointer types
# Line 690  namespace Serialization { Line 723  namespace Serialization {
723          UID m_root;          UID m_root;
724          RawData m_rawData;          RawData m_rawData;
725          bool m_isModified;          bool m_isModified;
726            String m_name;
727            String m_comment;
728            time_t m_timeCreated;
729            time_t m_timeModified;
730      };      };
731    
732      /**      /**

Legend:
Removed from v.3150  
changed lines
  Added in v.3165

  ViewVC Help
Powered by ViewVC