Nameless Engine
|
#include <SerializableObjectFieldSerializer.h>
Public Member Functions | |
virtual bool | isFieldTypeSupported (const rfk::Field *pField) override |
virtual std::optional< Error > | serializeField (toml::value *pTomlData, Serializable *pFieldOwner, const rfk::Field *pField, const std::string &sSectionName, const std::string &sEntityId, size_t &iSubEntityId, Serializable *pOriginalObject=nullptr) override |
virtual std::optional< Error > | deserializeField (const toml::value *pTomlDocument, const toml::value *pTomlValue, Serializable *pFieldOwner, const rfk::Field *pField, const std::string &sOwnerSectionName, const std::string &sEntityId, std::unordered_map< std::string, std::string > &customAttributes) override |
virtual std::optional< Error > | cloneField (Serializable *pFromInstance, const rfk::Field *pFromField, Serializable *pToInstance, const rfk::Field *pToField) override |
virtual bool | isFieldValueEqual (Serializable *pFieldAOwner, const rfk::Field *pFieldA, Serializable *pFieldBOwner, const rfk::Field *pFieldB) override |
virtual bool | isFieldTypeSupported (const rfk::Field *pField)=0 |
virtual std::optional< Error > | serializeField (toml::value *pTomlData, Serializable *pFieldOwner, const rfk::Field *pField, const std::string &sSectionName, const std::string &sEntityId, size_t &iSubEntityId, Serializable *pOriginalObject=nullptr)=0 |
virtual std::optional< Error > | deserializeField (const toml::value *pTomlDocument, const toml::value *pTomlValue, Serializable *pFieldOwner, const rfk::Field *pField, const std::string &sOwnerSectionName, const std::string &sEntityId, std::unordered_map< std::string, std::string > &customAttributes)=0 |
virtual std::optional< Error > | cloneField (Serializable *pFromInstance, const rfk::Field *pFromField, Serializable *pToInstance, const rfk::Field *pToField)=0 |
virtual bool | isFieldValueEqual (Serializable *pFieldAOwner, const rfk::Field *pFieldA, Serializable *pFieldBOwner, const rfk::Field *pFieldB)=0 |
Static Public Member Functions | |
static std::optional< Error > | serializeFieldObject (Serializable *pObject, toml::value *pTomlData, const std::string &sFieldName, const std::string &sSectionName, const std::string &sEntityId, size_t &iSubEntityId, Serializable *pOriginalObject=nullptr) |
static std::optional< Error > | cloneSerializableObject (Serializable *pFrom, Serializable *pTo, bool bNotifyAboutDeserialized) |
static std::variant< std::unique_ptr< Serializable >, Error > | deserializeSerializableObject (const toml::value *pTomlDocument, const toml::value *pTomlValue, const std::string &sFieldName, Serializable *pTarget, const std::string &sOwnerSectionName, const std::string &sEntityId, std::unordered_map< std::string, std::string > &customAttributes) |
static bool | isSerializableObjectValueEqual (Serializable *pObjectA, Serializable *pObjectB) |
static bool | isTypeDerivesFromSerializable (const std::string &sCanonicalTypeName) |
static bool | isFieldSerializable (rfk::Field const &field) |
static bool | isDerivedFromSerializable (rfk::Archetype const *pArchetype) |
Static Private Member Functions | |
static bool | isTypeDerivesFromSerializable (const std::string &sCanonicalTypeName, const rfk::Namespace *pNamespace) |
Static Private Attributes | |
static const auto | sSubEntityFieldNameKey = ".field_name" |
Friends | |
class | GameManager |
Serializer for field types that derive from Serializable class.
|
overridevirtual |
Clones field's data from one object to another.
pFromInstance | Instance to copy the field from. |
pFromField | Field to copy. |
pToInstance | Instance to copy to. |
pToField | Field to copy to. |
Implements ne::IFieldSerializer.
|
static |
Clones reflected serializable fields of one object to another.
pFrom | Object to clone fields from. |
pTo | Object to clone fields to. |
bNotifyAboutDeserialized | Whether or not to notify the target object we cloned fields to about it being finally deserialized or not. This should be true if you are calling this function as the last step of your deserialize function or in some special cases for new objects that won't reach deserialize function (for ex. when copying data to new object), otherwise false . |
|
overridevirtual |
Deserializes field from a TOML value.
pTomlDocument | TOML document that contains a value to deserialize. |
pTomlValue | TOML value to deserialize the field from. |
pFieldOwner | Field's owner. |
pField | Field to deserialize TOML value to. |
sOwnerSectionName | Name of the TOML section where is field was found. |
sEntityId | Current ID string of the entity (field owner) that we are deserializing. |
customAttributes | Pairs of values that were found with this object in TOML data. Only found when deserializing a field of type that derives from Serializable. |
Implements ne::IFieldSerializer.
|
static |
Deserializes field's object from a TOML value.
pTomlDocument | TOML document that contains a value to deserialize. |
pTomlValue | TOML value to deserialize the field from. |
sFieldName | Name of the field to deserialize to. |
pTarget | Field's object to deserialize the value to. |
sOwnerSectionName | Name of the TOML section where is field was found. |
sEntityId | Current ID string of the entity (field owner) that we are deserializing. |
customAttributes | Pairs of values that were found with this object in TOML data. Only found when deserializing a field of type that derives from Serializable. |
|
static |
Tests whether the specified archetype is Serializable or derives at some point from Serializable class.
pArchetype | Archetype to test. |
|
static |
Returns whether the specified field can be serialized or not.
field | Field to test. |
|
overridevirtual |
Tests if this serializer supports serialization/deserialization of this field.
pField | Field to test for serialization/deserialization support. |
true
if this serializer can be used to serialize this field, false
otherwise. Implements ne::IFieldSerializer.
|
overridevirtual |
Checks if the specified fields' values are equal or not.
pFieldAOwner | Owner of the field A. |
pFieldA | Field A to compare. |
pFieldBOwner | Owner of the field B. |
pFieldB | Field B to compare. |
false
if some field is unsupported by this serializer or if fields' values are not equal, true
otherwise. Implements ne::IFieldSerializer.
|
static |
Checks if the specified fields' values are equal or not.
pObjectA | Object to compare with B. |
pObjectB | Object to compare with A. |
false
if some field is unsupported by this serializer or if fields' values are not equal, true
otherwise.
|
static |
Looks if the specified canonical type name derives from Serializable
or not.
sCanonicalTypeName | Canonical type name (not just type name, see rfk::Field::getCanonicalTypeName ). |
false
if the specified type was not found to be derived from Serializable
, otherwise true
.
|
staticprivate |
Looks if the specified canonical type name derives from Serializable
.
sCanonicalTypeName | Canonical type name without namespace in the name. |
pNamespace | Optional. Namespace that the specified type resides in. |
false
if the specified type was not found to be derived from Serializable
, otherwise true
.
|
overridevirtual |
Serializes field into a TOML value.
pTomlData | TOML value to serialize the field to. |
pFieldOwner | Field's owner. |
pField | Field to serialize. |
sSectionName | Name of the section (for TOML value) to use for this field. |
sEntityId | Current ID string of the entity (field owner) that we are serializing. Only used when serializing a field of type that derives from Serializable. |
iSubEntityId | Current ID of the sub entity (sub entity of the field owner). Only used when serializing a field of type that derives from Serializable. |
pOriginalObject | Optional. Original object of the same type as the object being serialized, this object is a deserialized version of the object being serialized, used to compare serializable fields' values and only serialize changed values. Only used when serializing a field of type that derives from Serializable. |
Implements ne::IFieldSerializer.
|
static |
Serializes field's object (serializable object wrapped into a container, such as gc
) into a TOML value.
pObject | Object to serialize. |
pTomlData | TOML value to serialize the field to. |
sFieldName | Name of the field to serialize. |
sSectionName | Name of the section (for TOML value) to use for this field. |
sEntityId | Current ID string of the entity (field owner) that we are serializing. Only used when serializing a field of type that derives from Serializable. |
iSubEntityId | Current ID of the sub entity (sub entity of the field owner). Only used when serializing a field of type that derives from Serializable. |
pOriginalObject | Optional. Original object of the same type as the object being serialized, this object is a deserialized version of the object being serialized, used to compare serializable fields' values and only serialize changed values. Only used when serializing a field of type that derives from Serializable. |
|
inlinestaticprivate |
Name of the key in which to store name of the field a section represents.