Nameless Engine
Loading...
Searching...
No Matches
ne::IFieldSerializer Class Referenceabstract

#include <IFieldSerializer.hpp>

Inheritance diagram for ne::IFieldSerializer:
ne::GlmVecFieldSerializer ne::PrimitiveFieldSerializer ne::SerializableObjectFieldSerializer ne::StringFieldSerializer ne::UnorderedMapFieldSerializer ne::VectorFieldSerializer

Public Member Functions

virtual bool isFieldTypeSupported (const rfk::Field *pField)=0
 
virtual std::optional< ErrorserializeField (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< ErrordeserializeField (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< ErrorcloneField (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
 

Detailed Description

Interface for implementing support for serialization of new field types.

By implementing this interface and registering it in the FieldSerializerManager class you can add support for serialization/deserialization of new field types and extend serialization/deserialization functionality for Serializable derived classes.

Member Function Documentation

◆ cloneField()

virtual std::optional< Error > ne::IFieldSerializer::cloneField ( Serializable pFromInstance,
const rfk::Field *  pFromField,
Serializable pToInstance,
const rfk::Field *  pToField 
)
pure virtual

Clones field's data from one object to another.

Parameters
pFromInstanceInstance to copy the field from.
pFromFieldField to copy.
pToInstanceInstance to copy to.
pToFieldField to copy to.
Returns
Error if something went wrong, empty otherwise.

Implemented in ne::GlmVecFieldSerializer, ne::PrimitiveFieldSerializer, ne::SerializableObjectFieldSerializer, ne::StringFieldSerializer, ne::UnorderedMapFieldSerializer, and ne::VectorFieldSerializer.

◆ deserializeField()

virtual std::optional< Error > ne::IFieldSerializer::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 
)
pure virtual

Deserializes field from a TOML value.

Parameters
pTomlDocumentTOML document that contains a value to deserialize.
pTomlValueTOML value to deserialize the field from.
pFieldOwnerField's owner.
pFieldField to deserialize TOML value to.
sOwnerSectionNameName of the TOML section where is field was found.
sEntityIdCurrent ID string of the entity (field owner) that we are deserializing.
customAttributesPairs of values that were found with this object in TOML data. Only found when deserializing a field of type that derives from Serializable.
Returns
Error if something went wrong, empty otherwise.

Implemented in ne::GlmVecFieldSerializer, ne::PrimitiveFieldSerializer, ne::SerializableObjectFieldSerializer, ne::StringFieldSerializer, ne::UnorderedMapFieldSerializer, and ne::VectorFieldSerializer.

◆ isFieldTypeSupported()

virtual bool ne::IFieldSerializer::isFieldTypeSupported ( const rfk::Field *  pField)
pure virtual

Tests if this serializer supports serialization/deserialization of this field.

Parameters
pFieldField to test for serialization/deserialization support.
Returns
true if this serializer can be used to serialize this field, false otherwise.

Implemented in ne::GlmVecFieldSerializer, ne::PrimitiveFieldSerializer, ne::SerializableObjectFieldSerializer, ne::StringFieldSerializer, ne::UnorderedMapFieldSerializer, and ne::VectorFieldSerializer.

◆ isFieldValueEqual()

virtual bool ne::IFieldSerializer::isFieldValueEqual ( Serializable pFieldAOwner,
const rfk::Field *  pFieldA,
Serializable pFieldBOwner,
const rfk::Field *  pFieldB 
)
pure virtual

Checks if the specified fields' values are equal or not.

Parameters
pFieldAOwnerOwner of the field A.
pFieldAField A to compare.
pFieldBOwnerOwner of the field B.
pFieldBField B to compare.
Returns
false if some field is unsupported by this serializer or if fields' values are not equal, true otherwise.

Implemented in ne::GlmVecFieldSerializer, ne::PrimitiveFieldSerializer, ne::SerializableObjectFieldSerializer, ne::StringFieldSerializer, ne::UnorderedMapFieldSerializer, and ne::VectorFieldSerializer.

◆ serializeField()

virtual std::optional< Error > ne::IFieldSerializer::serializeField ( toml::value *  pTomlData,
Serializable pFieldOwner,
const rfk::Field *  pField,
const std::string &  sSectionName,
const std::string &  sEntityId,
size_t &  iSubEntityId,
Serializable pOriginalObject = nullptr 
)
pure virtual

Serializes field into a TOML value.

Parameters
pTomlDataTOML value to serialize the field to.
pFieldOwnerField's owner.
pFieldField to serialize.
sSectionNameName of the section (for TOML value) to use for this field.
sEntityIdCurrent ID string of the entity (field owner) that we are serializing. Only used when serializing a field of type that derives from Serializable.
iSubEntityIdCurrent ID of the sub entity (sub entity of the field owner). Only used when serializing a field of type that derives from Serializable.
pOriginalObjectOptional. 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.
Returns
Error if something went wrong, empty otherwise.

Implemented in ne::GlmVecFieldSerializer, ne::PrimitiveFieldSerializer, ne::SerializableObjectFieldSerializer, ne::StringFieldSerializer, ne::UnorderedMapFieldSerializer, and ne::VectorFieldSerializer.


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