From a14074fd6d2c30d19b8315bcab0061e40447dddc Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 3 Dec 2024 12:20:47 +0100 Subject: [PATCH] Update libs --- lib/ArduinoJson/CHANGELOG.md | 7 ++ lib/ArduinoJson/CMakeLists.txt | 2 +- lib/ArduinoJson/appveyor.yml | 2 +- lib/ArduinoJson/extras/tests/CMakeLists.txt | 9 +- .../extras/tests/Deprecated/containsKey.cpp | 38 +++++++- .../extras/tests/FailingBuilds/CMakeLists.txt | 28 +++--- .../FailingBuilds/deserialize_object.cpp | 12 +++ .../extras/tests/JsonDocument/CMakeLists.txt | 1 + .../tests/JsonDocument/ElementProxy.cpp | 40 +++++++- .../extras/tests/JsonDocument/MemberProxy.cpp | 28 +++++- .../extras/tests/JsonDocument/add.cpp | 18 ++++ .../extras/tests/JsonDocument/set.cpp | 79 +++++++++++++++ .../extras/tests/JsonDocument/subscript.cpp | 47 +++++++-- .../extras/tests/JsonObject/subscript.cpp | 12 ++- .../tests/JsonObjectConst/subscript.cpp | 14 ++- .../extras/tests/JsonVariant/add.cpp | 12 +++ .../extras/tests/JsonVariant/remove.cpp | 17 ++++ .../tests/JsonVariant/stl_containers.cpp | 2 +- .../extras/tests/JsonVariant/subscript.cpp | 17 +++- .../tests/JsonVariantConst/subscript.cpp | 35 ++++--- .../extras/tests/Misc/CMakeLists.txt | 1 + .../extras/tests/Misc/StringAdapters.cpp | 95 ++++++++++++------- .../extras/tests/Misc/custom_string.hpp | 2 +- .../extras/tests/Misc/issue2129.cpp | 55 +++++++++++ lib/ArduinoJson/idf_component.yml | 4 +- lib/ArduinoJson/library.json | 4 +- lib/ArduinoJson/library.properties | 4 +- .../src/ArduinoJson/Array/JsonArray.hpp | 2 +- .../src/ArduinoJson/Array/JsonArrayConst.hpp | 2 +- .../Deserialization/deserialize.hpp | 10 +- .../src/ArduinoJson/Document/JsonDocument.hpp | 11 ++- .../ArduinoJson/Json/PrettyJsonSerializer.hpp | 2 +- .../src/ArduinoJson/Json/TextFormatter.hpp | 2 +- .../src/ArduinoJson/Numbers/FloatParts.hpp | 2 +- .../src/ArduinoJson/Numbers/FloatTraits.hpp | 8 +- .../src/ArduinoJson/Numbers/JsonFloat.hpp | 4 +- .../src/ArduinoJson/Numbers/JsonInteger.hpp | 8 +- .../src/ArduinoJson/Numbers/parseNumber.hpp | 6 +- .../src/ArduinoJson/Object/JsonObject.hpp | 8 +- .../ArduinoJson/Object/JsonObjectConst.hpp | 6 +- .../src/ArduinoJson/Polyfills/integer.hpp | 6 +- .../Polyfills/type_traits/conditional.hpp | 4 +- .../Polyfills/type_traits/enable_if.hpp | 2 +- .../type_traits/integral_constant.hpp | 7 +- .../Polyfills/type_traits/is_convertible.hpp | 2 +- .../Polyfills/type_traits/remove_const.hpp | 4 +- .../Polyfills/type_traits/remove_cv.hpp | 8 +- .../type_traits/remove_reference.hpp | 4 +- .../Polyfills/type_traits/type_identity.hpp | 2 +- .../Strings/Adapters/FlashString.hpp | 4 +- .../Strings/Adapters/JsonString.hpp | 2 +- .../Strings/Adapters/RamString.hpp | 20 +--- .../Strings/Adapters/StringObject.hpp | 2 +- .../ArduinoJson/Variant/JsonVariantConst.hpp | 2 +- .../ArduinoJson/Variant/JsonVariantCopier.hpp | 2 +- .../Variant/JsonVariantVisitor.hpp | 2 +- .../Variant/VariantDataVisitor.hpp | 2 +- .../ArduinoJson/Variant/VariantRefBase.hpp | 2 +- .../src/ArduinoJson/Variant/VariantTo.hpp | 6 +- lib/ArduinoJson/src/ArduinoJson/version.hpp | 6 +- src/Config.h | 2 +- src/idf_component.yml | 4 +- 62 files changed, 561 insertions(+), 190 deletions(-) create mode 100644 lib/ArduinoJson/extras/tests/FailingBuilds/deserialize_object.cpp create mode 100644 lib/ArduinoJson/extras/tests/JsonDocument/set.cpp create mode 100644 lib/ArduinoJson/extras/tests/Misc/issue2129.cpp diff --git a/lib/ArduinoJson/CHANGELOG.md b/lib/ArduinoJson/CHANGELOG.md index aaec586..2148c6d 100644 --- a/lib/ArduinoJson/CHANGELOG.md +++ b/lib/ArduinoJson/CHANGELOG.md @@ -1,6 +1,13 @@ ArduinoJson: change log ======================= +v7.2.1 (2024-11-15) +------ + +* Forbid `deserializeJson(JsonArray|JsonObject, ...)` (issue #2135) +* Fix VLA support in `JsonDocument::set()` +* Fix `operator[](variant)` ignoring NUL characters + v7.2.0 (2024-09-18) ------ diff --git a/lib/ArduinoJson/CMakeLists.txt b/lib/ArduinoJson/CMakeLists.txt index 2fa0593..24584f0 100644 --- a/lib/ArduinoJson/CMakeLists.txt +++ b/lib/ArduinoJson/CMakeLists.txt @@ -10,7 +10,7 @@ if(ESP_PLATFORM) return() endif() -project(ArduinoJson VERSION 7.2.0) +project(ArduinoJson VERSION 7.2.1) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) diff --git a/lib/ArduinoJson/appveyor.yml b/lib/ArduinoJson/appveyor.yml index c928a56..3660d01 100644 --- a/lib/ArduinoJson/appveyor.yml +++ b/lib/ArduinoJson/appveyor.yml @@ -1,4 +1,4 @@ -version: 7.2.0.{build} +version: 7.2.1.{build} environment: matrix: - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 diff --git a/lib/ArduinoJson/extras/tests/CMakeLists.txt b/lib/ArduinoJson/extras/tests/CMakeLists.txt index f79a3c9..212e31e 100644 --- a/lib/ArduinoJson/extras/tests/CMakeLists.txt +++ b/lib/ArduinoJson/extras/tests/CMakeLists.txt @@ -5,15 +5,18 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_subdirectory(catch) +link_libraries(ArduinoJson) -link_libraries(ArduinoJson catch) +# Failing builds should only link with ArduinoJson, not catch +add_subdirectory(FailingBuilds) + +add_subdirectory(catch) +link_libraries(catch) include_directories(Helpers) add_subdirectory(Cpp17) add_subdirectory(Cpp20) add_subdirectory(Deprecated) -add_subdirectory(FailingBuilds) add_subdirectory(IntegrationTests) add_subdirectory(JsonArray) add_subdirectory(JsonArrayConst) diff --git a/lib/ArduinoJson/extras/tests/Deprecated/containsKey.cpp b/lib/ArduinoJson/extras/tests/Deprecated/containsKey.cpp index 3a429de..1b50897 100644 --- a/lib/ArduinoJson/extras/tests/Deprecated/containsKey.cpp +++ b/lib/ArduinoJson/extras/tests/Deprecated/containsKey.cpp @@ -44,13 +44,25 @@ TEST_CASE("JsonDocument::containsKey()") { REQUIRE(doc.containsKey("hello") == false); } - SECTION("support JsonVariant") { + SECTION("supports JsonVariant") { doc["hello"] = "world"; doc["key"] = "hello"; REQUIRE(doc.containsKey(doc["key"]) == true); REQUIRE(doc.containsKey(doc["foo"]) == false); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("supports VLAs") { + size_t i = 16; + char vla[i]; + strcpy(vla, "hello"); + + doc["hello"] = "world"; + + REQUIRE(doc.containsKey(vla) == true); + } +#endif } TEST_CASE("MemberProxy::containsKey()") { @@ -70,6 +82,18 @@ TEST_CASE("MemberProxy::containsKey()") { REQUIRE(mp.containsKey("key"_s) == true); REQUIRE(mp.containsKey("key"_s) == true); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("supports VLAs") { + size_t i = 16; + char vla[i]; + strcpy(vla, "hello"); + + mp["hello"] = "world"; + + REQUIRE(mp.containsKey(vla) == true); + } +#endif } TEST_CASE("JsonObject::containsKey()") { @@ -175,6 +199,18 @@ TEST_CASE("JsonVariant::containsKey()") { REQUIRE(var.containsKey(doc["key"]) == true); REQUIRE(var.containsKey(doc["foo"]) == false); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("supports VLAs") { + size_t i = 16; + char vla[i]; + strcpy(vla, "hello"); + + var["hello"] = "world"; + + REQUIRE(var.containsKey(vla) == true); + } +#endif } TEST_CASE("JsonVariantConst::containsKey()") { diff --git a/lib/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt b/lib/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt index 7ee4a46..ebe15f8 100644 --- a/lib/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt +++ b/lib/ArduinoJson/extras/tests/FailingBuilds/CMakeLists.txt @@ -2,7 +2,11 @@ # Copyright © 2014-2024, Benoit BLANCHON # MIT License -macro(build_should_fail target) +macro(add_failing_build source_file) + get_filename_component(target ${source_file} NAME_WE) + + add_executable(${target} ${source_file}) + set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL TRUE @@ -16,21 +20,13 @@ macro(build_should_fail target) set_tests_properties(${target} PROPERTIES WILL_FAIL TRUE - LABELS "WillFail;Catch" + LABELS "WillFail" ) endmacro() -add_executable(Issue978 Issue978.cpp) -build_should_fail(Issue978) - -add_executable(read_long_long read_long_long.cpp) -build_should_fail(read_long_long) - -add_executable(write_long_long write_long_long.cpp) -build_should_fail(write_long_long) - -add_executable(variant_as_char variant_as_char.cpp) -build_should_fail(variant_as_char) - -add_executable(assign_char assign_char.cpp) -build_should_fail(assign_char) +add_failing_build(Issue978.cpp) +add_failing_build(read_long_long.cpp) +add_failing_build(write_long_long.cpp) +add_failing_build(variant_as_char.cpp) +add_failing_build(assign_char.cpp) +add_failing_build(deserialize_object.cpp) diff --git a/lib/ArduinoJson/extras/tests/FailingBuilds/deserialize_object.cpp b/lib/ArduinoJson/extras/tests/FailingBuilds/deserialize_object.cpp new file mode 100644 index 0000000..04845cd --- /dev/null +++ b/lib/ArduinoJson/extras/tests/FailingBuilds/deserialize_object.cpp @@ -0,0 +1,12 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2024, Benoit BLANCHON +// MIT License + +#include + +// See issue #2135 + +int main() { + JsonObject obj; + deserializeJson(obj, ""); +} diff --git a/lib/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt b/lib/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt index 0caa7b9..e85db02 100644 --- a/lib/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt +++ b/lib/ArduinoJson/extras/tests/JsonDocument/CMakeLists.txt @@ -16,6 +16,7 @@ add_executable(JsonDocumentTests nesting.cpp overflowed.cpp remove.cpp + set.cpp shrinkToFit.cpp size.cpp subscript.cpp diff --git a/lib/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp b/lib/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp index 0a9039d..7faf0e4 100644 --- a/lib/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp +++ b/lib/ArduinoJson/extras/tests/JsonDocument/ElementProxy.cpp @@ -7,7 +7,7 @@ #include "Literals.hpp" -typedef ArduinoJson::detail::ElementProxy ElementProxy; +using ElementProxy = ArduinoJson::detail::ElementProxy; TEST_CASE("ElementProxy::add()") { JsonDocument doc; @@ -26,13 +26,25 @@ TEST_CASE("ElementProxy::add()") { REQUIRE(doc.as() == "[[\"world\"]]"); } - SECTION("set(char[])") { + SECTION("add(char[])") { char s[] = "world"; ep.add(s); strcpy(s, "!!!!!"); REQUIRE(doc.as() == "[[\"world\"]]"); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("set(vla)") { + size_t i = 8; + char vla[i]; + strcpy(vla, "world"); + + ep.add(vla); + + REQUIRE(doc.as() == "[[\"world\"]]"); + } +#endif } TEST_CASE("ElementProxy::clear()") { @@ -166,6 +178,18 @@ TEST_CASE("ElementProxy::set()") { REQUIRE(doc.as() == "[\"world\"]"); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("set(VLA)") { + size_t i = 8; + char vla[i]; + strcpy(vla, "world"); + + ep.set(vla); + + REQUIRE(doc.as() == "[\"world\"]"); + } +#endif } TEST_CASE("ElementProxy::size()") { @@ -205,6 +229,18 @@ TEST_CASE("ElementProxy::operator[]") { REQUIRE(doc.as() == "[null,[null,null,42]]"); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("set VLA") { + size_t i = 8; + char vla[i]; + strcpy(vla, "world"); + + ep[0] = vla; + + REQUIRE(doc.as() == "[null,[\"world\"]]"); + } +#endif } TEST_CASE("ElementProxy cast to JsonVariantConst") { diff --git a/lib/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp b/lib/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp index b48eda1..d59b581 100644 --- a/lib/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp +++ b/lib/ArduinoJson/extras/tests/JsonDocument/MemberProxy.cpp @@ -14,8 +14,8 @@ using ArduinoJson::detail::sizeofArray; using ArduinoJson::detail::sizeofObject; -typedef ArduinoJson::detail::MemberProxy - MemberProxy; +using MemberProxy = + ArduinoJson::detail::MemberProxy; TEST_CASE("MemberProxy::add()") { JsonDocument doc; @@ -32,6 +32,18 @@ TEST_CASE("MemberProxy::add()") { REQUIRE(doc.as() == "{\"hello\":[\"world\"]}"); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("add(vla)") { + size_t i = 16; + char vla[i]; + strcpy(vla, "world"); + + mp.add(vla); + + REQUIRE(doc.as() == "{\"hello\":[\"world\"]}"); + } +#endif } TEST_CASE("MemberProxy::clear()") { @@ -195,6 +207,18 @@ TEST_CASE("MemberProxy::set()") { REQUIRE(doc.as() == "{\"hello\":\"world\"}"); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("set(vla)") { + size_t i = 8; + char vla[i]; + strcpy(vla, "world"); + + mp.set(vla); + + REQUIRE(doc.as() == "{\"hello\":\"world\"}"); + } +#endif } TEST_CASE("MemberProxy::size()") { diff --git a/lib/ArduinoJson/extras/tests/JsonDocument/add.cpp b/lib/ArduinoJson/extras/tests/JsonDocument/add.cpp index 498663c..31aa6c2 100644 --- a/lib/ArduinoJson/extras/tests/JsonDocument/add.cpp +++ b/lib/ArduinoJson/extras/tests/JsonDocument/add.cpp @@ -79,6 +79,24 @@ TEST_CASE("JsonDocument::add(T)") { Allocate(sizeofString("example")), }); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("VLA") { + size_t i = 16; + char vla[i]; + strcpy(vla, "example"); + + doc.add(vla); + doc.add(vla); + + CHECK(doc[0].as() == doc[1].as()); + REQUIRE("example"_s == doc[0]); + REQUIRE(spy.log() == AllocatorLog{ + Allocate(sizeofPool()), + Allocate(sizeofString("example")), + }); + } +#endif } TEST_CASE("JsonDocument::add()") { diff --git a/lib/ArduinoJson/extras/tests/JsonDocument/set.cpp b/lib/ArduinoJson/extras/tests/JsonDocument/set.cpp new file mode 100644 index 0000000..ce9de42 --- /dev/null +++ b/lib/ArduinoJson/extras/tests/JsonDocument/set.cpp @@ -0,0 +1,79 @@ +#define ARDUINOJSON_ENABLE_ARDUINO_STRING 1 +#define ARDUINOJSON_ENABLE_PROGMEM 1 +#include + +#include + +#include "Allocators.hpp" +#include "Literals.hpp" + +TEST_CASE("JsonDocument::set()") { + SpyingAllocator spy; + JsonDocument doc(&spy); + + SECTION("integer") { + doc.set(42); + + REQUIRE(doc.as() == "42"); + REQUIRE(spy.log() == AllocatorLog{}); + } + + SECTION("const char*") { + doc.set("example"); + + REQUIRE(doc.as() == "example"_s); + REQUIRE(spy.log() == AllocatorLog{}); + } + + SECTION("std::string") { + doc.set("example"_s); + + REQUIRE(doc.as() == "example"_s); + REQUIRE(spy.log() == AllocatorLog{ + Allocate(sizeofString("example")), + }); + } + + SECTION("char*") { + char value[] = "example"; + doc.set(value); + + REQUIRE(doc.as() == "example"_s); + REQUIRE(spy.log() == AllocatorLog{ + Allocate(sizeofString("example")), + }); + } + + SECTION("Arduino String") { + doc.set(String("example")); + + REQUIRE(doc.as() == "example"_s); + REQUIRE(spy.log() == AllocatorLog{ + Allocate(sizeofString("example")), + }); + } + + SECTION("Flash string") { + doc.set(F("example")); + + REQUIRE(doc.as() == "example"_s); + REQUIRE(spy.log() == AllocatorLog{ + Allocate(sizeofString("example")), + }); + } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("VLA") { + size_t i = 16; + char vla[i]; + strcpy(vla, "example"); + + doc.set(vla); + + REQUIRE(doc.as() == "example"_s); + REQUIRE(spy.log() == AllocatorLog{ + Allocate(sizeofString("example")), + }); + } +#endif +} diff --git a/lib/ArduinoJson/extras/tests/JsonDocument/subscript.cpp b/lib/ArduinoJson/extras/tests/JsonDocument/subscript.cpp index 5c7a65d..250ce1d 100644 --- a/lib/ArduinoJson/extras/tests/JsonDocument/subscript.cpp +++ b/lib/ArduinoJson/extras/tests/JsonDocument/subscript.cpp @@ -12,28 +12,55 @@ TEST_CASE("JsonDocument::operator[]") { const JsonDocument& cdoc = doc; SECTION("object") { - deserializeJson(doc, "{\"hello\":\"world\"}"); + doc["abc"_s] = "ABC"; + doc["abc\0d"_s] = "ABCD"; SECTION("const char*") { - REQUIRE(doc["hello"] == "world"); - REQUIRE(cdoc["hello"] == "world"); + REQUIRE(doc["abc"] == "ABC"); + REQUIRE(cdoc["abc"] == "ABC"); } SECTION("std::string") { - REQUIRE(doc["hello"_s] == "world"); - REQUIRE(cdoc["hello"_s] == "world"); + REQUIRE(doc["abc"_s] == "ABC"); + REQUIRE(cdoc["abc"_s] == "ABC"); + REQUIRE(doc["abc\0d"_s] == "ABCD"); + REQUIRE(cdoc["abc\0d"_s] == "ABCD"); } SECTION("JsonVariant") { - doc["key"] = "hello"; - REQUIRE(doc[doc["key"]] == "world"); - REQUIRE(cdoc[cdoc["key"]] == "world"); + doc["key1"] = "abc"; + doc["key2"] = "abc\0d"_s; + doc["key3"] = "foo"; + + CHECK(doc[doc["key1"]] == "ABC"); + CHECK(doc[doc["key2"]] == "ABCD"); + CHECK(doc[doc["key3"]] == nullptr); + CHECK(doc[doc["key4"]] == nullptr); + + CHECK(cdoc[cdoc["key1"]] == "ABC"); + CHECK(cdoc[cdoc["key2"]] == "ABCD"); + CHECK(cdoc[cdoc["key3"]] == nullptr); + CHECK(cdoc[cdoc["key4"]] == nullptr); } SECTION("supports operator|") { - REQUIRE((doc["hello"] | "nope") == "world"_s); - REQUIRE((doc["world"] | "nope") == "nope"_s); + REQUIRE((doc["abc"] | "nope") == "ABC"_s); + REQUIRE((doc["def"] | "nope") == "nope"_s); } + +#if defined(HAS_VARIABLE_LENGTH_ARRAY) && \ + !defined(SUBSCRIPT_CONFLICTS_WITH_BUILTIN_OPERATOR) + SECTION("supports VLAs") { + size_t i = 16; + char vla[i]; + strcpy(vla, "hello"); + + doc[vla] = "world"; + + REQUIRE(doc[vla] == "world"); + REQUIRE(cdoc[vla] == "world"); + } +#endif } SECTION("array") { diff --git a/lib/ArduinoJson/extras/tests/JsonObject/subscript.cpp b/lib/ArduinoJson/extras/tests/JsonObject/subscript.cpp index 1a5ceb7..23512a0 100644 --- a/lib/ArduinoJson/extras/tests/JsonObject/subscript.cpp +++ b/lib/ArduinoJson/extras/tests/JsonObject/subscript.cpp @@ -253,9 +253,15 @@ TEST_CASE("JsonObject::operator[]") { SECTION("JsonVariant") { obj["hello"] = "world"; - doc["key"] = "hello"; + obj["a\0b"_s] = "ABC"; - REQUIRE(obj[obj["key"]] == "world"); - REQUIRE(obj[obj["foo"]] == nullptr); + doc["key1"] = "hello"; + doc["key2"] = "a\0b"_s; + doc["key3"] = "foo"; + + REQUIRE(obj[obj["key1"]] == "world"); + REQUIRE(obj[obj["key2"]] == "ABC"); + REQUIRE(obj[obj["key3"]] == nullptr); + REQUIRE(obj[obj["key4"]] == nullptr); } } diff --git a/lib/ArduinoJson/extras/tests/JsonObjectConst/subscript.cpp b/lib/ArduinoJson/extras/tests/JsonObjectConst/subscript.cpp index 12f080c..59714c0 100644 --- a/lib/ArduinoJson/extras/tests/JsonObjectConst/subscript.cpp +++ b/lib/ArduinoJson/extras/tests/JsonObjectConst/subscript.cpp @@ -11,6 +11,7 @@ TEST_CASE("JsonObjectConst::operator[]") { JsonDocument doc; doc["hello"] = "world"; + doc["a\0b"_s] = "ABC"; JsonObjectConst obj = doc.as(); SECTION("supports const char*") { @@ -19,6 +20,7 @@ TEST_CASE("JsonObjectConst::operator[]") { SECTION("supports std::string") { REQUIRE(obj["hello"_s] == "world"); // issue #2019 + REQUIRE(obj["a\0b"_s] == "ABC"); } #if defined(HAS_VARIABLE_LENGTH_ARRAY) && \ @@ -28,13 +30,17 @@ TEST_CASE("JsonObjectConst::operator[]") { char vla[i]; strcpy(vla, "hello"); - REQUIRE("world"_s == obj[vla]); + REQUIRE(obj[vla] == "world"_s); } #endif SECTION("supports JsonVariant") { - doc["key"] = "hello"; - REQUIRE(obj[obj["key"]] == "world"); - REQUIRE(obj[obj["foo"]] == nullptr); + doc["key1"] = "hello"; + doc["key2"] = "a\0b"_s; + doc["key3"] = "foo"; + REQUIRE(obj[obj["key1"]] == "world"); + REQUIRE(obj[obj["key2"]] == "ABC"); + REQUIRE(obj[obj["key3"]] == nullptr); + REQUIRE(obj[obj["key4"]] == nullptr); } } diff --git a/lib/ArduinoJson/extras/tests/JsonVariant/add.cpp b/lib/ArduinoJson/extras/tests/JsonVariant/add.cpp index 8b3e602..a81d792 100644 --- a/lib/ArduinoJson/extras/tests/JsonVariant/add.cpp +++ b/lib/ArduinoJson/extras/tests/JsonVariant/add.cpp @@ -46,6 +46,18 @@ TEST_CASE("JsonVariant::add(T)") { REQUIRE(var.as() == "{\"val\":123}"); } + +#ifdef HAS_VARIABLE_LENGTH_ARRAY + SECTION("supports VLAs") { + size_t i = 16; + char vla[i]; + strcpy(vla, "hello"); + + var.add(vla); + + REQUIRE(var.as() == "[\"hello\"]"); + } +#endif } TEST_CASE("JsonVariant::add()") { diff --git a/lib/ArduinoJson/extras/tests/JsonVariant/remove.cpp b/lib/ArduinoJson/extras/tests/JsonVariant/remove.cpp index b8dfc0e..3371c2e 100644 --- a/lib/ArduinoJson/extras/tests/JsonVariant/remove.cpp +++ b/lib/ArduinoJson/extras/tests/JsonVariant/remove.cpp @@ -83,6 +83,23 @@ TEST_CASE("JsonVariant::remove(std::string)") { REQUIRE(var.as() == "{\"a\":1}"); } +#ifdef HAS_VARIABLE_LENGTH_ARRAY +TEST_CASE("JsonVariant::remove(VLA)") { + JsonDocument doc; + JsonVariant var = doc.to(); + + var["a"] = 1; + var["b"] = 2; + size_t i = 16; + char vla[i]; + strcpy(vla, "b"); + + var.remove("b"_s); + + REQUIRE(var.as() == "{\"a\":1}"); +} +#endif + TEST_CASE("JsonVariant::remove(JsonVariant) from object") { JsonDocument doc; JsonVariant var = doc.to(); diff --git a/lib/ArduinoJson/extras/tests/JsonVariant/stl_containers.cpp b/lib/ArduinoJson/extras/tests/JsonVariant/stl_containers.cpp index 05d1020..6ffa580 100644 --- a/lib/ArduinoJson/extras/tests/JsonVariant/stl_containers.cpp +++ b/lib/ArduinoJson/extras/tests/JsonVariant/stl_containers.cpp @@ -99,7 +99,7 @@ TEST_CASE("vector") { } TEST_CASE("array") { - typedef std::array array_type; + using array_type = std::array; SECTION("toJson") { array_type v; diff --git a/lib/ArduinoJson/extras/tests/JsonVariant/subscript.cpp b/lib/ArduinoJson/extras/tests/JsonVariant/subscript.cpp index 946d84c..7c3d1e4 100644 --- a/lib/ArduinoJson/extras/tests/JsonVariant/subscript.cpp +++ b/lib/ArduinoJson/extras/tests/JsonVariant/subscript.cpp @@ -116,12 +116,19 @@ TEST_CASE("JsonVariant::operator[]") { } SECTION("use JsonVariant as key") { - object["a"] = "a"; - object["b"] = "b"; - object["c"] = "b"; + object["a"] = "A"; + object["ab"] = "AB"; + object["ab\0c"_s] = "ABC"; + object["key1"] = "a"; + object["key2"] = "ab"; + object["key3"] = "ab\0c"_s; + object["key4"] = "foo"; - REQUIRE(var[var["c"]] == "b"); - REQUIRE(var[var["d"]].isNull()); + REQUIRE(var[var["key1"]] == "A"); + REQUIRE(var[var["key2"]] == "AB"); + REQUIRE(var[var["key3"]] == "ABC"); + REQUIRE(var[var["key4"]].isNull()); + REQUIRE(var[var["key5"]].isNull()); } } diff --git a/lib/ArduinoJson/extras/tests/JsonVariantConst/subscript.cpp b/lib/ArduinoJson/extras/tests/JsonVariantConst/subscript.cpp index 67ac98e..735506a 100644 --- a/lib/ArduinoJson/extras/tests/JsonVariantConst/subscript.cpp +++ b/lib/ArduinoJson/extras/tests/JsonVariantConst/subscript.cpp @@ -50,20 +50,22 @@ TEST_CASE("JsonVariantConst::operator[]") { SECTION("object") { JsonObject object = doc.to(); - object["a"] = "A"; - object["b"] = "B"; + object["ab"_s] = "AB"; + object["abc"_s] = "ABC"; + object["abc\0d"_s] = "ABCD"; SECTION("supports const char*") { - REQUIRE("A"_s == var["a"]); - REQUIRE("B"_s == var["b"]); - REQUIRE(var["c"].isNull()); + REQUIRE(var["ab"] == "AB"_s); + REQUIRE(var["abc"] == "ABC"_s); + REQUIRE(var["def"].isNull()); REQUIRE(var[0].isNull()); } SECTION("supports std::string") { - REQUIRE("A"_s == var["a"_s]); - REQUIRE("B"_s == var["b"_s]); - REQUIRE(var["c"_s].isNull()); + REQUIRE(var["ab"_s] == "AB"_s); + REQUIRE(var["abc"_s] == "ABC"_s); + REQUIRE(var["abc\0d"_s] == "ABCD"_s); + REQUIRE(var["def"_s].isNull()); } #if defined(HAS_VARIABLE_LENGTH_ARRAY) && \ @@ -71,16 +73,23 @@ TEST_CASE("JsonVariantConst::operator[]") { SECTION("supports VLA") { size_t i = 16; char vla[i]; - strcpy(vla, "a"); + strcpy(vla, "abc"); - REQUIRE("A"_s == var[vla]); + REQUIRE(var[vla] == "ABC"_s); } #endif SECTION("supports JsonVariant") { - object["c"] = "b"; - REQUIRE(var[var["c"]] == "B"); - REQUIRE(var[var["d"]].isNull()); + object["key1"] = "ab"; + object["key2"] = "abc"; + object["key3"] = "abc\0d"_s; + object["key4"] = "foo"; + + REQUIRE(var[var["key1"]] == "AB"_s); + REQUIRE(var[var["key2"]] == "ABC"_s); + REQUIRE(var[var["key3"]] == "ABCD"_s); + REQUIRE(var[var["key4"]].isNull()); + REQUIRE(var[var["key5"]].isNull()); } } } diff --git a/lib/ArduinoJson/extras/tests/Misc/CMakeLists.txt b/lib/ArduinoJson/extras/tests/Misc/CMakeLists.txt index 82f1a0c..4230a9c 100644 --- a/lib/ArduinoJson/extras/tests/Misc/CMakeLists.txt +++ b/lib/ArduinoJson/extras/tests/Misc/CMakeLists.txt @@ -6,6 +6,7 @@ add_executable(MiscTests arithmeticCompare.cpp conflicts.cpp issue1967.cpp + issue2129.cpp JsonString.cpp NoArduinoHeader.cpp printable.cpp diff --git a/lib/ArduinoJson/extras/tests/Misc/StringAdapters.cpp b/lib/ArduinoJson/extras/tests/Misc/StringAdapters.cpp index 3e5c2b6..b33ab99 100644 --- a/lib/ArduinoJson/extras/tests/Misc/StringAdapters.cpp +++ b/lib/ArduinoJson/extras/tests/Misc/StringAdapters.cpp @@ -12,77 +12,101 @@ #include "custom_string.hpp" #include "weird_strcmp.hpp" +using ArduinoJson::JsonString; using namespace ArduinoJson::detail; -TEST_CASE("ZeroTerminatedRamString") { - SECTION("null") { - ZeroTerminatedRamString s = adaptString(static_cast(0)); +TEST_CASE("adaptString()") { + SECTION("null const char*") { + auto s = adaptString(static_cast(0)); CHECK(s.isNull() == true); CHECK(s.size() == 0); + CHECK(s.isLinked() == true); } - SECTION("non-null") { - ZeroTerminatedRamString s = adaptString("bravo"); + SECTION("non-null const char*") { + auto s = adaptString("bravo"); CHECK(s.isNull() == false); CHECK(s.size() == 5); + CHECK(s.isLinked() == true); } -} -TEST_CASE("SizedRamString") { - SECTION("null") { - SizedRamString s = adaptString(static_cast(0), 10); + SECTION("null const char* + size") { + auto s = adaptString(static_cast(0), 10); CHECK(s.isNull() == true); + CHECK(s.isLinked() == false); } - SECTION("non-null") { - SizedRamString s = adaptString("bravo", 5); + SECTION("non-null const char* + size") { + auto s = adaptString("bravo", 5); CHECK(s.isNull() == false); CHECK(s.size() == 5); + CHECK(s.isLinked() == false); } -} -TEST_CASE("FlashString") { - SECTION("null") { - FlashString s = adaptString(static_cast(0)); + SECTION("null Flash string") { + auto s = adaptString(static_cast(0)); CHECK(s.isNull() == true); CHECK(s.size() == 0); + CHECK(s.isLinked() == false); } - SECTION("non-null") { - FlashString s = adaptString(F("bravo")); + SECTION("non-null Flash string") { + auto s = adaptString(F("bravo")); CHECK(s.isNull() == false); CHECK(s.size() == 5); + CHECK(s.isLinked() == false); } -} -TEST_CASE("std::string") { - std::string orig("bravo"); - SizedRamString s = adaptString(orig); + SECTION("std::string") { + std::string orig("bravo"); + auto s = adaptString(orig); - CHECK(s.isNull() == false); - CHECK(s.size() == 5); -} + CHECK(s.isNull() == false); + CHECK(s.size() == 5); + CHECK(s.isLinked() == false); + } -TEST_CASE("Arduino String") { - ::String orig("bravo"); - SizedRamString s = adaptString(orig); + SECTION("Arduino String") { + ::String orig("bravo"); + auto s = adaptString(orig); - CHECK(s.isNull() == false); - CHECK(s.size() == 5); -} + CHECK(s.isNull() == false); + CHECK(s.size() == 5); + CHECK(s.isLinked() == false); + } -TEST_CASE("custom_string") { - custom_string orig("bravo"); - SizedRamString s = adaptString(orig); + SECTION("custom_string") { + custom_string orig("bravo"); + auto s = adaptString(orig); - CHECK(s.isNull() == false); - CHECK(s.size() == 5); + CHECK(s.isNull() == false); + CHECK(s.size() == 5); + CHECK(s.isLinked() == false); + } + + SECTION("JsonString linked") { + JsonString orig("hello", JsonString::Ownership::Linked); + auto s = adaptString(orig); + + CHECK(s.isNull() == false); + CHECK(s.size() == 5); + CHECK(s.isLinked() == true); + } + + SECTION("JsonString copied") { + JsonString orig("hello", JsonString::Ownership::Copied); + auto s = adaptString(orig); + + CHECK(s.isNull() == false); + CHECK(s.size() == 5); + CHECK(s.isLinked() == false); + } } struct EmptyStruct {}; @@ -97,6 +121,7 @@ TEST_CASE("IsString") { CHECK(IsString<::String>::value == true); CHECK(IsString<::StringSumHelper>::value == true); CHECK(IsString::value == false); + CHECK(IsString::value == true); } TEST_CASE("stringCompare") { diff --git a/lib/ArduinoJson/extras/tests/Misc/custom_string.hpp b/lib/ArduinoJson/extras/tests/Misc/custom_string.hpp index acc6752..9be1f54 100644 --- a/lib/ArduinoJson/extras/tests/Misc/custom_string.hpp +++ b/lib/ArduinoJson/extras/tests/Misc/custom_string.hpp @@ -8,4 +8,4 @@ struct custom_char_traits : std::char_traits {}; -typedef std::basic_string custom_string; +using custom_string = std::basic_string; diff --git a/lib/ArduinoJson/extras/tests/Misc/issue2129.cpp b/lib/ArduinoJson/extras/tests/Misc/issue2129.cpp new file mode 100644 index 0000000..8b336f2 --- /dev/null +++ b/lib/ArduinoJson/extras/tests/Misc/issue2129.cpp @@ -0,0 +1,55 @@ +// ArduinoJson - https://arduinojson.org +// Copyright © 2014-2024, Benoit BLANCHON +// MIT License + +#include +#include + +template +class Nullable { + public: + Nullable() : value_{} {} + Nullable(T value) : value_{value} {} + + operator T() const { + return value_; + } + + operator T&() { + return value_; + } + + bool is_valid() const { + return value_ != invalid_value_; + } + + T value() const { + return value_; + } + + private: + T value_; + static T invalid_value_; +}; + +template <> +float Nullable::invalid_value_ = std::numeric_limits::lowest(); + +template +void convertToJson(const Nullable& src, JsonVariant dst) { + if (src.is_valid()) { + dst.set(src.value()); + } else { + dst.clear(); + } +} + +TEST_CASE("Issue #2129") { + Nullable nullable_value = Nullable{123.4f}; + + JsonDocument doc; + + doc["value"] = nullable_value; + + REQUIRE(doc["value"].as() == Approx(123.4f)); +} diff --git a/lib/ArduinoJson/idf_component.yml b/lib/ArduinoJson/idf_component.yml index bdf8d36..4a65119 100644 --- a/lib/ArduinoJson/idf_component.yml +++ b/lib/ArduinoJson/idf_component.yml @@ -1,7 +1,7 @@ -version: "7.2.0" +version: "7.2.1" description: >- A simple and efficient JSON library for embedded C++. - ⭐ 6690 stars on GitHub! + ★ 6739 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented. url: https://arduinojson.org/ diff --git a/lib/ArduinoJson/library.json b/lib/ArduinoJson/library.json index 30da9fc..4c61b31 100644 --- a/lib/ArduinoJson/library.json +++ b/lib/ArduinoJson/library.json @@ -1,13 +1,13 @@ { "name": "ArduinoJson", "keywords": "json, rest, http, web", - "description": "A simple and efficient JSON library for embedded C++. ⭐ 6690 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.", + "description": "A simple and efficient JSON library for embedded C++. ⭐ 6739 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented.", "homepage": "https://arduinojson.org/?utm_source=meta&utm_medium=library.json", "repository": { "type": "git", "url": "https://github.com/bblanchon/ArduinoJson.git" }, - "version": "7.2.0", + "version": "7.2.1", "authors": { "name": "Benoit Blanchon", "url": "https://blog.benoitblanchon.fr" diff --git a/lib/ArduinoJson/library.properties b/lib/ArduinoJson/library.properties index 86866c0..c3ea5c3 100644 --- a/lib/ArduinoJson/library.properties +++ b/lib/ArduinoJson/library.properties @@ -1,9 +1,9 @@ name=ArduinoJson -version=7.2.0 +version=7.2.1 author=Benoit Blanchon maintainer=Benoit Blanchon sentence=A simple and efficient JSON library for embedded C++. -paragraph=⭐ 6690 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented. +paragraph=⭐ 6739 stars on GitHub! Supports serialization, deserialization, MessagePack, streams, filtering, and more. Fully tested and documented. category=Data Processing url=https://arduinojson.org/?utm_source=meta&utm_medium=library.properties architectures=* diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp index 9a4e5f9..0e3ea2e 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArray.hpp @@ -17,7 +17,7 @@ class JsonArray : public detail::VariantOperators { friend class detail::VariantAttorney; public: - typedef JsonArrayIterator iterator; + using iterator = JsonArrayIterator; // Constructs an unbound reference. JsonArray() : data_(0), resources_(0) {} diff --git a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp index c6e027f..6b9db19 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Array/JsonArrayConst.hpp @@ -19,7 +19,7 @@ class JsonArrayConst : public detail::VariantOperators { friend class detail::VariantAttorney; public: - typedef JsonArrayConstIterator iterator; + using iterator = JsonArrayConstIterator; // Returns an iterator to the first element of the array. // https://arduinojson.org/v7/api/jsonarrayconst/begin/ diff --git a/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp b/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp index b33313e..a95049a 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Deserialization/deserialize.hpp @@ -24,14 +24,10 @@ struct first_or_void { // A meta-function that returns true if T is a valid destination type for // deserialize() -template -struct is_deserialize_destination : false_type {}; - template -struct is_deserialize_destination< - T, enable_if_t())), - ResourceManager*>::value>> : true_type {}; +using is_deserialize_destination = + bool_constant>::value || + IsVariant::value>; template inline void shrinkJsonDocument(TDestination&) { diff --git a/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp b/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp index 5ba62f4..b145f0c 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Document/JsonDocument.hpp @@ -142,6 +142,13 @@ class JsonDocument : public detail::VariantOperators { return to().set(src); } + // Replaces the root with the specified value. + // https://arduinojson.org/v7/api/jsondocument/set/ + template + bool set(TChar* src) { + return to().set(src); + } + // Clears the document and converts it to the specified type. // https://arduinojson.org/v7/api/jsondocument/to/ template @@ -232,8 +239,8 @@ class JsonDocument : public detail::VariantOperators { template detail::enable_if_t::value, JsonVariantConst> operator[](const TVariant& key) const { - if (key.template is()) - return operator[](key.template as()); + if (key.template is()) + return operator[](key.template as()); if (key.template is()) return operator[](key.template as()); return {}; diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp index 9ae0367..56cedf2 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Json/PrettyJsonSerializer.hpp @@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template class PrettyJsonSerializer : public JsonSerializer { - typedef JsonSerializer base; + using base = JsonSerializer; public: PrettyJsonSerializer(TWriter writer, const ResourceManager* resources) diff --git a/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp b/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp index 5b94b5e..0fab396 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Json/TextFormatter.hpp @@ -105,7 +105,7 @@ class TextFormatter { template enable_if_t::value> writeInteger(T value) { - typedef make_unsigned_t unsigned_type; + using unsigned_type = make_unsigned_t; unsigned_type unsigned_value; if (value < 0) { writeRaw('-'); diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp index 0affe06..536ae2a 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatParts.hpp @@ -20,7 +20,7 @@ struct FloatParts { template inline int16_t normalize(TFloat& value) { - typedef FloatTraits traits; + using traits = FloatTraits; int16_t powersOf10 = 0; int8_t index = sizeof(TFloat) == 8 ? 8 : 5; diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp index 2dcbe10..ea99625 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Numbers/FloatTraits.hpp @@ -21,12 +21,12 @@ struct FloatTraits {}; template struct FloatTraits { - typedef uint64_t mantissa_type; + using mantissa_type = uint64_t; static const short mantissa_bits = 52; static const mantissa_type mantissa_max = (mantissa_type(1) << mantissa_bits) - 1; - typedef int16_t exponent_type; + using exponent_type = int16_t; static const exponent_type exponent_max = 308; static pgm_ptr positiveBinaryPowersOfTen() { @@ -105,12 +105,12 @@ struct FloatTraits { template struct FloatTraits { - typedef uint32_t mantissa_type; + using mantissa_type = uint32_t; static const short mantissa_bits = 23; static const mantissa_type mantissa_max = (mantissa_type(1) << mantissa_bits) - 1; - typedef int8_t exponent_type; + using exponent_type = int8_t; static const exponent_type exponent_max = 38; static pgm_ptr positiveBinaryPowersOfTen() { diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonFloat.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonFloat.hpp index 89f3351..e370f66 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonFloat.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonFloat.hpp @@ -10,9 +10,9 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE #if ARDUINOJSON_USE_DOUBLE -typedef double JsonFloat; +using JsonFloat = double; #else -typedef float JsonFloat; +using JsonFloat = float; #endif ARDUINOJSON_END_PUBLIC_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonInteger.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonInteger.hpp index ae025b7..d65805c 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonInteger.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Numbers/JsonInteger.hpp @@ -12,11 +12,11 @@ ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE #if ARDUINOJSON_USE_LONG_LONG -typedef int64_t JsonInteger; -typedef uint64_t JsonUInt; +using JsonInteger = int64_t; +using JsonUInt = uint64_t; #else -typedef long JsonInteger; -typedef unsigned long JsonUInt; +using JsonInteger = long; +using JsonUInt = unsigned long; #endif ARDUINOJSON_END_PUBLIC_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp b/lib/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp index 2df8cdc..7f4b220 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Numbers/parseNumber.hpp @@ -103,9 +103,9 @@ class Number { }; inline Number parseNumber(const char* s) { - typedef FloatTraits traits; - typedef largest_type mantissa_t; - typedef traits::exponent_type exponent_t; + using traits = FloatTraits; + using mantissa_t = largest_type; + using exponent_t = traits::exponent_type; ARDUINOJSON_ASSERT(s != 0); diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp index 2eeeed3..379e8e4 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObject.hpp @@ -17,7 +17,7 @@ class JsonObject : public detail::VariantOperators { friend class detail::VariantAttorney; public: - typedef JsonObjectIterator iterator; + using iterator = JsonObjectIterator; // Creates an unbound reference. JsonObject() : data_(0), resources_(0) {} @@ -121,10 +121,10 @@ class JsonObject : public detail::VariantOperators { // https://arduinojson.org/v7/api/jsonobject/subscript/ template detail::enable_if_t::value, - detail::MemberProxy> + detail::MemberProxy> operator[](const TVariant& key) const { - if (key.template is()) - return {*this, key.template as()}; + if (key.template is()) + return {*this, key.template as()}; else return {*this, nullptr}; } diff --git a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp index 3af7d12..6b0de20 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Object/JsonObjectConst.hpp @@ -16,7 +16,7 @@ class JsonObjectConst : public detail::VariantOperators { friend class detail::VariantAttorney; public: - typedef JsonObjectConstIterator iterator; + using iterator = JsonObjectConstIterator; // Creates an unbound reference. JsonObjectConst() : data_(0), resources_(0) {} @@ -121,8 +121,8 @@ class JsonObjectConst : public detail::VariantOperators { template detail::enable_if_t::value, JsonVariantConst> operator[](const TVariant& key) const { - if (key.template is()) - return operator[](key.template as()); + if (key.template is()) + return operator[](key.template as()); else return JsonVariantConst(); } diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp index 8b74bd9..c56e1e9 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/integer.hpp @@ -15,17 +15,17 @@ struct uint_; template <> struct uint_<8> { - typedef uint8_t type; + using type = uint8_t; }; template <> struct uint_<16> { - typedef uint16_t type; + using type = uint16_t; }; template <> struct uint_<32> { - typedef uint32_t type; + using type = uint32_t; }; template diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp index bebd844..75ebdd4 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/conditional.hpp @@ -10,12 +10,12 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template struct conditional { - typedef TrueType type; + using type = TrueType; }; template struct conditional { - typedef FalseType type; + using type = FalseType; }; template diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp index 0fed8f4..f1184f2 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/enable_if.hpp @@ -14,7 +14,7 @@ struct enable_if {}; template struct enable_if { - typedef T type; + using type = T; }; template diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp index e1db890..e263523 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/integral_constant.hpp @@ -13,7 +13,10 @@ struct integral_constant { static const T value = v; }; -typedef integral_constant true_type; -typedef integral_constant false_type; +template +using bool_constant = integral_constant; + +using true_type = bool_constant; +using false_type = bool_constant; ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp index c6919d4..e906ab7 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/is_convertible.hpp @@ -27,7 +27,7 @@ struct is_convertible { static int probe(To); static char probe(...); - static From& from_; + static const From& from_; public: static const bool value = sizeof(probe(from_)) == sizeof(int); diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp index 5e08dce..22406e5 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_const.hpp @@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE // A meta-function that return the type T without the const modifier template struct remove_const { - typedef T type; + using type = T; }; template struct remove_const { - typedef T type; + using type = T; }; template diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp index 0c7b633..67d75c6 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_cv.hpp @@ -10,19 +10,19 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template struct remove_cv { - typedef T type; + using type = T; }; template struct remove_cv { - typedef T type; + using type = T; }; template struct remove_cv { - typedef T type; + using type = T; }; template struct remove_cv { - typedef T type; + using type = T; }; template diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp index c5ddeed..60e31b0 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/remove_reference.hpp @@ -11,11 +11,11 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE // A meta-function that return the type T without the reference modifier. template struct remove_reference { - typedef T type; + using type = T; }; template struct remove_reference { - typedef T type; + using type = T; }; template diff --git a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp index 0dd1a9f..ea899f6 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Polyfills/type_traits/type_identity.hpp @@ -10,7 +10,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template struct type_identity { - typedef T type; + using type = T; }; ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp index fafed96..4cbbc0f 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/FlashString.hpp @@ -74,7 +74,7 @@ class FlashString { template <> struct StringAdapter { - typedef FlashString AdaptedString; + using AdaptedString = FlashString; static AdaptedString adapt(const __FlashStringHelper* s) { return AdaptedString(s, s ? strlen_P(reinterpret_cast(s)) : 0); @@ -83,7 +83,7 @@ struct StringAdapter { template <> struct SizedStringAdapter { - typedef FlashString AdaptedString; + using AdaptedString = FlashString; static AdaptedString adapt(const __FlashStringHelper* s, size_t n) { return AdaptedString(s, n); diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp index b98c407..b611bcf 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/JsonString.hpp @@ -25,7 +25,7 @@ class JsonStringAdapter : public SizedRamString { template <> struct StringAdapter { - typedef JsonStringAdapter AdaptedString; + using AdaptedString = JsonStringAdapter; static AdaptedString adapt(const JsonString& s) { return AdaptedString(s); diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp index c27c4b3..0864c93 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/RamString.hpp @@ -41,18 +41,6 @@ class ZeroTerminatedRamString { return str_; } - friend int stringCompare(ZeroTerminatedRamString a, - ZeroTerminatedRamString b) { - ARDUINOJSON_ASSERT(!a.isNull()); - ARDUINOJSON_ASSERT(!b.isNull()); - return ::strcmp(a.str_, b.str_); - } - - friend bool stringEquals(ZeroTerminatedRamString a, - ZeroTerminatedRamString b) { - return stringCompare(a, b) == 0; - } - bool isLinked() const { return false; } @@ -63,7 +51,7 @@ class ZeroTerminatedRamString { template struct StringAdapter::value>> { - typedef ZeroTerminatedRamString AdaptedString; + using AdaptedString = ZeroTerminatedRamString; static AdaptedString adapt(const TChar* p) { return AdaptedString(reinterpret_cast(p)); @@ -72,7 +60,7 @@ struct StringAdapter::value>> { template struct StringAdapter::value>> { - typedef ZeroTerminatedRamString AdaptedString; + using AdaptedString = ZeroTerminatedRamString; static AdaptedString adapt(const TChar* p) { return AdaptedString(reinterpret_cast(p)); @@ -90,7 +78,7 @@ class StaticStringAdapter : public ZeroTerminatedRamString { template <> struct StringAdapter { - typedef StaticStringAdapter AdaptedString; + using AdaptedString = StaticStringAdapter; static AdaptedString adapt(const char* p) { return AdaptedString(p); @@ -132,7 +120,7 @@ class SizedRamString { template struct SizedStringAdapter::value>> { - typedef SizedRamString AdaptedString; + using AdaptedString = SizedRamString; static AdaptedString adapt(const TChar* p, size_t n) { return AdaptedString(reinterpret_cast(p), n); diff --git a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringObject.hpp b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringObject.hpp index 095f40d..d29d653 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringObject.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Strings/Adapters/StringObject.hpp @@ -15,7 +15,7 @@ struct StringAdapter< T, enable_if_t<(string_traits::has_cstr || string_traits::has_data) && (string_traits::has_length || string_traits::has_size)>> { - typedef SizedRamString AdaptedString; + using AdaptedString = SizedRamString; static AdaptedString adapt(const T& s) { return AdaptedString(get_data(s), get_size(s)); diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp index 5147204..4389bb8 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantConst.hpp @@ -136,7 +136,7 @@ class JsonVariantConst : public detail::VariantTag, if (key.template is()) return operator[](key.template as()); else - return operator[](key.template as()); + return operator[](key.template as()); } // DEPRECATED: use obj[key].is() instead diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantCopier.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantCopier.hpp index 032f1f8..659069d 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantCopier.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantCopier.hpp @@ -11,7 +11,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE class JsonVariantCopier { public: - typedef bool result_type; + using result_type = bool; JsonVariantCopier(JsonVariant dst) : dst_(dst) {} diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantVisitor.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantVisitor.hpp index 83f5153..6069b6e 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantVisitor.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/JsonVariantVisitor.hpp @@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template struct JsonVariantVisitor { - typedef TResult result_type; + using result_type = TResult; template TResult visit(const T&) { diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantDataVisitor.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantDataVisitor.hpp index 631bce7..662ab13 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantDataVisitor.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantDataVisitor.hpp @@ -13,7 +13,7 @@ ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE template struct VariantDataVisitor { - typedef TResult result_type; + using result_type = TResult; template TResult visit(const T&) { diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp index 6a79af0..d8f5cfc 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantRefBase.hpp @@ -207,7 +207,7 @@ class VariantRefBase : public VariantTag { if (key.template is()) return operator[](key.template as()); else - return operator[](key.template as()); + return operator[](key.template as()); } // DEPRECATED: use add() instead diff --git a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp index c533040..f159aef 100644 --- a/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/Variant/VariantTo.hpp @@ -20,15 +20,15 @@ struct VariantTo {}; template <> struct VariantTo { - typedef JsonArray type; + using type = JsonArray; }; template <> struct VariantTo { - typedef JsonObject type; + using type = JsonObject; }; template <> struct VariantTo { - typedef JsonVariant type; + using type = JsonVariant; }; ARDUINOJSON_END_PRIVATE_NAMESPACE diff --git a/lib/ArduinoJson/src/ArduinoJson/version.hpp b/lib/ArduinoJson/src/ArduinoJson/version.hpp index 9348b3a..6df6b76 100644 --- a/lib/ArduinoJson/src/ArduinoJson/version.hpp +++ b/lib/ArduinoJson/src/ArduinoJson/version.hpp @@ -4,8 +4,8 @@ #pragma once -#define ARDUINOJSON_VERSION "7.2.0" +#define ARDUINOJSON_VERSION "7.2.1" #define ARDUINOJSON_VERSION_MAJOR 7 #define ARDUINOJSON_VERSION_MINOR 2 -#define ARDUINOJSON_VERSION_REVISION 0 -#define ARDUINOJSON_VERSION_MACRO V720 +#define ARDUINOJSON_VERSION_REVISION 1 +#define ARDUINOJSON_VERSION_MACRO V721 diff --git a/src/Config.h b/src/Config.h index 30d77e7..0a56b7c 100644 --- a/src/Config.h +++ b/src/Config.h @@ -4,7 +4,7 @@ #define NUKI_HUB_VERSION "9.03" #define NUKI_HUB_BUILD "unknownbuildnr" -#define NUKI_HUB_DATE "2024-12-01" +#define NUKI_HUB_DATE "2024-12-03" #define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json" diff --git a/src/idf_component.yml b/src/idf_component.yml index b69cad4..e4996ee 100644 --- a/src/idf_component.yml +++ b/src/idf_component.yml @@ -4,9 +4,9 @@ dependencies: esp-nimble-cpp: git: https://github.com/h2zero/esp-nimble-cpp.git - version: 020c61700dce2174769f855d45ab0ea70a2aaac4 + version: 6c85cfa6c3d5ec9c46b87c761925b1bcb5c3827c - espressif/libsodium: "^1.0.20~1" + espressif/libsodium: "^1.0.20~2" # # Defining a dependency from the registry: # # https://components.espressif.com/component/example/cmp