3#include "rapidjson/document.h"
59 virtual rapidjson::Value
66 tid.SetString(
typeid(*this).name(), d.GetAllocator());
72 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
76 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
88 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
89 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
101 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
102 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
114 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
115 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
127 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
128 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
140 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
141 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
154 virtual rapidjson::Value
GetName(rapidjson::Document& d);
155 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
156 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
164 if (value !=
nullptr)
165 return value->ToDom(d);
167 return rapidjson::Value(
"");
176 value->FromDom(v, d);
184 rapidjson::Value tid;
185 tid.SetString(
typeid(T).name(), d.GetAllocator());
193 value = std::make_shared<T>();
202 std::vector<std::shared_ptr<T>>&
value;
206 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
207 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
216 for (
auto& element : value) {
217 rapidjson::Value v = element->ToDom(d);
218 a.PushBack(v, d.GetAllocator());
227 for (rapidjson::SizeType i = 0; i < v.Size();
229 std::shared_ptr<T> cv = std::make_shared<T>();
230 cv->FromDom(v[i], d);
241 std::vector<std::vector<std::shared_ptr<T>>>&
value;
246 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
247 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
254 rapidjson::Value outer;
256 for (
auto& outer_element : value) {
257 rapidjson::Value inner;
259 for (
auto& inner_element : outer_element) {
260 rapidjson::Value v = inner_element->ToDom(d);
261 inner.PushBack(v, d.GetAllocator());
263 outer.PushBack(inner, d.GetAllocator());
272 for (rapidjson::SizeType i = 0; i < v.Size(); i++) {
273 std::vector<std::shared_ptr<T>> line;
274 for (rapidjson::SizeType j = 0; j < v[i].Size(); j++) {
275 std::shared_ptr<T> cv = std::make_shared<T>();
276 cv->FromDom(v[i][j], d);
279 value.push_back(line);
293 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
294 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
301 rapidjson::Value outer;
303 for (
auto& outer_element : value) {
304 rapidjson::Value inner;
306 for (
auto& inner_element : outer_element) {
307 rapidjson::Value v = inner_element.ToDom(d);
308 inner.PushBack(v, d.GetAllocator());
310 outer.PushBack(inner, d.GetAllocator());
319 for (rapidjson::SizeType i = 0; i < v.Size(); i++) {
321 for (rapidjson::SizeType j = 0; j < v[i].Size(); j++) {
323 cv.FromDom(v[i][j], d);
326 value.push_back(line);
340 virtual rapidjson::Value
GetName(rapidjson::Document& d);
341 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
342 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
350 return value.ToDom(d);
364 rapidjson::Value tid;
365 tid.SetString(
typeid(T).name(), d.GetAllocator());
388 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
389 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
399 for (
auto& element : value) {
400 rapidjson::Value v = element.ToDom(d);
401 a.PushBack(v, d.GetAllocator());
411 for (rapidjson::SizeType i = 0; i < v.Size();
430 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
431 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
434 using ISFV = std::vector<float>;
445 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
446 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
449 using ISDV = std::vector<double>;
460 virtual rapidjson::Value
ToDom(rapidjson::Document& d);
461 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
530 virtual Json::ISProperties GetProperty() \
532 Json::ISProperties prop = {
535# m, std::make_shared < Json::ISInt>(m) \
537#define JSONINTVECTOR(m) \
539# m, std::make_shared < Json::ISIntVector>(m) \
541#define JSONFLOAT(m) \
543# m, std::make_shared < Json::ISFloat>(m) \
545#define JSONFLOATVECTOR(m) \
547# m, std::make_shared < Json::ISFloatVector>(m) \
549#define JSONDOUBLE(m) \
551# m, std::make_shared < Json::ISDouble>(m) \
553#define JSONDOUBLEVECTOR(m) \
555# m, std::make_shared < Json::ISDoubleVector>(m) \
559# m, std::make_shared < Json::ISBool>(m) \
561#define JSONSTRING(m) \
563# m, std::make_shared < Json::ISString>(m) \
565#define JSONOBJECT(T, m) \
567# m, std::make_shared < Json::ISObject < T>>(m) \
569#define JSONOBJECTVECTOR(T, m) \
571# m, std::make_shared < Json::ISObjectVector < T>>(m) \
573#define JSONOBJVECVEC(T, m) \
575# m, std::make_shared < Json::ISObjVecVec < T>>(m) \
577#define JSONMEMBER(T, m) \
579# m, std::make_shared < Json::ISMember < T>>(m) \
581#define JSONMEMBERVECTOR(T, m) \
583# m, std::make_shared < Json::ISMemberVector < T>>(m) \
585#define JSONMEMVECVEC(T, m) \
587# m, std::make_shared < Json::ISMemVecVec < T>>(m) \
Implementation for bools.
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
Implemented for future expansion.
void operator=(const ISConstructors &)=delete
int AddConstructor(std::string name, ISValuePtr(*creator)())
ISValuePtr GetObject(std::string name)
ISConstructors(const ISConstructors &)=delete
std::map< std::string, Json::ISValuePtr(*)()> m_TheRegistry
static ISConstructors & GetInstance()
Implementation for a vector with doubles.
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
std::vector< double > & value
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
Implementation for doubles.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Implementation for a vector with floats.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
std::vector< float > & value
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Implementation for floats.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Implementation for a vector with integers.
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
std::vector< int > & value
Implementation for integers.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Implementation for a vector with vectors with members.
std::vector< std::vector< T > > & value
ISMemVecVec(std::vector< std::vector< T > > &v)
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Implementation for a vector with members.
ISMemberVector(std::vector< T > &v)
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
ISMemberVector(const ISMemberVector< T > &)
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Implementation for Members.
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
void CreateObject()
For future expansion.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value GetName(rapidjson::Document &d)
For future expansion.
Implementation for a vector with vectors with objects.
ISObjVecVec(std::vector< std::vector< std::shared_ptr< T > > > &v)
std::vector< std::vector< std::shared_ptr< T > > > & value
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Implementation for a vector with objects.
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
std::vector< std::shared_ptr< T > > & value
ISObjectVector(std::vector< std::shared_ptr< T > > &v)
Implementation for objects.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
ISObject(std::shared_ptr< T > &v)
void CreateObject()
For future expansion.
std::shared_ptr< T > & value
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
virtual rapidjson::Value GetName(rapidjson::Document &d)
For future expansion.
Implementation for strings.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
Rflection is made possible by the help of the ISValue class and the type classes.
virtual void CreateObject()
For future expansion.
virtual rapidjson::Value ToDom(rapidjson::Document &d)
ToDom is the function that enables the serializer to take data from the application to the JSON file.
virtual ISProperties GetProperty()
GetProperty enables the serializer to deal with composite type like objects and members.
virtual void FromDom(rapidjson::Value &v, rapidjson::Document &d)
FromDom is the function that enables the serializer to get data out of the JSON file and put it in th...
virtual rapidjson::Value GetName(rapidjson::Document &d)
For future expansion.
void deserialize(std::string filename, ISValue *p)
Function to start deserializing a file.
std::vector< ISValuePtr > ISValues
std::vector< double > ISDV
void serialize(std::string filename, ISValue *p)
Function to start serializing an onbject.
std::vector< float > ISFV
std::vector< ISProperty > ISProperties
ISProperties is a vector with ISProperty.
std::shared_ptr< ISValue > ISValuePtr
Serializing and deserializing (persistent values) requires recflection which is a way for the program...