From fa5711eaaa79ec47a1981c8b1ecfbd3321e3ce0b Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 9 Jan 2019 15:32:43 +0100 Subject: [PATCH] Update ArduinoJson to 5.13.4 Update ArduinoJson to 5.13.4 --- lib/ArduinoJson-5.11.2/ArduinoJson.h | 8 - lib/ArduinoJson-5.11.2/README.md | 130 ------- .../JsonHttpClient/JsonHttpClient.ino | 184 ---------- .../examples/JsonServer/JsonServer.ino | 76 ----- .../examples/JsonUdpBeacon/JsonUdpBeacon.ino | 57 ---- lib/ArduinoJson-5.11.2/library.properties | 9 - lib/ArduinoJson-5.11.2/src/ArduinoJson.h | 12 - .../src/ArduinoJson/Data/ValueSetter.hpp | 51 --- .../src/ArduinoJson/Polyfills/isInteger.hpp | 22 -- .../src/ArduinoJson/RawJson.hpp | 23 -- .../TypeTraits/IsSignedIntegral.hpp | 33 -- .../TypeTraits/IsUnsignedIntegral.hpp | 33 -- lib/ArduinoJson-5.13.4/ArduinoJson.h | 5 + .../CHANGELOG.md | 317 ++++++++---------- .../LICENSE.md | 2 +- lib/ArduinoJson-5.13.4/README.md | 110 ++++++ .../JsonConfigFile/JsonConfigFile.ino | 144 ++++++++ .../JsonGeneratorExample.ino | 29 +- .../JsonHttpClient/JsonHttpClient.ino | 112 +++++++ .../JsonParserExample/JsonParserExample.ino | 31 +- .../examples/JsonServer/JsonServer.ino | 109 ++++++ .../examples/JsonUdpBeacon/JsonUdpBeacon.ino | 101 ++++++ .../ProgmemExample/ProgmemExample.ino | 38 ++- .../examples/StringExample/StringExample.ino | 33 +- .../keywords.txt | 0 lib/ArduinoJson-5.13.4/library.properties | 11 + lib/ArduinoJson-5.13.4/src/ArduinoJson.h | 17 + .../src/ArduinoJson.hpp | 9 +- .../src/ArduinoJson/Configuration.hpp | 10 +- .../src/ArduinoJson/Data/Encoding.hpp | 7 +- .../ArduinoJson/Data/JsonBufferAllocated.hpp | 7 +- .../src/ArduinoJson/Data/JsonFloat.hpp | 7 +- .../src/ArduinoJson/Data/JsonInteger.hpp | 7 +- .../src/ArduinoJson/Data/JsonVariantAs.hpp | 7 +- .../ArduinoJson/Data/JsonVariantContent.hpp | 7 +- .../ArduinoJson/Data/JsonVariantDefault.hpp | 7 +- .../src/ArduinoJson/Data/JsonVariantType.hpp | 7 +- .../src/ArduinoJson/Data/List.hpp | 7 +- .../ArduinoJson/Data/ListConstIterator.hpp | 7 +- .../src/ArduinoJson/Data/ListIterator.hpp | 7 +- .../src/ArduinoJson/Data/ListNode.hpp | 7 +- .../src/ArduinoJson/Data/NonCopyable.hpp | 7 +- .../src/ArduinoJson/Data/ReferenceType.hpp | 7 +- .../src/ArduinoJson/Data/ValueSaver.hpp | 52 +++ .../ArduinoJson/Deserialization/Comments.hpp | 7 +- .../Deserialization/JsonParser.hpp | 29 +- .../Deserialization/JsonParserImpl.hpp | 35 +- .../Deserialization/StringWriter.hpp | 7 +- .../src/ArduinoJson/DynamicJsonBuffer.hpp | 12 +- .../src/ArduinoJson/JsonArray.hpp | 48 ++- .../src/ArduinoJson/JsonArrayImpl.hpp | 7 +- .../src/ArduinoJson/JsonArraySubscript.hpp | 61 ++-- .../src/ArduinoJson/JsonBuffer.hpp | 24 +- .../src/ArduinoJson/JsonBufferBase.hpp | 21 +- .../src/ArduinoJson/JsonBufferImpl.hpp | 7 +- .../src/ArduinoJson/JsonObject.hpp | 195 +++++------ .../src/ArduinoJson/JsonObjectImpl.hpp | 7 +- .../src/ArduinoJson/JsonObjectSubscript.hpp | 41 +-- .../src/ArduinoJson/JsonPair.hpp | 7 +- .../src/ArduinoJson/JsonVariant.hpp | 115 ++++--- .../src/ArduinoJson/JsonVariantBase.hpp | 15 +- .../src/ArduinoJson/JsonVariantCasts.hpp | 9 +- .../ArduinoJson/JsonVariantComparisons.hpp | 41 +-- .../src/ArduinoJson/JsonVariantImpl.hpp | 15 +- .../src/ArduinoJson/JsonVariantOr.hpp | 52 +++ .../src/ArduinoJson/JsonVariantSubscripts.hpp | 35 +- .../src/ArduinoJson/Polyfills/attributes.hpp | 9 +- .../src/ArduinoJson/Polyfills/ctype.hpp | 9 +- .../src/ArduinoJson/Polyfills/isFloat.hpp | 9 +- .../src/ArduinoJson/Polyfills/isInteger.hpp | 19 ++ .../src/ArduinoJson/Polyfills/math.hpp | 9 +- .../src/ArduinoJson/Polyfills/parseFloat.hpp | 11 +- .../ArduinoJson/Polyfills/parseInteger.hpp | 9 +- .../src/ArduinoJson/RawJson.hpp | 46 +++ .../ArduinoJson/Serialization/DummyPrint.hpp | 7 +- .../Serialization/DynamicStringBuilder.hpp | 7 +- .../ArduinoJson/Serialization/FloatParts.hpp | 9 +- .../Serialization/IndentedPrint.hpp | 7 +- .../Serialization/JsonPrintable.hpp | 21 +- .../Serialization/JsonSerializer.hpp | 14 +- .../Serialization/JsonSerializerImpl.hpp | 7 +- .../ArduinoJson/Serialization/JsonWriter.hpp | 11 +- .../ArduinoJson/Serialization/Prettyfier.hpp | 7 +- .../Serialization/StaticStringBuilder.hpp | 7 +- .../Serialization/StreamPrintAdapter.hpp | 7 +- .../src/ArduinoJson/StaticJsonBuffer.hpp | 14 +- .../StringTraits/ArduinoStream.hpp | 20 +- .../ArduinoJson/StringTraits/CharPointer.hpp | 32 +- .../ArduinoJson/StringTraits/FlashString.hpp | 25 +- .../ArduinoJson/StringTraits/StdStream.hpp | 20 +- .../ArduinoJson/StringTraits/StdString.hpp | 27 +- .../ArduinoJson/StringTraits/StringTraits.hpp | 28 +- .../src/ArduinoJson/TypeTraits/EnableIf.hpp | 9 +- .../ArduinoJson/TypeTraits/FloatTraits.hpp | 54 ++- .../src/ArduinoJson/TypeTraits/IsArray.hpp | 9 +- .../src/ArduinoJson/TypeTraits/IsBaseOf.hpp | 9 +- .../src/ArduinoJson/TypeTraits/IsChar.hpp | 9 +- .../src/ArduinoJson/TypeTraits/IsConst.hpp | 9 +- .../TypeTraits/IsFloatingPoint.hpp | 9 +- .../src/ArduinoJson/TypeTraits/IsIntegral.hpp | 15 +- .../src/ArduinoJson/TypeTraits/IsSame.hpp | 9 +- .../TypeTraits/IsSignedIntegral.hpp | 28 ++ .../TypeTraits/IsUnsignedIntegral.hpp | 28 ++ .../src/ArduinoJson/TypeTraits/IsVariant.hpp | 9 +- .../ArduinoJson/TypeTraits/RemoveConst.hpp | 9 +- .../TypeTraits/RemoveReference.hpp | 9 +- .../src/ArduinoJson/version.hpp | 10 + 107 files changed, 1652 insertions(+), 1620 deletions(-) delete mode 100644 lib/ArduinoJson-5.11.2/ArduinoJson.h delete mode 100644 lib/ArduinoJson-5.11.2/README.md delete mode 100644 lib/ArduinoJson-5.11.2/examples/JsonHttpClient/JsonHttpClient.ino delete mode 100644 lib/ArduinoJson-5.11.2/examples/JsonServer/JsonServer.ino delete mode 100644 lib/ArduinoJson-5.11.2/examples/JsonUdpBeacon/JsonUdpBeacon.ino delete mode 100644 lib/ArduinoJson-5.11.2/library.properties delete mode 100644 lib/ArduinoJson-5.11.2/src/ArduinoJson.h delete mode 100644 lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ValueSetter.hpp delete mode 100644 lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/isInteger.hpp delete mode 100644 lib/ArduinoJson-5.11.2/src/ArduinoJson/RawJson.hpp delete mode 100644 lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp delete mode 100644 lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp create mode 100644 lib/ArduinoJson-5.13.4/ArduinoJson.h rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/CHANGELOG.md (68%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/LICENSE.md (96%) create mode 100644 lib/ArduinoJson-5.13.4/README.md create mode 100644 lib/ArduinoJson-5.13.4/examples/JsonConfigFile/JsonConfigFile.ino rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/examples/JsonGeneratorExample/JsonGeneratorExample.ino (63%) create mode 100644 lib/ArduinoJson-5.13.4/examples/JsonHttpClient/JsonHttpClient.ino rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/examples/JsonParserExample/JsonParserExample.ino (61%) create mode 100644 lib/ArduinoJson-5.13.4/examples/JsonServer/JsonServer.ino create mode 100644 lib/ArduinoJson-5.13.4/examples/JsonUdpBeacon/JsonUdpBeacon.ino rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/examples/ProgmemExample/ProgmemExample.ino (52%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/examples/StringExample/StringExample.ino (67%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/keywords.txt (100%) create mode 100644 lib/ArduinoJson-5.13.4/library.properties create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson.h rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson.hpp (75%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Configuration.hpp (94%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/Encoding.hpp (80%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/JsonBufferAllocated.hpp (68%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/JsonFloat.hpp (56%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/JsonInteger.hpp (70%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/JsonVariantAs.hpp (80%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/JsonVariantContent.hpp (79%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/JsonVariantDefault.hpp (68%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/JsonVariantType.hpp (84%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/List.hpp (93%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/ListConstIterator.hpp (85%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/ListIterator.hpp (86%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/ListNode.hpp (70%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/NonCopyable.hpp (67%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Data/ReferenceType.hpp (74%) create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ValueSaver.hpp rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Deserialization/Comments.hpp (88%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Deserialization/JsonParser.hpp (77%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Deserialization/JsonParserImpl.hpp (85%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Deserialization/StringWriter.hpp (79%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/DynamicJsonBuffer.hpp (94%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonArray.hpp (82%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonArrayImpl.hpp (75%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonArraySubscript.hpp (69%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonBuffer.hpp (74%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonBufferBase.hpp (88%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonBufferImpl.hpp (72%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonObject.hpp (57%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonObjectImpl.hpp (79%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonObjectSubscript.hpp (66%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonPair.hpp (53%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonVariant.hpp (72%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonVariantBase.hpp (59%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonVariantCasts.hpp (89%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonVariantComparisons.hpp (75%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonVariantImpl.hpp (87%) create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantOr.hpp rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/JsonVariantSubscripts.hpp (70%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Polyfills/attributes.hpp (74%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Polyfills/ctype.hpp (50%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Polyfills/isFloat.hpp (75%) create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/isInteger.hpp rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Polyfills/math.hpp (52%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Polyfills/parseFloat.hpp (89%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Polyfills/parseInteger.hpp (75%) create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson/RawJson.hpp rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/DummyPrint.hpp (64%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp (80%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/FloatParts.hpp (91%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/IndentedPrint.hpp (89%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/JsonPrintable.hpp (80%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/JsonSerializer.hpp (79%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp (94%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/JsonWriter.hpp (91%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/Prettyfier.hpp (93%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/StaticStringBuilder.hpp (77%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp (77%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/StaticJsonBuffer.hpp (89%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/StringTraits/ArduinoStream.hpp (64%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/StringTraits/CharPointer.hpp (54%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/StringTraits/FlashString.hpp (64%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/StringTraits/StdStream.hpp (63%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/StringTraits/StdString.hpp (70%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/StringTraits/StringTraits.hpp (55%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/EnableIf.hpp (58%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/FloatTraits.hpp (68%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsArray.hpp (67%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsBaseOf.hpp (73%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsChar.hpp (69%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsConst.hpp (61%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp (60%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsIntegral.hpp (50%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsSame.hpp (62%) create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/IsVariant.hpp (50%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/RemoveConst.hpp (59%) rename lib/{ArduinoJson-5.11.2 => ArduinoJson-5.13.4}/src/ArduinoJson/TypeTraits/RemoveReference.hpp (60%) create mode 100644 lib/ArduinoJson-5.13.4/src/ArduinoJson/version.hpp diff --git a/lib/ArduinoJson-5.11.2/ArduinoJson.h b/lib/ArduinoJson-5.11.2/ArduinoJson.h deleted file mode 100644 index 896503a6c..000000000 --- a/lib/ArduinoJson-5.11.2/ArduinoJson.h +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#include "src/ArduinoJson.h" diff --git a/lib/ArduinoJson-5.11.2/README.md b/lib/ArduinoJson-5.11.2/README.md deleted file mode 100644 index 6ee8a37a6..000000000 --- a/lib/ArduinoJson-5.11.2/README.md +++ /dev/null @@ -1,130 +0,0 @@ -[![Build status](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/master?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/master) [![Build Status](https://travis-ci.org/bblanchon/ArduinoJson.svg?branch=master)](https://travis-ci.org/bblanchon/ArduinoJson) [![Coverage Status](https://img.shields.io/coveralls/bblanchon/ArduinoJson.svg)](https://coveralls.io/r/bblanchon/ArduinoJson?branch=master) [![Star this project](http://githubbadges.com/star.svg?user=bblanchon&repo=ArduinoJson&style=flat&color=fff&background=007ec6)](https://github.com/bblanchon/ArduinoJson) - -![ArduinoJson's logo](banner.svg) - -ArduinoJson - C++ JSON library for IoT -==================== - -*An elegant and efficient JSON library for embedded systems.* - -It's designed to have the most intuitive API, the smallest footprint and is able to work without any allocation on the heap (no malloc). - -It has been written with Arduino in mind, but it isn't linked to Arduino libraries so you can use this library in any other C++ project. -For instance, it supports Aduino's `String` and `Stream`, but also `std::string`, `std::istream` and `std::ostream`. - -Features --------- - -* JSON decoding (comments are supported) -* JSON encoding (with optional indentation) -* Elegant API, very easy to use -* Fixed memory allocation (zero malloc) -* No data duplication (zero copy) -* Portable (written in C++98) -* Self-contained (no external dependency) -* Small footprint -* Header-only library -* MIT License - -Works on --------- - -* Arduino boards: Uno, Due, Mini, Micro, Yun... -* ESP8266, ESP32 -* Teensy -* RedBearLab boards (BLE Nano...) -* Intel Edison and Galileo -* WeMos boards: D1... -* Computers: Windows, Linux, OSX... -* PlatformIO -* Particle -* Energia - -Quick start ------------ - -#### Decoding / Parsing - -```c++ -char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; - -StaticJsonBuffer<200> jsonBuffer; - -JsonObject& root = jsonBuffer.parseObject(json); - -const char* sensor = root["sensor"]; -long time = root["time"]; -double latitude = root["data"][0]; -double longitude = root["data"][1]; -``` - -[See JsonParserExample.ino](examples/JsonParserExample/JsonParserExample.ino) - -Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size. - -#### Encoding / Generating - -```c++ -StaticJsonBuffer<200> jsonBuffer; - -JsonObject& root = jsonBuffer.createObject(); -root["sensor"] = "gps"; -root["time"] = 1351824120; - -JsonArray& data = root.createNestedArray("data"); -data.add(48.756080); -data.add(2.302038); - -root.printTo(Serial); -// This prints: -// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} -``` - -[See JsonGeneratorExample.ino](examples/JsonGeneratorExample/JsonGeneratorExample.ino) - -Use [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) to compute the buffer size. - - -Documentation -------------- - -The documentation is available online in the [ArduinoJson Website](https://bblanchon.github.io/ArduinoJson/). - -The [ArduinoJson Assistant](https://bblanchon.github.io/ArduinoJson/assistant/) helps you get started with the library. - - -Donators --------- - -Special thanks to the following persons and companies who made generous donations to the library author: - -* Robert Murphy USA -* Surge Communications USA -* Alex Scott United Kingdom -* Firepick Services LLC USA -* A B Doodkorte Netherlands -* Scott Smith USA -* Johann Stieger Austria -* Gustavo Donizeti Gini Brazil -* Charles-Henri Hallard France -* Martijn van den Burg Netherlands -* Nick Koumaris Greece -* Jon Williams USA -* Kestutis Liaugminas Lithuania -* Darlington Adibe Nigeria -* Yoeri Kroon Netherlands -* Andrew Melvin United Kingdom -* Doanh Luong Vietnam -* Christoph Schmidt Germany -* OpenEVSE LLC USA -* Prokhoryatov Alexey Russia -* Google Inc. USA -* Charles Haynes Australia -* Charles Walker USA -* Günther Jehle Liechtenstein -* Patrick Elliott - - ---- - -Found this library useful? Please star this project or [help me back with a donation!](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=donate%40benoitblanchon%2efr&lc=GB&item_name=Benoit%20Blanchon&item_number=Arduino%20JSON¤cy_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) :smile: diff --git a/lib/ArduinoJson-5.11.2/examples/JsonHttpClient/JsonHttpClient.ino b/lib/ArduinoJson-5.11.2/examples/JsonHttpClient/JsonHttpClient.ino deleted file mode 100644 index 5edb817f1..000000000 --- a/lib/ArduinoJson-5.11.2/examples/JsonHttpClient/JsonHttpClient.ino +++ /dev/null @@ -1,184 +0,0 @@ -// Sample Arduino Json Web Client -// Downloads and parse http://jsonplaceholder.typicode.com/users/1 -// -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#include -#include -#include - -EthernetClient client; - -const char* server = "jsonplaceholder.typicode.com"; // server's address -const char* resource = "/users/1"; // http resource -const unsigned long BAUD_RATE = 9600; // serial connection speed -const unsigned long HTTP_TIMEOUT = 10000; // max respone time from server -const size_t MAX_CONTENT_SIZE = 512; // max size of the HTTP response - -// The type of data that we want to extract from the page -struct UserData { - char name[32]; - char company[32]; -}; - -// ARDUINO entry point #1: runs once when you press reset or power the board -void setup() { - initSerial(); - initEthernet(); -} - -// ARDUINO entry point #2: runs over and over again forever -void loop() { - if (connect(server)) { - if (sendRequest(server, resource) && skipResponseHeaders()) { - UserData userData; - if (readReponseContent(&userData)) { - printUserData(&userData); - } - } - } - disconnect(); - wait(); -} - -// Initialize Serial port -void initSerial() { - Serial.begin(BAUD_RATE); - while (!Serial) { - ; // wait for serial port to initialize - } - Serial.println("Serial ready"); -} - -// Initialize Ethernet library -void initEthernet() { - byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; - if (!Ethernet.begin(mac)) { - Serial.println("Failed to configure Ethernet"); - return; - } - Serial.println("Ethernet ready"); - delay(1000); -} - -// Open connection to the HTTP server -bool connect(const char* hostName) { - Serial.print("Connect to "); - Serial.println(hostName); - - bool ok = client.connect(hostName, 80); - - Serial.println(ok ? "Connected" : "Connection Failed!"); - return ok; -} - -// Send the HTTP GET request to the server -bool sendRequest(const char* host, const char* resource) { - Serial.print("GET "); - Serial.println(resource); - - client.print("GET "); - client.print(resource); - client.println(" HTTP/1.0"); - client.print("Host: "); - client.println(host); - client.println("Connection: close"); - client.println(); - - return true; -} - -// Skip HTTP headers so that we are at the beginning of the response's body -bool skipResponseHeaders() { - // HTTP headers end with an empty line - char endOfHeaders[] = "\r\n\r\n"; - - client.setTimeout(HTTP_TIMEOUT); - bool ok = client.find(endOfHeaders); - - if (!ok) { - Serial.println("No response or invalid response!"); - } - - return ok; -} - -// Parse the JSON from the input string and extract the interesting values -// Here is the JSON we need to parse -// { -// "id": 1, -// "name": "Leanne Graham", -// "username": "Bret", -// "email": "Sincere@april.biz", -// "address": { -// "street": "Kulas Light", -// "suite": "Apt. 556", -// "city": "Gwenborough", -// "zipcode": "92998-3874", -// "geo": { -// "lat": "-37.3159", -// "lng": "81.1496" -// } -// }, -// "phone": "1-770-736-8031 x56442", -// "website": "hildegard.org", -// "company": { -// "name": "Romaguera-Crona", -// "catchPhrase": "Multi-layered client-server neural-net", -// "bs": "harness real-time e-markets" -// } -// } -bool readReponseContent(struct UserData* userData) { - // Compute optimal size of the JSON buffer according to what we need to parse. - // See https://bblanchon.github.io/ArduinoJson/assistant/ - const size_t BUFFER_SIZE = - JSON_OBJECT_SIZE(8) // the root object has 8 elements - + JSON_OBJECT_SIZE(5) // the "address" object has 5 elements - + JSON_OBJECT_SIZE(2) // the "geo" object has 2 elements - + JSON_OBJECT_SIZE(3) // the "company" object has 3 elements - + MAX_CONTENT_SIZE; // additional space for strings - - // Allocate a temporary memory pool - DynamicJsonBuffer jsonBuffer(BUFFER_SIZE); - - JsonObject& root = jsonBuffer.parseObject(client); - - if (!root.success()) { - Serial.println("JSON parsing failed!"); - return false; - } - - // Here were copy the strings we're interested in - strcpy(userData->name, root["name"]); - strcpy(userData->company, root["company"]["name"]); - // It's not mandatory to make a copy, you could just use the pointers - // Since, they are pointing inside the "content" buffer, so you need to make - // sure it's still in memory when you read the string - - return true; -} - -// Print the data extracted from the JSON -void printUserData(const struct UserData* userData) { - Serial.print("Name = "); - Serial.println(userData->name); - Serial.print("Company = "); - Serial.println(userData->company); -} - -// Close the connection with the HTTP server -void disconnect() { - Serial.println("Disconnect"); - client.stop(); -} - -// Pause for a 1 minute -void wait() { - Serial.println("Wait 60 seconds"); - delay(60000); -} diff --git a/lib/ArduinoJson-5.11.2/examples/JsonServer/JsonServer.ino b/lib/ArduinoJson-5.11.2/examples/JsonServer/JsonServer.ino deleted file mode 100644 index 555842b82..000000000 --- a/lib/ArduinoJson-5.11.2/examples/JsonServer/JsonServer.ino +++ /dev/null @@ -1,76 +0,0 @@ -// Sample Arduino Json Web Server -// Created by Benoit Blanchon. -// Heavily inspired by "Web Server" from David A. Mellis and Tom Igoe - -#include -#include -#include - -byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; -IPAddress ip(192, 168, 0, 177); -EthernetServer server(80); - -bool readRequest(EthernetClient& client) { - bool currentLineIsBlank = true; - while (client.connected()) { - if (client.available()) { - char c = client.read(); - if (c == '\n' && currentLineIsBlank) { - return true; - } else if (c == '\n') { - currentLineIsBlank = true; - } else if (c != '\r') { - currentLineIsBlank = false; - } - } - } - return false; -} - -JsonObject& prepareResponse(JsonBuffer& jsonBuffer) { - JsonObject& root = jsonBuffer.createObject(); - - JsonArray& analogValues = root.createNestedArray("analog"); - for (int pin = 0; pin < 6; pin++) { - int value = analogRead(pin); - analogValues.add(value); - } - - JsonArray& digitalValues = root.createNestedArray("digital"); - for (int pin = 0; pin < 14; pin++) { - int value = digitalRead(pin); - digitalValues.add(value); - } - - return root; -} - -void writeResponse(EthernetClient& client, JsonObject& json) { - client.println("HTTP/1.1 200 OK"); - client.println("Content-Type: application/json"); - client.println("Connection: close"); - client.println(); - - json.prettyPrintTo(client); -} - -void setup() { - Ethernet.begin(mac, ip); - server.begin(); -} - -void loop() { - EthernetClient client = server.available(); - if (client) { - bool success = readRequest(client); - if (success) { - // Use https://bblanchon.github.io/ArduinoJson/assistant/ to - // compute the right size for the buffer - StaticJsonBuffer<500> jsonBuffer; - JsonObject& json = prepareResponse(jsonBuffer); - writeResponse(client, json); - } - delay(1); - client.stop(); - } -} diff --git a/lib/ArduinoJson-5.11.2/examples/JsonUdpBeacon/JsonUdpBeacon.ino b/lib/ArduinoJson-5.11.2/examples/JsonUdpBeacon/JsonUdpBeacon.ino deleted file mode 100644 index b3bd5fc50..000000000 --- a/lib/ArduinoJson-5.11.2/examples/JsonUdpBeacon/JsonUdpBeacon.ino +++ /dev/null @@ -1,57 +0,0 @@ -// Send a JSON object on UDP at regular interval -// -// You can easily test this program with netcat: -// $ nc -ulp 8888 -// -// by Benoit Blanchon, MIT License 2015-2017 - -#include -#include -#include - -byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; -IPAddress localIp(192, 168, 0, 177); -IPAddress remoteIp(192, 168, 0, 109); -unsigned int remotePort = 8888; -unsigned localPort = 8888; -EthernetUDP udp; - -JsonObject& buildJson(JsonBuffer& jsonBuffer) { - JsonObject& root = jsonBuffer.createObject(); - - JsonArray& analogValues = root.createNestedArray("analog"); - for (int pin = 0; pin < 6; pin++) { - int value = analogRead(pin); - analogValues.add(value); - } - - JsonArray& digitalValues = root.createNestedArray("digital"); - for (int pin = 0; pin < 14; pin++) { - int value = digitalRead(pin); - digitalValues.add(value); - } - - return root; -} - -void sendJson(JsonObject& json) { - udp.beginPacket(remoteIp, remotePort); - json.printTo(udp); - udp.println(); - udp.endPacket(); -} - -void setup() { - Ethernet.begin(mac, localIp); - udp.begin(localPort); -} - -void loop() { - delay(1000); - - // Use https://bblanchon.github.io/ArduinoJson/assistant/ to - // compute the right size for the buffer - StaticJsonBuffer<300> jsonBuffer; - JsonObject& json = buildJson(jsonBuffer); - sendJson(json); -} diff --git a/lib/ArduinoJson-5.11.2/library.properties b/lib/ArduinoJson-5.11.2/library.properties deleted file mode 100644 index 9809a3c0b..000000000 --- a/lib/ArduinoJson-5.11.2/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=ArduinoJson -version=5.11.2 -author=Benoit Blanchon -maintainer=Benoit Blanchon -sentence=An efficient and elegant JSON library for Arduino. -paragraph=Like this project? Please star it on GitHub! -category=Data Processing -url=https://bblanchon.github.io/ArduinoJson/ -architectures=* diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson.h b/lib/ArduinoJson-5.11.2/src/ArduinoJson.h deleted file mode 100644 index c1ec7c02f..000000000 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson.h +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#pragma once - -#include "ArduinoJson.hpp" - -using namespace ArduinoJson; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ValueSetter.hpp b/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ValueSetter.hpp deleted file mode 100644 index 7eb3ed63b..000000000 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ValueSetter.hpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#pragma once - -#include "../JsonBuffer.hpp" -#include "../JsonVariant.hpp" -#include "../StringTraits/StringTraits.hpp" -#include "../TypeTraits/EnableIf.hpp" - -namespace ArduinoJson { -namespace Internals { - -template -struct ValueSetter { - template - static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) { - destination = source; - return true; - } -}; - -template -struct ValueSetter::should_duplicate>::type> { - template - static bool set(JsonBuffer* buffer, TDestination& destination, - TSourceRef source) { - const char* copy = buffer->strdup(source); - if (!copy) return false; - destination = copy; - return true; - } -}; - -template -struct ValueSetter::should_duplicate>::type> { - template - static bool set(JsonBuffer*, TDestination& destination, TSourceRef source) { - // unsigned char* -> char* - destination = reinterpret_cast(source); - return true; - } -}; -} -} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/isInteger.hpp b/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/isInteger.hpp deleted file mode 100644 index ea39f2a63..000000000 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/isInteger.hpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#pragma once - -#include "./ctype.hpp" - -namespace ArduinoJson { -namespace Polyfills { - -inline bool isInteger(const char* s) { - if (!s) return false; - if (issign(*s)) s++; - while (isdigit(*s)) s++; - return *s == '\0'; -} -} -} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/RawJson.hpp b/lib/ArduinoJson-5.11.2/src/ArduinoJson/RawJson.hpp deleted file mode 100644 index 6db195c32..000000000 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/RawJson.hpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#pragma once - -namespace ArduinoJson { - -// A special type of data that can be used to insert pregenerated JSON portions. -class RawJson { - public: - explicit RawJson(const char* str) : _str(str) {} - operator const char*() const { - return _str; - } - - private: - const char* _str; -}; -} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp b/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp deleted file mode 100644 index fde6e13b0..000000000 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#pragma once - -#include "../Configuration.hpp" -#include "IsSame.hpp" - -namespace ArduinoJson { -namespace TypeTraits { - -// A meta-function that returns true if T is an integral type. -template -struct IsSignedIntegral { - static const bool value = TypeTraits::IsSame::value || - TypeTraits::IsSame::value || - TypeTraits::IsSame::value || - TypeTraits::IsSame::value || -#if ARDUINOJSON_USE_LONG_LONG - TypeTraits::IsSame::value || -#endif - -#if ARDUINOJSON_USE_INT64 - TypeTraits::IsSame::value || -#endif - false; -}; -} -} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp b/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp deleted file mode 100644 index 173763e05..000000000 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright Benoit Blanchon 2014-2017 -// MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! - -#pragma once - -#include "../Configuration.hpp" -#include "IsSame.hpp" - -namespace ArduinoJson { -namespace TypeTraits { - -// A meta-function that returns true if T is an integral type. -template -struct IsUnsignedIntegral { - static const bool value = TypeTraits::IsSame::value || - TypeTraits::IsSame::value || - TypeTraits::IsSame::value || - TypeTraits::IsSame::value || -#if ARDUINOJSON_USE_LONG_LONG - TypeTraits::IsSame::value || -#endif - -#if ARDUINOJSON_USE_INT64 - TypeTraits::IsSame::value || -#endif - false; -}; -} -} diff --git a/lib/ArduinoJson-5.13.4/ArduinoJson.h b/lib/ArduinoJson-5.13.4/ArduinoJson.h new file mode 100644 index 000000000..9f78b9f18 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/ArduinoJson.h @@ -0,0 +1,5 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#include "src/ArduinoJson.h" diff --git a/lib/ArduinoJson-5.11.2/CHANGELOG.md b/lib/ArduinoJson-5.13.4/CHANGELOG.md similarity index 68% rename from lib/ArduinoJson-5.11.2/CHANGELOG.md rename to lib/ArduinoJson-5.13.4/CHANGELOG.md index 490e25c8c..3616b176a 100644 --- a/lib/ArduinoJson-5.11.2/CHANGELOG.md +++ b/lib/ArduinoJson-5.13.4/CHANGELOG.md @@ -1,6 +1,78 @@ ArduinoJson: change log ======================= +v5.13.4 +------- + +* Removed spurious files in the Particle library + +v5.13.3 +------- + +* Improved float serialization when `-fsingle-precision-constant` is used +* Fixed `JsonVariant::is()` that returned true for empty strings +* Fixed `JsonVariant::is()` (closes #763) + +v5.13.2 +------- + +* Fixed `JsonBuffer::parse()` not respecting nesting limit correctly (issue #693) +* Fixed inconsistencies in nesting level counting (PR #695 from Zhenyu Wu) +* Fixed null values that could be pass to `strcmp()` (PR #745 from Mike Karlesky) +* Added macros `ARDUINOJSON_VERSION`, `ARDUINOJSON_VERSION_MAJOR`... + +v5.13.1 +------- + +* Fixed `JsonVariant::operator|(int)` that returned the default value if the variant contained a double (issue #675) +* Allowed non-quoted key to contain underscores (issue #665) + +v5.13.0 +------- + +* Changed the rules of string duplication (issue #658) +* `RawJson()` accepts any kind of string and obeys to the same rules for duplication +* Changed the return type of `strdup()` to `const char*` to prevent double duplication +* Marked `strdup()` as deprecated + +> ### New rules for string duplication +> +> | type | duplication | +> |:---------------------------|:------------| +> | const char* | no | +> | char* | ~~no~~ yes | +> | String | yes | +> | std::string | yes | +> | const __FlashStringHelper* | yes | +> +> These new rules make `JsonBuffer::strdup()` useless. + +v5.12.0 +------- + +* Added `JsonVariant::operator|` to return a default value (see below) +* Added a clear error message when compiled as C instead of C++ (issue #629) +* Added detection of MPLAB XC compiler (issue #629) +* Added detection of Keil ARM Compiler (issue #629) +* Added an example that shows how to save and load a configuration file +* Reworked all other examples + +> ### How to use the new feature? +> +> If you have a block like this: +> +> ```c++ +> const char* ssid = root["ssid"]; +> if (!ssid) +> ssid = "default ssid"; +> ``` +> +> You can simplify like that: +> +> ```c++ +> const char* ssid = root["ssid"] | "default ssid"; +> ``` + v5.11.2 ------- @@ -42,27 +114,26 @@ v5.10.0 * Fixed error `IsBaseOf is not a member of ArduinoJson::TypeTraits` (issue #495) * Fixed error `forming reference to reference` (issue #495) -### BREAKING CHANGES :warning: - -| Old syntax | New syntax | -|---------------------------------|---------------------| -| `double_with_n_digits(3.14, 2)` | `3.14` | -| `float_with_n_digits(3.14, 2)` | `3.14f` | -| `obj.set("key", 3.14, 2)` | `obj["key"] = 3.14` | -| `arr.add(3.14, 2)` | `arr.add(3.14)` | - -| Input | Old output | New output | -|-----------|------------|------------| -| `3.14159` | `3.14` | `3.14159` | -| `42.0` | `42.00` | `42` | -| `0.0` | `0.00` | `0` | - -| Expression | Old result | New result | -|--------------------------------|------------|------------| -| `JsonVariant(42).is()` | `true` | `true` | -| `JsonVariant(42).is()` | `false` | `true` | -| `JsonVariant(42).is()` | `false` | `true` | - +> ### BREAKING CHANGES :warning: +> +> | Old syntax | New syntax | +> |:--------------------------------|:--------------------| +> | `double_with_n_digits(3.14, 2)` | `3.14` | +> | `float_with_n_digits(3.14, 2)` | `3.14f` | +> | `obj.set("key", 3.14, 2)` | `obj["key"] = 3.14` | +> | `arr.add(3.14, 2)` | `arr.add(3.14)` | +> +> | Input | Old output | New output | +> |:----------|:-----------|:-----------| +> | `3.14159` | `3.14` | `3.14159` | +> | `42.0` | `42.00` | `42` | +> | `0.0` | `0.00` | `0` | +> +> | Expression | Old result | New result | +> |:-------------------------------|:-----------|:-----------| +> | `JsonVariant(42).is()` | `true` | `true` | +> | `JsonVariant(42).is()` | `false` | `true` | +> | `JsonVariant(42).is()` | `false` | `true` | v5.9.0 ------ @@ -116,24 +187,23 @@ v5.8.0 * Added support for `Stream` (issue #300) * Reduced memory consumption by not duplicating spaces and comments -### BREAKING CHANGES :warning: - -`JsonBuffer::parseObject()` and `JsonBuffer::parseArray()` have been pulled down to the derived classes `DynamicJsonBuffer` and `StaticJsonBufferBase`. - -This means that if you have code like: - -```c++ -void myFunction(JsonBuffer& jsonBuffer); -``` - -you need to replace it with one of the following: - -```c++ -void myFunction(DynamicJsonBuffer& jsonBuffer); -void myFunction(StaticJsonBufferBase& jsonBuffer); -template void myFunction(TJsonBuffer& jsonBuffer); -``` - +> ### BREAKING CHANGES :warning: +> +> `JsonBuffer::parseObject()` and `JsonBuffer::parseArray()` have been pulled down to the derived classes `DynamicJsonBuffer` and `StaticJsonBufferBase`. +> +> This means that if you have code like: +> +> ```c++ +> void myFunction(JsonBuffer& jsonBuffer); +> ``` +> +> you need to replace it with one of the following: +> +> ```c++ +> void myFunction(DynamicJsonBuffer& jsonBuffer); +> void myFunction(StaticJsonBufferBase& jsonBuffer); +> template void myFunction(TJsonBuffer& jsonBuffer); +> ``` v5.7.3 ------ @@ -166,27 +236,26 @@ v5.7.0 * Added example `StringExample.ino` to show where `String` can be used * Increased default nesting limit to 50 when compiled for a computer (issue #349) -### BREAKING CHANGES :warning: - -The non-template functions `JsonObject::get()` and `JsonArray.get()` have been removed. This means that you need to explicitely tell the type you expect in return. - -Old code: - -```c++ -#define ARDUINOJSON_USE_ARDUINO_STRING 0 -JsonVariant value1 = myObject.get("myKey"); -JsonVariant value2 = myArray.get(0); -``` - -New code: - -```c++ -#define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 -#define ARDUINOJSON_ENABLE_STD_STRING 1 -JsonVariant value1 = myObject.get("myKey"); -JsonVariant value2 = myArray.get(0); -``` - +> ### BREAKING CHANGES :warning: +> +> The non-template functions `JsonObject::get()` and `JsonArray.get()` have been removed. This means that you need to explicitely tell the type you expect in return. +> +> Old code: +> +> ```c++ +> #define ARDUINOJSON_USE_ARDUINO_STRING 0 +> JsonVariant value1 = myObject.get("myKey"); +> JsonVariant value2 = myArray.get(0); +> ``` +> +> New code: +> +> ```c++ +> #define ARDUINOJSON_ENABLE_ARDUINO_STRING 0 +> #define ARDUINOJSON_ENABLE_STD_STRING 1 +> JsonVariant value1 = myObject.get("myKey"); +> JsonVariant value2 = myArray.get(0); +> ``` v5.6.7 ------ @@ -278,8 +347,9 @@ v5.1.0 * Added support of `long long` (issue #171) * Moved all build settings to `ArduinoJson/Configuration.hpp` -**BREAKING CHANGE**: -If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`. +> ### BREAKING CHANGE :warning: +> +> If you defined `ARDUINOJSON_ENABLE_STD_STREAM`, you now need to define it to `1`. v5.0.8 ------ @@ -293,10 +363,10 @@ v5.0.7 * Made library easier to use from a CMake project: simply `add_subdirectory(ArduinoJson/src)` * Changed `String` to be a `typedef` of `std::string` (issues #142 and #161) -### BREAKING CHANGES :warning: - -- `JsonVariant(true).as()` now returns `"true"` instead of `"1"` -- `JsonVariant(false).as()` now returns `"false"` instead of `"0"` +> ### BREAKING CHANGES :warning: +> +> - `JsonVariant(true).as()` now returns `"true"` instead of `"1"` +> - `JsonVariant(false).as()` now returns `"false"` instead of `"0"` v5.0.6 ------ @@ -350,11 +420,11 @@ v5.0.0 * Redesigned `JsonVariant` to leverage converting constructors instead of assignment operators (issue #66) * Switched to new the library layout (requires Arduino 1.0.6 or above) -### BREAKING CHANGES :warning: - -- `JsonObject::add()` was renamed to `set()` -- `JsonArray::at()` and `JsonObject::at()` were renamed to `get()` -- Number of digits of floating point value are now set with `double_with_n_digits()` +> ### BREAKING CHANGES :warning: +> +> - `JsonObject::add()` was renamed to `set()` +> - `JsonArray::at()` and `JsonObject::at()` were renamed to `get()` +> - Number of digits of floating point value are now set with `double_with_n_digits()` **Personal note about the `String` class**: Support of the `String` class has been added to the library because many people use it in their programs. @@ -407,106 +477,7 @@ v4.0 * Unified parser and generator API (issue #23) * Updated library layout, now requires Arduino 1.0.6 or newer -**BREAKING CHANGE**: API changed significantly, see [Migrating code to the new API](https://github.com/bblanchon/ArduinoJson/wiki/Migrating-code-to-the-new-API). +> ### BREAKING CHANGES :warning: +> +> API changed significantly since v3, see [Migrating code to the new API](https://arduinojson.org/doc/migration/). - -v3.4 ----- - -* Fixed escaped char parsing (issue #16) - - -v3.3 ----- - -* Added indented output for the JSON generator (issue #11), see example bellow. -* Added `IndentedPrint`, a decorator for `Print` to allow indented output - -Example: - - JsonOject<2> json; - json["key"] = "value"; - json.prettyPrintTo(Serial); - -v3.2 ----- - -* Fixed a bug when adding nested object in `JsonArray` (bug introduced in v3.1). - -v3.1 ----- - -* Calling `Generator::JsonObject::add()` twice with the same `key` now replaces the `value` -* Added `Generator::JsonObject::operator[]`, see bellow the new API -* Added `Generator::JsonObject::remove()` (issue #9) - -Old generator API: - - JsonObject<3> root; - root.add("sensor", "gps"); - root.add("time", 1351824120); - root.add("data", array); - -New generator API: - - JsonObject<3> root; - root["sensor"] = "gps"; - root["time"] = 1351824120; - root["data"] = array; - -v3.0 ----- - -* New parser API, see bellow -* Renamed `JsonHashTable` into `JsonObject` -* Added iterators for `JsonArray` and `JsonObject` (issue #4) - -Old parser API: - - JsonHashTable root = parser.parseHashTable(json); - - char* sensor = root.getString("sensor"); - long time = root.getLong("time"); - double latitude = root.getArray("data").getDouble(0); - double longitude = root.getArray("data").getDouble(1); - -New parser API: - - JsonObject root = parser.parse(json); - - char* sensor = root["sensor"]; - long time = root["time"]; - double latitude = root["data"][0]; - double longitude = root["data"][1]; - -v2.1 ----- - -* Fixed case `#include "jsmn.cpp"` which caused an error in Linux (issue #6) -* Fixed a buffer overrun in JSON Parser (issue #5) - -v2.0 ----- - -* Added JSON encoding (issue #2) -* Renamed the library `ArduinoJsonParser` becomes `ArduinoJson` - -**Breaking change**: you need to add the following line at the top of your program. - - using namespace ArduinoJson::Parser; - -v1.2 ----- - -* Fixed error in JSON parser example (issue #1) - -v1.1 ----- - -* Example: changed `char* json` into `char[] json` so that the bytes are not write protected -* Fixed parsing bug when the JSON contains multi-dimensional arrays - -v1.0 ----- - -Initial release diff --git a/lib/ArduinoJson-5.11.2/LICENSE.md b/lib/ArduinoJson-5.13.4/LICENSE.md similarity index 96% rename from lib/ArduinoJson-5.11.2/LICENSE.md rename to lib/ArduinoJson-5.13.4/LICENSE.md index 9f35ed446..f0c4b5ae7 100644 --- a/lib/ArduinoJson-5.11.2/LICENSE.md +++ b/lib/ArduinoJson-5.13.4/LICENSE.md @@ -1,7 +1,7 @@ The MIT License (MIT) --------------------- -Copyright © 2014-2017 Benoit BLANCHON +Copyright © 2014-2018 Benoit BLANCHON Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/lib/ArduinoJson-5.13.4/README.md b/lib/ArduinoJson-5.13.4/README.md new file mode 100644 index 000000000..8ddc698fc --- /dev/null +++ b/lib/ArduinoJson-5.13.4/README.md @@ -0,0 +1,110 @@ +![ArduinoJson](banner.svg) + +--- + +[![Build status](https://ci.appveyor.com/api/projects/status/m7s53wav1l0abssg/branch/master?svg=true)](https://ci.appveyor.com/project/bblanchon/arduinojson/branch/master) [![Build Status](https://travis-ci.org/bblanchon/ArduinoJson.svg?branch=master)](https://travis-ci.org/bblanchon/ArduinoJson) [![Coverage Status](https://img.shields.io/coveralls/bblanchon/ArduinoJson.svg)](https://coveralls.io/r/bblanchon/ArduinoJson?branch=master) [![Star this project](http://githubbadges.com/star.svg?user=bblanchon&repo=ArduinoJson&style=flat&color=fff&background=007ec6)](https://github.com/bblanchon/ArduinoJson) + +ArduinoJson is a C++ JSON library for Arduino and IoT (Internet Of Things). + +## Features + +* JSON decoding (comments are supported) +* JSON encoding (with optional indentation) +* Elegant API, easy to use +* Fixed memory allocation (zero malloc) +* No data duplication (zero copy) +* Portable (written in C++98, can be used in any C++ project) +* Self-contained (no external dependency) +* Small footprint +* Input and output streams +* [100% code coverage](https://coveralls.io/github/bblanchon/ArduinoJson) +* [Header-only library](https://en.wikipedia.org/wiki/Header-only) +* [MIT License](https://en.wikipedia.org/wiki/MIT_License) +* [Comprehensive documentation](https://arduinojson.org?utm_source=github&utm_medium=readme) + +## Compatibility + +ArduinoJson works on the following hardware: + +* Arduino boards: [Uno](https://www.arduino.cc/en/Main/ArduinoBoardUno), [Due](https://www.arduino.cc/en/Main/ArduinoBoardDue), [Mini](https://www.arduino.cc/en/Main/ArduinoBoardMini), [Micro](https://www.arduino.cc/en/Main/ArduinoBoardMicro), [Yun](https://www.arduino.cc/en/Main/ArduinoBoardYun)... +* Espressif chips: [ESP8266](https://en.wikipedia.org/wiki/ESP8266), [ESP32](https://en.wikipedia.org/wiki/ESP32) +* WeMos boards: [D1](https://wiki.wemos.cc/products:d1:d1), [D1 mini](https://wiki.wemos.cc/products:d1:d1_mini), ... +* RedBearLab boards: [BLE Nano](http://redbearlab.com/blenano/), [BLE Mini](http://redbearlab.com/blemini/), [WiFi Micro](https://redbear.cc/product/wifi/wifi-micro.html), [LOLIN32](https://wiki.wemos.cc/products:lolin32:lolin32)... +* [Teensy](https://www.pjrc.com/teensy/) boards +* Intel boards: Edison, Galileo... +* Particle boards: [Photon](https://www.particle.io/products/hardware/photon-wifi-dev-kit), [Electron](https://www.particle.io/products/hardware/electron-cellular-dev-kit)... +* Texas Instruments boards: [MSP430](http://www.ti.com/microcontrollers/msp430-ultra-low-power-mcus/overview/overview.html)... + +ArduinoJson compiles with zero warning on the following compilers, IDEs, and platforms: + +* [Arduino IDE](https://www.arduino.cc/en/Main/Software) +* [PlatformIO](http://platformio.org/) +* [Energia](http://energia.nu/) +* [Visual Micro](http://www.visualmicro.com/) +* [Atmel Studio](http://www.atmel.com/microsite/atmel-studio/) +* [IAR Embedded Workbench](https://www.iar.com/iar-embedded-workbench/) +* [Atollic TrueSTUDIO](https://atollic.com/truestudio/) +* [Keil uVision](http://www.keil.com/) +* [MPLAB X IDE](http://www.microchip.com/mplab/mplab-x-ide) +* [GCC](https://gcc.gnu.org/) +* [Clang](https://clang.llvm.org/) +* [Visual Studio](https://www.visualstudio.com/) + +## Quickstart + +### Deserialization + +Here is a program that parses a JSON document with ArduinoJson. + +```c++ +char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; + +StaticJsonBuffer<200> jsonBuffer; + +JsonObject& root = jsonBuffer.parseObject(json); + +const char* sensor = root["sensor"]; +long time = root["time"]; +double latitude = root["data"][0]; +double longitude = root["data"][1]; +``` + +See the [tutorial on arduinojson.org](https://arduinojson.org/doc/decoding/?utm_source=github&utm_medium=readme) + +### Serialization + +Here is a program that generates a JSON document with ArduinoJson: + +```c++ +StaticJsonBuffer<200> jsonBuffer; + +JsonObject& root = jsonBuffer.createObject(); +root["sensor"] = "gps"; +root["time"] = 1351824120; + +JsonArray& data = root.createNestedArray("data"); +data.add(48.756080); +data.add(2.302038); + +root.printTo(Serial); +// This prints: +// {"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]} +``` + +See the [tutorial on arduinojson.org](https://arduinojson.org/doc/encoding/?utm_source=github&utm_medium=readme) + +## Documentation + +The documentation is available on [arduinojson.org](https://arduinojson.org/?utm_source=github&utm_medium=readme), here are some shortcuts: + +* The [Examples](https://arduinojson.org/example/?utm_source=github&utm_medium=readme) show how to use the library in various situations. +* The [API Reference](https://arduinojson.org/api/?utm_source=github&utm_medium=readme) contains the description of each class and function. +* The [FAQ](https://arduinojson.org/faq/?utm_source=github&utm_medium=readme) has the answer to virtually every question. +* The [ArduinoJson Assistant](https://arduinojson.org/assistant/?utm_source=github&utm_medium=readme) writes programs for you! + +--- + +Do you like this library? Please [star this project on GitHub](https://github.com/bblanchon/ArduinoJson/stargazers)! + +What? You don't like it but you *love* it? +We don't take donations anymore, but [we sell a book](https://arduinojson.org/book/?utm_source=github&utm_medium=readme), so you can help and learn at the same time! \ No newline at end of file diff --git a/lib/ArduinoJson-5.13.4/examples/JsonConfigFile/JsonConfigFile.ino b/lib/ArduinoJson-5.13.4/examples/JsonConfigFile/JsonConfigFile.ino new file mode 100644 index 000000000..2ccf7d673 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/examples/JsonConfigFile/JsonConfigFile.ino @@ -0,0 +1,144 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// 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 +// } + +#include +#include +#include + +// Configuration that we'll store on disk +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 the memory pool on the stack. + // Don't forget to change the capacity to match your JSON document. + // Use arduinojson.org/assistant to compute the capacity. + StaticJsonBuffer<512> jsonBuffer; + + // Parse the root object + JsonObject &root = jsonBuffer.parseObject(file); + + if (!root.success()) + Serial.println(F("Failed to read file, using default configuration")); + + // Copy values from the JsonObject to the Config + config.port = root["port"] | 2731; + strlcpy(config.hostname, // <- destination + root["hostname"] | "example.com", // <- source + sizeof(config.hostname)); // <- destination's capacity + + // Close the file (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 the memory pool on the stack + // Don't forget to change the capacity to match your JSON document. + // Use https://arduinojson.org/assistant/ to compute the capacity. + StaticJsonBuffer<256> jsonBuffer; + + // Parse the root object + JsonObject &root = jsonBuffer.createObject(); + + // Set the values + root["hostname"] = config.hostname; + root["port"] = config.port; + + // Serialize JSON to file + if (root.printTo(file) == 0) { + Serial.println(F("Failed to write to file")); + } + + // Close the file (File's destructor doesn't 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's destructor doesn't close the file) + file.close(); +} + +void setup() { + // Initialize serial port + Serial.begin(9600); + while (!Serial) continue; + + // Initialize SD library + while (!SD.begin()) { + 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-5.11.2/examples/JsonGeneratorExample/JsonGeneratorExample.ino b/lib/ArduinoJson-5.13.4/examples/JsonGeneratorExample/JsonGeneratorExample.ino similarity index 63% rename from lib/ArduinoJson-5.11.2/examples/JsonGeneratorExample/JsonGeneratorExample.ino rename to lib/ArduinoJson-5.13.4/examples/JsonGeneratorExample/JsonGeneratorExample.ino index 0f636faf8..7b38227b3 100644 --- a/lib/ArduinoJson-5.11.2/examples/JsonGeneratorExample/JsonGeneratorExample.ino +++ b/lib/ArduinoJson-5.13.4/examples/JsonGeneratorExample/JsonGeneratorExample.ino @@ -1,23 +1,21 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License // -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! +// This example shows how to generate a JSON document with ArduinoJson. #include void setup() { + // Initialize Serial port Serial.begin(9600); - while (!Serial) { - // wait serial port initialization - } + while (!Serial) continue; // Memory pool for JSON object tree. // // Inside the brackets, 200 is the size of the pool in bytes. - // If the JSON object is more complex, you need to increase that value. - // See https://bblanchon.github.io/ArduinoJson/assistant/ + // Don't forget to change this value to match your JSON document. + // Use arduinojson.org/assistant to compute the capacity. StaticJsonBuffer<200> jsonBuffer; // StaticJsonBuffer allocates memory on the stack, it can be @@ -68,3 +66,16 @@ void setup() { 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-5.13.4/examples/JsonHttpClient/JsonHttpClient.ino b/lib/ArduinoJson-5.13.4/examples/JsonHttpClient/JsonHttpClient.ino new file mode 100644 index 000000000..4ce1c20d1 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/examples/JsonHttpClient/JsonHttpClient.ino @@ -0,0 +1,112 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// 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 +// ] +// } + +#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)); + if (strcmp(status, "HTTP/1.1 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 JsonBuffer + // Use arduinojson.org/assistant to compute the capacity. + const size_t capacity = JSON_OBJECT_SIZE(3) + JSON_ARRAY_SIZE(2) + 60; + DynamicJsonBuffer jsonBuffer(capacity); + + // Parse JSON object + JsonObject& root = jsonBuffer.parseObject(client); + if (!root.success()) { + Serial.println(F("Parsing failed!")); + return; + } + + // Extract values + Serial.println(F("Response:")); + Serial.println(root["sensor"].as()); + Serial.println(root["time"].as()); + Serial.println(root["data"][0].as()); + Serial.println(root["data"][1].as()); + + // 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 Yahoo Weather. In the last chapter, +// it shows how to parse the huge documents from OpenWeatherMap +// and Weather Underground. +// Learn more at https://arduinojson.org/book/ +// Use the coupon code TWENTY for a 20% discount ❤❤❤❤❤ diff --git a/lib/ArduinoJson-5.11.2/examples/JsonParserExample/JsonParserExample.ino b/lib/ArduinoJson-5.13.4/examples/JsonParserExample/JsonParserExample.ino similarity index 61% rename from lib/ArduinoJson-5.11.2/examples/JsonParserExample/JsonParserExample.ino rename to lib/ArduinoJson-5.13.4/examples/JsonParserExample/JsonParserExample.ino index 719d2ee28..6c16211b5 100644 --- a/lib/ArduinoJson-5.11.2/examples/JsonParserExample/JsonParserExample.ino +++ b/lib/ArduinoJson-5.13.4/examples/JsonParserExample/JsonParserExample.ino @@ -1,23 +1,21 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License // -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! +// This example shows how to deserialize a JSON document with ArduinoJson. #include void setup() { + // Initialize serial port Serial.begin(9600); - while (!Serial) { - // wait serial port initialization - } + while (!Serial) continue; // Memory pool for JSON object tree. // - // Inside the brackets, 200 is the size of the pool in bytes, - // If the JSON object is more complex, you need to increase that value. - // See https://bblanchon.github.io/ArduinoJson/assistant/ + // Inside the brackets, 200 is the size of the pool in bytes. + // Don't forget to change this value to match your JSON document. + // Use arduinojson.org/assistant to compute the capacity. StaticJsonBuffer<200> jsonBuffer; // StaticJsonBuffer allocates memory on the stack, it can be @@ -65,3 +63,16 @@ void setup() { 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-5.13.4/examples/JsonServer/JsonServer.ino b/lib/ArduinoJson-5.13.4/examples/JsonServer/JsonServer.ino new file mode 100644 index 000000000..e693ae176 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/examples/JsonServer/JsonServer.ino @@ -0,0 +1,109 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License +// +// This example shows how to implement an HTTP server that sends JSON document +// in the responses. +// It uses the Ethernet library but can be easily adapted for Wifi. +// +// It sends the value of the analog and digital pins. +// The JSON document looks like the following: +// { +// "analog": [ 0, 1, 2, 3, 4, 5 ], +// "digital": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] +// } + +#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 JsonBuffer + // Use arduinojson.org/assistant to compute the capacity. + StaticJsonBuffer<500> jsonBuffer; + + // Create the root object + JsonObject& root = jsonBuffer.createObject(); + + // Create the "analog" array + JsonArray& analogValues = root.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 = root.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: ")); + root.printTo(Serial); + Serial.println(); + + // Write response headers + client.println("HTTP/1.0 200 OK"); + client.println("Content-Type: application/json"); + client.println("Connection: close"); + client.println(); + + // Write JSON document + root.prettyPrintTo(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-5.13.4/examples/JsonUdpBeacon/JsonUdpBeacon.ino b/lib/ArduinoJson-5.13.4/examples/JsonUdpBeacon/JsonUdpBeacon.ino new file mode 100644 index 000000000..b2328a62d --- /dev/null +++ b/lib/ArduinoJson-5.13.4/examples/JsonUdpBeacon/JsonUdpBeacon.ino @@ -0,0 +1,101 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// 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. +// The JSON document looks like the following: +// { +// "analog": [ 0, 1, 2, 3, 4, 5 ], +// "digital": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ] +// } +// +// 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/ + +#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 JsonBuffer + // Use arduinojson.org/assistant to compute the capacity. + StaticJsonBuffer<500> jsonBuffer; + + // Create the root object + JsonObject& root = jsonBuffer.createObject(); + + // Create the "analog" array + JsonArray& analogValues = root.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 = root.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); + root.printTo(Serial); + + // Send UDP packet + udp.beginPacket(remoteIp, remotePort); + root.printTo(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-5.11.2/examples/ProgmemExample/ProgmemExample.ino b/lib/ArduinoJson-5.13.4/examples/ProgmemExample/ProgmemExample.ino similarity index 52% rename from lib/ArduinoJson-5.11.2/examples/ProgmemExample/ProgmemExample.ino rename to lib/ArduinoJson-5.13.4/examples/ProgmemExample/ProgmemExample.ino index 195b014fb..ddde8fd1d 100644 --- a/lib/ArduinoJson-5.11.2/examples/ProgmemExample/ProgmemExample.ino +++ b/lib/ArduinoJson-5.13.4/examples/ProgmemExample/ProgmemExample.ino @@ -1,21 +1,19 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License // -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! +// This example shows the different ways you can use Flash strings with +// ArduinoJson. +// +// Use Flash strings sparingly, because ArduinoJson duplicates them in the +// JsonBuffer. Prefer plain old char*, as they are more efficient in term of +// code size, speed, and memory usage. #include -// About -// ----- -// This example shows the different ways you can use PROGMEM with ArduinoJson. -// Please don't see this as an invitation to use PROGMEM. -// On the contrary, you should always use char[] when possible, it's much more -// efficient in term of code size, speed and memory usage. - void setup() { -#ifdef PROGMEM +#ifdef PROGMEM // <- check that Flash strings are supported + DynamicJsonBuffer jsonBuffer; // You can use a Flash String as your JSON input. @@ -39,6 +37,9 @@ void setup() { // JsonBuffer. root["sensor"] = F("gps"); + // It works with RawJson too: + root["sensor"] = RawJson(F("\"gps\"")); + // You can compare the content of a JsonVariant to a Flash String if (root["sensor"] == F("gps")) { // ... @@ -54,3 +55,16 @@ void setup() { 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-5.11.2/examples/StringExample/StringExample.ino b/lib/ArduinoJson-5.13.4/examples/StringExample/StringExample.ino similarity index 67% rename from lib/ArduinoJson-5.11.2/examples/StringExample/StringExample.ino rename to lib/ArduinoJson-5.13.4/examples/StringExample/StringExample.ino index 50b8db6ec..fc7503d0e 100644 --- a/lib/ArduinoJson-5.11.2/examples/StringExample/StringExample.ino +++ b/lib/ArduinoJson-5.13.4/examples/StringExample/StringExample.ino @@ -1,19 +1,15 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License // -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! +// This example shows the different ways you can use String with ArduinoJson. +// +// Use String objects sparingly, because ArduinoJson duplicates them in the +// JsonBuffer. Prefer plain old char[], as they are more efficient in term of +// code size, speed, and memory usage. #include -// About -// ----- -// This example shows the different ways you can use String with ArduinoJson. -// Please don't see this as an invitation to use String. -// On the contrary, you should always use char[] when possible, it's much more -// efficient in term of code size, speed and memory usage. - void setup() { DynamicJsonBuffer jsonBuffer; @@ -44,6 +40,9 @@ void setup() { // WARNING: the content of the String will be duplicated in the JsonBuffer. root["sensor"] = sensor; + // It works with RawJson too: + root["sensor"] = RawJson(sensor); + // You can also concatenate strings // WARNING: the content of the String will be duplicated in the JsonBuffer. root[String("sen") + "sor"] = String("gp") + "s"; @@ -61,3 +60,15 @@ void setup() { 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-5.11.2/keywords.txt b/lib/ArduinoJson-5.13.4/keywords.txt similarity index 100% rename from lib/ArduinoJson-5.11.2/keywords.txt rename to lib/ArduinoJson-5.13.4/keywords.txt diff --git a/lib/ArduinoJson-5.13.4/library.properties b/lib/ArduinoJson-5.13.4/library.properties new file mode 100644 index 000000000..67ccbb95e --- /dev/null +++ b/lib/ArduinoJson-5.13.4/library.properties @@ -0,0 +1,11 @@ +name=ArduinoJson +version=5.13.4 +author=Benoit Blanchon +maintainer=Benoit Blanchon +sentence=An efficient and elegant JSON library for Arduino. +paragraph=ArduinoJson supports ✔ serialization, ✔ deserialization, ✔ fixed allocation, ✔ zero-copy, ✔ streams, 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-5.13.4/src/ArduinoJson.h b/lib/ArduinoJson-5.13.4/src/ArduinoJson.h new file mode 100644 index 000000000..3782aeabc --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson.h @@ -0,0 +1,17 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// 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-5.11.2/src/ArduinoJson.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson.hpp similarity index 75% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson.hpp index 949fa5ca0..c493c06a9 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson.hpp @@ -1,12 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once +#include "ArduinoJson/version.hpp" + #include "ArduinoJson/DynamicJsonBuffer.hpp" #include "ArduinoJson/JsonArray.hpp" #include "ArduinoJson/JsonObject.hpp" diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Configuration.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Configuration.hpp similarity index 94% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Configuration.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Configuration.hpp index a1015a6f3..82483adfa 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Configuration.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Configuration.hpp @@ -1,15 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once // Small or big machine? #ifndef ARDUINOJSON_EMBEDDED_MODE -#if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) +#if defined(ARDUINO) || defined(__IAR_SYSTEMS_ICC__) || defined(__XC) || \ + defined(__ARMCC_VERSION) #define ARDUINOJSON_EMBEDDED_MODE 1 #else #define ARDUINOJSON_EMBEDDED_MODE 0 diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/Encoding.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/Encoding.hpp similarity index 80% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/Encoding.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/Encoding.hpp index dba785aae..a0efa2c74 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/Encoding.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/Encoding.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonBufferAllocated.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonBufferAllocated.hpp similarity index 68% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonBufferAllocated.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonBufferAllocated.hpp index ff74adc55..443aae4df 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonBufferAllocated.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonBufferAllocated.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonFloat.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonFloat.hpp similarity index 56% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonFloat.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonFloat.hpp index a4a8e937f..0ed42140f 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonFloat.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonFloat.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonInteger.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonInteger.hpp similarity index 70% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonInteger.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonInteger.hpp index 574a5e109..c8ddd00b4 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonInteger.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonInteger.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantAs.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantAs.hpp similarity index 80% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantAs.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantAs.hpp index 3f19fd23a..8f202c5eb 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantAs.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantAs.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantContent.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantContent.hpp similarity index 79% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantContent.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantContent.hpp index b27716299..c525a6060 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantContent.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantContent.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantDefault.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantDefault.hpp similarity index 68% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantDefault.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantDefault.hpp index a59fd46c9..57ecc83ee 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantDefault.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantDefault.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantType.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantType.hpp similarity index 84% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantType.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantType.hpp index ba6a24999..21f890e52 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/JsonVariantType.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/JsonVariantType.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/List.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/List.hpp similarity index 93% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/List.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/List.hpp index 8a24666ec..506308cc3 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/List.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/List.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListConstIterator.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListConstIterator.hpp similarity index 85% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListConstIterator.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListConstIterator.hpp index bce1bfa5e..a6af685e5 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListConstIterator.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListConstIterator.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListIterator.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListIterator.hpp similarity index 86% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListIterator.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListIterator.hpp index a491866f0..01fa287f7 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListIterator.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListIterator.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListNode.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListNode.hpp similarity index 70% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListNode.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListNode.hpp index 712e15e1f..c0907120e 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ListNode.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ListNode.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/NonCopyable.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/NonCopyable.hpp similarity index 67% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/NonCopyable.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/NonCopyable.hpp index 98ebd8fb3..73f3d8edb 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/NonCopyable.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/NonCopyable.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ReferenceType.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ReferenceType.hpp similarity index 74% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ReferenceType.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ReferenceType.hpp index bbc9046be..1e491172f 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Data/ReferenceType.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ReferenceType.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ValueSaver.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ValueSaver.hpp new file mode 100644 index 000000000..9750f1ac5 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Data/ValueSaver.hpp @@ -0,0 +1,52 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +#include "../JsonBuffer.hpp" +#include "../JsonVariant.hpp" +#include "../StringTraits/StringTraits.hpp" +#include "../TypeTraits/EnableIf.hpp" + +namespace ArduinoJson { +namespace Internals { + +template +struct ValueSaver { + template + static bool save(JsonBuffer*, Destination& destination, Source source) { + destination = source; + return true; + } +}; + +template +struct ValueSaver< + Source, typename EnableIf::should_duplicate>::type> { + template + static bool save(JsonBuffer* buffer, Destination& dest, Source source) { + if (!StringTraits::is_null(source)) { + typename StringTraits::duplicate_t dup = + StringTraits::duplicate(source, buffer); + if (!dup) return false; + dest = dup; + } else { + dest = reinterpret_cast(0); + } + return true; + } +}; + +// const char*, const signed char*, const unsigned char* +template +struct ValueSaver< + Char*, typename EnableIf::should_duplicate>::type> { + template + static bool save(JsonBuffer*, Destination& dest, Char* source) { + dest = reinterpret_cast(source); + return true; + } +}; +} +} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/Comments.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/Comments.hpp similarity index 88% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/Comments.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/Comments.hpp index 9f281da49..c2c48ebcc 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/Comments.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/Comments.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/JsonParser.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/JsonParser.hpp similarity index 77% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/JsonParser.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/JsonParser.hpp index 3e605ef25..4cbaf454c 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/JsonParser.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/JsonParser.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -47,19 +44,18 @@ class JsonParser { const char *parseString(); bool parseAnythingTo(JsonVariant *destination); - FORCE_INLINE bool parseAnythingToUnsafe(JsonVariant *destination); inline bool parseArrayTo(JsonVariant *destination); inline bool parseObjectTo(JsonVariant *destination); inline bool parseStringTo(JsonVariant *destination); - static inline bool isInRange(char c, char min, char max) { + static inline bool isBetween(char c, char min, char max) { return min <= c && c <= max; } - static inline bool isLetterOrNumber(char c) { - return isInRange(c, '0', '9') || isInRange(c, 'a', 'z') || - isInRange(c, 'A', 'Z') || c == '+' || c == '-' || c == '.'; + static inline bool canBeInNonQuotedString(char c) { + return isBetween(c, '0', '9') || isBetween(c, '_', 'z') || + isBetween(c, 'A', 'Z') || c == '+' || c == '-' || c == '.'; } static inline bool isQuote(char c) { @@ -74,7 +70,7 @@ class JsonParser { template struct JsonParserBuilder { - typedef typename Internals::StringTraits::Reader InputReader; + typedef typename StringTraits::Reader InputReader; typedef JsonParser TParser; static TParser makeParser(TJsonBuffer *buffer, TString &json, @@ -84,10 +80,9 @@ struct JsonParserBuilder { }; template -struct JsonParserBuilder< - TJsonBuffer, TChar *, - typename TypeTraits::EnableIf::value>::type> { - typedef typename Internals::StringTraits::Reader TReader; +struct JsonParserBuilder::value>::type> { + typedef typename StringTraits::Reader TReader; typedef StringWriter TWriter; typedef JsonParser TParser; @@ -103,5 +98,5 @@ inline typename JsonParserBuilder::TParser makeParser( return JsonParserBuilder::makeParser(buffer, json, nestingLimit); } -} -} +} // namespace Internals +} // namespace ArduinoJson diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/JsonParserImpl.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/JsonParserImpl.hpp similarity index 85% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/JsonParserImpl.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/JsonParserImpl.hpp index 1c41bdaac..504267355 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/JsonParserImpl.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/JsonParserImpl.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -20,18 +17,9 @@ inline bool ArduinoJson::Internals::JsonParser::eat( } template -inline bool ArduinoJson::Internals::JsonParser< - TReader, TWriter>::parseAnythingTo(JsonVariant *destination) { - if (_nestingLimit == 0) return false; - _nestingLimit--; - bool success = parseAnythingToUnsafe(destination); - _nestingLimit++; - return success; -} - -template -inline bool ArduinoJson::Internals::JsonParser< - TReader, TWriter>::parseAnythingToUnsafe(JsonVariant *destination) { +inline bool +ArduinoJson::Internals::JsonParser::parseAnythingTo( + JsonVariant *destination) { skipSpacesAndComments(_reader); switch (_reader.current()) { @@ -49,6 +37,9 @@ inline bool ArduinoJson::Internals::JsonParser< template inline ArduinoJson::JsonArray & ArduinoJson::Internals::JsonParser::parseArray() { + if (_nestingLimit == 0) return JsonArray::invalid(); + _nestingLimit--; + // Create an empty array JsonArray &array = _buffer->createArray(); @@ -70,6 +61,7 @@ ArduinoJson::Internals::JsonParser::parseArray() { SUCCESS_EMPTY_ARRAY: SUCCES_NON_EMPTY_ARRAY: + _nestingLimit++; return array; ERROR_INVALID_VALUE: @@ -92,6 +84,9 @@ inline bool ArduinoJson::Internals::JsonParser::parseArrayTo( template inline ArduinoJson::JsonObject & ArduinoJson::Internals::JsonParser::parseObject() { + if (_nestingLimit == 0) return JsonObject::invalid(); + _nestingLimit--; + // Create an empty object JsonObject &object = _buffer->createObject(); @@ -118,6 +113,7 @@ ArduinoJson::Internals::JsonParser::parseObject() { SUCCESS_EMPTY_OBJECT: SUCCESS_NON_EMPTY_OBJECT: + _nestingLimit++; return object; ERROR_INVALID_KEY: @@ -142,8 +138,7 @@ inline bool ArduinoJson::Internals::JsonParser::parseObjectTo( template inline const char * ArduinoJson::Internals::JsonParser::parseString() { - typename TypeTraits::RemoveReference::type::String str = - _writer.startString(); + typename RemoveReference::type::String str = _writer.startString(); skipSpacesAndComments(_reader); char c = _reader.current(); @@ -169,7 +164,7 @@ ArduinoJson::Internals::JsonParser::parseString() { } } else { // no quotes for (;;) { - if (!isLetterOrNumber(c)) break; + if (!canBeInNonQuotedString(c)) break; _reader.move(); str.append(c); c = _reader.current(); diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/StringWriter.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/StringWriter.hpp similarity index 79% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/StringWriter.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/StringWriter.hpp index 42ee640d8..fd5507ea5 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Deserialization/StringWriter.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Deserialization/StringWriter.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/DynamicJsonBuffer.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/DynamicJsonBuffer.hpp similarity index 94% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/DynamicJsonBuffer.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/DynamicJsonBuffer.hpp index 65e744bf2..bdbd5dd90 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/DynamicJsonBuffer.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/DynamicJsonBuffer.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -22,6 +19,7 @@ #endif namespace ArduinoJson { +namespace Internals { class DefaultAllocator { public: void* allocate(size_t size) { @@ -154,6 +152,7 @@ class DynamicJsonBufferBase Block* _head; size_t _nextBlockCapacity; }; +} #if defined(__clang__) #pragma clang diagnostic pop @@ -166,5 +165,6 @@ class DynamicJsonBufferBase // Implements a JsonBuffer with dynamic memory allocation. // You are strongly encouraged to consider using StaticJsonBuffer which is much // more suitable for embedded systems. -typedef DynamicJsonBufferBase DynamicJsonBuffer; +typedef Internals::DynamicJsonBufferBase + DynamicJsonBuffer; } diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArray.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArray.hpp similarity index 82% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArray.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArray.hpp index 27404fb7b..2acd2a1a5 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArray.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArray.hpp @@ -1,16 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "Data/JsonBufferAllocated.hpp" #include "Data/List.hpp" #include "Data/ReferenceType.hpp" -#include "Data/ValueSetter.hpp" +#include "Data/ValueSaver.hpp" #include "JsonVariant.hpp" #include "Serialization/JsonPrintable.hpp" #include "StringTraits/StringTraits.hpp" @@ -29,7 +26,9 @@ namespace ArduinoJson { // Forward declarations class JsonObject; class JsonBuffer; +namespace Internals { class JsonArraySubscript; +} // An array of JsonVariant. // @@ -50,28 +49,26 @@ class JsonArray : public Internals::JsonPrintable, : Internals::List(buffer) {} // Gets the value at the specified index - const JsonArraySubscript operator[](size_t index) const; + const Internals::JsonArraySubscript operator[](size_t index) const; // Gets or sets the value at specified index - JsonArraySubscript operator[](size_t index); + Internals::JsonArraySubscript operator[](size_t index); // Adds the specified value at the end of the array. // // bool add(TValue); // TValue = bool, long, int, short, float, double, RawJson, JsonVariant, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - typename TypeTraits::EnableIf::value, bool>::type add( - const T &value) { + bool add(const T &value) { return add_impl(value); } // // bool add(TValue); - // TValue = const char*, const char[N], const FlashStringHelper* + // TValue = char*, const char*, const FlashStringHelper* template - bool add(const T *value) { - return add_impl(value); + bool add(T *value) { + return add_impl(value); } // // bool add(TValue value, uint8_t decimals); @@ -84,28 +81,25 @@ class JsonArray : public Internals::JsonPrintable, // Sets the value at specified index. // - // bool add(size_t index, TValue); + // bool add(size_t index, const TValue&); // TValue = bool, long, int, short, float, double, RawJson, JsonVariant, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - typename TypeTraits::EnableIf::value, bool>::type set( - size_t index, const T &value) { + bool set(size_t index, const T &value) { return set_impl(index, value); } // // bool add(size_t index, TValue); - // TValue = const char*, const char[N], const FlashStringHelper* + // TValue = char*, const char*, const FlashStringHelper* template - bool set(size_t index, const T *value) { - return set_impl(index, value); + bool set(size_t index, T *value) { + return set_impl(index, value); } // // bool set(size_t index, TValue value, uint8_t decimals); // TValue = float, double template - typename TypeTraits::EnableIf::value, - bool>::type + typename Internals::EnableIf::value, bool>::type set(size_t index, T value, uint8_t decimals) { return set_impl(index, JsonVariant(value, decimals)); } @@ -211,14 +205,14 @@ class JsonArray : public Internals::JsonPrintable, bool set_impl(size_t index, TValueRef value) { iterator it = begin() += index; if (it == end()) return false; - return Internals::ValueSetter::set(_buffer, *it, value); + return Internals::ValueSaver::save(_buffer, *it, value); } template bool add_impl(TValueRef value) { iterator it = Internals::List::add(); if (it == end()) return false; - return Internals::ValueSetter::set(_buffer, *it, value); + return Internals::ValueSaver::save(_buffer, *it, value); } }; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArrayImpl.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArrayImpl.hpp similarity index 75% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArrayImpl.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArrayImpl.hpp index 6ebd39baa..924b7ea7a 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArrayImpl.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArrayImpl.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArraySubscript.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArraySubscript.hpp similarity index 69% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArraySubscript.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArraySubscript.hpp index 5bd6208a5..afb4dc1ec 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonArraySubscript.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonArraySubscript.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -16,6 +13,7 @@ #endif namespace ArduinoJson { +namespace Internals { class JsonArraySubscript : public JsonVariantBase { public: FORCE_INLINE JsonArraySubscript(JsonArray& array, size_t index) @@ -28,10 +26,9 @@ class JsonArraySubscript : public JsonVariantBase { // Replaces the value // - // operator=(TValue) + // operator=(const TValue&) // TValue = bool, long, int, short, float, double, RawJson, JsonVariant, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template FORCE_INLINE JsonArraySubscript& operator=(const T& src) { _array.set(_index, src); @@ -39,9 +36,9 @@ class JsonArraySubscript : public JsonVariantBase { } // // operator=(TValue) - // TValue = const char*, const char[N], const FlashStringHelper* + // TValue = char*, const char*, const FlashStringHelper* template - FORCE_INLINE JsonArraySubscript& operator=(const T* src) { + FORCE_INLINE JsonArraySubscript& operator=(T* src) { _array.set(_index, src); return *this; } @@ -51,7 +48,7 @@ class JsonArraySubscript : public JsonVariantBase { } template - FORCE_INLINE typename Internals::JsonVariantAs::type as() const { + FORCE_INLINE typename JsonVariantAs::type as() const { return _array.get(_index); } @@ -62,19 +59,18 @@ class JsonArraySubscript : public JsonVariantBase { // Replaces the value // - // bool set(TValue) + // bool set(const TValue&) // TValue = bool, long, int, short, float, double, RawJson, JsonVariant, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template FORCE_INLINE bool set(const TValue& value) { return _array.set(_index, value); } // // bool set(TValue) - // TValue = const char*, const char[N], const FlashStringHelper* + // TValue = char*, const char*, const FlashStringHelper* template - FORCE_INLINE bool set(const TValue* value) { + FORCE_INLINE bool set(TValue* value) { return _array.set(_index, value); } // @@ -91,21 +87,6 @@ class JsonArraySubscript : public JsonVariantBase { const size_t _index; }; -#if ARDUINOJSON_ENABLE_STD_STREAM -inline std::ostream& operator<<(std::ostream& os, - const JsonArraySubscript& source) { - return source.printTo(os); -} -#endif - -inline JsonArraySubscript JsonArray::operator[](size_t index) { - return JsonArraySubscript(*this, index); -} - -inline const JsonArraySubscript JsonArray::operator[](size_t index) const { - return JsonArraySubscript(*const_cast(this), index); -} - template inline JsonArraySubscript JsonVariantSubscripts::operator[]( size_t index) { @@ -118,7 +99,23 @@ inline const JsonArraySubscript JsonVariantSubscripts::operator[]( return impl()->template as()[index]; } -} // namespace ArduinoJson +#if ARDUINOJSON_ENABLE_STD_STREAM +inline std::ostream& operator<<(std::ostream& os, + const JsonArraySubscript& source) { + return source.printTo(os); +} +#endif +} + +inline Internals::JsonArraySubscript JsonArray::operator[](size_t index) { + return Internals::JsonArraySubscript(*this, index); +} + +inline const Internals::JsonArraySubscript JsonArray::operator[]( + size_t index) const { + return Internals::JsonArraySubscript(*const_cast(this), index); +} +} #ifdef _MSC_VER #pragma warning(pop) diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBuffer.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBuffer.hpp similarity index 74% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBuffer.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBuffer.hpp index 06bda0ef4..26101e086 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBuffer.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBuffer.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -41,20 +38,21 @@ class JsonBuffer : Internals::NonCopyable { // Duplicates a string // - // char* strdup(TValue); + // const char* strdup(TValue); // TValue = const std::string&, const String&, template - typename TypeTraits::EnableIf::value, - char *>::type - strdup(const TString &src) { + DEPRECATED("char* are duplicated, you don't need strdup() anymore") + typename Internals::EnableIf::value, + const char *>::type strdup(const TString &src) { return Internals::StringTraits::duplicate(src, this); } // - // char* strdup(TValue); - // TValue = const char*, const char[N], const FlashStringHelper* + // const char* strdup(TValue); + // TValue = char*, const char*, const FlashStringHelper* template - char *strdup(const TString *src) { - return Internals::StringTraits::duplicate(src, this); + DEPRECATED("char* are duplicated, you don't need strdup() anymore") + const char *strdup(TString *src) { + return Internals::StringTraits::duplicate(src, this); } // Allocates n bytes in the JsonBuffer. diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBufferBase.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBufferBase.hpp similarity index 88% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBufferBase.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBufferBase.hpp index 480cd8307..1e771bfdb 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBufferBase.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBufferBase.hpp @@ -1,15 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "Deserialization/JsonParser.hpp" namespace ArduinoJson { +namespace Internals { template class JsonBufferBase : public JsonBuffer { public: @@ -28,8 +26,8 @@ class JsonBufferBase : public JsonBuffer { // JsonArray& parseArray(TString); // TString = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - JsonArray &>::type + typename Internals::EnableIf::value, + JsonArray &>::type parseArray(const TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseArray(); @@ -65,8 +63,8 @@ class JsonBufferBase : public JsonBuffer { // JsonObject& parseObject(TString); // TString = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - JsonObject &>::type + typename Internals::EnableIf::value, + JsonObject &>::type parseObject(const TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseObject(); @@ -94,8 +92,8 @@ class JsonBufferBase : public JsonBuffer { // JsonVariant parse(TString); // TString = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - JsonVariant>::type + typename Internals::EnableIf::value, + JsonVariant>::type parse(const TString &json, uint8_t nestingLimit = ARDUINOJSON_DEFAULT_NESTING_LIMIT) { return Internals::makeParser(that(), json, nestingLimit).parseVariant(); @@ -126,3 +124,4 @@ class JsonBufferBase : public JsonBuffer { } }; } +} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBufferImpl.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBufferImpl.hpp similarity index 72% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBufferImpl.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBufferImpl.hpp index 98d5de595..cdea374bb 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonBufferImpl.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonBufferImpl.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObject.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObject.hpp similarity index 57% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObject.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObject.hpp index a3e30ab27..caf698a3e 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObject.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObject.hpp @@ -1,16 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "Data/JsonBufferAllocated.hpp" #include "Data/List.hpp" #include "Data/ReferenceType.hpp" -#include "Data/ValueSetter.hpp" +#include "Data/ValueSaver.hpp" #include "JsonPair.hpp" #include "Serialization/JsonPrintable.hpp" #include "StringTraits/StringTraits.hpp" @@ -29,6 +26,10 @@ namespace ArduinoJson { // Forward declarations class JsonArray; class JsonBuffer; +namespace Internals { +template +class JsonObjectSubscript; +} // A dictionary of JsonVariant indexed by string (char*) // @@ -45,25 +46,24 @@ class JsonObject : public Internals::JsonPrintable, // Create an empty JsonArray attached to the specified JsonBuffer. // You should not use this constructor directly. // Instead, use JsonBuffer::createObject() or JsonBuffer.parseObject(). - explicit JsonObject(JsonBuffer* buffer) throw() - : Internals::List(buffer) {} + explicit JsonObject(JsonBuffer* buffer) throw() + : Internals::List(buffer) {} // Gets or sets the value associated with the specified key. // // JsonObjectSubscript operator[](TKey) // TKey = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - JsonObjectSubscript >::type - operator[](const TString& key) { - return JsonObjectSubscript(*this, key); + Internals::JsonObjectSubscript operator[]( + const TString& key) { + return Internals::JsonObjectSubscript(*this, key); } // // JsonObjectSubscript operator[](TKey) - // TKey = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, char[], const char[N], const FlashStringHelper* template - JsonObjectSubscript operator[](const TString* key) { - return JsonObjectSubscript(*this, key); + Internals::JsonObjectSubscript operator[](TString* key) { + return Internals::JsonObjectSubscript(*this, key); } // Gets the value associated with the specified key. @@ -71,21 +71,19 @@ class JsonObject : public Internals::JsonPrintable, // const JsonObjectSubscript operator[](TKey) const; // TKey = const std::string&, const String& template - typename TypeTraits::EnableIf< - !TypeTraits::IsArray::value, - const JsonObjectSubscript >::type - operator[](const TString& key) const { - return JsonObjectSubscript(*const_cast(this), - key); + const Internals::JsonObjectSubscript operator[]( + const TString& key) const { + return Internals::JsonObjectSubscript( + *const_cast(this), key); } // // const JsonObjectSubscript operator[](TKey) const; // TKey = const char*, const char[N], const FlashStringHelper* template - const JsonObjectSubscript operator[]( - const TString* key) const { - return JsonObjectSubscript(*const_cast(this), - key); + const Internals::JsonObjectSubscript operator[]( + TString* key) const { + return Internals::JsonObjectSubscript( + *const_cast(this), key); } // Sets the specified key with the specified value. @@ -93,43 +91,35 @@ class JsonObject : public Internals::JsonPrintable, // bool set(TKey, TValue); // TKey = const std::string&, const String& // TValue = bool, long, int, short, float, double, RawJson, JsonVariant, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - typename TypeTraits::EnableIf::value && - !TypeTraits::IsArray::value, - bool>::type - set(const TString& key, const TValue& value) { + bool set(const TString& key, const TValue& value) { return set_impl(key, value); } // // bool set(TKey, TValue); // TKey = const std::string&, const String& - // TValue = const char*, const char[N], const FlashStringHelper* + // TValue = char*, const char*, const FlashStringHelper* template - typename TypeTraits::EnableIf::value, - bool>::type - set(const TString& key, const TValue* value) { - return set_impl(key, value); + bool set(const TString& key, TValue* value) { + return set_impl(key, value); } // - // bool set(TKey, TValue); - // TKey = const char*, const char[N], const FlashStringHelper* + // bool set(TKey, const TValue&); + // TKey = char*, const char*, const FlashStringHelper* // TValue = bool, long, int, short, float, double, RawJson, JsonVariant, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - typename TypeTraits::EnableIf::value, bool>::type - set(const TString* key, const TValue& value) { - return set_impl(key, value); + bool set(TString* key, const TValue& value) { + return set_impl(key, value); } // // bool set(TKey, TValue); - // TKey = const char*, const char[N], const FlashStringHelper* - // TValue = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, const FlashStringHelper* + // TValue = char*, const char*, const FlashStringHelper* template - bool set(const TString* key, const TValue* value) { - return set_impl(key, value); + bool set(TString* key, TValue* value) { + return set_impl(key, value); } // // bool set(TKey, TValue, uint8_t decimals); @@ -137,50 +127,43 @@ class JsonObject : public Internals::JsonPrintable, // TValue = float, double template DEPRECATED("Second argument is not supported anymore") - typename TypeTraits::EnableIf::value && - !TypeTraits::IsArray::value, - bool>::type + typename Internals::EnableIf::value, + bool>::type set(const TString& key, TValue value, uint8_t) { return set_impl(key, JsonVariant(value)); } // // bool set(TKey, TValue, uint8_t decimals); - // TKey = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, const FlashStringHelper* // TValue = float, double template DEPRECATED("Second argument is not supported anymore") - typename TypeTraits::EnableIf::value, - bool>::type - set(const TString* key, TValue value, uint8_t) { - return set_impl(key, - JsonVariant(value)); + typename Internals::EnableIf::value, + bool>::type + set(TString* key, TValue value, uint8_t) { + return set_impl(key, JsonVariant(value)); } // Gets the value associated with the specified key. // - // TValue get(TKey); + // TValue get(TKey) const; // TKey = const std::string&, const String& // TValue = bool, char, long, int, short, float, double, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - typename TypeTraits::EnableIf< - !TypeTraits::IsArray::value, - typename Internals::JsonVariantAs::type>::type - get(const TString& key) const { + typename Internals::JsonVariantAs::type get( + const TString& key) const { return get_impl(key); } // - // TValue get(TKey); - // TKey = const char*, const char[N], const FlashStringHelper* + // TValue get(TKey) const; + // TKey = char*, const char*, const FlashStringHelper* // TValue = bool, char, long, int, short, float, double, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - typename Internals::JsonVariantAs::type get( - const TString* key) const { - return get_impl(key); + typename Internals::JsonVariantAs::type get(TString* key) const { + return get_impl(key); } // Checks the type of the value associated with the specified key. @@ -189,23 +172,19 @@ class JsonObject : public Internals::JsonPrintable, // bool is(TKey) const; // TKey = const std::string&, const String& // TValue = bool, char, long, int, short, float, double, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - typename TypeTraits::EnableIf::value, - bool>::type - is(const TString& key) const { + bool is(const TString& key) const { return is_impl(key); } // // bool is(TKey) const; - // TKey = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, const FlashStringHelper* // TValue = bool, char, long, int, short, float, double, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - bool is(const TString* key) const { - return is_impl(key); + bool is(TString* key) const { + return is_impl(key); } // Creates and adds a JsonArray. @@ -213,16 +192,14 @@ class JsonObject : public Internals::JsonPrintable, // JsonArray& createNestedArray(TKey); // TKey = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - JsonArray&>::type - createNestedArray(const TString& key) { + JsonArray& createNestedArray(const TString& key) { return createNestedArray_impl(key); } // JsonArray& createNestedArray(TKey); - // TKey = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, char[], const char[], const FlashStringHelper* template - JsonArray& createNestedArray(const TString* key) { - return createNestedArray_impl(key); + JsonArray& createNestedArray(TString* key) { + return createNestedArray_impl(key); } // Creates and adds a JsonObject. @@ -230,17 +207,15 @@ class JsonObject : public Internals::JsonPrintable, // JsonObject& createNestedObject(TKey); // TKey = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - JsonObject&>::type - createNestedObject(const TString& key) { + JsonObject& createNestedObject(const TString& key) { return createNestedObject_impl(key); } // // JsonObject& createNestedObject(TKey); - // TKey = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, char[], const char[], const FlashStringHelper* template - JsonObject& createNestedObject(const TString* key) { - return createNestedObject_impl(key); + JsonObject& createNestedObject(TString* key) { + return createNestedObject_impl(key); } // Tells weither the specified key is present and associated with a value. @@ -248,17 +223,15 @@ class JsonObject : public Internals::JsonPrintable, // bool containsKey(TKey); // TKey = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - bool>::type - containsKey(const TString& key) const { + bool containsKey(const TString& key) const { return findKey(key) != end(); } // // bool containsKey(TKey); - // TKey = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, char[], const char[], const FlashStringHelper* template - bool containsKey(const TString* key) const { - return findKey(key) != end(); + bool containsKey(TString* key) const { + return findKey(key) != end(); } // Removes the specified key and the associated value. @@ -266,17 +239,15 @@ class JsonObject : public Internals::JsonPrintable, // void remove(TKey); // TKey = const std::string&, const String& template - typename TypeTraits::EnableIf::value, - void>::type - remove(const TString& key) { + void remove(const TString& key) { remove(findKey(key)); } // // void remove(TKey); - // TKey = const char*, const char[N], const FlashStringHelper* + // TKey = char*, const char*, char[], const char[], const FlashStringHelper* template - void remove(const TString* key) { - remove(findKey(key)); + void remove(TString* key) { + remove(findKey(key)); } // // void remove(iterator) @@ -315,16 +286,22 @@ class JsonObject : public Internals::JsonPrintable, template bool set_impl(TStringRef key, TValueRef value) { + // ignore null key + if (Internals::StringTraits::is_null(key)) return false; + + // search a matching key iterator it = findKey(key); if (it == end()) { + // add the key it = Internals::List::add(); if (it == end()) return false; - bool key_ok = - Internals::ValueSetter::set(_buffer, it->key, key); + Internals::ValueSaver::save(_buffer, it->key, key); if (!key_ok) return false; } - return Internals::ValueSetter::set(_buffer, it->value, value); + + // save the value + return Internals::ValueSaver::save(_buffer, it->value, value); } template @@ -347,5 +324,5 @@ struct JsonVariantDefault { return JsonObject::invalid(); } }; -} -} +} // namespace Internals +} // namespace ArduinoJson diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObjectImpl.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObjectImpl.hpp similarity index 79% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObjectImpl.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObjectImpl.hpp index 9741bfadd..e7689b507 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObjectImpl.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObjectImpl.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObjectSubscript.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObjectSubscript.hpp similarity index 66% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObjectSubscript.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObjectSubscript.hpp index 99dfe7cd0..6ac476370 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonObjectSubscript.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonObjectSubscript.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -17,6 +14,7 @@ #endif namespace ArduinoJson { +namespace Internals { template class JsonObjectSubscript @@ -34,23 +32,20 @@ class JsonObjectSubscript // Set the specified value // - // operator=(TValue); + // operator=(const TValue&); // TValue = bool, char, long, int, short, float, double, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - FORCE_INLINE - typename TypeTraits::EnableIf::value, - this_type&>::type - operator=(const TValue& src) { + FORCE_INLINE typename EnableIf::value, this_type&>::type + operator=(const TValue& src) { _object.set(_key, src); return *this; } // // operator=(TValue); - // TValue = const char*, const char[N], const FlashStringHelper* + // TValue = char*, const char*, const FlashStringHelper* template - FORCE_INLINE this_type& operator=(const TValue* src) { + FORCE_INLINE this_type& operator=(TValue* src) { _object.set(_key, src); return *this; } @@ -60,7 +55,7 @@ class JsonObjectSubscript } template - FORCE_INLINE typename Internals::JsonVariantAs::type as() const { + FORCE_INLINE typename JsonVariantAs::type as() const { return _object.get(_key); } @@ -71,20 +66,17 @@ class JsonObjectSubscript // Sets the specified value. // - // bool set(TValue); + // bool set(const TValue&); // TValue = bool, char, long, int, short, float, double, RawJson, JsonVariant, - // const std::string&, const String&, - // const JsonArray&, const JsonObject& + // std::string, String, JsonArray, JsonObject template - FORCE_INLINE - typename TypeTraits::EnableIf::value, - bool>::type - set(const TValue& value) { + FORCE_INLINE typename EnableIf::value, bool>::type set( + const TValue& value) { return _object.set(_key, value); } // // bool set(TValue); - // TValue = const char*, const char[N], const FlashStringHelper* + // TValue = char*, const char, const FlashStringHelper* template FORCE_INLINE bool set(const TValue* value) { return _object.set(_key, value); @@ -110,7 +102,8 @@ inline std::ostream& operator<<(std::ostream& os, return source.printTo(os); } #endif -} // namespace ArduinoJson +} +} #ifdef _MSC_VER #pragma warning(pop) diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonPair.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonPair.hpp similarity index 53% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonPair.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonPair.hpp index 5a32601c0..417243045 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonPair.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonPair.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariant.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariant.hpp similarity index 72% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariant.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariant.hpp index 9037d54d1..43c51b770 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariant.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariant.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -39,7 +36,7 @@ class JsonObject; // - a char, short, int or a long (signed or unsigned) // - a string (const char*) // - a reference to a JsonArray or JsonObject -class JsonVariant : public JsonVariantBase { +class JsonVariant : public Internals::JsonVariantBase { template friend class Internals::JsonSerializer; @@ -59,8 +56,8 @@ class JsonVariant : public JsonVariantBase { // JsonVariant(double value); // JsonVariant(float value); template - JsonVariant(T value, typename TypeTraits::EnableIf< - TypeTraits::IsFloatingPoint::value>::type * = 0) { + JsonVariant(T value, typename Internals::EnableIf< + Internals::IsFloatingPoint::value>::type * = 0) { using namespace Internals; _type = JSON_FLOAT; _content.asFloat = static_cast(value); @@ -68,8 +65,8 @@ class JsonVariant : public JsonVariantBase { template DEPRECATED("Second argument is not supported anymore") JsonVariant(T value, uint8_t, - typename TypeTraits::EnableIf< - TypeTraits::IsFloatingPoint::value>::type * = 0) { + typename Internals::EnableIf< + Internals::IsFloatingPoint::value>::type * = 0) { using namespace Internals; _type = JSON_FLOAT; _content.asFloat = static_cast(value); @@ -82,9 +79,11 @@ class JsonVariant : public JsonVariantBase { // JsonVariant(signed long) // JsonVariant(signed char) template - JsonVariant(T value, typename TypeTraits::EnableIf< - TypeTraits::IsSignedIntegral::value || - TypeTraits::IsSame::value>::type * = 0) { + JsonVariant( + T value, + typename Internals::EnableIf::value || + Internals::IsSame::value>::type * = + 0) { using namespace Internals; if (value >= 0) { _type = JSON_POSITIVE_INTEGER; @@ -99,8 +98,8 @@ class JsonVariant : public JsonVariantBase { // JsonVariant(unsigned long) template JsonVariant(T value, - typename TypeTraits::EnableIf< - TypeTraits::IsUnsignedIntegral::value>::type * = 0) { + typename Internals::EnableIf< + Internals::IsUnsignedIntegral::value>::type * = 0) { using namespace Internals; _type = JSON_POSITIVE_INTEGER; _content.asInteger = static_cast(value); @@ -113,14 +112,14 @@ class JsonVariant : public JsonVariantBase { template JsonVariant( const TChar *value, - typename TypeTraits::EnableIf::value>::type * = + typename Internals::EnableIf::value>::type * = 0) { _type = Internals::JSON_STRING; _content.asString = reinterpret_cast(value); } // Create a JsonVariant containing an unparsed string - JsonVariant(RawJson value) { + JsonVariant(Internals::RawJsonString value) { _type = Internals::JSON_UNPARSED; _content.asString = value; } @@ -147,14 +146,13 @@ class JsonVariant : public JsonVariantBase { // unsigned int as() const; // unsigned long as() const; template - const typename TypeTraits::EnableIf::value, T>::type + const typename Internals::EnableIf::value, T>::type as() const { return variantAsInteger(); } // bool as() const template - const typename TypeTraits::EnableIf::value, - T>::type + const typename Internals::EnableIf::value, T>::type as() const { return variantAsInteger() != 0; } @@ -162,8 +160,8 @@ class JsonVariant : public JsonVariantBase { // double as() const; // float as() const; template - const typename TypeTraits::EnableIf::value, - T>::type + const typename Internals::EnableIf::value, + T>::type as() const { return variantAsFloat(); } @@ -171,9 +169,9 @@ class JsonVariant : public JsonVariantBase { // const char* as() const; // const char* as() const; template - typename TypeTraits::EnableIf::value || - TypeTraits::IsSame::value, - const char *>::type + typename Internals::EnableIf::value || + Internals::IsSame::value, + const char *>::type as() const { return variantAsString(); } @@ -181,7 +179,7 @@ class JsonVariant : public JsonVariantBase { // std::string as() const; // String as() const; template - typename TypeTraits::EnableIf::has_append, T>::type + typename Internals::EnableIf::has_append, T>::type as() const { const char *cstr = variantAsString(); if (cstr) return T(cstr); @@ -193,9 +191,9 @@ class JsonVariant : public JsonVariantBase { // JsonArray& as const; // JsonArray& as const; template - typename TypeTraits::EnableIf< - TypeTraits::IsSame::type, - JsonArray>::value, + typename Internals::EnableIf< + Internals::IsSame::type, + JsonArray>::value, JsonArray &>::type as() const { return variantAsArray(); @@ -203,9 +201,9 @@ class JsonVariant : public JsonVariantBase { // // const JsonArray& as const; template - typename TypeTraits::EnableIf< - TypeTraits::IsSame::type, - const JsonArray>::value, + typename Internals::EnableIf< + Internals::IsSame::type, + const JsonArray>::value, const JsonArray &>::type as() const { return variantAsArray(); @@ -214,9 +212,9 @@ class JsonVariant : public JsonVariantBase { // JsonObject& as const; // JsonObject& as const; template - typename TypeTraits::EnableIf< - TypeTraits::IsSame::type, - JsonObject>::value, + typename Internals::EnableIf< + Internals::IsSame::type, + JsonObject>::value, JsonObject &>::type as() const { return variantAsObject(); @@ -225,9 +223,9 @@ class JsonVariant : public JsonVariantBase { // JsonObject& as const; // JsonObject& as const; template - typename TypeTraits::EnableIf< - TypeTraits::IsSame::type, - const JsonObject>::value, + typename Internals::EnableIf< + Internals::IsSame::type, + const JsonObject>::value, const JsonObject &>::type as() const { return variantAsObject(); @@ -235,8 +233,8 @@ class JsonVariant : public JsonVariantBase { // // JsonVariant as const; template - typename TypeTraits::EnableIf::value, - T>::type + typename Internals::EnableIf::value, + T>::type as() const { return *this; } @@ -254,33 +252,34 @@ class JsonVariant : public JsonVariantBase { // bool is() const; // bool is() const; template - typename TypeTraits::EnableIf::value, bool>::type - is() const { + typename Internals::EnableIf::value, bool>::type is() + const { return variantIsInteger(); } // // bool is() const; // bool is() const; template - typename TypeTraits::EnableIf::value, - bool>::type + typename Internals::EnableIf::value, bool>::type is() const { return variantIsFloat(); } // // bool is() const template - typename TypeTraits::EnableIf::value, bool>::type + typename Internals::EnableIf::value, bool>::type is() const { return variantIsBoolean(); } // // bool is() const; // bool is() const; + // bool is() const; template - typename TypeTraits::EnableIf::value || - TypeTraits::IsSame::value, - bool>::type + typename Internals::EnableIf::value || + Internals::IsSame::value || + Internals::StringTraits::has_append, + bool>::type is() const { return variantIsString(); } @@ -289,11 +288,10 @@ class JsonVariant : public JsonVariantBase { // bool is const; // bool is const; template - typename TypeTraits::EnableIf< - TypeTraits::IsSame< - typename TypeTraits::RemoveConst< - typename TypeTraits::RemoveReference::type>::type, - JsonArray>::value, + typename Internals::EnableIf< + Internals::IsSame::type>::type, + JsonArray>::value, bool>::type is() const { return variantIsArray(); @@ -303,11 +301,10 @@ class JsonVariant : public JsonVariantBase { // bool is const; // bool is const; template - typename TypeTraits::EnableIf< - TypeTraits::IsSame< - typename TypeTraits::RemoveConst< - typename TypeTraits::RemoveReference::type>::type, - JsonObject>::value, + typename Internals::EnableIf< + Internals::IsSame::type>::type, + JsonObject>::value, bool>::type is() const { return variantIsObject(); @@ -357,4 +354,4 @@ DEPRECATED("Decimal places are ignored, use the double value instead") inline JsonVariant double_with_n_digits(double value, uint8_t) { return JsonVariant(value); } -} +} // namespace ArduinoJson diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantBase.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantBase.hpp similarity index 59% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantBase.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantBase.hpp index a010e253f..44acf2e14 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantBase.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantBase.hpp @@ -1,23 +1,24 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "JsonVariantCasts.hpp" #include "JsonVariantComparisons.hpp" +#include "JsonVariantOr.hpp" #include "JsonVariantSubscripts.hpp" #include "Serialization/JsonPrintable.hpp" namespace ArduinoJson { +namespace Internals { template -class JsonVariantBase : public Internals::JsonPrintable, +class JsonVariantBase : public JsonPrintable, public JsonVariantCasts, public JsonVariantComparisons, + public JsonVariantOr, public JsonVariantSubscripts, - public TypeTraits::JsonVariantTag {}; + public JsonVariantTag {}; +} } diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantCasts.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantCasts.hpp similarity index 89% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantCasts.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantCasts.hpp index b3b41b4ba..68f5bd7dd 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantCasts.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantCasts.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -11,6 +8,7 @@ #include "Polyfills/attributes.hpp" namespace ArduinoJson { +namespace Internals { template class JsonVariantCasts { @@ -58,3 +56,4 @@ class JsonVariantCasts { } }; } +} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantComparisons.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantComparisons.hpp similarity index 75% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantComparisons.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantComparisons.hpp index eb0ef5c2c..47f9d6322 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantComparisons.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantComparisons.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -12,6 +9,7 @@ #include "TypeTraits/IsVariant.hpp" namespace ArduinoJson { +namespace Internals { template class JsonVariantComparisons { @@ -23,10 +21,8 @@ class JsonVariantComparisons { } template - friend - typename TypeTraits::EnableIf::value, - bool>::type - operator==(TComparand comparand, const JsonVariantComparisons &variant) { + friend typename EnableIf::value, bool>::type + operator==(TComparand comparand, const JsonVariantComparisons &variant) { return variant.equals(comparand); } @@ -37,10 +33,8 @@ class JsonVariantComparisons { } template - friend - typename TypeTraits::EnableIf::value, - bool>::type - operator!=(TComparand comparand, const JsonVariantComparisons &variant) { + friend typename EnableIf::value, bool>::type + operator!=(TComparand comparand, const JsonVariantComparisons &variant) { return !variant.equals(comparand); } @@ -97,7 +91,7 @@ class JsonVariantComparisons { } template - const typename Internals::JsonVariantAs::type as() const { + const typename JsonVariantAs::type as() const { return impl()->template as(); } @@ -107,17 +101,16 @@ class JsonVariantComparisons { } template - typename TypeTraits::EnableIf::value, - bool>::type - equals(const TString &comparand) const { + typename EnableIf::has_equals, bool>::type equals( + const TString &comparand) const { const char *value = as(); - return Internals::StringTraits::equals(comparand, value); + return StringTraits::equals(comparand, value); } template - typename TypeTraits::EnableIf::value && - !TypeTraits::IsString::value, - bool>::type + typename EnableIf::value && + !StringTraits::has_equals, + bool>::type equals(const TComparand &comparand) const { return as() == comparand; } @@ -136,9 +129,11 @@ class JsonVariantComparisons { if (is() && right.template is()) return as() == right.template as(); if (is() && right.template is()) - return strcmp(as(), right.template as()) == 0; + return StringTraits::equals(as(), + right.template as()); return false; } }; -} +} // namespace Internals +} // namespace ArduinoJson diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantImpl.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantImpl.hpp similarity index 87% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantImpl.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantImpl.hpp index eb6a4735d..31f96ce1a 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantImpl.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantImpl.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -61,7 +58,7 @@ inline T JsonVariant::variantAsInteger() const { return T(~_content.asInteger + 1); case JSON_STRING: case JSON_UNPARSED: - return Polyfills::parseInteger(_content.asString); + return parseInteger(_content.asString); default: return T(_content.asFloat); } @@ -89,7 +86,7 @@ inline T JsonVariant::variantAsFloat() const { return -static_cast(_content.asInteger); case JSON_STRING: case JSON_UNPARSED: - return Polyfills::parseFloat(_content.asString); + return parseFloat(_content.asString); default: return static_cast(_content.asFloat); } @@ -109,7 +106,7 @@ inline bool JsonVariant::variantIsInteger() const { using namespace Internals; return _type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER || - (_type == JSON_UNPARSED && Polyfills::isInteger(_content.asString)); + (_type == JSON_UNPARSED && isInteger(_content.asString)); } inline bool JsonVariant::variantIsFloat() const { @@ -117,7 +114,7 @@ inline bool JsonVariant::variantIsFloat() const { return _type == JSON_FLOAT || _type == JSON_POSITIVE_INTEGER || _type == JSON_NEGATIVE_INTEGER || - (_type == JSON_UNPARSED && Polyfills::isFloat(_content.asString)); + (_type == JSON_UNPARSED && isFloat(_content.asString)); } #if ARDUINOJSON_ENABLE_STD_STREAM diff --git a/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantOr.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantOr.hpp new file mode 100644 index 000000000..d8022fcb2 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantOr.hpp @@ -0,0 +1,52 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +#include "Data/JsonVariantAs.hpp" +#include "Polyfills/attributes.hpp" +#include "TypeTraits/EnableIf.hpp" +#include "TypeTraits/IsIntegral.hpp" + +namespace ArduinoJson { +namespace Internals { + +template +class JsonVariantOr { + public: + // Returns the default value if the JsonVariant is undefined of incompatible + template + typename EnableIf::value, T>::type operator|( + const T &defaultValue) const { + if (impl()->template is()) + return impl()->template as(); + else + return defaultValue; + } + + // Returns the default value if the JsonVariant is undefined of incompatible + // Special case for string: null is treated as undefined + const char *operator|(const char *defaultValue) const { + const char *value = impl()->template as(); + return value ? value : defaultValue; + } + + // Returns the default value if the JsonVariant is undefined of incompatible + // Special case for integers: we also accept double + template + typename EnableIf::value, Integer>::type operator|( + const Integer &defaultValue) const { + if (impl()->template is()) + return impl()->template as(); + else + return defaultValue; + } + + private: + const TImpl *impl() const { + return static_cast(this); + } +}; +} // namespace Internals +} // namespace ArduinoJson diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantSubscripts.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantSubscripts.hpp similarity index 70% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantSubscripts.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantSubscripts.hpp index 2143236a6..279ee019f 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/JsonVariantSubscripts.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/JsonVariantSubscripts.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -13,6 +10,7 @@ #include "TypeTraits/EnableIf.hpp" namespace ArduinoJson { +namespace Internals { // Forward declarations. class JsonArraySubscript; @@ -44,19 +42,18 @@ class JsonVariantSubscripts { // const JsonObjectSubscript operator[](TKey) const; // TKey = const std::string&, const String& template - FORCE_INLINE typename TypeTraits::EnableIf< - Internals::StringTraits::has_equals, - const JsonObjectSubscript >::type - operator[](const TString &key) const { + FORCE_INLINE + typename EnableIf::has_equals, + const JsonObjectSubscript >::type + operator[](const TString &key) const { return impl()->template as()[key]; } // // const JsonObjectSubscript operator[](TKey) const; // TKey = const std::string&, const String& template - FORCE_INLINE typename TypeTraits::EnableIf< - Internals::StringTraits::has_equals, - JsonObjectSubscript >::type + FORCE_INLINE typename EnableIf::has_equals, + JsonObjectSubscript >::type operator[](const TString &key) { return impl()->template as()[key]; } @@ -64,9 +61,8 @@ class JsonVariantSubscripts { // JsonObjectSubscript operator[](TKey); // TKey = const char*, const char[N], const FlashStringHelper* template - FORCE_INLINE typename TypeTraits::EnableIf< - Internals::StringTraits::has_equals, - JsonObjectSubscript >::type + FORCE_INLINE typename EnableIf::has_equals, + JsonObjectSubscript >::type operator[](const TString *key) { return impl()->template as()[key]; } @@ -74,10 +70,10 @@ class JsonVariantSubscripts { // JsonObjectSubscript operator[](TKey); // TKey = const char*, const char[N], const FlashStringHelper* template - FORCE_INLINE typename TypeTraits::EnableIf< - Internals::StringTraits::has_equals, - const JsonObjectSubscript >::type - operator[](const TString *key) const { + FORCE_INLINE + typename EnableIf::has_equals, + const JsonObjectSubscript >::type + operator[](const TString *key) const { return impl()->template as()[key]; } @@ -87,3 +83,4 @@ class JsonVariantSubscripts { } }; } +} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/attributes.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/attributes.hpp similarity index 74% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/attributes.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/attributes.hpp index e4f9406ac..b49091ddc 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/attributes.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/attributes.hpp @@ -1,15 +1,12 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #ifdef _MSC_VER // Visual Studio -#define FORCE_INLINE __forceinline +#define FORCE_INLINE // __forceinline causes C4714 when returning std::string #define NO_INLINE __declspec(noinline) #define DEPRECATED(msg) __declspec(deprecated(msg)) diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/ctype.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/ctype.hpp similarity index 50% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/ctype.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/ctype.hpp index f13e3edf6..2d52703cd 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/ctype.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/ctype.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace Polyfills { +namespace Internals { inline bool isdigit(char c) { return '0' <= c && c <= '9'; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/isFloat.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/isFloat.hpp similarity index 75% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/isFloat.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/isFloat.hpp index f6b9c97d9..973b89fe9 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/isFloat.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/isFloat.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -11,7 +8,7 @@ #include "./ctype.hpp" namespace ArduinoJson { -namespace Polyfills { +namespace Internals { inline bool isFloat(const char* s) { if (!s) return false; diff --git a/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/isInteger.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/isInteger.hpp new file mode 100644 index 000000000..8049079a7 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/isInteger.hpp @@ -0,0 +1,19 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +#include "./ctype.hpp" + +namespace ArduinoJson { +namespace Internals { + +inline bool isInteger(const char* s) { + if (!s || !*s) return false; + if (issign(*s)) s++; + while (isdigit(*s)) s++; + return *s == '\0'; +} +} // namespace Internals +} // namespace ArduinoJson diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/math.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/math.hpp similarity index 52% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/math.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/math.hpp index 9dbd161d6..48773edd2 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/math.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/math.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace Polyfills { +namespace Internals { template bool isNaN(T x) { return x != x; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/parseFloat.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/parseFloat.hpp similarity index 89% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/parseFloat.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/parseFloat.hpp index e5d99f1bf..49b0f6fcd 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/parseFloat.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/parseFloat.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -12,11 +9,11 @@ #include "./math.hpp" namespace ArduinoJson { -namespace Polyfills { +namespace Internals { template inline T parseFloat(const char* s) { - typedef TypeTraits::FloatTraits traits; + typedef FloatTraits traits; typedef typename traits::mantissa_type mantissa_t; typedef typename traits::exponent_type exponent_t; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/parseInteger.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/parseInteger.hpp similarity index 75% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/parseInteger.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/parseInteger.hpp index 023d7bcbd..e8f197494 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Polyfills/parseInteger.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Polyfills/parseInteger.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -13,7 +10,7 @@ #include "./ctype.hpp" namespace ArduinoJson { -namespace Polyfills { +namespace Internals { template T parseInteger(const char *s) { if (!s) return 0; // NULL diff --git a/lib/ArduinoJson-5.13.4/src/ArduinoJson/RawJson.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/RawJson.hpp new file mode 100644 index 000000000..4beb980ee --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/RawJson.hpp @@ -0,0 +1,46 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +namespace ArduinoJson { + +namespace Internals { +// A special type of data that can be used to insert pregenerated JSON portions. +template +class RawJsonString { + public: + explicit RawJsonString(T str) : _str(str) {} + operator T() const { + return _str; + } + + private: + T _str; +}; + +template +struct StringTraits, void> { + static bool is_null(RawJsonString source) { + return StringTraits::is_null(static_cast(source)); + } + + typedef RawJsonString duplicate_t; + + template + static duplicate_t duplicate(RawJsonString source, Buffer* buffer) { + return duplicate_t(StringTraits::duplicate(source, buffer)); + } + + static const bool has_append = false; + static const bool has_equals = false; + static const bool should_duplicate = StringTraits::should_duplicate; +}; +} + +template +inline Internals::RawJsonString RawJson(T str) { + return Internals::RawJsonString(str); +} +} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/DummyPrint.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/DummyPrint.hpp similarity index 64% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/DummyPrint.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/DummyPrint.hpp index 656aa9ed6..9fdf2d6a0 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/DummyPrint.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/DummyPrint.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp similarity index 80% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp index a344588de..41be6392c 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/DynamicStringBuilder.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/FloatParts.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/FloatParts.hpp similarity index 91% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/FloatParts.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/FloatParts.hpp index fa650723d..c14e3b553 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/FloatParts.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/FloatParts.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -59,7 +56,7 @@ struct FloatParts { } static int16_t normalize(TFloat& value) { - typedef TypeTraits::FloatTraits traits; + typedef FloatTraits traits; int16_t powersOf10 = 0; int8_t index = sizeof(TFloat) == 8 ? 8 : 5; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/IndentedPrint.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/IndentedPrint.hpp similarity index 89% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/IndentedPrint.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/IndentedPrint.hpp index 66ca6ac2f..864f9aaa4 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/IndentedPrint.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/IndentedPrint.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonPrintable.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonPrintable.hpp similarity index 80% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonPrintable.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonPrintable.hpp index f33e5584e..43d413a85 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonPrintable.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonPrintable.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -32,9 +29,8 @@ template class JsonPrintable { public: template - typename TypeTraits::EnableIf::value, - size_t>::type - printTo(Print &print) const { + typename EnableIf::has_append, size_t>::type printTo( + Print &print) const { JsonWriter writer(print); JsonSerializer >::serialize(downcast(), writer); return writer.bytesWritten(); @@ -59,8 +55,8 @@ class JsonPrintable { } template - typename TypeTraits::EnableIf::has_append, size_t>::type - printTo(TString &str) const { + typename EnableIf::has_append, size_t>::type printTo( + TString &str) const { DynamicStringBuilder sb(str); return printTo(sb); } @@ -82,15 +78,14 @@ class JsonPrintable { } template - typename TypeTraits::EnableIf::value, - size_t>::type + typename EnableIf::has_append, size_t>::type prettyPrintTo(Print &print) const { IndentedPrint indentedPrint(print); return prettyPrintTo(indentedPrint); } template - typename TypeTraits::EnableIf::has_append, size_t>::type + typename EnableIf::has_append, size_t>::type prettyPrintTo(TString &str) const { DynamicStringBuilder sb(str); return prettyPrintTo(sb); diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonSerializer.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonSerializer.hpp similarity index 79% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonSerializer.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonSerializer.hpp index 86ed73ee1..0cb537f7d 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonSerializer.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonSerializer.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -12,14 +9,15 @@ namespace ArduinoJson { class JsonArray; -class JsonArraySubscript; class JsonObject; -template -class JsonObjectSubscript; class JsonVariant; namespace Internals { +class JsonArraySubscript; +template +class JsonObjectSubscript; + template class JsonSerializer { public: diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp similarity index 94% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp index f544488af..0faae2769 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonSerializerImpl.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonWriter.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonWriter.hpp similarity index 91% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonWriter.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonWriter.hpp index 2d54a2a0b..146d51dcb 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/JsonWriter.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/JsonWriter.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -82,14 +79,14 @@ class JsonWriter { template void writeFloat(TFloat value) { - if (Polyfills::isNaN(value)) return writeRaw("NaN"); + if (isNaN(value)) return writeRaw("NaN"); if (value < 0.0) { writeRaw('-'); value = -value; } - if (Polyfills::isInfinity(value)) return writeRaw("Infinity"); + if (isInfinity(value)) return writeRaw("Infinity"); FloatParts parts(value); diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/Prettyfier.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/Prettyfier.hpp similarity index 93% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/Prettyfier.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/Prettyfier.hpp index 377138b4f..8b4f0d2eb 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/Prettyfier.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/Prettyfier.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/StaticStringBuilder.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/StaticStringBuilder.hpp similarity index 77% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/StaticStringBuilder.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/StaticStringBuilder.hpp index 2df932fd4..9617bbd97 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/StaticStringBuilder.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/StaticStringBuilder.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp similarity index 77% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp index 9c2f86fd7..60f0af4a3 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/Serialization/StreamPrintAdapter.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StaticJsonBuffer.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StaticJsonBuffer.hpp similarity index 89% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/StaticJsonBuffer.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/StaticJsonBuffer.hpp index 8eaa4bb53..267d9d018 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StaticJsonBuffer.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StaticJsonBuffer.hpp @@ -1,15 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "JsonBufferBase.hpp" namespace ArduinoJson { +namespace Internals { class StaticJsonBufferBase : public JsonBufferBase { public: @@ -93,6 +91,7 @@ class StaticJsonBufferBase : public JsonBufferBase { size_t _capacity; size_t _size; }; +} #if defined(__clang__) #pragma clang diagnostic push @@ -108,9 +107,10 @@ class StaticJsonBufferBase : public JsonBufferBase { // The template paramenter CAPACITY specifies the capacity of the buffer in // bytes. template -class StaticJsonBuffer : public StaticJsonBufferBase { +class StaticJsonBuffer : public Internals::StaticJsonBufferBase { public: - explicit StaticJsonBuffer() : StaticJsonBufferBase(_buffer, CAPACITY) {} + explicit StaticJsonBuffer() + : Internals::StaticJsonBufferBase(_buffer, CAPACITY) {} private: char _buffer[CAPACITY]; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/ArduinoStream.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/ArduinoStream.hpp similarity index 64% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/ArduinoStream.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/ArduinoStream.hpp index 87d1672d5..5db0852b8 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/ArduinoStream.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/ArduinoStream.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -46,14 +43,17 @@ struct ArduinoStreamTraits { return c; } }; + + static const bool has_append = false; + static const bool has_equals = false; }; template -struct StringTraits::type>::value>::type> +struct StringTraits< + TStream, + // match any type that is derived from Stream: + typename EnableIf< + IsBaseOf::type>::value>::type> : ArduinoStreamTraits {}; } } diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/CharPointer.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/CharPointer.hpp similarity index 54% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/CharPointer.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/CharPointer.hpp index 203e3924e..98896ccfb 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/CharPointer.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/CharPointer.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -33,26 +30,35 @@ struct CharPointerTraits { }; static bool equals(const TChar* str, const char* expected) { - return strcmp(reinterpret_cast(str), expected) == 0; + const char* actual = reinterpret_cast(str); + if (!actual || !expected) return actual == expected; + return strcmp(actual, expected) == 0; } + static bool is_null(const TChar* str) { + return !str; + } + + typedef const char* duplicate_t; + template - static char* duplicate(const TChar* str, Buffer* buffer) { + static duplicate_t duplicate(const TChar* str, Buffer* buffer) { if (!str) return NULL; size_t size = strlen(reinterpret_cast(str)) + 1; void* dup = buffer->alloc(size); if (dup != NULL) memcpy(dup, str, size); - return static_cast(dup); + return static_cast(dup); } static const bool has_append = false; static const bool has_equals = true; - static const bool should_duplicate = false; + static const bool should_duplicate = !IsConst::value; }; +// char*, unsigned char*, signed char* +// const char*, const unsigned char*, const signed char* template -struct StringTraits::value>::type> +struct StringTraits::value>::type> : CharPointerTraits {}; -} -} +} // namespace Internals +} // namespace ArduinoJson diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/FlashString.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/FlashString.hpp similarity index 64% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/FlashString.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/FlashString.hpp index 37e36b8d2..0701b9ba2 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/FlashString.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/FlashString.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -34,23 +31,31 @@ struct StringTraits { }; static bool equals(const __FlashStringHelper* str, const char* expected) { - return strcmp_P(expected, (const char*)str) == 0; + const char* actual = reinterpret_cast(str); + if (!actual || !expected) return actual == expected; + return strcmp_P(expected, actual) == 0; } + static bool is_null(const __FlashStringHelper* str) { + return !str; + } + + typedef const char* duplicate_t; + template - static char* duplicate(const __FlashStringHelper* str, Buffer* buffer) { + static duplicate_t duplicate(const __FlashStringHelper* str, Buffer* buffer) { if (!str) return NULL; size_t size = strlen_P((const char*)str) + 1; void* dup = buffer->alloc(size); if (dup != NULL) memcpy_P(dup, (const char*)str, size); - return static_cast(dup); + return static_cast(dup); } static const bool has_append = false; static const bool has_equals = true; static const bool should_duplicate = true; }; -} -} +} // namespace Internals +} // namespace ArduinoJson #endif diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StdStream.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StdStream.hpp similarity index 63% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StdStream.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StdStream.hpp index 35049d941..227c74406 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StdStream.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StdStream.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -45,14 +42,17 @@ struct StdStreamTraits { return _stream.eof() ? '\0' : static_cast(_stream.get()); } }; + + static const bool has_append = false; + static const bool has_equals = false; }; template -struct StringTraits::type>::value>::type> +struct StringTraits< + TStream, + // match any type that is derived from std::istream: + typename EnableIf::type>::value>::type> : StdStreamTraits {}; } } diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StdString.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StdString.hpp similarity index 70% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StdString.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StdString.hpp index 959c47466..35f4461d8 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StdString.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StdString.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -22,13 +19,20 @@ namespace Internals { template struct StdStringTraits { + typedef const char* duplicate_t; + template - static char* duplicate(const TString& str, Buffer* buffer) { + static duplicate_t duplicate(const TString& str, Buffer* buffer) { if (!str.c_str()) return NULL; // <- Arduino string can return NULL size_t size = str.length() + 1; void* dup = buffer->alloc(size); if (dup != NULL) memcpy(dup, str.c_str(), size); - return static_cast(dup); + return static_cast(dup); + } + + static bool is_null(const TString& str) { + // Arduino's String::c_str() can return NULL + return !str.c_str(); } struct Reader : CharPointerTraits::Reader { @@ -36,7 +40,10 @@ struct StdStringTraits { }; static bool equals(const TString& str, const char* expected) { - return 0 == strcmp(str.c_str(), expected); + // Arduino's String::c_str() can return NULL + const char* actual = str.c_str(); + if (!actual || !expected) return actual == expected; + return 0 == strcmp(actual, expected); } static void append(TString& str, char c) { @@ -64,7 +71,7 @@ struct StringTraits : StdStringTraits { template <> struct StringTraits : StdStringTraits {}; #endif -} -} +} // namespace Internals +} // namespace ArduinoJson #endif diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StringTraits.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StringTraits.hpp similarity index 55% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StringTraits.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StringTraits.hpp index 55bacca26..dd5694b2e 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/StringTraits/StringTraits.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/StringTraits/StringTraits.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -12,13 +9,17 @@ #include "../TypeTraits/EnableIf.hpp" #include "../TypeTraits/IsBaseOf.hpp" #include "../TypeTraits/IsChar.hpp" +#include "../TypeTraits/IsConst.hpp" #include "../TypeTraits/RemoveReference.hpp" namespace ArduinoJson { namespace Internals { template -struct StringTraits {}; +struct StringTraits { + static const bool has_append = false; + static const bool has_equals = false; +}; template struct StringTraits : StringTraits {}; @@ -33,18 +34,3 @@ struct StringTraits : StringTraits {}; #include "FlashString.hpp" #include "StdStream.hpp" #include "StdString.hpp" - -namespace ArduinoJson { -namespace TypeTraits { -template -struct IsString { - static const bool value = false; -}; - -template -struct IsString::has_equals>::type> { - static const bool value = Internals::StringTraits::has_equals; -}; -} -} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/EnableIf.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/EnableIf.hpp similarity index 58% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/EnableIf.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/EnableIf.hpp index 654b308e6..83fc5e07f 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/EnableIf.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/EnableIf.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that return the type T if Condition is true. template diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/FloatTraits.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/FloatTraits.hpp similarity index 68% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/FloatTraits.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/FloatTraits.hpp index a52e1e879..648cc82fd 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/FloatTraits.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/FloatTraits.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -13,7 +10,7 @@ #include "../Polyfills/math.hpp" namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { template struct FloatTraits {}; @@ -47,28 +44,46 @@ struct FloatTraits { static T positiveBinaryPowerOfTen(int index) { static T factors[] = { - 1e1, 1e2, 1e4, 1e8, 1e16, 1e32, - // workaround to support platforms with single precision literals - forge(0x4D384F03, 0xE93FF9F5), forge(0x5A827748, 0xF9301D32), - forge(0x75154FDD, 0x7F73BF3C)}; + 1e1, + 1e2, + 1e4, + 1e8, + 1e16, + forge(0x4693B8B5, 0xB5056E17), // 1e32 + forge(0x4D384F03, 0xE93FF9F5), // 1e64 + forge(0x5A827748, 0xF9301D32), // 1e128 + forge(0x75154FDD, 0x7F73BF3C) // 1e256 + }; return factors[index]; } static T negativeBinaryPowerOfTen(int index) { static T factors[] = { - 1e-1, 1e-2, 1e-4, 1e-8, 1e-16, 1e-32, - // workaround to support platforms with single precision literals - forge(0x32A50FFD, 0x44F4A73D), forge(0x255BBA08, 0xCF8C979D), - forge(0x0AC80628, 0x64AC6F43)}; + forge(0x3FB99999, 0x9999999A), // 1e-1 + forge(0x3F847AE1, 0x47AE147B), // 1e-2 + forge(0x3F1A36E2, 0xEB1C432D), // 1e-4 + forge(0x3E45798E, 0xE2308C3A), // 1e-8 + forge(0x3C9CD2B2, 0x97D889BC), // 1e-16 + forge(0x3949F623, 0xD5A8A733), // 1e-32 + forge(0x32A50FFD, 0x44F4A73D), // 1e-64 + forge(0x255BBA08, 0xCF8C979D), // 1e-128 + forge(0x0AC80628, 0x64AC6F43) // 1e-256 + }; return factors[index]; } static T negativeBinaryPowerOfTenPlusOne(int index) { static T factors[] = { - 1e0, 1e-1, 1e-3, 1e-7, 1e-15, 1e-31, - // workaround to support platforms with single precision literals - forge(0x32DA53FC, 0x9631D10D), forge(0x25915445, 0x81B7DEC2), - forge(0x0AFE07B2, 0x7DD78B14)}; + 1e0, + forge(0x3FB99999, 0x9999999A), // 1e-1 + forge(0x3F50624D, 0xD2F1A9FC), // 1e-3 + forge(0x3E7AD7F2, 0x9ABCAF48), // 1e-7 + forge(0x3CD203AF, 0x9EE75616), // 1e-15 + forge(0x398039D6, 0x65896880), // 1e-31 + forge(0x32DA53FC, 0x9631D10D), // 1e-63 + forge(0x25915445, 0x81B7DEC2), // 1e-127 + forge(0x0AFE07B2, 0x7DD78B14) // 1e-255 + }; return factors[index]; } @@ -80,6 +95,9 @@ struct FloatTraits { return forge(0x7ff00000, 0x00000000); } + // constructs a double floating point values from its binary representation + // we use this function to workaround platforms with single precision literals + // (for example, when -fsingle-precision-constant is passed to GCC) static T forge(uint32_t msb, uint32_t lsb) { union { uint64_t integerBits; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsArray.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsArray.hpp similarity index 67% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsArray.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsArray.hpp index 713808aed..259923115 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsArray.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsArray.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that return the type T without the const modifier template diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsBaseOf.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsBaseOf.hpp similarity index 73% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsBaseOf.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsBaseOf.hpp index 9e68debc3..bf24e965e 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsBaseOf.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsBaseOf.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that returns true if Derived inherits from TBase is an // integral type. diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsChar.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsChar.hpp similarity index 69% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsChar.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsChar.hpp index bd1b5fdd5..d97cec213 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsChar.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsChar.hpp @@ -1,16 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "IsSame.hpp" namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that returns true if T is a charater template diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsConst.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsConst.hpp similarity index 61% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsConst.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsConst.hpp index 7ffed8443..512ee5ca0 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsConst.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsConst.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that return the type T without the const modifier template diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp similarity index 60% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp index c04ce2a63..e41a6824c 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsFloatingPoint.hpp @@ -1,16 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "IsSame.hpp" namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that returns true if T is a floating point type template diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsIntegral.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsIntegral.hpp similarity index 50% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsIntegral.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsIntegral.hpp index e34add52e..17ae5f284 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsIntegral.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsIntegral.hpp @@ -1,9 +1,6 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once @@ -12,14 +9,14 @@ #include "IsUnsignedIntegral.hpp" namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that returns true if T is an integral type. template struct IsIntegral { - static const bool value = TypeTraits::IsSignedIntegral::value || - TypeTraits::IsUnsignedIntegral::value || - TypeTraits::IsSame::value; + static const bool value = IsSignedIntegral::value || + IsUnsignedIntegral::value || + IsSame::value; // CAUTION: differs from std::is_integral as it doesn't include bool }; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsSame.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsSame.hpp similarity index 62% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsSame.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsSame.hpp index d96a5b554..06567c93b 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsSame.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsSame.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that returns true if types T and U are the same. template diff --git a/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp new file mode 100644 index 000000000..7334eb9c7 --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsSignedIntegral.hpp @@ -0,0 +1,28 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +#include "../Configuration.hpp" +#include "IsSame.hpp" + +namespace ArduinoJson { +namespace Internals { + +// A meta-function that returns true if T is an integral type. +template +struct IsSignedIntegral { + static const bool value = + IsSame::value || IsSame::value || + IsSame::value || IsSame::value || +#if ARDUINOJSON_USE_LONG_LONG + IsSame::value || +#endif +#if ARDUINOJSON_USE_INT64 + IsSame::value || +#endif + false; +}; +} +} diff --git a/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp new file mode 100644 index 000000000..938423f5c --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsUnsignedIntegral.hpp @@ -0,0 +1,28 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +#include "../Configuration.hpp" +#include "IsSame.hpp" + +namespace ArduinoJson { +namespace Internals { + +// A meta-function that returns true if T is an integral type. +template +struct IsUnsignedIntegral { + static const bool value = + IsSame::value || IsSame::value || + IsSame::value || IsSame::value || +#if ARDUINOJSON_USE_LONG_LONG + IsSame::value || +#endif +#if ARDUINOJSON_USE_INT64 + IsSame::value || +#endif + false; +}; +} +} diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsVariant.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsVariant.hpp similarity index 50% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsVariant.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsVariant.hpp index 8297cf5cd..f8b299f7a 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/IsVariant.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/IsVariant.hpp @@ -1,16 +1,13 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once #include "IsBaseOf.hpp" namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { class JsonVariantTag {}; diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/RemoveConst.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/RemoveConst.hpp similarity index 59% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/RemoveConst.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/RemoveConst.hpp index 0186234ef..39d4cb5a5 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/RemoveConst.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/RemoveConst.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that return the type T without the const modifier template diff --git a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/RemoveReference.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/RemoveReference.hpp similarity index 60% rename from lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/RemoveReference.hpp rename to lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/RemoveReference.hpp index 4968997e7..395a12889 100644 --- a/lib/ArduinoJson-5.11.2/src/ArduinoJson/TypeTraits/RemoveReference.hpp +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/TypeTraits/RemoveReference.hpp @@ -1,14 +1,11 @@ -// Copyright Benoit Blanchon 2014-2017 +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 // MIT License -// -// Arduino JSON library -// https://bblanchon.github.io/ArduinoJson/ -// If you like this project, please add a star! #pragma once namespace ArduinoJson { -namespace TypeTraits { +namespace Internals { // A meta-function that return the type T without the reference modifier. template diff --git a/lib/ArduinoJson-5.13.4/src/ArduinoJson/version.hpp b/lib/ArduinoJson-5.13.4/src/ArduinoJson/version.hpp new file mode 100644 index 000000000..34c78461d --- /dev/null +++ b/lib/ArduinoJson-5.13.4/src/ArduinoJson/version.hpp @@ -0,0 +1,10 @@ +// ArduinoJson - arduinojson.org +// Copyright Benoit Blanchon 2014-2018 +// MIT License + +#pragma once + +#define ARDUINOJSON_VERSION "5.13.4" +#define ARDUINOJSON_VERSION_MAJOR 5 +#define ARDUINOJSON_VERSION_MINOR 13 +#define ARDUINOJSON_VERSION_REVISION 4