From 4fc26dbb44061b0b0a79b2824fd0972914bdb072 Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 19 Oct 2020 23:15:16 +0200 Subject: [PATCH] upgrade arduinojson to 6.17.0 --- lib/ArduinoJson/ArduinoJson.h | 10 +- lib/ArduinoJson/CHANGELOG.md | 14 + lib/ArduinoJson/README.md | 2 +- lib/ArduinoJson/SUPPORT.md | 27 + .../JsonConfigFile/JsonConfigFile.ino | 154 -- .../JsonFilterExample/JsonFilterExample.ino | 63 - .../JsonGeneratorExample.ino | 77 - .../JsonHttpClient/JsonHttpClient.ino | 116 -- .../JsonParserExample/JsonParserExample.ino | 80 - .../examples/JsonServer/JsonServer.ino | 110 -- .../examples/JsonUdpBeacon/JsonUdpBeacon.ino | 100 -- .../examples/MsgPackParser/MsgPackParser.ino | 75 - .../ProgmemExample/ProgmemExample.ino | 72 - .../examples/StringExample/StringExample.ino | 77 - lib/ArduinoJson/keywords.txt | 39 - lib/ArduinoJson/library.properties | 11 - lib/ArduinoJson/src/ArduinoJson.h | 34 +- lib/ArduinoJson/src/ArduinoJson.hpp | 146 +- .../src/ArduinoJson/Array/ArrayFunctions.hpp | 61 +- .../src/ArduinoJson/Array/ArrayImpl.hpp | 56 +- .../src/ArduinoJson/Array/ArrayIterator.hpp | 242 +-- .../src/ArduinoJson/Array/ArrayRef.hpp | 334 ++-- .../src/ArduinoJson/Array/ArrayShortcuts.hpp | 94 +- .../src/ArduinoJson/Array/ElementProxy.hpp | 356 ++-- .../src/ArduinoJson/Array/Utilities.hpp | 321 ++-- .../ArduinoJson/Collection/CollectionData.hpp | 176 +- .../ArduinoJson/Collection/CollectionImpl.hpp | 464 +++--- .../src/ArduinoJson/Configuration.hpp | 469 +++--- .../Deserialization/DeserializationError.hpp | 240 +-- .../ArduinoJson/Deserialization/Filter.hpp | 132 +- .../Deserialization/NestingLimit.hpp | 58 +- .../ArduinoJson/Deserialization/Reader.hpp | 112 +- .../Readers/ArduinoStreamReader.hpp | 62 +- .../Readers/ArduinoStringReader.hpp | 34 +- .../Deserialization/Readers/FlashReader.hpp | 106 +- .../Readers/IteratorReader.hpp | 86 +- .../Deserialization/Readers/RamReader.hpp | 100 +- .../Readers/StdStreamReader.hpp | 58 +- .../Deserialization/Readers/VariantReader.hpp | 68 +- .../Deserialization/deserialize.hpp | 139 +- .../Document/BasicJsonDocument.hpp | 328 ++-- .../Document/DynamicJsonDocument.hpp | 58 +- .../src/ArduinoJson/Document/JsonDocument.hpp | 661 ++++---- .../Document/StaticJsonDocument.hpp | 112 +- .../src/ArduinoJson/Json/EscapeSequence.hpp | 78 +- .../src/ArduinoJson/Json/JsonDeserializer.hpp | 1477 +++++++++-------- .../src/ArduinoJson/Json/JsonSerializer.hpp | 261 +-- .../src/ArduinoJson/Json/Latch.hpp | 110 +- .../ArduinoJson/Json/PrettyJsonSerializer.hpp | 174 +- .../src/ArduinoJson/Json/TextFormatter.hpp | 317 ++-- .../src/ArduinoJson/Json/Utf16.hpp | 134 +- lib/ArduinoJson/src/ArduinoJson/Json/Utf8.hpp | 92 +- .../src/ArduinoJson/Memory/Alignment.hpp | 120 +- .../src/ArduinoJson/Memory/MemoryPool.hpp | 412 ++--- .../src/ArduinoJson/Memory/StringSlot.hpp | 19 - .../src/ArduinoJson/Misc/SerializedValue.hpp | 136 +- .../src/ArduinoJson/Misc/Visitable.hpp | 47 +- .../MsgPack/MsgPackDeserializer.hpp | 1018 +++++++----- .../ArduinoJson/MsgPack/MsgPackSerializer.hpp | 396 ++--- .../src/ArduinoJson/MsgPack/endianess.hpp | 82 +- .../src/ArduinoJson/MsgPack/ieee754.hpp | 36 +- lib/ArduinoJson/src/ArduinoJson/Namespace.hpp | 75 +- .../src/ArduinoJson/Numbers/Float.hpp | 34 +- .../src/ArduinoJson/Numbers/FloatParts.hpp | 174 +- .../src/ArduinoJson/Numbers/FloatTraits.hpp | 382 +++-- .../src/ArduinoJson/Numbers/Integer.hpp | 64 +- .../ArduinoJson/Numbers/arithmeticCompare.hpp | 242 +-- .../src/ArduinoJson/Numbers/convertNumber.hpp | 210 +-- .../src/ArduinoJson/Numbers/parseFloat.hpp | 20 - .../src/ArduinoJson/Numbers/parseInteger.hpp | 21 - .../src/ArduinoJson/Numbers/parseNumber.hpp | 324 ++-- .../src/ArduinoJson/Object/MemberProxy.hpp | 374 ++--- .../ArduinoJson/Object/ObjectFunctions.hpp | 101 +- .../src/ArduinoJson/Object/ObjectImpl.hpp | 138 +- .../src/ArduinoJson/Object/ObjectIterator.hpp | 246 +-- .../src/ArduinoJson/Object/ObjectRef.hpp | 478 +++--- .../ArduinoJson/Object/ObjectShortcuts.hpp | 146 +- .../src/ArduinoJson/Object/Pair.hpp | 110 +- .../src/ArduinoJson/Polyfills/alias_cast.hpp | 58 +- .../src/ArduinoJson/Polyfills/assert.hpp | 28 +- .../src/ArduinoJson/Polyfills/attributes.hpp | 90 +- .../src/ArduinoJson/Polyfills/ctype.hpp | 36 +- .../ArduinoJson/Polyfills/gsl/not_null.hpp | 34 - .../src/ArduinoJson/Polyfills/limits.hpp | 90 +- .../src/ArduinoJson/Polyfills/math.hpp | 54 +- .../src/ArduinoJson/Polyfills/mpl/max.hpp | 52 +- .../src/ArduinoJson/Polyfills/pgmspace.hpp | 157 +- .../Polyfills/pgmspace_generic.hpp | 32 + .../ArduinoJson/Polyfills/preprocessor.hpp | 36 + .../src/ArduinoJson/Polyfills/safe_strcmp.hpp | 64 +- .../ArduinoJson/Polyfills/static_array.hpp | 34 + .../src/ArduinoJson/Polyfills/type_traits.hpp | 47 +- .../Polyfills/type_traits/conditional.hpp | 40 +- .../Polyfills/type_traits/declval.hpp | 28 +- .../Polyfills/type_traits/enable_if.hpp | 38 +- .../type_traits/integral_constant.hpp | 38 +- .../Polyfills/type_traits/is_array.hpp | 42 +- .../Polyfills/type_traits/is_base_of.hpp | 52 +- .../Polyfills/type_traits/is_class.hpp | 52 +- .../Polyfills/type_traits/is_const.hpp | 34 +- .../Polyfills/type_traits/is_convertible.hpp | 86 +- .../Polyfills/type_traits/is_enum.hpp | 44 +- .../type_traits/is_floating_point.hpp | 38 +- .../Polyfills/type_traits/is_integral.hpp | 66 +- .../Polyfills/type_traits/is_pointer.hpp | 16 + .../Polyfills/type_traits/is_same.hpp | 34 +- .../Polyfills/type_traits/is_signed.hpp | 86 +- .../Polyfills/type_traits/is_unsigned.hpp | 74 +- .../Polyfills/type_traits/make_unsigned.hpp | 98 +- .../Polyfills/type_traits/remove_const.hpp | 40 +- .../type_traits/remove_reference.hpp | 40 +- .../Polyfills/type_traits/type_identity.hpp | 30 +- .../src/ArduinoJson/Polyfills/utility.hpp | 56 +- .../Serialization/CountingDecorator.hpp | 33 + .../src/ArduinoJson/Serialization/Writer.hpp | 94 +- .../Writers/ArduinoStringWriter.hpp | 104 +- .../Serialization/Writers/DummyWriter.hpp | 42 +- .../Serialization/Writers/PrintWriter.hpp | 56 +- .../Writers/StaticStringWriter.hpp | 80 +- .../Serialization/Writers/StdStreamWriter.hpp | 64 +- .../Serialization/Writers/StdStringWriter.hpp | 80 +- .../src/ArduinoJson/Serialization/measure.hpp | 37 +- .../ArduinoJson/Serialization/serialize.hpp | 87 +- .../StringStorage/StringCopier.hpp | 120 +- .../ArduinoJson/StringStorage/StringMover.hpp | 84 +- .../StringStorage/StringStorage.hpp | 63 +- .../Strings/ArduinoStringAdapter.hpp | 124 +- .../Strings/ConstRamStringAdapter.hpp | 124 +- .../Strings/FlashStringAdapter.hpp | 124 +- .../Strings/FlashStringIterator.hpp | 88 +- .../src/ArduinoJson/Strings/IsString.hpp | 36 +- .../ArduinoJson/Strings/IsWriteableString.hpp | 74 +- .../ArduinoJson/Strings/RamStringAdapter.hpp | 86 +- .../Strings/SizedFlashStringAdapter.hpp | 120 +- .../Strings/SizedRamStringAdapter.hpp | 110 +- ...StringAdapter.hpp => StdStringAdapter.hpp} | 130 +- .../src/ArduinoJson/Strings/StoragePolicy.hpp | 30 +- .../src/ArduinoJson/Strings/String.hpp | 154 +- .../ArduinoJson/Strings/StringAdapters.hpp | 44 +- .../src/ArduinoJson/Variant/SlotFunctions.hpp | 120 +- .../src/ArduinoJson/Variant/VariantAs.hpp | 226 +-- .../src/ArduinoJson/Variant/VariantAsImpl.hpp | 114 +- .../ArduinoJson/Variant/VariantCompare.hpp | 498 +++--- .../ArduinoJson/Variant/VariantContent.hpp | 108 +- .../src/ArduinoJson/Variant/VariantData.hpp | 774 ++++----- .../ArduinoJson/Variant/VariantFunctions.hpp | 331 ++-- .../src/ArduinoJson/Variant/VariantImpl.hpp | 288 ++-- .../ArduinoJson/Variant/VariantOperators.hpp | 328 ++-- .../src/ArduinoJson/Variant/VariantRef.hpp | 814 ++++----- .../ArduinoJson/Variant/VariantShortcuts.hpp | 46 +- .../src/ArduinoJson/Variant/VariantSlot.hpp | 217 ++- .../src/ArduinoJson/Variant/VariantTo.hpp | 64 +- .../src/ArduinoJson/compatibility.hpp | 46 +- lib/ArduinoJson/src/ArduinoJson/version.hpp | 18 +- lib/ArduinoJson/src/CMakeLists.txt | 180 +- lib_standalone/Arduino.h | 9 +- 156 files changed, 10929 insertions(+), 11466 deletions(-) create mode 100644 lib/ArduinoJson/SUPPORT.md delete mode 100644 lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino delete mode 100644 lib/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino delete mode 100644 lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino delete mode 100644 lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino delete mode 100644 lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino delete mode 100644 lib/ArduinoJson/examples/JsonServer/JsonServer.ino delete mode 100644 lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino delete mode 100644 lib/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino delete mode 100644 lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino delete mode 100644 lib/ArduinoJson/examples/StringExample/StringExample.ino delete mode 100644 lib/ArduinoJson/keywords.txt delete mode 100644 lib/ArduinoJson/library.properties delete mode 100644 lib/ArduinoJson/src/ArduinoJson/Memory/StringSlot.hpp delete mode 100644 lib/ArduinoJson/src/ArduinoJson/Numbers/parseFloat.hpp delete mode 100644 lib/ArduinoJson/src/ArduinoJson/Numbers/parseInteger.hpp delete mode 100644 lib/ArduinoJson/src/ArduinoJson/Polyfills/gsl/not_null.hpp create mode 100644 lib/ArduinoJson/src/ArduinoJson/Polyfills/pgmspace_generic.hpp create mode 100644 lib/ArduinoJson/src/ArduinoJson/Polyfills/preprocessor.hpp create mode 100644 lib/ArduinoJson/src/ArduinoJson/Polyfills/static_array.hpp create mode 100644 lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_pointer.hpp create mode 100644 lib/ArduinoJson/src/ArduinoJson/Serialization/CountingDecorator.hpp rename lib/ArduinoJson/src/ArduinoJson/Strings/{StlStringAdapter.hpp => StdStringAdapter.hpp} (81%) diff --git a/lib/ArduinoJson/ArduinoJson.h b/lib/ArduinoJson/ArduinoJson.h index 067661c77..1606a3d6a 100644 --- a/lib/ArduinoJson/ArduinoJson.h +++ b/lib/ArduinoJson/ArduinoJson.h @@ -1,5 +1,5 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#include "src/ArduinoJson.h" +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#include "src/ArduinoJson.h" diff --git a/lib/ArduinoJson/CHANGELOG.md b/lib/ArduinoJson/CHANGELOG.md index 2fa203e8b..d140edaa2 100644 --- a/lib/ArduinoJson/CHANGELOG.md +++ b/lib/ArduinoJson/CHANGELOG.md @@ -1,6 +1,19 @@ ArduinoJson: change log ======================= +v6.17.0 (2020-10-19) +------- + +* Added a build failure when nullptr is defined as a macro (issue #1355) +* Added `JsonDocument::overflowed()` which tells if the memory pool was too small (issue #1358) +* Added `DeserializationError::EmptyInput` which tells if the input was empty +* Added `DeserializationError::f_str()` which returns a `const __FlashStringHelper*` (issue #846) +* Added `operator|(JsonVariantConst, JsonVariantConst)` +* Added filtering for MessagePack (issue #1298, PR #1394 by Luca Passarella) +* Moved float convertion tables to PROGMEM +* Fixed `JsonVariant::set((char*)0)` which returned false instead of true (issue #1368) +* Fixed error `No such file or directory #include ` (issue #1381) + v6.16.1 (2020-08-04) ------- @@ -12,6 +25,7 @@ v6.16.0 (2020-08-01) * Added comparisons (`>`, `>=`, `==`, `!=`, `<`, and `<=`) between `JsonVariant`s * Added string deduplication (issue #1303) * Added `JsonString::operator!=` +* Added wildcard key (`*`) for filters (issue #1309) * Set `ARDUINOJSON_DECODE_UNICODE` to `1` by default * Fixed `copyArray()` not working with `String`, `ElementProxy`, and `MemberProxy` * Fixed error `getOrAddElement is not a member of ElementProxy` (issue #1311) diff --git a/lib/ArduinoJson/README.md b/lib/ArduinoJson/README.md index 5ae324731..3516985e8 100644 --- a/lib/ArduinoJson/README.md +++ b/lib/ArduinoJson/README.md @@ -2,7 +2,7 @@ --- -[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.16.1)](https://www.ardu-badge.com/ArduinoJson/6.16.1) +[![arduino-library-badge](https://www.ardu-badge.com/badge/ArduinoJson.svg?version=6.17.0)](https://www.ardu-badge.com/ArduinoJson/6.17.0) [![Build Status](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/6.x?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/6.x) [![Build Status](https://travis-ci.org/bblanchon/ArduinoJson.svg?branch=6.x)](https://travis-ci.org/bblanchon/ArduinoJson) [![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/arduinojson.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:arduinojson) diff --git a/lib/ArduinoJson/SUPPORT.md b/lib/ArduinoJson/SUPPORT.md new file mode 100644 index 000000000..c47e1b1ba --- /dev/null +++ b/lib/ArduinoJson/SUPPORT.md @@ -0,0 +1,27 @@ +# ArduinoJson Support + +First off, thank you very much for using ArduinoJson. + +We'll be very happy to help you, but first please read the following. + +## Before asking for help + +1. Read the [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=support) +2. Search in the [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=support) + +If you did not find the answer, please create a [new issue on GitHub](https://github.com/bblanchon/ArduinoJson/issues/new). + +It is OK to add a comment to a currently opened issue, but please avoid adding comments to a closed issue. + +## Before hitting the Submit button + +Please provide all the relevant information: + +* Good title +* Short description of the problem +* Target platform +* Compiler model and version +* [MVCE](https://stackoverflow.com/help/mcve) +* Compiler output + +Good questions get fast answers! diff --git a/lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino b/lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino deleted file mode 100644 index e674e6652..000000000 --- a/lib/ArduinoJson/examples/JsonConfigFile/JsonConfigFile.ino +++ /dev/null @@ -1,154 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to store your project configuration in a file. -// It uses the SD library but can be easily modified for any other file-system. -// -// The file contains a JSON document with the following content: -// { -// "hostname": "examples.com", -// "port": 2731 -// } -// -// To run this program, you need an SD card connected to the SPI bus as follows: -// * MOSI <-> pin 11 -// * MISO <-> pin 12 -// * CLK <-> pin 13 -// * CS <-> pin 4 -// -// https://arduinojson.org/v6/example/config/ - -#include -#include -#include - -// Our configuration structure. -// -// Never use a JsonDocument to store the configuration! -// A JsonDocument is *not* a permanent storage; it's only a temporary storage -// used during the serialization phase. See: -// https://arduinojson.org/v6/faq/why-must-i-create-a-separate-config-object/ -struct Config { - char hostname[64]; - int port; -}; - -const char *filename = "/config.txt"; // <- SD library uses 8.3 filenames -Config config; // <- global configuration object - -// Loads the configuration from a file -void loadConfiguration(const char *filename, Config &config) { - // Open file for reading - File file = SD.open(filename); - - // Allocate a temporary JsonDocument - // Don't forget to change the capacity to match your requirements. - // Use arduinojson.org/v6/assistant to compute the capacity. - StaticJsonDocument<512> doc; - - // Deserialize the JSON document - DeserializationError error = deserializeJson(doc, file); - if (error) - Serial.println(F("Failed to read file, using default configuration")); - - // Copy values from the JsonDocument to the Config - config.port = doc["port"] | 2731; - strlcpy(config.hostname, // <- destination - doc["hostname"] | "example.com", // <- source - sizeof(config.hostname)); // <- destination's capacity - - // Close the file (Curiously, File's destructor doesn't close the file) - file.close(); -} - -// Saves the configuration to a file -void saveConfiguration(const char *filename, const Config &config) { - // Delete existing file, otherwise the configuration is appended to the file - SD.remove(filename); - - // Open file for writing - File file = SD.open(filename, FILE_WRITE); - if (!file) { - Serial.println(F("Failed to create file")); - return; - } - - // Allocate a temporary JsonDocument - // Don't forget to change the capacity to match your requirements. - // Use arduinojson.org/assistant to compute the capacity. - StaticJsonDocument<256> doc; - - // Set the values in the document - doc["hostname"] = config.hostname; - doc["port"] = config.port; - - // Serialize JSON to file - if (serializeJson(doc, file) == 0) { - Serial.println(F("Failed to write to file")); - } - - // Close the file - file.close(); -} - -// Prints the content of a file to the Serial -void printFile(const char *filename) { - // Open file for reading - File file = SD.open(filename); - if (!file) { - Serial.println(F("Failed to read file")); - return; - } - - // Extract each characters by one by one - while (file.available()) { - Serial.print((char)file.read()); - } - Serial.println(); - - // Close the file - file.close(); -} - -void setup() { - // Initialize serial port - Serial.begin(9600); - while (!Serial) continue; - - // Initialize SD library - const int chipSelect = 4; - while (!SD.begin(chipSelect)) { - Serial.println(F("Failed to initialize SD library")); - delay(1000); - } - - // Should load default config if run for the first time - Serial.println(F("Loading configuration...")); - loadConfiguration(filename, config); - - // Create configuration file - Serial.println(F("Saving configuration...")); - saveConfiguration(filename, config); - - // Dump config file - Serial.println(F("Print config file...")); - printFile(filename); -} - -void loop() { - // not used in this example -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any -// serialization or deserialization problem. -// -// The book "Mastering ArduinoJson" contains a case study of a project that has -// a complex configuration with nested members. -// Contrary to this example, the project in the book uses the SPIFFS filesystem. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino b/lib/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino deleted file mode 100644 index ad37e6b9b..000000000 --- a/lib/ArduinoJson/examples/JsonFilterExample/JsonFilterExample.ino +++ /dev/null @@ -1,63 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to use DeserializationOpion::Filter -// -// https://arduinojson.org/v6/example/filter/ - -#include - -void setup() { - // Initialize serial port - Serial.begin(9600); - while (!Serial) continue; - - // The huge input: an extract from OpenWeatherMap response - const __FlashStringHelper* input_json = F( - "{\"cod\":\"200\",\"message\":0,\"list\":[{\"dt\":1581498000,\"main\":{" - "\"temp\":3.23,\"feels_like\":-3.63,\"temp_min\":3.23,\"temp_max\":4.62," - "\"pressure\":1014,\"sea_level\":1014,\"grnd_level\":1010,\"humidity\":" - "58,\"temp_kf\":-1.39},\"weather\":[{\"id\":800,\"main\":\"Clear\"," - "\"description\":\"clear " - "sky\",\"icon\":\"01d\"}],\"clouds\":{\"all\":0},\"wind\":{\"speed\":6." - "19,\"deg\":266},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2020-02-12 " - "09:00:00\"},{\"dt\":1581508800,\"main\":{\"temp\":6.09,\"feels_like\":-" - "1.07,\"temp_min\":6.09,\"temp_max\":7.13,\"pressure\":1015,\"sea_" - "level\":1015,\"grnd_level\":1011,\"humidity\":48,\"temp_kf\":-1.04}," - "\"weather\":[{\"id\":800,\"main\":\"Clear\",\"description\":\"clear " - "sky\",\"icon\":\"01d\"}],\"clouds\":{\"all\":9},\"wind\":{\"speed\":6." - "64,\"deg\":268},\"sys\":{\"pod\":\"d\"},\"dt_txt\":\"2020-02-12 " - "12:00:00\"}],\"city\":{\"id\":2643743,\"name\":\"London\",\"coord\":{" - "\"lat\":51.5085,\"lon\":-0.1257},\"country\":\"GB\",\"population\":" - "1000000,\"timezone\":0,\"sunrise\":1581492085,\"sunset\":1581527294}}"); - - // The filter: it contains "true" for each value we want to keep - StaticJsonDocument<200> filter; - filter["list"][0]["dt"] = true; - filter["list"][0]["main"]["temp"] = true; - - // Deserialize the document - StaticJsonDocument<400> doc; - deserializeJson(doc, input_json, DeserializationOption::Filter(filter)); - - // Print the result - serializeJsonPretty(doc, Serial); -} - -void loop() { - // not used in this example -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any -// deserialization problem. -// -// The book "Mastering ArduinoJson" contains a tutorial on deserialization. -// It begins with a simple example, like the one above, and then adds more -// features like deserializing directly from a file or an HTTP request. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino b/lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino deleted file mode 100644 index e2ec4a98d..000000000 --- a/lib/ArduinoJson/examples/JsonGeneratorExample/JsonGeneratorExample.ino +++ /dev/null @@ -1,77 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to generate a JSON document with ArduinoJson. -// -// https://arduinojson.org/v6/example/generator/ - -#include - -void setup() { - // Initialize Serial port - Serial.begin(9600); - while (!Serial) continue; - - // Allocate the JSON document - // - // Inside the brackets, 200 is the RAM allocated to this document. - // Don't forget to change this value to match your requirement. - // Use arduinojson.org/v6/assistant to compute the capacity. - StaticJsonDocument<200> doc; - - // StaticJsonObject allocates memory on the stack, it can be - // replaced by DynamicJsonDocument which allocates in the heap. - // - // DynamicJsonDocument doc(200); - - // Add values in the document - // - doc["sensor"] = "gps"; - doc["time"] = 1351824120; - - // Add an array. - // - JsonArray data = doc.createNestedArray("data"); - data.add(48.756080); - data.add(2.302038); - - // Generate the minified JSON and send it to the Serial port. - // - serializeJson(doc, Serial); - // The above line prints: - // {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} - - // Start a new line - Serial.println(); - - // Generate the prettified JSON and send it to the Serial port. - // - serializeJsonPretty(doc, Serial); - // The above line prints: - // { - // "sensor": "gps", - // "time": 1351824120, - // "data": [ - // 48.756080, - // 2.302038 - // ] - // } -} - -void loop() { - // not used in this example -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any -// serialization problem. -// -// The book "Mastering ArduinoJson" contains a tutorial on serialization. -// It begins with a simple example, like the one above, and then adds more -// features like serializing directly to a file or an HTTP request. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino b/lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino deleted file mode 100644 index 9614217b3..000000000 --- a/lib/ArduinoJson/examples/JsonHttpClient/JsonHttpClient.ino +++ /dev/null @@ -1,116 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to parse a JSON document in an HTTP response. -// It uses the Ethernet library, but can be easily adapted for Wifi. -// -// It performs a GET resquest on arduinojson.org/example.json -// Here is the expected response: -// { -// "sensor": "gps", -// "time": 1351824120, -// "data": [ -// 48.756080, -// 2.302038 -// ] -// } -// -// https://arduinojson.org/v6/example/http-client/ - -#include -#include -#include - -void setup() { - // Initialize Serial port - Serial.begin(9600); - while (!Serial) continue; - - // Initialize Ethernet library - byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; - if (!Ethernet.begin(mac)) { - Serial.println(F("Failed to configure Ethernet")); - return; - } - delay(1000); - - Serial.println(F("Connecting...")); - - // Connect to HTTP server - EthernetClient client; - client.setTimeout(10000); - if (!client.connect("arduinojson.org", 80)) { - Serial.println(F("Connection failed")); - return; - } - - Serial.println(F("Connected!")); - - // Send HTTP request - client.println(F("GET /example.json HTTP/1.0")); - client.println(F("Host: arduinojson.org")); - client.println(F("Connection: close")); - if (client.println() == 0) { - Serial.println(F("Failed to send request")); - return; - } - - // Check HTTP status - char status[32] = {0}; - client.readBytesUntil('\r', status, sizeof(status)); - // It should be "HTTP/1.0 200 OK" or "HTTP/1.1 200 OK" - if (strcmp(status + 9, "200 OK") != 0) { - Serial.print(F("Unexpected response: ")); - Serial.println(status); - return; - } - - // Skip HTTP headers - char endOfHeaders[] = "\r\n\r\n"; - if (!client.find(endOfHeaders)) { - Serial.println(F("Invalid response")); - return; - } - - // Allocate the JSON document - // Use arduinojson.org/v6/assistant to compute the capacity. - const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60; - DynamicJsonDocument doc(capacity); - - // Parse JSON object - DeserializationError error = deserializeJson(doc, client); - if (error) { - Serial.print(F("deserializeJson() failed: ")); - Serial.println(error.c_str()); - return; - } - - // Extract values - Serial.println(F("Response:")); - Serial.println(doc["sensor"].as()); - Serial.println(doc["time"].as()); - Serial.println(doc["data"][0].as(), 6); - Serial.println(doc["data"][1].as(), 6); - - // Disconnect - client.stop(); -} - -void loop() { - // not used in this example -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any -// serialization problem. -// -// The book "Mastering ArduinoJson" contains a tutorial on deserialization -// showing how to parse the response from GitHub's API. In the last chapter, -// it shows how to parse the huge documents from OpenWeatherMap -// and Reddit. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino b/lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino deleted file mode 100644 index 62ff8782b..000000000 --- a/lib/ArduinoJson/examples/JsonParserExample/JsonParserExample.ino +++ /dev/null @@ -1,80 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to deserialize a JSON document with ArduinoJson. -// -// https://arduinojson.org/v6/example/parser/ - -#include - -void setup() { - // Initialize serial port - Serial.begin(9600); - while (!Serial) continue; - - // Allocate the JSON document - // - // Inside the brackets, 200 is the capacity of the memory pool in bytes. - // Don't forget to change this value to match your JSON document. - // Use arduinojson.org/v6/assistant to compute the capacity. - StaticJsonDocument<200> doc; - - // StaticJsonDocument allocates memory on the stack, it can be - // replaced by DynamicJsonDocument which allocates in the heap. - // - // DynamicJsonDocument doc(200); - - // JSON input string. - // - // Using a char[], as shown here, enables the "zero-copy" mode. This mode uses - // the minimal amount of memory because the JsonDocument stores pointers to - // the input buffer. - // If you use another type of input, ArduinoJson must copy the strings from - // the input to the JsonDocument, so you need to increase the capacity of the - // JsonDocument. - char json[] = - "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; - - // Deserialize the JSON document - DeserializationError error = deserializeJson(doc, json); - - // Test if parsing succeeds. - if (error) { - Serial.print(F("deserializeJson() failed: ")); - Serial.println(error.c_str()); - return; - } - - // Fetch values. - // - // Most of the time, you can rely on the implicit casts. - // In other case, you can do doc["time"].as(); - const char* sensor = doc["sensor"]; - long time = doc["time"]; - double latitude = doc["data"][0]; - double longitude = doc["data"][1]; - - // Print values. - Serial.println(sensor); - Serial.println(time); - Serial.println(latitude, 6); - Serial.println(longitude, 6); -} - -void loop() { - // not used in this example -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any -// deserialization problem. -// -// The book "Mastering ArduinoJson" contains a tutorial on deserialization. -// It begins with a simple example, like the one above, and then adds more -// features like deserializing directly from a file or an HTTP request. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/JsonServer/JsonServer.ino b/lib/ArduinoJson/examples/JsonServer/JsonServer.ino deleted file mode 100644 index e0eea3fc6..000000000 --- a/lib/ArduinoJson/examples/JsonServer/JsonServer.ino +++ /dev/null @@ -1,110 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to implement an HTTP server that sends a JSON document -// in the response. -// It uses the Ethernet library but can be easily adapted for Wifi. -// -// The JSON document contains the values of the analog and digital pins. -// It looks like that: -// { -// "analog": [0, 76, 123, 158, 192, 205], -// "digital": [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0] -// } -// -// https://arduinojson.org/v6/example/http-server/ - -#include -#include -#include - -byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; -EthernetServer server(80); - -void setup() { - // Initialize serial port - Serial.begin(9600); - while (!Serial) continue; - - // Initialize Ethernet libary - if (!Ethernet.begin(mac)) { - Serial.println(F("Failed to initialize Ethernet library")); - return; - } - - // Start to listen - server.begin(); - - Serial.println(F("Server is ready.")); - Serial.print(F("Please connect to http://")); - Serial.println(Ethernet.localIP()); -} - -void loop() { - // Wait for an incomming connection - EthernetClient client = server.available(); - - // Do we have a client? - if (!client) return; - - Serial.println(F("New client")); - - // Read the request (we ignore the content in this example) - while (client.available()) client.read(); - - // Allocate a temporary JsonDocument - // Use arduinojson.org/v6/assistant to compute the capacity. - StaticJsonDocument<500> doc; - - // Create the "analog" array - JsonArray analogValues = doc.createNestedArray("analog"); - for (int pin = 0; pin < 6; pin++) { - // Read the analog input - int value = analogRead(pin); - - // Add the value at the end of the array - analogValues.add(value); - } - - // Create the "digital" array - JsonArray digitalValues = doc.createNestedArray("digital"); - for (int pin = 0; pin < 14; pin++) { - // Read the digital input - int value = digitalRead(pin); - - // Add the value at the end of the array - digitalValues.add(value); - } - - Serial.print(F("Sending: ")); - serializeJson(doc, Serial); - Serial.println(); - - // Write response headers - client.println(F("HTTP/1.0 200 OK")); - client.println(F("Content-Type: application/json")); - client.println(F("Connection: close")); - client.print(F("Content-Length: ")); - client.println(measureJsonPretty(doc)); - client.println(); - - // Write JSON document - serializeJsonPretty(doc, client); - - // Disconnect - client.stop(); -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any -// serialization problem. -// -// The book "Mastering ArduinoJson" contains a tutorial on serialization. -// It begins with a simple example, then adds more features like serializing -// directly to a file or an HTTP client. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino b/lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino deleted file mode 100644 index 71fec895e..000000000 --- a/lib/ArduinoJson/examples/JsonUdpBeacon/JsonUdpBeacon.ino +++ /dev/null @@ -1,100 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to send a JSON document to a UDP socket. -// At regular interval, it sends a UDP packet that contains the status of -// analog and digital pins. -// It looks like that: -// { -// "analog": [0, 76, 123, 158, 192, 205], -// "digital": [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0] -// } -// -// If you want to test this program, you need to be able to receive the UDP -// packets. -// For example, you can run netcat on your computer -// $ ncat -ulp 8888 -// See https://nmap.org/ncat/ -// -// https://arduinojson.org/v6/example/udp-beacon/ - -#include -#include -#include - -byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; -IPAddress remoteIp(192, 168, 0, 108); // <- EDIT!!!! -unsigned short remotePort = 8888; -unsigned short localPort = 8888; -EthernetUDP udp; - -void setup() { - // Initialize serial port - Serial.begin(9600); - while (!Serial) continue; - - // Initialize Ethernet libary - if (!Ethernet.begin(mac)) { - Serial.println(F("Failed to initialize Ethernet library")); - return; - } - - // Enable UDP - udp.begin(localPort); -} - -void loop() { - // Allocate a temporary JsonDocument - // Use arduinojson.org/v6/assistant to compute the capacity. - StaticJsonDocument<500> doc; - - // Create the "analog" array - JsonArray analogValues = doc.createNestedArray("analog"); - for (int pin = 0; pin < 6; pin++) { - // Read the analog input - int value = analogRead(pin); - - // Add the value at the end of the array - analogValues.add(value); - } - - // Create the "digital" array - JsonArray digitalValues = doc.createNestedArray("digital"); - for (int pin = 0; pin < 14; pin++) { - // Read the digital input - int value = digitalRead(pin); - - // Add the value at the end of the array - digitalValues.add(value); - } - - // Log - Serial.print(F("Sending to ")); - Serial.print(remoteIp); - Serial.print(F(" on port ")); - Serial.println(remotePort); - serializeJson(doc, Serial); - - // Send UDP packet - udp.beginPacket(remoteIp, remotePort); - serializeJson(doc, udp); - udp.println(); - udp.endPacket(); - - // Wait - delay(10000); -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any -// serialization problem. -// -// The book "Mastering ArduinoJson" contains a tutorial on serialization. -// It begins with a simple example, then adds more features like serializing -// directly to a file or any stream. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino b/lib/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino deleted file mode 100644 index bae9bdae9..000000000 --- a/lib/ArduinoJson/examples/MsgPackParser/MsgPackParser.ino +++ /dev/null @@ -1,75 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows how to deserialize a MessagePack document with -// ArduinoJson. -// -// https://arduinojson.org/v6/example/msgpack-parser/ - -#include - -void setup() { - // Initialize serial port - Serial.begin(9600); - while (!Serial) continue; - - // Allocate the JSON document - // - // Inside the brackets, 200 is the capacity of the memory pool in bytes. - // Don't forget to change this value to match your JSON document. - // Use arduinojson.org/v6/assistant to compute the capacity. - StaticJsonDocument<200> doc; - - // StaticJsonObject allocates memory on the stack, it can be - // replaced by DynamicJsonObject which allocates in the heap. - // - // DynamicJsonObject doc(200); - - // MessagePack input string. - // - // Using a char[], as shown here, enables the "zero-copy" mode. This mode uses - // the minimal amount of memory because the JsonDocument stores pointers to - // the input buffer. - // If you use another type of input, ArduinoJson must copy the strings from - // the input to the JsonDocument, so you need to increase the capacity of the - // JsonDocument. - uint8_t input[] = {131, 166, 115, 101, 110, 115, 111, 114, 163, 103, 112, 115, - 164, 116, 105, 109, 101, 206, 80, 147, 50, 248, 164, 100, - 97, 116, 97, 146, 203, 64, 72, 96, 199, 58, 188, 148, - 112, 203, 64, 2, 106, 146, 230, 33, 49, 169}; - // This MessagePack document contains: - // { - // "sensor": "gps", - // "time": 1351824120, - // "data": [48.75608, 2.302038] - // } - - DeserializationError error = deserializeMsgPack(doc, input); - - // Test if parsing succeeded. - if (error) { - Serial.print("deserializeMsgPack() failed: "); - Serial.println(error.c_str()); - return; - } - - // Fetch values. - // - // Most of the time, you can rely on the implicit casts. - // In other case, you can do doc["time"].as(); - const char* sensor = doc["sensor"]; - long time = doc["time"]; - double latitude = doc["data"][0]; - double longitude = doc["data"][1]; - - // Print values. - Serial.println(sensor); - Serial.println(time); - Serial.println(latitude, 6); - Serial.println(longitude, 6); -} - -void loop() { - // not used in this example -} diff --git a/lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino b/lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino deleted file mode 100644 index 7b7f81612..000000000 --- a/lib/ArduinoJson/examples/ProgmemExample/ProgmemExample.ino +++ /dev/null @@ -1,72 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows the different ways you can use Flash strings with -// ArduinoJson. -// -// Use Flash strings sparingly, because ArduinoJson duplicates them in the -// JsonDocument. Prefer plain old char*, as they are more efficient in term of -// code size, speed, and memory usage. -// -// https://arduinojson.org/v6/example/progmem/ - -#include - -void setup() { -#ifdef PROGMEM // <- check that Flash strings are supported - - DynamicJsonDocument doc(1024); - - // You can use a Flash String as your JSON input. - // WARNING: the strings in the input will be duplicated in the JsonDocument. - deserializeJson(doc, F("{\"sensor\":\"gps\",\"time\":1351824120," - "\"data\":[48.756080,2.302038]}")); - JsonObject obj = doc.as(); - - // You can use a Flash String to get an element of a JsonObject - // No duplication is done. - long time = obj[F("time")]; - - // You can use a Flash String to set an element of a JsonObject - // WARNING: the content of the Flash String will be duplicated in the - // JsonDocument. - obj[F("time")] = time; - - // You can set a Flash String to a JsonObject or JsonArray: - // WARNING: the content of the Flash String will be duplicated in the - // JsonDocument. - obj["sensor"] = F("gps"); - - // It works with serialized() too: - obj["sensor"] = serialized(F("\"gps\"")); - obj["sensor"] = serialized(F("\xA3gps"), 3); - - // You can compare the content of a JsonVariant to a Flash String - if (obj["sensor"] == F("gps")) { - // ... - } - -#else - -#warning PROGMEM is not supported on this platform - -#endif -} - -void loop() { - // not used in this example -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any memory -// problem. -// -// The book "Mastering ArduinoJson" contains a quick C++ course that explains -// how your microcontroller stores strings in memory. It also tells why you -// should not abuse Flash strings with ArduinoJson. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/examples/StringExample/StringExample.ino b/lib/ArduinoJson/examples/StringExample/StringExample.ino deleted file mode 100644 index 9fb443aed..000000000 --- a/lib/ArduinoJson/examples/StringExample/StringExample.ino +++ /dev/null @@ -1,77 +0,0 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License -// -// This example shows the different ways you can use String with ArduinoJson. -// -// Use String objects sparingly, because ArduinoJson duplicates them in the -// JsonDocument. Prefer plain old char[], as they are more efficient in term of -// code size, speed, and memory usage. -// -// https://arduinojson.org/v6/example/string/ - -#include - -void setup() { - DynamicJsonDocument doc(1024); - - // You can use a String as your JSON input. - // WARNING: the string in the input will be duplicated in the JsonDocument. - String input = - "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; - deserializeJson(doc, input); - JsonObject obj = doc.as(); - - // You can use a String to get an element of a JsonObject - // No duplication is done. - long time = obj[String("time")]; - - // You can use a String to set an element of a JsonObject - // WARNING: the content of the String will be duplicated in the JsonDocument. - obj[String("time")] = time; - - // You can get a String from a JsonObject or JsonArray: - // No duplication is done, at least not in the JsonDocument. - String sensor = obj["sensor"]; - - // Unfortunately, the following doesn't work (issue #118): - // sensor = obj["sensor"]; // <- error "ambiguous overload for 'operator='" - // As a workaround, you need to replace by: - sensor = obj["sensor"].as(); - - // You can set a String to a JsonObject or JsonArray: - // WARNING: the content of the String will be duplicated in the JsonDocument. - obj["sensor"] = sensor; - - // It works with serialized() too: - obj["sensor"] = serialized(sensor); - - // You can also concatenate strings - // WARNING: the content of the String will be duplicated in the JsonDocument. - obj[String("sen") + "sor"] = String("gp") + "s"; - - // You can compare the content of a JsonObject with a String - if (obj["sensor"] == sensor) { - // ... - } - - // Lastly, you can print the resulting JSON to a String - String output; - serializeJson(doc, output); -} - -void loop() { - // not used in this example -} - -// See also -// -------- -// -// https://arduinojson.org/ contains the documentation for all the functions -// used above. It also includes an FAQ that will help you solve any problem. -// -// The book "Mastering ArduinoJson" contains a quick C++ course that explains -// how your microcontroller stores strings in memory. On several occasions, it -// shows how you can avoid String in your program. -// Learn more at https://arduinojson.org/book/ -// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson/keywords.txt b/lib/ArduinoJson/keywords.txt deleted file mode 100644 index a67a17f00..000000000 --- a/lib/ArduinoJson/keywords.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Macros -JSON_ARRAY_SIZE KEYWORD2 -JSON_OBJECT_SIZE KEYWORD2 -JSON_STRING_SIZE KEYWORD2 - -# Free functions -deserializeJson KEYWORD2 -deserializeMsgPack KEYWORD2 -serialized KEYWORD2 -serializeJson KEYWORD2 -serializeJsonPretty KEYWORD2 -serializeMsgPack KEYWORD2 -measureJson KEYWORD2 -measureJsonPretty KEYWORD2 -measureMsgPack KEYWORD2 - -# Methods -add KEYWORD2 -as KEYWORD2 -createNestedArray KEYWORD2 -createNestedObject KEYWORD2 -get KEYWORD2 -set KEYWORD2 -to KEYWORD2 - -# Type names -DeserializationError KEYWORD1 DATA_TYPE -DynamicJsonDocument KEYWORD1 DATA_TYPE -JsonArray KEYWORD1 DATA_TYPE -JsonArrayConst KEYWORD1 DATA_TYPE -JsonFloat KEYWORD1 DATA_TYPE -JsonInteger KEYWORD1 DATA_TYPE -JsonObject KEYWORD1 DATA_TYPE -JsonObjectConst KEYWORD1 DATA_TYPE -JsonString KEYWORD1 DATA_TYPE -JsonUInt KEYWORD1 DATA_TYPE -JsonVariant KEYWORD1 DATA_TYPE -JsonVariantConst KEYWORD1 DATA_TYPE -StaticJsonDocument KEYWORD1 DATA_TYPE diff --git a/lib/ArduinoJson/library.properties b/lib/ArduinoJson/library.properties deleted file mode 100644 index 7af2db406..000000000 --- a/lib/ArduinoJson/library.properties +++ /dev/null @@ -1,11 +0,0 @@ -name=ArduinoJson -version=6.16.1 -author=Benoit Blanchon -maintainer=Benoit Blanchon -sentence=A simple and efficient JSON library for embedded C++. -paragraph=ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ MessagePack, ✔ fixed allocation, ✔ zero-copy, ✔ streams, ✔ filtering, and more. It is the most popular Arduino library on GitHub ❤❤❤❤❤. Check out arduinojson.org for a comprehensive documentation. -category=Data Processing -url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties -architectures=* -repository=https://github.com/bblanchon/ArduinoJson.git -license=MIT diff --git a/lib/ArduinoJson/src/ArduinoJson.h b/lib/ArduinoJson/src/ArduinoJson.h index 74eadd9b3..e5aac0fed 100644 --- a/lib/ArduinoJson/src/ArduinoJson.h +++ b/lib/ArduinoJson/src/ArduinoJson.h @@ -1,17 +1,17 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#ifdef __cplusplus - -#include "ArduinoJson.hpp" - -using namespace ArduinoJson; - -#else - -#error ArduinoJson requires a C++ compiler, please change file extension to .cc or .cpp - -#endif +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#ifdef __cplusplus + +#include "ArduinoJson.hpp" + +using namespace ArduinoJson; + +#else + +#error ArduinoJson requires a C++ compiler, please change file extension to .cc or .cpp + +#endif diff --git a/lib/ArduinoJson/src/ArduinoJson.hpp b/lib/ArduinoJson/src/ArduinoJson.hpp index 040d2dbe4..a5da7a2e1 100644 --- a/lib/ArduinoJson/src/ArduinoJson.hpp +++ b/lib/ArduinoJson/src/ArduinoJson.hpp @@ -1,73 +1,73 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include "ArduinoJson/Configuration.hpp" - -#if !ARDUINOJSON_DEBUG -#ifdef __clang__ -#pragma clang system_header -#elif defined __GNUC__ -#pragma GCC system_header -#endif -#endif - -#include "ArduinoJson/Array/ArrayRef.hpp" -#include "ArduinoJson/Object/ObjectRef.hpp" -#include "ArduinoJson/Variant/VariantRef.hpp" - -#include "ArduinoJson/Document/DynamicJsonDocument.hpp" -#include "ArduinoJson/Document/StaticJsonDocument.hpp" - -#include "ArduinoJson/Array/ArrayImpl.hpp" -#include "ArduinoJson/Array/ElementProxy.hpp" -#include "ArduinoJson/Array/Utilities.hpp" -#include "ArduinoJson/Collection/CollectionImpl.hpp" -#include "ArduinoJson/Object/MemberProxy.hpp" -#include "ArduinoJson/Object/ObjectImpl.hpp" -#include "ArduinoJson/Variant/VariantAsImpl.hpp" -#include "ArduinoJson/Variant/VariantCompare.hpp" -#include "ArduinoJson/Variant/VariantImpl.hpp" - -#include "ArduinoJson/Json/JsonDeserializer.hpp" -#include "ArduinoJson/Json/JsonSerializer.hpp" -#include "ArduinoJson/Json/PrettyJsonSerializer.hpp" -#include "ArduinoJson/MsgPack/MsgPackDeserializer.hpp" -#include "ArduinoJson/MsgPack/MsgPackSerializer.hpp" - -#include "ArduinoJson/compatibility.hpp" - -namespace ArduinoJson { -typedef ARDUINOJSON_NAMESPACE::ArrayConstRef JsonArrayConst; -typedef ARDUINOJSON_NAMESPACE::ArrayRef JsonArray; -typedef ARDUINOJSON_NAMESPACE::Float JsonFloat; -typedef ARDUINOJSON_NAMESPACE::Integer JsonInteger; -typedef ARDUINOJSON_NAMESPACE::ObjectConstRef JsonObjectConst; -typedef ARDUINOJSON_NAMESPACE::ObjectRef JsonObject; -typedef ARDUINOJSON_NAMESPACE::Pair JsonPair; -typedef ARDUINOJSON_NAMESPACE::PairConst JsonPairConst; -typedef ARDUINOJSON_NAMESPACE::String JsonString; -typedef ARDUINOJSON_NAMESPACE::UInt JsonUInt; -typedef ARDUINOJSON_NAMESPACE::VariantConstRef JsonVariantConst; -typedef ARDUINOJSON_NAMESPACE::VariantRef JsonVariant; -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::JsonDocument; -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 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include "ArduinoJson/Configuration.hpp" + +#if !ARDUINOJSON_DEBUG +#ifdef __clang__ +#pragma clang system_header +#elif defined __GNUC__ +#pragma GCC system_header +#endif +#endif + +#include "ArduinoJson/Array/ArrayRef.hpp" +#include "ArduinoJson/Object/ObjectRef.hpp" +#include "ArduinoJson/Variant/VariantRef.hpp" + +#include "ArduinoJson/Document/DynamicJsonDocument.hpp" +#include "ArduinoJson/Document/StaticJsonDocument.hpp" + +#include "ArduinoJson/Array/ArrayImpl.hpp" +#include "ArduinoJson/Array/ElementProxy.hpp" +#include "ArduinoJson/Array/Utilities.hpp" +#include "ArduinoJson/Collection/CollectionImpl.hpp" +#include "ArduinoJson/Object/MemberProxy.hpp" +#include "ArduinoJson/Object/ObjectImpl.hpp" +#include "ArduinoJson/Variant/VariantAsImpl.hpp" +#include "ArduinoJson/Variant/VariantCompare.hpp" +#include "ArduinoJson/Variant/VariantImpl.hpp" + +#include "ArduinoJson/Json/JsonDeserializer.hpp" +#include "ArduinoJson/Json/JsonSerializer.hpp" +#include "ArduinoJson/Json/PrettyJsonSerializer.hpp" +#include "ArduinoJson/MsgPack/MsgPackDeserializer.hpp" +#include "ArduinoJson/MsgPack/MsgPackSerializer.hpp" + +#include "ArduinoJson/compatibility.hpp" + +namespace ArduinoJson { +typedef ARDUINOJSON_NAMESPACE::ArrayConstRef JsonArrayConst; +typedef ARDUINOJSON_NAMESPACE::ArrayRef JsonArray; +typedef ARDUINOJSON_NAMESPACE::Float JsonFloat; +typedef ARDUINOJSON_NAMESPACE::Integer JsonInteger; +typedef ARDUINOJSON_NAMESPACE::ObjectConstRef JsonObjectConst; +typedef ARDUINOJSON_NAMESPACE::ObjectRef JsonObject; +typedef ARDUINOJSON_NAMESPACE::Pair JsonPair; +typedef ARDUINOJSON_NAMESPACE::PairConst JsonPairConst; +typedef ARDUINOJSON_NAMESPACE::String JsonString; +typedef ARDUINOJSON_NAMESPACE::UInt JsonUInt; +typedef ARDUINOJSON_NAMESPACE::VariantConstRef JsonVariantConst; +typedef ARDUINOJSON_NAMESPACE::VariantRef JsonVariant; +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::JsonDocument; +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 diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp index c52db0ea6..517d0b89e 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayFunctions.hpp @@ -1,30 +1,31 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include - -namespace ARDUINOJSON_NAMESPACE { - -inline VariantData *arrayAdd(CollectionData *arr, MemoryPool *pool) { - return arr ? arr->addElement(pool) : 0; -} - -template -inline void arrayAccept(const CollectionData *arr, Visitor &visitor) { - if (arr) - visitor.visitArray(*arr); - else - visitor.visitNull(); -} - -inline bool arrayEquals(const CollectionData *lhs, const CollectionData *rhs) { - if (lhs == rhs) - return true; - if (!lhs || !rhs) - return false; - return lhs->equalsArray(*rhs); -} -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +inline VariantData *arrayAdd(CollectionData *arr, MemoryPool *pool) { + return arr ? arr->addElement(pool) : 0; +} + +template +inline typename TVisitor::result_type arrayAccept(const CollectionData *arr, + TVisitor &visitor) { + if (arr) + return visitor.visitArray(*arr); + else + return visitor.visitNull(); +} + +inline bool arrayEquals(const CollectionData *lhs, const CollectionData *rhs) { + if (lhs == rhs) + return true; + if (!lhs || !rhs) + return false; + return lhs->equalsArray(*rhs); +} +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp index 4c57ad8f2..21fe43bca 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayImpl.hpp @@ -1,28 +1,28 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -namespace ARDUINOJSON_NAMESPACE { - -template -inline ArrayRef ArrayShortcuts::createNestedArray() const { - return impl()->addElement().template to(); -} - -template -inline ObjectRef ArrayShortcuts::createNestedObject() const { - return impl()->addElement().template to(); -} - -template -inline ElementProxy ArrayShortcuts::operator[]( - size_t index) const { - return ElementProxy(*impl(), index); -} - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +inline ArrayRef ArrayShortcuts::createNestedArray() const { + return impl()->addElement().template to(); +} + +template +inline ObjectRef ArrayShortcuts::createNestedObject() const { + return impl()->addElement().template to(); +} + +template +inline ElementProxy ArrayShortcuts::operator[]( + size_t index) const { + return ElementProxy(*impl(), index); +} + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp index bacaaab3f..cb158d2b0 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayIterator.hpp @@ -1,121 +1,121 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -namespace ARDUINOJSON_NAMESPACE { - -class VariantPtr { - public: - VariantPtr(MemoryPool *pool, VariantData *data) : _variant(pool, data) {} - - VariantRef *operator->() { - return &_variant; - } - - VariantRef &operator*() { - return _variant; - } - - private: - VariantRef _variant; -}; - -class ArrayIterator { - public: - ArrayIterator() : _slot(0) {} - explicit ArrayIterator(MemoryPool *pool, VariantSlot *slot) - : _pool(pool), _slot(slot) {} - - VariantRef operator*() const { - return VariantRef(_pool, _slot->data()); - } - VariantPtr operator->() { - return VariantPtr(_pool, _slot->data()); - } - - bool operator==(const ArrayIterator &other) const { - return _slot == other._slot; - } - - bool operator!=(const ArrayIterator &other) const { - return _slot != other._slot; - } - - ArrayIterator &operator++() { - _slot = _slot->next(); - return *this; - } - - ArrayIterator &operator+=(size_t distance) { - _slot = _slot->next(distance); - return *this; - } - - VariantSlot *internal() { - return _slot; - } - - private: - MemoryPool *_pool; - VariantSlot *_slot; -}; - -class VariantConstPtr { - public: - VariantConstPtr(const VariantData *data) : _variant(data) {} - - VariantConstRef *operator->() { - return &_variant; - } - - VariantConstRef &operator*() { - return _variant; - } - - private: - VariantConstRef _variant; -}; - -class ArrayConstRefIterator { - public: - ArrayConstRefIterator() : _slot(0) {} - explicit ArrayConstRefIterator(const VariantSlot *slot) : _slot(slot) {} - - VariantConstRef operator*() const { - return VariantConstRef(_slot->data()); - } - VariantConstPtr operator->() { - return VariantConstPtr(_slot->data()); - } - - bool operator==(const ArrayConstRefIterator &other) const { - return _slot == other._slot; - } - - bool operator!=(const ArrayConstRefIterator &other) const { - return _slot != other._slot; - } - - ArrayConstRefIterator &operator++() { - _slot = _slot->next(); - return *this; - } - - ArrayConstRefIterator &operator+=(size_t distance) { - _slot = _slot->next(distance); - return *this; - } - - const VariantSlot *internal() { - return _slot; - } - - private: - const VariantSlot *_slot; -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +class VariantPtr { + public: + VariantPtr(MemoryPool *pool, VariantData *data) : _variant(pool, data) {} + + VariantRef *operator->() { + return &_variant; + } + + VariantRef &operator*() { + return _variant; + } + + private: + VariantRef _variant; +}; + +class ArrayIterator { + public: + ArrayIterator() : _slot(0) {} + explicit ArrayIterator(MemoryPool *pool, VariantSlot *slot) + : _pool(pool), _slot(slot) {} + + VariantRef operator*() const { + return VariantRef(_pool, _slot->data()); + } + VariantPtr operator->() { + return VariantPtr(_pool, _slot->data()); + } + + bool operator==(const ArrayIterator &other) const { + return _slot == other._slot; + } + + bool operator!=(const ArrayIterator &other) const { + return _slot != other._slot; + } + + ArrayIterator &operator++() { + _slot = _slot->next(); + return *this; + } + + ArrayIterator &operator+=(size_t distance) { + _slot = _slot->next(distance); + return *this; + } + + VariantSlot *internal() { + return _slot; + } + + private: + MemoryPool *_pool; + VariantSlot *_slot; +}; + +class VariantConstPtr { + public: + VariantConstPtr(const VariantData *data) : _variant(data) {} + + VariantConstRef *operator->() { + return &_variant; + } + + VariantConstRef &operator*() { + return _variant; + } + + private: + VariantConstRef _variant; +}; + +class ArrayConstRefIterator { + public: + ArrayConstRefIterator() : _slot(0) {} + explicit ArrayConstRefIterator(const VariantSlot *slot) : _slot(slot) {} + + VariantConstRef operator*() const { + return VariantConstRef(_slot->data()); + } + VariantConstPtr operator->() { + return VariantConstPtr(_slot->data()); + } + + bool operator==(const ArrayConstRefIterator &other) const { + return _slot == other._slot; + } + + bool operator!=(const ArrayConstRefIterator &other) const { + return _slot != other._slot; + } + + ArrayConstRefIterator &operator++() { + _slot = _slot->next(); + return *this; + } + + ArrayConstRefIterator &operator+=(size_t distance) { + _slot = _slot->next(distance); + return *this; + } + + const VariantSlot *internal() { + return _slot; + } + + private: + const VariantSlot *_slot; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp index abbee8df6..2e8e7bfda 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayRef.hpp @@ -1,167 +1,167 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include -#include - -// Returns the size (in bytes) of an array with n elements. -// Can be very handy to determine the size of a StaticMemoryPool. -#define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \ - ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot)) - -namespace ARDUINOJSON_NAMESPACE { - -class ObjectRef; -template -class ElementProxy; - -template -class ArrayRefBase { - public: - operator VariantConstRef() const { - const void* data = _data; // prevent warning cast-align - return VariantConstRef(reinterpret_cast(data)); - } - - template - FORCE_INLINE void accept(Visitor& visitor) const { - arrayAccept(_data, visitor); - } - - FORCE_INLINE bool isNull() const { - return _data == 0; - } - - FORCE_INLINE operator bool() const { - return _data != 0; - } - - FORCE_INLINE size_t memoryUsage() const { - return _data ? _data->memoryUsage() : 0; - } - - FORCE_INLINE size_t nesting() const { - return _data ? _data->nesting() : 0; - } - - FORCE_INLINE size_t size() const { - return _data ? _data->size() : 0; - } - - protected: - ArrayRefBase(TData* data) : _data(data) {} - TData* _data; -}; - -class ArrayConstRef : public ArrayRefBase, - public Visitable { - friend class ArrayRef; - typedef ArrayRefBase base_type; - - public: - typedef ArrayConstRefIterator iterator; - - FORCE_INLINE iterator begin() const { - if (!_data) - return iterator(); - return iterator(_data->head()); - } - - FORCE_INLINE iterator end() const { - return iterator(); - } - - FORCE_INLINE ArrayConstRef() : base_type(0) {} - FORCE_INLINE ArrayConstRef(const CollectionData* data) : base_type(data) {} - - FORCE_INLINE bool operator==(ArrayConstRef rhs) const { - return arrayEquals(_data, rhs._data); - } - - FORCE_INLINE VariantConstRef operator[](size_t index) const { - return getElement(index); - } - - FORCE_INLINE VariantConstRef getElement(size_t index) const { - return VariantConstRef(_data ? _data->getElement(index) : 0); - } -}; - -class ArrayRef : public ArrayRefBase, - public ArrayShortcuts, - public Visitable { - typedef ArrayRefBase base_type; - - public: - typedef ArrayIterator iterator; - - FORCE_INLINE ArrayRef() : base_type(0), _pool(0) {} - FORCE_INLINE ArrayRef(MemoryPool* pool, CollectionData* data) - : base_type(data), _pool(pool) {} - - operator VariantRef() { - void* data = _data; // prevent warning cast-align - return VariantRef(_pool, reinterpret_cast(data)); - } - - operator ArrayConstRef() const { - return ArrayConstRef(_data); - } - - VariantRef addElement() const { - return VariantRef(_pool, arrayAdd(_data, _pool)); - } - - FORCE_INLINE iterator begin() const { - if (!_data) - return iterator(); - return iterator(_pool, _data->head()); - } - - FORCE_INLINE iterator end() const { - return iterator(); - } - - // Copy a ArrayRef - FORCE_INLINE bool set(ArrayConstRef src) const { - if (!_data || !src._data) - return false; - return _data->copyFrom(*src._data, _pool); - } - - FORCE_INLINE bool operator==(ArrayRef rhs) const { - return arrayEquals(_data, rhs._data); - } - - // Internal use - FORCE_INLINE VariantRef getOrAddElement(size_t index) const { - return VariantRef(_pool, _data ? _data->getOrAddElement(index, _pool) : 0); - } - - // Gets the value at the specified index. - FORCE_INLINE VariantRef getElement(size_t index) const { - return VariantRef(_pool, _data ? _data->getElement(index) : 0); - } - - // Removes element at specified position. - FORCE_INLINE void remove(iterator it) const { - if (!_data) - return; - _data->removeSlot(it.internal()); - } - - // Removes element at specified index. - FORCE_INLINE void remove(size_t index) const { - if (!_data) - return; - _data->removeElement(index); - } - - private: - MemoryPool* _pool; -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include +#include + +// Returns the size (in bytes) of an array with n elements. +// Can be very handy to determine the size of a StaticMemoryPool. +#define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \ + ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot)) + +namespace ARDUINOJSON_NAMESPACE { + +class ObjectRef; +template +class ElementProxy; + +template +class ArrayRefBase { + public: + operator VariantConstRef() const { + const void* data = _data; // prevent warning cast-align + return VariantConstRef(reinterpret_cast(data)); + } + + template + FORCE_INLINE typename TVisitor::result_type accept(TVisitor& visitor) const { + return arrayAccept(_data, visitor); + } + + FORCE_INLINE bool isNull() const { + return _data == 0; + } + + FORCE_INLINE operator bool() const { + return _data != 0; + } + + FORCE_INLINE size_t memoryUsage() const { + return _data ? _data->memoryUsage() : 0; + } + + FORCE_INLINE size_t nesting() const { + return _data ? _data->nesting() : 0; + } + + FORCE_INLINE size_t size() const { + return _data ? _data->size() : 0; + } + + protected: + ArrayRefBase(TData* data) : _data(data) {} + TData* _data; +}; + +class ArrayConstRef : public ArrayRefBase, + public Visitable { + friend class ArrayRef; + typedef ArrayRefBase base_type; + + public: + typedef ArrayConstRefIterator iterator; + + FORCE_INLINE iterator begin() const { + if (!_data) + return iterator(); + return iterator(_data->head()); + } + + FORCE_INLINE iterator end() const { + return iterator(); + } + + FORCE_INLINE ArrayConstRef() : base_type(0) {} + FORCE_INLINE ArrayConstRef(const CollectionData* data) : base_type(data) {} + + FORCE_INLINE bool operator==(ArrayConstRef rhs) const { + return arrayEquals(_data, rhs._data); + } + + FORCE_INLINE VariantConstRef operator[](size_t index) const { + return getElement(index); + } + + FORCE_INLINE VariantConstRef getElement(size_t index) const { + return VariantConstRef(_data ? _data->getElement(index) : 0); + } +}; + +class ArrayRef : public ArrayRefBase, + public ArrayShortcuts, + public Visitable { + typedef ArrayRefBase base_type; + + public: + typedef ArrayIterator iterator; + + FORCE_INLINE ArrayRef() : base_type(0), _pool(0) {} + FORCE_INLINE ArrayRef(MemoryPool* pool, CollectionData* data) + : base_type(data), _pool(pool) {} + + operator VariantRef() { + void* data = _data; // prevent warning cast-align + return VariantRef(_pool, reinterpret_cast(data)); + } + + operator ArrayConstRef() const { + return ArrayConstRef(_data); + } + + VariantRef addElement() const { + return VariantRef(_pool, arrayAdd(_data, _pool)); + } + + FORCE_INLINE iterator begin() const { + if (!_data) + return iterator(); + return iterator(_pool, _data->head()); + } + + FORCE_INLINE iterator end() const { + return iterator(); + } + + // Copy a ArrayRef + FORCE_INLINE bool set(ArrayConstRef src) const { + if (!_data || !src._data) + return false; + return _data->copyFrom(*src._data, _pool); + } + + FORCE_INLINE bool operator==(ArrayRef rhs) const { + return arrayEquals(_data, rhs._data); + } + + // Internal use + FORCE_INLINE VariantRef getOrAddElement(size_t index) const { + return VariantRef(_pool, _data ? _data->getOrAddElement(index, _pool) : 0); + } + + // Gets the value at the specified index. + FORCE_INLINE VariantRef getElement(size_t index) const { + return VariantRef(_pool, _data ? _data->getElement(index) : 0); + } + + // Removes element at specified position. + FORCE_INLINE void remove(iterator it) const { + if (!_data) + return; + _data->removeSlot(it.internal()); + } + + // Removes element at specified index. + FORCE_INLINE void remove(size_t index) const { + if (!_data) + return; + _data->removeElement(index); + } + + private: + MemoryPool* _pool; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp index 564197421..6f1021cd2 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ArrayShortcuts.hpp @@ -1,47 +1,47 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -namespace ARDUINOJSON_NAMESPACE { -// Forward declarations. -template -class ElementProxy; - -template -class ArrayShortcuts { - public: - // Returns the element at specified index if the variant is an array. - FORCE_INLINE ElementProxy operator[](size_t index) const; - - FORCE_INLINE ObjectRef createNestedObject() const; - - FORCE_INLINE ArrayRef createNestedArray() const; - - // Adds the specified value at the end of the array. - // - // bool add(TValue); - // TValue = bool, long, int, short, float, double, serialized, VariantRef, - // std::string, String, ObjectRef - template - FORCE_INLINE bool add(const T &value) const { - return impl()->addElement().set(value); - } - // - // bool add(TValue); - // TValue = char*, const char*, const __FlashStringHelper* - template - FORCE_INLINE bool add(T *value) const { - return impl()->addElement().set(value); - } - - private: - const TArray *impl() const { - return static_cast(this); - } -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { +// Forward declarations. +template +class ElementProxy; + +template +class ArrayShortcuts { + public: + // Returns the element at specified index if the variant is an array. + FORCE_INLINE ElementProxy operator[](size_t index) const; + + FORCE_INLINE ObjectRef createNestedObject() const; + + FORCE_INLINE ArrayRef createNestedArray() const; + + // Adds the specified value at the end of the array. + // + // bool add(TValue); + // TValue = bool, long, int, short, float, double, serialized, VariantRef, + // std::string, String, ObjectRef + template + FORCE_INLINE bool add(const T &value) const { + return impl()->addElement().set(value); + } + // + // bool add(TValue); + // TValue = char*, const char*, const __FlashStringHelper* + template + FORCE_INLINE bool add(T *value) const { + return impl()->addElement().set(value); + } + + private: + const TArray *impl() const { + return static_cast(this); + } +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp index 4de117f2b..6d47ef371 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/ElementProxy.hpp @@ -1,178 +1,178 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include -#include -#include - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4522) -#endif - -namespace ARDUINOJSON_NAMESPACE { - -template -class ElementProxy : public VariantOperators >, - public VariantShortcuts >, - public Visitable { - typedef ElementProxy this_type; - - public: - FORCE_INLINE ElementProxy(TArray array, size_t index) - : _array(array), _index(index) {} - - FORCE_INLINE ElementProxy(const ElementProxy& src) - : _array(src._array), _index(src._index) {} - - FORCE_INLINE this_type& operator=(const this_type& src) { - getOrAddUpstreamElement().set(src.as()); - return *this; - } - - // Replaces the value - // - // operator=(const TValue&) - // TValue = bool, long, int, short, float, double, serialized, VariantRef, - // std::string, String, ArrayRef, ObjectRef - template - FORCE_INLINE this_type& operator=(const T& src) { - getOrAddUpstreamElement().set(src); - return *this; - } - // - // operator=(TValue) - // TValue = char*, const char*, const __FlashStringHelper* - template - FORCE_INLINE this_type& operator=(T* src) { - getOrAddUpstreamElement().set(src); - return *this; - } - - FORCE_INLINE void clear() const { - getUpstreamElement().clear(); - } - - FORCE_INLINE bool isNull() const { - return getUpstreamElement().isNull(); - } - - template - FORCE_INLINE typename VariantAs::type as() const { - return getUpstreamElement().template as(); - } - - template - FORCE_INLINE operator T() const { - return getUpstreamElement(); - } - - template - FORCE_INLINE bool is() const { - return getUpstreamElement().template is(); - } - - template - FORCE_INLINE typename VariantTo::type to() const { - return getOrAddUpstreamElement().template to(); - } - - // Replaces the value - // - // bool set(const TValue&) - // TValue = bool, long, int, short, float, double, serialized, VariantRef, - // std::string, String, ArrayRef, ObjectRef - template - FORCE_INLINE bool set(const TValue& value) const { - return getOrAddUpstreamElement().set(value); - } - // - // bool set(TValue) - // TValue = char*, const char*, const __FlashStringHelper* - template - FORCE_INLINE bool set(TValue* value) const { - return getOrAddUpstreamElement().set(value); - } - - template - void accept(Visitor& visitor) const { - return getUpstreamElement().accept(visitor); - } - - FORCE_INLINE size_t size() const { - return getUpstreamElement().size(); - } - - template - VariantRef getMember(TNestedKey* key) const { - return getUpstreamElement().getMember(key); - } - - template - VariantRef getMember(const TNestedKey& key) const { - return getUpstreamElement().getMember(key); - } - - template - VariantRef getOrAddMember(TNestedKey* key) const { - return getOrAddUpstreamElement().getOrAddMember(key); - } - - template - VariantRef getOrAddMember(const TNestedKey& key) const { - return getOrAddUpstreamElement().getOrAddMember(key); - } - - VariantRef addElement() const { - return getOrAddUpstreamElement().addElement(); - } - - VariantRef getElement(size_t index) const { - return getOrAddUpstreamElement().getElement(index); - } - - VariantRef getOrAddElement(size_t index) const { - return getOrAddUpstreamElement().getOrAddElement(index); - } - - FORCE_INLINE void remove(size_t index) const { - getUpstreamElement().remove(index); - } - // remove(char*) const - // remove(const char*) const - // remove(const __FlashStringHelper*) const - template - FORCE_INLINE typename enable_if::value>::type remove( - TChar* key) const { - getUpstreamElement().remove(key); - } - // remove(const std::string&) const - // remove(const String&) const - template - FORCE_INLINE typename enable_if::value>::type remove( - const TString& key) const { - getUpstreamElement().remove(key); - } - - private: - FORCE_INLINE VariantRef getUpstreamElement() const { - return _array.getElement(_index); - } - - FORCE_INLINE VariantRef getOrAddUpstreamElement() const { - return _array.getOrAddElement(_index); - } - - TArray _array; - const size_t _index; -}; - -} // namespace ARDUINOJSON_NAMESPACE - -#ifdef _MSC_VER -#pragma warning(pop) -#endif +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4522) +#endif + +namespace ARDUINOJSON_NAMESPACE { + +template +class ElementProxy : public VariantOperators >, + public VariantShortcuts >, + public Visitable { + typedef ElementProxy this_type; + + public: + FORCE_INLINE ElementProxy(TArray array, size_t index) + : _array(array), _index(index) {} + + FORCE_INLINE ElementProxy(const ElementProxy& src) + : _array(src._array), _index(src._index) {} + + FORCE_INLINE this_type& operator=(const this_type& src) { + getOrAddUpstreamElement().set(src.as()); + return *this; + } + + // Replaces the value + // + // operator=(const TValue&) + // TValue = bool, long, int, short, float, double, serialized, VariantRef, + // std::string, String, ArrayRef, ObjectRef + template + FORCE_INLINE this_type& operator=(const T& src) { + getOrAddUpstreamElement().set(src); + return *this; + } + // + // operator=(TValue) + // TValue = char*, const char*, const __FlashStringHelper* + template + FORCE_INLINE this_type& operator=(T* src) { + getOrAddUpstreamElement().set(src); + return *this; + } + + FORCE_INLINE void clear() const { + getUpstreamElement().clear(); + } + + FORCE_INLINE bool isNull() const { + return getUpstreamElement().isNull(); + } + + template + FORCE_INLINE typename VariantAs::type as() const { + return getUpstreamElement().template as(); + } + + template + FORCE_INLINE operator T() const { + return getUpstreamElement(); + } + + template + FORCE_INLINE bool is() const { + return getUpstreamElement().template is(); + } + + template + FORCE_INLINE typename VariantTo::type to() const { + return getOrAddUpstreamElement().template to(); + } + + // Replaces the value + // + // bool set(const TValue&) + // TValue = bool, long, int, short, float, double, serialized, VariantRef, + // std::string, String, ArrayRef, ObjectRef + template + FORCE_INLINE bool set(const TValue& value) const { + return getOrAddUpstreamElement().set(value); + } + // + // bool set(TValue) + // TValue = char*, const char*, const __FlashStringHelper* + template + FORCE_INLINE bool set(TValue* value) const { + return getOrAddUpstreamElement().set(value); + } + + template + typename TVisitor::result_type accept(TVisitor& visitor) const { + return getUpstreamElement().accept(visitor); + } + + FORCE_INLINE size_t size() const { + return getUpstreamElement().size(); + } + + template + VariantRef getMember(TNestedKey* key) const { + return getUpstreamElement().getMember(key); + } + + template + VariantRef getMember(const TNestedKey& key) const { + return getUpstreamElement().getMember(key); + } + + template + VariantRef getOrAddMember(TNestedKey* key) const { + return getOrAddUpstreamElement().getOrAddMember(key); + } + + template + VariantRef getOrAddMember(const TNestedKey& key) const { + return getOrAddUpstreamElement().getOrAddMember(key); + } + + VariantRef addElement() const { + return getOrAddUpstreamElement().addElement(); + } + + VariantRef getElement(size_t index) const { + return getOrAddUpstreamElement().getElement(index); + } + + VariantRef getOrAddElement(size_t index) const { + return getOrAddUpstreamElement().getOrAddElement(index); + } + + FORCE_INLINE void remove(size_t index) const { + getUpstreamElement().remove(index); + } + // remove(char*) const + // remove(const char*) const + // remove(const __FlashStringHelper*) const + template + FORCE_INLINE typename enable_if::value>::type remove( + TChar* key) const { + getUpstreamElement().remove(key); + } + // remove(const std::string&) const + // remove(const String&) const + template + FORCE_INLINE typename enable_if::value>::type remove( + const TString& key) const { + getUpstreamElement().remove(key); + } + + private: + FORCE_INLINE VariantRef getUpstreamElement() const { + return _array.getElement(_index); + } + + FORCE_INLINE VariantRef getOrAddUpstreamElement() const { + return _array.getOrAddElement(_index); + } + + TArray _array; + const size_t _index; +}; + +} // namespace ARDUINOJSON_NAMESPACE + +#ifdef _MSC_VER +#pragma warning(pop) +#endif diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp index 07ebf9b55..cd84eb808 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/Utilities.hpp @@ -1,150 +1,171 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -namespace ARDUINOJSON_NAMESPACE { - -// Copy a 1D array to a JsonArray -template -inline typename enable_if::value && - !is_base_of::value, - bool>::type -copyArray(T (&src)[N], const TDestination& dst) { - return copyArray(src, N, dst); -} - -// Copy a 1D array to a JsonDocument -template -inline bool copyArray(T (&src)[N], JsonDocument& dst) { - return copyArray(src, dst.to()); -} - -// Copy a 1D array to a JsonArray -template -inline typename enable_if::value && - !is_base_of::value, - bool>::type -copyArray(T* src, size_t len, const TDestination& dst) { - bool ok = true; - for (size_t i = 0; i < len; i++) { - ok &= dst.add(src[i]); - } - return ok; -} - -// Copy a 1D array to a JsonDocument -template -inline bool copyArray(T* src, size_t len, JsonDocument& dst) { - return copyArray(src, len, dst.to()); -} - -// Copy a 2D array to a JsonArray -template -inline typename enable_if::value, - bool>::type -copyArray(T (&src)[N1][N2], const TDestination& dst) { - bool ok = true; - for (size_t i = 0; i < N1; i++) { - ArrayRef nestedArray = dst.createNestedArray(); - for (size_t j = 0; j < N2; j++) { - ok &= nestedArray.add(src[i][j]); - } - } - return ok; -} - -// Copy a 2D array to a JsonDocument -template -inline bool copyArray(T (&src)[N1][N2], JsonDocument& dst) { - return copyArray(src, dst.to()); -} - -template -class ArrayCopier1D { - public: - ArrayCopier1D(T* destination, size_t capacity) - : _destination(destination), _capacity(capacity), _size(0) {} - - void visitArray(const CollectionData& array) { - VariantSlot* slot = array.head(); - - while (slot != 0 && _size < _capacity) { - _destination[_size++] = variantAs(slot->data()); - slot = slot->next(); - } - } - void visitObject(const CollectionData&) {} - void visitFloat(Float) {} - void visitString(const char*) {} - void visitRawJson(const char*, size_t) {} - void visitNegativeInteger(UInt) {} - void visitPositiveInteger(UInt) {} - void visitBoolean(bool) {} - void visitNull() {} - - size_t result() const { - return _size; - } - - private: - T* _destination; - size_t _capacity; - size_t _size; -}; - -template -class ArrayCopier2D { - public: - ArrayCopier2D(T (*destination)[N1][N2]) : _destination(destination) {} - - void visitArray(const CollectionData& array) { - VariantSlot* slot = array.head(); - size_t n = 0; - while (slot != 0 && n < N1) { - ArrayCopier1D copier((*_destination)[n++], N2); - variantAccept(slot->data(), copier); - slot = slot->next(); - } - } - void visitObject(const CollectionData&) {} - void visitFloat(Float) {} - void visitString(const char*) {} - void visitRawJson(const char*, size_t) {} - void visitNegativeInteger(UInt) {} - void visitPositiveInteger(UInt) {} - void visitBoolean(bool) {} - void visitNull() {} - - private: - T (*_destination)[N1][N2]; - size_t _capacity1, _capacity2; -}; - -// Copy a JsonArray to a 1D array -template -inline typename enable_if::value, size_t>::type copyArray( - const TSource& src, T (&dst)[N]) { - return copyArray(src, dst, N); -} - -// Copy a JsonArray to a 1D array -template -inline size_t copyArray(const TSource& src, T* dst, size_t len) { - ArrayCopier1D copier(dst, len); - src.accept(copier); - return copier.result(); -} - -// Copy a JsonArray to a 2D array -template -inline void copyArray(const TSource& src, T (&dst)[N1][N2]) { - ArrayCopier2D copier(&dst); - src.accept(copier); -} - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +// Copy a 1D array to a JsonArray +template +inline typename enable_if::value && + !is_base_of::value, + bool>::type +copyArray(T (&src)[N], const TDestination& dst) { + return copyArray(src, N, dst); +} + +// Copy a 1D array to a JsonDocument +template +inline bool copyArray(T (&src)[N], JsonDocument& dst) { + return copyArray(src, dst.to()); +} + +// Copy a 1D array to a JsonArray +template +inline typename enable_if::value && + !is_base_of::value, + bool>::type +copyArray(T* src, size_t len, const TDestination& dst) { + bool ok = true; + for (size_t i = 0; i < len; i++) { + ok &= dst.add(src[i]); + } + return ok; +} + +// Copy a 1D array to a JsonDocument +template +inline bool copyArray(T* src, size_t len, JsonDocument& dst) { + return copyArray(src, len, dst.to()); +} + +// Copy a 2D array to a JsonArray +template +inline typename enable_if::value, + bool>::type +copyArray(T (&src)[N1][N2], const TDestination& dst) { + bool ok = true; + for (size_t i = 0; i < N1; i++) { + ArrayRef nestedArray = dst.createNestedArray(); + for (size_t j = 0; j < N2; j++) { + ok &= nestedArray.add(src[i][j]); + } + } + return ok; +} + +// Copy a 2D array to a JsonDocument +template +inline bool copyArray(T (&src)[N1][N2], JsonDocument& dst) { + return copyArray(src, dst.to()); +} + +template +class ArrayCopier1D : public Visitor { + public: + ArrayCopier1D(T* destination, size_t capacity) + : _destination(destination), _capacity(capacity) {} + + size_t visitArray(const CollectionData& array) { + size_t size = 0; + VariantSlot* slot = array.head(); + + while (slot != 0 && size < _capacity) { + _destination[size++] = variantAs(slot->data()); + slot = slot->next(); + } + return size; + } + + size_t visitObject(const CollectionData&) { + return 0; + } + + size_t visitFloat(Float) { + return 0; + } + + size_t visitString(const char*) { + return 0; + } + + size_t visitRawJson(const char*, size_t) { + return 0; + } + + size_t visitNegativeInteger(UInt) { + return 0; + } + + size_t visitPositiveInteger(UInt) { + return 0; + } + + size_t visitBoolean(bool) { + return 0; + } + + size_t visitNull() { + return 0; + } + + private: + T* _destination; + size_t _capacity; +}; + +template +class ArrayCopier2D : public Visitor { + public: + ArrayCopier2D(T (*destination)[N1][N2]) : _destination(destination) {} + + void visitArray(const CollectionData& array) { + VariantSlot* slot = array.head(); + size_t n = 0; + while (slot != 0 && n < N1) { + ArrayCopier1D copier((*_destination)[n++], N2); + variantAccept(slot->data(), copier); + slot = slot->next(); + } + } + void visitObject(const CollectionData&) {} + void visitFloat(Float) {} + void visitString(const char*) {} + void visitRawJson(const char*, size_t) {} + void visitNegativeInteger(UInt) {} + void visitPositiveInteger(UInt) {} + void visitBoolean(bool) {} + void visitNull() {} + + private: + T (*_destination)[N1][N2]; + size_t _capacity1, _capacity2; +}; + +// Copy a JsonArray to a 1D array +template +inline typename enable_if::value, size_t>::type copyArray( + const TSource& src, T (&dst)[N]) { + return copyArray(src, dst, N); +} + +// Copy a JsonArray to a 1D array +template +inline size_t copyArray(const TSource& src, T* dst, size_t len) { + ArrayCopier1D copier(dst, len); + + return src.accept(copier); +} + +// Copy a JsonArray to a 2D array +template +inline void copyArray(const TSource& src, T (&dst)[N1][N2]) { + ArrayCopier2D copier(&dst); + src.accept(copier); +} + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp index 7cb0fd1fe..13fb78b24 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionData.hpp @@ -1,88 +1,88 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -#include // size_t - -namespace ARDUINOJSON_NAMESPACE { - -class MemoryPool; -class VariantData; -class VariantSlot; - -class CollectionData { - VariantSlot *_head; - VariantSlot *_tail; - - public: - // Must be a POD! - // - no constructor - // - no destructor - // - no virtual - // - no inheritance - - // Array only - - VariantData *addElement(MemoryPool *pool); - - VariantData *getElement(size_t index) const; - - VariantData *getOrAddElement(size_t index, MemoryPool *pool); - - void removeElement(size_t index); - - bool equalsArray(const CollectionData &other) const; - - // Object only - - template - VariantData *addMember(TAdaptedString key, MemoryPool *pool); - - template - VariantData *getMember(TAdaptedString key) const; - - template - VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool); - - template - void removeMember(TAdaptedString key) { - removeSlot(getSlot(key)); - } - - template - bool containsKey(const TAdaptedString &key) const; - - bool equalsObject(const CollectionData &other) const; - - // Generic - - void clear(); - size_t memoryUsage() const; - size_t nesting() const; - size_t size() const; - - VariantSlot *addSlot(MemoryPool *); - void removeSlot(VariantSlot *slot); - - bool copyFrom(const CollectionData &src, MemoryPool *pool); - - VariantSlot *head() const { - return _head; - } - - void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance); - - private: - VariantSlot *getSlot(size_t index) const; - - template - VariantSlot *getSlot(TAdaptedString key) const; - - VariantSlot *getPreviousSlot(VariantSlot *) const; -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +#include // size_t + +namespace ARDUINOJSON_NAMESPACE { + +class MemoryPool; +class VariantData; +class VariantSlot; + +class CollectionData { + VariantSlot *_head; + VariantSlot *_tail; + + public: + // Must be a POD! + // - no constructor + // - no destructor + // - no virtual + // - no inheritance + + // Array only + + VariantData *addElement(MemoryPool *pool); + + VariantData *getElement(size_t index) const; + + VariantData *getOrAddElement(size_t index, MemoryPool *pool); + + void removeElement(size_t index); + + bool equalsArray(const CollectionData &other) const; + + // Object only + + template + VariantData *addMember(TAdaptedString key, MemoryPool *pool); + + template + VariantData *getMember(TAdaptedString key) const; + + template + VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool); + + template + void removeMember(TAdaptedString key) { + removeSlot(getSlot(key)); + } + + template + bool containsKey(const TAdaptedString &key) const; + + bool equalsObject(const CollectionData &other) const; + + // Generic + + void clear(); + size_t memoryUsage() const; + size_t nesting() const; + size_t size() const; + + VariantSlot *addSlot(MemoryPool *); + void removeSlot(VariantSlot *slot); + + bool copyFrom(const CollectionData &src, MemoryPool *pool); + + VariantSlot *head() const { + return _head; + } + + void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance); + + private: + VariantSlot *getSlot(size_t index) const; + + template + VariantSlot *getSlot(TAdaptedString key) const; + + VariantSlot *getPreviousSlot(VariantSlot *) const; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp index e81497b29..349754422 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Collection/CollectionImpl.hpp @@ -1,232 +1,232 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -namespace ARDUINOJSON_NAMESPACE { - -inline bool variantEquals(const VariantData* a, const VariantData* b) { - return variantCompare(a, b) == COMPARE_RESULT_EQUAL; -} - -inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) { - VariantSlot* slot = pool->allocVariant(); - if (!slot) - return 0; - - if (_tail) { - _tail->setNextNotNull(slot); - _tail = slot; - } else { - _head = slot; - _tail = slot; - } - - slot->clear(); - return slot; -} - -inline VariantData* CollectionData::addElement(MemoryPool* pool) { - return slotData(addSlot(pool)); -} - -template -inline VariantData* CollectionData::addMember(TAdaptedString key, - MemoryPool* pool) { - VariantSlot* slot = addSlot(pool); - if (!slotSetKey(slot, key, pool)) { - removeSlot(slot); - return 0; - } - return slot->data(); -} - -inline void CollectionData::clear() { - _head = 0; - _tail = 0; -} - -template -inline bool CollectionData::containsKey(const TAdaptedString& key) const { - return getSlot(key) != 0; -} - -inline bool CollectionData::copyFrom(const CollectionData& src, - MemoryPool* pool) { - clear(); - for (VariantSlot* s = src._head; s; s = s->next()) { - VariantData* var; - if (s->key() != 0) { - if (s->ownsKey()) - var = addMember(RamStringAdapter(s->key()), pool); - else - var = addMember(ConstRamStringAdapter(s->key()), pool); - } else { - var = addElement(pool); - } - if (!var) - return false; - if (!var->copyFrom(*s->data(), pool)) - return false; - } - return true; -} - -inline bool CollectionData::equalsObject(const CollectionData& other) const { - size_t count = 0; - for (VariantSlot* slot = _head; slot; slot = slot->next()) { - VariantData* v1 = slot->data(); - VariantData* v2 = other.getMember(adaptString(slot->key())); - if (!variantEquals(v1, v2)) - return false; - count++; - } - return count == other.size(); -} - -inline bool CollectionData::equalsArray(const CollectionData& other) const { - VariantSlot* s1 = _head; - VariantSlot* s2 = other._head; - for (;;) { - if (s1 == s2) - return true; - if (!s1 || !s2) - return false; - if (!variantEquals(s1->data(), s2->data())) - return false; - s1 = s1->next(); - s2 = s2->next(); - } -} - -template -inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { - VariantSlot* slot = _head; - while (slot) { - if (key.equals(slot->key())) - break; - slot = slot->next(); - } - return slot; -} - -inline VariantSlot* CollectionData::getSlot(size_t index) const { - return _head->next(index); -} - -inline VariantSlot* CollectionData::getPreviousSlot(VariantSlot* target) const { - VariantSlot* current = _head; - while (current) { - VariantSlot* next = current->next(); - if (next == target) - return current; - current = next; - } - return 0; -} - -template -inline VariantData* CollectionData::getMember(TAdaptedString key) const { - VariantSlot* slot = getSlot(key); - return slot ? slot->data() : 0; -} - -template -inline VariantData* CollectionData::getOrAddMember(TAdaptedString key, - MemoryPool* pool) { - // ignore null key - if (key.isNull()) - return 0; - - // search a matching key - VariantSlot* slot = getSlot(key); - if (slot) - return slot->data(); - - return addMember(key, pool); -} - -inline VariantData* CollectionData::getElement(size_t index) const { - VariantSlot* slot = getSlot(index); - return slot ? slot->data() : 0; -} - -inline VariantData* CollectionData::getOrAddElement(size_t index, - MemoryPool* pool) { - VariantSlot* slot = _head; - while (slot && index > 0) { - slot = slot->next(); - index--; - } - if (!slot) - index++; - while (index > 0) { - slot = addSlot(pool); - index--; - } - return slotData(slot); -} - -inline void CollectionData::removeSlot(VariantSlot* slot) { - if (!slot) - return; - VariantSlot* prev = getPreviousSlot(slot); - VariantSlot* next = slot->next(); - if (prev) - prev->setNext(next); - else - _head = next; - if (!next) - _tail = prev; -} - -inline void CollectionData::removeElement(size_t index) { - removeSlot(getSlot(index)); -} - -inline size_t CollectionData::memoryUsage() const { - size_t total = 0; - for (VariantSlot* s = _head; s; s = s->next()) { - total += sizeof(VariantSlot) + s->data()->memoryUsage(); - if (s->ownsKey()) - total += strlen(s->key()) + 1; - } - return total; -} - -inline size_t CollectionData::nesting() const { - size_t maxChildNesting = 0; - for (VariantSlot* s = _head; s; s = s->next()) { - size_t childNesting = s->data()->nesting(); - if (childNesting > maxChildNesting) - maxChildNesting = childNesting; - } - return maxChildNesting + 1; -} - -inline size_t CollectionData::size() const { - return slotSize(_head); -} - -template -inline void movePointer(T*& p, ptrdiff_t offset) { - if (!p) - return; - p = reinterpret_cast( - reinterpret_cast(reinterpret_cast(p) + offset)); - ARDUINOJSON_ASSERT(isAligned(p)); -} - -inline void CollectionData::movePointers(ptrdiff_t stringDistance, - ptrdiff_t variantDistance) { - movePointer(_head, variantDistance); - movePointer(_tail, variantDistance); - for (VariantSlot* slot = _head; slot; slot = slot->next()) - slot->movePointers(stringDistance, variantDistance); -} - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +inline bool variantEquals(const VariantData* a, const VariantData* b) { + return variantCompare(a, b) == COMPARE_RESULT_EQUAL; +} + +inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) { + VariantSlot* slot = pool->allocVariant(); + if (!slot) + return 0; + + if (_tail) { + _tail->setNextNotNull(slot); + _tail = slot; + } else { + _head = slot; + _tail = slot; + } + + slot->clear(); + return slot; +} + +inline VariantData* CollectionData::addElement(MemoryPool* pool) { + return slotData(addSlot(pool)); +} + +template +inline VariantData* CollectionData::addMember(TAdaptedString key, + MemoryPool* pool) { + VariantSlot* slot = addSlot(pool); + if (!slotSetKey(slot, key, pool)) { + removeSlot(slot); + return 0; + } + return slot->data(); +} + +inline void CollectionData::clear() { + _head = 0; + _tail = 0; +} + +template +inline bool CollectionData::containsKey(const TAdaptedString& key) const { + return getSlot(key) != 0; +} + +inline bool CollectionData::copyFrom(const CollectionData& src, + MemoryPool* pool) { + clear(); + for (VariantSlot* s = src._head; s; s = s->next()) { + VariantData* var; + if (s->key() != 0) { + if (s->ownsKey()) + var = addMember(RamStringAdapter(s->key()), pool); + else + var = addMember(ConstRamStringAdapter(s->key()), pool); + } else { + var = addElement(pool); + } + if (!var) + return false; + if (!var->copyFrom(*s->data(), pool)) + return false; + } + return true; +} + +inline bool CollectionData::equalsObject(const CollectionData& other) const { + size_t count = 0; + for (VariantSlot* slot = _head; slot; slot = slot->next()) { + VariantData* v1 = slot->data(); + VariantData* v2 = other.getMember(adaptString(slot->key())); + if (!variantEquals(v1, v2)) + return false; + count++; + } + return count == other.size(); +} + +inline bool CollectionData::equalsArray(const CollectionData& other) const { + VariantSlot* s1 = _head; + VariantSlot* s2 = other._head; + for (;;) { + if (s1 == s2) + return true; + if (!s1 || !s2) + return false; + if (!variantEquals(s1->data(), s2->data())) + return false; + s1 = s1->next(); + s2 = s2->next(); + } +} + +template +inline VariantSlot* CollectionData::getSlot(TAdaptedString key) const { + VariantSlot* slot = _head; + while (slot) { + if (key.equals(slot->key())) + break; + slot = slot->next(); + } + return slot; +} + +inline VariantSlot* CollectionData::getSlot(size_t index) const { + return _head->next(index); +} + +inline VariantSlot* CollectionData::getPreviousSlot(VariantSlot* target) const { + VariantSlot* current = _head; + while (current) { + VariantSlot* next = current->next(); + if (next == target) + return current; + current = next; + } + return 0; +} + +template +inline VariantData* CollectionData::getMember(TAdaptedString key) const { + VariantSlot* slot = getSlot(key); + return slot ? slot->data() : 0; +} + +template +inline VariantData* CollectionData::getOrAddMember(TAdaptedString key, + MemoryPool* pool) { + // ignore null key + if (key.isNull()) + return 0; + + // search a matching key + VariantSlot* slot = getSlot(key); + if (slot) + return slot->data(); + + return addMember(key, pool); +} + +inline VariantData* CollectionData::getElement(size_t index) const { + VariantSlot* slot = getSlot(index); + return slot ? slot->data() : 0; +} + +inline VariantData* CollectionData::getOrAddElement(size_t index, + MemoryPool* pool) { + VariantSlot* slot = _head; + while (slot && index > 0) { + slot = slot->next(); + index--; + } + if (!slot) + index++; + while (index > 0) { + slot = addSlot(pool); + index--; + } + return slotData(slot); +} + +inline void CollectionData::removeSlot(VariantSlot* slot) { + if (!slot) + return; + VariantSlot* prev = getPreviousSlot(slot); + VariantSlot* next = slot->next(); + if (prev) + prev->setNext(next); + else + _head = next; + if (!next) + _tail = prev; +} + +inline void CollectionData::removeElement(size_t index) { + removeSlot(getSlot(index)); +} + +inline size_t CollectionData::memoryUsage() const { + size_t total = 0; + for (VariantSlot* s = _head; s; s = s->next()) { + total += sizeof(VariantSlot) + s->data()->memoryUsage(); + if (s->ownsKey()) + total += strlen(s->key()) + 1; + } + return total; +} + +inline size_t CollectionData::nesting() const { + size_t maxChildNesting = 0; + for (VariantSlot* s = _head; s; s = s->next()) { + size_t childNesting = s->data()->nesting(); + if (childNesting > maxChildNesting) + maxChildNesting = childNesting; + } + return maxChildNesting + 1; +} + +inline size_t CollectionData::size() const { + return slotSize(_head); +} + +template +inline void movePointer(T*& p, ptrdiff_t offset) { + if (!p) + return; + p = reinterpret_cast( + reinterpret_cast(reinterpret_cast(p) + offset)); + ARDUINOJSON_ASSERT(isAligned(p)); +} + +inline void CollectionData::movePointers(ptrdiff_t stringDistance, + ptrdiff_t variantDistance) { + movePointer(_head, variantDistance); + movePointer(_tail, variantDistance); + for (VariantSlot* slot = _head; slot; slot = slot->next()) + slot->movePointers(stringDistance, variantDistance); +} + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp b/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp index 24e7b17da..42ba498ef 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Configuration.hpp @@ -1,232 +1,237 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#if __cplusplus >= 201103L -#define ARDUINOJSON_HAS_LONG_LONG 1 -#define ARDUINOJSON_HAS_NULLPTR 1 -#define ARDUINOJSON_HAS_RVALUE_REFERENCES 1 -#else -#define ARDUINOJSON_HAS_LONG_LONG 0 -#define ARDUINOJSON_HAS_NULLPTR 0 -#define ARDUINOJSON_HAS_RVALUE_REFERENCES 0 -#endif - -#if defined(_MSC_VER) && !ARDUINOJSON_HAS_LONG_LONG -#define ARDUINOJSON_HAS_INT64 1 -#else -#define ARDUINOJSON_HAS_INT64 0 -#endif - -// Small or big machine? -#ifndef ARDUINOJSON_EMBEDDED_MODE -#if defined(ARDUINO) /* Arduino*/ \ - || defined(__IAR_SYSTEMS_ICC__) /* IAR Embedded Workbench */ \ - || defined(__XC) /* MPLAB XC compiler */ \ - || defined(__ARMCC_VERSION) /* Keil ARM Compiler */ \ - || defined(__AVR) /* Atmel AVR8/GNU C Compiler */ -#define ARDUINOJSON_EMBEDDED_MODE 1 -#else -#define ARDUINOJSON_EMBEDDED_MODE 0 -#endif -#endif - -// Auto enable std::stream if the right headers are here and no conflicting -// macro is defined -#if !defined(ARDUINOJSON_ENABLE_STD_STREAM) && defined(__has_include) -#if __has_include() && \ - __has_include() && \ - !defined(min) && \ - !defined(max) -#define ARDUINOJSON_ENABLE_STD_STREAM 1 -#else -#define ARDUINOJSON_ENABLE_STD_STREAM 0 -#endif -#endif - -// Auto enable std::string if the right header is here and no conflicting -// macro is defined -#if !defined(ARDUINOJSON_ENABLE_STD_STRING) && defined(__has_include) -#if __has_include() && !defined(min) && !defined(max) -#define ARDUINOJSON_ENABLE_STD_STRING 1 -#else -#define ARDUINOJSON_ENABLE_STD_STRING 0 -#endif -#endif - -#if ARDUINOJSON_EMBEDDED_MODE - -// Store floats by default to reduce the memory usage (issue #134) -#ifndef ARDUINOJSON_USE_DOUBLE -#define ARDUINOJSON_USE_DOUBLE 0 -#endif - -// Store longs by default, because they usually match the size of a float. -#ifndef ARDUINOJSON_USE_LONG_LONG -#define ARDUINOJSON_USE_LONG_LONG 0 -#endif - -// Embedded systems usually don't have std::string -#ifndef ARDUINOJSON_ENABLE_STD_STRING -#define ARDUINOJSON_ENABLE_STD_STRING 0 -#endif - -// Embedded systems usually don't have std::stream -#ifndef ARDUINOJSON_ENABLE_STD_STREAM -#define ARDUINOJSON_ENABLE_STD_STREAM 0 -#endif - -// Limit nesting as the stack is likely to be small -#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT -#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 -#endif - -#else // ARDUINOJSON_EMBEDDED_MODE - -// On a computer we have plenty of memory so we can use doubles -#ifndef ARDUINOJSON_USE_DOUBLE -#define ARDUINOJSON_USE_DOUBLE 1 -#endif - -// Use long long when available -#ifndef ARDUINOJSON_USE_LONG_LONG -#if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64 -#define ARDUINOJSON_USE_LONG_LONG 1 -#else -#define ARDUINOJSON_USE_LONG_LONG 0 -#endif -#endif - -// On a computer, we can use std::string -#ifndef ARDUINOJSON_ENABLE_STD_STRING -#define ARDUINOJSON_ENABLE_STD_STRING 1 -#endif - -// On a computer, we can assume std::stream -#ifndef ARDUINOJSON_ENABLE_STD_STREAM -#define ARDUINOJSON_ENABLE_STD_STREAM 1 -#endif - -// On a computer, the stack is large so we can increase nesting limit -#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT -#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 -#endif - -#endif // ARDUINOJSON_EMBEDDED_MODE - -#ifdef ARDUINO - -#include - -// Enable support for Arduino's String class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING -#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 -#endif - -// Enable support for Arduino's Stream class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM -#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1 -#endif - -// Enable support for Arduino's Print class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT -#define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1 -#endif - -#else // ARDUINO - -// Disable support for Arduino's String class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING -#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 -#endif - -// Disable support for Arduino's Stream class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM -#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 -#endif - -// Disable support for Arduino's Print class -#ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT -#define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 -#endif - -#endif // ARDUINO - -#ifndef ARDUINOJSON_ENABLE_PROGMEM -#ifdef PROGMEM -#define ARDUINOJSON_ENABLE_PROGMEM 1 -#else -#define ARDUINOJSON_ENABLE_PROGMEM 0 -#endif -#endif - -// Convert unicode escape sequence (\u0123) to UTF-8 -#ifndef ARDUINOJSON_DECODE_UNICODE -#define ARDUINOJSON_DECODE_UNICODE 1 -#endif - -// Ignore comments in input -#ifndef ARDUINOJSON_ENABLE_COMMENTS -#define ARDUINOJSON_ENABLE_COMMENTS 0 -#endif - -// Support NaN in JSON -#ifndef ARDUINOJSON_ENABLE_NAN -#define ARDUINOJSON_ENABLE_NAN 0 -#endif - -// Support Infinity in JSON -#ifndef ARDUINOJSON_ENABLE_INFINITY -#define ARDUINOJSON_ENABLE_INFINITY 0 -#endif - -// Control the exponentiation threshold for big numbers -// CAUTION: cannot be more that 1e9 !!!! -#ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD -#define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7 -#endif - -// Control the exponentiation threshold for small numbers -#ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD -#define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5 -#endif - -#ifndef ARDUINOJSON_LITTLE_ENDIAN -#if defined(_MSC_VER) || \ - (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ - defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(__x86_64) -#define ARDUINOJSON_LITTLE_ENDIAN 1 -#else -#define ARDUINOJSON_LITTLE_ENDIAN 0 -#endif -#endif - -#ifndef ARDUINOJSON_ENABLE_ALIGNMENT -#if defined(__AVR) -#define ARDUINOJSON_ENABLE_ALIGNMENT 0 -#else -#define ARDUINOJSON_ENABLE_ALIGNMENT 1 -#endif -#endif - -#ifndef ARDUINOJSON_TAB -#define ARDUINOJSON_TAB " " -#endif - -#ifndef ARDUINOJSON_ENABLE_STRING_DEDUPLICATION -#define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 -#endif - -#ifndef ARDUINOJSON_STRING_BUFFER_SIZE -#define ARDUINOJSON_STRING_BUFFER_SIZE 32 -#endif - -#ifndef ARDUINOJSON_DEBUG -#ifdef __PLATFORMIO_BUILD_DEBUG__ -#define ARDUINOJSON_DEBUG 1 -#else -#define ARDUINOJSON_DEBUG 0 -#endif -#endif +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#if __cplusplus >= 201103L +#define ARDUINOJSON_HAS_LONG_LONG 1 +#define ARDUINOJSON_HAS_NULLPTR 1 +#define ARDUINOJSON_HAS_RVALUE_REFERENCES 1 +#else +#define ARDUINOJSON_HAS_LONG_LONG 0 +#define ARDUINOJSON_HAS_NULLPTR 0 +#define ARDUINOJSON_HAS_RVALUE_REFERENCES 0 +#endif + +#if defined(_MSC_VER) && !ARDUINOJSON_HAS_LONG_LONG +#define ARDUINOJSON_HAS_INT64 1 +#else +#define ARDUINOJSON_HAS_INT64 0 +#endif + +// Small or big machine? +#ifndef ARDUINOJSON_EMBEDDED_MODE +#if defined(ARDUINO) /* Arduino*/ \ + || defined(__IAR_SYSTEMS_ICC__) /* IAR Embedded Workbench */ \ + || defined(__XC) /* MPLAB XC compiler */ \ + || defined(__ARMCC_VERSION) /* Keil ARM Compiler */ \ + || defined(__AVR) /* Atmel AVR8/GNU C Compiler */ +#define ARDUINOJSON_EMBEDDED_MODE 1 +#else +#define ARDUINOJSON_EMBEDDED_MODE 0 +#endif +#endif + +// Auto enable std::stream if the right headers are here and no conflicting +// macro is defined +#if !defined(ARDUINOJSON_ENABLE_STD_STREAM) && defined(__has_include) +#if __has_include() && \ + __has_include() && \ + !defined(min) && \ + !defined(max) +#define ARDUINOJSON_ENABLE_STD_STREAM 1 +#else +#define ARDUINOJSON_ENABLE_STD_STREAM 0 +#endif +#endif + +// Auto enable std::string if the right header is here and no conflicting +// macro is defined +#if !defined(ARDUINOJSON_ENABLE_STD_STRING) && defined(__has_include) +#if __has_include() && !defined(min) && !defined(max) +#define ARDUINOJSON_ENABLE_STD_STRING 1 +#else +#define ARDUINOJSON_ENABLE_STD_STRING 0 +#endif +#endif + +#if ARDUINOJSON_EMBEDDED_MODE + +// Store floats by default to reduce the memory usage (issue #134) +#ifndef ARDUINOJSON_USE_DOUBLE +#define ARDUINOJSON_USE_DOUBLE 0 +#endif + +// Store longs by default, because they usually match the size of a float. +#ifndef ARDUINOJSON_USE_LONG_LONG +#define ARDUINOJSON_USE_LONG_LONG 0 +#endif + +// Embedded systems usually don't have std::string +#ifndef ARDUINOJSON_ENABLE_STD_STRING +#define ARDUINOJSON_ENABLE_STD_STRING 0 +#endif + +// Embedded systems usually don't have std::stream +#ifndef ARDUINOJSON_ENABLE_STD_STREAM +#define ARDUINOJSON_ENABLE_STD_STREAM 0 +#endif + +// Limit nesting as the stack is likely to be small +#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT +#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 10 +#endif + +#else // ARDUINOJSON_EMBEDDED_MODE + +// On a computer we have plenty of memory so we can use doubles +#ifndef ARDUINOJSON_USE_DOUBLE +#define ARDUINOJSON_USE_DOUBLE 1 +#endif + +// Use long long when available +#ifndef ARDUINOJSON_USE_LONG_LONG +#if ARDUINOJSON_HAS_LONG_LONG || ARDUINOJSON_HAS_INT64 +#define ARDUINOJSON_USE_LONG_LONG 1 +#else +#define ARDUINOJSON_USE_LONG_LONG 0 +#endif +#endif + +// On a computer, we can use std::string +#ifndef ARDUINOJSON_ENABLE_STD_STRING +#define ARDUINOJSON_ENABLE_STD_STRING 1 +#endif + +// On a computer, we can assume std::stream +#ifndef ARDUINOJSON_ENABLE_STD_STREAM +#define ARDUINOJSON_ENABLE_STD_STREAM 1 +#endif + +// On a computer, the stack is large so we can increase nesting limit +#ifndef ARDUINOJSON_DEFAULT_NESTING_LIMIT +#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 50 +#endif + +#endif // ARDUINOJSON_EMBEDDED_MODE + +#ifdef ARDUINO + +#include + +// Enable support for Arduino's String class +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING +#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 +#endif + +// Enable support for Arduino's Stream class +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM +#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 1 +#endif + +// Enable support for Arduino's Print class +#ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT +#define ARDUINOJSON_ENABLE_ARDUINO_PRINT 1 +#endif + +#else // ARDUINO + +// Disable support for Arduino's String class +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STRING +#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 +#endif + +// Disable support for Arduino's Stream class +#ifndef ARDUINOJSON_ENABLE_ARDUINO_STREAM +#define ARDUINOJSON_ENABLE_ARDUINO_STREAM 0 +#endif + +// Disable support for Arduino's Print class +#ifndef ARDUINOJSON_ENABLE_ARDUINO_PRINT +#define ARDUINOJSON_ENABLE_ARDUINO_PRINT 0 +#endif + +#endif // ARDUINO + +#ifndef ARDUINOJSON_ENABLE_PROGMEM +#ifdef PROGMEM +#define ARDUINOJSON_ENABLE_PROGMEM 1 +#else +#define ARDUINOJSON_ENABLE_PROGMEM 0 +#endif +#endif + +// Convert unicode escape sequence (\u0123) to UTF-8 +#ifndef ARDUINOJSON_DECODE_UNICODE +#define ARDUINOJSON_DECODE_UNICODE 1 +#endif + +// Ignore comments in input +#ifndef ARDUINOJSON_ENABLE_COMMENTS +#define ARDUINOJSON_ENABLE_COMMENTS 0 +#endif + +// Support NaN in JSON +#ifndef ARDUINOJSON_ENABLE_NAN +#define ARDUINOJSON_ENABLE_NAN 0 +#endif + +// Support Infinity in JSON +#ifndef ARDUINOJSON_ENABLE_INFINITY +#define ARDUINOJSON_ENABLE_INFINITY 0 +#endif + +// Control the exponentiation threshold for big numbers +// CAUTION: cannot be more that 1e9 !!!! +#ifndef ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD +#define ARDUINOJSON_POSITIVE_EXPONENTIATION_THRESHOLD 1e7 +#endif + +// Control the exponentiation threshold for small numbers +#ifndef ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD +#define ARDUINOJSON_NEGATIVE_EXPONENTIATION_THRESHOLD 1e-5 +#endif + +#ifndef ARDUINOJSON_LITTLE_ENDIAN +#if defined(_MSC_VER) || \ + (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || \ + defined(__LITTLE_ENDIAN__) || defined(__i386) || defined(__x86_64) +#define ARDUINOJSON_LITTLE_ENDIAN 1 +#else +#define ARDUINOJSON_LITTLE_ENDIAN 0 +#endif +#endif + +#ifndef ARDUINOJSON_ENABLE_ALIGNMENT +#if defined(__AVR) +#define ARDUINOJSON_ENABLE_ALIGNMENT 0 +#else +#define ARDUINOJSON_ENABLE_ALIGNMENT 1 +#endif +#endif + +#ifndef ARDUINOJSON_TAB +#define ARDUINOJSON_TAB " " +#endif + +#ifndef ARDUINOJSON_ENABLE_STRING_DEDUPLICATION +#define ARDUINOJSON_ENABLE_STRING_DEDUPLICATION 1 +#endif + +#ifndef ARDUINOJSON_STRING_BUFFER_SIZE +#define ARDUINOJSON_STRING_BUFFER_SIZE 32 +#endif + +#ifndef ARDUINOJSON_DEBUG +#ifdef __PLATFORMIO_BUILD_DEBUG__ +#define ARDUINOJSON_DEBUG 1 +#else +#define ARDUINOJSON_DEBUG 0 +#endif +#endif + +#if ARDUINOJSON_HAS_NULLPTR && 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 diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp index 4efc57dfc..e8902f09c 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/DeserializationError.hpp @@ -1,115 +1,125 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include - -#if ARDUINOJSON_ENABLE_STD_STREAM -#include -#endif - -namespace ARDUINOJSON_NAMESPACE { - -class DeserializationError { - // safe bool idiom - typedef void (DeserializationError::*bool_type)() const; - void safeBoolHelper() const {} - - public: - enum Code { - Ok, - IncompleteInput, - InvalidInput, - NoMemory, - NotSupported, - TooDeep - }; - - DeserializationError() {} - DeserializationError(Code c) : _code(c) {} - - // Compare with DeserializationError - friend bool operator==(const DeserializationError& lhs, - const DeserializationError& rhs) { - return lhs._code == rhs._code; - } - friend bool operator!=(const DeserializationError& lhs, - const DeserializationError& rhs) { - return lhs._code != rhs._code; - } - - // Compare with Code - friend bool operator==(const DeserializationError& lhs, Code rhs) { - return lhs._code == rhs; - } - friend bool operator==(Code lhs, const DeserializationError& rhs) { - return lhs == rhs._code; - } - friend bool operator!=(const DeserializationError& lhs, Code rhs) { - return lhs._code != rhs; - } - friend bool operator!=(Code lhs, const DeserializationError& rhs) { - return lhs != rhs._code; - } - - // Behaves like a bool - operator bool_type() const { - return _code != Ok ? &DeserializationError::safeBoolHelper : 0; - } - friend bool operator==(bool value, const DeserializationError& err) { - return static_cast(err) == value; - } - friend bool operator==(const DeserializationError& err, bool value) { - return static_cast(err) == value; - } - friend bool operator!=(bool value, const DeserializationError& err) { - return static_cast(err) != value; - } - friend bool operator!=(const DeserializationError& err, bool value) { - return static_cast(err) != value; - } - - // Returns internal enum, useful for switch statement - Code code() const { - return _code; - } - - const char* c_str() const { - switch (_code) { - case Ok: - return "Ok"; - case TooDeep: - return "TooDeep"; - case NoMemory: - return "NoMemory"; - case InvalidInput: - return "InvalidInput"; - case IncompleteInput: - return "IncompleteInput"; - case NotSupported: - return "NotSupported"; - default: - return "???"; - } - } - - private: - Code _code; -}; - -#if ARDUINOJSON_ENABLE_STD_STREAM -inline std::ostream& operator<<(std::ostream& s, - const DeserializationError& e) { - s << e.c_str(); - return s; -} - -inline std::ostream& operator<<(std::ostream& s, DeserializationError::Code c) { - s << DeserializationError(c).c_str(); - return s; -} -#endif - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include +#include + +#if ARDUINOJSON_ENABLE_STD_STREAM +#include +#endif + +namespace ARDUINOJSON_NAMESPACE { + +class DeserializationError { + // safe bool idiom + typedef void (DeserializationError::*bool_type)() const; + void safeBoolHelper() const {} + + public: + enum Code { + Ok, + EmptyInput, + IncompleteInput, + InvalidInput, + NoMemory, + NotSupported, + TooDeep + }; + + DeserializationError() {} + DeserializationError(Code c) : _code(c) {} + + // Compare with DeserializationError + friend bool operator==(const DeserializationError& lhs, + const DeserializationError& rhs) { + return lhs._code == rhs._code; + } + friend bool operator!=(const DeserializationError& lhs, + const DeserializationError& rhs) { + return lhs._code != rhs._code; + } + + // Compare with Code + friend bool operator==(const DeserializationError& lhs, Code rhs) { + return lhs._code == rhs; + } + friend bool operator==(Code lhs, const DeserializationError& rhs) { + return lhs == rhs._code; + } + friend bool operator!=(const DeserializationError& lhs, Code rhs) { + return lhs._code != rhs; + } + friend bool operator!=(Code lhs, const DeserializationError& rhs) { + return lhs != rhs._code; + } + + // Behaves like a bool + operator bool_type() const { + return _code != Ok ? &DeserializationError::safeBoolHelper : 0; + } + friend bool operator==(bool value, const DeserializationError& err) { + return static_cast(err) == value; + } + friend bool operator==(const DeserializationError& err, bool value) { + return static_cast(err) == value; + } + friend bool operator!=(bool value, const DeserializationError& err) { + return static_cast(err) != value; + } + friend bool operator!=(const DeserializationError& err, bool value) { + return static_cast(err) != value; + } + + // Returns internal enum, useful for switch statement + Code code() const { + return _code; + } + + const char* c_str() const { + static const char* messages[] = { + "Ok", "EmptyInput", "IncompleteInput", "InvalidInput", + "NoMemory", "NotSupported", "TooDeep"}; + ARDUINOJSON_ASSERT(static_cast(_code) < + sizeof(messages) / sizeof(messages[0])); + return messages[_code]; + } + +#if ARDUINOJSON_ENABLE_PROGMEM + const __FlashStringHelper* f_str() const { + ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s0, "Ok"); + ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s1, "EmptyInput"); + ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s2, "IncompleteInput"); + ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s3, "InvalidInput"); + ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s4, "NoMemory"); + ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s5, "NotSupported"); + ARDUINOJSON_DEFINE_STATIC_ARRAY(char, s6, "TooDeep"); + ARDUINOJSON_DEFINE_STATIC_ARRAY( + const char*, messages, + ARDUINOJSON_EXPAND7({s0, s1, s2, s3, s4, s5, s6})); + return ARDUINOJSON_READ_STATIC_ARRAY(const __FlashStringHelper*, messages, + _code); + } +#endif + + private: + Code _code; +}; + +#if ARDUINOJSON_ENABLE_STD_STREAM +inline std::ostream& operator<<(std::ostream& s, + const DeserializationError& e) { + s << e.c_str(); + return s; +} + +inline std::ostream& operator<<(std::ostream& s, DeserializationError::Code c) { + s << DeserializationError(c).c_str(); + return s; +} +#endif + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp index fb41a9d03..63e06a563 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Filter.hpp @@ -1,66 +1,66 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include - -namespace ARDUINOJSON_NAMESPACE { - -class Filter { - public: - explicit Filter(VariantConstRef v) : _variant(v) {} - - bool allow() const { - return _variant; - } - - bool allowArray() const { - return _variant == true || _variant.is(); - } - - bool allowObject() const { - return _variant == true || _variant.is(); - } - - bool allowValue() const { - return _variant == true; - } - - template - Filter operator[](const TKey& key) const { - if (_variant == true) // "true" means "allow recursively" - return *this; - else - return Filter(_variant[key]); - } - - private: - VariantConstRef _variant; -}; - -struct AllowAllFilter { - bool allow() const { - return true; - } - - bool allowArray() const { - return true; - } - - bool allowObject() const { - return true; - } - - bool allowValue() const { - return true; - } - - template - AllowAllFilter operator[](const TKey&) const { - return AllowAllFilter(); - } -}; - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +class Filter { + public: + explicit Filter(VariantConstRef v) : _variant(v) {} + + bool allow() const { + return _variant; + } + + bool allowArray() const { + return _variant == true || _variant.is(); + } + + bool allowObject() const { + return _variant == true || _variant.is(); + } + + bool allowValue() const { + return _variant == true; + } + + template + Filter operator[](const TKey& key) const { + if (_variant == true) // "true" means "allow recursively" + return *this; + else + return Filter(_variant[key] | _variant["*"]); + } + + private: + VariantConstRef _variant; +}; + +struct AllowAllFilter { + bool allow() const { + return true; + } + + bool allowArray() const { + return true; + } + + bool allowObject() const { + return true; + } + + bool allowValue() const { + return true; + } + + template + AllowAllFilter operator[](const TKey&) const { + return AllowAllFilter(); + } +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp index 47e36d0fd..8f33b6c7d 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/NestingLimit.hpp @@ -1,29 +1,29 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -namespace ARDUINOJSON_NAMESPACE { - -class NestingLimit { - public: - NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} - explicit NestingLimit(uint8_t n) : _value(n) {} - - NestingLimit decrement() const { - ARDUINOJSON_ASSERT(_value > 0); - return NestingLimit(static_cast(_value - 1)); - } - - bool reached() const { - return _value == 0; - } - - private: - uint8_t _value; -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +class NestingLimit { + public: + NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} + explicit NestingLimit(uint8_t n) : _value(n) {} + + NestingLimit decrement() const { + ARDUINOJSON_ASSERT(_value > 0); + return NestingLimit(static_cast(_value - 1)); + } + + bool reached() const { + return _value == 0; + } + + private: + uint8_t _value; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp index a71134ab9..da9a9f24b 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Reader.hpp @@ -1,56 +1,56 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include - -#include // for size_t - -namespace ARDUINOJSON_NAMESPACE { - -// The default reader is a simple wrapper for Readers that are not copiable -template -struct Reader { - public: - Reader(TSource& source) : _source(&source) {} - - int read() { - return _source->read(); - } - - size_t readBytes(char* buffer, size_t length) { - return _source->readBytes(buffer, length); - } - - private: - TSource* _source; -}; - -template -struct BoundedReader { - // no default implementation because we need to pass the size to the - // constructor -}; -} // namespace ARDUINOJSON_NAMESPACE - -#include -#include -#include - -#if ARDUINOJSON_ENABLE_ARDUINO_STREAM -#include -#endif - -#if ARDUINOJSON_ENABLE_ARDUINO_STRING -#include -#endif - -#if ARDUINOJSON_ENABLE_PROGMEM -#include -#endif - -#if ARDUINOJSON_ENABLE_STD_STREAM -#include -#endif +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include + +#include // for size_t + +namespace ARDUINOJSON_NAMESPACE { + +// The default reader is a simple wrapper for Readers that are not copiable +template +struct Reader { + public: + Reader(TSource& source) : _source(&source) {} + + int read() { + return _source->read(); + } + + size_t readBytes(char* buffer, size_t length) { + return _source->readBytes(buffer, length); + } + + private: + TSource* _source; +}; + +template +struct BoundedReader { + // no default implementation because we need to pass the size to the + // constructor +}; +} // namespace ARDUINOJSON_NAMESPACE + +#include +#include +#include + +#if ARDUINOJSON_ENABLE_ARDUINO_STREAM +#include +#endif + +#if ARDUINOJSON_ENABLE_ARDUINO_STRING +#include +#endif + +#if ARDUINOJSON_ENABLE_PROGMEM +#include +#endif + +#if ARDUINOJSON_ENABLE_STD_STREAM +#include +#endif diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp index a50485d03..6c46d5d85 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStreamReader.hpp @@ -1,31 +1,31 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include - -namespace ARDUINOJSON_NAMESPACE { - -template -struct Reader::value>::type> { - public: - explicit Reader(Stream& stream) : _stream(&stream) {} - - int read() { - // don't use _stream.read() as it ignores the timeout - char c; - return _stream->readBytes(&c, 1) ? static_cast(c) : -1; - } - - size_t readBytes(char* buffer, size_t length) { - return _stream->readBytes(buffer, length); - } - - private: - Stream* _stream; -}; - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct Reader::value>::type> { + public: + explicit Reader(Stream& stream) : _stream(&stream) {} + + int read() { + // don't use _stream.read() as it ignores the timeout + char c; + return _stream->readBytes(&c, 1) ? static_cast(c) : -1; + } + + size_t readBytes(char* buffer, size_t length) { + return _stream->readBytes(buffer, length); + } + + private: + Stream* _stream; +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp index 71cbc56b1..5b6bcd2eb 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/ArduinoStringReader.hpp @@ -1,17 +1,17 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -namespace ARDUINOJSON_NAMESPACE { - -template -struct Reader::value>::type> - : BoundedReader { - explicit Reader(const ::String& s) - : BoundedReader(s.c_str(), s.length()) {} -}; - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +namespace ARDUINOJSON_NAMESPACE { + +template +struct Reader::value>::type> + : BoundedReader { + explicit Reader(const ::String& s) + : BoundedReader(s.c_str(), s.length()) {} +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp index 3c8ad2745..36b7fde6d 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/FlashReader.hpp @@ -1,53 +1,53 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -namespace ARDUINOJSON_NAMESPACE { - -template <> -struct Reader { - const char* _ptr; - - public: - explicit Reader(const __FlashStringHelper* ptr) - : _ptr(reinterpret_cast(ptr)) {} - - int read() { - return pgm_read_byte(_ptr++); - } - - size_t readBytes(char* buffer, size_t length) { - memcpy_P(buffer, _ptr, length); - _ptr += length; - return length; - } -}; - -template <> -struct BoundedReader { - const char* _ptr; - const char* _end; - - public: - explicit BoundedReader(const __FlashStringHelper* ptr, size_t size) - : _ptr(reinterpret_cast(ptr)), _end(_ptr + size) {} - - int read() { - if (_ptr < _end) - return pgm_read_byte(_ptr++); - else - return -1; - } - - size_t readBytes(char* buffer, size_t length) { - size_t available = static_cast(_end - _ptr); - if (available < length) - length = available; - memcpy_P(buffer, _ptr, length); - _ptr += length; - return length; - } -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +namespace ARDUINOJSON_NAMESPACE { + +template <> +struct Reader { + const char* _ptr; + + public: + explicit Reader(const __FlashStringHelper* ptr) + : _ptr(reinterpret_cast(ptr)) {} + + int read() { + return pgm_read_byte(_ptr++); + } + + size_t readBytes(char* buffer, size_t length) { + memcpy_P(buffer, _ptr, length); + _ptr += length; + return length; + } +}; + +template <> +struct BoundedReader { + const char* _ptr; + const char* _end; + + public: + explicit BoundedReader(const __FlashStringHelper* ptr, size_t size) + : _ptr(reinterpret_cast(ptr)), _end(_ptr + size) {} + + int read() { + if (_ptr < _end) + return pgm_read_byte(_ptr++); + else + return -1; + } + + size_t readBytes(char* buffer, size_t length) { + size_t available = static_cast(_end - _ptr); + if (available < length) + length = available; + memcpy_P(buffer, _ptr, length); + _ptr += length; + return length; + } +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp index 1c2893031..2f07c3442 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/IteratorReader.hpp @@ -1,43 +1,43 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -namespace ARDUINOJSON_NAMESPACE { - -template -class IteratorReader { - TIterator _ptr, _end; - - public: - explicit IteratorReader(TIterator begin, TIterator end) - : _ptr(begin), _end(end) {} - - int read() { - if (_ptr < _end) - return static_cast(*_ptr++); - else - return -1; - } - - size_t readBytes(char* buffer, size_t length) { - size_t i = 0; - while (i < length && _ptr < _end) buffer[i++] = *_ptr++; - return i; - } -}; - -template -struct void_ { - typedef void type; -}; - -template -struct Reader::type> - : IteratorReader { - explicit Reader(const TSource& source) - : IteratorReader(source.begin(), - source.end()) {} -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +namespace ARDUINOJSON_NAMESPACE { + +template +class IteratorReader { + TIterator _ptr, _end; + + public: + explicit IteratorReader(TIterator begin, TIterator end) + : _ptr(begin), _end(end) {} + + int read() { + if (_ptr < _end) + return static_cast(*_ptr++); + else + return -1; + } + + size_t readBytes(char* buffer, size_t length) { + size_t i = 0; + while (i < length && _ptr < _end) buffer[i++] = *_ptr++; + return i; + } +}; + +template +struct void_ { + typedef void type; +}; + +template +struct Reader::type> + : IteratorReader { + explicit Reader(const TSource& source) + : IteratorReader(source.begin(), + source.end()) {} +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp index 44cc63cdd..5f238a1df 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/RamReader.hpp @@ -1,50 +1,50 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include - -namespace ARDUINOJSON_NAMESPACE { - -template -struct IsCharOrVoid { - static const bool value = - is_same::value || is_same::value || - is_same::value || is_same::value; -}; - -template -struct IsCharOrVoid : IsCharOrVoid {}; - -template -struct Reader::value>::type> { - const char* _ptr; - - public: - explicit Reader(const void* ptr) - : _ptr(ptr ? reinterpret_cast(ptr) : "") {} - - int read() { - return static_cast(*_ptr++); - } - - size_t readBytes(char* buffer, size_t length) { - for (size_t i = 0; i < length; i++) buffer[i] = *_ptr++; - return length; - } -}; - -template -struct BoundedReader::value>::type> - : public IteratorReader { - public: - explicit BoundedReader(const void* ptr, size_t len) - : IteratorReader(reinterpret_cast(ptr), - reinterpret_cast(ptr) + len) {} -}; - -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct IsCharOrVoid { + static const bool value = + is_same::value || is_same::value || + is_same::value || is_same::value; +}; + +template +struct IsCharOrVoid : IsCharOrVoid {}; + +template +struct Reader::value>::type> { + const char* _ptr; + + public: + explicit Reader(const void* ptr) + : _ptr(ptr ? reinterpret_cast(ptr) : "") {} + + int read() { + return static_cast(*_ptr++); + } + + size_t readBytes(char* buffer, size_t length) { + for (size_t i = 0; i < length; i++) buffer[i] = *_ptr++; + return length; + } +}; + +template +struct BoundedReader::value>::type> + : public IteratorReader { + public: + explicit BoundedReader(const void* ptr, size_t len) + : IteratorReader(reinterpret_cast(ptr), + reinterpret_cast(ptr) + len) {} +}; + +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp index e4f56145b..1e7f83fd4 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/StdStreamReader.hpp @@ -1,29 +1,29 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include - -namespace ARDUINOJSON_NAMESPACE { - -template -struct Reader::value>::type> { - public: - explicit Reader(std::istream& stream) : _stream(&stream) {} - - int read() { - return _stream->get(); - } - - size_t readBytes(char* buffer, size_t length) { - _stream->read(buffer, static_cast(length)); - return static_cast(_stream->gcount()); - } - - private: - std::istream* _stream; -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct Reader::value>::type> { + public: + explicit Reader(std::istream& stream) : _stream(&stream) {} + + int read() { + return _stream->get(); + } + + size_t readBytes(char* buffer, size_t length) { + _stream->read(buffer, static_cast(length)); + return static_cast(_stream->gcount()); + } + + private: + std::istream* _stream; +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp index aecc9de83..b06bd4a0a 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/Readers/VariantReader.hpp @@ -1,34 +1,34 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include - -namespace ARDUINOJSON_NAMESPACE { - -template -struct Reader, void> : Reader { - explicit Reader(const ElementProxy& x) - : Reader(x.template as()) {} -}; - -template -struct Reader, void> : Reader { - explicit Reader(const MemberProxy& x) - : Reader(x.template as()) {} -}; - -template <> -struct Reader : Reader { - explicit Reader(VariantRef x) : Reader(x.as()) {} -}; - -template <> -struct Reader : Reader { - explicit Reader(VariantConstRef x) - : Reader(x.as()) {} -}; -} // namespace ARDUINOJSON_NAMESPACE +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2020 +// MIT License + +#pragma once + +#include +#include + +namespace ARDUINOJSON_NAMESPACE { + +template +struct Reader, void> : Reader { + explicit Reader(const ElementProxy& x) + : Reader(x.template as()) {} +}; + +template +struct Reader, void> : Reader { + explicit Reader(const MemberProxy& x) + : Reader(x.template as()) {} +}; + +template <> +struct Reader : Reader { + explicit Reader(VariantRef x) : Reader(x.as()) {} +}; + +template <> +struct Reader : Reader { + explicit Reader(VariantConstRef x) + : Reader(x.as()) {} +}; +} // namespace ARDUINOJSON_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp index d0907842a..7b15e2dac 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp @@ -1,68 +1,71 @@ -// ArduinoJson - arduinojson.org -// Copyright Benoit Blanchon 2014-2020 -// MIT License - -#pragma once - -#include -#include -#include -#include -#include - -namespace ARDUINOJSON_NAMESPACE { - -template