hivemind 1.0.0
Loading...
Searching...
No Matches
serializer.h
Go to the documentation of this file.
1#pragma once
2
3#include "rapidjson/document.h"
4#include <iostream>
5#include <map>
6#include <memory>
7#include <string>
8#include <type_traits>
9#include <vector>
10
11extern bool debug;
12
13namespace Json
14{
15 // IS... IntroSpection
16 class ISValue;
17 using ISValuePtr = std::shared_ptr<ISValue>;
18 using ISValues = std::vector<ISValuePtr>;
19
20///
21///\brief Serializing and deserializing (persistent values) requires recflection which is a way for the programmer to ensure that
22///the data you serialize will get back to the place you want it to be when you deserialize it later.
23///As this is not supported by C++ this is implemented by the ISProperty structure with the ISValue helper classes. The ISValue keeps the references
24///to the actual values in the application. The ISProperty is the collection of all the application data.
25///
27 {
28 std::string name;
30 };
31///
32///\brief ISProperties is a vector with ISProperty.
33///
34 using ISProperties = std::vector<ISProperty>;
35///
36///\brief Rflection is made possible by the help of the ISValue class and the type classes. Each type needs their own implementation for
37///reflection to work. At the moment only JSON is supported by this library.
38///Making the library work for other format than JSON would require implementing each type again for the new format by in theory would not
39///impact the application programmers at all
40///
41 class ISValue
42 {
43 public:
44///
45///\brief GetProperty enables the serializer to deal with composite type like objects and members.
46///
47 virtual ISProperties
49 {
50 return ISProperties{};
51 };
52///
53///\brief For future expansion.
54///
55 virtual void CreateObject(){};
56///
57///\brief For future expansion
58///
59 virtual rapidjson::Value
60 GetName(rapidjson::Document& d)
61 {
62///
63///\brief Typeid is mostly implemented for future expansion, but it helps with making the JSON file more readable for humans.
64///
65 rapidjson::Value tid;
66 tid.SetString(typeid(*this).name(), d.GetAllocator());
67 return tid;
68 };
69///
70///\brief ToDom is the function that enables the serializer to take data from the application to the JSON file.
71///
72 virtual rapidjson::Value ToDom(rapidjson::Document& d);
73///
74///\brief FromDom is the function that enables the serializer to get data out of the JSON file and put it in the application.
75///
76 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
77 };
78
79///
80///\brief Implementation for integers
81///
82 class ISInt : public ISValue
83 {
84 int& value;
85
86 public:
87 ISInt(int& v) : value(v){};
88 virtual rapidjson::Value ToDom(rapidjson::Document& d);
89 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
90 };
91
92///
93///\brief Implementation for floats
94///
95 class ISFloat : public ISValue
96 {
97 float& value;
98
99 public:
100 ISFloat(float& v) : value(v){};
101 virtual rapidjson::Value ToDom(rapidjson::Document& d);
102 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
103 };
104
105///
106///\brief Implementation for doubles
107///
108 class ISDouble : public ISValue
109 {
110 double& value;
111
112 public:
113 ISDouble(double& v) : value(v){};
114 virtual rapidjson::Value ToDom(rapidjson::Document& d);
115 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
116 };
117
118///
119///\brief Implementation for bools
120///
121 class ISBool : public ISValue
122 {
123 bool& value;
124
125 public:
126 ISBool(bool& v) : value(v){};
127 virtual rapidjson::Value ToDom(rapidjson::Document& d);
128 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
129 };
130
131///
132///\brief Implementation for strings
133///
134 class ISString : public ISValue
135 {
136 std::string& value;
137
138 public:
139 ISString(std::string& v) : value(v){};
140 virtual rapidjson::Value ToDom(rapidjson::Document& d);
141 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
142 };
143
144///
145///\brief Implementation for objects
146///
147 template<typename T>
148 class ISObject : public ISValue
149 {
150 std::shared_ptr<T>& value;
151
152 public:
153 ISObject(std::shared_ptr<T>& v) : value(v){};
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);
157 void CreateObject();
158 };
159
160 template<typename T>
161 rapidjson::Value
162 ISObject<T>::ToDom(rapidjson::Document& d)
163 {
164 if (value != nullptr)
165 return value->ToDom(d);
166 else
167 return rapidjson::Value("");
168 };
169
170 template<typename T>
171 void
172 ISObject<T>::FromDom(rapidjson::Value& v, rapidjson::Document& d)
173 {
174 if (v.IsObject()) {
175 CreateObject();
176 value->FromDom(v, d);
177 }
178 };
179
180 template<typename T>
181 rapidjson::Value
182 ISObject<T>::GetName(rapidjson::Document& d)
183 {
184 rapidjson::Value tid;
185 tid.SetString(typeid(T).name(), d.GetAllocator());
186 return tid;
187 }
188
189 template<typename T>
190 void
192 {
193 value = std::make_shared<T>();
194 }
195
196///
197///\brief Implementation for a vector with objects
198///
199 template<typename T>
200 class ISObjectVector : public ISValue
201 {
202 std::vector<std::shared_ptr<T>>& value;
203
204 public:
205 ISObjectVector(std::vector<std::shared_ptr<T>>& v) : value(v){};
206 virtual rapidjson::Value ToDom(rapidjson::Document& d);
207 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
208 };
209
210 template<typename T>
211 rapidjson::Value
212 ISObjectVector<T>::ToDom(rapidjson::Document& d)
213 {
214 rapidjson::Value a;
215 a.SetArray();
216 for (auto& element : value) {
217 rapidjson::Value v = element->ToDom(d);
218 a.PushBack(v, d.GetAllocator());
219 }
220 return a;
221 }
222
223 template<typename T>
224 void
225 ISObjectVector<T>::FromDom(rapidjson::Value& v, rapidjson::Document& d)
226 {
227 for (rapidjson::SizeType i = 0; i < v.Size();
228 i++) { // rapidjson uses SizeType instead of size_t.
229 std::shared_ptr<T> cv = std::make_shared<T>();
230 cv->FromDom(v[i], d);
231 value.push_back(cv);
232 }
233 }
234
235///
236///\brief Implementation for a vector with vectors with objects
237///
238 template<typename T>
239 class ISObjVecVec : public ISValue
240 {
241 std::vector<std::vector<std::shared_ptr<T>>>& value;
242
243 public:
244 ISObjVecVec(std::vector<std::vector<std::shared_ptr<T>>>& v)
245 : value(v){};
246 virtual rapidjson::Value ToDom(rapidjson::Document& d);
247 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
248 };
249
250 template<typename T>
251 rapidjson::Value
252 ISObjVecVec<T>::ToDom(rapidjson::Document& d)
253 {
254 rapidjson::Value outer;
255 outer.SetArray();
256 for (auto& outer_element : value) {
257 rapidjson::Value inner;
258 inner.SetArray();
259 for (auto& inner_element : outer_element) {
260 rapidjson::Value v = inner_element->ToDom(d);
261 inner.PushBack(v, d.GetAllocator());
262 }
263 outer.PushBack(inner, d.GetAllocator());
264 }
265 return outer;
266 }
267
268 template<typename T>
269 void
270 ISObjVecVec<T>::FromDom(rapidjson::Value& v, rapidjson::Document& d)
271 {
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);
277 line.push_back(cv);
278 }
279 value.push_back(line);
280 }
281 }
282
283///
284///\brief Implementation for a vector with vectors with members
285///
286 template<typename T>
287 class ISMemVecVec : public ISValue
288 {
289 std::vector<std::vector<T>>& value;
290
291 public:
292 ISMemVecVec(std::vector<std::vector<T>>& v) : value(v){};
293 virtual rapidjson::Value ToDom(rapidjson::Document& d);
294 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
295 };
296
297 template<typename T>
298 rapidjson::Value
299 ISMemVecVec<T>::ToDom(rapidjson::Document& d)
300 {
301 rapidjson::Value outer;
302 outer.SetArray();
303 for (auto& outer_element : value) {
304 rapidjson::Value inner;
305 inner.SetArray();
306 for (auto& inner_element : outer_element) {
307 rapidjson::Value v = inner_element.ToDom(d);
308 inner.PushBack(v, d.GetAllocator());
309 }
310 outer.PushBack(inner, d.GetAllocator());
311 }
312 return outer;
313 }
314
315 template<typename T>
316 void
317 ISMemVecVec<T>::FromDom(rapidjson::Value& v, rapidjson::Document& d)
318 {
319 for (rapidjson::SizeType i = 0; i < v.Size(); i++) {
320 std::vector<T> line;
321 for (rapidjson::SizeType j = 0; j < v[i].Size(); j++) {
322 T cv;
323 cv.FromDom(v[i][j], d);
324 line.push_back(cv);
325 }
326 value.push_back(line);
327 }
328 }
329
330///
331///\brief Implementation for Members
332///
333 template<typename T>
334 class ISMember : public ISValue
335 {
337
338 public:
339 ISMember(T& v) : value(v){};
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);
343 void CreateObject();
344 };
345
346 template<typename T>
347 rapidjson::Value
348 ISMember<T>::ToDom(rapidjson::Document& d)
349 {
350 return value.ToDom(d);
351 };
352
353 template<typename T>
354 void
355 ISMember<T>::FromDom(rapidjson::Value& v, rapidjson::Document& d)
356 {
357 value.FromDom(v, d);
358 };
359
360 template<typename T>
361 rapidjson::Value
362 ISMember<T>::GetName(rapidjson::Document& d)
363 {
364 rapidjson::Value tid;
365 tid.SetString(typeid(T).name(), d.GetAllocator());
366 return tid;
367 }
368
369 template<typename T>
370 void
372 {
373 assert(false);
374 }
375
376///
377///\brief Implementation for a vector with members
378///
379 template<typename T>
380 class ISMemberVector : public ISValue
381 {
382 std::vector<T>& value;
383
384 public:
385 ISMemberVector(const ISMemberVector<T>&) { assert(false); };
386
387 ISMemberVector(std::vector<T>& v) : value(v){};
388 virtual rapidjson::Value ToDom(rapidjson::Document& d);
389 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
390 };
391
392 template<typename T>
393 rapidjson::Value
394 ISMemberVector<T>::ToDom(rapidjson::Document& d)
395 {
396 rapidjson::Value a;
397 a.SetArray();
398 debug = true;
399 for (auto& element : value) {
400 rapidjson::Value v = element.ToDom(d);
401 a.PushBack(v, d.GetAllocator());
402 }
403 debug = false;
404 return a;
405 }
406
407 template<typename T>
408 void
409 ISMemberVector<T>::FromDom(rapidjson::Value& v, rapidjson::Document& d)
410 {
411 for (rapidjson::SizeType i = 0; i < v.Size();
412 i++) { // rapidjson uses SizeType instead of size_t.
413 T cv;
414 cv.FromDom(v[i], d);
415 value.push_back(cv);
416 }
417 }
418
419 using ISIV = std::vector<int>;
420
421///
422///\brief Implementation for a vector with integers
423///
424 class ISIntVector : public ISValue
425 {
426 std::vector<int>& value;
427
428 public:
430 virtual rapidjson::Value ToDom(rapidjson::Document& d);
431 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
432 };
433
434 using ISFV = std::vector<float>;
435
436///
437///\brief Implementation for a vector with floats
438///
439 class ISFloatVector : public ISValue
440 {
441 std::vector<float>& value;
442
443 public:
445 virtual rapidjson::Value ToDom(rapidjson::Document& d);
446 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
447 };
448
449 using ISDV = std::vector<double>;
450
451///
452///\brief Implementation for a vector with doubles
453///
454 class ISDoubleVector : public ISValue
455 {
456 std::vector<double>& value;
457
458 public:
460 virtual rapidjson::Value ToDom(rapidjson::Document& d);
461 virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
462 };
463
464 // using ISBV = std::vector<bool>;
465 // class ISBoolVector: public ISValue {
466 // std::vector<bool> &value;
467 // public:
468 // ISBoolVector (ISBV &v) : value(v) {};
469 // virtual rapidjson::Value ToDom(rapidjson::Document& d);
470 // virtual void FromDom(rapidjson::Value& v, rapidjson::Document& d);
471 //};
472
473///
474///\brief Implemented for future expansion
475///
477 { // OBS OBS this is an implementation of the Singleton design pattern.
478 public:
479 static ISConstructors&
481 {
482 static ISConstructors instance; // Guaranteed to be destroyed.
483 // Instantiated on first use.
484 return instance;
485 }
486
487 private:
488 ISConstructors(){}; // Constructor? (the {} brackets) are needed here.
489
490 std::map<std::string, Json::ISValuePtr (*)()> m_TheRegistry;
491
492 public:
494 void operator=(const ISConstructors&) = delete;
495
496 int AddConstructor(std::string name, ISValuePtr (*creator)());
497 ISValuePtr GetObject(std::string name);
498 };
499///
500///\brief Function to start serializing an onbject.
501///
502///\param std::string filename
503///Name of the file you want to store the application data in.
504///
505///\param ISValue* p
506///A pointer to the object you want to serialize.
507///
508 void serialize(std::string filename, ISValue* p);
509///
510///\brief Function to start deserializing a file
511///
512///\param std::string filename
513///Name of the file you want to extract data from.
514///
515///\param ISValue* p
516///A pointer to the top object so it know where to start.
517///
518 void deserialize(std::string filename, ISValue* p);
519///
520///\brief Macros
521///To serialize an object you need to have the GetProperty() function in the object.
522///This is complex for each application programmer to execute so therefore these macros have benn implemented.
523///Each macro start with JSONSTART then each of the types you want to serialize and to end the macro you write JSONEND.
524///
525#define JSON \
526 public \
527 Json::ISValue
528
529#define JSONSTART \
530 virtual Json::ISProperties GetProperty() \
531 { \
532 Json::ISProperties prop = {
533#define JSONINT(m) \
534 { \
535# m, std::make_shared < Json::ISInt>(m) \
536 }
537#define JSONINTVECTOR(m) \
538 { \
539# m, std::make_shared < Json::ISIntVector>(m) \
540 }
541#define JSONFLOAT(m) \
542 { \
543# m, std::make_shared < Json::ISFloat>(m) \
544 }
545#define JSONFLOATVECTOR(m) \
546 { \
547# m, std::make_shared < Json::ISFloatVector>(m) \
548 }
549#define JSONDOUBLE(m) \
550 { \
551# m, std::make_shared < Json::ISDouble>(m) \
552 }
553#define JSONDOUBLEVECTOR(m) \
554 { \
555# m, std::make_shared < Json::ISDoubleVector>(m) \
556 }
557#define JSONBOOL(m) \
558 { \
559# m, std::make_shared < Json::ISBool>(m) \
560 }
561#define JSONSTRING(m) \
562 { \
563# m, std::make_shared < Json::ISString>(m) \
564 }
565#define JSONOBJECT(T, m) \
566 { \
567# m, std::make_shared < Json::ISObject < T>>(m) \
568 }
569#define JSONOBJECTVECTOR(T, m) \
570 { \
571# m, std::make_shared < Json::ISObjectVector < T>>(m) \
572 }
573#define JSONOBJVECVEC(T, m) \
574 { \
575# m, std::make_shared < Json::ISObjVecVec < T>>(m) \
576 }
577#define JSONMEMBER(T, m) \
578 { \
579# m, std::make_shared < Json::ISMember < T>>(m) \
580 }
581#define JSONMEMBERVECTOR(T, m) \
582 { \
583# m, std::make_shared < Json::ISMemberVector < T>>(m) \
584 }
585#define JSONMEMVECVEC(T, m) \
586 { \
587# m, std::make_shared < Json::ISMemVecVec < T>>(m) \
588 }
589
590#define JSONEND \
591 } \
592 ; \
593 return prop; \
594 } \
595 ;
596
597} // namespace Json
Implementation for bools.
Definition: serializer.h:122
bool & value
Definition: serializer.h:123
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.
Definition: serializer.cpp:65
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...
Definition: serializer.cpp:73
ISBool(bool &v)
Definition: serializer.h:126
Implemented for future expansion.
Definition: serializer.h:477
void operator=(const ISConstructors &)=delete
int AddConstructor(std::string name, ISValuePtr(*creator)())
Definition: serializer.cpp:190
ISValuePtr GetObject(std::string name)
Definition: serializer.cpp:198
ISConstructors(const ISConstructors &)=delete
std::map< std::string, Json::ISValuePtr(*)()> m_TheRegistry
Definition: serializer.h:490
static ISConstructors & GetInstance()
Definition: serializer.h:480
Implementation for a vector with doubles.
Definition: serializer.h:455
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.
Definition: serializer.cpp:168
std::vector< double > & value
Definition: serializer.h:456
ISDoubleVector(ISDV &v)
Definition: serializer.h:459
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...
Definition: serializer.cpp:181
Implementation for doubles.
Definition: serializer.h:109
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...
Definition: serializer.cpp:58
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.
Definition: serializer.cpp:48
ISDouble(double &v)
Definition: serializer.h:113
double & value
Definition: serializer.h:110
Implementation for a vector with floats.
Definition: serializer.h:440
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...
Definition: serializer.cpp:159
ISFloatVector(ISFV &v)
Definition: serializer.h:444
std::vector< float > & value
Definition: serializer.h:441
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.
Definition: serializer.cpp:146
Implementation for floats.
Definition: serializer.h:96
ISFloat(float &v)
Definition: serializer.h:100
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...
Definition: serializer.cpp:41
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.
Definition: serializer.cpp:33
float & value
Definition: serializer.h:97
Implementation for a vector with integers.
Definition: serializer.h:425
ISIntVector(ISIV &v)
Definition: serializer.h:429
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.
Definition: serializer.cpp:124
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...
Definition: serializer.cpp:137
std::vector< int > & value
Definition: serializer.h:426
Implementation for integers.
Definition: serializer.h:83
int & value
Definition: serializer.h:84
ISInt(int &v)
Definition: serializer.h:87
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...
Definition: serializer.cpp:26
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.
Definition: serializer.cpp:18
Implementation for a vector with vectors with members.
Definition: serializer.h:288
std::vector< std::vector< T > > & value
Definition: serializer.h:289
ISMemVecVec(std::vector< std::vector< T > > &v)
Definition: serializer.h:292
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...
Definition: serializer.h:317
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.
Definition: serializer.h:299
Implementation for a vector with members.
Definition: serializer.h:381
ISMemberVector(std::vector< T > &v)
Definition: serializer.h:387
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...
Definition: serializer.h:409
std::vector< T > & value
Definition: serializer.h:382
ISMemberVector(const ISMemberVector< T > &)
Definition: serializer.h:385
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.
Definition: serializer.h:394
Implementation for Members.
Definition: serializer.h:335
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.
Definition: serializer.h:348
void CreateObject()
For future expansion.
Definition: serializer.h:371
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...
Definition: serializer.h:355
virtual rapidjson::Value GetName(rapidjson::Document &d)
For future expansion.
Definition: serializer.h:362
Implementation for a vector with vectors with objects.
Definition: serializer.h:240
ISObjVecVec(std::vector< std::vector< std::shared_ptr< T > > > &v)
Definition: serializer.h:244
std::vector< std::vector< std::shared_ptr< T > > > & value
Definition: serializer.h:241
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...
Definition: serializer.h:270
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.
Definition: serializer.h:252
Implementation for a vector with objects.
Definition: serializer.h:201
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.
Definition: serializer.h:212
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...
Definition: serializer.h:225
std::vector< std::shared_ptr< T > > & value
Definition: serializer.h:202
ISObjectVector(std::vector< std::shared_ptr< T > > &v)
Definition: serializer.h:205
Implementation for objects.
Definition: serializer.h:149
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...
Definition: serializer.h:172
ISObject(std::shared_ptr< T > &v)
Definition: serializer.h:153
void CreateObject()
For future expansion.
Definition: serializer.h:191
std::shared_ptr< T > & value
Definition: serializer.h:150
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.
Definition: serializer.h:162
virtual rapidjson::Value GetName(rapidjson::Document &d)
For future expansion.
Definition: serializer.h:182
Implementation for strings.
Definition: serializer.h:135
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...
Definition: serializer.cpp:88
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.
Definition: serializer.cpp:80
std::string & value
Definition: serializer.h:136
ISString(std::string &v)
Definition: serializer.h:139
Rflection is made possible by the help of the ISValue class and the type classes.
Definition: serializer.h:42
virtual void CreateObject()
For future expansion.
Definition: serializer.h:55
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.
Definition: serializer.cpp:95
virtual ISProperties GetProperty()
GetProperty enables the serializer to deal with composite type like objects and members.
Definition: serializer.h:48
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...
Definition: serializer.cpp:113
virtual rapidjson::Value GetName(rapidjson::Document &d)
For future expansion.
Definition: serializer.h:60
void deserialize(std::string filename, ISValue *p)
Function to start deserializing a file.
Definition: serializer.cpp:235
std::vector< ISValuePtr > ISValues
Definition: serializer.h:18
std::vector< double > ISDV
Definition: serializer.h:449
void serialize(std::string filename, ISValue *p)
Function to start serializing an onbject.
Definition: serializer.cpp:206
std::vector< float > ISFV
Definition: serializer.h:434
std::vector< ISProperty > ISProperties
ISProperties is a vector with ISProperty.
Definition: serializer.h:34
std::shared_ptr< ISValue > ISValuePtr
Definition: serializer.h:17
std::vector< int > ISIV
Definition: serializer.h:419
bool debug
Definition: serializer.cpp:12
Serializing and deserializing (persistent values) requires recflection which is a way for the program...
Definition: serializer.h:27
std::string name
Definition: serializer.h:28
ISValuePtr value
Definition: serializer.h:29