24#ifndef LIBGIG_SERIALIZATION_H
25#define LIBGIG_SERIALIZATION_H
45using ssize_t = SSIZE_T;
48#ifndef __has_extension
49# define __has_extension(x) 0
52#ifndef HAS_BUILTIN_TYPE_TRAITS
53# if __cplusplus >= 201103L
54# define HAS_BUILTIN_TYPE_TRAITS 1
55# elif ( __has_extension(is_class) && __has_extension(is_enum) )
56# define HAS_BUILTIN_TYPE_TRAITS 1
57# elif ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 ) )
58# define HAS_BUILTIN_TYPE_TRAITS 1
59# elif _MSC_VER >= 1400
60# define HAS_BUILTIN_TYPE_TRAITS 1
61# elif __INTEL_COMPILER >= 1100
62# define HAS_BUILTIN_TYPE_TRAITS 1
64# define HAS_BUILTIN_TYPE_TRAITS 0
68#if !HAS_BUILTIN_TYPE_TRAITS
69# include <tr1/type_traits>
70# define LIBGIG_IS_CLASS(type) std::tr1::__is_union_or_class<type>::value
72# define LIBGIG_IS_CLASS(type) __is_class(type)
182 template<
class T_key,
class T_value>
183 using Map = std::map<T_key,T_value>;
235 #if !HAS_BUILTIN_TYPE_TRAITS
236 return std::tr1::is_enum<T>::value;
254 #if !HAS_BUILTIN_TYPE_TRAITS
257 return __is_union(T);
272 #if !HAS_BUILTIN_TYPE_TRAITS
273 return std::tr1::__is_union_or_class<T>::value;
275 return __is_class(T);
299 template<
typename T>
inline
300 String toString(
const T& value) {
301 return std::to_string(value);
305 String toString(
const String& value) {
332 bool operator==(
const UID& other)
const {
return id == other.
id &&
size == other.
size; }
333 bool operator!=(
const UID& other)
const {
return id != other.id ||
size != other.size; }
334 bool operator<(
const UID& other)
const {
return id < other.id || (
id == other.id &&
size < other.size); }
335 bool operator>(
const UID& other)
const {
return id > other.id || (
id == other.id &&
size > other.size); }
346 return Resolver<T>::resolve(obj);
353 static UID resolve(
const T& obj) {
354 const UID uid = { (
ID) &obj,
sizeof(obj) };
361 struct Resolver<T*> {
362 static UID resolve(
const T*
const & obj) {
363 const UID uid = { (
ID) obj,
sizeof(*obj) };
409#if LIBGIG_SERIALIZATION_INTERNAL
412 static DataType _popDataTypeBlob(
const char*& p,
const char* end);
413 static Member _popMemberBlob(
const char*& p,
const char* end);
414 static Object _popObjectBlob(
const char*& p,
const char* end);
415 static void _popPrimitiveValue(
const char*& p,
const char* end,
Object& obj);
416 static String _primitiveObjectValueToString(
const Object& obj);
419 static T _primitiveObjectValueToNumber(
const Object& obj);
441 size_t size()
const {
return m_size; }
478 return Resolver<T>::resolve(data);
485 template<
typename T,
bool T_isPo
inter>
486 struct ResolverBase {
487 static DataType resolve(
const T& data) {
488 const std::type_info& type =
typeid(data);
489 const int sz =
sizeof(data);
494 if (type ==
typeid(int8_t))
return DataType(T_isPointer, sz,
"int8");
495 if (type ==
typeid(uint8_t))
return DataType(T_isPointer, sz,
"uint8");
496 if (type ==
typeid(int16_t))
return DataType(T_isPointer, sz,
"int16");
497 if (type ==
typeid(uint16_t))
return DataType(T_isPointer, sz,
"uint16");
498 if (type ==
typeid(int32_t))
return DataType(T_isPointer, sz,
"int32");
499 if (type ==
typeid(uint32_t))
return DataType(T_isPointer, sz,
"uint32");
500 if (type ==
typeid(int64_t))
return DataType(T_isPointer, sz,
"int64");
501 if (type ==
typeid(uint64_t))
return DataType(T_isPointer, sz,
"uint64");
502 if (type ==
typeid(
size_t)) {
503 if (sz == 1)
return DataType(T_isPointer, sz,
"uint8");
504 if (sz == 2)
return DataType(T_isPointer, sz,
"uint16");
505 if (sz == 4)
return DataType(T_isPointer, sz,
"uint32");
506 if (sz == 8)
return DataType(T_isPointer, sz,
"uint64");
509 if (type ==
typeid(ssize_t)) {
510 if (sz == 1)
return DataType(T_isPointer, sz,
"int8");
511 if (sz == 2)
return DataType(T_isPointer, sz,
"int16");
512 if (sz == 4)
return DataType(T_isPointer, sz,
"int32");
513 if (sz == 8)
return DataType(T_isPointer, sz,
"int64");
516 if (type ==
typeid(
bool))
return DataType(T_isPointer, sz,
"bool");
517 if (type ==
typeid(
float))
return DataType(T_isPointer, sz,
"real32");
518 if (type ==
typeid(
double))
return DataType(T_isPointer, sz,
"real64");
519 if (type ==
typeid(String))
return DataType(T_isPointer, sz,
"String");
521 if (
IsEnum(data))
return DataType(T_isPointer, sz,
"enum", rawCppTypeNameOf(data));
522 if (
IsUnion(data))
return DataType(T_isPointer, sz,
"union", rawCppTypeNameOf(data));
523 if (
IsClass(data))
return DataType(T_isPointer, sz,
"class", rawCppTypeNameOf(data));
531 struct Resolver : ResolverBase<T,false> {
532 static DataType resolve(
const T& data) {
533 return ResolverBase<T,false>::resolve(data);
539 struct Resolver<T*> : ResolverBase<T,true> {
540 static DataType resolve(
const T*& data) {
541 return ResolverBase<T,true>::resolve(*data);
547 struct Resolver<
Array<T>> {
548 static DataType resolve(
const Array<T>& data) {
549 const int sz =
sizeof(data);
551 return DataType(
false, sz,
"Array", rawCppTypeNameOf(unused));
557 struct Resolver<
Array<T>*> {
558 static DataType resolve(
const Array<T>*& data) {
559 const int sz =
sizeof(*data);
561 return DataType(
true, sz,
"Array", rawCppTypeNameOf(unused));
567 struct Resolver<
Set<T>> {
568 static DataType resolve(
const Set<T>& data) {
569 const int sz =
sizeof(data);
571 return DataType(
false, sz,
"Set", rawCppTypeNameOf(unused));
577 struct Resolver<
Set<T>*> {
578 static DataType resolve(
const Set<T>*& data) {
579 const int sz =
sizeof(*data);
581 return DataType(
true, sz,
"Set", rawCppTypeNameOf(unused));
586 template<
typename T_key,
typename T_value>
587 struct Resolver<
Map<T_key,T_value>> {
588 static DataType resolve(
const Map<T_key,T_value>& data) {
589 const int sz =
sizeof(data);
592 return DataType(
false, sz,
"Map", rawCppTypeNameOf(unused1),
593 rawCppTypeNameOf(unused2));
598 template<
typename T_key,
typename T_value>
599 struct Resolver<
Map<T_key,T_value>*> {
600 static DataType resolve(
const Map<T_key,T_value>*& data) {
601 const int sz =
sizeof(*data);
604 return DataType(
true, sz,
"Map", rawCppTypeNameOf(unused1),
605 rawCppTypeNameOf(unused2));
610 static String rawCppTypeNameOf(
const T& data) {
612 String name =
typeid(data).raw_name();
614 String name =
typeid(data).name();
622 String m_baseTypeName;
623 String m_customTypeName;
624 String m_customTypeName2;
628#if LIBGIG_SERIALIZATION_INTERNAL
629 friend DataType _popDataTypeBlob(
const char*& p,
const char* end);
631 friend class Archive;
680#if LIBGIG_SERIALIZATION_INTERNAL
681 friend Member _popMemberBlob(
const char*& p,
const char* end);
714 UID uid(
int index = 0)
const;
721 std::vector<Member>&
members();
722 const std::vector<Member>&
members()
const;
737 void remove(
const Member& member);
747 std::vector<Member> m_members;
748 std::function<void(
Object& dstObj,
const Object& srcObj,
void* syncer)> m_sync;
750#if LIBGIG_SERIALIZATION_INTERNAL
752 friend Object _popObjectBlob(
const char*& p,
const char* end);
753 friend void _popPrimitiveValue(
const char*& p,
const char* end,
Object& obj);
754 friend String _primitiveObjectValueToString(
const Object& obj);
757 friend T _primitiveObjectValueToNumber(
const Object& obj);
912 Archive(
const uint8_t* data,
size_t size);
943 m_allObjects.clear();
1022 template<
typename T>
1086 template<
typename T_
classType,
typename T_memberType>
1087 void serializeMember(
const T_classType& nativeObject,
const T_memberType& nativeMember,
const char* memberName) {
1088 const ssize_t offset =
1089 ((
const uint8_t*)(
const void*)&nativeMember) -
1090 ((
const uint8_t*)(
const void*)&nativeObject);
1091 const UIDChain uids = UIDChainResolver<T_memberType>(nativeMember);
1093 const Member member(memberName, uids[0], offset, type);
1095 Object& parent = m_allObjects[parentUID];
1097 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1099 parent =
Object(uids, type);
1101 parent.
members().push_back(member);
1102 const Object obj(uids, type);
1103 const bool bExistsAlready = m_allObjects.count(uids[0]);
1104 const bool isValidObject = obj;
1105 const bool bExistingObjectIsInvalid = !m_allObjects[uids[0]];
1106 if (!bExistsAlready || (bExistingObjectIsInvalid && isValidObject)) {
1107 m_allObjects[uids[0]] = obj;
1110 SerializationRecursion<T_memberType>::serializeObject(
this, nativeMember);
1144 template<
typename T_
classType,
typename T_memberType>
1145 void serializeHeapMember(
const T_classType& nativeObject,
const T_memberType& heapMember,
const char* memberName) {
1146 const ssize_t offset = -1;
1147 const UIDChain uids = UIDChainResolver<T_memberType>(heapMember);
1149 const Member member(memberName, uids[0], offset, type);
1151 Object& parent = m_allObjects[parentUID];
1153 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1155 parent =
Object(uids, type);
1157 parent.
members().push_back(member);
1158 const Object obj(uids, type);
1159 const bool bExistsAlready = m_allObjects.count(uids[0]);
1160 const bool isValidObject = obj;
1161 const bool bExistingObjectIsInvalid = !m_allObjects[uids[0]];
1162 if (!bExistsAlready || (bExistingObjectIsInvalid && isValidObject)) {
1163 m_allObjects[uids[0]] = obj;
1166 SerializationRecursion<T_memberType>::serializeObject(
this, heapMember);
1249 template<
typename T_
classType>
1252 Object& obj = m_allObjects[uid];
1254 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1256 obj =
Object(uids, type);
1290 template<
typename T_
classType>
1293 Object& obj = m_allObjects[uid];
1295 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1297 obj =
Object(uids, type);
1303 virtual void decode(
const uint8_t* data,
size_t size);
1334 template<
typename T>
1335 class UIDChainResolver {
1337 UIDChainResolver(
const T& data) {
1341 operator UIDChain()
const {
return m_uid; }
1342 UIDChain operator()()
const {
return m_uid; }
1348 template<
typename T>
1349 class UIDChainResolver<T*> {
1351 UIDChainResolver(
const T*& data) {
1352 const UID uids[2] = {
1353 { &data,
sizeof(data) },
1354 { data,
sizeof(*data) }
1356 m_uid.push_back(uids[0]);
1357 m_uid.push_back(uids[1]);
1360 operator UIDChain()
const {
return m_uid; }
1361 UIDChain operator()()
const {
return m_uid; }
1367 template<
typename T,
bool T_isRecursive>
1368 struct SerializationRecursionImpl {
1369 static void serializeObject(
Archive* archive,
const T& obj) {
1375 template<
typename T,
bool T_isRecursive>
1376 struct SerializationRecursionImpl<T*,T_isRecursive> {
1377 static void serializeObject(
Archive* archive,
const T*& obj) {
1379 const_cast<T*&
>(obj)->
serialize(archive);
1384 template<
typename T>
1385 struct SerializationRecursionImpl<T,false> {
1386 static void serializeObject(
Archive* archive,
const T& obj) {}
1390 template<
typename T>
1391 struct SerializationRecursionImpl<T*,
false> {
1392 static void serializeObject(
Archive* archive,
const T*& obj) {}
1396 template<
bool T_isRecursive>
1397 struct SerializationRecursionImpl<String,T_isRecursive> {
1398 static void serializeObject(
Archive* archive,
const String& obj) {}
1402 template<
bool T_isRecursive>
1403 struct SerializationRecursionImpl<String*,T_isRecursive> {
1404 static void serializeObject(
Archive* archive,
const String*& obj) {}
1408 template<
typename T,
bool T_isRecursive>
1409 struct SerializationRecursionImpl<
Array<T>,T_isRecursive> {
1410 static void serializeObject(
Archive* archive,
const Array<T>& obj) {
1411 const UIDChain uids = UIDChainResolver<Array<T>>(obj);
1412 const Object&
object = archive->objectByUID(uids[0]);
1414 for (
size_t i = 0; i < obj.size(); ++i) {
1415 archive->serializeHeapMember(
1416 obj, obj[i], (
"[" + toString(i) +
"]").c_str()
1420 const_cast<Object&
>(object).m_sync =
1421 [&obj,archive](Object& dstObj,
const Object& srcObj,
1424 const size_t n = srcObj.members().size();
1425 const_cast<Array<T>&
>(obj).resize(n);
1426 for (
size_t i = 0; i < obj.size(); ++i) {
1427 archive->serializeHeapMember(
1428 obj, obj[i], (
"[" + toString(i) +
"]").c_str()
1433 dstObj = archive->objectByUID(dstObj.uid());
1434 for (
size_t i = 0; i < obj.size(); ++i) {
1435 String
name =
"[" + toString(i) +
"]";
1436 Member srcMember = srcObj.memberNamed(
name);
1437 Member dstMember = dstObj.memberNamed(
name);
1438 ((Syncer*)syncer)->syncMember(dstMember, srcMember);
1446 template<
typename T,
bool T_isRecursive>
1447 struct SerializationRecursionImpl<
Array<T>*,T_isRecursive> {
1448 static void serializeObject(
Archive* archive,
const Array<T>*& obj) {
1450 SerializationRecursionImpl<Array<T>,T_isRecursive>::serializeObject(
1457 template<
typename T,
bool T_isRecursive>
1458 struct SerializationRecursionImpl<
Set<T>,T_isRecursive> {
1459 static void serializeObject(
Archive* archive,
const Set<T>& obj) {
1460 const UIDChain uids = UIDChainResolver<Set<T>>(obj);
1461 const Object&
object = archive->objectByUID(uids[0]);
1463 for (
const T& key : obj) {
1464 archive->serializeHeapMember(
1465 obj, key, (
"[" + toString(key) +
"]").c_str()
1469 const_cast<Object&
>(object).m_sync =
1470 [&obj,archive](Object& dstObj,
const Object& srcObj,
1473 const size_t n = srcObj.members().size();
1474 const_cast<Set<T>&
>(obj).
clear();
1475 for (
size_t i = 0; i < n; ++i) {
1476 const Member& member = srcObj.members()[i];
1477 String
name = member.name();
1478 if (
name.length() < 2 ||
name[0] !=
'[' ||
1479 *
name.rbegin() !=
']')
continue;
1482 const UIDChain uids = UIDChainResolver<T>(key);
1484 Object tmpObj(uids, type);
1485 tmpObj.setNativeValueFromString(
name);
1486 const_cast<Set<T>&
>(obj).insert(key);
1488 for (
const T& key : obj) {
1489 archive->serializeHeapMember(
1490 obj, key, (
"[" + toString(key) +
"]").c_str()
1495 dstObj = archive->objectByUID(dstObj.uid());
1502 template<
typename T,
bool T_isRecursive>
1503 struct SerializationRecursionImpl<
Set<T>*,T_isRecursive> {
1504 static void serializeObject(
Archive* archive,
const Set<T>*& obj) {
1506 SerializationRecursionImpl<Set<T>,T_isRecursive>::serializeObject(
1513 template<
typename T_key,
typename T_value,
bool T_isRecursive>
1514 struct SerializationRecursionImpl<
Map<T_key,T_value>,T_isRecursive> {
1515 static void serializeObject(
Archive* archive,
const Map<T_key,T_value>& obj) {
1516 const UIDChain uids = UIDChainResolver<Map<T_key,T_value>>(obj);
1517 const Object&
object = archive->objectByUID(uids[0]);
1519 for (
const auto& it : obj) {
1520 archive->serializeHeapMember(
1521 obj, it.second, (
"[" + toString(it.first) +
"]").c_str()
1525 const_cast<Object&
>(object).m_sync =
1526 [&obj,archive](Object& dstObj,
const Object& srcObj,
1529 const size_t n = srcObj.members().size();
1530 const_cast<Map<T_key,T_value>&
>(obj).
clear();
1531 for (
size_t i = 0; i < n; ++i) {
1532 const Member& member = srcObj.members()[i];
1533 String
name = member.name();
1534 if (
name.length() < 2 ||
name[0] !=
'[' ||
1535 *
name.rbegin() !=
']')
continue;
1538 const UIDChain uids = UIDChainResolver<T_key>(key);
1540 Object tmpObj(uids, type);
1541 tmpObj.setNativeValueFromString(
name);
1542 const_cast<Map<T_key,T_value>&
>(obj)[key] = T_value();
1544 for (
const auto& it : obj) {
1545 archive->serializeHeapMember(
1546 obj, it.second, (
"[" + toString(it.first) +
"]").c_str()
1551 dstObj = archive->objectByUID(dstObj.uid());
1552 for (
size_t i = 0; i < n; ++i) {
1553 Member srcMember = srcObj.members()[i];
1554 Member dstMember = dstObj.memberNamed(srcMember.name());
1555 ((Syncer*)syncer)->syncMember(dstMember, srcMember);
1563 template<
typename T_key,
typename T_value,
bool T_isRecursive>
1564 struct SerializationRecursionImpl<
Map<T_key,T_value>*,T_isRecursive> {
1565 static void serializeObject(
Archive* archive,
const Map<T_key,T_value>*& obj) {
1567 SerializationRecursionImpl<Map<T_key,T_value>,T_isRecursive>::serializeObject(
1574 template<
typename T>
1575 struct SerializationRecursion : SerializationRecursionImpl<T, LIBGIG_IS_CLASS(T)> {
1578 class ObjectPool :
public std::map<UID,Object> {
1581 Object& operator[](
const UID& k) {
1582 static Object invalid;
1587 return std::map<UID,Object>::operator[](k);
1591 friend String _encode(
const ObjectPool& objects);
1594 String _encodeRootBlob();
1595 void _popRootBlob(
const char*& p,
const char* end);
1596 void _popObjectsBlob(
const char*& p,
const char* end);
1642 void syncPrimitive(
const Object& dst,
const Object& src);
1647 void syncPointer(
const Object& dst,
const Object& src);
1648 void syncMember(
const Member& dstMember,
const Member& srcMember);
1656 virtual void encode();
1658 ObjectPool m_allObjects;
1665 time_t m_timeCreated;
1666 time_t m_timeModified;
Synchronizes 2 archives with each other.
Destination container for serialization, and source container for deserialization.
void setStringValue(Object &object, String value)
Set new textual string for given String object.
void setRealValue(Object &object, double value)
Set new floating point value for given floating point object.
void serializeMember(const T_classType &nativeObject, const T_memberType &nativeMember, const char *memberName)
Serialize a native C/C++ member variable.
void setMinVersion(const T_classType &nativeObject, Version v)
Set a minimum version number for your C++ class.
void setName(String name)
Assign a name to this archive.
void serialize(const T *obj)
Initiate serialization.
time_t timeStampCreated() const
Date and time when this archive was initially created.
void setBoolValue(Object &object, bool value)
Set new boolean value for given boolean object.
void clear()
Clear content of this archive.
double valueAsReal(const Object &object)
Get floating point value of object.
time_t timeStampModified() const
Date and time when this archive was modified for the last time.
virtual String rawDataFormat() const
Name of the encoding format used by this Archive class.
void setIntValue(Object &object, int64_t value)
Set new integer value for given integer object.
operation_t
Current activity of Archive object.
@ OPERATION_DESERIALIZE
Archive is currently deserializing.
@ OPERATION_NONE
Archive is currently neither serializing, nor deserializing.
@ OPERATION_SERIALIZE
Archive is currently serializing.
const RawData & rawData()
Raw data stream of this archive content.
bool isModified() const
Whether this archive was modified.
void deserialize(T *obj)
Initiate deserialization.
virtual void decode(const RawData &data)
Fill this archive with the given serialized raw data.
tm dateTimeCreated(time_base_t base=LOCAL_TIME) const
Date and time when this archive was initially created.
Object & rootObject()
Root C++ object of this archive.
Object & objectByUID(const UID &uid)
Access object by its unique identifier.
String valueAsString(const Object &object)
Get value of object as string.
int64_t valueAsInt(const Object &object)
Get integer value of object.
void setVersion(const T_classType &nativeObject, Version v)
Set current version number for your C++ class.
void removeMember(Object &parent, const Member &member)
Remove a member variable from the given object.
void remove(const Object &obj)
Remove an object from this archive.
bool valueAsBool(const Object &object)
Get boolean value of object.
void setEnumValue(Object &object, uint64_t value)
Set new value for given enum object.
void serializeHeapMember(const T_classType &nativeObject, const T_memberType &heapMember, const char *memberName)
Serialize a C/C++ member variable allocated on the heap.
void operator<<(const T &obj)
Initiate serialization of your C++ objects.
void setComment(String comment)
Assign a comment to this archive.
Archive()
Create an "empty" archive.
String name() const
Optional name of this archive.
void setAutoValue(Object &object, String value)
Automatically cast and assign appropriate value to object.
String comment() const
Optional comments for this archive.
void operator>>(T &obj)
Initiate deserialization of your C++ objects.
tm dateTimeModified(time_base_t base=LOCAL_TIME) const
Date and time when this archive was modified for the last time.
Abstract reflection of a native C++ data type.
bool isPrimitive() const
Whether this is reflecting a fundamental C/C++ data type.
bool isSet() const
Whether this is a C++ Set<> object type.
bool isPointer() const
Whether this is reflecting a C/C++ pointer type.
bool isSigned() const
Whether this is a signed integer C/C++ data type.
String baseTypeName() const
The base type name of this data type.
bool operator!=(const DataType &other) const
Comparison for inequalness.
bool isReal() const
Whether this is a floating point based C/C++ data type.
DataType()
Default constructor (as "invalid" DataType).
String asLongDescr() const
Human readable long description for this data type.
bool isBool() const
Whether this is a boolean C/C++ data type.
bool isMap() const
Whether this is a C++ Map<> object type.
bool isValid() const
Check if this is a valid DataType object.
bool isArray() const
Whether this is a C++ Array<> object type.
bool operator>(const DataType &other) const
Greater than comparison.
bool isEnum() const
Whether this is a C/C++ enum data type.
bool operator<(const DataType &other) const
Smaller than comparison.
String customTypeName2(bool demangle=false) const
The 2nd user defined C/C++ data type name of this data type.
bool isClass() const
Whether this is reflecting a C/C++ struct or class type.
bool isInteger() const
Whether this is an integer C/C++ data type.
bool operator==(const DataType &other) const
Comparison for equalness.
static DataType dataTypeOf(const T &data)
Construct a DataType object for the given native C++ data.
bool isString() const
Whether this is a C++ String data type.
String customTypeName(bool demangle=false) const
The 1st user defined C/C++ data type name of this data type.
size_t size() const
Returns native memory size of the respective C++ object or variable.
Will be thrown whenever an error occurs during an serialization or deserialization process.
void PrintMessage()
Print exception message to stdout.
Abstract reflection of a native C++ class/struct's member variable.
Member()
Default constructor.
bool operator!=(const Member &other) const
Comparison for inequalness.
bool operator<(const Member &other) const
Smaller than comparison.
bool operator>(const Member &other) const
Greater than comparison.
ssize_t offset() const
Offset of member in its containing parent data structure.
String name() const
Name of the member.
bool operator==(const Member &other) const
Comparison for equalness.
const DataType & type() const
C/C++ Data type of this member.
bool isValid() const
Check if this is a valid Member object.
UID uid() const
Unique identifier of this member instance.
Abstract reflection of some native serialized C/C++ data.
bool isValid() const
Check if this is a valid Object instance.
Member memberNamed(String name) const
Get the member of this Object with given name.
Version version() const
Version of original user defined C/C++ struct or class.
UID uid(int index=0) const
Unique identifier of this Object.
const UIDChain & uidChain() const
Unique identifier chain of this Object.
const RawData & rawData() const
Raw data of the original native C/C++ data.
bool operator<(const Object &other) const
Smaller than comparison.
Object()
Default constructor (for an "invalid" Object).
Member memberByUID(const UID &uid) const
Get the member of this Object with given unique identifier.
std::vector< Member > membersOfType(const DataType &type) const
Get all members of this Object with given data type.
int sequenceIndexOf(const Member &member) const
Serialization/deserialization sequence number of the requested member.
void setNativeValueFromString(const String &s)
Cast from string to object's data type and assign value natively.
bool operator!=(const Object &other) const
Comparison for inequalness.
bool operator>(const Object &other) const
Greater than comparison.
std::vector< Member > & members()
All members of the original native C/C++ struct or class instance.
const DataType & type() const
C/C++ data type this Object is reflecting.
bool isVersionCompatibleTo(const Object &other) const
Check version compatibility between Object instances.
Version minVersion() const
Minimum version of original user defined C/C++ struct or class.
bool operator==(const Object &other) const
Comparison for equalness.
Unique identifier referring to one specific native C++ object, member, fundamental variable,...
static UID from(const T &obj)
Create an unique indentifier for a native C++ object/member/variable.
bool isValid() const
Check whether this is a valid unique identifier.
size_t size
Memory size of the object or member in question.
ID id
Abstract non-unique ID of the object or member in question.
Serialization / deserialization framework.
bool IsUnion(const T &data)
Check whether data is a C++ union type.
void * ID
Abstract identifier for serialized C++ objects.
std::vector< T > Array
Array<> template.
const UID NO_UID
Reflects an invalid UID and behaves similar to NULL as invalid value for pointer types.
bool IsEnum(const T &data)
Check whether data is a C/C++ enum type.
bool IsClass(const T &data)
Check whether data is a C/C++ struct or C++ class type.
std::set< T > Set
Set<> template.
std::string String
Textual string.
std::map< T_key, T_value > Map
Map<> template.
uint32_t Version
Version number data type.
std::vector< UID > UIDChain
Chain of UIDs.
std::vector< uint8_t > RawData
Raw data stream of serialized C++ objects.
time_base_t
To which time zone a certain timing information relates to.
@ UTC_TIME
The time stamp relates to "Greenwhich Mean Time" zone, also known as "Coordinated Universal Time"....
@ LOCAL_TIME
The time stamp relates to the machine's local time zone. Request a time stamp in local time if you wa...