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

#include <StringFieldSerializer.h>

Inheritance diagram for ne::StringFieldSerializer:
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
 

Static Private Attributes

static const std::string sStringCanonicalTypeName = "std::basic_string<char>"
 

Detailed Description

Serializer for the std::string field type.

Member Function Documentation

◆ cloneField()

std::optional< Error > ne::StringFieldSerializer::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::StringFieldSerializer::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::StringFieldSerializer::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::StringFieldSerializer::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::StringFieldSerializer::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.

Member Data Documentation

◆ sStringCanonicalTypeName

const std::string ne::StringFieldSerializer::sStringCanonicalTypeName = "std::basic_string<char>"
inlinestaticprivate

Canonical type name for std::string fields.


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