Nameless Engine
Loading...
Searching...
No Matches
ne::PrimitiveFieldSerializer Class Reference

#include <PrimitiveFieldSerializer.h>

Inheritance diagram for ne::PrimitiveFieldSerializer:
ne::IFieldSerializer

Public Member Functions

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

Serializer for some primitive field types: bool, int, unsigned int, long long, unsigned long long, float, double.

Member Function Documentation

◆ cloneField()

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

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.

Implements ne::IFieldSerializer.

◆ deserializeField()

std::optional< Error > ne::PrimitiveFieldSerializer::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 
)
overridevirtual

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.

Implements ne::IFieldSerializer.

◆ isFieldTypeSupported()

bool ne::PrimitiveFieldSerializer::isFieldTypeSupported ( const rfk::Field *  pField)
overridevirtual

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.

Implements ne::IFieldSerializer.

◆ isFieldValueEqual()

bool ne::PrimitiveFieldSerializer::isFieldValueEqual ( Serializable pFieldAOwner,
const rfk::Field *  pFieldA,
Serializable pFieldBOwner,
const rfk::Field *  pFieldB 
)
overridevirtual

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.

Implements ne::IFieldSerializer.

◆ serializeField()

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

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.

Implements ne::IFieldSerializer.


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