13#include <rapidjson/document.h>
14#include <rapidjson/writer.h>
30 typedef rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>
JsonAllocator;
35 typedef rapidjson::GenericObject<true, rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>>
ConstJsonObject;
42 typedef rapidjson::GenericArray<true, rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>>
ConstJsonArray;
47 typedef rapidjson::GenericMemberIterator<true, rapidjson::UTF8<>, rapidjson::MemoryPoolAllocator<rapidjson::CrtAllocator>>
JsonMemberIterator;
71 JsonNumber(
unsigned long long _value) :
JsonValue(rapidjson::kNumberType) { this->SetUint64(_value); };
123 : rapidjson::Value(rapidjson::kArrayType)
125 for (
auto itm : _lst) {
126 this->PushBack(itm, _allocator);
132 : rapidjson::Value(rapidjson::kArrayType)
134 for (
auto itm : _vec) {
135 this->PushBack(itm, _allocator);
141 : rapidjson::Value(rapidjson::kArrayType)
143 for (
auto itm : _lst) {
144 this->PushBack(itm, _allocator);
150 : rapidjson::Value(rapidjson::kArrayType)
152 for (
auto itm : _vec) {
153 this->PushBack(itm, _allocator);
159 : rapidjson::Value(rapidjson::kArrayType)
161 for (
auto itm : _lst) {
162 this->PushBack(itm, _allocator);
168 : rapidjson::Value(rapidjson::kArrayType)
170 for (
auto itm : _vec) {
171 this->PushBack(itm, _allocator);
177 : rapidjson::Value(rapidjson::kArrayType)
179 for (
auto itm : _lst) {
180 this->PushBack(itm, _allocator);
186 : rapidjson::Value(rapidjson::kArrayType)
188 for (
auto itm : _vec) {
189 this->PushBack(itm, _allocator);
195 : rapidjson::Value(rapidjson::kArrayType)
197 for (
auto itm : _lst) {
198 this->PushBack(itm, _allocator);
204 : rapidjson::Value(rapidjson::kArrayType)
206 for (
auto itm : _vec) {
207 this->PushBack(itm, _allocator);
213 : rapidjson::Value(rapidjson::kArrayType)
215 for (
auto itm : _lst) {
216 this->PushBack(itm, _allocator);
222 : rapidjson::Value(rapidjson::kArrayType)
224 for (
auto itm : _vec) {
225 this->PushBack(itm, _allocator);
231 : rapidjson::Value(rapidjson::kArrayType)
233 for (
auto itm : _lst) {
234 this->PushBack(itm, _allocator);
240 : rapidjson::Value(rapidjson::kArrayType)
242 for (
auto itm : _vec) {
243 this->PushBack(itm, _allocator);
249 : rapidjson::Value(rapidjson::kArrayType)
251 for (
auto itm : _lst) {
252 this->PushBack(
JsonString(itm, _allocator), _allocator);
258 : rapidjson::Value(rapidjson::kArrayType)
260 for (
auto itm : _vec) {
261 this->PushBack(
JsonString(itm, _allocator), _allocator);
296 this->Parse(_fromJson);
297 return (this->GetType() == rapidjson::kObjectType) || (this->GetType() == rapidjson::kArrayType);
303 return this->GetObject();
308 rapidjson::StringBuffer buffer;
312 rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
313 this->Accept(writer);
316 return std::string(buffer.GetString());
#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
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
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