mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
upgrade 6.21.0
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#include "src/ArduinoJson.h"
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
ArduinoJson: change log
|
||||
=======================
|
||||
|
||||
v6.21.0 (2023-03-14)
|
||||
-------
|
||||
|
||||
* Drop support for C++98/C++03. Minimum required is C++11.
|
||||
* Remove `ARDUINOJSON_NAMESPACE`; use `ArduinoJson` instead.
|
||||
* Make string support generic (issue #1807)
|
||||
|
||||
v6.20.1 (2023-02-08)
|
||||
-------
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
---------------------
|
||||
|
||||
Copyright © 2014-2022, Benoit BLANCHON
|
||||
Copyright © 2014-2023, Benoit BLANCHON
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
@@ -1,160 +0,0 @@
|
||||
<p align="center">
|
||||
<a href="https://arduinojson.org/"><img alt="ArduinoJson" src="https://arduinojson.org/images/logo.svg" width="200" /></a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
[](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A6.x)
|
||||
[](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
|
||||
[](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
|
||||
[](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
|
||||
[](https://www.ardu-badge.com/ArduinoJson/6.20.1)
|
||||
[](https://registry.platformio.org/packages/libraries/bblanchon/ArduinoJson?version=6.20.1)
|
||||
[](https://components.espressif.com/components/bblanchon/arduinojson)
|
||||
[](https://github.com/bblanchon/ArduinoJson/stargazers)
|
||||
[](https://github.com/sponsors/bblanchon)
|
||||
|
||||
ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things).
|
||||
|
||||
## Features
|
||||
|
||||
* [JSON deserialization](https://arduinojson.org/v6/api/json/deserializejson/)
|
||||
* [Optionally decodes UTF-16 escape sequences to UTF-8](https://arduinojson.org/v6/api/config/decode_unicode/)
|
||||
* [Optionally stores links to the input buffer (zero-copy)](https://arduinojson.org/v6/api/json/deserializejson/)
|
||||
* [Optionally supports comments in the input](https://arduinojson.org/v6/api/config/enable_comments/)
|
||||
* [Optionally filters the input to keep only desired values](https://arduinojson.org/v6/api/json/deserializejson/#filtering)
|
||||
* Supports single quotes as a string delimiter
|
||||
* Compatible with [NDJSON](http://ndjson.org/) and [JSON Lines](https://jsonlines.org/)
|
||||
* [JSON serialization](https://arduinojson.org/v6/api/json/serializejson/)
|
||||
* [Can write to a buffer or a stream](https://arduinojson.org/v6/api/json/serializejson/)
|
||||
* [Optionally indents the document (prettified JSON)](https://arduinojson.org/v6/api/json/serializejsonpretty/)
|
||||
* [MessagePack serialization](https://arduinojson.org/v6/api/msgpack/serializemsgpack/)
|
||||
* [MessagePack deserialization](https://arduinojson.org/v6/api/msgpack/deserializemsgpack/)
|
||||
* Efficient
|
||||
* [Twice smaller than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
|
||||
* [Almost 10% faster than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
|
||||
* [Consumes roughly 10% less RAM than the "official" Arduino_JSON library](https://arduinojson.org/2019/11/19/arduinojson-vs-arduino_json/)
|
||||
* [Fixed memory allocation, no heap fragmentation](https://arduinojson.org/v6/api/jsondocument/)
|
||||
* [Optionally works without heap memory (zero malloc)](https://arduinojson.org/v6/api/staticjsondocument/)
|
||||
* [Deduplicates strings](https://arduinojson.org/news/2020/08/01/version-6-16-0/)
|
||||
* Versatile
|
||||
* Supports [custom allocators (to use external RAM chip, for example)](https://arduinojson.org/v6/how-to/use-external-ram-on-esp32/)
|
||||
* Supports [`String`](https://arduinojson.org/v6/api/config/enable_arduino_string/), [`std::string`](https://arduinojson.org/v6/api/config/enable_std_string/), and [`std::string_view`](https://arduinojson.org/v6/api/config/enable_string_view/)
|
||||
* Supports [`Stream`](https://arduinojson.org/v6/api/config/enable_arduino_stream/) and [`std::istream`/`std::ostream`](https://arduinojson.org/v6/api/config/enable_std_stream/)
|
||||
* Supports [Flash strings](https://arduinojson.org/v6/api/config/enable_progmem/)
|
||||
* Supports [custom readers](https://arduinojson.org/v6/api/json/deserializejson/#custom-reader) and [custom writers](https://arduinojson.org/v6/api/json/serializejson/#custom-writer)
|
||||
* Supports [custom converters](https://arduinojson.org/news/2021/05/04/version-6-18-0/)
|
||||
* Portable
|
||||
* Usable on any C++ project (not limited to Arduino)
|
||||
* Compatible with C++98, C++11, C++14 and C++17
|
||||
* Zero warnings with `-Wall -Wextra -pedantic` and `/W4`
|
||||
* [Header-only library](https://en.wikipedia.org/wiki/Header-only)
|
||||
* Works with virtually any board
|
||||
* Arduino boards: [Uno](https://amzn.to/38aL2ik), [Due](https://amzn.to/36YkWi2), [Micro](https://amzn.to/35WkdwG), [Nano](https://amzn.to/2QTvwRX), [Mega](https://amzn.to/36XWhuf), [Yun](https://amzn.to/30odURc), [Leonardo](https://amzn.to/36XWjlR)...
|
||||
* Espressif chips: [ESP8266](https://amzn.to/36YluV8), [ESP32](https://amzn.to/2G4pRCB)
|
||||
* Lolin (WeMos) boards: [D1 mini](https://amzn.to/2QUpz7q), [D1 Mini Pro](https://amzn.to/36UsGSs)...
|
||||
* Teensy boards: [4.0](https://amzn.to/30ljXGq), [3.2](https://amzn.to/2FT0EuC), [2.0](https://amzn.to/2QXUMXj)
|
||||
* Particle boards: [Argon](https://amzn.to/2FQHa9X), [Boron](https://amzn.to/36WgLUd), [Electron](https://amzn.to/30vEc4k), [Photon](https://amzn.to/387F9Cd)...
|
||||
* Texas Instruments boards: [MSP430](https://amzn.to/30nJWgg)...
|
||||
* Soft cores: [Nios II](https://en.wikipedia.org/wiki/Nios_II)...
|
||||
* Tested on all major development environments
|
||||
* [Arduino IDE](https://www.arduino.cc/en/Main/Software)
|
||||
* [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/)
|
||||
* [Atollic TrueSTUDIO](https://atollic.com/truestudio/)
|
||||
* [Energia](http://energia.nu/)
|
||||
* [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/)
|
||||
* [Keil uVision](http://www.keil.com/)
|
||||
* [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide)
|
||||
* [Particle](https://www.particle.io/)
|
||||
* [PlatformIO](http://platformio.org/)
|
||||
* [Sloeber plugin for Eclipse](https://eclipse.baeyens.it/)
|
||||
* [Visual Micro](http://www.visualmicro.com/)
|
||||
* [Visual Studio](https://www.visualstudio.com/)
|
||||
* [Even works with online compilers like wandbox.org](https://wandbox.org/permlink/RlZSKy17DjJ6HcdN)
|
||||
* [CMake friendly](https://arduinojson.org/v6/how-to/use-arduinojson-with-cmake/)
|
||||
* Well designed
|
||||
* [Elegant API](http://arduinojson.org/v6/example/)
|
||||
* [Thread-safe](https://en.wikipedia.org/wiki/Thread_safety)
|
||||
* Self-contained (no external dependency)
|
||||
* `const` friendly
|
||||
* [`for` friendly](https://arduinojson.org/v6/api/jsonobject/begin_end/)
|
||||
* [TMP friendly](https://en.wikipedia.org/wiki/Template_metaprogramming)
|
||||
* Handles [integer overflows](https://arduinojson.org/v6/api/jsonvariant/as/#integer-overflows)
|
||||
* Well tested
|
||||
* [Unit test coverage close to 100%](https://coveralls.io/github/bblanchon/ArduinoJson?branch=6.x)
|
||||
* Continuously tested on
|
||||
* [Visual Studio 2010, 2012, 2013, 2015, 2017, 2019, 2022](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x)
|
||||
* [GCC 4.4, 4.6, 4.7, 4.8, 4.9, 5, 6, 7, 8, 9, 10, 11](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
||||
* [Clang 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10](https://github.com/bblanchon/ArduinoJson/actions?query=workflow%3A%22Continuous+Integration%22)
|
||||
* [Continuously fuzzed with Google OSS Fuzz](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson)
|
||||
* Passes all default checks of [clang-tidy](https://releases.llvm.org/10.0.0/tools/clang/tools/extra/docs/clang-tidy/)
|
||||
* Well documented
|
||||
* [Tutorials](https://arduinojson.org/v6/doc/deserialization/)
|
||||
* [Examples](https://arduinojson.org/v6/example/)
|
||||
* [How-tos](https://arduinojson.org/v6/example/)
|
||||
* [FAQ](https://arduinojson.org/v6/faq/)
|
||||
* [Troubleshooter](https://arduinojson.org/v6/troubleshooter/)
|
||||
* [Book](https://arduinojson.org/book/)
|
||||
* [Changelog](CHANGELOG.md)
|
||||
* Vibrant user community
|
||||
* Most popular of all Arduino libraries on [GitHub](https://github.com/search?o=desc&q=arduino+library&s=stars&type=Repositories)
|
||||
* [Used in hundreds of projects](https://www.hackster.io/search?i=projects&q=arduinojson)
|
||||
* [Responsive support](https://github.com/bblanchon/ArduinoJson/issues?q=is%3Aissue+is%3Aclosed)
|
||||
|
||||
## Quickstart
|
||||
|
||||
### Deserialization
|
||||
|
||||
Here is a program that parses a JSON document with ArduinoJson.
|
||||
|
||||
```c++
|
||||
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
|
||||
|
||||
DynamicJsonDocument doc(1024);
|
||||
deserializeJson(doc, json);
|
||||
|
||||
const char* sensor = doc["sensor"];
|
||||
long time = doc["time"];
|
||||
double latitude = doc["data"][0];
|
||||
double longitude = doc["data"][1];
|
||||
```
|
||||
|
||||
See the [tutorial on arduinojson.org](https://arduinojson.org/v6/doc/deserialization/)
|
||||
|
||||
### Serialization
|
||||
|
||||
Here is a program that generates a JSON document with ArduinoJson:
|
||||
|
||||
```c++
|
||||
DynamicJsonDocument doc(1024);
|
||||
|
||||
doc["sensor"] = "gps";
|
||||
doc["time"] = 1351824120;
|
||||
doc["data"][0] = 48.756080;
|
||||
doc["data"][1] = 2.302038;
|
||||
|
||||
serializeJson(doc, Serial);
|
||||
// This prints:
|
||||
// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}
|
||||
```
|
||||
|
||||
See the [tutorial on arduinojson.org](https://arduinojson.org/v6/doc/serialization/)
|
||||
|
||||
## Sponsors
|
||||
|
||||
ArduinoJson is thankful to its sponsors. Please give them a visit; they deserve it!
|
||||
|
||||
<p>
|
||||
<a href="https://www.programmingelectronics.com/" rel="sponsored">
|
||||
<img src="https://arduinojson.org/images/2021/10/programmingeleactronicsacademy.png" alt="Programming Electronics Academy" width="200">
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<a href="https://github.com/1technophile" rel="sponsored">
|
||||
<img alt="1technophile" src="https://avatars.githubusercontent.com/u/12672732?s=40&v=4">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
If you run a commercial project that embeds ArduinoJson, think about [sponsoring the library's development](https://github.com/sponsors/bblanchon): it ensures the code that your products rely on stays actively maintained. It can also give your project some exposure to the makers' community.
|
||||
|
||||
If you are an individual user and want to support the development (or give a sign of appreciation), consider purchasing the book [Mastering ArduinoJson](https://arduinojson.org/book/) ❤, or simply [cast a star](https://github.com/bblanchon/ArduinoJson/stargazers) ⭐.
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __cplusplus < 201103L && (!defined(_MSC_VER) || _MSC_VER < 1910)
|
||||
# error ArduinoJson requires C++11 or newer. Configure your compiler for C++11 or downgrade ArduinoJson to 6.20.
|
||||
#endif
|
||||
|
||||
#include "ArduinoJson/Configuration.hpp"
|
||||
|
||||
// Include Arduino.h before stdlib.h to avoid conflict with atexit()
|
||||
@@ -45,36 +49,3 @@
|
||||
#include "ArduinoJson/MsgPack/MsgPackSerializer.hpp"
|
||||
|
||||
#include "ArduinoJson/compatibility.hpp"
|
||||
|
||||
namespace ArduinoJson {
|
||||
using ARDUINOJSON_NAMESPACE::BasicJsonDocument;
|
||||
using ARDUINOJSON_NAMESPACE::copyArray;
|
||||
using ARDUINOJSON_NAMESPACE::DeserializationError;
|
||||
using ARDUINOJSON_NAMESPACE::deserializeJson;
|
||||
using ARDUINOJSON_NAMESPACE::deserializeMsgPack;
|
||||
using ARDUINOJSON_NAMESPACE::DynamicJsonDocument;
|
||||
using ARDUINOJSON_NAMESPACE::JsonArray;
|
||||
using ARDUINOJSON_NAMESPACE::JsonArrayConst;
|
||||
using ARDUINOJSON_NAMESPACE::JsonDocument;
|
||||
using ARDUINOJSON_NAMESPACE::JsonFloat;
|
||||
using ARDUINOJSON_NAMESPACE::JsonInteger;
|
||||
using ARDUINOJSON_NAMESPACE::JsonObject;
|
||||
using ARDUINOJSON_NAMESPACE::JsonObjectConst;
|
||||
using ARDUINOJSON_NAMESPACE::JsonPair;
|
||||
using ARDUINOJSON_NAMESPACE::JsonPairConst;
|
||||
using ARDUINOJSON_NAMESPACE::JsonString;
|
||||
using ARDUINOJSON_NAMESPACE::JsonUInt;
|
||||
using ARDUINOJSON_NAMESPACE::JsonVariant;
|
||||
using ARDUINOJSON_NAMESPACE::JsonVariantConst;
|
||||
using ARDUINOJSON_NAMESPACE::measureJson;
|
||||
using ARDUINOJSON_NAMESPACE::serialized;
|
||||
using ARDUINOJSON_NAMESPACE::serializeJson;
|
||||
using ARDUINOJSON_NAMESPACE::serializeJsonPretty;
|
||||
using ARDUINOJSON_NAMESPACE::serializeMsgPack;
|
||||
using ARDUINOJSON_NAMESPACE::StaticJsonDocument;
|
||||
|
||||
namespace DeserializationOption {
|
||||
using ARDUINOJSON_NAMESPACE::Filter;
|
||||
using ARDUINOJSON_NAMESPACE::NestingLimit;
|
||||
} // namespace DeserializationOption
|
||||
} // namespace ArduinoJson
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Variant/VariantRefBase.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A proxy class to get or set an element of an array.
|
||||
// https://arduinojson.org/v6/api/jsonarray/subscript/
|
||||
template <typename TUpstream>
|
||||
class ElementProxy : public VariantRefBase<ElementProxy<TUpstream> >,
|
||||
public VariantOperators<ElementProxy<TUpstream> > {
|
||||
class ElementProxy : public VariantRefBase<ElementProxy<TUpstream>>,
|
||||
public VariantOperators<ElementProxy<TUpstream>> {
|
||||
friend class VariantAttorney;
|
||||
|
||||
public:
|
||||
@@ -57,4 +57,4 @@ class ElementProxy : public VariantRefBase<ElementProxy<TUpstream> >,
|
||||
size_t _index;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,14 +7,14 @@
|
||||
#include <ArduinoJson/Array/ElementProxy.hpp>
|
||||
#include <ArduinoJson/Array/JsonArrayConst.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
class JsonObject;
|
||||
|
||||
// A reference to an array in a JsonDocument
|
||||
// https://arduinojson.org/v6/api/jsonarray/
|
||||
class JsonArray : public VariantOperators<JsonArray> {
|
||||
friend class VariantAttorney;
|
||||
class JsonArray : public detail::VariantOperators<JsonArray> {
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonArrayIterator iterator;
|
||||
@@ -23,14 +23,14 @@ class JsonArray : public VariantOperators<JsonArray> {
|
||||
FORCE_INLINE JsonArray() : _data(0), _pool(0) {}
|
||||
|
||||
// INTERNAL USE ONLY
|
||||
FORCE_INLINE JsonArray(MemoryPool* pool, CollectionData* data)
|
||||
FORCE_INLINE JsonArray(detail::MemoryPool* pool, detail::CollectionData* data)
|
||||
: _data(data), _pool(pool) {}
|
||||
|
||||
// Returns a JsonVariant pointing to the array.
|
||||
// https://arduinojson.org/v6/api/jsonvariant/
|
||||
operator JsonVariant() {
|
||||
void* data = _data; // prevent warning cast-align
|
||||
return JsonVariant(_pool, reinterpret_cast<VariantData*>(data));
|
||||
return JsonVariant(_pool, reinterpret_cast<detail::VariantData*>(data));
|
||||
}
|
||||
|
||||
// Returns a read-only reference to the array.
|
||||
@@ -118,8 +118,8 @@ class JsonArray : public VariantOperators<JsonArray> {
|
||||
|
||||
// Gets or sets the element at the specified index.
|
||||
// https://arduinojson.org/v6/api/jsonarray/subscript/
|
||||
FORCE_INLINE ElementProxy<JsonArray> operator[](size_t index) const {
|
||||
return ElementProxy<JsonArray>(*this, index);
|
||||
FORCE_INLINE detail::ElementProxy<JsonArray> operator[](size_t index) const {
|
||||
return {*this, index};
|
||||
}
|
||||
|
||||
// Creates an object and appends it to the array.
|
||||
@@ -167,35 +167,35 @@ class JsonArray : public VariantOperators<JsonArray> {
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryPool* getPool() const {
|
||||
detail::MemoryPool* getPool() const {
|
||||
return _pool;
|
||||
}
|
||||
|
||||
VariantData* getData() const {
|
||||
detail::VariantData* getData() const {
|
||||
return collectionToVariant(_data);
|
||||
}
|
||||
|
||||
VariantData* getOrCreateData() const {
|
||||
detail::VariantData* getOrCreateData() const {
|
||||
return collectionToVariant(_data);
|
||||
}
|
||||
|
||||
CollectionData* _data;
|
||||
MemoryPool* _pool;
|
||||
detail::CollectionData* _data;
|
||||
detail::MemoryPool* _pool;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<JsonArray> : private VariantAttorney {
|
||||
struct Converter<JsonArray> : private detail::VariantAttorney {
|
||||
static void toJson(JsonVariantConst src, JsonVariant dst) {
|
||||
variantCopyFrom(getData(dst), getData(src), getPool(dst));
|
||||
}
|
||||
|
||||
static JsonArray fromJson(JsonVariant src) {
|
||||
VariantData* data = getData(src);
|
||||
MemoryPool* pool = getPool(src);
|
||||
auto data = getData(src);
|
||||
auto pool = getPool(src);
|
||||
return JsonArray(pool, data != 0 ? data->asArray() : 0);
|
||||
}
|
||||
|
||||
static InvalidConversion<JsonVariantConst, JsonArray> fromJson(
|
||||
static detail::InvalidConversion<JsonVariantConst, JsonArray> fromJson(
|
||||
JsonVariantConst);
|
||||
|
||||
static bool checkJson(JsonVariantConst) {
|
||||
@@ -203,8 +203,9 @@ struct Converter<JsonArray> : private VariantAttorney {
|
||||
}
|
||||
|
||||
static bool checkJson(JsonVariant src) {
|
||||
VariantData* data = getData(src);
|
||||
auto data = getData(src);
|
||||
return data && data->isArray();
|
||||
}
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,15 +8,15 @@
|
||||
#include <ArduinoJson/Variant/VariantAttorney.hpp>
|
||||
#include <ArduinoJson/Variant/VariantData.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
class JsonObject;
|
||||
|
||||
// A read-only reference to an array in a JsonDocument
|
||||
// https://arduinojson.org/v6/api/jsonarrayconst/
|
||||
class JsonArrayConst : public VariantOperators<JsonArrayConst> {
|
||||
class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> {
|
||||
friend class JsonArray;
|
||||
friend class VariantAttorney;
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonArrayConstIterator iterator;
|
||||
@@ -39,7 +39,8 @@ class JsonArrayConst : public VariantOperators<JsonArrayConst> {
|
||||
FORCE_INLINE JsonArrayConst() : _data(0) {}
|
||||
|
||||
// INTERNAL USE ONLY
|
||||
FORCE_INLINE JsonArrayConst(const CollectionData* data) : _data(data) {}
|
||||
FORCE_INLINE JsonArrayConst(const detail::CollectionData* data)
|
||||
: _data(data) {}
|
||||
|
||||
// Compares the content of two arrays.
|
||||
// Returns true if the two arrays are equal.
|
||||
@@ -107,28 +108,28 @@ class JsonArrayConst : public VariantOperators<JsonArrayConst> {
|
||||
}
|
||||
|
||||
private:
|
||||
const VariantData* getData() const {
|
||||
const detail::VariantData* getData() const {
|
||||
return collectionToVariant(_data);
|
||||
}
|
||||
|
||||
const CollectionData* _data;
|
||||
const detail::CollectionData* _data;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<JsonArrayConst> : private VariantAttorney {
|
||||
struct Converter<JsonArrayConst> : private detail::VariantAttorney {
|
||||
static void toJson(JsonVariantConst src, JsonVariant dst) {
|
||||
variantCopyFrom(getData(dst), getData(src), getPool(dst));
|
||||
}
|
||||
|
||||
static JsonArrayConst fromJson(JsonVariantConst src) {
|
||||
const VariantData* data = getData(src);
|
||||
auto data = getData(src);
|
||||
return data ? data->asArray() : 0;
|
||||
}
|
||||
|
||||
static bool checkJson(JsonVariantConst src) {
|
||||
const VariantData* data = getData(src);
|
||||
auto data = getData(src);
|
||||
return data && data->isArray();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,12 +7,16 @@
|
||||
#include <ArduinoJson/Array/JsonArray.hpp>
|
||||
#include <ArduinoJson/Object/JsonObject.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
inline JsonObject JsonArray::createNestedObject() const {
|
||||
return add().to<JsonObject>();
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TDerived>
|
||||
inline JsonArray VariantRefBase<TDerived>::createNestedArray() const {
|
||||
return add().template to<JsonArray>();
|
||||
@@ -29,4 +33,4 @@ inline ElementProxy<TDerived> VariantRefBase<TDerived>::operator[](
|
||||
return ElementProxy<TDerived>(derived(), index);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,11 +7,12 @@
|
||||
#include <ArduinoJson/Variant/JsonVariant.hpp>
|
||||
#include <ArduinoJson/Variant/SlotFunctions.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
class VariantPtr {
|
||||
public:
|
||||
VariantPtr(MemoryPool* pool, VariantData* data) : _variant(pool, data) {}
|
||||
VariantPtr(detail::MemoryPool* pool, detail::VariantData* data)
|
||||
: _variant(pool, data) {}
|
||||
|
||||
JsonVariant* operator->() {
|
||||
return &_variant;
|
||||
@@ -30,7 +31,8 @@ class JsonArrayIterator {
|
||||
|
||||
public:
|
||||
JsonArrayIterator() : _slot(0) {}
|
||||
explicit JsonArrayIterator(MemoryPool* pool, VariantSlot* slot)
|
||||
explicit JsonArrayIterator(detail::MemoryPool* pool,
|
||||
detail::VariantSlot* slot)
|
||||
: _pool(pool), _slot(slot) {}
|
||||
|
||||
JsonVariant operator*() const {
|
||||
@@ -59,13 +61,13 @@ class JsonArrayIterator {
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryPool* _pool;
|
||||
VariantSlot* _slot;
|
||||
detail::MemoryPool* _pool;
|
||||
detail::VariantSlot* _slot;
|
||||
};
|
||||
|
||||
class VariantConstPtr {
|
||||
public:
|
||||
VariantConstPtr(const VariantData* data) : _variant(data) {}
|
||||
VariantConstPtr(const detail::VariantData* data) : _variant(data) {}
|
||||
|
||||
JsonVariantConst* operator->() {
|
||||
return &_variant;
|
||||
@@ -84,7 +86,8 @@ class JsonArrayConstIterator {
|
||||
|
||||
public:
|
||||
JsonArrayConstIterator() : _slot(0) {}
|
||||
explicit JsonArrayConstIterator(const VariantSlot* slot) : _slot(slot) {}
|
||||
explicit JsonArrayConstIterator(const detail::VariantSlot* slot)
|
||||
: _slot(slot) {}
|
||||
|
||||
JsonVariantConst operator*() const {
|
||||
return JsonVariantConst(_slot->data());
|
||||
@@ -112,6 +115,7 @@ class JsonArrayConstIterator {
|
||||
}
|
||||
|
||||
private:
|
||||
const VariantSlot* _slot;
|
||||
const detail::VariantSlot* _slot;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,21 +7,21 @@
|
||||
#include <ArduinoJson/Array/JsonArray.hpp>
|
||||
#include <ArduinoJson/Document/JsonDocument.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// Copies a value to a JsonVariant.
|
||||
// This is a degenerated form of copyArray() to stop the recursion.
|
||||
template <typename T>
|
||||
inline typename enable_if<!is_array<T>::value, bool>::type copyArray(
|
||||
const T& src, JsonVariant dst) {
|
||||
inline typename detail::enable_if<!detail::is_array<T>::value, bool>::type
|
||||
copyArray(const T& src, JsonVariant dst) {
|
||||
return dst.set(src);
|
||||
}
|
||||
|
||||
// Copies values from an array to a JsonArray or a JsonVariant.
|
||||
// https://arduinojson.org/v6/api/misc/copyarray/
|
||||
template <typename T, size_t N, typename TDestination>
|
||||
inline typename enable_if<!is_base_of<JsonDocument, TDestination>::value,
|
||||
bool>::type
|
||||
inline typename detail::enable_if<
|
||||
!detail::is_base_of<JsonDocument, TDestination>::value, bool>::type
|
||||
copyArray(T (&src)[N], const TDestination& dst) {
|
||||
return copyArray(src, N, dst);
|
||||
}
|
||||
@@ -29,8 +29,8 @@ copyArray(T (&src)[N], const TDestination& dst) {
|
||||
// Copies values from an array to a JsonArray or a JsonVariant.
|
||||
// https://arduinojson.org/v6/api/misc/copyarray/
|
||||
template <typename T, typename TDestination>
|
||||
inline typename enable_if<!is_base_of<JsonDocument, TDestination>::value,
|
||||
bool>::type
|
||||
inline typename detail::enable_if<
|
||||
!detail::is_base_of<JsonDocument, TDestination>::value, bool>::type
|
||||
copyArray(const T* src, size_t len, const TDestination& dst) {
|
||||
bool ok = true;
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
@@ -63,8 +63,8 @@ inline bool copyArray(const T* src, size_t len, JsonDocument& dst) {
|
||||
// Copies a value from a JsonVariant.
|
||||
// This is a degenerated form of copyArray() to stop the recursion.
|
||||
template <typename T>
|
||||
inline typename enable_if<!is_array<T>::value, size_t>::type copyArray(
|
||||
JsonVariantConst src, T& dst) {
|
||||
inline typename detail::enable_if<!detail::is_array<T>::value, size_t>::type
|
||||
copyArray(JsonVariantConst src, T& dst) {
|
||||
dst = src.as<T>();
|
||||
return 1;
|
||||
}
|
||||
@@ -103,11 +103,12 @@ inline size_t copyArray(JsonVariantConst src, char (&dst)[N]) {
|
||||
// Copies values from a JsonDocument to an array.
|
||||
// https://arduinojson.org/v6/api/misc/copyarray/
|
||||
template <typename TSource, typename T>
|
||||
inline typename enable_if<is_array<T>::value &&
|
||||
is_base_of<JsonDocument, TSource>::value,
|
||||
size_t>::type
|
||||
inline typename detail::enable_if<
|
||||
detail::is_array<T>::value &&
|
||||
detail::is_base_of<JsonDocument, TSource>::value,
|
||||
size_t>::type
|
||||
copyArray(const TSource& src, T& dst) {
|
||||
return copyArray(src.template as<JsonArrayConst>(), dst);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
class MemoryPool;
|
||||
class VariantData;
|
||||
@@ -91,4 +91,5 @@ inline VariantData* collectionToVariant(CollectionData* collection) {
|
||||
void* data = collection; // prevent warning cast-align
|
||||
return reinterpret_cast<VariantData*>(data);
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <ArduinoJson/Strings/StringAdapters.hpp>
|
||||
#include <ArduinoJson/Variant/VariantData.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) {
|
||||
VariantSlot* slot = pool->allocVariant();
|
||||
@@ -194,4 +194,4 @@ inline void CollectionData::movePointers(ptrdiff_t stringDistance,
|
||||
slot->movePointers(stringDistance, variantDistance);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,31 +1,9 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define ARDUINOJSON_HAS_LONG_LONG 1
|
||||
# define ARDUINOJSON_HAS_RVALUE_REFERENCES 1
|
||||
#else
|
||||
# define ARDUINOJSON_HAS_LONG_LONG 0
|
||||
# define ARDUINOJSON_HAS_RVALUE_REFERENCES 0
|
||||
#endif
|
||||
|
||||
#ifndef ARDUINOJSON_HAS_NULLPTR
|
||||
# if __cplusplus >= 201103L
|
||||
# define ARDUINOJSON_HAS_NULLPTR 1
|
||||
# else
|
||||
# define ARDUINOJSON_HAS_NULLPTR 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !ARDUINOJSON_HAS_LONG_LONG
|
||||
# define ARDUINOJSON_HAS_INT64 1
|
||||
#else
|
||||
# define ARDUINOJSON_HAS_INT64 0
|
||||
#endif
|
||||
|
||||
// Support std::istream and std::ostream
|
||||
#ifndef ARDUINOJSON_ENABLE_STD_STREAM
|
||||
# ifdef __has_include
|
||||
@@ -83,8 +61,7 @@
|
||||
|
||||
// Store integral values with long (0) or long long (1)
|
||||
#ifndef ARDUINOJSON_USE_LONG_LONG
|
||||
# if ARDUINOJSON_HAS_LONG_LONG && defined(__SIZEOF_POINTER__) && \
|
||||
__SIZEOF_POINTER__ >= 4 || \
|
||||
# if defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ >= 4 || \
|
||||
defined(_MSC_VER)
|
||||
# define ARDUINOJSON_USE_LONG_LONG 1
|
||||
# endif
|
||||
@@ -230,7 +207,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_HAS_NULLPTR && defined(nullptr)
|
||||
#if defined(nullptr)
|
||||
# error nullptr is defined as a macro. Remove the faulty #define or #undef nullptr
|
||||
// See https://github.com/bblanchon/ArduinoJson/issues/1355
|
||||
#endif
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Misc/SafeBoolIdiom.hpp>
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
#include <ArduinoJson/Polyfills/pgmspace_generic.hpp>
|
||||
#include <ArduinoJson/Polyfills/preprocessor.hpp>
|
||||
@@ -13,9 +12,9 @@
|
||||
# include <ostream>
|
||||
#endif
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
class DeserializationError : public SafeBoolIdom<DeserializationError> {
|
||||
class DeserializationError {
|
||||
public:
|
||||
enum Code {
|
||||
Ok,
|
||||
@@ -53,9 +52,9 @@ class DeserializationError : public SafeBoolIdom<DeserializationError> {
|
||||
return lhs != rhs._code;
|
||||
}
|
||||
|
||||
// Behaves like a bool
|
||||
operator bool_type() const {
|
||||
return _code != Ok ? safe_true() : safe_false();
|
||||
// Returns true if there is an error
|
||||
explicit operator bool() const {
|
||||
return _code != Ok;
|
||||
}
|
||||
|
||||
// Returns internal enum, useful for switch statement
|
||||
@@ -80,10 +79,10 @@ class DeserializationError : public SafeBoolIdom<DeserializationError> {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s3, "InvalidInput");
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s4, "NoMemory");
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(char, s5, "TooDeep");
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(
|
||||
const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5}));
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(const char*, messages,
|
||||
{s0, s1, s2, s3, s4, s5});
|
||||
return reinterpret_cast<const __FlashStringHelper*>(
|
||||
pgm_read(messages + _code));
|
||||
detail::pgm_read(messages + _code));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -104,4 +103,4 @@ inline std::ostream& operator<<(std::ostream& s, DeserializationError::Code c) {
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Deserialization/Filter.hpp>
|
||||
#include <ArduinoJson/Deserialization/NestingLimit.hpp>
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TFilter>
|
||||
struct DeserializationOptions {
|
||||
TFilter filter;
|
||||
DeserializationOption::NestingLimit nestingLimit;
|
||||
};
|
||||
|
||||
template <typename TFilter>
|
||||
inline DeserializationOptions<TFilter> makeDeserializationOptions(
|
||||
TFilter filter, DeserializationOption::NestingLimit nestingLimit = {}) {
|
||||
return {filter, nestingLimit};
|
||||
}
|
||||
|
||||
template <typename TFilter>
|
||||
inline DeserializationOptions<TFilter> makeDeserializationOptions(
|
||||
DeserializationOption::NestingLimit nestingLimit, TFilter filter) {
|
||||
return {filter, nestingLimit};
|
||||
}
|
||||
|
||||
inline DeserializationOptions<AllowAllFilter> makeDeserializationOptions(
|
||||
DeserializationOption::NestingLimit nestingLimit = {}) {
|
||||
return {{}, nestingLimit};
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
@@ -1,13 +1,14 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
namespace DeserializationOption {
|
||||
class Filter {
|
||||
public:
|
||||
explicit Filter(JsonVariantConst v) : _variant(v) {}
|
||||
@@ -39,7 +40,9 @@ class Filter {
|
||||
private:
|
||||
JsonVariantConst _variant;
|
||||
};
|
||||
} // namespace DeserializationOption
|
||||
|
||||
namespace detail {
|
||||
struct AllowAllFilter {
|
||||
bool allow() const {
|
||||
return true;
|
||||
@@ -62,5 +65,6 @@ struct AllowAllFilter {
|
||||
return AllowAllFilter();
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,8 +7,9 @@
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
#include <ArduinoJson/Polyfills/assert.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
namespace DeserializationOption {
|
||||
class NestingLimit {
|
||||
public:
|
||||
NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {}
|
||||
@@ -26,4 +27,6 @@ class NestingLimit {
|
||||
private:
|
||||
uint8_t _value;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
} // namespace DeserializationOption
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
#include <ArduinoJson/Polyfills/utility.hpp>
|
||||
|
||||
#include <stdlib.h> // for size_t
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// The default reader is a simple wrapper for Readers that are not copiable
|
||||
template <typename TSource, typename Enable = void>
|
||||
@@ -33,7 +34,8 @@ struct BoundedReader {
|
||||
// no default implementation because we need to pass the size to the
|
||||
// constructor
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
#include <ArduinoJson/Deserialization/Readers/IteratorReader.hpp>
|
||||
#include <ArduinoJson/Deserialization/Readers/RamReader.hpp>
|
||||
@@ -54,3 +56,18 @@ struct BoundedReader {
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
||||
# include <ArduinoJson/Deserialization/Readers/StdStreamReader.hpp>
|
||||
#endif
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TInput>
|
||||
Reader<typename remove_reference<TInput>::type> makeReader(TInput&& input) {
|
||||
return Reader<typename remove_reference<TInput>::type>{
|
||||
detail::forward<TInput>(input)};
|
||||
}
|
||||
|
||||
template <typename TChar>
|
||||
BoundedReader<TChar*> makeReader(TChar* input, size_t inputSize) {
|
||||
return BoundedReader<TChar*>{input, inputSize};
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TSource>
|
||||
struct Reader<TSource,
|
||||
@@ -28,4 +28,4 @@ struct Reader<TSource,
|
||||
Stream* _stream;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TSource>
|
||||
struct Reader<TSource,
|
||||
typename enable_if<is_base_of< ::String, TSource>::value>::type>
|
||||
typename enable_if<is_base_of<::String, TSource>::value>::type>
|
||||
: BoundedReader<const char*> {
|
||||
explicit Reader(const ::String& s)
|
||||
: BoundedReader<const char*>(s.c_str(), s.length()) {}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <>
|
||||
struct Reader<const __FlashStringHelper*, void> {
|
||||
@@ -52,4 +52,5 @@ struct BoundedReader<const __FlashStringHelper*, void> {
|
||||
return length;
|
||||
}
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TIterator>
|
||||
class IteratorReader {
|
||||
@@ -41,4 +41,5 @@ struct Reader<TSource, typename void_<typename TSource::const_iterator>::type>
|
||||
: IteratorReader<typename TSource::const_iterator>(source.begin(),
|
||||
source.end()) {}
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct IsCharOrVoid {
|
||||
@@ -48,4 +48,4 @@ struct BoundedReader<TSource*,
|
||||
reinterpret_cast<const char*>(ptr) + len) {}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <istream>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TSource>
|
||||
struct Reader<TSource, typename enable_if<
|
||||
@@ -26,4 +26,5 @@ struct Reader<TSource, typename enable_if<
|
||||
private:
|
||||
std::istream* _stream;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <ArduinoJson/Object/MemberProxy.hpp>
|
||||
#include <ArduinoJson/Variant/JsonVariantConst.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TVariant>
|
||||
struct Reader<TVariant, typename enable_if<IsVariant<TVariant>::value>::type>
|
||||
@@ -16,4 +16,4 @@ struct Reader<TVariant, typename enable_if<IsVariant<TVariant>::value>::type>
|
||||
: Reader<char*, void>(x.template as<const char*>()) {}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Deserialization/DeserializationError.hpp>
|
||||
#include <ArduinoJson/Deserialization/Filter.hpp>
|
||||
#include <ArduinoJson/Deserialization/NestingLimit.hpp>
|
||||
#include <ArduinoJson/Deserialization/DeserializationOptions.hpp>
|
||||
#include <ArduinoJson/Deserialization/Reader.hpp>
|
||||
#include <ArduinoJson/Polyfills/utility.hpp>
|
||||
#include <ArduinoJson/StringStorage/StringStorage.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <template <typename, typename> class TDeserializer, typename TReader,
|
||||
typename TWriter>
|
||||
@@ -21,55 +21,33 @@ TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool,
|
||||
return TDeserializer<TReader, TWriter>(pool, reader, writer);
|
||||
}
|
||||
|
||||
// deserialize(JsonDocument&, const std::string&, NestingLimit, Filter);
|
||||
// deserialize(JsonDocument&, const String&, NestingLimit, Filter);
|
||||
// deserialize(JsonDocument&, char*, NestingLimit, Filter);
|
||||
// deserialize(JsonDocument&, const char*, NestingLimit, Filter);
|
||||
// deserialize(JsonDocument&, const __FlashStringHelper*, NestingLimit, Filter);
|
||||
template <template <typename, typename> class TDeserializer, typename TString,
|
||||
typename TFilter>
|
||||
typename enable_if<!is_array<TString>::value, DeserializationError>::type
|
||||
deserialize(JsonDocument& doc, const TString& input, NestingLimit nestingLimit,
|
||||
TFilter filter) {
|
||||
Reader<TString> reader(input);
|
||||
VariantData* data = VariantAttorney::getData(doc);
|
||||
MemoryPool* pool = VariantAttorney::getPool(doc);
|
||||
doc.clear();
|
||||
return makeDeserializer<TDeserializer>(pool, reader,
|
||||
makeStringStorage(input, pool))
|
||||
.parse(*data, filter, nestingLimit);
|
||||
}
|
||||
//
|
||||
// deserialize(JsonDocument&, char*, size_t, NestingLimit, Filter);
|
||||
// deserialize(JsonDocument&, const char*, size_t, NestingLimit, Filter);
|
||||
// deserialize(JsonDocument&, const __FlashStringHelper*, size_t, NL, Filter);
|
||||
template <template <typename, typename> class TDeserializer, typename TChar,
|
||||
typename TFilter>
|
||||
DeserializationError deserialize(JsonDocument& doc, TChar* input,
|
||||
size_t inputSize, NestingLimit nestingLimit,
|
||||
TFilter filter) {
|
||||
BoundedReader<TChar*> reader(input, inputSize);
|
||||
VariantData* data = VariantAttorney::getData(doc);
|
||||
MemoryPool* pool = VariantAttorney::getPool(doc);
|
||||
doc.clear();
|
||||
return makeDeserializer<TDeserializer>(pool, reader,
|
||||
makeStringStorage(input, pool))
|
||||
.parse(*data, filter, nestingLimit);
|
||||
}
|
||||
//
|
||||
// deserialize(JsonDocument&, std::istream&, NestingLimit, Filter);
|
||||
// deserialize(JsonDocument&, Stream&, NestingLimit, Filter);
|
||||
template <template <typename, typename> class TDeserializer, typename TStream,
|
||||
typename TFilter>
|
||||
DeserializationError deserialize(JsonDocument& doc, TStream& input,
|
||||
NestingLimit nestingLimit, TFilter filter) {
|
||||
Reader<TStream> reader(input);
|
||||
VariantData* data = VariantAttorney::getData(doc);
|
||||
MemoryPool* pool = VariantAttorney::getPool(doc);
|
||||
typename... Args>
|
||||
DeserializationError deserialize(JsonDocument& doc, TStream&& input,
|
||||
Args... args) {
|
||||
auto reader = makeReader(detail::forward<TStream>(input));
|
||||
auto data = VariantAttorney::getData(doc);
|
||||
auto pool = VariantAttorney::getPool(doc);
|
||||
auto options = makeDeserializationOptions(args...);
|
||||
doc.clear();
|
||||
return makeDeserializer<TDeserializer>(pool, reader,
|
||||
makeStringStorage(input, pool))
|
||||
.parse(*data, filter, nestingLimit);
|
||||
.parse(*data, options.filter, options.nestingLimit);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
template <template <typename, typename> class TDeserializer, typename TChar,
|
||||
typename Size, typename... Args,
|
||||
typename = typename enable_if<is_integral<Size>::value>::type>
|
||||
DeserializationError deserialize(JsonDocument& doc, TChar* input,
|
||||
Size inputSize, Args... args) {
|
||||
auto reader = makeReader(input, size_t(inputSize));
|
||||
auto data = VariantAttorney::getData(doc);
|
||||
auto pool = VariantAttorney::getPool(doc);
|
||||
auto options = makeDeserializationOptions(args...);
|
||||
doc.clear();
|
||||
return makeDeserializer<TDeserializer>(pool, reader,
|
||||
makeStringStorage(input, pool))
|
||||
.parse(*data, options.filter, options.nestingLimit);
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Document/JsonDocument.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// Helper to implement the "base-from-member" idiom
|
||||
// (we need to store the allocator before constructing JsonDocument)
|
||||
@@ -52,11 +52,9 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument {
|
||||
}
|
||||
|
||||
// Move-constructor
|
||||
#if ARDUINOJSON_HAS_RVALUE_REFERENCES
|
||||
BasicJsonDocument(BasicJsonDocument&& src) : AllocatorOwner<TAllocator>(src) {
|
||||
moveAssignFrom(src);
|
||||
}
|
||||
#endif
|
||||
|
||||
BasicJsonDocument(const JsonDocument& src) {
|
||||
copyAssignFrom(src);
|
||||
@@ -64,13 +62,14 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument {
|
||||
|
||||
// Construct from variant, array, or object
|
||||
template <typename T>
|
||||
BasicJsonDocument(
|
||||
const T& src,
|
||||
typename enable_if<
|
||||
is_same<T, JsonVariant>::value ||
|
||||
is_same<T, JsonVariantConst>::value || is_same<T, JsonArray>::value ||
|
||||
is_same<T, JsonArrayConst>::value || is_same<T, JsonObject>::value ||
|
||||
is_same<T, JsonObjectConst>::value>::type* = 0)
|
||||
BasicJsonDocument(const T& src,
|
||||
typename detail::enable_if<
|
||||
detail::is_same<T, JsonVariant>::value ||
|
||||
detail::is_same<T, JsonVariantConst>::value ||
|
||||
detail::is_same<T, JsonArray>::value ||
|
||||
detail::is_same<T, JsonArrayConst>::value ||
|
||||
detail::is_same<T, JsonObject>::value ||
|
||||
detail::is_same<T, JsonObjectConst>::value>::type* = 0)
|
||||
: JsonDocument(allocPool(src.memoryUsage())) {
|
||||
set(src);
|
||||
}
|
||||
@@ -90,12 +89,10 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ARDUINOJSON_HAS_RVALUE_REFERENCES
|
||||
BasicJsonDocument& operator=(BasicJsonDocument&& src) {
|
||||
moveAssignFrom(src);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T>
|
||||
BasicJsonDocument& operator=(const T& src) {
|
||||
@@ -138,17 +135,17 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument {
|
||||
using AllocatorOwner<TAllocator>::allocator;
|
||||
|
||||
private:
|
||||
MemoryPool allocPool(size_t requiredSize) {
|
||||
size_t capa = addPadding(requiredSize);
|
||||
return MemoryPool(reinterpret_cast<char*>(this->allocate(capa)), capa);
|
||||
detail::MemoryPool allocPool(size_t requiredSize) {
|
||||
size_t capa = detail::addPadding(requiredSize);
|
||||
return {reinterpret_cast<char*>(this->allocate(capa)), capa};
|
||||
}
|
||||
|
||||
void reallocPool(size_t requiredSize) {
|
||||
size_t capa = addPadding(requiredSize);
|
||||
size_t capa = detail::addPadding(requiredSize);
|
||||
if (capa == _pool.capacity())
|
||||
return;
|
||||
freePool();
|
||||
replacePool(allocPool(addPadding(requiredSize)));
|
||||
replacePool(allocPool(detail::addPadding(requiredSize)));
|
||||
}
|
||||
|
||||
void freePool() {
|
||||
@@ -165,8 +162,8 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument {
|
||||
_data = src._data;
|
||||
_pool = src._pool;
|
||||
src._data.setNull();
|
||||
src._pool = MemoryPool(0, 0);
|
||||
src._pool = {0, 0};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <stdlib.h> // malloc, free
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// The allocator of DynamicJsonDocument.
|
||||
struct DefaultAllocator {
|
||||
@@ -29,4 +29,4 @@ struct DefaultAllocator {
|
||||
// https://arduinojson.org/v6/api/dynamicjsondocument/
|
||||
typedef BasicJsonDocument<DefaultAllocator> DynamicJsonDocument;
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -12,14 +12,17 @@
|
||||
#include <ArduinoJson/Variant/JsonVariantConst.hpp>
|
||||
#include <ArduinoJson/Variant/VariantTo.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// A JSON document.
|
||||
// https://arduinojson.org/v6/api/jsondocument/
|
||||
class JsonDocument : public VariantOperators<const JsonDocument&> {
|
||||
friend class VariantAttorney;
|
||||
class JsonDocument : public detail::VariantOperators<const JsonDocument&> {
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
JsonDocument(const JsonDocument&) = delete;
|
||||
JsonDocument& operator=(const JsonDocument&) = delete;
|
||||
|
||||
// Casts the root to the specified type.
|
||||
// https://arduinojson.org/v6/api/jsondocument/as/
|
||||
template <typename T>
|
||||
@@ -100,15 +103,16 @@ class JsonDocument : public VariantOperators<const JsonDocument&> {
|
||||
// Replaces the root with the specified value.
|
||||
// https://arduinojson.org/v6/api/jsondocument/set/
|
||||
template <typename T>
|
||||
typename enable_if<!is_base_of<JsonDocument, T>::value, bool>::type set(
|
||||
const T& src) {
|
||||
typename detail::enable_if<!detail::is_base_of<JsonDocument, T>::value,
|
||||
bool>::type
|
||||
set(const T& src) {
|
||||
return to<JsonVariant>().set(src);
|
||||
}
|
||||
|
||||
// Clears the document and converts it to the specified type.
|
||||
// https://arduinojson.org/v6/api/jsondocument/to/
|
||||
template <typename T>
|
||||
typename VariantTo<T>::type to() {
|
||||
typename detail::VariantTo<T>::type to() {
|
||||
clear();
|
||||
return getVariant().template to<T>();
|
||||
}
|
||||
@@ -157,56 +161,58 @@ class JsonDocument : public VariantOperators<const JsonDocument&> {
|
||||
// https://arduinojson.org/v6/api/jsondocument/containskey/
|
||||
template <typename TChar>
|
||||
bool containsKey(TChar* key) const {
|
||||
return _data.getMember(adaptString(key)) != 0;
|
||||
return _data.getMember(detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Returns true if the root object contains the specified key.
|
||||
// https://arduinojson.org/v6/api/jsondocument/containskey/
|
||||
template <typename TString>
|
||||
bool containsKey(const TString& key) const {
|
||||
return _data.getMember(adaptString(key)) != 0;
|
||||
return _data.getMember(detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Gets or sets a root object's member.
|
||||
// https://arduinojson.org/v6/api/jsondocument/subscript/
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename enable_if<IsString<TString>::value,
|
||||
MemberProxy<JsonDocument&, TString> >::type
|
||||
FORCE_INLINE typename detail::enable_if<
|
||||
detail::IsString<TString>::value,
|
||||
detail::MemberProxy<JsonDocument&, TString>>::type
|
||||
operator[](const TString& key) {
|
||||
return MemberProxy<JsonDocument&, TString>(*this, key);
|
||||
return {*this, key};
|
||||
}
|
||||
|
||||
// Gets or sets a root object's member.
|
||||
// https://arduinojson.org/v6/api/jsondocument/subscript/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE typename enable_if<IsString<TChar*>::value,
|
||||
MemberProxy<JsonDocument&, TChar*> >::type
|
||||
FORCE_INLINE typename detail::enable_if<
|
||||
detail::IsString<TChar*>::value,
|
||||
detail::MemberProxy<JsonDocument&, TChar*>>::type
|
||||
operator[](TChar* key) {
|
||||
return MemberProxy<JsonDocument&, TChar*>(*this, key);
|
||||
return {*this, key};
|
||||
}
|
||||
|
||||
// Gets a root object's member.
|
||||
// https://arduinojson.org/v6/api/jsondocument/subscript/
|
||||
template <typename TString>
|
||||
FORCE_INLINE
|
||||
typename enable_if<IsString<TString>::value, JsonVariantConst>::type
|
||||
operator[](const TString& key) const {
|
||||
return JsonVariantConst(_data.getMember(adaptString(key)));
|
||||
FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value,
|
||||
JsonVariantConst>::type
|
||||
operator[](const TString& key) const {
|
||||
return JsonVariantConst(_data.getMember(detail::adaptString(key)));
|
||||
}
|
||||
|
||||
// Gets a root object's member.
|
||||
// https://arduinojson.org/v6/api/jsondocument/subscript/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE
|
||||
typename enable_if<IsString<TChar*>::value, JsonVariantConst>::type
|
||||
operator[](TChar* key) const {
|
||||
return JsonVariantConst(_data.getMember(adaptString(key)));
|
||||
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value,
|
||||
JsonVariantConst>::type
|
||||
operator[](TChar* key) const {
|
||||
return JsonVariantConst(_data.getMember(detail::adaptString(key)));
|
||||
}
|
||||
|
||||
// Gets or sets a root array's element.
|
||||
// https://arduinojson.org/v6/api/jsondocument/subscript/
|
||||
FORCE_INLINE ElementProxy<JsonDocument&> operator[](size_t index) {
|
||||
return ElementProxy<JsonDocument&>(*this, index);
|
||||
FORCE_INLINE detail::ElementProxy<JsonDocument&> operator[](size_t index) {
|
||||
return {*this, index};
|
||||
}
|
||||
|
||||
// Gets a root array's member.
|
||||
@@ -247,18 +253,19 @@ class JsonDocument : public VariantOperators<const JsonDocument&> {
|
||||
// ⚠️ Doesn't release the memory associated with the removed element.
|
||||
// https://arduinojson.org/v6/api/jsondocument/remove/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE typename enable_if<IsString<TChar*>::value>::type remove(
|
||||
TChar* key) {
|
||||
_data.remove(adaptString(key));
|
||||
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value>::type
|
||||
remove(TChar* key) {
|
||||
_data.remove(detail::adaptString(key));
|
||||
}
|
||||
|
||||
// Removes a member of the root object.
|
||||
// ⚠️ Doesn't release the memory associated with the removed element.
|
||||
// https://arduinojson.org/v6/api/jsondocument/remove/
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove(
|
||||
const TString& key) {
|
||||
_data.remove(adaptString(key));
|
||||
FORCE_INLINE
|
||||
typename detail::enable_if<detail::IsString<TString>::value>::type
|
||||
remove(const TString& key) {
|
||||
_data.remove(detail::adaptString(key));
|
||||
}
|
||||
|
||||
FORCE_INLINE operator JsonVariant() {
|
||||
@@ -274,7 +281,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> {
|
||||
_data.init();
|
||||
}
|
||||
|
||||
JsonDocument(MemoryPool pool) : _pool(pool) {
|
||||
JsonDocument(detail::MemoryPool pool) : _pool(pool) {
|
||||
_data.init();
|
||||
}
|
||||
|
||||
@@ -284,7 +291,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> {
|
||||
|
||||
~JsonDocument() {}
|
||||
|
||||
void replacePool(MemoryPool pool) {
|
||||
void replacePool(detail::MemoryPool pool) {
|
||||
_pool = pool;
|
||||
}
|
||||
|
||||
@@ -296,27 +303,23 @@ class JsonDocument : public VariantOperators<const JsonDocument&> {
|
||||
return JsonVariantConst(&_data);
|
||||
}
|
||||
|
||||
MemoryPool _pool;
|
||||
VariantData _data;
|
||||
|
||||
private:
|
||||
JsonDocument(const JsonDocument&);
|
||||
JsonDocument& operator=(const JsonDocument&);
|
||||
detail::MemoryPool _pool;
|
||||
detail::VariantData _data;
|
||||
|
||||
protected:
|
||||
MemoryPool* getPool() {
|
||||
detail::MemoryPool* getPool() {
|
||||
return &_pool;
|
||||
}
|
||||
|
||||
VariantData* getData() {
|
||||
detail::VariantData* getData() {
|
||||
return &_data;
|
||||
}
|
||||
|
||||
const VariantData* getData() const {
|
||||
const detail::VariantData* getData() const {
|
||||
return &_data;
|
||||
}
|
||||
|
||||
VariantData* getOrCreateData() {
|
||||
detail::VariantData* getOrCreateData() {
|
||||
return &_data;
|
||||
}
|
||||
};
|
||||
@@ -325,4 +328,4 @@ inline void convertToJson(const JsonDocument& src, JsonVariant dst) {
|
||||
dst.set(src.as<JsonVariantConst>());
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Document/JsonDocument.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// A JsonDocument with a memory pool on the stack.
|
||||
template <size_t desiredCapacity>
|
||||
class StaticJsonDocument : public JsonDocument {
|
||||
static const size_t _capacity =
|
||||
AddPadding<Max<1, desiredCapacity>::value>::value;
|
||||
detail::AddPadding<detail::Max<1, desiredCapacity>::value>::value;
|
||||
|
||||
public:
|
||||
StaticJsonDocument() : JsonDocument(_buffer, _capacity) {}
|
||||
@@ -25,7 +25,8 @@ class StaticJsonDocument : public JsonDocument {
|
||||
template <typename T>
|
||||
StaticJsonDocument(
|
||||
const T& src,
|
||||
typename enable_if<is_convertible<T, JsonVariantConst>::value>::type* = 0)
|
||||
typename detail::enable_if<
|
||||
detail::is_convertible<T, JsonVariantConst>::value>::type* = 0)
|
||||
: JsonDocument(_buffer, _capacity) {
|
||||
set(src);
|
||||
}
|
||||
@@ -57,4 +58,4 @@ class StaticJsonDocument : public JsonDocument {
|
||||
char _buffer[_capacity];
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
class EscapeSequence {
|
||||
public:
|
||||
@@ -36,4 +36,5 @@ class EscapeSequence {
|
||||
return &"//\"\"\\\\b\bf\fn\nr\rt\t"[excludeSolidus ? 2 : 0];
|
||||
}
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -13,9 +13,10 @@
|
||||
#include <ArduinoJson/Numbers/parseNumber.hpp>
|
||||
#include <ArduinoJson/Polyfills/assert.hpp>
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
#include <ArduinoJson/Polyfills/utility.hpp>
|
||||
#include <ArduinoJson/Variant/VariantData.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TReader, typename TStringStorage>
|
||||
class JsonDeserializer {
|
||||
@@ -29,7 +30,7 @@ class JsonDeserializer {
|
||||
|
||||
template <typename TFilter>
|
||||
DeserializationError parse(VariantData& variant, TFilter filter,
|
||||
NestingLimit nestingLimit) {
|
||||
DeserializationOption::NestingLimit nestingLimit) {
|
||||
DeserializationError::Code err;
|
||||
|
||||
err = parseVariant(variant, filter, nestingLimit);
|
||||
@@ -59,8 +60,9 @@ class JsonDeserializer {
|
||||
}
|
||||
|
||||
template <typename TFilter>
|
||||
DeserializationError::Code parseVariant(VariantData& variant, TFilter filter,
|
||||
NestingLimit nestingLimit) {
|
||||
DeserializationError::Code parseVariant(
|
||||
VariantData& variant, TFilter filter,
|
||||
DeserializationOption::NestingLimit nestingLimit) {
|
||||
DeserializationError::Code err;
|
||||
|
||||
err = skipSpacesAndComments();
|
||||
@@ -110,7 +112,8 @@ class JsonDeserializer {
|
||||
}
|
||||
}
|
||||
|
||||
DeserializationError::Code skipVariant(NestingLimit nestingLimit) {
|
||||
DeserializationError::Code skipVariant(
|
||||
DeserializationOption::NestingLimit nestingLimit) {
|
||||
DeserializationError::Code err;
|
||||
|
||||
err = skipSpacesAndComments();
|
||||
@@ -143,8 +146,9 @@ class JsonDeserializer {
|
||||
}
|
||||
|
||||
template <typename TFilter>
|
||||
DeserializationError::Code parseArray(CollectionData& array, TFilter filter,
|
||||
NestingLimit nestingLimit) {
|
||||
DeserializationError::Code parseArray(
|
||||
CollectionData& array, TFilter filter,
|
||||
DeserializationOption::NestingLimit nestingLimit) {
|
||||
DeserializationError::Code err;
|
||||
|
||||
if (nestingLimit.reached())
|
||||
@@ -196,7 +200,8 @@ class JsonDeserializer {
|
||||
}
|
||||
}
|
||||
|
||||
DeserializationError::Code skipArray(NestingLimit nestingLimit) {
|
||||
DeserializationError::Code skipArray(
|
||||
DeserializationOption::NestingLimit nestingLimit) {
|
||||
DeserializationError::Code err;
|
||||
|
||||
if (nestingLimit.reached())
|
||||
@@ -227,8 +232,9 @@ class JsonDeserializer {
|
||||
}
|
||||
|
||||
template <typename TFilter>
|
||||
DeserializationError::Code parseObject(CollectionData& object, TFilter filter,
|
||||
NestingLimit nestingLimit) {
|
||||
DeserializationError::Code parseObject(
|
||||
CollectionData& object, TFilter filter,
|
||||
DeserializationOption::NestingLimit nestingLimit) {
|
||||
DeserializationError::Code err;
|
||||
|
||||
if (nestingLimit.reached())
|
||||
@@ -312,7 +318,8 @@ class JsonDeserializer {
|
||||
}
|
||||
}
|
||||
|
||||
DeserializationError::Code skipObject(NestingLimit nestingLimit) {
|
||||
DeserializationError::Code skipObject(
|
||||
DeserializationOption::NestingLimit nestingLimit) {
|
||||
DeserializationError::Code err;
|
||||
|
||||
if (nestingLimit.reached())
|
||||
@@ -661,115 +668,26 @@ class JsonDeserializer {
|
||||
// code
|
||||
};
|
||||
|
||||
// Parses a JSON input and puts the result in a JsonDocument.
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TString>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, const TString& input,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit,
|
||||
AllowAllFilter());
|
||||
template <typename... Args>
|
||||
DeserializationError deserializeJson(JsonDocument& doc, Args&&... args) {
|
||||
using namespace detail;
|
||||
return deserialize<JsonDeserializer>(doc, detail::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TString>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, const TString& input, Filter filter,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter);
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TString>
|
||||
DeserializationError deserializeJson(JsonDocument& doc, const TString& input,
|
||||
NestingLimit nestingLimit, Filter filter) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter);
|
||||
}
|
||||
|
||||
// Parses a JSON input and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TStream>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, TStream& input,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit,
|
||||
AllowAllFilter());
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TStream>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, TStream& input, Filter filter,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter);
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TStream>
|
||||
DeserializationError deserializeJson(JsonDocument& doc, TStream& input,
|
||||
NestingLimit nestingLimit, Filter filter) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter);
|
||||
}
|
||||
|
||||
// Parses a JSON input and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TChar>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, TChar* input,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit,
|
||||
AllowAllFilter());
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TChar>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, TChar* input, Filter filter,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter);
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TChar>
|
||||
template <typename TChar, typename... Args>
|
||||
DeserializationError deserializeJson(JsonDocument& doc, TChar* input,
|
||||
NestingLimit nestingLimit, Filter filter) {
|
||||
return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter);
|
||||
Args&&... args) {
|
||||
using namespace detail;
|
||||
return deserialize<JsonDeserializer>(doc, input,
|
||||
detail::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// Parses a JSON input and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TChar>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, TChar* input, size_t inputSize,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit,
|
||||
AllowAllFilter());
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TChar>
|
||||
DeserializationError deserializeJson(
|
||||
JsonDocument& doc, TChar* input, size_t inputSize, Filter filter,
|
||||
NestingLimit nestingLimit = NestingLimit()) {
|
||||
return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit,
|
||||
filter);
|
||||
}
|
||||
|
||||
// Parses a JSON input, filters, and puts the result in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/json/deserializejson/
|
||||
template <typename TChar>
|
||||
DeserializationError deserializeJson(JsonDocument& doc, TChar* input,
|
||||
size_t inputSize,
|
||||
NestingLimit nestingLimit, Filter filter) {
|
||||
return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit,
|
||||
filter);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <ArduinoJson/Serialization/serialize.hpp>
|
||||
#include <ArduinoJson/Variant/Visitor.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TWriter>
|
||||
class JsonSerializer : public Visitor<size_t> {
|
||||
@@ -115,10 +115,15 @@ class JsonSerializer : public Visitor<size_t> {
|
||||
TextFormatter<TWriter> _formatter;
|
||||
};
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// Produces a minified JSON document.
|
||||
// https://arduinojson.org/v6/api/json/serializejson/
|
||||
template <typename TDestination>
|
||||
size_t serializeJson(JsonVariantConst source, TDestination& destination) {
|
||||
using namespace detail;
|
||||
return serialize<JsonSerializer>(source, destination);
|
||||
}
|
||||
|
||||
@@ -126,23 +131,25 @@ size_t serializeJson(JsonVariantConst source, TDestination& destination) {
|
||||
// https://arduinojson.org/v6/api/json/serializejson/
|
||||
inline size_t serializeJson(JsonVariantConst source, void* buffer,
|
||||
size_t bufferSize) {
|
||||
using namespace detail;
|
||||
return serialize<JsonSerializer>(source, buffer, bufferSize);
|
||||
}
|
||||
|
||||
// Computes the length of the document that serializeJson() produces.
|
||||
// https://arduinojson.org/v6/api/json/measurejson/
|
||||
inline size_t measureJson(JsonVariantConst source) {
|
||||
using namespace detail;
|
||||
return measure<JsonSerializer>(source);
|
||||
}
|
||||
|
||||
#if ARDUINOJSON_ENABLE_STD_STREAM
|
||||
template <typename T>
|
||||
inline typename enable_if<is_convertible<T, JsonVariantConst>::value,
|
||||
std::ostream&>::type
|
||||
inline typename detail::enable_if<
|
||||
detail::is_convertible<T, JsonVariantConst>::value, std::ostream&>::type
|
||||
operator<<(std::ostream& os, const T& source) {
|
||||
serializeJson(source, os);
|
||||
return os;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Polyfills/assert.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TReader>
|
||||
class Latch {
|
||||
@@ -53,4 +53,4 @@ class Latch {
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <ArduinoJson/Serialization/measure.hpp>
|
||||
#include <ArduinoJson/Serialization/serialize.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TWriter>
|
||||
class PrettyJsonSerializer : public JsonSerializer<TWriter> {
|
||||
@@ -71,10 +71,15 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
|
||||
uint8_t _nesting;
|
||||
};
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// Produces JsonDocument to create a prettified JSON document.
|
||||
// https://arduinojson.org/v6/api/json/serializejsonpretty/
|
||||
template <typename TDestination>
|
||||
size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) {
|
||||
using namespace ArduinoJson::detail;
|
||||
return serialize<PrettyJsonSerializer>(source, destination);
|
||||
}
|
||||
|
||||
@@ -82,13 +87,15 @@ size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) {
|
||||
// https://arduinojson.org/v6/api/json/serializejsonpretty/
|
||||
inline size_t serializeJsonPretty(JsonVariantConst source, void* buffer,
|
||||
size_t bufferSize) {
|
||||
using namespace ArduinoJson::detail;
|
||||
return serialize<PrettyJsonSerializer>(source, buffer, bufferSize);
|
||||
}
|
||||
|
||||
// Computes the length of the document that serializeJsonPretty() produces.
|
||||
// https://arduinojson.org/v6/api/json/measurejsonpretty/
|
||||
inline size_t measureJsonPretty(JsonVariantConst source) {
|
||||
using namespace ArduinoJson::detail;
|
||||
return measure<PrettyJsonSerializer>(source);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -15,13 +15,15 @@
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
#include <ArduinoJson/Serialization/CountingDecorator.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TWriter>
|
||||
class TextFormatter {
|
||||
public:
|
||||
explicit TextFormatter(TWriter writer) : _writer(writer) {}
|
||||
|
||||
TextFormatter& operator=(const TextFormatter&) = delete;
|
||||
|
||||
// Returns the number of bytes sent to the TWriter implementation.
|
||||
size_t bytesWritten() const {
|
||||
return _writer.count();
|
||||
@@ -166,8 +168,6 @@ class TextFormatter {
|
||||
|
||||
protected:
|
||||
CountingDecorator<TWriter> _writer;
|
||||
|
||||
private:
|
||||
TextFormatter& operator=(const TextFormatter&); // cannot be assigned
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -18,7 +18,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
namespace Utf16 {
|
||||
inline bool isHighSurrogate(uint16_t codeunit) {
|
||||
@@ -58,7 +58,7 @@ class Codepoint {
|
||||
uint32_t _codepoint;
|
||||
};
|
||||
} // namespace Utf16
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# if __GNUC__ >= 8
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
namespace Utf8 {
|
||||
template <typename TStringBuilder>
|
||||
@@ -43,4 +43,4 @@ inline void encodeCodepoint(uint32_t codepoint32, TStringBuilder& str) {
|
||||
}
|
||||
}
|
||||
} // namespace Utf8
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_ENABLE_ALIGNMENT
|
||||
|
||||
@@ -57,4 +57,4 @@ inline T* addPadding(T* p) {
|
||||
return reinterpret_cast<T*>(address);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -17,14 +17,14 @@
|
||||
// Computes the size required to store an array in a JsonDocument.
|
||||
// https://arduinojson.org/v6/how-to/determine-the-capacity-of-the-jsondocument/
|
||||
#define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \
|
||||
((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot))
|
||||
((NUMBER_OF_ELEMENTS) * sizeof(ArduinoJson::detail::VariantSlot))
|
||||
|
||||
// Returns the size (in bytes) of an object with n elements.
|
||||
// Can be very handy to determine the size of a StaticMemoryPool.
|
||||
#define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \
|
||||
((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot))
|
||||
((NUMBER_OF_ELEMENTS) * sizeof(ArduinoJson::detail::VariantSlot))
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// _begin _end
|
||||
// v v
|
||||
@@ -250,4 +250,4 @@ bool storeString(MemoryPool* pool, TAdaptedString str, TCallback callback) {
|
||||
return storeString(pool, str, str.storagePolicy(), callback);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
|
||||
template <typename T>
|
||||
class SafeBoolIdom {
|
||||
protected:
|
||||
typedef void (T::*bool_type)() const;
|
||||
void safeBoolHelper() const {}
|
||||
|
||||
static bool_type safe_true() {
|
||||
return &SafeBoolIdom::safeBoolHelper;
|
||||
}
|
||||
|
||||
static bool_type safe_false() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Strings/StringAdapters.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// A special type of data that can be used to insert pregenerated JSON portions.
|
||||
template <typename T>
|
||||
@@ -58,11 +58,12 @@ inline SerializedValue<T> serialized(T str) {
|
||||
|
||||
template <typename TChar>
|
||||
inline SerializedValue<TChar*> serialized(TChar* p) {
|
||||
return SerializedValue<TChar*>(p, adaptString(p).size());
|
||||
return SerializedValue<TChar*>(p, detail::adaptString(p).size());
|
||||
}
|
||||
|
||||
template <typename TChar>
|
||||
inline SerializedValue<TChar*> serialized(TChar* p, size_t n) {
|
||||
return SerializedValue<TChar*>(p, n);
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <ArduinoJson/Serialization/serialize.hpp>
|
||||
#include <ArduinoJson/Variant/VariantData.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TWriter>
|
||||
class MsgPackSerializer : public Visitor<size_t> {
|
||||
@@ -197,10 +197,15 @@ class MsgPackSerializer : public Visitor<size_t> {
|
||||
CountingDecorator<TWriter> _writer;
|
||||
};
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// Produces a MessagePack document.
|
||||
// https://arduinojson.org/v6/api/msgpack/serializemsgpack/
|
||||
template <typename TDestination>
|
||||
inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) {
|
||||
using namespace ArduinoJson::detail;
|
||||
return serialize<MsgPackSerializer>(source, output);
|
||||
}
|
||||
|
||||
@@ -208,13 +213,15 @@ inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) {
|
||||
// https://arduinojson.org/v6/api/msgpack/serializemsgpack/
|
||||
inline size_t serializeMsgPack(JsonVariantConst source, void* output,
|
||||
size_t size) {
|
||||
using namespace ArduinoJson::detail;
|
||||
return serialize<MsgPackSerializer>(source, output, size);
|
||||
}
|
||||
|
||||
// Computes the length of the document that serializeMsgPack() produces.
|
||||
// https://arduinojson.org/v6/api/msgpack/measuremsgpack/
|
||||
inline size_t measureMsgPack(JsonVariantConst source) {
|
||||
using namespace ArduinoJson::detail;
|
||||
return measure<MsgPackSerializer>(source);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_LITTLE_ENDIAN
|
||||
inline void swapBytes(uint8_t& a, uint8_t& b) {
|
||||
@@ -43,4 +43,4 @@ template <typename T>
|
||||
inline void fixEndianess(T&) {}
|
||||
#endif
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) {
|
||||
f[0] = uint8_t((d[0] & 0xC0) | (d[0] << 3 & 0x3f) | (d[1] >> 5));
|
||||
@@ -15,4 +15,4 @@ inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) {
|
||||
f[3] = uint8_t((d[3] << 3) | (d[4] >> 5));
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,19 +8,36 @@
|
||||
#include <ArduinoJson/Polyfills/preprocessor.hpp>
|
||||
#include <ArduinoJson/version.hpp>
|
||||
|
||||
#ifndef ARDUINOJSON_NAMESPACE
|
||||
#ifndef ARDUINOJSON_VERSION_NAMESPACE
|
||||
|
||||
# define ARDUINOJSON_NAMESPACE \
|
||||
ARDUINOJSON_CONCAT4( \
|
||||
ARDUINOJSON_CONCAT4(ArduinoJson, ARDUINOJSON_VERSION_MAJOR, \
|
||||
# define ARDUINOJSON_VERSION_NAMESPACE \
|
||||
ARDUINOJSON_CONCAT3( \
|
||||
ARDUINOJSON_CONCAT4(V, ARDUINOJSON_VERSION_MAJOR, \
|
||||
ARDUINOJSON_VERSION_MINOR, \
|
||||
ARDUINOJSON_VERSION_REVISION), \
|
||||
_, \
|
||||
ARDUINOJSON_HEX_DIGIT( \
|
||||
ARDUINOJSON_BIN2ALPHA( \
|
||||
ARDUINOJSON_ENABLE_PROGMEM, ARDUINOJSON_USE_LONG_LONG, \
|
||||
ARDUINOJSON_USE_DOUBLE, ARDUINOJSON_ENABLE_STRING_DEDUPLICATION), \
|
||||
ARDUINOJSON_HEX_DIGIT( \
|
||||
ARDUINOJSON_BIN2ALPHA( \
|
||||
ARDUINOJSON_ENABLE_NAN, ARDUINOJSON_ENABLE_INFINITY, \
|
||||
ARDUINOJSON_ENABLE_COMMENTS, ARDUINOJSON_DECODE_UNICODE))
|
||||
|
||||
#endif
|
||||
|
||||
#define ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE \
|
||||
namespace ArduinoJson { \
|
||||
inline namespace ARDUINOJSON_VERSION_NAMESPACE {
|
||||
|
||||
#define ARDUINOJSON_END_PUBLIC_NAMESPACE \
|
||||
} \
|
||||
}
|
||||
|
||||
#define ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE \
|
||||
namespace ArduinoJson { \
|
||||
inline namespace ARDUINOJSON_VERSION_NAMESPACE { \
|
||||
namespace detail {
|
||||
|
||||
#define ARDUINOJSON_END_PRIVATE_NAMESPACE \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <ArduinoJson/Numbers/FloatTraits.hpp>
|
||||
#include <ArduinoJson/Polyfills/math.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TFloat>
|
||||
struct FloatParts {
|
||||
@@ -63,8 +63,8 @@ struct FloatParts {
|
||||
|
||||
if (value >= ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD) {
|
||||
for (; index >= 0; index--) {
|
||||
if (value >= traits::positiveBinaryPowerOfTen(index)) {
|
||||
value *= traits::negativeBinaryPowerOfTen(index);
|
||||
if (value >= traits::positiveBinaryPowersOfTen()[index]) {
|
||||
value *= traits::negativeBinaryPowersOfTen()[index];
|
||||
powersOf10 = int16_t(powersOf10 + bit);
|
||||
}
|
||||
bit >>= 1;
|
||||
@@ -73,8 +73,8 @@ struct FloatParts {
|
||||
|
||||
if (value > 0 && value <= ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD) {
|
||||
for (; index >= 0; index--) {
|
||||
if (value < traits::negativeBinaryPowerOfTenPlusOne(index)) {
|
||||
value *= traits::positiveBinaryPowerOfTen(index);
|
||||
if (value < traits::negativeBinaryPowersOfTen()[index] * 10) {
|
||||
value *= traits::positiveBinaryPowersOfTen()[index];
|
||||
powersOf10 = int16_t(powersOf10 - bit);
|
||||
}
|
||||
bit >>= 1;
|
||||
@@ -84,4 +84,5 @@ struct FloatParts {
|
||||
return powersOf10;
|
||||
}
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -14,7 +14,7 @@
|
||||
#include <ArduinoJson/Polyfills/preprocessor.hpp>
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T, size_t = sizeof(T)>
|
||||
struct FloatTraits {};
|
||||
@@ -29,89 +29,50 @@ struct FloatTraits<T, 8 /*64bits*/> {
|
||||
typedef int16_t exponent_type;
|
||||
static const exponent_type exponent_max = 308;
|
||||
|
||||
template <typename TExponent>
|
||||
static T make_float(T m, TExponent e) {
|
||||
if (e > 0) {
|
||||
for (uint8_t index = 0; e != 0; index++) {
|
||||
if (e & 1)
|
||||
m *= positiveBinaryPowerOfTen(index);
|
||||
e >>= 1;
|
||||
}
|
||||
} else {
|
||||
e = TExponent(-e);
|
||||
for (uint8_t index = 0; e != 0; index++) {
|
||||
if (e & 1)
|
||||
m *= negativeBinaryPowerOfTen(index);
|
||||
e >>= 1;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
static pgm_ptr<T> positiveBinaryPowersOfTen() {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY( //
|
||||
uint64_t, factors,
|
||||
{
|
||||
0x4024000000000000, // 1e1
|
||||
0x4059000000000000, // 1e2
|
||||
0x40C3880000000000, // 1e4
|
||||
0x4197D78400000000, // 1e8
|
||||
0x4341C37937E08000, // 1e16
|
||||
0x4693B8B5B5056E17, // 1e32
|
||||
0x4D384F03E93FF9F5, // 1e64
|
||||
0x5A827748F9301D32, // 1e128
|
||||
0x75154FDD7F73BF3C, // 1e256
|
||||
});
|
||||
return pgm_ptr<T>(reinterpret_cast<const T*>(factors));
|
||||
}
|
||||
|
||||
static T positiveBinaryPowerOfTen(int index) {
|
||||
static pgm_ptr<T> negativeBinaryPowersOfTen() {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY( //
|
||||
uint32_t, factors,
|
||||
ARDUINOJSON_EXPAND18({
|
||||
0x40240000, 0x00000000, // 1e1
|
||||
0x40590000, 0x00000000, // 1e2
|
||||
0x40C38800, 0x00000000, // 1e4
|
||||
0x4197D784, 0x00000000, // 1e8
|
||||
0x4341C379, 0x37E08000, // 1e16
|
||||
0x4693B8B5, 0xB5056E17, // 1e32
|
||||
0x4D384F03, 0xE93FF9F5, // 1e64
|
||||
0x5A827748, 0xF9301D32, // 1e128
|
||||
0x75154FDD, 0x7F73BF3C // 1e256
|
||||
}));
|
||||
return forge(pgm_read(factors + 2 * index),
|
||||
pgm_read(factors + 2 * index + 1));
|
||||
}
|
||||
|
||||
static T negativeBinaryPowerOfTen(int index) {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY( //
|
||||
uint32_t, factors,
|
||||
ARDUINOJSON_EXPAND18({
|
||||
0x3FB99999, 0x9999999A, // 1e-1
|
||||
0x3F847AE1, 0x47AE147B, // 1e-2
|
||||
0x3F1A36E2, 0xEB1C432D, // 1e-4
|
||||
0x3E45798E, 0xE2308C3A, // 1e-8
|
||||
0x3C9CD2B2, 0x97D889BC, // 1e-16
|
||||
0x3949F623, 0xD5A8A733, // 1e-32
|
||||
0x32A50FFD, 0x44F4A73D, // 1e-64
|
||||
0x255BBA08, 0xCF8C979D, // 1e-128
|
||||
0x0AC80628, 0x64AC6F43 // 1e-256
|
||||
}));
|
||||
return forge(pgm_read(factors + 2 * index),
|
||||
pgm_read(factors + 2 * index + 1));
|
||||
}
|
||||
|
||||
static T negativeBinaryPowerOfTenPlusOne(int index) {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY( //
|
||||
uint32_t, factors,
|
||||
ARDUINOJSON_EXPAND18({
|
||||
0x3FF00000, 0x00000000, // 1e0
|
||||
0x3FB99999, 0x9999999A, // 1e-1
|
||||
0x3F50624D, 0xD2F1A9FC, // 1e-3
|
||||
0x3E7AD7F2, 0x9ABCAF48, // 1e-7
|
||||
0x3CD203AF, 0x9EE75616, // 1e-15
|
||||
0x398039D6, 0x65896880, // 1e-31
|
||||
0x32DA53FC, 0x9631D10D, // 1e-63
|
||||
0x25915445, 0x81B7DEC2, // 1e-127
|
||||
0x0AFE07B2, 0x7DD78B14 // 1e-255
|
||||
}));
|
||||
return forge(pgm_read(factors + 2 * index),
|
||||
pgm_read(factors + 2 * index + 1));
|
||||
uint64_t, factors,
|
||||
{
|
||||
0x3FB999999999999A, // 1e-1
|
||||
0x3F847AE147AE147B, // 1e-2
|
||||
0x3F1A36E2EB1C432D, // 1e-4
|
||||
0x3E45798EE2308C3A, // 1e-8
|
||||
0x3C9CD2B297D889BC, // 1e-16
|
||||
0x3949F623D5A8A733, // 1e-32
|
||||
0x32A50FFD44F4A73D, // 1e-64
|
||||
0x255BBA08CF8C979D, // 1e-128
|
||||
0x0AC8062864AC6F43 // 1e-256
|
||||
});
|
||||
return pgm_ptr<T>(reinterpret_cast<const T*>(factors));
|
||||
}
|
||||
|
||||
static T nan() {
|
||||
return forge(0x7ff80000, 0x00000000);
|
||||
return forge(0x7ff8000000000000);
|
||||
}
|
||||
|
||||
static T inf() {
|
||||
return forge(0x7ff00000, 0x00000000);
|
||||
return forge(0x7ff0000000000000);
|
||||
}
|
||||
|
||||
static T highest() {
|
||||
return forge(0x7FEFFFFF, 0xFFFFFFFF);
|
||||
return forge(0x7FEFFFFFFFFFFFFF);
|
||||
}
|
||||
|
||||
template <typename TOut> // int64_t
|
||||
@@ -119,7 +80,7 @@ struct FloatTraits<T, 8 /*64bits*/> {
|
||||
typename enable_if<is_integral<TOut>::value && is_signed<TOut>::value &&
|
||||
sizeof(TOut) == 8,
|
||||
signed>::type* = 0) {
|
||||
return forge(0x43DFFFFF, 0xFFFFFFFF); // 9.2233720368547748e+18
|
||||
return forge(0x43DFFFFFFFFFFFFF); // 9.2233720368547748e+18
|
||||
}
|
||||
|
||||
template <typename TOut> // uint64_t
|
||||
@@ -127,18 +88,18 @@ struct FloatTraits<T, 8 /*64bits*/> {
|
||||
typename enable_if<is_integral<TOut>::value && is_unsigned<TOut>::value &&
|
||||
sizeof(TOut) == 8,
|
||||
unsigned>::type* = 0) {
|
||||
return forge(0x43EFFFFF, 0xFFFFFFFF); // 1.8446744073709549568e+19
|
||||
return forge(0x43EFFFFFFFFFFFFF); // 1.8446744073709549568e+19
|
||||
}
|
||||
|
||||
static T lowest() {
|
||||
return forge(0xFFEFFFFF, 0xFFFFFFFF);
|
||||
return forge(0xFFEFFFFFFFFFFFFF);
|
||||
}
|
||||
|
||||
// constructs a double floating point values from its binary representation
|
||||
// we use this function to workaround platforms with single precision literals
|
||||
// (for example, when -fsingle-precision-constant is passed to GCC)
|
||||
static T forge(uint32_t msb, uint32_t lsb) {
|
||||
return alias_cast<T>((uint64_t(msb) << 32) | lsb);
|
||||
static T forge(uint64_t bits) {
|
||||
return alias_cast<T>(bits);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -152,62 +113,30 @@ struct FloatTraits<T, 4 /*32bits*/> {
|
||||
typedef int8_t exponent_type;
|
||||
static const exponent_type exponent_max = 38;
|
||||
|
||||
template <typename TExponent>
|
||||
static T make_float(T m, TExponent e) {
|
||||
if (e > 0) {
|
||||
for (uint8_t index = 0; e != 0; index++) {
|
||||
if (e & 1)
|
||||
m *= positiveBinaryPowerOfTen(index);
|
||||
e >>= 1;
|
||||
}
|
||||
} else {
|
||||
e = -e;
|
||||
for (uint8_t index = 0; e != 0; index++) {
|
||||
if (e & 1)
|
||||
m *= negativeBinaryPowerOfTen(index);
|
||||
e >>= 1;
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
static T positiveBinaryPowerOfTen(int index) {
|
||||
static pgm_ptr<T> positiveBinaryPowersOfTen() {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors,
|
||||
ARDUINOJSON_EXPAND6({
|
||||
{
|
||||
0x41200000, // 1e1f
|
||||
0x42c80000, // 1e2f
|
||||
0x461c4000, // 1e4f
|
||||
0x4cbebc20, // 1e8f
|
||||
0x5a0e1bca, // 1e16f
|
||||
0x749dc5ae // 1e32f
|
||||
}));
|
||||
return forge(pgm_read(factors + index));
|
||||
});
|
||||
return pgm_ptr<T>(reinterpret_cast<const T*>(factors));
|
||||
}
|
||||
|
||||
static T negativeBinaryPowerOfTen(int index) {
|
||||
static pgm_ptr<T> negativeBinaryPowersOfTen() {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors,
|
||||
ARDUINOJSON_EXPAND6({
|
||||
{
|
||||
0x3dcccccd, // 1e-1f
|
||||
0x3c23d70a, // 1e-2f
|
||||
0x38d1b717, // 1e-4f
|
||||
0x322bcc77, // 1e-8f
|
||||
0x24e69595, // 1e-16f
|
||||
0x0a4fb11f // 1e-32f
|
||||
}));
|
||||
return forge(pgm_read(factors + index));
|
||||
}
|
||||
|
||||
static T negativeBinaryPowerOfTenPlusOne(int index) {
|
||||
ARDUINOJSON_DEFINE_PROGMEM_ARRAY(uint32_t, factors,
|
||||
ARDUINOJSON_EXPAND6({
|
||||
0x3f800000, // 1e0f
|
||||
0x3dcccccd, // 1e-1f
|
||||
0x3a83126f, // 1e-3f
|
||||
0x33d6bf95, // 1e-7f
|
||||
0x26901d7d, // 1e-15f
|
||||
0x0c01ceb3 // 1e-31f
|
||||
}));
|
||||
return forge(pgm_read(factors + index));
|
||||
});
|
||||
return pgm_ptr<T>(reinterpret_cast<const T*>(factors));
|
||||
}
|
||||
|
||||
static T forge(uint32_t bits) {
|
||||
@@ -262,4 +191,22 @@ struct FloatTraits<T, 4 /*32bits*/> {
|
||||
return forge(0xFf7fffff);
|
||||
}
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
template <typename TFloat, typename TExponent>
|
||||
inline TFloat make_float(TFloat m, TExponent e) {
|
||||
using traits = FloatTraits<TFloat>;
|
||||
|
||||
auto powersOfTen = e > 0 ? traits::positiveBinaryPowersOfTen()
|
||||
: traits::negativeBinaryPowersOfTen();
|
||||
if (e <= 0)
|
||||
e = TExponent(-e);
|
||||
|
||||
for (uint8_t index = 0; e != 0; index++) {
|
||||
if (e & 1)
|
||||
m *= powersOfTen[index];
|
||||
e >>= 1;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,11 +7,12 @@
|
||||
#include <ArduinoJson/Configuration.hpp>
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_USE_DOUBLE
|
||||
typedef double JsonFloat;
|
||||
#else
|
||||
typedef float JsonFloat;
|
||||
#endif
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <stdint.h> // int64_t
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_USE_LONG_LONG
|
||||
typedef int64_t JsonInteger;
|
||||
@@ -19,14 +19,10 @@ typedef long JsonInteger;
|
||||
typedef unsigned long JsonUInt;
|
||||
#endif
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_HAS_LONG_LONG && !ARDUINOJSON_USE_LONG_LONG
|
||||
# define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) \
|
||||
static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::JsonInteger), \
|
||||
"To use 64-bit integers with ArduinoJson, you must set " \
|
||||
"ARDUINOJSON_USE_LONG_LONG to 1. See " \
|
||||
"https://arduinojson.org/v6/api/config/use_long_long/");
|
||||
#else
|
||||
# define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T)
|
||||
#endif
|
||||
#define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T) \
|
||||
static_assert(sizeof(T) <= sizeof(ArduinoJson::JsonInteger), \
|
||||
"To use 64-bit integers with ArduinoJson, you must set " \
|
||||
"ARDUINOJSON_USE_LONG_LONG to 1. See " \
|
||||
"https://arduinojson.org/v6/api/config/use_long_long/");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <ArduinoJson/Numbers/JsonInteger.hpp>
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
enum CompareResult {
|
||||
COMPARE_RESULT_DIFFER = 0,
|
||||
@@ -33,10 +33,7 @@ template <typename T1, typename T2>
|
||||
CompareResult arithmeticCompare(
|
||||
const T1& lhs, const T2& rhs,
|
||||
typename enable_if<is_integral<T1>::value && is_integral<T2>::value &&
|
||||
sizeof(T1) < sizeof(T2),
|
||||
int // Using int instead of void to avoid C2572 on
|
||||
// Visual Studio 2012, 2013, and 2015
|
||||
>::type* = 0) {
|
||||
sizeof(T1) < sizeof(T2)>::type* = 0) {
|
||||
return arithmeticCompare<T2>(static_cast<T2>(lhs), rhs);
|
||||
}
|
||||
|
||||
@@ -120,4 +117,4 @@ CompareResult arithmeticCompareNegateRight(
|
||||
return arithmeticCompare(static_cast<T1>(rhs), -lhs);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,9 +8,7 @@
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wconversion"
|
||||
#elif defined(__GNUC__)
|
||||
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
# pragma GCC diagnostic push
|
||||
# endif
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wconversion"
|
||||
#endif
|
||||
|
||||
@@ -19,7 +17,7 @@
|
||||
#include <ArduinoJson/Polyfills/limits.hpp>
|
||||
#include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// uint32 -> int32
|
||||
// uint64 -> int32
|
||||
@@ -128,12 +126,10 @@ template <typename TOut, typename TIn>
|
||||
TOut convertNumber(TIn value) {
|
||||
return canConvertNumber<TOut>(value) ? TOut(value) : 0;
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <ArduinoJson/Variant/Converter.hpp>
|
||||
#include <ArduinoJson/Variant/VariantData.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename A, typename B>
|
||||
struct choose_largest : conditional<(sizeof(A) > sizeof(B)), A, B> {};
|
||||
@@ -137,7 +137,7 @@ inline bool parseNumber(const char* s, VariantData& result) {
|
||||
return false;
|
||||
|
||||
JsonFloat final_result =
|
||||
traits::make_float(static_cast<JsonFloat>(mantissa), exponent);
|
||||
make_float(static_cast<JsonFloat>(mantissa), exponent);
|
||||
|
||||
result.setFloat(is_negative ? -final_result : final_result);
|
||||
return true;
|
||||
@@ -150,4 +150,4 @@ inline T parseNumber(const char* s) {
|
||||
parseNumber(s, value);
|
||||
return Converter<T>::fromJson(JsonVariantConst(&value));
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,14 +7,14 @@
|
||||
#include <ArduinoJson/Object/JsonObjectConst.hpp>
|
||||
#include <ArduinoJson/Object/MemberProxy.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
class JsonArray;
|
||||
|
||||
// A reference to an object in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/jsonobject/
|
||||
class JsonObject : public VariantOperators<JsonObject> {
|
||||
friend class VariantAttorney;
|
||||
class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonObjectIterator iterator;
|
||||
@@ -23,12 +23,12 @@ class JsonObject : public VariantOperators<JsonObject> {
|
||||
FORCE_INLINE JsonObject() : _data(0), _pool(0) {}
|
||||
|
||||
// INTERNAL USE ONLY
|
||||
FORCE_INLINE JsonObject(MemoryPool* buf, CollectionData* data)
|
||||
FORCE_INLINE JsonObject(detail::MemoryPool* buf, detail::CollectionData* data)
|
||||
: _data(data), _pool(buf) {}
|
||||
|
||||
operator JsonVariant() const {
|
||||
void* data = _data; // prevent warning cast-align
|
||||
return JsonVariant(_pool, reinterpret_cast<VariantData*>(data));
|
||||
return JsonVariant(_pool, reinterpret_cast<detail::VariantData*>(data));
|
||||
}
|
||||
|
||||
operator JsonObjectConst() const {
|
||||
@@ -108,19 +108,21 @@ class JsonObject : public VariantOperators<JsonObject> {
|
||||
// Gets or sets the member with specified key.
|
||||
// https://arduinojson.org/v6/api/jsonobject/subscript/
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename enable_if<IsString<TString>::value,
|
||||
MemberProxy<JsonObject, TString> >::type
|
||||
operator[](const TString& key) const {
|
||||
return MemberProxy<JsonObject, TString>(*this, key);
|
||||
FORCE_INLINE
|
||||
typename detail::enable_if<detail::IsString<TString>::value,
|
||||
detail::MemberProxy<JsonObject, TString>>::type
|
||||
operator[](const TString& key) const {
|
||||
return {*this, key};
|
||||
}
|
||||
|
||||
// Gets or sets the member with specified key.
|
||||
// https://arduinojson.org/v6/api/jsonobject/subscript/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE typename enable_if<IsString<TChar*>::value,
|
||||
MemberProxy<JsonObject, TChar*> >::type
|
||||
operator[](TChar* key) const {
|
||||
return MemberProxy<JsonObject, TChar*>(*this, key);
|
||||
FORCE_INLINE
|
||||
typename detail::enable_if<detail::IsString<TChar*>::value,
|
||||
detail::MemberProxy<JsonObject, TChar*>>::type
|
||||
operator[](TChar* key) const {
|
||||
return {*this, key};
|
||||
}
|
||||
|
||||
// Removes the member at the specified iterator.
|
||||
@@ -137,7 +139,7 @@ class JsonObject : public VariantOperators<JsonObject> {
|
||||
// https://arduinojson.org/v6/api/jsonobject/remove/
|
||||
template <typename TString>
|
||||
FORCE_INLINE void remove(const TString& key) const {
|
||||
removeMember(adaptString(key));
|
||||
removeMember(detail::adaptString(key));
|
||||
}
|
||||
|
||||
// Removes the member with the specified key.
|
||||
@@ -145,23 +147,25 @@ class JsonObject : public VariantOperators<JsonObject> {
|
||||
// https://arduinojson.org/v6/api/jsonobject/remove/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE void remove(TChar* key) const {
|
||||
removeMember(adaptString(key));
|
||||
removeMember(detail::adaptString(key));
|
||||
}
|
||||
|
||||
// Returns true if the object contains the specified key.
|
||||
// https://arduinojson.org/v6/api/jsonobject/containskey/
|
||||
template <typename TString>
|
||||
FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type
|
||||
containsKey(const TString& key) const {
|
||||
return getMember(adaptString(key)) != 0;
|
||||
FORCE_INLINE
|
||||
typename detail::enable_if<detail::IsString<TString>::value, bool>::type
|
||||
containsKey(const TString& key) const {
|
||||
return getMember(detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Returns true if the object contains the specified key.
|
||||
// https://arduinojson.org/v6/api/jsonobject/containskey/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type
|
||||
containsKey(TChar* key) const {
|
||||
return getMember(adaptString(key)) != 0;
|
||||
FORCE_INLINE
|
||||
typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type
|
||||
containsKey(TChar* key) const {
|
||||
return getMember(detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Creates an array and adds it to the object.
|
||||
@@ -189,20 +193,20 @@ class JsonObject : public VariantOperators<JsonObject> {
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryPool* getPool() const {
|
||||
detail::MemoryPool* getPool() const {
|
||||
return _pool;
|
||||
}
|
||||
|
||||
VariantData* getData() const {
|
||||
return collectionToVariant(_data);
|
||||
detail::VariantData* getData() const {
|
||||
return detail::collectionToVariant(_data);
|
||||
}
|
||||
|
||||
VariantData* getOrCreateData() const {
|
||||
return collectionToVariant(_data);
|
||||
detail::VariantData* getOrCreateData() const {
|
||||
return detail::collectionToVariant(_data);
|
||||
}
|
||||
|
||||
template <typename TAdaptedString>
|
||||
inline VariantData* getMember(TAdaptedString key) const {
|
||||
inline detail::VariantData* getMember(TAdaptedString key) const {
|
||||
if (!_data)
|
||||
return 0;
|
||||
return _data->getMember(key);
|
||||
@@ -215,23 +219,23 @@ class JsonObject : public VariantOperators<JsonObject> {
|
||||
_data->removeMember(key);
|
||||
}
|
||||
|
||||
CollectionData* _data;
|
||||
MemoryPool* _pool;
|
||||
detail::CollectionData* _data;
|
||||
detail::MemoryPool* _pool;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<JsonObject> : private VariantAttorney {
|
||||
struct Converter<JsonObject> : private detail::VariantAttorney {
|
||||
static void toJson(JsonVariantConst src, JsonVariant dst) {
|
||||
variantCopyFrom(getData(dst), getData(src), getPool(dst));
|
||||
}
|
||||
|
||||
static JsonObject fromJson(JsonVariant src) {
|
||||
VariantData* data = getData(src);
|
||||
MemoryPool* pool = getPool(src);
|
||||
auto data = getData(src);
|
||||
auto pool = getPool(src);
|
||||
return JsonObject(pool, data != 0 ? data->asObject() : 0);
|
||||
}
|
||||
|
||||
static InvalidConversion<JsonVariantConst, JsonObject> fromJson(
|
||||
static detail::InvalidConversion<JsonVariantConst, JsonObject> fromJson(
|
||||
JsonVariantConst);
|
||||
|
||||
static bool checkJson(JsonVariantConst) {
|
||||
@@ -239,8 +243,9 @@ struct Converter<JsonObject> : private VariantAttorney {
|
||||
}
|
||||
|
||||
static bool checkJson(JsonVariant src) {
|
||||
VariantData* data = getData(src);
|
||||
auto data = getData(src);
|
||||
return data && data->isObject();
|
||||
}
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,13 +7,13 @@
|
||||
#include <ArduinoJson/Object/JsonObjectIterator.hpp>
|
||||
#include <ArduinoJson/Variant/VariantOperators.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// A read-only reference to an object in a JsonDocument.
|
||||
// https://arduinojson.org/v6/api/jsonobjectconst/
|
||||
class JsonObjectConst : public VariantOperators<JsonObjectConst> {
|
||||
class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> {
|
||||
friend class JsonObject;
|
||||
friend class VariantAttorney;
|
||||
friend class detail::VariantAttorney;
|
||||
|
||||
public:
|
||||
typedef JsonObjectConstIterator iterator;
|
||||
@@ -22,7 +22,7 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> {
|
||||
JsonObjectConst() : _data(0) {}
|
||||
|
||||
// INTERNAL USE ONLY
|
||||
JsonObjectConst(const CollectionData* data) : _data(data) {}
|
||||
JsonObjectConst(const detail::CollectionData* data) : _data(data) {}
|
||||
|
||||
operator JsonVariantConst() const {
|
||||
return JsonVariantConst(collectionToVariant(_data));
|
||||
@@ -76,32 +76,32 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> {
|
||||
// https://arduinojson.org/v6/api/jsonobjectconst/containskey/
|
||||
template <typename TString>
|
||||
FORCE_INLINE bool containsKey(const TString& key) const {
|
||||
return getMember(adaptString(key)) != 0;
|
||||
return getMember(detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Returns true if the object contains the specified key.
|
||||
// https://arduinojson.org/v6/api/jsonobjectconst/containskey/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE bool containsKey(TChar* key) const {
|
||||
return getMember(adaptString(key)) != 0;
|
||||
return getMember(detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Gets the member with specified key.
|
||||
// https://arduinojson.org/v6/api/jsonobjectconst/subscript/
|
||||
template <typename TString>
|
||||
FORCE_INLINE
|
||||
typename enable_if<IsString<TString>::value, JsonVariantConst>::type
|
||||
operator[](const TString& key) const {
|
||||
return JsonVariantConst(getMember(adaptString(key)));
|
||||
FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value,
|
||||
JsonVariantConst>::type
|
||||
operator[](const TString& key) const {
|
||||
return JsonVariantConst(getMember(detail::adaptString(key)));
|
||||
}
|
||||
|
||||
// Gets the member with specified key.
|
||||
// https://arduinojson.org/v6/api/jsonobjectconst/subscript/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE
|
||||
typename enable_if<IsString<TChar*>::value, JsonVariantConst>::type
|
||||
operator[](TChar* key) const {
|
||||
return JsonVariantConst(getMember(adaptString(key)));
|
||||
FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value,
|
||||
JsonVariantConst>::type
|
||||
operator[](TChar* key) const {
|
||||
return JsonVariantConst(getMember(detail::adaptString(key)));
|
||||
}
|
||||
|
||||
// Compares objects.
|
||||
@@ -122,35 +122,35 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> {
|
||||
}
|
||||
|
||||
private:
|
||||
const VariantData* getData() const {
|
||||
const detail::VariantData* getData() const {
|
||||
return collectionToVariant(_data);
|
||||
}
|
||||
|
||||
template <typename TAdaptedString>
|
||||
const VariantData* getMember(TAdaptedString key) const {
|
||||
const detail::VariantData* getMember(TAdaptedString key) const {
|
||||
if (!_data)
|
||||
return 0;
|
||||
return _data->getMember(key);
|
||||
}
|
||||
|
||||
const CollectionData* _data;
|
||||
const detail::CollectionData* _data;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Converter<JsonObjectConst> : private VariantAttorney {
|
||||
struct Converter<JsonObjectConst> : private detail::VariantAttorney {
|
||||
static void toJson(JsonVariantConst src, JsonVariant dst) {
|
||||
variantCopyFrom(getData(dst), getData(src), getPool(dst));
|
||||
}
|
||||
|
||||
static JsonObjectConst fromJson(JsonVariantConst src) {
|
||||
const VariantData* data = getData(src);
|
||||
auto data = getData(src);
|
||||
return data != 0 ? data->asObject() : 0;
|
||||
}
|
||||
|
||||
static bool checkJson(JsonVariantConst src) {
|
||||
const VariantData* data = getData(src);
|
||||
auto data = getData(src);
|
||||
return data && data->isObject();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <ArduinoJson/Array/JsonArray.hpp>
|
||||
#include <ArduinoJson/Object/JsonObject.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
template <typename TString>
|
||||
inline JsonArray JsonObject::createNestedArray(const TString& key) const {
|
||||
@@ -19,6 +19,10 @@ inline JsonArray JsonObject::createNestedArray(TChar* key) const {
|
||||
return operator[](key).template to<JsonArray>();
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TDerived>
|
||||
template <typename TString>
|
||||
inline JsonArray VariantRefBase<TDerived>::createNestedArray(
|
||||
@@ -65,7 +69,7 @@ VariantRefBase<TDerived>::containsKey(TChar* key) const {
|
||||
template <typename TDerived>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString*>::value,
|
||||
MemberProxy<TDerived, TString*> >::type
|
||||
MemberProxy<TDerived, TString*>>::type
|
||||
VariantRefBase<TDerived>::operator[](TString* key) const {
|
||||
return MemberProxy<TDerived, TString*>(derived(), key);
|
||||
}
|
||||
@@ -73,9 +77,9 @@ VariantRefBase<TDerived>::operator[](TString* key) const {
|
||||
template <typename TDerived>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString>::value,
|
||||
MemberProxy<TDerived, TString> >::type
|
||||
MemberProxy<TDerived, TString>>::type
|
||||
VariantRefBase<TDerived>::operator[](const TString& key) const {
|
||||
return MemberProxy<TDerived, TString>(derived(), key);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -7,11 +7,12 @@
|
||||
#include <ArduinoJson/Object/JsonPair.hpp>
|
||||
#include <ArduinoJson/Variant/SlotFunctions.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
class JsonPairPtr {
|
||||
public:
|
||||
JsonPairPtr(MemoryPool* pool, VariantSlot* slot) : _pair(pool, slot) {}
|
||||
JsonPairPtr(detail::MemoryPool* pool, detail::VariantSlot* slot)
|
||||
: _pair(pool, slot) {}
|
||||
|
||||
const JsonPair* operator->() const {
|
||||
return &_pair;
|
||||
@@ -31,7 +32,8 @@ class JsonObjectIterator {
|
||||
public:
|
||||
JsonObjectIterator() : _slot(0) {}
|
||||
|
||||
explicit JsonObjectIterator(MemoryPool* pool, VariantSlot* slot)
|
||||
explicit JsonObjectIterator(detail::MemoryPool* pool,
|
||||
detail::VariantSlot* slot)
|
||||
: _pool(pool), _slot(slot) {}
|
||||
|
||||
JsonPair operator*() const {
|
||||
@@ -60,13 +62,13 @@ class JsonObjectIterator {
|
||||
}
|
||||
|
||||
private:
|
||||
MemoryPool* _pool;
|
||||
VariantSlot* _slot;
|
||||
detail::MemoryPool* _pool;
|
||||
detail::VariantSlot* _slot;
|
||||
};
|
||||
|
||||
class JsonPairConstPtr {
|
||||
public:
|
||||
JsonPairConstPtr(const VariantSlot* slot) : _pair(slot) {}
|
||||
JsonPairConstPtr(const detail::VariantSlot* slot) : _pair(slot) {}
|
||||
|
||||
const JsonPairConst* operator->() const {
|
||||
return &_pair;
|
||||
@@ -86,7 +88,8 @@ class JsonObjectConstIterator {
|
||||
public:
|
||||
JsonObjectConstIterator() : _slot(0) {}
|
||||
|
||||
explicit JsonObjectConstIterator(const VariantSlot* slot) : _slot(slot) {}
|
||||
explicit JsonObjectConstIterator(const detail::VariantSlot* slot)
|
||||
: _slot(slot) {}
|
||||
|
||||
JsonPairConst operator*() const {
|
||||
return JsonPairConst(_slot);
|
||||
@@ -114,6 +117,7 @@ class JsonObjectConstIterator {
|
||||
}
|
||||
|
||||
private:
|
||||
const VariantSlot* _slot;
|
||||
const detail::VariantSlot* _slot;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,14 +8,14 @@
|
||||
#include <ArduinoJson/Variant/JsonVariant.hpp>
|
||||
#include <ArduinoJson/Variant/JsonVariantConst.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||
|
||||
// A key-value pair.
|
||||
// https://arduinojson.org/v6/api/jsonobject/begin_end/
|
||||
class JsonPair {
|
||||
public:
|
||||
// INTERNAL USE ONLY
|
||||
JsonPair(MemoryPool* pool, VariantSlot* slot) {
|
||||
JsonPair(detail::MemoryPool* pool, detail::VariantSlot* slot) {
|
||||
if (slot) {
|
||||
_key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied
|
||||
: JsonString::Linked);
|
||||
@@ -42,7 +42,7 @@ class JsonPair {
|
||||
// https://arduinojson.org/v6/api/jsonobjectconst/begin_end/
|
||||
class JsonPairConst {
|
||||
public:
|
||||
JsonPairConst(const VariantSlot* slot) {
|
||||
JsonPairConst(const detail::VariantSlot* slot) {
|
||||
if (slot) {
|
||||
_key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied
|
||||
: JsonString::Linked);
|
||||
@@ -64,4 +64,5 @@ class JsonPairConst {
|
||||
JsonString _key;
|
||||
JsonVariantConst _value;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PUBLIC_NAMESPACE
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Variant/VariantRefBase.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A proxy class to get or set a member of an object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/subscript/
|
||||
template <typename TUpstream, typename TStringRef>
|
||||
class MemberProxy
|
||||
: public VariantRefBase<MemberProxy<TUpstream, TStringRef> >,
|
||||
public VariantOperators<MemberProxy<TUpstream, TStringRef> > {
|
||||
: public VariantRefBase<MemberProxy<TUpstream, TStringRef>>,
|
||||
public VariantOperators<MemberProxy<TUpstream, TStringRef>> {
|
||||
friend class VariantAttorney;
|
||||
|
||||
public:
|
||||
@@ -61,4 +61,4 @@ class MemberProxy
|
||||
TStringRef _key;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <ArduinoJson/Configuration.hpp>
|
||||
#include "math.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T, typename F>
|
||||
struct alias_cast_t {
|
||||
@@ -26,4 +26,5 @@ T alias_cast(F raw_data) {
|
||||
ac.raw = raw_data;
|
||||
return ac.data;
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -21,12 +21,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201103L
|
||||
# define NOEXCEPT noexcept
|
||||
#else
|
||||
# define NOEXCEPT throw()
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute)
|
||||
# if __has_attribute(no_sanitize)
|
||||
# define ARDUINOJSON_NO_SANITIZE(check) __attribute__((no_sanitize(check)))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
#ifndef isdigit
|
||||
inline bool isdigit(char c) {
|
||||
@@ -17,4 +17,5 @@ inline bool isdigit(char c) {
|
||||
inline bool issign(char c) {
|
||||
return '-' == c || c == '+';
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <int Bits>
|
||||
struct int_t;
|
||||
@@ -27,4 +27,5 @@ template <>
|
||||
struct int_t<32> {
|
||||
typedef int32_t type;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -11,7 +11,7 @@
|
||||
# pragma warning(disable : 4310)
|
||||
#endif
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// Differs from standard because we can't use the symbols "min" and "max"
|
||||
template <typename T, typename Enable = void>
|
||||
@@ -38,7 +38,7 @@ struct numeric_limits<
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// Some libraries #define isnan() and isinf() so we need to check before
|
||||
// using this name
|
||||
@@ -24,4 +24,4 @@ bool isinf(T x) {
|
||||
return x != 0.0 && x * 2 == x;
|
||||
}
|
||||
#endif
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <stddef.h> // for size_t
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A meta-function that returns the highest value
|
||||
template <size_t X, size_t Y, bool MaxIsX = (X > Y)>
|
||||
@@ -23,4 +23,5 @@ template <size_t X, size_t Y>
|
||||
struct Max<X, Y, false> {
|
||||
static const size_t value = Y;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -10,17 +10,18 @@
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
#include <ArduinoJson/Polyfills/assert.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
// Wraps a const char* so that the our functions are picked only if the
|
||||
// originals are missing
|
||||
struct pgm_p {
|
||||
pgm_p(const void* p) : address(reinterpret_cast<const char*>(p)) {}
|
||||
const char* address;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
#ifndef strlen_P
|
||||
inline size_t strlen_P(ARDUINOJSON_NAMESPACE::pgm_p s) {
|
||||
inline size_t strlen_P(ArduinoJson::detail::pgm_p s) {
|
||||
const char* p = s.address;
|
||||
ARDUINOJSON_ASSERT(p != NULL);
|
||||
while (pgm_read_byte(p))
|
||||
@@ -30,7 +31,7 @@ inline size_t strlen_P(ARDUINOJSON_NAMESPACE::pgm_p s) {
|
||||
#endif
|
||||
|
||||
#ifndef strncmp_P
|
||||
inline int strncmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) {
|
||||
inline int strncmp_P(const char* a, ArduinoJson::detail::pgm_p b, size_t n) {
|
||||
const char* s1 = a;
|
||||
const char* s2 = b.address;
|
||||
ARDUINOJSON_ASSERT(s1 != NULL);
|
||||
@@ -50,7 +51,7 @@ inline int strncmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) {
|
||||
#endif
|
||||
|
||||
#ifndef strcmp_P
|
||||
inline int strcmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b) {
|
||||
inline int strcmp_P(const char* a, ArduinoJson::detail::pgm_p b) {
|
||||
const char* s1 = a;
|
||||
const char* s2 = b.address;
|
||||
ARDUINOJSON_ASSERT(s1 != NULL);
|
||||
@@ -69,7 +70,7 @@ inline int strcmp_P(const char* a, ARDUINOJSON_NAMESPACE::pgm_p b) {
|
||||
#endif
|
||||
|
||||
#ifndef memcmp_P
|
||||
inline int memcmp_P(const void* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) {
|
||||
inline int memcmp_P(const void* a, ArduinoJson::detail::pgm_p b, size_t n) {
|
||||
const uint8_t* p1 = reinterpret_cast<const uint8_t*>(a);
|
||||
const char* p2 = b.address;
|
||||
ARDUINOJSON_ASSERT(p1 != NULL);
|
||||
@@ -85,7 +86,7 @@ inline int memcmp_P(const void* a, ARDUINOJSON_NAMESPACE::pgm_p b, size_t n) {
|
||||
#endif
|
||||
|
||||
#ifndef memcpy_P
|
||||
inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) {
|
||||
inline void* memcpy_P(void* dst, ArduinoJson::detail::pgm_p src, size_t n) {
|
||||
uint8_t* d = reinterpret_cast<uint8_t*>(dst);
|
||||
const char* s = src.address;
|
||||
ARDUINOJSON_ASSERT(d != NULL);
|
||||
@@ -98,15 +99,38 @@ inline void* memcpy_P(void* dst, ARDUINOJSON_NAMESPACE::pgm_p src, size_t n) {
|
||||
#endif
|
||||
|
||||
#ifndef pgm_read_dword
|
||||
inline uint32_t pgm_read_dword(ARDUINOJSON_NAMESPACE::pgm_p p) {
|
||||
inline uint32_t pgm_read_dword(ArduinoJson::detail::pgm_p p) {
|
||||
uint32_t result;
|
||||
memcpy_P(&result, p.address, 4);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef pgm_read_float
|
||||
inline float pgm_read_float(ArduinoJson::detail::pgm_p p) {
|
||||
float result;
|
||||
memcpy_P(&result, p.address, sizeof(float));
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef pgm_read_double
|
||||
# if defined(__SIZEOF_DOUBLE__) && defined(__SIZEOF_FLOAT__) && \
|
||||
__SIZEOF_DOUBLE__ == __SIZEOF_FLOAT__
|
||||
inline double pgm_read_double(ArduinoJson::detail::pgm_p p) {
|
||||
return pgm_read_float(p.address);
|
||||
}
|
||||
# else
|
||||
inline double pgm_read_double(ArduinoJson::detail::pgm_p p) {
|
||||
double result;
|
||||
memcpy_P(&result, p.address, sizeof(double));
|
||||
return result;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef pgm_read_ptr
|
||||
inline void* pgm_read_ptr(ARDUINOJSON_NAMESPACE::pgm_p p) {
|
||||
inline void* pgm_read_ptr(ArduinoJson::detail::pgm_p p) {
|
||||
void* result;
|
||||
memcpy_P(&result, p.address, sizeof(result));
|
||||
return result;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -11,13 +11,13 @@
|
||||
# include <ArduinoJson/Polyfills/type_traits.hpp>
|
||||
#endif
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
#if ARDUINOJSON_ENABLE_PROGMEM
|
||||
|
||||
# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY
|
||||
# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \
|
||||
static type const name[] PROGMEM = value;
|
||||
# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, ...) \
|
||||
static type const name[] PROGMEM = __VA_ARGS__;
|
||||
# endif
|
||||
|
||||
template <typename T>
|
||||
@@ -28,11 +28,20 @@ inline const T* pgm_read(const T* const* p) {
|
||||
inline uint32_t pgm_read(const uint32_t* p) {
|
||||
return pgm_read_dword(p);
|
||||
}
|
||||
|
||||
inline double pgm_read(const double* p) {
|
||||
return pgm_read_double(p);
|
||||
}
|
||||
|
||||
inline float pgm_read(const float* p) {
|
||||
return pgm_read_float(p);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
# ifndef ARDUINOJSON_DEFINE_PROGMEM_ARRAY
|
||||
# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value) \
|
||||
static type const name[] = value;
|
||||
# define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, ...) \
|
||||
static type const name[] = __VA_ARGS__;
|
||||
# endif
|
||||
|
||||
template <typename T>
|
||||
@@ -42,4 +51,17 @@ inline T pgm_read(const T* p) {
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
template <typename T>
|
||||
class pgm_ptr {
|
||||
public:
|
||||
explicit pgm_ptr(const T* ptr) : _ptr(ptr) {}
|
||||
|
||||
T operator[](intptr_t index) const {
|
||||
return pgm_read(_ptr + index);
|
||||
}
|
||||
|
||||
private:
|
||||
const T* _ptr;
|
||||
};
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,35 +1,31 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#define ARDUINOJSON_EXPAND6(a, b, c, d, e, f) a, b, c, d, e, f
|
||||
#define ARDUINOJSON_EXPAND9(a, b, c, d, e, f, g, h, i) a, b, c, d, e, f, g, h, i
|
||||
#define ARDUINOJSON_EXPAND18(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, \
|
||||
q, r) \
|
||||
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r
|
||||
|
||||
#define ARDUINOJSON_CONCAT_(A, B) A##B
|
||||
#define ARDUINOJSON_CONCAT2(A, B) ARDUINOJSON_CONCAT_(A, B)
|
||||
#define ARDUINOJSON_CONCAT3(A, B, C) \
|
||||
ARDUINOJSON_CONCAT2(ARDUINOJSON_CONCAT2(A, B), C)
|
||||
#define ARDUINOJSON_CONCAT4(A, B, C, D) \
|
||||
ARDUINOJSON_CONCAT2(ARDUINOJSON_CONCAT2(A, B), ARDUINOJSON_CONCAT2(C, D))
|
||||
|
||||
#define ARDUINOJSON_HEX_DIGIT_0000() 0
|
||||
#define ARDUINOJSON_HEX_DIGIT_0001() 1
|
||||
#define ARDUINOJSON_HEX_DIGIT_0010() 2
|
||||
#define ARDUINOJSON_HEX_DIGIT_0011() 3
|
||||
#define ARDUINOJSON_HEX_DIGIT_0100() 4
|
||||
#define ARDUINOJSON_HEX_DIGIT_0101() 5
|
||||
#define ARDUINOJSON_HEX_DIGIT_0110() 6
|
||||
#define ARDUINOJSON_HEX_DIGIT_0111() 7
|
||||
#define ARDUINOJSON_HEX_DIGIT_1000() 8
|
||||
#define ARDUINOJSON_HEX_DIGIT_1001() 9
|
||||
#define ARDUINOJSON_HEX_DIGIT_1010() A
|
||||
#define ARDUINOJSON_HEX_DIGIT_1011() B
|
||||
#define ARDUINOJSON_HEX_DIGIT_1100() C
|
||||
#define ARDUINOJSON_HEX_DIGIT_1101() D
|
||||
#define ARDUINOJSON_HEX_DIGIT_1110() E
|
||||
#define ARDUINOJSON_HEX_DIGIT_1111() F
|
||||
#define ARDUINOJSON_HEX_DIGIT_(A, B, C, D) ARDUINOJSON_HEX_DIGIT_##A##B##C##D()
|
||||
#define ARDUINOJSON_HEX_DIGIT(A, B, C, D) ARDUINOJSON_HEX_DIGIT_(A, B, C, D)
|
||||
#define ARDUINOJSON_BIN2ALPHA_0000() A
|
||||
#define ARDUINOJSON_BIN2ALPHA_0001() B
|
||||
#define ARDUINOJSON_BIN2ALPHA_0010() C
|
||||
#define ARDUINOJSON_BIN2ALPHA_0011() D
|
||||
#define ARDUINOJSON_BIN2ALPHA_0100() E
|
||||
#define ARDUINOJSON_BIN2ALPHA_0101() F
|
||||
#define ARDUINOJSON_BIN2ALPHA_0110() F
|
||||
#define ARDUINOJSON_BIN2ALPHA_0111() H
|
||||
#define ARDUINOJSON_BIN2ALPHA_1000() I
|
||||
#define ARDUINOJSON_BIN2ALPHA_1001() J
|
||||
#define ARDUINOJSON_BIN2ALPHA_1010() K
|
||||
#define ARDUINOJSON_BIN2ALPHA_1011() L
|
||||
#define ARDUINOJSON_BIN2ALPHA_1100() M
|
||||
#define ARDUINOJSON_BIN2ALPHA_1101() N
|
||||
#define ARDUINOJSON_BIN2ALPHA_1110() O
|
||||
#define ARDUINOJSON_BIN2ALPHA_1111() P
|
||||
#define ARDUINOJSON_BIN2ALPHA_(A, B, C, D) ARDUINOJSON_BIN2ALPHA_##A##B##C##D()
|
||||
#define ARDUINOJSON_BIN2ALPHA(A, B, C, D) ARDUINOJSON_BIN2ALPHA_(A, B, C, D)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <bool Condition, class TrueType, class FalseType>
|
||||
struct conditional {
|
||||
@@ -17,4 +17,5 @@ template <class TrueType, class FalseType>
|
||||
struct conditional<false, TrueType, FalseType> {
|
||||
typedef FalseType type;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
T declval();
|
||||
T&& declval();
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A meta-function that return the type T if Condition is true.
|
||||
template <bool Condition, typename T = void>
|
||||
@@ -16,4 +16,5 @@ template <typename T>
|
||||
struct enable_if<true, T> {
|
||||
typedef T type;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T, T v>
|
||||
struct integral_constant {
|
||||
@@ -16,4 +16,4 @@ struct integral_constant {
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
typedef integral_constant<bool, false> false_type;
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include <stddef.h> // size_t
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct is_array : false_type {};
|
||||
@@ -18,4 +18,5 @@ struct is_array<T[]> : true_type {};
|
||||
|
||||
template <typename T, size_t N>
|
||||
struct is_array<T[N]> : true_type {};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
#include "remove_reference.hpp"
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A meta-function that returns true if Derived inherits from TBase is an
|
||||
// integral type.
|
||||
@@ -18,6 +20,8 @@ class is_base_of {
|
||||
|
||||
public:
|
||||
static const bool value =
|
||||
sizeof(probe(reinterpret_cast<TDerived*>(0))) == sizeof(int);
|
||||
sizeof(probe(reinterpret_cast<typename remove_reference<TDerived>::type*>(
|
||||
0))) == sizeof(int);
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "declval.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct is_class {
|
||||
@@ -20,4 +20,4 @@ struct is_class {
|
||||
static const bool value = sizeof(probe<T>(0)) == sizeof(int);
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "integral_constant.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A meta-function that return the type T without the const modifier
|
||||
template <typename T>
|
||||
@@ -14,4 +14,5 @@ struct is_const : false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_const<const T> : true_type {};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -19,7 +19,7 @@
|
||||
#endif
|
||||
// clang-format on
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename From, typename To>
|
||||
struct is_convertible {
|
||||
@@ -33,7 +33,7 @@ struct is_convertible {
|
||||
static const bool value = sizeof(probe(_from)) == sizeof(int);
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(pop)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "is_integral.hpp"
|
||||
#include "is_same.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct is_enum {
|
||||
@@ -19,4 +19,4 @@ struct is_enum {
|
||||
!is_floating_point<T>::value;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "is_same.hpp"
|
||||
#include "remove_cv.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <class T>
|
||||
struct is_floating_point
|
||||
@@ -17,4 +17,4 @@ struct is_floating_point
|
||||
is_same<float, typename remove_cv<T>::type>::value ||
|
||||
is_same<double, typename remove_cv<T>::type>::value> {};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "is_same.hpp"
|
||||
#include "remove_cv.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// clang-format off
|
||||
template <typename T>
|
||||
@@ -23,15 +23,10 @@ struct is_integral : integral_constant<bool,
|
||||
is_same<typename remove_cv<T>::type, unsigned int>::value ||
|
||||
is_same<typename remove_cv<T>::type, signed long>::value ||
|
||||
is_same<typename remove_cv<T>::type, unsigned long>::value ||
|
||||
#if ARDUINOJSON_HAS_LONG_LONG
|
||||
is_same<typename remove_cv<T>::type, signed long long>::value ||
|
||||
is_same<typename remove_cv<T>::type, unsigned long long>::value ||
|
||||
#endif
|
||||
#if ARDUINOJSON_HAS_INT64
|
||||
is_same<typename remove_cv<T>::type, signed __int64>::value ||
|
||||
is_same<typename remove_cv<T>::type, unsigned __int64>::value ||
|
||||
#endif
|
||||
is_same<typename remove_cv<T>::type, char>::value ||
|
||||
is_same<typename remove_cv<T>::type, bool>::value> {};
|
||||
// clang-format on
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "integral_constant.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer : false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_pointer<T*> : true_type {};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "integral_constant.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A meta-function that returns true if types T and U are the same.
|
||||
template <typename T, typename U>
|
||||
@@ -14,4 +14,5 @@ struct is_same : false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct is_same<T, T> : true_type {};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,23 +8,19 @@
|
||||
#include "is_same.hpp"
|
||||
#include "remove_cv.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// clang-format off
|
||||
template <typename T>
|
||||
struct is_signed : integral_constant<bool,
|
||||
struct is_signed : integral_constant<bool,
|
||||
is_same<typename remove_cv<T>::type, char>::value ||
|
||||
is_same<typename remove_cv<T>::type, signed char>::value ||
|
||||
is_same<typename remove_cv<T>::type, signed short>::value ||
|
||||
is_same<typename remove_cv<T>::type, signed int>::value ||
|
||||
is_same<typename remove_cv<T>::type, signed long>::value ||
|
||||
#if ARDUINOJSON_HAS_LONG_LONG
|
||||
is_same<typename remove_cv<T>::type, signed long long>::value ||
|
||||
#endif
|
||||
#if ARDUINOJSON_HAS_INT64
|
||||
is_same<typename remove_cv<T>::type, signed __int64>::value ||
|
||||
#endif
|
||||
is_same<typename remove_cv<T>::type, float>::value ||
|
||||
is_same<typename remove_cv<T>::type, double>::value> {};
|
||||
// clang-format on
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "is_same.hpp"
|
||||
#include "remove_cv.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// clang-format off
|
||||
template <typename T>
|
||||
@@ -17,12 +17,8 @@ struct is_unsigned : integral_constant<bool,
|
||||
is_same<typename remove_cv<T>::type, unsigned short>::value ||
|
||||
is_same<typename remove_cv<T>::type, unsigned int>::value ||
|
||||
is_same<typename remove_cv<T>::type, unsigned long>::value ||
|
||||
#if ARDUINOJSON_HAS_INT64
|
||||
is_same<typename remove_cv<T>::type, unsigned __int64>::value ||
|
||||
#endif
|
||||
#if ARDUINOJSON_HAS_LONG_LONG
|
||||
is_same<typename remove_cv<T>::type, unsigned long long>::value ||
|
||||
#endif
|
||||
is_same<typename remove_cv<T>::type, bool>::value> {};
|
||||
// clang-format on
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "type_identity.hpp"
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct make_unsigned;
|
||||
@@ -33,17 +33,9 @@ struct make_unsigned<signed long> : type_identity<unsigned long> {};
|
||||
template <>
|
||||
struct make_unsigned<unsigned long> : type_identity<unsigned long> {};
|
||||
|
||||
#if ARDUINOJSON_HAS_LONG_LONG
|
||||
template <>
|
||||
struct make_unsigned<signed long long> : type_identity<unsigned long long> {};
|
||||
template <>
|
||||
struct make_unsigned<unsigned long long> : type_identity<unsigned long long> {};
|
||||
#endif
|
||||
|
||||
#if ARDUINOJSON_HAS_INT64
|
||||
template <>
|
||||
struct make_unsigned<signed __int64> : type_identity<unsigned __int64> {};
|
||||
template <>
|
||||
struct make_unsigned<unsigned __int64> : type_identity<unsigned __int64> {};
|
||||
#endif
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <class = void>
|
||||
struct make_void {
|
||||
typedef void type;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A meta-function that return the type T without the const modifier
|
||||
template <typename T>
|
||||
@@ -17,4 +17,5 @@ template <typename T>
|
||||
struct remove_const<const T> {
|
||||
typedef T type;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct remove_cv {
|
||||
@@ -24,4 +24,5 @@ template <typename T>
|
||||
struct remove_cv<const volatile T> {
|
||||
typedef T type;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// A meta-function that return the type T without the reference modifier.
|
||||
template <typename T>
|
||||
@@ -17,4 +17,5 @@ template <typename T>
|
||||
struct remove_reference<T&> {
|
||||
typedef T type;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "integral_constant.hpp"
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename T>
|
||||
struct type_identity {
|
||||
typedef T type;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
16
lib/ArduinoJson/src/ArduinoJson/Polyfills/utility.hpp
Normal file
16
lib/ArduinoJson/src/ArduinoJson/Polyfills/utility.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "type_traits.hpp"
|
||||
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <class T>
|
||||
T&& forward(typename remove_reference<T>::type& t) noexcept {
|
||||
return static_cast<T&&>(t);
|
||||
}
|
||||
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <typename TWriter>
|
||||
class CountingDecorator {
|
||||
@@ -30,4 +30,4 @@ class CountingDecorator {
|
||||
size_t _count;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson/Namespace.hpp>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
// The default writer is a simple wrapper for Writers that are not copiable
|
||||
template <typename TDestination, typename Enable = void>
|
||||
@@ -26,7 +26,7 @@ class Writer {
|
||||
TDestination* _dest;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
#include <ArduinoJson/Serialization/Writers/StaticStringWriter.hpp>
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// ArduinoJson - https://arduinojson.org
|
||||
// Copyright © 2014-2022, Benoit BLANCHON
|
||||
// Copyright © 2014-2023, Benoit BLANCHON
|
||||
// MIT License
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
namespace ARDUINOJSON_NAMESPACE {
|
||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||
|
||||
template <>
|
||||
class Writer< ::String, void> {
|
||||
class Writer<::String, void> {
|
||||
static const size_t bufferCapacity = ARDUINOJSON_STRING_BUFFER_SIZE;
|
||||
|
||||
public:
|
||||
@@ -50,4 +50,4 @@ class Writer< ::String, void> {
|
||||
size_t _size;
|
||||
};
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user