7#ifdef JPH_OBJECT_STREAM
26 #define JPH_DECLARE_PRIMITIVE(name) T_##name,
47 SerializableAttribute(
const char *inName,
uint inMemberOffset,
pGetMemberPrimitiveType inGetMemberPrimitiveType,
pIsType inIsType,
pReadData inReadData,
pWriteData inWriteData,
pWriteDataType inWriteDataType) : mName(inName), mMemberOffset(inMemberOffset), mGetMemberPrimitiveType(inGetMemberPrimitiveType), mIsType(inIsType), mReadData(inReadData), mWriteData(inWriteData), mWriteDataType(inWriteDataType) { }
50 SerializableAttribute(
const SerializableAttribute &inOther,
int inBaseOffset) : mName(inOther.mName), mMemberOffset(inOther.mMemberOffset + inBaseOffset), mGetMemberPrimitiveType(inOther.mGetMemberPrimitiveType), mIsType(inOther.mIsType), mReadData(inOther.mReadData), mWriteData(inOther.mWriteData), mWriteDataType(inOther.mWriteDataType) { }
53 void SetName(
const char *inName) { mName = inName; }
54 const char *
GetName()
const {
return mName; }
58 inline T *
GetMemberPointer(
void *inObject)
const {
return reinterpret_cast<T *
>(
reinterpret_cast<uint8 *
>(inObject) + mMemberOffset); }
60 inline const T *
GetMemberPointer(
const void *inObject)
const {
return reinterpret_cast<const T *
>(
reinterpret_cast<const uint8 *
>(inObject) + mMemberOffset); }
65 return mGetMemberPrimitiveType();
71 return mIsType(inArrayDepth, inDataType, inClassName);
77 return mReadData(ioStream, GetMemberPointer<void>(inObject));
83 mWriteData(ioStream, GetMemberPointer<void>(inObject));
89 mWriteDataType(ioStream);
std::uint8_t uint8
Definition Core.h:482
unsigned int uint
Definition Core.h:481
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
EOSDataType
Data type.
Definition SerializableAttribute.h:17
@ Array
Used in attribute declaration, indicates that this is an array of objects.
@ Object
Start of a new object.
@ Invalid
Next token on the stream was not a valid data type.
@ Pointer
Used in attribute declaration, indicates that an object is a pointer attribute.
@ Instance
Used in attribute declaration, indicates that an object is an instanced attribute (no pointer)
Interface class for reading from an object stream.
Definition ObjectStream.h:42
Interface class for writing to an object stream.
Definition ObjectStream.h:76
Attributes are members of classes that need to be serialized.
Definition SerializableAttribute.h:37
void(*)(IObjectStreamOut &ioStream) pWriteDataType
Definition SerializableAttribute.h:44
void WriteData(IObjectStreamOut &ioStream, const void *inObject) const
Write the data for this attribute from attribute containing class inObject.
Definition SerializableAttribute.h:81
void WriteDataType(IObjectStreamOut &ioStream) const
Write the data type of this attribute to a stream.
Definition SerializableAttribute.h:87
bool(*)(int inArrayDepth, EOSDataType inDataType, const char *inClassName) pIsType
Definition SerializableAttribute.h:41
const RTTI * GetMemberPrimitiveType() const
In case this attribute contains an RTTI type, return it (note that a Array<sometype> will return the ...
Definition SerializableAttribute.h:63
const T * GetMemberPointer(const void *inObject) const
Definition SerializableAttribute.h:60
T * GetMemberPointer(void *inObject) const
Access to the memory location that contains the member.
Definition SerializableAttribute.h:58
void SetName(const char *inName)
Name of the attribute.
Definition SerializableAttribute.h:53
SerializableAttribute(const char *inName, uint inMemberOffset, pGetMemberPrimitiveType inGetMemberPrimitiveType, pIsType inIsType, pReadData inReadData, pWriteData inWriteData, pWriteDataType inWriteDataType)
Constructor.
Definition SerializableAttribute.h:47
bool IsType(int inArrayDepth, EOSDataType inDataType, const char *inClassName) const
Check if this attribute is of a specific type.
Definition SerializableAttribute.h:69
bool(*)(IObjectStreamIn &ioStream, void *inObject) pReadData
Definition SerializableAttribute.h:42
bool ReadData(IObjectStreamIn &ioStream, void *inObject) const
Read the data for this attribute into attribute containing class inObject.
Definition SerializableAttribute.h:75
SerializableAttribute(const SerializableAttribute &inOther, int inBaseOffset)
Construct from other attribute with base class offset.
Definition SerializableAttribute.h:50
const char * GetName() const
Definition SerializableAttribute.h:54
const RTTI *(*)() pGetMemberPrimitiveType
@ Serialization functions
Definition SerializableAttribute.h:40
void(*)(IObjectStreamOut &ioStream, const void *inObject) pWriteData
Definition SerializableAttribute.h:43