OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
JSON.h
Go to the documentation of this file.
1
4// ###########################################################################################################################################################################################################################################################################################################################
5
6#pragma once
7
8// OpenTwin header
11
12// rapidjson header
13#include <rapidjson/document.h>
14#include <rapidjson/writer.h>
15
16// std header
17#include <list>
18#include <vector>
19#include <string>
20
21namespace ot {
22
24 typedef rapidjson::SizeType JsonSizeType;
25
27 typedef rapidjson::Value JsonValue;
28
30 typedef rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator> JsonAllocator;
31
32 //typedef rapidjson::GenericObject<false, rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>> JsonObjectHandle;
33
35 typedef rapidjson::GenericObject<true, rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>> ConstJsonObject;
36
37 typedef std::list<ConstJsonObject> ConstJsonObjectList;
38
39 //typedef rapidjson::GenericArray<false, rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>> JsonArrayHandle;
40
42 typedef rapidjson::GenericArray<true, rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>> ConstJsonArray;
43
44 typedef std::list<ConstJsonArray> ConstJsonArrayList;
45
47 typedef rapidjson::GenericMemberIterator<true, rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>> JsonMemberIterator;
48
51 class JsonNullValue : public JsonValue {
53 public:
54 JsonNullValue() : JsonValue(rapidjson::kNullType) {};
55 virtual ~JsonNullValue() {};
56 };
57
58 // ###########################################################################################################################################################################################################################################################################################################################
59
60 // ###########################################################################################################################################################################################################################################################################################################################
61
62 // ###########################################################################################################################################################################################################################################################################################################################
63
64 class JsonNumber : public JsonValue {
67 public:
68 JsonNumber(long _value) : JsonValue(rapidjson::kNumberType) { this->SetInt64(_value); };
69 JsonNumber(long long _value) : JsonValue(rapidjson::kNumberType) { this->SetInt64(_value); };
70 JsonNumber(unsigned long _value) : JsonValue(rapidjson::kNumberType) { this->SetUint64(_value); };
71 JsonNumber(unsigned long long _value) : JsonValue(rapidjson::kNumberType) { this->SetUint64(_value); };
72 JsonNumber(float _value) : JsonValue(rapidjson::kNumberType) { this->SetFloat(_value); };
73 JsonNumber(double _value) : JsonValue(rapidjson::kNumberType) { this->SetDouble(_value); };
74 };
75
76 // ###########################################################################################################################################################################################################################################################################################################################
77
78 // ###########################################################################################################################################################################################################################################################################################################################
79
80 // ###########################################################################################################################################################################################################################################################################################################################
81
84 class JsonString : public JsonValue {
87 public:
88 JsonString(const char* _cstr, JsonAllocator& _allocator) : JsonValue(_cstr, _allocator) {};
89 JsonString(const std::string& _str, JsonAllocator& _allocator) : JsonValue(_str.c_str(), _allocator) {};
90 virtual ~JsonString() {};
91 };
92
93 // ###########################################################################################################################################################################################################################################################################################################################
94
95 // ###########################################################################################################################################################################################################################################################################################################################
96
97 // ###########################################################################################################################################################################################################################################################################################################################
98
101 class JsonObject : public JsonValue {
103 public:
104 JsonObject() : JsonValue(rapidjson::kObjectType) {};
105 virtual ~JsonObject() {};
106 };
107
108 // ###########################################################################################################################################################################################################################################################################################################################
109
110 // ###########################################################################################################################################################################################################################################################################################################################
111
112 // ###########################################################################################################################################################################################################################################################################################################################
113
116 class JsonArray : public JsonValue {
118 public:
119 explicit JsonArray() : JsonValue(rapidjson::kArrayType) {};
120
122 JsonArray(const std::list<bool>& _lst, JsonAllocator& _allocator)
123 : rapidjson::Value(rapidjson::kArrayType)
124 {
125 for (auto itm : _lst) {
126 this->PushBack(itm, _allocator);
127 }
128 }
129
131 explicit JsonArray(const std::vector<bool>& _vec, JsonAllocator& _allocator)
132 : rapidjson::Value(rapidjson::kArrayType)
133 {
134 for (auto itm : _vec) {
135 this->PushBack(itm, _allocator);
136 }
137 }
138
140 JsonArray(const std::list<int32_t>& _lst, JsonAllocator& _allocator)
141 : rapidjson::Value(rapidjson::kArrayType)
142 {
143 for (auto itm : _lst) {
144 this->PushBack(itm, _allocator);
145 }
146 }
147
149 explicit JsonArray(const std::vector<int32_t>& _vec, JsonAllocator& _allocator)
150 : rapidjson::Value(rapidjson::kArrayType)
151 {
152 for (auto itm : _vec) {
153 this->PushBack(itm, _allocator);
154 }
155 }
156
158 explicit JsonArray(const std::list<uint32_t>& _lst, JsonAllocator& _allocator)
159 : rapidjson::Value(rapidjson::kArrayType)
160 {
161 for (auto itm : _lst) {
162 this->PushBack(itm, _allocator);
163 }
164 }
165
167 explicit JsonArray(const std::vector<uint32_t>& _vec, JsonAllocator& _allocator)
168 : rapidjson::Value(rapidjson::kArrayType)
169 {
170 for (auto itm : _vec) {
171 this->PushBack(itm, _allocator);
172 }
173 }
174
176 explicit JsonArray(const std::list<int64_t>& _lst, JsonAllocator& _allocator)
177 : rapidjson::Value(rapidjson::kArrayType)
178 {
179 for (auto itm : _lst) {
180 this->PushBack(itm, _allocator);
181 }
182 }
183
185 explicit JsonArray(const std::vector<int64_t>& _vec, JsonAllocator& _allocator)
186 : rapidjson::Value(rapidjson::kArrayType)
187 {
188 for (auto itm : _vec) {
189 this->PushBack(itm, _allocator);
190 }
191 }
192
194 explicit JsonArray(const std::list<uint64_t>& _lst, JsonAllocator& _allocator)
195 : rapidjson::Value(rapidjson::kArrayType)
196 {
197 for (auto itm : _lst) {
198 this->PushBack(itm, _allocator);
199 }
200 }
201
203 explicit JsonArray(const std::vector<uint64_t>& _vec, JsonAllocator& _allocator)
204 : rapidjson::Value(rapidjson::kArrayType)
205 {
206 for (auto itm : _vec) {
207 this->PushBack(itm, _allocator);
208 }
209 }
210
212 explicit JsonArray(const std::list<float>& _lst, JsonAllocator& _allocator)
213 : rapidjson::Value(rapidjson::kArrayType)
214 {
215 for (auto itm : _lst) {
216 this->PushBack(itm, _allocator);
217 }
218 }
219
221 explicit JsonArray(const std::vector<float>& _vec, JsonAllocator& _allocator)
222 : rapidjson::Value(rapidjson::kArrayType)
223 {
224 for (auto itm : _vec) {
225 this->PushBack(itm, _allocator);
226 }
227 }
228
230 explicit JsonArray(const std::list<double>& _lst, JsonAllocator& _allocator)
231 : rapidjson::Value(rapidjson::kArrayType)
232 {
233 for (auto itm : _lst) {
234 this->PushBack(itm, _allocator);
235 }
236 }
237
239 explicit JsonArray(const std::vector<double>& _vec, JsonAllocator& _allocator)
240 : rapidjson::Value(rapidjson::kArrayType)
241 {
242 for (auto itm : _vec) {
243 this->PushBack(itm, _allocator);
244 }
245 }
246
248 explicit JsonArray(const std::list<std::string>& _lst, JsonAllocator& _allocator)
249 : rapidjson::Value(rapidjson::kArrayType)
250 {
251 for (auto itm : _lst) {
252 this->PushBack(JsonString(itm, _allocator), _allocator);
253 }
254 }
255
257 explicit JsonArray(const std::vector<std::string>& _vec, JsonAllocator& _allocator)
258 : rapidjson::Value(rapidjson::kArrayType)
259 {
260 for (auto itm : _vec) {
261 this->PushBack(JsonString(itm, _allocator), _allocator);
262 }
263 }
264
265 virtual ~JsonArray() {};
266 };
267
268 // ###########################################################################################################################################################################################################################################################################################################################
269
270 // ###########################################################################################################################################################################################################################################################################################################################
271
272 // ###########################################################################################################################################################################################################################################################################################################################
273
276 class JsonDocument : public rapidjson::Document {
277 private:
278 JsonDocument(const JsonDocument&) = delete;
279 JsonDocument& operator = (const JsonDocument&) = delete;
280 public:
283 JsonDocument() : rapidjson::Document(rapidjson::kObjectType) {};
284
287 JsonDocument(rapidjson::Type _type) : rapidjson::Document(_type) {};
288
290 JsonDocument(JsonDocument&& _other) noexcept : rapidjson::Document((rapidjson::Document&& )_other) {};
291
292 virtual ~JsonDocument() {};
293
294 bool fromJson(const std::string& _json) { return this->fromJson(_json.c_str()); };
295 bool fromJson(const char* _fromJson) {
296 this->Parse(_fromJson);
297 return (this->GetType() == rapidjson::kObjectType) || (this->GetType() == rapidjson::kArrayType);
298 }
299
300 const JsonDocument& constRef(void) const { return *this; };
301
303 return this->GetObject();
304 }
305
306 std::string toJson(void) const {
307 // Create String buffer
308 rapidjson::StringBuffer buffer;
309 buffer.Clear();
310
311 // Setup the Writer
312 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
313 this->Accept(writer);
314
315 // Return string
316 return std::string(buffer.GetString());
317 }
318 };
319
320 // ###########################################################################################################################################################################################################################################################################################################################
321
322 // ###########################################################################################################################################################################################################################################################################################################################
323
324 // ###########################################################################################################################################################################################################################################################################################################################
325
327 namespace json {
328
330 OT_CORE_API_EXPORT bool exists(const JsonValue& _value, const char* _member);
331 OT_CORE_API_EXPORT bool exists(const JsonValue& _value, const std::string& _member);
332
334 OT_CORE_API_EXPORT bool exists(const ConstJsonObject& _value, const char* _member);
335 OT_CORE_API_EXPORT bool exists(const ConstJsonObject& _value, const std::string& _member);
336
338 OT_CORE_API_EXPORT bool isNull(const JsonValue& _value, const char* _member);
339 OT_CORE_API_EXPORT bool isNull(const JsonValue& _value, const std::string& _member);
341 OT_CORE_API_EXPORT bool isNull(const ConstJsonObject& _value, const char* _member);
342 OT_CORE_API_EXPORT bool isNull(const ConstJsonObject& _value, const std::string& _member);
343
345 OT_CORE_API_EXPORT bool isBool(const JsonValue& _value, const char* _member);
346 OT_CORE_API_EXPORT bool isBool(const JsonValue& _value, const std::string& _member);
348 OT_CORE_API_EXPORT bool isBool(const ConstJsonObject& _value, const char* _member);
349 OT_CORE_API_EXPORT bool isBool(const ConstJsonObject& _value, const std::string& _member);
350
352 OT_CORE_API_EXPORT bool isInt(const JsonValue& _value, const char* _member);
353 OT_CORE_API_EXPORT bool isInt(const JsonValue& _value, const std::string& _member);
355 OT_CORE_API_EXPORT bool isInt(const ConstJsonObject& _value, const char* _member);
356 OT_CORE_API_EXPORT bool isInt(const ConstJsonObject& _value, const std::string& _member);
357
359 OT_CORE_API_EXPORT bool isUInt(const JsonValue& _value, const char* _member);
360 OT_CORE_API_EXPORT bool isUInt(const JsonValue& _value, const std::string& _member);
362 OT_CORE_API_EXPORT bool isUInt(const ConstJsonObject& _value, const char* _member);
363 OT_CORE_API_EXPORT bool isUInt(const ConstJsonObject& _value, const std::string& _member);
364
366 OT_CORE_API_EXPORT bool isInt64(const JsonValue& _value, const char* _member);
367 OT_CORE_API_EXPORT bool isInt64(const JsonValue& _value, const std::string& _member);
369 OT_CORE_API_EXPORT bool isInt64(const ConstJsonObject& _value, const char* _member);
370 OT_CORE_API_EXPORT bool isInt64(const ConstJsonObject& _value, const std::string& _member);
371
373 OT_CORE_API_EXPORT bool isUInt64(const JsonValue& _value, const char* _member);
374 OT_CORE_API_EXPORT bool isUInt64(const JsonValue& _value, const std::string& _member);
376 OT_CORE_API_EXPORT bool isUInt64(const ConstJsonObject& _value, const char* _member);
377 OT_CORE_API_EXPORT bool isUInt64(const ConstJsonObject& _value, const std::string& _member);
378
380 OT_CORE_API_EXPORT bool isFloat(const JsonValue& _value, const char* _member);
381 OT_CORE_API_EXPORT bool isFloat(const JsonValue& _value, const std::string& _member);
383 OT_CORE_API_EXPORT bool isFloat(const ConstJsonObject& _value, const char* _member);
384 OT_CORE_API_EXPORT bool isFloat(const ConstJsonObject& _value, const std::string& _member);
385
387 OT_CORE_API_EXPORT bool isDouble(const JsonValue& _value, const char* _member);
388 OT_CORE_API_EXPORT bool isDouble(const JsonValue& _value, const std::string& _member);
390 OT_CORE_API_EXPORT bool isDouble(const ConstJsonObject& _value, const char* _member);
391 OT_CORE_API_EXPORT bool isDouble(const ConstJsonObject& _value, const std::string& _member);
392
394 OT_CORE_API_EXPORT bool isString(const JsonValue& _value, const char* _member);
395 OT_CORE_API_EXPORT bool isString(const JsonValue& _value, const std::string& _member);
397 OT_CORE_API_EXPORT bool isString(const ConstJsonObject& _value, const char* _member);
398 OT_CORE_API_EXPORT bool isString(const ConstJsonObject& _value, const std::string& _member);
399
401 OT_CORE_API_EXPORT bool isObject(const JsonValue& _value, const char* _member);
402 OT_CORE_API_EXPORT bool isObject(const JsonValue& _value, const std::string& _member);
404 OT_CORE_API_EXPORT bool isObject(const ConstJsonObject& _value, const char* _member);
405 OT_CORE_API_EXPORT bool isObject(const ConstJsonObject& _value, const std::string& _member);
406
408 OT_CORE_API_EXPORT bool isArray(const JsonValue& _value, const char* _member);
409 OT_CORE_API_EXPORT bool isArray(const JsonValue& _value, const std::string& _member);
411 OT_CORE_API_EXPORT bool isArray(const ConstJsonObject& _value, const char* _member);
412 OT_CORE_API_EXPORT bool isArray(const ConstJsonObject& _value, const std::string& _member);
413
416 OT_CORE_API_EXPORT bool getBool(const JsonValue& _value, const char* _member, bool _default = false);
417 OT_CORE_API_EXPORT bool getBool(const JsonValue& _value, const std::string& _member, bool _default = false);
418 OT_CORE_API_EXPORT bool getBool(const ConstJsonObject& _value, const char* _member, bool _default = false);
419 OT_CORE_API_EXPORT bool getBool(const ConstJsonObject& _value, const std::string& _member, bool _default = false);
420
423 OT_CORE_API_EXPORT int32_t getInt(const JsonValue& _value, const char* _member, int32_t _default = 0);
424 OT_CORE_API_EXPORT int32_t getInt(const JsonValue& _value, const std::string& _member, int32_t _default = 0);
425 OT_CORE_API_EXPORT int32_t getInt(const ConstJsonObject& _value, const char* _member, int32_t _default = 0);
426 OT_CORE_API_EXPORT int32_t getInt(const ConstJsonObject& _value, const std::string& _member, int32_t _default = 0);
427
430 OT_CORE_API_EXPORT uint32_t getUInt(const JsonValue& _value, const char* _member, uint32_t _default = 0);
431 OT_CORE_API_EXPORT uint32_t getUInt(const JsonValue& _value, const std::string& _member, uint32_t _default = 0);
432 OT_CORE_API_EXPORT uint32_t getUInt(const ConstJsonObject& _value, const char* _member, uint32_t _default = 0);
433 OT_CORE_API_EXPORT uint32_t getUInt(const ConstJsonObject& _value, const std::string& _member, uint32_t _default = 0);
434
437 OT_CORE_API_EXPORT int64_t getInt64(const JsonValue& _value, const char* _member, int64_t _default = 0);
438 OT_CORE_API_EXPORT int64_t getInt64(const JsonValue& _value, const std::string& _member, int64_t _default = 0);
439 OT_CORE_API_EXPORT int64_t getInt64(const ConstJsonObject& _value, const char* _member, int64_t _default = 0);
440 OT_CORE_API_EXPORT int64_t getInt64(const ConstJsonObject& _value, const std::string& _member, int64_t _default = 0);
441
444 OT_CORE_API_EXPORT uint64_t getUInt64(const JsonValue& _value, const char* _member, uint64_t _default = 0);
445 OT_CORE_API_EXPORT uint64_t getUInt64(const JsonValue& _value, const std::string& _member, uint64_t _default = 0);
446 OT_CORE_API_EXPORT uint64_t getUInt64(const ConstJsonObject& _value, const char* _member, uint64_t _default = 0);
447 OT_CORE_API_EXPORT uint64_t getUInt64(const ConstJsonObject& _value, const std::string& _member, uint64_t _default = 0);
448
451 OT_CORE_API_EXPORT float getFloat(const JsonValue& _value, const char* _member, float _default = 0.f);
452 OT_CORE_API_EXPORT float getFloat(const JsonValue& _value, const std::string& _member, float _default = 0.f);
453 OT_CORE_API_EXPORT float getFloat(const ConstJsonObject& _value, const char* _member, float _default = 0.f);
454 OT_CORE_API_EXPORT float getFloat(const ConstJsonObject& _value, const std::string& _member, float _default = 0.f);
455
458 OT_CORE_API_EXPORT double getDouble(const JsonValue& _value, const char* _member, double _default = 0.);
459 OT_CORE_API_EXPORT double getDouble(const JsonValue& _value, const std::string& _member, double _default = 0.);
460 OT_CORE_API_EXPORT double getDouble(const ConstJsonObject& _value, const char* _member, double _default = 0.);
461 OT_CORE_API_EXPORT double getDouble(const ConstJsonObject& _value, const std::string& _member, double _default = 0.);
462
465 OT_CORE_API_EXPORT std::string getString(const JsonValue& _value, const char* _member, const std::string& _default = std::string());
466 OT_CORE_API_EXPORT std::string getString(const JsonValue& _value, const std::string& _member, const std::string& _default = std::string());
467 OT_CORE_API_EXPORT std::string getString(const ConstJsonObject& _value, const char* _member, const std::string& _default = std::string());
468 OT_CORE_API_EXPORT std::string getString(const ConstJsonObject& _value, const std::string& _member, const std::string& _default = std::string());
469
472 OT_CORE_API_EXPORT ConstJsonObject getObject(const JsonValue& _value, const char* _member);
473 OT_CORE_API_EXPORT ConstJsonObject getObject(const JsonValue& _value, const std::string& _member);
474 OT_CORE_API_EXPORT ConstJsonObject getObject(const ConstJsonObject& _value, const char* _member);
475 OT_CORE_API_EXPORT ConstJsonObject getObject(const ConstJsonObject& _value, const std::string& _member);
476
479 OT_CORE_API_EXPORT ConstJsonArray getArray(const JsonValue& _value, const char* _member);
480 OT_CORE_API_EXPORT ConstJsonArray getArray(const JsonValue& _value, const std::string& _member);
481 OT_CORE_API_EXPORT ConstJsonArray getArray(const ConstJsonObject& _value, const char* _member);
482 OT_CORE_API_EXPORT ConstJsonArray getArray(const ConstJsonObject& _value, const std::string& _member);
483
486 OT_CORE_API_EXPORT std::list<bool> getBoolList(const JsonValue& _value, const char* _member, const std::list<bool>& _default = std::list<bool>());
487 OT_CORE_API_EXPORT std::list<bool> getBoolList(const JsonValue& _value, const std::string& _member, const std::list<bool>& _default = std::list<bool>());
488 OT_CORE_API_EXPORT std::list<bool> getBoolList(const ConstJsonObject& _value, const char* _member, const std::list<bool>& _default = std::list<bool>());
489 OT_CORE_API_EXPORT std::list<bool> getBoolList(const ConstJsonObject& _value, const std::string& _member, const std::list<bool>& _default = std::list<bool>());
490
493 OT_CORE_API_EXPORT std::list<int32_t> getIntList(const JsonValue& _value, const char* _member, const std::list<int32_t>& _default = std::list<int32_t>());
494 OT_CORE_API_EXPORT std::list<int32_t> getIntList(const JsonValue& _value, const std::string& _member, const std::list<int32_t>& _default = std::list<int32_t>());
495 OT_CORE_API_EXPORT std::list<int32_t> getIntList(const ConstJsonObject& _value, const char* _member, const std::list<int32_t>& _default = std::list<int32_t>());
496 OT_CORE_API_EXPORT std::list<int32_t> getIntList(const ConstJsonObject& _value, const std::string& _member, const std::list<int32_t>& _default = std::list<int32_t>());
497
500 OT_CORE_API_EXPORT std::list<uint32_t> getUIntList(const JsonValue& _value, const char* _member, const std::list<uint32_t>& _default = std::list<uint32_t>());
501 OT_CORE_API_EXPORT std::list<uint32_t> getUIntList(const JsonValue& _value, const std::string& _member, const std::list<uint32_t>& _default = std::list<uint32_t>());
502 OT_CORE_API_EXPORT std::list<uint32_t> getUIntList(const ConstJsonObject& _value, const char* _member, const std::list<uint32_t>& _default = std::list<uint32_t>());
503 OT_CORE_API_EXPORT std::list<uint32_t> getUIntList(const ConstJsonObject& _value, const std::string& _member, const std::list<uint32_t>& _default = std::list<uint32_t>());
504
507 OT_CORE_API_EXPORT std::list<int64_t> getInt64List(const JsonValue& _value, const char* _member, const std::list<int64_t>& _default = std::list<int64_t>());
508 OT_CORE_API_EXPORT std::list<int64_t> getInt64List(const JsonValue& _value, const std::string& _member, const std::list<int64_t>& _default = std::list<int64_t>());
509 OT_CORE_API_EXPORT std::list<int64_t> getInt64List(const ConstJsonObject& _value, const char* _member, const std::list<int64_t>& _default = std::list<int64_t>());
510 OT_CORE_API_EXPORT std::list<int64_t> getInt64List(const ConstJsonObject& _value, const std::string& _member, const std::list<int64_t>& _default = std::list<int64_t>());
511
514 OT_CORE_API_EXPORT std::list<uint64_t> getUInt64List(const JsonValue& _value, const char* _member, const std::list<uint64_t>& _default = std::list<uint64_t>());
515 OT_CORE_API_EXPORT std::list<uint64_t> getUInt64List(const JsonValue& _value, const std::string& _member, const std::list<uint64_t>& _default = std::list<uint64_t>());
516 OT_CORE_API_EXPORT std::list<uint64_t> getUInt64List(const ConstJsonObject& _value, const char* _member, const std::list<uint64_t>& _default = std::list<uint64_t>());
517 OT_CORE_API_EXPORT std::list<uint64_t> getUInt64List(const ConstJsonObject& _value, const std::string& _member, const std::list<uint64_t>& _default = std::list<uint64_t>());
518
521 OT_CORE_API_EXPORT std::list<float> getFloatList(const JsonValue& _value, const char* _member, const std::list<float>& _default = std::list<float>());
522 OT_CORE_API_EXPORT std::list<float> getFloatList(const JsonValue& _value, const std::string& _member, const std::list<float>& _default = std::list<float>());
523 OT_CORE_API_EXPORT std::list<float> getFloatList(const ConstJsonObject& _value, const char* _member, const std::list<float>& _default = std::list<float>());
524 OT_CORE_API_EXPORT std::list<float> getFloatList(const ConstJsonObject& _value, const std::string& _member, const std::list<float>& _default = std::list<float>());
525
528 OT_CORE_API_EXPORT std::list<double> getDoubleList(const JsonValue& _value, const char* _member, const std::list<double>& _default = std::list<double>());
529 OT_CORE_API_EXPORT std::list<double> getDoubleList(const JsonValue& _value, const std::string& _member, const std::list<double>& _default = std::list<double>());
530 OT_CORE_API_EXPORT std::list<double> getDoubleList(const ConstJsonObject& _value, const char* _member, const std::list<double>& _default = std::list<double>());
531 OT_CORE_API_EXPORT std::list<double> getDoubleList(const ConstJsonObject& _value, const std::string& _member, const std::list<double>& _default = std::list<double>());
532
535 OT_CORE_API_EXPORT std::list<std::string> getStringList(const JsonValue& _value, const char* _member, const std::list<std::string>& _default = std::list<std::string>());
536 OT_CORE_API_EXPORT std::list<std::string> getStringList(const JsonValue& _value, const std::string& _member, const std::list<std::string>& _default = std::list<std::string>());
537 OT_CORE_API_EXPORT std::list<std::string> getStringList(const ConstJsonObject& _value, const char* _member, const std::list<std::string>& _default = std::list<std::string>());
538 OT_CORE_API_EXPORT std::list<std::string> getStringList(const ConstJsonObject& _value, const std::string& _member, const std::list<std::string>& _default = std::list<std::string>());
539
542 OT_CORE_API_EXPORT std::list<ConstJsonObject> getObjectList(const JsonValue& _value, const char* _member);
543 OT_CORE_API_EXPORT std::list<ConstJsonObject> getObjectList(const JsonValue& _value, const std::string& _member);
544 OT_CORE_API_EXPORT std::list<ConstJsonObject> getObjectList(const ConstJsonObject& _value, const char* _member);
545 OT_CORE_API_EXPORT std::list<ConstJsonObject> getObjectList(const ConstJsonObject& _value, const std::string& _member);
546
549 OT_CORE_API_EXPORT std::list<ConstJsonArray> getArrayList(const JsonValue& _value, const char* _member);
550 OT_CORE_API_EXPORT std::list<ConstJsonArray> getArrayList(const JsonValue& _value, const std::string& _member);
551 OT_CORE_API_EXPORT std::list<ConstJsonArray> getArrayList(const ConstJsonObject& _value, const char* _member);
552 OT_CORE_API_EXPORT std::list<ConstJsonArray> getArrayList(const ConstJsonObject& _value, const std::string& _member);
553
556 OT_CORE_API_EXPORT std::vector<bool> getBoolVector(const JsonValue& _value, const char* _member, const std::vector<bool>& _default = std::vector<bool>());
557 OT_CORE_API_EXPORT std::vector<bool> getBoolVector(const JsonValue& _value, const std::string& _member, const std::vector<bool>& _default = std::vector<bool>());
558 OT_CORE_API_EXPORT std::vector<bool> getBoolVector(const ConstJsonObject& _value, const char* _member, const std::vector<bool>& _default = std::vector<bool>());
559 OT_CORE_API_EXPORT std::vector<bool> getBoolVector(const ConstJsonObject& _value, const std::string& _member, const std::vector<bool>& _default = std::vector<bool>());
560
563 OT_CORE_API_EXPORT std::vector<int32_t> getIntVector(const JsonValue& _value, const char* _member, const std::vector<int32_t>& _default = std::vector<int32_t>());
564 OT_CORE_API_EXPORT std::vector<int32_t> getIntVector(const JsonValue& _value, const std::string& _member, const std::vector<int32_t>& _default = std::vector<int32_t>());
565 OT_CORE_API_EXPORT std::vector<int32_t> getIntVector(const ConstJsonObject& _value, const char* _member, const std::vector<int32_t>& _default = std::vector<int32_t>());
566 OT_CORE_API_EXPORT std::vector<int32_t> getIntVector(const ConstJsonObject& _value, const std::string& _member, const std::vector<int32_t>& _default = std::vector<int32_t>());
567
570 OT_CORE_API_EXPORT std::vector<uint32_t> getUIntVector(const JsonValue& _value, const char* _member, const std::vector<uint32_t>& _default = std::vector<uint32_t>());
571 OT_CORE_API_EXPORT std::vector<uint32_t> getUIntVector(const JsonValue& _value, const std::string& _member, const std::vector<uint32_t>& _default = std::vector<uint32_t>());
572 OT_CORE_API_EXPORT std::vector<uint32_t> getUIntVector(const ConstJsonObject& _value, const char* _member, const std::vector<uint32_t>& _default = std::vector<uint32_t>());
573 OT_CORE_API_EXPORT std::vector<uint32_t> getUIntVector(const ConstJsonObject& _value, const std::string& _member, const std::vector<uint32_t>& _default = std::vector<uint32_t>());
574
577 OT_CORE_API_EXPORT std::vector<int64_t> getInt64Vector(const JsonValue& _value, const char* _member, const std::vector<int64_t>& _default = std::vector<int64_t>());
578 OT_CORE_API_EXPORT std::vector<int64_t> getInt64Vector(const JsonValue& _value, const std::string& _member, const std::vector<int64_t>& _default = std::vector<int64_t>());
579 OT_CORE_API_EXPORT std::vector<int64_t> getInt64Vector(const ConstJsonObject& _value, const char* _member, const std::vector<int64_t>& _default = std::vector<int64_t>());
580 OT_CORE_API_EXPORT std::vector<int64_t> getInt64Vector(const ConstJsonObject& _value, const std::string& _member, const std::vector<int64_t>& _default = std::vector<int64_t>());
581
584 OT_CORE_API_EXPORT std::vector<uint64_t> getUInt64Vector(const JsonValue& _value, const char* _member, const std::vector<uint64_t>& _default = std::vector<uint64_t>());
585 OT_CORE_API_EXPORT std::vector<uint64_t> getUInt64Vector(const JsonValue& _value, const std::string& _member, const std::vector<uint64_t>& _default = std::vector<uint64_t>());
586 OT_CORE_API_EXPORT std::vector<uint64_t> getUInt64Vector(const ConstJsonObject& _value, const char* _member, const std::vector<uint64_t>& _default = std::vector<uint64_t>());
587 OT_CORE_API_EXPORT std::vector<uint64_t> getUInt64Vector(const ConstJsonObject& _value, const std::string& _member, const std::vector<uint64_t>& _default = std::vector<uint64_t>());
588
591 OT_CORE_API_EXPORT std::vector<float> getFloatVector(const JsonValue& _value, const char* _member, const std::vector<float>& _default = std::vector<float>());
592 OT_CORE_API_EXPORT std::vector<float> getFloatVector(const JsonValue& _value, const std::string& _member, const std::vector<float>& _default = std::vector<float>());
593 OT_CORE_API_EXPORT std::vector<float> getFloatVector(const ConstJsonObject& _value, const char* _member, const std::vector<float>& _default = std::vector<float>());
594 OT_CORE_API_EXPORT std::vector<float> getFloatVector(const ConstJsonObject& _value, const std::string& _member, const std::vector<float>& _default = std::vector<float>());
595
598 OT_CORE_API_EXPORT std::vector<double> getDoubleVector(const JsonValue& _value, const char* _member, const std::vector<double>& _default = std::vector<double>());
599 OT_CORE_API_EXPORT std::vector<double> getDoubleVector(const JsonValue& _value, const std::string& _member, const std::vector<double>& _default = std::vector<double>());
600 OT_CORE_API_EXPORT std::vector<double> getDoubleVector(const ConstJsonObject& _value, const char* _member, const std::vector<double>& _default = std::vector<double>());
601 OT_CORE_API_EXPORT std::vector<double> getDoubleVector(const ConstJsonObject& _value, const std::string& _member, const std::vector<double>& _default = std::vector<double>());
602
605 OT_CORE_API_EXPORT std::vector<std::string> getStringVector(const JsonValue& _value, const char* _member, const std::vector<std::string>& _default = std::vector<std::string>());
606 OT_CORE_API_EXPORT std::vector<std::string> getStringVector(const JsonValue& _value, const std::string& _member, const std::vector<std::string>& _default = std::vector<std::string>());
607 OT_CORE_API_EXPORT std::vector<std::string> getStringVector(const ConstJsonObject& _value, const char* _member, const std::vector<std::string>& _default = std::vector<std::string>());
608 OT_CORE_API_EXPORT std::vector<std::string> getStringVector(const ConstJsonObject& _value, const std::string& _member, const std::vector<std::string>& _default = std::vector<std::string>());
609
612 OT_CORE_API_EXPORT std::vector<ConstJsonObject> getObjectVector(const JsonValue& _value, const char* _member);
613 OT_CORE_API_EXPORT std::vector<ConstJsonObject> getObjectVector(const JsonValue& _value, const std::string& _member);
614 OT_CORE_API_EXPORT std::vector<ConstJsonObject> getObjectVector(const ConstJsonObject& _value, const char* _member);
615 OT_CORE_API_EXPORT std::vector<ConstJsonObject> getObjectVector(const ConstJsonObject& _value, const std::string& _member);
616
619 OT_CORE_API_EXPORT std::vector<ConstJsonArray> getArrayVector(const JsonValue& _value, const char* _member);
620 OT_CORE_API_EXPORT std::vector<ConstJsonArray> getArrayVector(const JsonValue& _value, const std::string& _member);
621 OT_CORE_API_EXPORT std::vector<ConstJsonArray> getArrayVector(const ConstJsonObject& _value, const char* _member);
622 OT_CORE_API_EXPORT std::vector<ConstJsonArray> getArrayVector(const ConstJsonObject& _value, const std::string& _member);
623
626 OT_CORE_API_EXPORT bool* getBoolArray(const JsonValue& _value, const char* _member, JsonSizeType& _size);
627 OT_CORE_API_EXPORT bool* getBoolArray(const JsonValue& _value, const std::string& _member, JsonSizeType& _size);
628 OT_CORE_API_EXPORT bool* getBoolArray(const ConstJsonObject& _value, const char* _member, JsonSizeType& _size);
629 OT_CORE_API_EXPORT bool* getBoolArray(const ConstJsonObject& _value, const std::string& _member, JsonSizeType& _size);
630
633 OT_CORE_API_EXPORT int32_t* getIntArray(const JsonValue& _value, const char* _member, JsonSizeType& _size);
634 OT_CORE_API_EXPORT int32_t* getIntArray(const JsonValue& _value, const std::string& _member, JsonSizeType& _size);
635 OT_CORE_API_EXPORT int32_t* getIntArray(const ConstJsonObject& _value, const char* _member, JsonSizeType& _size);
636 OT_CORE_API_EXPORT int32_t* getIntArray(const ConstJsonObject& _value, const std::string& _member, JsonSizeType& _size);
637
640 OT_CORE_API_EXPORT uint32_t* getUIntArray(const JsonValue& _value, const char* _member, JsonSizeType& _size);
641 OT_CORE_API_EXPORT uint32_t* getUIntArray(const JsonValue& _value, const std::string& _member, JsonSizeType& _size);
642 OT_CORE_API_EXPORT uint32_t* getUIntArray(const ConstJsonObject& _value, const char* _member, JsonSizeType& _size);
643 OT_CORE_API_EXPORT uint32_t* getUIntArray(const ConstJsonObject& _value, const std::string& _member, JsonSizeType& _size);
644
647 OT_CORE_API_EXPORT int64_t* getInt64Array(const JsonValue& _value, const char* _member, JsonSizeType& _size);
648 OT_CORE_API_EXPORT int64_t* getInt64Array(const JsonValue& _value, const std::string& _member, JsonSizeType& _size);
649 OT_CORE_API_EXPORT int64_t* getInt64Array(const ConstJsonObject& _value, const char* _member, JsonSizeType& _size);
650 OT_CORE_API_EXPORT int64_t* getInt64Array(const ConstJsonObject& _value, const std::string& _member, JsonSizeType& _size);
651
654 OT_CORE_API_EXPORT uint64_t* getUInt64Array(const JsonValue& _value, const char* _member, JsonSizeType& _size);
655 OT_CORE_API_EXPORT uint64_t* getUInt64Array(const JsonValue& _value, const std::string& _member, JsonSizeType& _size);
656 OT_CORE_API_EXPORT uint64_t* getUInt64Array(const ConstJsonObject& _value, const char* _member, JsonSizeType& _size);
657 OT_CORE_API_EXPORT uint64_t* getUInt64Array(const ConstJsonObject& _value, const std::string& _member, JsonSizeType& _size);
658
661 OT_CORE_API_EXPORT float* getFloatArray(const JsonValue& _value, const char* _member, JsonSizeType& _size);
662 OT_CORE_API_EXPORT float* getFloatArray(const JsonValue& _value, const std::string& _member, JsonSizeType& _size);
663 OT_CORE_API_EXPORT float* getFloatArray(const ConstJsonObject& _value, const char* _member, JsonSizeType& _size);
664 OT_CORE_API_EXPORT float* getFloatArray(const ConstJsonObject& _value, const std::string& _member, JsonSizeType& _size);
665
668 OT_CORE_API_EXPORT double* getDoubleArray(const JsonValue& _value, const char* _member, JsonSizeType& _size);
669 OT_CORE_API_EXPORT double* getDoubleArray(const JsonValue& _value, const std::string& _member, JsonSizeType& _size);
670 OT_CORE_API_EXPORT double* getDoubleArray(const ConstJsonObject& _value, const char* _member, JsonSizeType& _size);
671 OT_CORE_API_EXPORT double* getDoubleArray(const ConstJsonObject& _value, const std::string& _member, JsonSizeType& _size);
672
673 // ###########################################################################################################################################################################################################################################################################################################################
674
675 // ###########################################################################################################################################################################################################################################################################################################################
676
677 // ###########################################################################################################################################################################################################################################################################################################################
678
680 OT_CORE_API_EXPORT bool isNull(const JsonValue& _value, unsigned int _ix);
682 OT_CORE_API_EXPORT bool isNull(const ConstJsonArray& _value, unsigned int _ix);
683
685 OT_CORE_API_EXPORT bool isBool(const JsonValue& _value, unsigned int _ix);
687 OT_CORE_API_EXPORT bool isBool(const ConstJsonArray& _value, unsigned int _ix);
688
690 OT_CORE_API_EXPORT bool isInt(const JsonValue& _value, unsigned int _ix);
692 OT_CORE_API_EXPORT bool isInt(const ConstJsonArray& _value, unsigned int _ix);
693
695 OT_CORE_API_EXPORT bool isUInt(const JsonValue& _value, unsigned int _ix);
697 OT_CORE_API_EXPORT bool isUInt(const ConstJsonArray& _value, unsigned int _ix);
698
700 OT_CORE_API_EXPORT bool isInt64(const JsonValue& _value, unsigned int _ix);
702 OT_CORE_API_EXPORT bool isInt64(const ConstJsonArray& _value, unsigned int _ix);
703
705 OT_CORE_API_EXPORT bool isUInt64(const JsonValue& _value, unsigned int _ix);
707 OT_CORE_API_EXPORT bool isUInt64(const ConstJsonArray& _value, unsigned int _ix);
708
710 OT_CORE_API_EXPORT bool isFloat(const JsonValue& _value, unsigned int _ix);
712 OT_CORE_API_EXPORT bool isFloat(const ConstJsonArray& _value, unsigned int _ix);
713
715 OT_CORE_API_EXPORT bool isDouble(const JsonValue& _value, unsigned int _ix);
717 OT_CORE_API_EXPORT bool isDouble(const ConstJsonArray& _value, unsigned int _ix);
718
720 OT_CORE_API_EXPORT bool isString(const JsonValue& _value, unsigned int _ix);
722 OT_CORE_API_EXPORT bool isString(const ConstJsonArray& _value, unsigned int _ix);
723
725 OT_CORE_API_EXPORT bool isObject(const JsonValue& _value, unsigned int _ix);
727 OT_CORE_API_EXPORT bool isObject(const ConstJsonArray& _value, unsigned int _ix);
728
730 OT_CORE_API_EXPORT bool isArray(const JsonValue& _value, unsigned int _ix);
732 OT_CORE_API_EXPORT bool isArray(const ConstJsonArray& _value, unsigned int _ix);
733
736 OT_CORE_API_EXPORT bool getBool(const JsonValue& _value, unsigned int _ix, bool _default = false);
737 OT_CORE_API_EXPORT bool getBool(const ConstJsonArray& _value, unsigned int _ix, bool _default = false);
738
741 OT_CORE_API_EXPORT int32_t getInt(const JsonValue& _value, unsigned int _ix, int32_t _default = 0);
742 OT_CORE_API_EXPORT int32_t getInt(const ConstJsonArray& _value, unsigned int _ix, int32_t _default = 0);
743
746 OT_CORE_API_EXPORT uint32_t getUInt(const JsonValue& _value, unsigned int _ix, uint32_t _default = 0);
747 OT_CORE_API_EXPORT uint32_t getUInt(const ConstJsonArray& _value, unsigned int _ix, uint32_t _default = 0);
748
751 OT_CORE_API_EXPORT int64_t getInt64(const JsonValue& _value, unsigned int _ix, int64_t _default = 0);
752 OT_CORE_API_EXPORT int64_t getInt64(const ConstJsonArray& _value, unsigned int _ix, int64_t _default = 0);
753
756 OT_CORE_API_EXPORT uint64_t getUInt64(const JsonValue& _value, unsigned int _ix, uint64_t _default = 0);
757 OT_CORE_API_EXPORT uint64_t getUInt64(const ConstJsonArray& _value, unsigned int _ix, uint64_t _default = 0);
758
761 OT_CORE_API_EXPORT float getFloat(const JsonValue& _value, unsigned int _ix, float _default = 0.f);
762 OT_CORE_API_EXPORT float getFloat(const ConstJsonArray& _value, unsigned int _ix, float _default = 0.f);
763
766 OT_CORE_API_EXPORT double getDouble(const JsonValue& _value, unsigned int _ix, double _default = 0.);
767 OT_CORE_API_EXPORT double getDouble(const ConstJsonArray& _value, unsigned int _ix, double _default = 0.);
768
771 OT_CORE_API_EXPORT std::string getString(const JsonValue& _value, unsigned int _ix, const std::string& _default = std::string());
772 OT_CORE_API_EXPORT std::string getString(const ConstJsonArray& _value, unsigned int _ix, const std::string& _default = std::string());
773
776 OT_CORE_API_EXPORT ConstJsonObject getObject(const JsonValue& _value, unsigned int _ix);
777 OT_CORE_API_EXPORT ConstJsonObject getObject(const ConstJsonArray& _value, unsigned int _ix);
778
781 OT_CORE_API_EXPORT ConstJsonArray getArray(const JsonValue& _value, unsigned int _ix);
782 OT_CORE_API_EXPORT ConstJsonArray getArray(const ConstJsonArray& _value, unsigned int _ix);
783
786 OT_CORE_API_EXPORT std::list<int32_t> getIntList(const JsonValue& _value, unsigned int _ix, const std::list<int32_t>& _default = std::list<int32_t>());
787 OT_CORE_API_EXPORT std::list<int32_t> getIntList(const ConstJsonArray& _value, unsigned int _ix, const std::list<int32_t>& _default = std::list<int32_t>());
788
791 OT_CORE_API_EXPORT std::list<uint32_t> getUIntList(const JsonValue& _value, unsigned int _ix, const std::list<uint32_t>& _default = std::list<uint32_t>());
792 OT_CORE_API_EXPORT std::list<uint32_t> getUIntList(const ConstJsonArray& _value, unsigned int _ix, const std::list<uint32_t>& _default = std::list<uint32_t>());
793
796 OT_CORE_API_EXPORT std::list<int64_t> getInt64List(const JsonValue& _value, unsigned int _ix, const std::list<int64_t>& _default = std::list<int64_t>());
797 OT_CORE_API_EXPORT std::list<int64_t> getInt64List(const ConstJsonArray& _value, unsigned int _ix, const std::list<int64_t>& _default = std::list<int64_t>());
798
801 OT_CORE_API_EXPORT std::list<uint64_t> getUInt64List(const JsonValue& _value, unsigned int _ix, const std::list<uint64_t>& _default = std::list<uint64_t>());
802 OT_CORE_API_EXPORT std::list<uint64_t> getUInt64List(const ConstJsonArray& _value, unsigned int _ix, const std::list<uint64_t>& _default = std::list<uint64_t>());
803
806 OT_CORE_API_EXPORT std::list<std::string> getStringList(const JsonValue& _value, unsigned int _ix, const std::list<std::string>& _default = std::list<std::string>());
807 OT_CORE_API_EXPORT std::list<std::string> getStringList(const ConstJsonArray& _value, unsigned int _ix, const std::list<std::string>& _default = std::list<std::string>());
808
811 OT_CORE_API_EXPORT std::list<ConstJsonObject> getObjectList(const JsonValue& _value, unsigned int _ix);
812 OT_CORE_API_EXPORT std::list<ConstJsonObject> getObjectList(const ConstJsonArray& _value, unsigned int _ix);
813
816 OT_CORE_API_EXPORT std::list<ConstJsonArray> getArrayList(const JsonValue& _value, unsigned int _ix);
817 OT_CORE_API_EXPORT std::list<ConstJsonArray> getArrayList(const ConstJsonArray& _value, unsigned int _ix);
818
821 OT_CORE_API_EXPORT std::vector<int32_t> getIntVector(const JsonValue& _value, unsigned int _ix, const std::vector<int32_t>& _default = std::vector<int32_t>());
822 OT_CORE_API_EXPORT std::vector<int32_t> getIntVector(const ConstJsonArray& _value, unsigned int _ix, const std::vector<int32_t>& _default = std::vector<int32_t>());
823
826 OT_CORE_API_EXPORT std::vector<uint32_t> getUIntVector(const JsonValue& _value, unsigned int _ix, const std::vector<uint32_t>& _default = std::vector<uint32_t>());
827 OT_CORE_API_EXPORT std::vector<uint32_t> getUIntVector(const ConstJsonArray& _value, unsigned int _ix, const std::vector<uint32_t>& _default = std::vector<uint32_t>());
828
831 OT_CORE_API_EXPORT std::vector<int64_t> getInt64Vector(const JsonValue& _value, unsigned int _ix, const std::vector<int64_t>& _default = std::vector<int64_t>());
832 OT_CORE_API_EXPORT std::vector<int64_t> getInt64Vector(const ConstJsonArray& _value, unsigned int _ix, const std::vector<int64_t>& _default = std::vector<int64_t>());
833
836 OT_CORE_API_EXPORT std::vector<uint64_t> getUInt64Vector(const JsonValue& _value, unsigned int _ix, const std::vector<uint64_t>& _default = std::vector<uint64_t>());
837 OT_CORE_API_EXPORT std::vector<uint64_t> getUInt64Vector(const ConstJsonArray& _value, unsigned int _ix, const std::vector<uint64_t>& _default = std::vector<uint64_t>());
838
841 OT_CORE_API_EXPORT std::vector<std::string> getStringVector(const JsonValue& _value, unsigned int _ix, const std::vector<std::string>& _default = std::vector<std::string>());
842 OT_CORE_API_EXPORT std::vector<std::string> getStringVector(const ConstJsonArray& _value, unsigned int _ix, const std::vector<std::string>& _default = std::vector<std::string>());
843
846 OT_CORE_API_EXPORT std::vector<ConstJsonObject> getObjectVector(const JsonValue& _value, unsigned int _ix);
847 OT_CORE_API_EXPORT std::vector<ConstJsonObject> getObjectVector(const ConstJsonArray& _value, unsigned int _ix);
848
851 OT_CORE_API_EXPORT std::vector<ConstJsonArray> getArrayVector(const JsonValue& _value, unsigned int _ix);
852 OT_CORE_API_EXPORT std::vector<ConstJsonArray> getArrayVector(const ConstJsonArray& _value, unsigned int _ix);
853 }
854}
#define OT_CORE_API_EXPORT
Dll import.
Definition CoreAPIExport.h:8
bsoncxx::builder::basic::document Document
Definition DocumentManager.h:14
This file contains defines that may be used simplyfy class creation.
#define OT_DECL_NODEFAULT(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:22
#define OT_DECL_NOCOPY(___class)
Removes the default copy constructor and assignment operator.
Definition OTClassHelper.h:14
JSON Array value.
Definition JSON.h:116
JsonArray(const std::list< float > &_lst, JsonAllocator &_allocator)
Create float array.
Definition JSON.h:212
virtual ~JsonArray()
Definition JSON.h:265
JsonArray(const std::vector< uint64_t > &_vec, JsonAllocator &_allocator)
Create uint64 array.
Definition JSON.h:203
JsonArray(const std::vector< bool > &_vec, JsonAllocator &_allocator)
Create bool array.
Definition JSON.h:131
JsonArray(const std::list< uint32_t > &_lst, JsonAllocator &_allocator)
Create uint32 array.
Definition JSON.h:158
JsonArray(const std::list< std::string > &_lst, JsonAllocator &_allocator)
Create string array.
Definition JSON.h:248
JsonArray(const std::vector< int64_t > &_vec, JsonAllocator &_allocator)
Create int64 array.
Definition JSON.h:185
JsonArray(const std::vector< float > &_vec, JsonAllocator &_allocator)
Create float array.
Definition JSON.h:221
JsonArray(const std::list< double > &_lst, JsonAllocator &_allocator)
Create double array.
Definition JSON.h:230
JsonArray(const std::vector< std::string > &_vec, JsonAllocator &_allocator)
Create string array.
Definition JSON.h:257
JsonArray()
Definition JSON.h:119
JsonArray(const std::list< uint64_t > &_lst, JsonAllocator &_allocator)
Create uint64 array.
Definition JSON.h:194
JsonArray(const std::list< int32_t > &_lst, JsonAllocator &_allocator)
Create int32 array.
Definition JSON.h:140
JsonArray(const std::vector< double > &_vec, JsonAllocator &_allocator)
Create double array.
Definition JSON.h:239
JsonArray(const std::vector< int32_t > &_vec, JsonAllocator &_allocator)
Create int32 array.
Definition JSON.h:149
JsonArray(const std::list< bool > &_lst, JsonAllocator &_allocator)
Create bool array.
Definition JSON.h:122
JsonArray(const std::list< int64_t > &_lst, JsonAllocator &_allocator)
Create int64 array.
Definition JSON.h:176
JsonArray(const std::vector< uint32_t > &_vec, JsonAllocator &_allocator)
Create uint32 array.
Definition JSON.h:167
JSON document.
Definition JSON.h:276
bool fromJson(const std::string &_json)
Definition JSON.h:294
JsonDocument(JsonDocument &&_other) noexcept
Move constructor.
Definition JSON.h:290
bool fromJson(const char *_fromJson)
Definition JSON.h:295
const JsonDocument & constRef(void) const
Definition JSON.h:300
JsonDocument(rapidjson::Type _type)
Constructor.
Definition JSON.h:287
JsonDocument()
Constructor Set the document as object.
Definition JSON.h:283
ConstJsonObject GetConstObject() const
Definition JSON.h:302
virtual ~JsonDocument()
Definition JSON.h:292
std::string toJson(void) const
Definition JSON.h:306
JSON NULL value.
Definition JSON.h:51
JsonNullValue()
Definition JSON.h:54
virtual ~JsonNullValue()
Definition JSON.h:55
Definition JSON.h:64
JsonNumber(unsigned long _value)
Definition JSON.h:70
JsonNumber(float _value)
Definition JSON.h:72
JsonNumber(unsigned long long _value)
Definition JSON.h:71
JsonNumber(long _value)
Definition JSON.h:68
JsonNumber(double _value)
Definition JSON.h:73
JsonNumber(long long _value)
Definition JSON.h:69
JSON Object value.
Definition JSON.h:101
JsonObject()
Definition JSON.h:104
virtual ~JsonObject()
Definition JSON.h:105
JSON String value.
Definition JSON.h:84
JsonString(const std::string &_str, JsonAllocator &_allocator)
Definition JSON.h:89
virtual ~JsonString()
Definition JSON.h:90
JsonString(const char *_cstr, JsonAllocator &_allocator)
Definition JSON.h:88
OT_CORE_API_EXPORT std::string getString(const JsonValue &_value, const char *_member, const std::string &_default=std::string())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:437
OT_CORE_API_EXPORT bool isObject(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a object.
Definition JSON.cpp:285
OT_CORE_API_EXPORT std::vector< float > getFloatVector(const JsonValue &_value, const char *_member, const std::vector< float > &_default=std::vector< float >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:785
OT_CORE_API_EXPORT std::list< std::string > getStringList(const JsonValue &_value, const char *_member, const std::list< std::string > &_default=std::list< std::string >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:625
OT_CORE_API_EXPORT std::vector< int32_t > getIntVector(const JsonValue &_value, const char *_member, const std::vector< int32_t > &_default=std::vector< int32_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:705
OT_CORE_API_EXPORT float getFloat(const JsonValue &_value, const char *_member, float _default=0.f)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:405
OT_CORE_API_EXPORT bool isString(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a string.
Definition JSON.cpp:265
OT_CORE_API_EXPORT int64_t * getInt64Array(const JsonValue &_value, const char *_member, JsonSizeType &_size)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:933
OT_CORE_API_EXPORT std::list< uint64_t > getUInt64List(const JsonValue &_value, const char *_member, const std::list< uint64_t > &_default=std::list< uint64_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:565
OT_CORE_API_EXPORT std::list< ConstJsonArray > getArrayList(const JsonValue &_value, const char *_member)
Check and return the requested value Asserts, logs and throws when the provided member does not exist...
Definition JSON.cpp:665
OT_CORE_API_EXPORT uint32_t getUInt(const JsonValue &_value, const char *_member, uint32_t _default=0)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:357
OT_CORE_API_EXPORT bool isUInt(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a uInt.
Definition JSON.cpp:165
OT_CORE_API_EXPORT std::list< bool > getBoolList(const JsonValue &_value, const char *_member, const std::list< bool > &_default=std::list< bool >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:485
OT_CORE_API_EXPORT std::vector< std::string > getStringVector(const JsonValue &_value, const char *_member, const std::vector< std::string > &_default=std::vector< std::string >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:825
OT_CORE_API_EXPORT bool isInt(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a int.
Definition JSON.cpp:145
OT_CORE_API_EXPORT std::vector< ConstJsonArray > getArrayVector(const JsonValue &_value, const char *_member)
Check and return the requested value Asserts, logs and throws when the provided member does not exist...
Definition JSON.cpp:865
OT_CORE_API_EXPORT std::vector< uint64_t > getUInt64Vector(const JsonValue &_value, const char *_member, const std::vector< uint64_t > &_default=std::vector< uint64_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:765
OT_CORE_API_EXPORT std::list< ConstJsonObject > getObjectList(const JsonValue &_value, const char *_member)
Check and return the requested value Asserts, logs and throws when the provided member does not exist...
Definition JSON.cpp:645
OT_CORE_API_EXPORT std::vector< ConstJsonObject > getObjectVector(const JsonValue &_value, const char *_member)
Check and return the requested value Asserts, logs and throws when the provided member does not exist...
Definition JSON.cpp:845
OT_CORE_API_EXPORT std::vector< uint32_t > getUIntVector(const JsonValue &_value, const char *_member, const std::vector< uint32_t > &_default=std::vector< uint32_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:725
OT_CORE_API_EXPORT bool isFloat(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a float.
Definition JSON.cpp:225
OT_CORE_API_EXPORT int64_t getInt64(const JsonValue &_value, const char *_member, int64_t _default=0)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:373
OT_CORE_API_EXPORT bool isUInt64(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a uInt64.
Definition JSON.cpp:205
OT_CORE_API_EXPORT std::list< int64_t > getInt64List(const JsonValue &_value, const char *_member, const std::list< int64_t > &_default=std::list< int64_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:545
OT_CORE_API_EXPORT std::vector< double > getDoubleVector(const JsonValue &_value, const char *_member, const std::vector< double > &_default=std::vector< double >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:805
OT_CORE_API_EXPORT uint64_t getUInt64(const JsonValue &_value, const char *_member, uint64_t _default=0)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:389
OT_CORE_API_EXPORT bool isBool(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a bool.
Definition JSON.cpp:125
OT_CORE_API_EXPORT uint64_t * getUInt64Array(const JsonValue &_value, const char *_member, JsonSizeType &_size)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:949
OT_CORE_API_EXPORT bool * getBoolArray(const JsonValue &_value, const char *_member, JsonSizeType &_size)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:885
OT_CORE_API_EXPORT ConstJsonObject getObject(const JsonValue &_value, const char *_member)
Check and return the requested value Asserts, logs and throws when the provided member does not exist...
Definition JSON.cpp:453
OT_CORE_API_EXPORT bool isNull(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a null.
Definition JSON.cpp:105
OT_CORE_API_EXPORT std::vector< int64_t > getInt64Vector(const JsonValue &_value, const char *_member, const std::vector< int64_t > &_default=std::vector< int64_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:745
OT_CORE_API_EXPORT uint32_t * getUIntArray(const JsonValue &_value, const char *_member, JsonSizeType &_size)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:917
OT_CORE_API_EXPORT bool exists(const JsonValue &_value, const char *_member)
Returns true if the specified object member exists.
Definition JSON.cpp:89
OT_CORE_API_EXPORT bool isArray(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a array.
Definition JSON.cpp:305
OT_CORE_API_EXPORT double getDouble(const JsonValue &_value, const char *_member, double _default=0.)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:421
OT_CORE_API_EXPORT double * getDoubleArray(const JsonValue &_value, const char *_member, JsonSizeType &_size)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:981
OT_CORE_API_EXPORT int32_t * getIntArray(const JsonValue &_value, const char *_member, JsonSizeType &_size)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:901
OT_CORE_API_EXPORT bool isInt64(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a int64.
Definition JSON.cpp:185
OT_CORE_API_EXPORT std::list< float > getFloatList(const JsonValue &_value, const char *_member, const std::list< float > &_default=std::list< float >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:585
OT_CORE_API_EXPORT std::vector< bool > getBoolVector(const JsonValue &_value, const char *_member, const std::vector< bool > &_default=std::vector< bool >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:685
OT_CORE_API_EXPORT ConstJsonArray getArray(const JsonValue &_value, const char *_member)
Check and return the requested value Asserts, logs and throws when the provided member does not exist...
Definition JSON.cpp:469
OT_CORE_API_EXPORT int32_t getInt(const JsonValue &_value, const char *_member, int32_t _default=0)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:341
OT_CORE_API_EXPORT bool isDouble(const JsonValue &_value, const char *_member)
Returns true if the specified object member is a double.
Definition JSON.cpp:245
OT_CORE_API_EXPORT std::list< uint32_t > getUIntList(const JsonValue &_value, const char *_member, const std::list< uint32_t > &_default=std::list< uint32_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:525
OT_CORE_API_EXPORT std::list< double > getDoubleList(const JsonValue &_value, const char *_member, const std::list< double > &_default=std::list< double >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:605
OT_CORE_API_EXPORT bool getBool(const JsonValue &_value, const char *_member, bool _default=false)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:325
OT_CORE_API_EXPORT float * getFloatArray(const JsonValue &_value, const char *_member, JsonSizeType &_size)
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:965
OT_CORE_API_EXPORT std::list< int32_t > getIntList(const JsonValue &_value, const char *_member, const std::list< int32_t > &_default=std::list< int32_t >())
Check and return the requested value Asserts, logs and returns default when the provided member does ...
Definition JSON.cpp:505
Definition Connector.h:8
rapidjson::GenericMemberIterator< true, rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > JsonMemberIterator
Read only JSON Object iterator.
Definition JSON.h:47
std::list< ConstJsonObject > ConstJsonObjectList
Definition JSON.h:37
rapidjson::SizeType JsonSizeType
Size type.
Definition JSON.h:24
rapidjson::GenericArray< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonArray
Read only JSON Array.
Definition JSON.h:42
rapidjson::Value JsonValue
Writable JSON value.
Definition JSON.h:27
rapidjson::GenericObject< true, rapidjson::GenericValue< rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > > > ConstJsonObject
Read only JSON Object.
Definition JSON.h:35
rapidjson::MemoryPoolAllocator< rapidjson::CrtAllocator > JsonAllocator
Allocator used for writing to JSON values.
Definition JSON.h:30
std::list< ConstJsonArray > ConstJsonArrayList
Definition JSON.h:44