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

#include <VectorFieldSerializer.h>

Inheritance diagram for ne::VectorFieldSerializer:
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 Member Functions

static bool isMostInnerTypeSerializable (const std::string &sFieldCanonicalTypeName)
 

Static Private Attributes

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

Detailed Description

Serializer for some std::vector<T> field types, the following inner vector types are supported: bool, int, unsigned int, long long, unsigned long long, float, double, std::string, MeshVertex. Additionally, supported inner types include std::unique_ptr<T> where T is any type that derives from Serializable.

Member Function Documentation

◆ cloneField()

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

◆ isMostInnerTypeSerializable()

bool ne::VectorFieldSerializer::isMostInnerTypeSerializable ( const std::string &  sFieldCanonicalTypeName)
staticprivate

Looks if the specified type contains Serializable type. Supports the following type format: SomeContainerType<SomeOtherContainerType<T>>.

Parameters
sFieldCanonicalTypeNameCanonical type name.
Returns
false if the most inner type is not Serializable, otherwise true.

◆ serializeField()

std::optional< Error > ne::VectorFieldSerializer::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::VectorFieldSerializer::sStringCanonicalTypeName = "std::basic_string<char>"
inlinestaticprivate

Canonical type name for std::string fields.


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