Plasma Engine  2.0
Loading...
Searching...
No Matches
plReflectionSerializer Class Reference

Static Public Member Functions

static void WriteObjectToDDL (plStreamWriter &inout_stream, const plRTTI *pRtti, const void *pObject, bool bCompactMmode=true, plOpenDdlWriter::TypeStringMode typeMode=plOpenDdlWriter::TypeStringMode::Shortest)
 Writes all property values of the reflected pObject of type pRtti to stream in DDL format.
 
static void WriteObjectToDDL (plOpenDdlWriter &ref_ddl, const plRTTI *pRtti, const void *pObject, plUuid guid=plUuid())
 Overload of WriteObjectToDDL that takes an existing DDL writer to output to.
 
static void WriteObjectToBinary (plStreamWriter &inout_stream, const plRTTI *pRtti, const void *pObject)
 Same as WriteObjectToDDL but binary.
 
static void * ReadObjectFromDDL (plStreamReader &inout_stream, const plRTTI *&ref_pRtti)
 Reads the entire DDL data in the stream and restores a reflected object.
 
static void * ReadObjectFromDDL (const plOpenDdlReaderElement *pRootElement, const plRTTI *&ref_pRtti)
 
static void * ReadObjectFromBinary (plStreamReader &inout_stream, const plRTTI *&ref_pRtti)
 Same as ReadObjectFromDDL but binary.
 
static void ReadObjectPropertiesFromDDL (plStreamReader &inout_stream, const plRTTI &rtti, void *pObject)
 Reads the entire DDL data in the stream and sets all properties of the given object.
 
static void ReadObjectPropertiesFromBinary (plStreamReader &inout_stream, const plRTTI &rtti, void *pObject)
 Same as ReadObjectPropertiesFromDDL but binary.
 
static void * Clone (const void *pObject, const plRTTI *pType)
 Clones pObject of type pType and returns it.
 
static void Clone (const void *pObject, void *pClone, const plRTTI *pType)
 Clones pObject of type pType into the already existing pClone.
 
template<typename T >
static T * Clone (const T *pObject)
 Templated convenience function that calls Clone and automatically deduces the type.
 

Member Function Documentation

◆ Clone() [1/2]

void * plReflectionSerializer::Clone ( const void * pObject,
const plRTTI * pType )
static

Clones pObject of type pType and returns it.

In case a class derived from plReflectedClass is passed in the correct derived type will automatically be determined so it is not necessary to put the exact type into pType, any derived class type will do.

◆ Clone() [2/2]

void plReflectionSerializer::Clone ( const void * pObject,
void * pClone,
const plRTTI * pType )
static

Clones pObject of type pType into the already existing pClone.

In case a class derived from plReflectedClass is passed in the correct derived type will automatically be determined so it is not necessary to put the exact type into pType, any derived class type will do. However, the function will assert if pObject and pClone actually have a different type.

◆ ReadObjectFromDDL()

void * plReflectionSerializer::ReadObjectFromDDL ( plStreamReader & inout_stream,
const plRTTI *& ref_pRtti )
static

Reads the entire DDL data in the stream and restores a reflected object.

The object type is read from the DDL information in the stream and the object is either allocated through the given allocator, or, if none is provided, the default allocator for the type is used.

All properties are set to the values as described in the DDL data, as long as the properties can be matched to the runtime type.

◆ ReadObjectPropertiesFromDDL()

void plReflectionSerializer::ReadObjectPropertiesFromDDL ( plStreamReader & inout_stream,
const plRTTI & rtti,
void * pObject )
static

Reads the entire DDL data in the stream and sets all properties of the given object.

All properties are set to the values as described in the DDL data, as long as the properties can be matched to the runtime type. The given object should ideally be of the same type as the object had that was written to the stream. However, if the types do not match or the properties have changed, the data will still be restored as good as possible.

The object itself will not be reset to the default state before the properties are set, so properties that do not appear in the DDL data, or cannot be matched, will not be affected.

◆ WriteObjectToDDL()

void plReflectionSerializer::WriteObjectToDDL ( plStreamWriter & inout_stream,
const plRTTI * pRtti,
const void * pObject,
bool bCompactMmode = true,
plOpenDdlWriter::TypeStringMode typeMode = plOpenDdlWriter::TypeStringMode::Shortest )
static

Writes all property values of the reflected pObject of type pRtti to stream in DDL format.

Using ReadObjectPropertiesFromDDL() you can read those properties back into an existing object. Using ReadObjectFromDDL() an object of the same type is allocated and its properties are restored from the DDL data.

Non-existing objects (pObject == nullptr) are stored as objects of type "null". The compact mode and typeMode should be set according to whether the DDL data is used for interchange with other code only, or might also be read by humans.

Read-only properties are not written out, as they cannot be restored anyway.


The documentation for this class was generated from the following files: