24 #ifndef LIBGIG_SERIALIZATION_H
25 #define LIBGIG_SERIALIZATION_H
43 #ifndef __has_extension
44 # define __has_extension(x) 0
47 #ifndef HAS_BUILTIN_TYPE_TRAITS
48 # if __cplusplus >= 201103L
49 # define HAS_BUILTIN_TYPE_TRAITS 1
50 # elif ( __has_extension(is_class) && __has_extension(is_enum) )
51 # define HAS_BUILTIN_TYPE_TRAITS 1
52 # elif ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 ) )
53 # define HAS_BUILTIN_TYPE_TRAITS 1
54 # elif _MSC_VER >= 1400
55 # define HAS_BUILTIN_TYPE_TRAITS 1
56 # elif __INTEL_COMPILER >= 1100
57 # define HAS_BUILTIN_TYPE_TRAITS 1
59 # define HAS_BUILTIN_TYPE_TRAITS 0
63 #if !HAS_BUILTIN_TYPE_TRAITS
64 # include <tr1/type_traits>
65 # define LIBGIG_IS_CLASS(type) std::tr1::__is_union_or_class<type>::value //NOTE: without compiler support we cannot distinguish union from class
67 # define LIBGIG_IS_CLASS(type) __is_class(type)
177 template<
class T_key,
class T_value>
178 using Map = std::map<T_key,T_value>;
230 #if !HAS_BUILTIN_TYPE_TRAITS
231 return std::tr1::is_enum<T>::value;
249 #if !HAS_BUILTIN_TYPE_TRAITS
252 return __is_union(T);
267 #if !HAS_BUILTIN_TYPE_TRAITS
268 return std::tr1::__is_union_or_class<T>::value;
270 return __is_class(T);
294 template<
typename T>
inline
295 String toString(
const T& value) {
296 return std::to_string(value);
300 String toString(
const String& value) {
327 bool operator==(
const UID& other)
const {
return id == other.
id &&
size == other.
size; }
328 bool operator!=(
const UID& other)
const {
return id != other.id ||
size != other.size; }
329 bool operator<(
const UID& other)
const {
return id < other.id || (
id == other.id &&
size < other.size); }
330 bool operator>(
const UID& other)
const {
return id > other.id || (
id == other.id &&
size > other.size); }
341 return Resolver<T>::resolve(obj);
348 static UID resolve(
const T& obj) {
349 const UID uid = { (
ID) &obj,
sizeof(obj) };
356 struct Resolver<T*> {
357 static UID resolve(
const T*
const & obj) {
358 const UID uid = { (
ID) obj,
sizeof(*obj) };
404 #if LIBGIG_SERIALIZATION_INTERNAL
407 static DataType _popDataTypeBlob(
const char*& p,
const char* end);
408 static Member _popMemberBlob(
const char*& p,
const char* end);
409 static Object _popObjectBlob(
const char*& p,
const char* end);
410 static void _popPrimitiveValue(
const char*& p,
const char* end,
Object& obj);
411 static String _primitiveObjectValueToString(
const Object& obj);
414 static T _primitiveObjectValueToNumber(
const Object& obj);
415 #endif // LIBGIG_SERIALIZATION_INTERNAL
436 size_t size()
const {
return m_size; }
473 return Resolver<T>::resolve(data);
480 template<
typename T,
bool T_isPo
inter>
481 struct ResolverBase {
482 static DataType resolve(
const T& data) {
483 const std::type_info& type =
typeid(data);
484 const int sz =
sizeof(data);
489 if (type ==
typeid(int8_t))
return DataType(T_isPointer, sz,
"int8");
490 if (type ==
typeid(uint8_t))
return DataType(T_isPointer, sz,
"uint8");
491 if (type ==
typeid(int16_t))
return DataType(T_isPointer, sz,
"int16");
492 if (type ==
typeid(uint16_t))
return DataType(T_isPointer, sz,
"uint16");
493 if (type ==
typeid(int32_t))
return DataType(T_isPointer, sz,
"int32");
494 if (type ==
typeid(uint32_t))
return DataType(T_isPointer, sz,
"uint32");
495 if (type ==
typeid(int64_t))
return DataType(T_isPointer, sz,
"int64");
496 if (type ==
typeid(uint64_t))
return DataType(T_isPointer, sz,
"uint64");
497 if (type ==
typeid(
size_t)) {
498 if (sz == 1)
return DataType(T_isPointer, sz,
"uint8");
499 if (sz == 2)
return DataType(T_isPointer, sz,
"uint16");
500 if (sz == 4)
return DataType(T_isPointer, sz,
"uint32");
501 if (sz == 8)
return DataType(T_isPointer, sz,
"uint64");
504 if (type ==
typeid(ssize_t)) {
505 if (sz == 1)
return DataType(T_isPointer, sz,
"int8");
506 if (sz == 2)
return DataType(T_isPointer, sz,
"int16");
507 if (sz == 4)
return DataType(T_isPointer, sz,
"int32");
508 if (sz == 8)
return DataType(T_isPointer, sz,
"int64");
511 if (type ==
typeid(
bool))
return DataType(T_isPointer, sz,
"bool");
512 if (type ==
typeid(
float))
return DataType(T_isPointer, sz,
"real32");
513 if (type ==
typeid(
double))
return DataType(T_isPointer, sz,
"real64");
514 if (type ==
typeid(String))
return DataType(T_isPointer, sz,
"String");
516 if (
IsEnum(data))
return DataType(T_isPointer, sz,
"enum", rawCppTypeNameOf(data));
517 if (
IsUnion(data))
return DataType(T_isPointer, sz,
"union", rawCppTypeNameOf(data));
518 if (
IsClass(data))
return DataType(T_isPointer, sz,
"class", rawCppTypeNameOf(data));
526 struct Resolver : ResolverBase<T,false> {
527 static DataType resolve(
const T& data) {
528 return ResolverBase<T,false>::resolve(data);
534 struct Resolver<T*> : ResolverBase<T,true> {
535 static DataType resolve(
const T*& data) {
536 return ResolverBase<T,true>::resolve(*data);
542 struct Resolver<
Array<T>> {
543 static DataType resolve(
const Array<T>& data) {
544 const int sz =
sizeof(data);
546 return DataType(
false, sz,
"Array", rawCppTypeNameOf(unused));
552 struct Resolver<
Array<T>*> {
553 static DataType resolve(
const Array<T>*& data) {
554 const int sz =
sizeof(*data);
556 return DataType(
true, sz,
"Array", rawCppTypeNameOf(unused));
562 struct Resolver<
Set<T>> {
563 static DataType resolve(
const Set<T>& data) {
564 const int sz =
sizeof(data);
566 return DataType(
false, sz,
"Set", rawCppTypeNameOf(unused));
572 struct Resolver<
Set<T>*> {
573 static DataType resolve(
const Set<T>*& data) {
574 const int sz =
sizeof(*data);
576 return DataType(
true, sz,
"Set", rawCppTypeNameOf(unused));
581 template<
typename T_key,
typename T_value>
582 struct Resolver<
Map<T_key,T_value>> {
583 static DataType resolve(
const Map<T_key,T_value>& data) {
584 const int sz =
sizeof(data);
587 return DataType(
false, sz,
"Map", rawCppTypeNameOf(unused1),
588 rawCppTypeNameOf(unused2));
593 template<
typename T_key,
typename T_value>
594 struct Resolver<
Map<T_key,T_value>*> {
595 static DataType resolve(
const Map<T_key,T_value>*& data) {
596 const int sz =
sizeof(*data);
599 return DataType(
true, sz,
"Map", rawCppTypeNameOf(unused1),
600 rawCppTypeNameOf(unused2));
605 static String rawCppTypeNameOf(
const T& data) {
606 #if defined _MSC_VER // Microsoft compiler ...
607 String name =
typeid(data).raw_name();
608 #else // i.e. especially GCC and clang ...
609 String name =
typeid(data).name();
617 String m_baseTypeName;
618 String m_customTypeName;
619 String m_customTypeName2;
623 #if LIBGIG_SERIALIZATION_INTERNAL
624 friend DataType _popDataTypeBlob(
const char*& p,
const char* end);
626 friend class Archive;
675 #if LIBGIG_SERIALIZATION_INTERNAL
676 friend Member _popMemberBlob(
const char*& p,
const char* end);
709 UID uid(
int index = 0)
const;
716 std::vector<Member>&
members();
717 const std::vector<Member>&
members()
const;
732 void remove(
const Member& member);
742 std::vector<Member> m_members;
743 std::function<void(
Object& dstObj,
const Object& srcObj,
void* syncer)> m_sync;
745 #if LIBGIG_SERIALIZATION_INTERNAL
747 friend Object _popObjectBlob(
const char*& p,
const char* end);
748 friend void _popPrimitiveValue(
const char*& p,
const char* end,
Object& obj);
749 friend String _primitiveObjectValueToString(
const Object& obj);
752 friend T _primitiveObjectValueToNumber(
const Object& obj);
753 #endif // LIBGIG_SERIALIZATION_INTERNAL
907 Archive(
const uint8_t* data,
size_t size);
938 m_allObjects.clear();
1017 template<
typename T>
1081 template<
typename T_
classType,
typename T_memberType>
1082 void serializeMember(
const T_classType& nativeObject,
const T_memberType& nativeMember,
const char* memberName) {
1083 const ssize_t offset =
1084 ((
const uint8_t*)(
const void*)&nativeMember) -
1085 ((
const uint8_t*)(
const void*)&nativeObject);
1086 const UIDChain uids = UIDChainResolver<T_memberType>(nativeMember);
1088 const Member member(memberName, uids[0], offset, type);
1090 Object& parent = m_allObjects[parentUID];
1092 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1094 parent =
Object(uids, type);
1096 parent.
members().push_back(member);
1097 const Object obj(uids, type);
1098 const bool bExistsAlready = m_allObjects.count(uids[0]);
1099 const bool isValidObject = obj;
1100 const bool bExistingObjectIsInvalid = !m_allObjects[uids[0]];
1101 if (!bExistsAlready || (bExistingObjectIsInvalid && isValidObject)) {
1102 m_allObjects[uids[0]] = obj;
1105 SerializationRecursion<T_memberType>::serializeObject(
this, nativeMember);
1139 template<
typename T_
classType,
typename T_memberType>
1140 void serializeHeapMember(
const T_classType& nativeObject,
const T_memberType& heapMember,
const char* memberName) {
1141 const ssize_t offset = -1;
1142 const UIDChain uids = UIDChainResolver<T_memberType>(heapMember);
1144 const Member member(memberName, uids[0], offset, type);
1146 Object& parent = m_allObjects[parentUID];
1148 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1150 parent =
Object(uids, type);
1152 parent.
members().push_back(member);
1153 const Object obj(uids, type);
1154 const bool bExistsAlready = m_allObjects.count(uids[0]);
1155 const bool isValidObject = obj;
1156 const bool bExistingObjectIsInvalid = !m_allObjects[uids[0]];
1157 if (!bExistsAlready || (bExistingObjectIsInvalid && isValidObject)) {
1158 m_allObjects[uids[0]] = obj;
1161 SerializationRecursion<T_memberType>::serializeObject(
this, heapMember);
1244 template<
typename T_
classType>
1247 Object& obj = m_allObjects[uid];
1249 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1251 obj =
Object(uids, type);
1285 template<
typename T_
classType>
1288 Object& obj = m_allObjects[uid];
1290 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1292 obj =
Object(uids, type);
1298 virtual void decode(
const uint8_t* data,
size_t size);
1329 template<
typename T>
1330 class UIDChainResolver {
1332 UIDChainResolver(
const T& data) {
1336 operator UIDChain()
const {
return m_uid; }
1337 UIDChain operator()()
const {
return m_uid; }
1343 template<
typename T>
1344 class UIDChainResolver<T*> {
1346 UIDChainResolver(
const T*& data) {
1347 const UID uids[2] = {
1348 { &data,
sizeof(data) },
1349 { data,
sizeof(*data) }
1351 m_uid.push_back(uids[0]);
1352 m_uid.push_back(uids[1]);
1355 operator UIDChain()
const {
return m_uid; }
1356 UIDChain operator()()
const {
return m_uid; }
1362 template<
typename T,
bool T_isRecursive>
1363 struct SerializationRecursionImpl {
1364 static void serializeObject(
Archive* archive,
const T& obj) {
1370 template<
typename T,
bool T_isRecursive>
1371 struct SerializationRecursionImpl<T*,T_isRecursive> {
1372 static void serializeObject(
Archive* archive,
const T*& obj) {
1374 const_cast<T*&
>(obj)->
serialize(archive);
1379 template<
typename T>
1380 struct SerializationRecursionImpl<T,false> {
1381 static void serializeObject(
Archive* archive,
const T& obj) {}
1385 template<
typename T>
1386 struct SerializationRecursionImpl<T*,
false> {
1387 static void serializeObject(
Archive* archive,
const T*& obj) {}
1391 template<
bool T_isRecursive>
1392 struct SerializationRecursionImpl<String,T_isRecursive> {
1393 static void serializeObject(
Archive* archive,
const String& obj) {}
1397 template<
bool T_isRecursive>
1398 struct SerializationRecursionImpl<String*,T_isRecursive> {
1399 static void serializeObject(
Archive* archive,
const String*& obj) {}
1403 template<
typename T,
bool T_isRecursive>
1404 struct SerializationRecursionImpl<
Array<T>,T_isRecursive> {
1405 static void serializeObject(
Archive* archive,
const Array<T>& obj) {
1406 const UIDChain uids = UIDChainResolver<Array<T>>(obj);
1407 const Object&
object = archive->objectByUID(uids[0]);
1409 for (
size_t i = 0; i < obj.size(); ++i) {
1410 archive->serializeHeapMember(
1411 obj, obj[i], (
"[" + toString(i) +
"]").c_str()
1415 const_cast<Object&
>(object).m_sync =
1416 [&obj,archive](Object& dstObj,
const Object& srcObj,
1419 const size_t n = srcObj.members().size();
1420 const_cast<Array<T>&
>(obj).resize(n);
1421 for (
size_t i = 0; i < obj.size(); ++i) {
1422 archive->serializeHeapMember(
1423 obj, obj[i], (
"[" + toString(i) +
"]").c_str()
1428 dstObj = archive->objectByUID(dstObj.uid());
1429 for (
size_t i = 0; i < obj.size(); ++i) {
1430 String
name =
"[" + toString(i) +
"]";
1431 Member srcMember = srcObj.memberNamed(
name);
1432 Member dstMember = dstObj.memberNamed(
name);
1433 ((Syncer*)syncer)->syncMember(dstMember, srcMember);
1441 template<
typename T,
bool T_isRecursive>
1442 struct SerializationRecursionImpl<
Array<T>*,T_isRecursive> {
1443 static void serializeObject(
Archive* archive,
const Array<T>*& obj) {
1445 SerializationRecursionImpl<Array<T>,T_isRecursive>::serializeObject(
1452 template<
typename T,
bool T_isRecursive>
1453 struct SerializationRecursionImpl<
Set<T>,T_isRecursive> {
1454 static void serializeObject(
Archive* archive,
const Set<T>& obj) {
1455 const UIDChain uids = UIDChainResolver<Set<T>>(obj);
1456 const Object&
object = archive->objectByUID(uids[0]);
1458 for (
const T& key : obj) {
1459 archive->serializeHeapMember(
1460 obj, key, (
"[" + toString(key) +
"]").c_str()
1464 const_cast<Object&
>(object).m_sync =
1465 [&obj,archive](Object& dstObj,
const Object& srcObj,
1468 const size_t n = srcObj.members().size();
1469 const_cast<Set<T>&
>(obj).
clear();
1470 for (
size_t i = 0; i < n; ++i) {
1471 const Member& member = srcObj.members()[i];
1472 String
name = member.name();
1473 if (
name.length() < 2 ||
name[0] !=
'[' ||
1474 *
name.rbegin() !=
']')
continue;
1477 const UIDChain uids = UIDChainResolver<T>(key);
1479 Object tmpObj(uids, type);
1480 tmpObj.setNativeValueFromString(
name);
1481 const_cast<Set<T>&
>(obj).insert(key);
1483 for (
const T& key : obj) {
1484 archive->serializeHeapMember(
1485 obj, key, (
"[" + toString(key) +
"]").c_str()
1490 dstObj = archive->objectByUID(dstObj.uid());
1497 template<
typename T,
bool T_isRecursive>
1498 struct SerializationRecursionImpl<
Set<T>*,T_isRecursive> {
1499 static void serializeObject(
Archive* archive,
const Set<T>*& obj) {
1501 SerializationRecursionImpl<Set<T>,T_isRecursive>::serializeObject(
1508 template<
typename T_key,
typename T_value,
bool T_isRecursive>
1509 struct SerializationRecursionImpl<
Map<T_key,T_value>,T_isRecursive> {
1510 static void serializeObject(
Archive* archive,
const Map<T_key,T_value>& obj) {
1511 const UIDChain uids = UIDChainResolver<Map<T_key,T_value>>(obj);
1512 const Object&
object = archive->objectByUID(uids[0]);
1514 for (
const auto& it : obj) {
1515 archive->serializeHeapMember(
1516 obj, it.second, (
"[" + toString(it.first) +
"]").c_str()
1520 const_cast<Object&
>(object).m_sync =
1521 [&obj,archive](Object& dstObj,
const Object& srcObj,
1524 const size_t n = srcObj.members().size();
1525 const_cast<Map<T_key,T_value>&
>(obj).
clear();
1526 for (
size_t i = 0; i < n; ++i) {
1527 const Member& member = srcObj.members()[i];
1528 String
name = member.name();
1529 if (
name.length() < 2 ||
name[0] !=
'[' ||
1530 *
name.rbegin() !=
']')
continue;
1533 const UIDChain uids = UIDChainResolver<T_key>(key);
1535 Object tmpObj(uids, type);
1536 tmpObj.setNativeValueFromString(
name);
1537 const_cast<Map<T_key,T_value>&
>(obj)[key] = T_value();
1539 for (
const auto& it : obj) {
1540 archive->serializeHeapMember(
1541 obj, it.second, (
"[" + toString(it.first) +
"]").c_str()
1546 dstObj = archive->objectByUID(dstObj.uid());
1547 for (
size_t i = 0; i < n; ++i) {
1548 Member srcMember = srcObj.members()[i];
1549 Member dstMember = dstObj.memberNamed(srcMember.name());
1550 ((Syncer*)syncer)->syncMember(dstMember, srcMember);
1558 template<
typename T_key,
typename T_value,
bool T_isRecursive>
1559 struct SerializationRecursionImpl<
Map<T_key,T_value>*,T_isRecursive> {
1560 static void serializeObject(
Archive* archive,
const Map<T_key,T_value>*& obj) {
1562 SerializationRecursionImpl<Map<T_key,T_value>,T_isRecursive>::serializeObject(
1569 template<
typename T>
1570 struct SerializationRecursion : SerializationRecursionImpl<T, LIBGIG_IS_CLASS(T)> {
1573 class ObjectPool :
public std::map<UID,Object> {
1576 Object& operator[](
const UID& k) {
1577 static Object invalid;
1582 return std::map<UID,Object>::operator[](k);
1586 friend String _encode(
const ObjectPool& objects);
1589 String _encodeRootBlob();
1590 void _popRootBlob(
const char*& p,
const char* end);
1591 void _popObjectsBlob(
const char*& p,
const char* end);
1637 void syncPrimitive(
const Object& dst,
const Object& src);
1642 void syncPointer(
const Object& dst,
const Object& src);
1643 void syncMember(
const Member& dstMember,
const Member& srcMember);
1651 virtual void encode();
1653 ObjectPool m_allObjects;
1660 time_t m_timeCreated;
1661 time_t m_timeModified;
1684 #endif // LIBGIG_SERIALIZATION_H
bool operator<(const DataType &other) const
Smaller than comparison.
void setIntValue(Object &object, int64_t value)
Set new integer value for given integer object.
Member memberByUID(const UID &uid) const
Get the member of this Object with given unique identifier.
const RawData & rawData() const
Raw data of the original native C/C++ data.
uint32_t Version
Version number data type.
Object & objectByUID(const UID &uid)
Access object by its unique identifier.
const UIDChain & uidChain() const
Unique identifier chain of this Object.
bool operator==(const Member &other) const
Comparison for equalness.
bool isPointer() const
Whether this is reflecting a C/C++ pointer type.
Abstract reflection of a native C++ class/struct's member variable.
bool operator>(const DataType &other) const
Greater than comparison.
bool isEnum() const
Whether this is a C/C++ enum data type.
bool valueAsBool(const Object &object)
Get boolean value of object.
Archive()
Create an "empty" archive.
std::vector< UID > UIDChain
Chain of UIDs.
bool isSet() const
Whether this is a C++ Set<> object type.
void clear()
Clear content of this archive.
operation_t
Current activity of Archive object.
String name() const
Optional name of this archive.
int64_t valueAsInt(const Object &object)
Get integer value of object.
bool IsUnion(const T &data)
Check whether data is a C++ union type.
bool isString() const
Whether this is a C++ String data type.
bool isBool() const
Whether this is a boolean C/C++ data type.
void setBoolValue(Object &object, bool value)
Set new boolean value for given boolean object.
void serialize(const T *obj)
Initiate serialization.
String comment() const
Optional comments for this archive.
virtual String rawDataFormat() const
Name of the encoding format used by this Archive class.
bool isMap() const
Whether this is a C++ Map<> object type.
void setRealValue(Object &object, double value)
Set new floating point value for given floating point object.
void setNativeValueFromString(const String &s)
Cast from string to object's data type and assign value natively.
void serializeMember(const T_classType &nativeObject, const T_memberType &nativeMember, const char *memberName)
Serialize a native C/C++ member variable.
tm dateTimeCreated(time_base_t base=LOCAL_TIME) const
Date and time when this archive was initially created.
bool isValid() const
Check if this is a valid Object instance.
bool isVersionCompatibleTo(const Object &other) const
Check version compatibility between Object instances.
bool isModified() const
Whether this archive was modified.
std::vector< uint8_t > RawData
Raw data stream of serialized C++ objects.
bool isArray() const
Whether this is a C++ Array<> object type.
@ LOCAL_TIME
The time stamp relates to the machine's local time zone. Request a time stamp in local time if you wa...
bool operator==(const Object &other) const
Comparison for equalness.
Will be thrown whenever an error occurs during an serialization or deserialization process.
@ OPERATION_SERIALIZE
Archive is currently serializing.
void * ID
Abstract identifier for serialized C++ objects.
bool isInteger() const
Whether this is an integer C/C++ data type.
void operator<<(const T &obj)
Initiate serialization of your C++ objects.
String asLongDescr() const
Human readable long description for this data type.
void setName(String name)
Assign a name to this archive.
bool isSigned() const
Whether this is a signed integer C/C++ data type.
DataType()
Default constructor (as "invalid" DataType).
std::vector< Member > & members()
All members of the original native C/C++ struct or class instance.
Abstract reflection of some native serialized C/C++ data.
const RawData & rawData()
Raw data stream of this archive content.
std::string String
Textual string.
@ OPERATION_NONE
Archive is currently neither serializing, nor deserializing.
Unique identifier referring to one specific native C++ object, member, fundamental variable,...
void setAutoValue(Object &object, String value)
Automatically cast and assign appropriate value to object.
Version version() const
Version of original user defined C/C++ struct or class.
bool operator<(const Object &other) const
Smaller than comparison.
const DataType & type() const
C/C++ data type this Object is reflecting.
time_base_t
To which time zone a certain timing information relates to.
void setVersion(const T_classType &nativeObject, Version v)
Set current version number for your C++ class.
size_t size
Memory size of the object or member in question.
bool operator!=(const DataType &other) const
Comparison for inequalness.
int sequenceIndexOf(const Member &member) const
Serialization/deserialization sequence number of the requested member.
void PrintMessage()
Print exception message to stdout.
Destination container for serialization, and source container for deserialization.
const DataType & type() const
C/C++ Data type of this member.
Object()
Default constructor (for an "invalid" Object).
bool isPrimitive() const
Whether this is reflecting a fundamental C/C++ data type.
bool IsEnum(const T &data)
Check whether data is a C/C++ enum type.
time_t timeStampModified() const
Date and time when this archive was modified for the last time.
Version minVersion() const
Minimum version of original user defined C/C++ struct or class.
bool operator!=(const Object &other) const
Comparison for inequalness.
std::vector< T > Array
Array<> template.
ssize_t offset() const
Offset of member in its containing parent data structure.
bool operator==(const DataType &other) const
Comparison for equalness.
time_t timeStampCreated() const
Date and time when this archive was initially created.
Object & rootObject()
Root C++ object of this archive.
String valueAsString(const Object &object)
Get value of object as string.
void serializeHeapMember(const T_classType &nativeObject, const T_memberType &heapMember, const char *memberName)
Serialize a C/C++ member variable allocated on the heap.
double valueAsReal(const Object &object)
Get floating point value of object.
bool isClass() const
Whether this is reflecting a C/C++ struct or class type.
Member memberNamed(String name) const
Get the member of this Object with given name.
virtual void decode(const RawData &data)
Fill this archive with the given serialized raw data.
UID uid() const
Unique identifier of this member instance.
void setMinVersion(const T_classType &nativeObject, Version v)
Set a minimum version number for your C++ class.
@ UTC_TIME
The time stamp relates to "Greenwhich Mean Time" zone, also known as "Coordinated Universal Time"....
UID uid(int index=0) const
Unique identifier of this Object.
bool isReal() const
Whether this is a floating point based C/C++ data type.
bool isValid() const
Check if this is a valid DataType object.
size_t size() const
Returns native memory size of the respective C++ object or variable.
Abstract reflection of a native C++ data type.
void removeMember(Object &parent, const Member &member)
Remove a member variable from the given object.
Serialization / deserialization framework.
bool IsClass(const T &data)
Check whether data is a C/C++ struct or C++ class type.
void setComment(String comment)
Assign a comment to this archive.
std::set< T > Set
Set<> template.
void setEnumValue(Object &object, uint64_t value)
Set new value for given enum object.
Synchronizes 2 archives with each other.
void remove(const Object &obj)
Remove an object from this archive.
bool isValid() const
Check if this is a valid Member object.
const UID NO_UID
Reflects an invalid UID and behaves similar to NULL as invalid value for pointer types.
tm dateTimeModified(time_base_t base=LOCAL_TIME) const
Date and time when this archive was modified for the last time.
static DataType dataTypeOf(const T &data)
Construct a DataType object for the given native C++ data.
String customTypeName(bool demangle=false) const
The 1st user defined C/C++ data type name of this data type.
String customTypeName2(bool demangle=false) const
The 2nd user defined C/C++ data type name of this data type.
bool operator>(const Object &other) const
Greater than comparison.
void deserialize(T *obj)
Initiate deserialization.
std::map< T_key, T_value > Map
Map<> template.
@ OPERATION_DESERIALIZE
Archive is currently deserializing.
ID id
Abstract non-unique ID of the object or member in question.
bool operator<(const Member &other) const
Smaller than comparison.
bool operator!=(const Member &other) const
Comparison for inequalness.
static UID from(const T &obj)
Create an unique indentifier for a native C++ object/member/variable.
void setStringValue(Object &object, String value)
Set new textual string for given String object.
bool isValid() const
Check whether this is a valid unique identifier.
String baseTypeName() const
The base type name of this data type.
void operator>>(T &obj)
Initiate deserialization of your C++ objects.
Member()
Default constructor.
String name() const
Name of the member.
bool operator>(const Member &other) const
Greater than comparison.
std::vector< Member > membersOfType(const DataType &type) const
Get all members of this Object with given data type.