24 #ifndef LIBGIG_SERIALIZATION_H
25 #define LIBGIG_SERIALIZATION_H
45 #ifndef __has_extension
46 # define __has_extension(x) 0
49 #ifndef HAS_BUILTIN_TYPE_TRAITS
50 # if __cplusplus >= 201103L
51 # define HAS_BUILTIN_TYPE_TRAITS 1
52 # elif ( __has_extension(is_class) && __has_extension(is_enum) )
53 # define HAS_BUILTIN_TYPE_TRAITS 1
54 # elif ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 ) )
55 # define HAS_BUILTIN_TYPE_TRAITS 1
56 # elif _MSC_VER >= 1400
57 # define HAS_BUILTIN_TYPE_TRAITS 1
58 # elif __INTEL_COMPILER >= 1100
59 # define HAS_BUILTIN_TYPE_TRAITS 1
61 # define HAS_BUILTIN_TYPE_TRAITS 0
65 #if !HAS_BUILTIN_TYPE_TRAITS
66 # include <tr1/type_traits>
67 # define LIBGIG_IS_CLASS(type) std::tr1::__is_union_or_class<type>::value
69 # define LIBGIG_IS_CLASS(type) __is_class(type)
179 template<
class T_key,
class T_value>
180 using Map = std::map<T_key,T_value>;
232 #if !HAS_BUILTIN_TYPE_TRAITS
233 return std::tr1::is_enum<T>::value;
251 #if !HAS_BUILTIN_TYPE_TRAITS
254 return __is_union(T);
269 #if !HAS_BUILTIN_TYPE_TRAITS
270 return std::tr1::__is_union_or_class<T>::value;
272 return __is_class(T);
296 template<
typename T>
inline
297 String toString(
const T& value) {
298 return std::to_string(value);
302 String toString(
const String& value) {
329 bool operator==(
const UID& other)
const {
return id == other.
id &&
size == other.
size; }
330 bool operator!=(
const UID& other)
const {
return id != other.id ||
size != other.size; }
331 bool operator<(
const UID& other)
const {
return id < other.id || (
id == other.id &&
size < other.size); }
332 bool operator>(
const UID& other)
const {
return id > other.id || (
id == other.id &&
size > other.size); }
343 return Resolver<T>::resolve(obj);
350 static UID resolve(
const T& obj) {
351 const UID uid = { (
ID) &obj,
sizeof(obj) };
358 struct Resolver<T*> {
359 static UID resolve(
const T*
const & obj) {
360 const UID uid = { (
ID) obj,
sizeof(*obj) };
406 #if LIBGIG_SERIALIZATION_INTERNAL
409 static DataType _popDataTypeBlob(
const char*& p,
const char* end);
410 static Member _popMemberBlob(
const char*& p,
const char* end);
411 static Object _popObjectBlob(
const char*& p,
const char* end);
412 static void _popPrimitiveValue(
const char*& p,
const char* end,
Object& obj);
413 static String _primitiveObjectValueToString(
const Object& obj);
416 static T _primitiveObjectValueToNumber(
const Object& obj);
438 size_t size()
const {
return m_size; }
475 return Resolver<T>::resolve(data);
482 template<
typename T,
bool T_isPo
inter>
483 struct ResolverBase {
484 static DataType resolve(
const T& data) {
485 const std::type_info& type =
typeid(data);
486 const int sz =
sizeof(data);
491 if (type ==
typeid(int8_t))
return DataType(T_isPointer, sz,
"int8");
492 if (type ==
typeid(uint8_t))
return DataType(T_isPointer, sz,
"uint8");
493 if (type ==
typeid(int16_t))
return DataType(T_isPointer, sz,
"int16");
494 if (type ==
typeid(uint16_t))
return DataType(T_isPointer, sz,
"uint16");
495 if (type ==
typeid(int32_t))
return DataType(T_isPointer, sz,
"int32");
496 if (type ==
typeid(uint32_t))
return DataType(T_isPointer, sz,
"uint32");
497 if (type ==
typeid(int64_t))
return DataType(T_isPointer, sz,
"int64");
498 if (type ==
typeid(uint64_t))
return DataType(T_isPointer, sz,
"uint64");
499 if (type ==
typeid(
size_t)) {
500 if (sz == 1)
return DataType(T_isPointer, sz,
"uint8");
501 if (sz == 2)
return DataType(T_isPointer, sz,
"uint16");
502 if (sz == 4)
return DataType(T_isPointer, sz,
"uint32");
503 if (sz == 8)
return DataType(T_isPointer, sz,
"uint64");
506 if (type ==
typeid(ssize_t)) {
507 if (sz == 1)
return DataType(T_isPointer, sz,
"int8");
508 if (sz == 2)
return DataType(T_isPointer, sz,
"int16");
509 if (sz == 4)
return DataType(T_isPointer, sz,
"int32");
510 if (sz == 8)
return DataType(T_isPointer, sz,
"int64");
513 if (type ==
typeid(
bool))
return DataType(T_isPointer, sz,
"bool");
514 if (type ==
typeid(
float))
return DataType(T_isPointer, sz,
"real32");
515 if (type ==
typeid(
double))
return DataType(T_isPointer, sz,
"real64");
516 if (type ==
typeid(String))
return DataType(T_isPointer, sz,
"String");
518 if (
IsEnum(data))
return DataType(T_isPointer, sz,
"enum", rawCppTypeNameOf(data));
519 if (
IsUnion(data))
return DataType(T_isPointer, sz,
"union", rawCppTypeNameOf(data));
520 if (
IsClass(data))
return DataType(T_isPointer, sz,
"class", rawCppTypeNameOf(data));
528 struct Resolver : ResolverBase<T,false> {
529 static DataType resolve(
const T& data) {
530 return ResolverBase<T,false>::resolve(data);
536 struct Resolver<T*> : ResolverBase<T,true> {
537 static DataType resolve(
const T*& data) {
538 return ResolverBase<T,true>::resolve(*data);
544 struct Resolver<
Array<T>> {
545 static DataType resolve(
const Array<T>& data) {
546 const int sz =
sizeof(data);
548 return DataType(
false, sz,
"Array", rawCppTypeNameOf(unused));
554 struct Resolver<
Array<T>*> {
555 static DataType resolve(
const Array<T>*& data) {
556 const int sz =
sizeof(*data);
558 return DataType(
true, sz,
"Array", rawCppTypeNameOf(unused));
564 struct Resolver<
Set<T>> {
565 static DataType resolve(
const Set<T>& data) {
566 const int sz =
sizeof(data);
568 return DataType(
false, sz,
"Set", rawCppTypeNameOf(unused));
574 struct Resolver<
Set<T>*> {
575 static DataType resolve(
const Set<T>*& data) {
576 const int sz =
sizeof(*data);
578 return DataType(
true, sz,
"Set", rawCppTypeNameOf(unused));
583 template<
typename T_key,
typename T_value>
584 struct Resolver<
Map<T_key,T_value>> {
585 static DataType resolve(
const Map<T_key,T_value>& data) {
586 const int sz =
sizeof(data);
589 return DataType(
false, sz,
"Map", rawCppTypeNameOf(unused1),
590 rawCppTypeNameOf(unused2));
595 template<
typename T_key,
typename T_value>
596 struct Resolver<
Map<T_key,T_value>*> {
597 static DataType resolve(
const Map<T_key,T_value>*& data) {
598 const int sz =
sizeof(*data);
601 return DataType(
true, sz,
"Map", rawCppTypeNameOf(unused1),
602 rawCppTypeNameOf(unused2));
607 static String rawCppTypeNameOf(
const T& data) {
609 String name =
typeid(data).raw_name();
611 String name =
typeid(data).name();
619 String m_baseTypeName;
620 String m_customTypeName;
621 String m_customTypeName2;
625 #if LIBGIG_SERIALIZATION_INTERNAL
626 friend DataType _popDataTypeBlob(
const char*& p,
const char* end);
628 friend class Archive;
677 #if LIBGIG_SERIALIZATION_INTERNAL
678 friend Member _popMemberBlob(
const char*& p,
const char* end);
711 UID uid(
int index = 0)
const;
718 std::vector<Member>&
members();
719 const std::vector<Member>&
members()
const;
734 void remove(
const Member& member);
744 std::vector<Member> m_members;
745 std::function<void(
Object& dstObj,
const Object& srcObj,
void* syncer)> m_sync;
747 #if LIBGIG_SERIALIZATION_INTERNAL
749 friend Object _popObjectBlob(
const char*& p,
const char* end);
750 friend void _popPrimitiveValue(
const char*& p,
const char* end,
Object& obj);
751 friend String _primitiveObjectValueToString(
const Object& obj);
754 friend T _primitiveObjectValueToNumber(
const Object& obj);
909 Archive(
const uint8_t* data,
size_t size);
940 m_allObjects.clear();
1019 template<
typename T>
1083 template<
typename T_
classType,
typename T_memberType>
1084 void serializeMember(
const T_classType& nativeObject,
const T_memberType& nativeMember,
const char* memberName) {
1085 const ssize_t offset =
1086 ((
const uint8_t*)(
const void*)&nativeMember) -
1087 ((
const uint8_t*)(
const void*)&nativeObject);
1088 const UIDChain uids = UIDChainResolver<T_memberType>(nativeMember);
1090 const Member member(memberName, uids[0], offset, type);
1092 Object& parent = m_allObjects[parentUID];
1094 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1096 parent =
Object(uids, type);
1098 parent.
members().push_back(member);
1099 const Object obj(uids, type);
1100 const bool bExistsAlready = m_allObjects.count(uids[0]);
1101 const bool isValidObject = obj;
1102 const bool bExistingObjectIsInvalid = !m_allObjects[uids[0]];
1103 if (!bExistsAlready || (bExistingObjectIsInvalid && isValidObject)) {
1104 m_allObjects[uids[0]] = obj;
1107 SerializationRecursion<T_memberType>::serializeObject(
this, nativeMember);
1141 template<
typename T_
classType,
typename T_memberType>
1142 void serializeHeapMember(
const T_classType& nativeObject,
const T_memberType& heapMember,
const char* memberName) {
1143 const ssize_t offset = -1;
1144 const UIDChain uids = UIDChainResolver<T_memberType>(heapMember);
1146 const Member member(memberName, uids[0], offset, type);
1148 Object& parent = m_allObjects[parentUID];
1150 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1152 parent =
Object(uids, type);
1154 parent.
members().push_back(member);
1155 const Object obj(uids, type);
1156 const bool bExistsAlready = m_allObjects.count(uids[0]);
1157 const bool isValidObject = obj;
1158 const bool bExistingObjectIsInvalid = !m_allObjects[uids[0]];
1159 if (!bExistsAlready || (bExistingObjectIsInvalid && isValidObject)) {
1160 m_allObjects[uids[0]] = obj;
1163 SerializationRecursion<T_memberType>::serializeObject(
this, heapMember);
1246 template<
typename T_
classType>
1249 Object& obj = m_allObjects[uid];
1251 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1253 obj =
Object(uids, type);
1287 template<
typename T_
classType>
1290 Object& obj = m_allObjects[uid];
1292 const UIDChain uids = UIDChainResolver<T_classType>(nativeObject);
1294 obj =
Object(uids, type);
1300 virtual void decode(
const uint8_t* data,
size_t size);
1331 template<
typename T>
1332 class UIDChainResolver {
1334 UIDChainResolver(
const T& data) {
1338 operator UIDChain()
const {
return m_uid; }
1339 UIDChain operator()()
const {
return m_uid; }
1345 template<
typename T>
1346 class UIDChainResolver<T*> {
1348 UIDChainResolver(
const T*& data) {
1349 const UID uids[2] = {
1350 { &data,
sizeof(data) },
1351 { data,
sizeof(*data) }
1353 m_uid.push_back(uids[0]);
1354 m_uid.push_back(uids[1]);
1357 operator UIDChain()
const {
return m_uid; }
1358 UIDChain operator()()
const {
return m_uid; }
1364 template<
typename T,
bool T_isRecursive>
1365 struct SerializationRecursionImpl {
1366 static void serializeObject(
Archive* archive,
const T& obj) {
1372 template<
typename T,
bool T_isRecursive>
1373 struct SerializationRecursionImpl<T*,T_isRecursive> {
1374 static void serializeObject(
Archive* archive,
const T*& obj) {
1376 const_cast<T*&
>(obj)->
serialize(archive);
1381 template<
typename T>
1382 struct SerializationRecursionImpl<T,false> {
1383 static void serializeObject(
Archive* archive,
const T& obj) {}
1387 template<
typename T>
1388 struct SerializationRecursionImpl<T*,
false> {
1389 static void serializeObject(
Archive* archive,
const T*& obj) {}
1393 template<
bool T_isRecursive>
1394 struct SerializationRecursionImpl<String,T_isRecursive> {
1395 static void serializeObject(
Archive* archive,
const String& obj) {}
1399 template<
bool T_isRecursive>
1400 struct SerializationRecursionImpl<String*,T_isRecursive> {
1401 static void serializeObject(
Archive* archive,
const String*& obj) {}
1405 template<
typename T,
bool T_isRecursive>
1406 struct SerializationRecursionImpl<
Array<T>,T_isRecursive> {
1407 static void serializeObject(
Archive* archive,
const Array<T>& obj) {
1408 const UIDChain uids = UIDChainResolver<Array<T>>(obj);
1409 const Object&
object = archive->objectByUID(uids[0]);
1411 for (
size_t i = 0; i < obj.size(); ++i) {
1412 archive->serializeHeapMember(
1413 obj, obj[i], (
"[" + toString(i) +
"]").c_str()
1417 const_cast<Object&
>(object).m_sync =
1418 [&obj,archive](Object& dstObj,
const Object& srcObj,
1421 const size_t n = srcObj.members().size();
1422 const_cast<Array<T>&
>(obj).resize(n);
1423 for (
size_t i = 0; i < obj.size(); ++i) {
1424 archive->serializeHeapMember(
1425 obj, obj[i], (
"[" + toString(i) +
"]").c_str()
1430 dstObj = archive->objectByUID(dstObj.uid());
1431 for (
size_t i = 0; i < obj.size(); ++i) {
1432 String
name =
"[" + toString(i) +
"]";
1433 Member srcMember = srcObj.memberNamed(
name);
1434 Member dstMember = dstObj.memberNamed(
name);
1435 ((Syncer*)syncer)->syncMember(dstMember, srcMember);
1443 template<
typename T,
bool T_isRecursive>
1444 struct SerializationRecursionImpl<
Array<T>*,T_isRecursive> {
1445 static void serializeObject(
Archive* archive,
const Array<T>*& obj) {
1447 SerializationRecursionImpl<Array<T>,T_isRecursive>::serializeObject(
1454 template<
typename T,
bool T_isRecursive>
1455 struct SerializationRecursionImpl<
Set<T>,T_isRecursive> {
1456 static void serializeObject(
Archive* archive,
const Set<T>& obj) {
1457 const UIDChain uids = UIDChainResolver<Set<T>>(obj);
1458 const Object&
object = archive->objectByUID(uids[0]);
1460 for (
const T& key : obj) {
1461 archive->serializeHeapMember(
1462 obj, key, (
"[" + toString(key) +
"]").c_str()
1466 const_cast<Object&
>(object).m_sync =
1467 [&obj,archive](Object& dstObj,
const Object& srcObj,
1470 const size_t n = srcObj.members().size();
1471 const_cast<Set<T>&
>(obj).
clear();
1472 for (
size_t i = 0; i < n; ++i) {
1473 const Member& member = srcObj.members()[i];
1474 String
name = member.name();
1475 if (
name.length() < 2 ||
name[0] !=
'[' ||
1476 *
name.rbegin() !=
']')
continue;
1479 const UIDChain uids = UIDChainResolver<T>(key);
1481 Object tmpObj(uids, type);
1482 tmpObj.setNativeValueFromString(
name);
1483 const_cast<Set<T>&
>(obj).insert(key);
1485 for (
const T& key : obj) {
1486 archive->serializeHeapMember(
1487 obj, key, (
"[" + toString(key) +
"]").c_str()
1492 dstObj = archive->objectByUID(dstObj.uid());
1499 template<
typename T,
bool T_isRecursive>
1500 struct SerializationRecursionImpl<
Set<T>*,T_isRecursive> {
1501 static void serializeObject(
Archive* archive,
const Set<T>*& obj) {
1503 SerializationRecursionImpl<Set<T>,T_isRecursive>::serializeObject(
1510 template<
typename T_key,
typename T_value,
bool T_isRecursive>
1511 struct SerializationRecursionImpl<
Map<T_key,T_value>,T_isRecursive> {
1512 static void serializeObject(
Archive* archive,
const Map<T_key,T_value>& obj) {
1513 const UIDChain uids = UIDChainResolver<Map<T_key,T_value>>(obj);
1514 const Object&
object = archive->objectByUID(uids[0]);
1516 for (
const auto& it : obj) {
1517 archive->serializeHeapMember(
1518 obj, it.second, (
"[" + toString(it.first) +
"]").c_str()
1522 const_cast<Object&
>(object).m_sync =
1523 [&obj,archive](Object& dstObj,
const Object& srcObj,
1526 const size_t n = srcObj.members().size();
1527 const_cast<Map<T_key,T_value>&
>(obj).
clear();
1528 for (
size_t i = 0; i < n; ++i) {
1529 const Member& member = srcObj.members()[i];
1530 String
name = member.name();
1531 if (
name.length() < 2 ||
name[0] !=
'[' ||
1532 *
name.rbegin() !=
']')
continue;
1535 const UIDChain uids = UIDChainResolver<T_key>(key);
1537 Object tmpObj(uids, type);
1538 tmpObj.setNativeValueFromString(
name);
1539 const_cast<Map<T_key,T_value>&
>(obj)[key] = T_value();
1541 for (
const auto& it : obj) {
1542 archive->serializeHeapMember(
1543 obj, it.second, (
"[" + toString(it.first) +
"]").c_str()
1548 dstObj = archive->objectByUID(dstObj.uid());
1549 for (
size_t i = 0; i < n; ++i) {
1550 Member srcMember = srcObj.members()[i];
1551 Member dstMember = dstObj.memberNamed(srcMember.name());
1552 ((Syncer*)syncer)->syncMember(dstMember, srcMember);
1560 template<
typename T_key,
typename T_value,
bool T_isRecursive>
1561 struct SerializationRecursionImpl<
Map<T_key,T_value>*,T_isRecursive> {
1562 static void serializeObject(
Archive* archive,
const Map<T_key,T_value>*& obj) {
1564 SerializationRecursionImpl<Map<T_key,T_value>,T_isRecursive>::serializeObject(
1571 template<
typename T>
1572 struct SerializationRecursion : SerializationRecursionImpl<T, LIBGIG_IS_CLASS(T)> {
1575 class ObjectPool :
public std::map<UID,Object> {
1578 Object& operator[](
const UID& k) {
1579 static Object invalid;
1584 return std::map<UID,Object>::operator[](k);
1588 friend String _encode(
const ObjectPool& objects);
1591 String _encodeRootBlob();
1592 void _popRootBlob(
const char*& p,
const char* end);
1593 void _popObjectsBlob(
const char*& p,
const char* end);
1639 void syncPrimitive(
const Object& dst,
const Object& src);
1644 void syncPointer(
const Object& dst,
const Object& src);
1645 void syncMember(
const Member& dstMember,
const Member& srcMember);
1653 virtual void encode();
1655 ObjectPool m_allObjects;
1662 time_t m_timeCreated;
1663 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.
const UID NO_UID
Reflects an invalid UID and behaves similar to NULL as invalid value for pointer types.
std::set< T > Set
Set<> template.
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::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< T > Array
Array<> template.
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...