Nameless Engine
Loading...
Searching...
No Matches
IFieldSerializer.hpp
1#pragma once
2
3// Standard.
4#include <optional>
5#include <format>
6
7// Custom.
8#include "misc/Error.h"
9
10// External.
11#include "Refureku/Refureku.h"
12#include "toml11/single_include/toml.hpp"
13
14namespace ne {
15 class Serializable;
16
24 inline std::string floatingToString(double value) { return std::format("{:.15f}", value); }
25
34 public:
35 IFieldSerializer() = default;
36 virtual ~IFieldSerializer() = default;
37
45 virtual bool isFieldTypeSupported(const rfk::Field* pField) = 0;
46
65 [[nodiscard]] virtual std::optional<Error> serializeField(
66 toml::value* pTomlData,
67 Serializable* pFieldOwner,
68 const rfk::Field* pField,
69 const std::string& sSectionName,
70 const std::string& sEntityId,
71 size_t& iSubEntityId,
72 Serializable* pOriginalObject = nullptr) = 0;
73
89 [[nodiscard]] virtual std::optional<Error> deserializeField(
90 const toml::value* pTomlDocument,
91 const toml::value* pTomlValue,
92 Serializable* pFieldOwner,
93 const rfk::Field* pField,
94 const std::string& sOwnerSectionName,
95 const std::string& sEntityId,
96 std::unordered_map<std::string, std::string>& customAttributes) = 0;
97
108 [[nodiscard]] virtual std::optional<Error> cloneField(
109 Serializable* pFromInstance,
110 const rfk::Field* pFromField,
111 Serializable* pToInstance,
112 const rfk::Field* pToField) = 0;
113
125 virtual bool isFieldValueEqual(
126 Serializable* pFieldAOwner,
127 const rfk::Field* pFieldA,
128 Serializable* pFieldBOwner,
129 const rfk::Field* pFieldB) = 0;
130 };
131} // namespace ne
Definition: IFieldSerializer.hpp:33
virtual std::optional< Error > cloneField(Serializable *pFromInstance, const rfk::Field *pFromField, Serializable *pToInstance, const rfk::Field *pToField)=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 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 bool isFieldValueEqual(Serializable *pFieldAOwner, const rfk::Field *pFieldA, Serializable *pFieldBOwner, const rfk::Field *pFieldB)=0
Definition: Serializable.h:113