mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Replace ARDUINOJSON_NAMESPACE with an inline namespace (#1820)
				
					
				
			This commit is contained in:
		| @@ -5,6 +5,7 @@ HEAD | |||||||
| ---- | ---- | ||||||
|  |  | ||||||
| * Drop support for C++98/C++03. Minimum required is C++11. | * Drop support for C++98/C++03. Minimum required is C++11. | ||||||
|  | * Remove `ARDUINOJSON_NAMESPACE`; use `ArduinoJson` instead. | ||||||
|  |  | ||||||
| v6.20.1 (2023-02-08) | v6.20.1 (2023-02-08) | ||||||
| ------- | ------- | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); | |||||||
|  |  | ||||||
| static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | ||||||
|  |  | ||||||
| static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 8, | static_assert(sizeof(ArduinoJson::detail::VariantSlot) == 8, | ||||||
|               "sizeof(VariantSlot)"); |               "sizeof(VariantSlot)"); | ||||||
|  |  | ||||||
| void setup() {} | void setup() {} | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); | |||||||
|  |  | ||||||
| static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | ||||||
|  |  | ||||||
| static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 16, | static_assert(sizeof(ArduinoJson::detail::VariantSlot) == 16, | ||||||
|               "sizeof(VariantSlot)"); |               "sizeof(VariantSlot)"); | ||||||
|  |  | ||||||
| void setup() {} | void setup() {} | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); | |||||||
|  |  | ||||||
| static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | ||||||
|  |  | ||||||
| static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 32, | static_assert(sizeof(ArduinoJson::detail::VariantSlot) == 32, | ||||||
|               "sizeof(VariantSlot)"); |               "sizeof(VariantSlot)"); | ||||||
|  |  | ||||||
| int main() {} | int main() {} | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ static_assert(ARDUINOJSON_LITTLE_ENDIAN == 1, "ARDUINOJSON_LITTLE_ENDIAN"); | |||||||
|  |  | ||||||
| static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | static_assert(ARDUINOJSON_USE_DOUBLE == 1, "ARDUINOJSON_USE_DOUBLE"); | ||||||
|  |  | ||||||
| static_assert(sizeof(ARDUINOJSON_NAMESPACE::VariantSlot) == 16, | static_assert(sizeof(ArduinoJson::detail::VariantSlot) == 16, | ||||||
|               "sizeof(VariantSlot)"); |               "sizeof(VariantSlot)"); | ||||||
|  |  | ||||||
| int main() {} | int main() {} | ||||||
|   | |||||||
| @@ -53,7 +53,8 @@ process() | |||||||
| } | } | ||||||
|  |  | ||||||
| simplify_namespaces() { | simplify_namespaces() { | ||||||
| 	perl -p0i -e 's|\}  // namespace ARDUINOJSON_NAMESPACE\r?\nnamespace ARDUINOJSON_NAMESPACE \{\r?\n||igs' "$1" | 	perl -p0i -e 's|ARDUINOJSON_END_PUBLIC_NAMESPACE\r?\nARDUINOJSON_BEGIN_PUBLIC_NAMESPACE\r?\n||igs' "$1" | ||||||
|  | 	perl -p0i -e 's|ARDUINOJSON_END_PRIVATE_NAMESPACE\r?\nARDUINOJSON_BEGIN_PRIVATE_NAMESPACE\r?\n||igs' "$1" | ||||||
| 	rm -f "$1.bak" | 	rm -f "$1.bak" | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -86,7 +86,7 @@ TEST_CASE("string_view") { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| using ARDUINOJSON_NAMESPACE::adaptString; | using ArduinoJson::detail::adaptString; | ||||||
|  |  | ||||||
| TEST_CASE("StringViewAdapter") { | TEST_CASE("StringViewAdapter") { | ||||||
|   std::string_view str("bravoXXX", 5); |   std::string_view str("bravoXXX", 5); | ||||||
|   | |||||||
| @@ -11,8 +11,8 @@ | |||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| namespace my { | namespace my { | ||||||
| using ARDUINOJSON_NAMESPACE::isinf; | using ArduinoJson::detail::isinf; | ||||||
| using ARDUINOJSON_NAMESPACE::isnan; | using ArduinoJson::detail::isnan; | ||||||
| }  // namespace my | }  // namespace my | ||||||
|  |  | ||||||
| TEST_CASE("deserialize an integer") { | TEST_CASE("deserialize an integer") { | ||||||
|   | |||||||
| @@ -8,8 +8,6 @@ | |||||||
| #include <sstream> | #include <sstream> | ||||||
| #include <utility> | #include <utility> | ||||||
|  |  | ||||||
| using ARDUINOJSON_NAMESPACE::addPadding; |  | ||||||
|  |  | ||||||
| class SpyingAllocator { | class SpyingAllocator { | ||||||
|  public: |  public: | ||||||
|   SpyingAllocator(const SpyingAllocator& src) : _log(src._log) {} |   SpyingAllocator(const SpyingAllocator& src) : _log(src._log) {} | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using ARDUINOJSON_NAMESPACE::addPadding; | using ArduinoJson::detail::addPadding; | ||||||
|  |  | ||||||
| static void REQUIRE_JSON(JsonDocument& doc, const std::string& expected) { | static void REQUIRE_JSON(JsonDocument& doc, const std::string& expected) { | ||||||
|   std::string json; |   std::string json; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| typedef ARDUINOJSON_NAMESPACE::ElementProxy<JsonDocument&> ElementProxy; | typedef ArduinoJson::detail::ElementProxy<JsonDocument&> ElementProxy; | ||||||
|  |  | ||||||
| TEST_CASE("ElementProxy::add()") { | TEST_CASE("ElementProxy::add()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| typedef ARDUINOJSON_NAMESPACE::MemberProxy<JsonDocument&, const char*> | typedef ArduinoJson::detail::MemberProxy<JsonDocument&, const char*> | ||||||
|     MemberProxy; |     MemberProxy; | ||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::add()") { | TEST_CASE("MemberProxy::add()") { | ||||||
|   | |||||||
| @@ -8,8 +8,6 @@ | |||||||
| #include <stdlib.h>  // malloc, free | #include <stdlib.h>  // malloc, free | ||||||
| #include <string> | #include <string> | ||||||
|  |  | ||||||
| using ARDUINOJSON_NAMESPACE::addPadding; |  | ||||||
|  |  | ||||||
| class ArmoredAllocator { | class ArmoredAllocator { | ||||||
|  public: |  public: | ||||||
|   ArmoredAllocator() : _ptr(0), _size(0) {} |   ArmoredAllocator() : _ptr(0), _size(0) {} | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| namespace my { | namespace my { | ||||||
| using ARDUINOJSON_NAMESPACE::isinf; | using ArduinoJson::detail::isinf; | ||||||
| }  // namespace my | }  // namespace my | ||||||
|  |  | ||||||
| enum MY_ENUM { ONE = 1, TWO = 2 }; | enum MY_ENUM { ONE = 1, TWO = 2 }; | ||||||
|   | |||||||
| @@ -88,7 +88,7 @@ class Complex { | |||||||
|   double _real, _imag; |   double _real, _imag; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ArduinoJson { | ||||||
| template <> | template <> | ||||||
| struct Converter<Complex> { | struct Converter<Complex> { | ||||||
|   static void toJson(const Complex& src, JsonVariant dst) { |   static void toJson(const Complex& src, JsonVariant dst) { | ||||||
| @@ -104,7 +104,7 @@ struct Converter<Complex> { | |||||||
|     return src["real"].is<double>() && src["imag"].is<double>(); |     return src["real"].is<double>() && src["imag"].is<double>(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ArduinoJson | ||||||
|  |  | ||||||
| TEST_CASE("Custom converter with specialization") { | TEST_CASE("Custom converter with specialization") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
| @@ -142,7 +142,7 @@ TEST_CASE("Custom converter with specialization") { | |||||||
| } | } | ||||||
|  |  | ||||||
| TEST_CASE("ConverterNeedsWriteableRef") { | TEST_CASE("ConverterNeedsWriteableRef") { | ||||||
|   using namespace ARDUINOJSON_NAMESPACE; |   using namespace ArduinoJson::detail; | ||||||
|   CHECK(ConverterNeedsWriteableRef<int>::value == false); |   CHECK(ConverterNeedsWriteableRef<int>::value == false); | ||||||
|   CHECK(ConverterNeedsWriteableRef<float>::value == false); |   CHECK(ConverterNeedsWriteableRef<float>::value == false); | ||||||
|   CHECK(ConverterNeedsWriteableRef<JsonVariant>::value == true); |   CHECK(ConverterNeedsWriteableRef<JsonVariant>::value == true); | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
| #include <string> | #include <string> | ||||||
| #include <vector> | #include <vector> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ArduinoJson { | ||||||
| template <typename T> | template <typename T> | ||||||
| struct Converter<std::vector<T> > { | struct Converter<std::vector<T> > { | ||||||
|   static void toJson(const std::vector<T>& src, JsonVariant dst) { |   static void toJson(const std::vector<T>& src, JsonVariant dst) { | ||||||
| @@ -63,7 +63,7 @@ struct Converter<std::array<T, N> > { | |||||||
|     return result && size == N; |     return result && size == N; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ArduinoJson | ||||||
|  |  | ||||||
| TEST_CASE("vector<int>") { | TEST_CASE("vector<int>") { | ||||||
|   SECTION("toJson") { |   SECTION("toJson") { | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson/StringStorage/StringCopier.hpp> | #include <ArduinoJson/StringStorage/StringCopier.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("StringCopier") { | TEST_CASE("StringCopier") { | ||||||
|   char buffer[4096]; |   char buffer[4096]; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson/Memory/MemoryPool.hpp> | #include <ArduinoJson/Memory/MemoryPool.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("MemoryPool::allocVariant()") { | TEST_CASE("MemoryPool::allocVariant()") { | ||||||
|   char buffer[4096]; |   char buffer[4096]; | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| static const size_t poolCapacity = 512; | static const size_t poolCapacity = 512; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| static const char* saveString(MemoryPool& pool, const char* s) { | static const char* saveString(MemoryPool& pool, const char* s) { | ||||||
|   return pool.saveString(adaptString(const_cast<char*>(s))); |   return pool.saveString(adaptString(const_cast<char*>(s))); | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson/Memory/MemoryPool.hpp> | #include <ArduinoJson/Memory/MemoryPool.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("MemoryPool::capacity()") { | TEST_CASE("MemoryPool::capacity()") { | ||||||
|   char buffer[4096]; |   char buffer[4096]; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson/Numbers/FloatParts.hpp> | #include <ArduinoJson/Numbers/FloatParts.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("FloatParts<double>") { | TEST_CASE("FloatParts<double>") { | ||||||
|   SECTION("1.7976931348623157E+308") { |   SECTION("1.7976931348623157E+308") { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|  |  | ||||||
| #include <sstream> | #include <sstream> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("Reader<std::istringstream>") { | TEST_CASE("Reader<std::istringstream>") { | ||||||
|   SECTION("read()") { |   SECTION("read()") { | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ | |||||||
|  |  | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("ZeroTerminatedRamString") { | TEST_CASE("ZeroTerminatedRamString") { | ||||||
|   SECTION("null") { |   SECTION("null") { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
| #include "custom_string.hpp" | #include "custom_string.hpp" | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| template <typename StringWriter> | template <typename StringWriter> | ||||||
| static size_t print(StringWriter& writer, const char* s) { | static size_t print(StringWriter& writer, const char* s) { | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  |  | ||||||
| #include <sstream> | #include <sstream> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| class EmptyClass {}; | class EmptyClass {}; | ||||||
| enum EmptyEnum {}; | enum EmptyEnum {}; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson/Json/Utf16.hpp> | #include <ArduinoJson/Json/Utf16.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| static void testUtf16Codepoint(uint16_t codeunit, uint32_t expectedCodepoint) { | static void testUtf16Codepoint(uint16_t codeunit, uint32_t expectedCodepoint) { | ||||||
|   Utf16::Codepoint cp; |   Utf16::Codepoint cp; | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  |  | ||||||
| #include <string> | #include <string> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| static void testCodepoint(uint32_t codepoint, std::string expected) { | static void testCodepoint(uint32_t codepoint, std::string expected) { | ||||||
|   char buffer[4096]; |   char buffer[4096]; | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson/Numbers/arithmeticCompare.hpp> | #include <ArduinoJson/Numbers/arithmeticCompare.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("arithmeticCompare()") { | TEST_CASE("arithmeticCompare()") { | ||||||
|   SECTION("int vs uint8_t") { |   SECTION("int vs uint8_t") { | ||||||
|   | |||||||
| @@ -8,7 +8,8 @@ | |||||||
|  |  | ||||||
| // Issue #1198: strcmp() implementation that returns a value larger than 8-bit | // Issue #1198: strcmp() implementation that returns a value larger than 8-bit | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| int strcmp(const char* a, const char* b) { | int strcmp(const char* a, const char* b) { | ||||||
|   int result = ::strcmp(a, b); |   int result = ::strcmp(a, b); | ||||||
|   if (result > 0) |   if (result > 0) | ||||||
| @@ -26,4 +27,5 @@ int strncmp(const char* a, const char* b, size_t n) { | |||||||
|     return -214748364; |     return -214748364; | ||||||
|   return 0; |   return 0; | ||||||
| } | } | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -1,11 +1,11 @@ | |||||||
| #define ARDUINOJSON_NAMESPACE ArduinoJson_NoAlignment | #define ARDUINOJSON_VERSION_NAMESPACE NoAlignment | ||||||
| #define ARDUINOJSON_ENABLE_ALIGNMENT 0 | #define ARDUINOJSON_ENABLE_ALIGNMENT 0 | ||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
|  |  | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| TEST_CASE("ARDUINOJSON_ENABLE_ALIGNMENT == 0") { | TEST_CASE("ARDUINOJSON_ENABLE_ALIGNMENT == 0") { | ||||||
|   using namespace ARDUINOJSON_NAMESPACE; |   using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
|   const size_t N = sizeof(void*); |   const size_t N = sizeof(void*); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| TEST_CASE("ARDUINOJSON_ENABLE_ALIGNMENT == 1") { | TEST_CASE("ARDUINOJSON_ENABLE_ALIGNMENT == 1") { | ||||||
|   using namespace ARDUINOJSON_NAMESPACE; |   using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
|   const size_t N = sizeof(void*); |   const size_t N = sizeof(void*); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <limits> | #include <limits> | ||||||
|  |  | ||||||
| namespace my { | namespace my { | ||||||
| using ARDUINOJSON_NAMESPACE::isinf; | using ArduinoJson::detail::isinf; | ||||||
| }  // namespace my | }  // namespace my | ||||||
|  |  | ||||||
| TEST_CASE("ARDUINOJSON_ENABLE_INFINITY == 1") { | TEST_CASE("ARDUINOJSON_ENABLE_INFINITY == 1") { | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <limits> | #include <limits> | ||||||
|  |  | ||||||
| namespace my { | namespace my { | ||||||
| using ARDUINOJSON_NAMESPACE::isnan; | using ArduinoJson::detail::isnan; | ||||||
| }  // namespace my | }  // namespace my | ||||||
|  |  | ||||||
| TEST_CASE("ARDUINOJSON_ENABLE_NAN == 1") { | TEST_CASE("ARDUINOJSON_ENABLE_NAN == 1") { | ||||||
|   | |||||||
| @@ -53,7 +53,7 @@ TEST_CASE("Flash strings") { | |||||||
| } | } | ||||||
|  |  | ||||||
| TEST_CASE("parseNumber()") {  // tables are in Flash | TEST_CASE("parseNumber()") {  // tables are in Flash | ||||||
|   using ARDUINOJSON_NAMESPACE::parseNumber; |   using ArduinoJson::detail::parseNumber; | ||||||
|  |  | ||||||
|   CHECK(parseNumber<float>("1") == 1.f); |   CHECK(parseNumber<float>("1") == 1.f); | ||||||
|   CHECK(parseNumber<float>("1.23") == 1.23f); |   CHECK(parseNumber<float>("1.23") == 1.23f); | ||||||
| @@ -95,7 +95,7 @@ TEST_CASE("memcpy_P") { | |||||||
| } | } | ||||||
|  |  | ||||||
| TEST_CASE("BoundedReader<const __FlashStringHelper*>") { | TEST_CASE("BoundedReader<const __FlashStringHelper*>") { | ||||||
|   using namespace ARDUINOJSON_NAMESPACE; |   using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
|   SECTION("read") { |   SECTION("read") { | ||||||
|     BoundedReader<const __FlashStringHelper*> reader(F("\x01\xFF"), 2); |     BoundedReader<const __FlashStringHelper*> reader(F("\x01\xFF"), 2); | ||||||
| @@ -135,7 +135,7 @@ TEST_CASE("BoundedReader<const __FlashStringHelper*>") { | |||||||
| } | } | ||||||
|  |  | ||||||
| TEST_CASE("Reader<const __FlashStringHelper*>") { | TEST_CASE("Reader<const __FlashStringHelper*>") { | ||||||
|   using namespace ARDUINOJSON_NAMESPACE; |   using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
|   SECTION("read()") { |   SECTION("read()") { | ||||||
|     Reader<const __FlashStringHelper*> reader(F("\x01\xFF\x00\x12")); |     Reader<const __FlashStringHelper*> reader(F("\x01\xFF\x00\x12")); | ||||||
|   | |||||||
| @@ -5,7 +5,7 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| static void check(const char* input, T expected) { | static void check(const char* input, T expected) { | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
|  |  | ||||||
| #include <sstream> | #include <sstream> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("deserializeMsgPack() filter") { | TEST_CASE("deserializeMsgPack() filter") { | ||||||
|   StaticJsonDocument<4096> doc; |   StaticJsonDocument<4096> doc; | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| #include <ArduinoJson.hpp> | #include <ArduinoJson.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("canConvertNumber<TOut, TIn>()") { | TEST_CASE("canConvertNumber<TOut, TIn>()") { | ||||||
|   SECTION("int8_t -> int8_t") { |   SECTION("int8_t -> int8_t") { | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include <ArduinoJson.hpp> | #include <ArduinoJson.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| void checkDouble(const char* input, double expected) { | void checkDouble(const char* input, double expected) { | ||||||
|   CAPTURE(input); |   CAPTURE(input); | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include <ArduinoJson.hpp> | #include <ArduinoJson.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| void checkFloat(const char* input, float expected) { | void checkFloat(const char* input, float expected) { | ||||||
|   CAPTURE(input); |   CAPTURE(input); | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| #include <ArduinoJson.hpp> | #include <ArduinoJson.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| void checkInteger(const char* input, T expected) { | void checkInteger(const char* input, T expected) { | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ | |||||||
| #include <ArduinoJson.hpp> | #include <ArduinoJson.hpp> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson; | ||||||
|  | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| TEST_CASE("Test unsigned integer overflow") { | TEST_CASE("Test unsigned integer overflow") { | ||||||
|   VariantData first, second; |   VariantData first, second; | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ | |||||||
| #include <ArduinoJson/Json/TextFormatter.hpp> | #include <ArduinoJson/Json/TextFormatter.hpp> | ||||||
| #include <ArduinoJson/Serialization/Writer.hpp> | #include <ArduinoJson/Serialization/Writer.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| template <typename TFloat> | template <typename TFloat> | ||||||
| void check(TFloat input, const std::string& expected) { | void check(TFloat input, const std::string& expected) { | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include <ArduinoJson/Json/TextFormatter.hpp> | #include <ArduinoJson/Json/TextFormatter.hpp> | ||||||
| #include <ArduinoJson/Serialization/Writer.hpp> | #include <ArduinoJson/Serialization/Writer.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| void checkWriteInteger(T value, std::string expected) { | void checkWriteInteger(T value, std::string expected) { | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| #include <ArduinoJson/Json/TextFormatter.hpp> | #include <ArduinoJson/Json/TextFormatter.hpp> | ||||||
| #include <ArduinoJson/Serialization/Writers/StaticStringWriter.hpp> | #include <ArduinoJson/Serialization/Writers/StaticStringWriter.hpp> | ||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ArduinoJson::detail; | ||||||
|  |  | ||||||
| void check(const char* input, std::string expected) { | void check(const char* input, std::string expected) { | ||||||
|   char output[64] = {0}; |   char output[64] = {0}; | ||||||
|   | |||||||
| @@ -49,36 +49,3 @@ | |||||||
| #include "ArduinoJson/MsgPack/MsgPackSerializer.hpp" | #include "ArduinoJson/MsgPack/MsgPackSerializer.hpp" | ||||||
|  |  | ||||||
| #include "ArduinoJson/compatibility.hpp" | #include "ArduinoJson/compatibility.hpp" | ||||||
|  |  | ||||||
| namespace ArduinoJson { |  | ||||||
| using ARDUINOJSON_NAMESPACE::BasicJsonDocument; |  | ||||||
| using ARDUINOJSON_NAMESPACE::copyArray; |  | ||||||
| using ARDUINOJSON_NAMESPACE::DeserializationError; |  | ||||||
| using ARDUINOJSON_NAMESPACE::deserializeJson; |  | ||||||
| using ARDUINOJSON_NAMESPACE::deserializeMsgPack; |  | ||||||
| using ARDUINOJSON_NAMESPACE::DynamicJsonDocument; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonArray; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonArrayConst; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonDocument; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonFloat; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonInteger; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonObject; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonObjectConst; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonPair; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonPairConst; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonString; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonUInt; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonVariant; |  | ||||||
| using ARDUINOJSON_NAMESPACE::JsonVariantConst; |  | ||||||
| using ARDUINOJSON_NAMESPACE::measureJson; |  | ||||||
| using ARDUINOJSON_NAMESPACE::serialized; |  | ||||||
| using ARDUINOJSON_NAMESPACE::serializeJson; |  | ||||||
| using ARDUINOJSON_NAMESPACE::serializeJsonPretty; |  | ||||||
| using ARDUINOJSON_NAMESPACE::serializeMsgPack; |  | ||||||
| using ARDUINOJSON_NAMESPACE::StaticJsonDocument; |  | ||||||
|  |  | ||||||
| namespace DeserializationOption { |  | ||||||
| using ARDUINOJSON_NAMESPACE::Filter; |  | ||||||
| using ARDUINOJSON_NAMESPACE::NestingLimit; |  | ||||||
| }  // namespace DeserializationOption |  | ||||||
| }  // namespace ArduinoJson |  | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Variant/VariantRefBase.hpp> | #include <ArduinoJson/Variant/VariantRefBase.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| // A proxy class to get or set an element of an array. | // A proxy class to get or set an element of an array. | ||||||
| // https://arduinojson.org/v6/api/jsonarray/subscript/ | // https://arduinojson.org/v6/api/jsonarray/subscript/ | ||||||
| @@ -57,4 +57,4 @@ class ElementProxy : public VariantRefBase<ElementProxy<TUpstream> >, | |||||||
|   size_t _index; |   size_t _index; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -7,14 +7,14 @@ | |||||||
| #include <ArduinoJson/Array/ElementProxy.hpp> | #include <ArduinoJson/Array/ElementProxy.hpp> | ||||||
| #include <ArduinoJson/Array/JsonArrayConst.hpp> | #include <ArduinoJson/Array/JsonArrayConst.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| class JsonObject; | class JsonObject; | ||||||
|  |  | ||||||
| // A reference to an array in a JsonDocument | // A reference to an array in a JsonDocument | ||||||
| // https://arduinojson.org/v6/api/jsonarray/ | // https://arduinojson.org/v6/api/jsonarray/ | ||||||
| class JsonArray : public VariantOperators<JsonArray> { | class JsonArray : public detail::VariantOperators<JsonArray> { | ||||||
|   friend class VariantAttorney; |   friend class detail::VariantAttorney; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   typedef JsonArrayIterator iterator; |   typedef JsonArrayIterator iterator; | ||||||
| @@ -23,14 +23,14 @@ class JsonArray : public VariantOperators<JsonArray> { | |||||||
|   FORCE_INLINE JsonArray() : _data(0), _pool(0) {} |   FORCE_INLINE JsonArray() : _data(0), _pool(0) {} | ||||||
|  |  | ||||||
|   // INTERNAL USE ONLY |   // INTERNAL USE ONLY | ||||||
|   FORCE_INLINE JsonArray(MemoryPool* pool, CollectionData* data) |   FORCE_INLINE JsonArray(detail::MemoryPool* pool, detail::CollectionData* data) | ||||||
|       : _data(data), _pool(pool) {} |       : _data(data), _pool(pool) {} | ||||||
|  |  | ||||||
|   // Returns a JsonVariant pointing to the array. |   // Returns a JsonVariant pointing to the array. | ||||||
|   // https://arduinojson.org/v6/api/jsonvariant/ |   // https://arduinojson.org/v6/api/jsonvariant/ | ||||||
|   operator JsonVariant() { |   operator JsonVariant() { | ||||||
|     void* data = _data;  // prevent warning cast-align |     void* data = _data;  // prevent warning cast-align | ||||||
|     return JsonVariant(_pool, reinterpret_cast<VariantData*>(data)); |     return JsonVariant(_pool, reinterpret_cast<detail::VariantData*>(data)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Returns a read-only reference to the array. |   // Returns a read-only reference to the array. | ||||||
| @@ -118,8 +118,8 @@ class JsonArray : public VariantOperators<JsonArray> { | |||||||
|  |  | ||||||
|   // Gets or sets the element at the specified index. |   // Gets or sets the element at the specified index. | ||||||
|   // https://arduinojson.org/v6/api/jsonarray/subscript/ |   // https://arduinojson.org/v6/api/jsonarray/subscript/ | ||||||
|   FORCE_INLINE ElementProxy<JsonArray> operator[](size_t index) const { |   FORCE_INLINE detail::ElementProxy<JsonArray> operator[](size_t index) const { | ||||||
|     return ElementProxy<JsonArray>(*this, index); |     return {*this, index}; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Creates an object and appends it to the array. |   // Creates an object and appends it to the array. | ||||||
| @@ -167,35 +167,35 @@ class JsonArray : public VariantOperators<JsonArray> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool* getPool() const { |   detail::MemoryPool* getPool() const { | ||||||
|     return _pool; |     return _pool; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData* getData() const { |   detail::VariantData* getData() const { | ||||||
|     return collectionToVariant(_data); |     return collectionToVariant(_data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData* getOrCreateData() const { |   detail::VariantData* getOrCreateData() const { | ||||||
|     return collectionToVariant(_data); |     return collectionToVariant(_data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CollectionData* _data; |   detail::CollectionData* _data; | ||||||
|   MemoryPool* _pool; |   detail::MemoryPool* _pool; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| struct Converter<JsonArray> : private VariantAttorney { | struct Converter<JsonArray> : private detail::VariantAttorney { | ||||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { |   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); |     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static JsonArray fromJson(JsonVariant src) { |   static JsonArray fromJson(JsonVariant src) { | ||||||
|     VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     MemoryPool* pool = getPool(src); |     auto pool = getPool(src); | ||||||
|     return JsonArray(pool, data != 0 ? data->asArray() : 0); |     return JsonArray(pool, data != 0 ? data->asArray() : 0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static InvalidConversion<JsonVariantConst, JsonArray> fromJson( |   static detail::InvalidConversion<JsonVariantConst, JsonArray> fromJson( | ||||||
|       JsonVariantConst); |       JsonVariantConst); | ||||||
|  |  | ||||||
|   static bool checkJson(JsonVariantConst) { |   static bool checkJson(JsonVariantConst) { | ||||||
| @@ -203,8 +203,9 @@ struct Converter<JsonArray> : private VariantAttorney { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   static bool checkJson(JsonVariant src) { |   static bool checkJson(JsonVariant src) { | ||||||
|     VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     return data && data->isArray(); |     return data && data->isArray(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -8,15 +8,15 @@ | |||||||
| #include <ArduinoJson/Variant/VariantAttorney.hpp> | #include <ArduinoJson/Variant/VariantAttorney.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantData.hpp> | #include <ArduinoJson/Variant/VariantData.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| class JsonObject; | class JsonObject; | ||||||
|  |  | ||||||
| // A read-only reference to an array in a JsonDocument | // A read-only reference to an array in a JsonDocument | ||||||
| // https://arduinojson.org/v6/api/jsonarrayconst/ | // https://arduinojson.org/v6/api/jsonarrayconst/ | ||||||
| class JsonArrayConst : public VariantOperators<JsonArrayConst> { | class JsonArrayConst : public detail::VariantOperators<JsonArrayConst> { | ||||||
|   friend class JsonArray; |   friend class JsonArray; | ||||||
|   friend class VariantAttorney; |   friend class detail::VariantAttorney; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   typedef JsonArrayConstIterator iterator; |   typedef JsonArrayConstIterator iterator; | ||||||
| @@ -39,7 +39,8 @@ class JsonArrayConst : public VariantOperators<JsonArrayConst> { | |||||||
|   FORCE_INLINE JsonArrayConst() : _data(0) {} |   FORCE_INLINE JsonArrayConst() : _data(0) {} | ||||||
|  |  | ||||||
|   // INTERNAL USE ONLY |   // INTERNAL USE ONLY | ||||||
|   FORCE_INLINE JsonArrayConst(const CollectionData* data) : _data(data) {} |   FORCE_INLINE JsonArrayConst(const detail::CollectionData* data) | ||||||
|  |       : _data(data) {} | ||||||
|  |  | ||||||
|   // Compares the content of two arrays. |   // Compares the content of two arrays. | ||||||
|   // Returns true if the two arrays are equal. |   // Returns true if the two arrays are equal. | ||||||
| @@ -107,28 +108,28 @@ class JsonArrayConst : public VariantOperators<JsonArrayConst> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const VariantData* getData() const { |   const detail::VariantData* getData() const { | ||||||
|     return collectionToVariant(_data); |     return collectionToVariant(_data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const CollectionData* _data; |   const detail::CollectionData* _data; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| struct Converter<JsonArrayConst> : private VariantAttorney { | struct Converter<JsonArrayConst> : private detail::VariantAttorney { | ||||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { |   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); |     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static JsonArrayConst fromJson(JsonVariantConst src) { |   static JsonArrayConst fromJson(JsonVariantConst src) { | ||||||
|     const VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     return data ? data->asArray() : 0; |     return data ? data->asArray() : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static bool checkJson(JsonVariantConst src) { |   static bool checkJson(JsonVariantConst src) { | ||||||
|     const VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     return data && data->isArray(); |     return data && data->isArray(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -7,12 +7,16 @@ | |||||||
| #include <ArduinoJson/Array/JsonArray.hpp> | #include <ArduinoJson/Array/JsonArray.hpp> | ||||||
| #include <ArduinoJson/Object/JsonObject.hpp> | #include <ArduinoJson/Object/JsonObject.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| inline JsonObject JsonArray::createNestedObject() const { | inline JsonObject JsonArray::createNestedObject() const { | ||||||
|   return add().to<JsonObject>(); |   return add().to<JsonObject>(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
|  | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TDerived> | template <typename TDerived> | ||||||
| inline JsonArray VariantRefBase<TDerived>::createNestedArray() const { | inline JsonArray VariantRefBase<TDerived>::createNestedArray() const { | ||||||
|   return add().template to<JsonArray>(); |   return add().template to<JsonArray>(); | ||||||
| @@ -29,4 +33,4 @@ inline ElementProxy<TDerived> VariantRefBase<TDerived>::operator[]( | |||||||
|   return ElementProxy<TDerived>(derived(), index); |   return ElementProxy<TDerived>(derived(), index); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -7,11 +7,12 @@ | |||||||
| #include <ArduinoJson/Variant/JsonVariant.hpp> | #include <ArduinoJson/Variant/JsonVariant.hpp> | ||||||
| #include <ArduinoJson/Variant/SlotFunctions.hpp> | #include <ArduinoJson/Variant/SlotFunctions.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| class VariantPtr { | class VariantPtr { | ||||||
|  public: |  public: | ||||||
|   VariantPtr(MemoryPool* pool, VariantData* data) : _variant(pool, data) {} |   VariantPtr(detail::MemoryPool* pool, detail::VariantData* data) | ||||||
|  |       : _variant(pool, data) {} | ||||||
|  |  | ||||||
|   JsonVariant* operator->() { |   JsonVariant* operator->() { | ||||||
|     return &_variant; |     return &_variant; | ||||||
| @@ -30,7 +31,8 @@ class JsonArrayIterator { | |||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   JsonArrayIterator() : _slot(0) {} |   JsonArrayIterator() : _slot(0) {} | ||||||
|   explicit JsonArrayIterator(MemoryPool* pool, VariantSlot* slot) |   explicit JsonArrayIterator(detail::MemoryPool* pool, | ||||||
|  |                              detail::VariantSlot* slot) | ||||||
|       : _pool(pool), _slot(slot) {} |       : _pool(pool), _slot(slot) {} | ||||||
|  |  | ||||||
|   JsonVariant operator*() const { |   JsonVariant operator*() const { | ||||||
| @@ -59,13 +61,13 @@ class JsonArrayIterator { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool* _pool; |   detail::MemoryPool* _pool; | ||||||
|   VariantSlot* _slot; |   detail::VariantSlot* _slot; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class VariantConstPtr { | class VariantConstPtr { | ||||||
|  public: |  public: | ||||||
|   VariantConstPtr(const VariantData* data) : _variant(data) {} |   VariantConstPtr(const detail::VariantData* data) : _variant(data) {} | ||||||
|  |  | ||||||
|   JsonVariantConst* operator->() { |   JsonVariantConst* operator->() { | ||||||
|     return &_variant; |     return &_variant; | ||||||
| @@ -84,7 +86,8 @@ class JsonArrayConstIterator { | |||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   JsonArrayConstIterator() : _slot(0) {} |   JsonArrayConstIterator() : _slot(0) {} | ||||||
|   explicit JsonArrayConstIterator(const VariantSlot* slot) : _slot(slot) {} |   explicit JsonArrayConstIterator(const detail::VariantSlot* slot) | ||||||
|  |       : _slot(slot) {} | ||||||
|  |  | ||||||
|   JsonVariantConst operator*() const { |   JsonVariantConst operator*() const { | ||||||
|     return JsonVariantConst(_slot->data()); |     return JsonVariantConst(_slot->data()); | ||||||
| @@ -112,6 +115,7 @@ class JsonArrayConstIterator { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const VariantSlot* _slot; |   const detail::VariantSlot* _slot; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -7,21 +7,21 @@ | |||||||
| #include <ArduinoJson/Array/JsonArray.hpp> | #include <ArduinoJson/Array/JsonArray.hpp> | ||||||
| #include <ArduinoJson/Document/JsonDocument.hpp> | #include <ArduinoJson/Document/JsonDocument.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // Copies a value to a JsonVariant. | // Copies a value to a JsonVariant. | ||||||
| // This is a degenerated form of copyArray() to stop the recursion. | // This is a degenerated form of copyArray() to stop the recursion. | ||||||
| template <typename T> | template <typename T> | ||||||
| inline typename enable_if<!is_array<T>::value, bool>::type copyArray( | inline typename detail::enable_if<!detail::is_array<T>::value, bool>::type | ||||||
|     const T& src, JsonVariant dst) { | copyArray(const T& src, JsonVariant dst) { | ||||||
|   return dst.set(src); |   return dst.set(src); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Copies values from an array to a JsonArray or a JsonVariant. | // Copies values from an array to a JsonArray or a JsonVariant. | ||||||
| // https://arduinojson.org/v6/api/misc/copyarray/ | // https://arduinojson.org/v6/api/misc/copyarray/ | ||||||
| template <typename T, size_t N, typename TDestination> | template <typename T, size_t N, typename TDestination> | ||||||
| inline typename enable_if<!is_base_of<JsonDocument, TDestination>::value, | inline typename detail::enable_if< | ||||||
|                           bool>::type |     !detail::is_base_of<JsonDocument, TDestination>::value, bool>::type | ||||||
| copyArray(T (&src)[N], const TDestination& dst) { | copyArray(T (&src)[N], const TDestination& dst) { | ||||||
|   return copyArray(src, N, dst); |   return copyArray(src, N, dst); | ||||||
| } | } | ||||||
| @@ -29,8 +29,8 @@ copyArray(T (&src)[N], const TDestination& dst) { | |||||||
| // Copies values from an array to a JsonArray or a JsonVariant. | // Copies values from an array to a JsonArray or a JsonVariant. | ||||||
| // https://arduinojson.org/v6/api/misc/copyarray/ | // https://arduinojson.org/v6/api/misc/copyarray/ | ||||||
| template <typename T, typename TDestination> | template <typename T, typename TDestination> | ||||||
| inline typename enable_if<!is_base_of<JsonDocument, TDestination>::value, | inline typename detail::enable_if< | ||||||
|                           bool>::type |     !detail::is_base_of<JsonDocument, TDestination>::value, bool>::type | ||||||
| copyArray(const T* src, size_t len, const TDestination& dst) { | copyArray(const T* src, size_t len, const TDestination& dst) { | ||||||
|   bool ok = true; |   bool ok = true; | ||||||
|   for (size_t i = 0; i < len; i++) { |   for (size_t i = 0; i < len; i++) { | ||||||
| @@ -63,8 +63,8 @@ inline bool copyArray(const T* src, size_t len, JsonDocument& dst) { | |||||||
| // Copies a value from a JsonVariant. | // Copies a value from a JsonVariant. | ||||||
| // This is a degenerated form of copyArray() to stop the recursion. | // This is a degenerated form of copyArray() to stop the recursion. | ||||||
| template <typename T> | template <typename T> | ||||||
| inline typename enable_if<!is_array<T>::value, size_t>::type copyArray( | inline typename detail::enable_if<!detail::is_array<T>::value, size_t>::type | ||||||
|     JsonVariantConst src, T& dst) { | copyArray(JsonVariantConst src, T& dst) { | ||||||
|   dst = src.as<T>(); |   dst = src.as<T>(); | ||||||
|   return 1; |   return 1; | ||||||
| } | } | ||||||
| @@ -103,11 +103,12 @@ inline size_t copyArray(JsonVariantConst src, char (&dst)[N]) { | |||||||
| // Copies values from a JsonDocument to an array. | // Copies values from a JsonDocument to an array. | ||||||
| // https://arduinojson.org/v6/api/misc/copyarray/ | // https://arduinojson.org/v6/api/misc/copyarray/ | ||||||
| template <typename TSource, typename T> | template <typename TSource, typename T> | ||||||
| inline typename enable_if<is_array<T>::value && | inline typename detail::enable_if< | ||||||
|                               is_base_of<JsonDocument, TSource>::value, |     detail::is_array<T>::value && | ||||||
|                           size_t>::type |         detail::is_base_of<JsonDocument, TSource>::value, | ||||||
|  |     size_t>::type | ||||||
| copyArray(const TSource& src, T& dst) { | copyArray(const TSource& src, T& dst) { | ||||||
|   return copyArray(src.template as<JsonArrayConst>(), dst); |   return copyArray(src.template as<JsonArrayConst>(), dst); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|  |  | ||||||
| #include <stddef.h>  // size_t | #include <stddef.h>  // size_t | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| class MemoryPool; | class MemoryPool; | ||||||
| class VariantData; | class VariantData; | ||||||
| @@ -91,4 +91,5 @@ inline VariantData* collectionToVariant(CollectionData* collection) { | |||||||
|   void* data = collection;  // prevent warning cast-align |   void* data = collection;  // prevent warning cast-align | ||||||
|   return reinterpret_cast<VariantData*>(data); |   return reinterpret_cast<VariantData*>(data); | ||||||
| } | } | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantData.hpp> | #include <ArduinoJson/Variant/VariantData.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) { | inline VariantSlot* CollectionData::addSlot(MemoryPool* pool) { | ||||||
|   VariantSlot* slot = pool->allocVariant(); |   VariantSlot* slot = pool->allocVariant(); | ||||||
| @@ -194,4 +194,4 @@ inline void CollectionData::movePointers(ptrdiff_t stringDistance, | |||||||
|     slot->movePointers(stringDistance, variantDistance); |     slot->movePointers(stringDistance, variantDistance); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ | |||||||
| #  include <ostream> | #  include <ostream> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| class DeserializationError { | class DeserializationError { | ||||||
|  public: |  public: | ||||||
| @@ -82,7 +82,7 @@ class DeserializationError { | |||||||
|     ARDUINOJSON_DEFINE_PROGMEM_ARRAY( |     ARDUINOJSON_DEFINE_PROGMEM_ARRAY( | ||||||
|         const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5})); |         const char*, messages, ARDUINOJSON_EXPAND6({s0, s1, s2, s3, s4, s5})); | ||||||
|     return reinterpret_cast<const __FlashStringHelper*>( |     return reinterpret_cast<const __FlashStringHelper*>( | ||||||
|         pgm_read(messages + _code)); |         detail::pgm_read(messages + _code)); | ||||||
|   } |   } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -103,4 +103,4 @@ inline std::ostream& operator<<(std::ostream& s, DeserializationError::Code c) { | |||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -6,8 +6,9 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Namespace.hpp> | #include <ArduinoJson/Namespace.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
|  | namespace DeserializationOption { | ||||||
| class Filter { | class Filter { | ||||||
|  public: |  public: | ||||||
|   explicit Filter(JsonVariantConst v) : _variant(v) {} |   explicit Filter(JsonVariantConst v) : _variant(v) {} | ||||||
| @@ -39,7 +40,9 @@ class Filter { | |||||||
|  private: |  private: | ||||||
|   JsonVariantConst _variant; |   JsonVariantConst _variant; | ||||||
| }; | }; | ||||||
|  | }  // namespace DeserializationOption | ||||||
|  |  | ||||||
|  | namespace detail { | ||||||
| struct AllowAllFilter { | struct AllowAllFilter { | ||||||
|   bool allow() const { |   bool allow() const { | ||||||
|     return true; |     return true; | ||||||
| @@ -62,5 +65,6 @@ struct AllowAllFilter { | |||||||
|     return AllowAllFilter(); |     return AllowAllFilter(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  | }  // namespace detail | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -7,8 +7,9 @@ | |||||||
| #include <ArduinoJson/Namespace.hpp> | #include <ArduinoJson/Namespace.hpp> | ||||||
| #include <ArduinoJson/Polyfills/assert.hpp> | #include <ArduinoJson/Polyfills/assert.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
|  | namespace DeserializationOption { | ||||||
| class NestingLimit { | class NestingLimit { | ||||||
|  public: |  public: | ||||||
|   NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} |   NestingLimit() : _value(ARDUINOJSON_DEFAULT_NESTING_LIMIT) {} | ||||||
| @@ -26,4 +27,6 @@ class NestingLimit { | |||||||
|  private: |  private: | ||||||
|   uint8_t _value; |   uint8_t _value; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace DeserializationOption | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|  |  | ||||||
| #include <stdlib.h>  // for size_t | #include <stdlib.h>  // for size_t | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| // The default reader is a simple wrapper for Readers that are not copiable | // The default reader is a simple wrapper for Readers that are not copiable | ||||||
| template <typename TSource, typename Enable = void> | template <typename TSource, typename Enable = void> | ||||||
| @@ -33,7 +33,8 @@ struct BoundedReader { | |||||||
|   // no default implementation because we need to pass the size to the |   // no default implementation because we need to pass the size to the | ||||||
|   // constructor |   // constructor | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| #include <ArduinoJson/Deserialization/Readers/IteratorReader.hpp> | #include <ArduinoJson/Deserialization/Readers/IteratorReader.hpp> | ||||||
| #include <ArduinoJson/Deserialization/Readers/RamReader.hpp> | #include <ArduinoJson/Deserialization/Readers/RamReader.hpp> | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <Arduino.h> | #include <Arduino.h> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TSource> | template <typename TSource> | ||||||
| struct Reader<TSource, | struct Reader<TSource, | ||||||
| @@ -28,4 +28,4 @@ struct Reader<TSource, | |||||||
|   Stream* _stream; |   Stream* _stream; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <Arduino.h> | #include <Arduino.h> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TSource> | template <typename TSource> | ||||||
| struct Reader<TSource, | struct Reader<TSource, | ||||||
| @@ -16,4 +16,4 @@ struct Reader<TSource, | |||||||
|       : BoundedReader<const char*>(s.c_str(), s.length()) {} |       : BoundedReader<const char*>(s.c_str(), s.length()) {} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <Arduino.h> | #include <Arduino.h> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| struct Reader<const __FlashStringHelper*, void> { | struct Reader<const __FlashStringHelper*, void> { | ||||||
| @@ -52,4 +52,5 @@ struct BoundedReader<const __FlashStringHelper*, void> { | |||||||
|     return length; |     return length; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -4,7 +4,7 @@ | |||||||
|  |  | ||||||
| #pragma once | #pragma once | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TIterator> | template <typename TIterator> | ||||||
| class IteratorReader { | class IteratorReader { | ||||||
| @@ -41,4 +41,5 @@ struct Reader<TSource, typename void_<typename TSource::const_iterator>::type> | |||||||
|       : IteratorReader<typename TSource::const_iterator>(source.begin(), |       : IteratorReader<typename TSource::const_iterator>(source.begin(), | ||||||
|                                                          source.end()) {} |                                                          source.end()) {} | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| struct IsCharOrVoid { | struct IsCharOrVoid { | ||||||
| @@ -48,4 +48,4 @@ struct BoundedReader<TSource*, | |||||||
|                                     reinterpret_cast<const char*>(ptr) + len) {} |                                     reinterpret_cast<const char*>(ptr) + len) {} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <istream> | #include <istream> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TSource> | template <typename TSource> | ||||||
| struct Reader<TSource, typename enable_if< | struct Reader<TSource, typename enable_if< | ||||||
| @@ -26,4 +26,5 @@ struct Reader<TSource, typename enable_if< | |||||||
|  private: |  private: | ||||||
|   std::istream* _stream; |   std::istream* _stream; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| #include <ArduinoJson/Object/MemberProxy.hpp> | #include <ArduinoJson/Object/MemberProxy.hpp> | ||||||
| #include <ArduinoJson/Variant/JsonVariantConst.hpp> | #include <ArduinoJson/Variant/JsonVariantConst.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TVariant> | template <typename TVariant> | ||||||
| struct Reader<TVariant, typename enable_if<IsVariant<TVariant>::value>::type> | struct Reader<TVariant, typename enable_if<IsVariant<TVariant>::value>::type> | ||||||
| @@ -16,4 +16,4 @@ struct Reader<TVariant, typename enable_if<IsVariant<TVariant>::value>::type> | |||||||
|       : Reader<char*, void>(x.template as<const char*>()) {} |       : Reader<char*, void>(x.template as<const char*>()) {} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
| #include <ArduinoJson/Deserialization/Reader.hpp> | #include <ArduinoJson/Deserialization/Reader.hpp> | ||||||
| #include <ArduinoJson/StringStorage/StringStorage.hpp> | #include <ArduinoJson/StringStorage/StringStorage.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <template <typename, typename> class TDeserializer, typename TReader, | template <template <typename, typename> class TDeserializer, typename TReader, | ||||||
|           typename TWriter> |           typename TWriter> | ||||||
| @@ -28,9 +28,10 @@ TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool, | |||||||
| // deserialize(JsonDocument&, const __FlashStringHelper*, NestingLimit, Filter); | // deserialize(JsonDocument&, const __FlashStringHelper*, NestingLimit, Filter); | ||||||
| template <template <typename, typename> class TDeserializer, typename TString, | template <template <typename, typename> class TDeserializer, typename TString, | ||||||
|           typename TFilter> |           typename TFilter> | ||||||
| typename enable_if<!is_array<TString>::value, DeserializationError>::type | typename detail::enable_if<!is_array<TString>::value, | ||||||
| deserialize(JsonDocument& doc, const TString& input, NestingLimit nestingLimit, |                            DeserializationError>::type | ||||||
|             TFilter filter) { | deserialize(JsonDocument& doc, const TString& input, | ||||||
|  |             DeserializationOption::NestingLimit nestingLimit, TFilter filter) { | ||||||
|   Reader<TString> reader(input); |   Reader<TString> reader(input); | ||||||
|   VariantData* data = VariantAttorney::getData(doc); |   VariantData* data = VariantAttorney::getData(doc); | ||||||
|   MemoryPool* pool = VariantAttorney::getPool(doc); |   MemoryPool* pool = VariantAttorney::getPool(doc); | ||||||
| @@ -45,9 +46,9 @@ deserialize(JsonDocument& doc, const TString& input, NestingLimit nestingLimit, | |||||||
| // deserialize(JsonDocument&, const __FlashStringHelper*, size_t, NL, Filter); | // deserialize(JsonDocument&, const __FlashStringHelper*, size_t, NL, Filter); | ||||||
| template <template <typename, typename> class TDeserializer, typename TChar, | template <template <typename, typename> class TDeserializer, typename TChar, | ||||||
|           typename TFilter> |           typename TFilter> | ||||||
| DeserializationError deserialize(JsonDocument& doc, TChar* input, | DeserializationError deserialize( | ||||||
|                                  size_t inputSize, NestingLimit nestingLimit, |     JsonDocument& doc, TChar* input, size_t inputSize, | ||||||
|                                  TFilter filter) { |     DeserializationOption::NestingLimit nestingLimit, TFilter filter) { | ||||||
|   BoundedReader<TChar*> reader(input, inputSize); |   BoundedReader<TChar*> reader(input, inputSize); | ||||||
|   VariantData* data = VariantAttorney::getData(doc); |   VariantData* data = VariantAttorney::getData(doc); | ||||||
|   MemoryPool* pool = VariantAttorney::getPool(doc); |   MemoryPool* pool = VariantAttorney::getPool(doc); | ||||||
| @@ -61,8 +62,9 @@ DeserializationError deserialize(JsonDocument& doc, TChar* input, | |||||||
| // deserialize(JsonDocument&, Stream&, NestingLimit, Filter); | // deserialize(JsonDocument&, Stream&, NestingLimit, Filter); | ||||||
| template <template <typename, typename> class TDeserializer, typename TStream, | template <template <typename, typename> class TDeserializer, typename TStream, | ||||||
|           typename TFilter> |           typename TFilter> | ||||||
| DeserializationError deserialize(JsonDocument& doc, TStream& input, | DeserializationError deserialize( | ||||||
|                                  NestingLimit nestingLimit, TFilter filter) { |     JsonDocument& doc, TStream& input, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit, TFilter filter) { | ||||||
|   Reader<TStream> reader(input); |   Reader<TStream> reader(input); | ||||||
|   VariantData* data = VariantAttorney::getData(doc); |   VariantData* data = VariantAttorney::getData(doc); | ||||||
|   MemoryPool* pool = VariantAttorney::getPool(doc); |   MemoryPool* pool = VariantAttorney::getPool(doc); | ||||||
| @@ -72,4 +74,4 @@ DeserializationError deserialize(JsonDocument& doc, TStream& input, | |||||||
|       .parse(*data, filter, nestingLimit); |       .parse(*data, filter, nestingLimit); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Document/JsonDocument.hpp> | #include <ArduinoJson/Document/JsonDocument.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // Helper to implement the "base-from-member" idiom | // Helper to implement the "base-from-member" idiom | ||||||
| // (we need to store the allocator before constructing JsonDocument) | // (we need to store the allocator before constructing JsonDocument) | ||||||
| @@ -62,13 +62,14 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument { | |||||||
|  |  | ||||||
|   // Construct from variant, array, or object |   // Construct from variant, array, or object | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   BasicJsonDocument( |   BasicJsonDocument(const T& src, | ||||||
|       const T& src, |                     typename detail::enable_if< | ||||||
|       typename enable_if< |                         detail::is_same<T, JsonVariant>::value || | ||||||
|           is_same<T, JsonVariant>::value || |                         detail::is_same<T, JsonVariantConst>::value || | ||||||
|           is_same<T, JsonVariantConst>::value || is_same<T, JsonArray>::value || |                         detail::is_same<T, JsonArray>::value || | ||||||
|           is_same<T, JsonArrayConst>::value || is_same<T, JsonObject>::value || |                         detail::is_same<T, JsonArrayConst>::value || | ||||||
|           is_same<T, JsonObjectConst>::value>::type* = 0) |                         detail::is_same<T, JsonObject>::value || | ||||||
|  |                         detail::is_same<T, JsonObjectConst>::value>::type* = 0) | ||||||
|       : JsonDocument(allocPool(src.memoryUsage())) { |       : JsonDocument(allocPool(src.memoryUsage())) { | ||||||
|     set(src); |     set(src); | ||||||
|   } |   } | ||||||
| @@ -134,17 +135,17 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument { | |||||||
|   using AllocatorOwner<TAllocator>::allocator; |   using AllocatorOwner<TAllocator>::allocator; | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool allocPool(size_t requiredSize) { |   detail::MemoryPool allocPool(size_t requiredSize) { | ||||||
|     size_t capa = addPadding(requiredSize); |     size_t capa = detail::addPadding(requiredSize); | ||||||
|     return MemoryPool(reinterpret_cast<char*>(this->allocate(capa)), capa); |     return {reinterpret_cast<char*>(this->allocate(capa)), capa}; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void reallocPool(size_t requiredSize) { |   void reallocPool(size_t requiredSize) { | ||||||
|     size_t capa = addPadding(requiredSize); |     size_t capa = detail::addPadding(requiredSize); | ||||||
|     if (capa == _pool.capacity()) |     if (capa == _pool.capacity()) | ||||||
|       return; |       return; | ||||||
|     freePool(); |     freePool(); | ||||||
|     replacePool(allocPool(addPadding(requiredSize))); |     replacePool(allocPool(detail::addPadding(requiredSize))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void freePool() { |   void freePool() { | ||||||
| @@ -161,8 +162,8 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument { | |||||||
|     _data = src._data; |     _data = src._data; | ||||||
|     _pool = src._pool; |     _pool = src._pool; | ||||||
|     src._data.setNull(); |     src._data.setNull(); | ||||||
|     src._pool = MemoryPool(0, 0); |     src._pool = {0, 0}; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|  |  | ||||||
| #include <stdlib.h>  // malloc, free | #include <stdlib.h>  // malloc, free | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // The allocator of DynamicJsonDocument. | // The allocator of DynamicJsonDocument. | ||||||
| struct DefaultAllocator { | struct DefaultAllocator { | ||||||
| @@ -29,4 +29,4 @@ struct DefaultAllocator { | |||||||
| // https://arduinojson.org/v6/api/dynamicjsondocument/ | // https://arduinojson.org/v6/api/dynamicjsondocument/ | ||||||
| typedef BasicJsonDocument<DefaultAllocator> DynamicJsonDocument; | typedef BasicJsonDocument<DefaultAllocator> DynamicJsonDocument; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -12,12 +12,12 @@ | |||||||
| #include <ArduinoJson/Variant/JsonVariantConst.hpp> | #include <ArduinoJson/Variant/JsonVariantConst.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantTo.hpp> | #include <ArduinoJson/Variant/VariantTo.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // A JSON document. | // A JSON document. | ||||||
| // https://arduinojson.org/v6/api/jsondocument/ | // https://arduinojson.org/v6/api/jsondocument/ | ||||||
| class JsonDocument : public VariantOperators<const JsonDocument&> { | class JsonDocument : public detail::VariantOperators<const JsonDocument&> { | ||||||
|   friend class VariantAttorney; |   friend class detail::VariantAttorney; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   // Casts the root to the specified type. |   // Casts the root to the specified type. | ||||||
| @@ -100,15 +100,16 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   // Replaces the root with the specified value. |   // Replaces the root with the specified value. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/set/ |   // https://arduinojson.org/v6/api/jsondocument/set/ | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   typename enable_if<!is_base_of<JsonDocument, T>::value, bool>::type set( |   typename detail::enable_if<!detail::is_base_of<JsonDocument, T>::value, | ||||||
|       const T& src) { |                              bool>::type | ||||||
|  |   set(const T& src) { | ||||||
|     return to<JsonVariant>().set(src); |     return to<JsonVariant>().set(src); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Clears the document and converts it to the specified type. |   // Clears the document and converts it to the specified type. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/to/ |   // https://arduinojson.org/v6/api/jsondocument/to/ | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   typename VariantTo<T>::type to() { |   typename detail::VariantTo<T>::type to() { | ||||||
|     clear(); |     clear(); | ||||||
|     return getVariant().template to<T>(); |     return getVariant().template to<T>(); | ||||||
|   } |   } | ||||||
| @@ -157,56 +158,58 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   // https://arduinojson.org/v6/api/jsondocument/containskey/ |   // https://arduinojson.org/v6/api/jsondocument/containskey/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   bool containsKey(TChar* key) const { |   bool containsKey(TChar* key) const { | ||||||
|     return _data.getMember(adaptString(key)) != 0; |     return _data.getMember(detail::adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Returns true if the root object contains the specified key. |   // Returns true if the root object contains the specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/containskey/ |   // https://arduinojson.org/v6/api/jsondocument/containskey/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   bool containsKey(const TString& key) const { |   bool containsKey(const TString& key) const { | ||||||
|     return _data.getMember(adaptString(key)) != 0; |     return _data.getMember(detail::adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets or sets a root object's member. |   // Gets or sets a root object's member. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ |   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, |   FORCE_INLINE typename detail::enable_if< | ||||||
|                                   MemberProxy<JsonDocument&, TString> >::type |       detail::IsString<TString>::value, | ||||||
|  |       detail::MemberProxy<JsonDocument&, TString> >::type | ||||||
|   operator[](const TString& key) { |   operator[](const TString& key) { | ||||||
|     return MemberProxy<JsonDocument&, TString>(*this, key); |     return {*this, key}; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets or sets a root object's member. |   // Gets or sets a root object's member. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ |   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, |   FORCE_INLINE typename detail::enable_if< | ||||||
|                                   MemberProxy<JsonDocument&, TChar*> >::type |       detail::IsString<TChar*>::value, | ||||||
|  |       detail::MemberProxy<JsonDocument&, TChar*> >::type | ||||||
|   operator[](TChar* key) { |   operator[](TChar* key) { | ||||||
|     return MemberProxy<JsonDocument&, TChar*>(*this, key); |     return {*this, key}; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets a root object's member. |   // Gets a root object's member. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ |   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE |   FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value, | ||||||
|       typename enable_if<IsString<TString>::value, JsonVariantConst>::type |                                           JsonVariantConst>::type | ||||||
|       operator[](const TString& key) const { |   operator[](const TString& key) const { | ||||||
|     return JsonVariantConst(_data.getMember(adaptString(key))); |     return JsonVariantConst(_data.getMember(detail::adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets a root object's member. |   // Gets a root object's member. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ |   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE |   FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value, | ||||||
|       typename enable_if<IsString<TChar*>::value, JsonVariantConst>::type |                                           JsonVariantConst>::type | ||||||
|       operator[](TChar* key) const { |   operator[](TChar* key) const { | ||||||
|     return JsonVariantConst(_data.getMember(adaptString(key))); |     return JsonVariantConst(_data.getMember(detail::adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets or sets a root array's element. |   // Gets or sets a root array's element. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/subscript/ |   // https://arduinojson.org/v6/api/jsondocument/subscript/ | ||||||
|   FORCE_INLINE ElementProxy<JsonDocument&> operator[](size_t index) { |   FORCE_INLINE detail::ElementProxy<JsonDocument&> operator[](size_t index) { | ||||||
|     return ElementProxy<JsonDocument&>(*this, index); |     return {*this, index}; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets a root array's member. |   // Gets a root array's member. | ||||||
| @@ -247,18 +250,19 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   // ⚠️ Doesn't release the memory associated with the removed element. |   // ⚠️ Doesn't release the memory associated with the removed element. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/remove/ |   // https://arduinojson.org/v6/api/jsondocument/remove/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value>::type remove( |   FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value>::type | ||||||
|       TChar* key) { |   remove(TChar* key) { | ||||||
|     _data.remove(adaptString(key)); |     _data.remove(detail::adaptString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Removes a member of the root object. |   // Removes a member of the root object. | ||||||
|   // ⚠️ Doesn't release the memory associated with the removed element. |   // ⚠️ Doesn't release the memory associated with the removed element. | ||||||
|   // https://arduinojson.org/v6/api/jsondocument/remove/ |   // https://arduinojson.org/v6/api/jsondocument/remove/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove( |   FORCE_INLINE | ||||||
|       const TString& key) { |       typename detail::enable_if<detail::IsString<TString>::value>::type | ||||||
|     _data.remove(adaptString(key)); |       remove(const TString& key) { | ||||||
|  |     _data.remove(detail::adaptString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE operator JsonVariant() { |   FORCE_INLINE operator JsonVariant() { | ||||||
| @@ -274,7 +278,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|     _data.init(); |     _data.init(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   JsonDocument(MemoryPool pool) : _pool(pool) { |   JsonDocument(detail::MemoryPool pool) : _pool(pool) { | ||||||
|     _data.init(); |     _data.init(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -284,7 +288,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|  |  | ||||||
|   ~JsonDocument() {} |   ~JsonDocument() {} | ||||||
|  |  | ||||||
|   void replacePool(MemoryPool pool) { |   void replacePool(detail::MemoryPool pool) { | ||||||
|     _pool = pool; |     _pool = pool; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -296,27 +300,27 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|     return JsonVariantConst(&_data); |     return JsonVariantConst(&_data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   MemoryPool _pool; |   detail::MemoryPool _pool; | ||||||
|   VariantData _data; |   detail::VariantData _data; | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   JsonDocument(const JsonDocument&); |   JsonDocument(const JsonDocument&); | ||||||
|   JsonDocument& operator=(const JsonDocument&); |   JsonDocument& operator=(const JsonDocument&); | ||||||
|  |  | ||||||
|  protected: |  protected: | ||||||
|   MemoryPool* getPool() { |   detail::MemoryPool* getPool() { | ||||||
|     return &_pool; |     return &_pool; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData* getData() { |   detail::VariantData* getData() { | ||||||
|     return &_data; |     return &_data; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const VariantData* getData() const { |   const detail::VariantData* getData() const { | ||||||
|     return &_data; |     return &_data; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData* getOrCreateData() { |   detail::VariantData* getOrCreateData() { | ||||||
|     return &_data; |     return &_data; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| @@ -325,4 +329,4 @@ inline void convertToJson(const JsonDocument& src, JsonVariant dst) { | |||||||
|   dst.set(src.as<JsonVariantConst>()); |   dst.set(src.as<JsonVariantConst>()); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -6,13 +6,13 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Document/JsonDocument.hpp> | #include <ArduinoJson/Document/JsonDocument.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // A JsonDocument with a memory pool on the stack. | // A JsonDocument with a memory pool on the stack. | ||||||
| template <size_t desiredCapacity> | template <size_t desiredCapacity> | ||||||
| class StaticJsonDocument : public JsonDocument { | class StaticJsonDocument : public JsonDocument { | ||||||
|   static const size_t _capacity = |   static const size_t _capacity = | ||||||
|       AddPadding<Max<1, desiredCapacity>::value>::value; |       detail::AddPadding<detail::Max<1, desiredCapacity>::value>::value; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   StaticJsonDocument() : JsonDocument(_buffer, _capacity) {} |   StaticJsonDocument() : JsonDocument(_buffer, _capacity) {} | ||||||
| @@ -25,7 +25,8 @@ class StaticJsonDocument : public JsonDocument { | |||||||
|   template <typename T> |   template <typename T> | ||||||
|   StaticJsonDocument( |   StaticJsonDocument( | ||||||
|       const T& src, |       const T& src, | ||||||
|       typename enable_if<is_convertible<T, JsonVariantConst>::value>::type* = 0) |       typename detail::enable_if< | ||||||
|  |           detail::is_convertible<T, JsonVariantConst>::value>::type* = 0) | ||||||
|       : JsonDocument(_buffer, _capacity) { |       : JsonDocument(_buffer, _capacity) { | ||||||
|     set(src); |     set(src); | ||||||
|   } |   } | ||||||
| @@ -57,4 +58,4 @@ class StaticJsonDocument : public JsonDocument { | |||||||
|   char _buffer[_capacity]; |   char _buffer[_capacity]; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Namespace.hpp> | #include <ArduinoJson/Namespace.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| class EscapeSequence { | class EscapeSequence { | ||||||
|  public: |  public: | ||||||
| @@ -36,4 +36,5 @@ class EscapeSequence { | |||||||
|     return &"//\"\"\\\\b\bf\fn\nr\rt\t"[excludeSolidus ? 2 : 0]; |     return &"//\"\"\\\\b\bf\fn\nr\rt\t"[excludeSolidus ? 2 : 0]; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ | |||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantData.hpp> | #include <ArduinoJson/Variant/VariantData.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TReader, typename TStringStorage> | template <typename TReader, typename TStringStorage> | ||||||
| class JsonDeserializer { | class JsonDeserializer { | ||||||
| @@ -29,7 +29,7 @@ class JsonDeserializer { | |||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError parse(VariantData& variant, TFilter filter, |   DeserializationError parse(VariantData& variant, TFilter filter, | ||||||
|                              NestingLimit nestingLimit) { |                              DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     err = parseVariant(variant, filter, nestingLimit); |     err = parseVariant(variant, filter, nestingLimit); | ||||||
| @@ -59,8 +59,9 @@ class JsonDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseVariant(VariantData& variant, TFilter filter, |   DeserializationError::Code parseVariant( | ||||||
|                                           NestingLimit nestingLimit) { |       VariantData& variant, TFilter filter, | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     err = skipSpacesAndComments(); |     err = skipSpacesAndComments(); | ||||||
| @@ -110,7 +111,8 @@ class JsonDeserializer { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code skipVariant(NestingLimit nestingLimit) { |   DeserializationError::Code skipVariant( | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     err = skipSpacesAndComments(); |     err = skipSpacesAndComments(); | ||||||
| @@ -143,8 +145,9 @@ class JsonDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseArray(CollectionData& array, TFilter filter, |   DeserializationError::Code parseArray( | ||||||
|                                         NestingLimit nestingLimit) { |       CollectionData& array, TFilter filter, | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     if (nestingLimit.reached()) |     if (nestingLimit.reached()) | ||||||
| @@ -196,7 +199,8 @@ class JsonDeserializer { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code skipArray(NestingLimit nestingLimit) { |   DeserializationError::Code skipArray( | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     if (nestingLimit.reached()) |     if (nestingLimit.reached()) | ||||||
| @@ -227,8 +231,9 @@ class JsonDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseObject(CollectionData& object, TFilter filter, |   DeserializationError::Code parseObject( | ||||||
|                                          NestingLimit nestingLimit) { |       CollectionData& object, TFilter filter, | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     if (nestingLimit.reached()) |     if (nestingLimit.reached()) | ||||||
| @@ -312,7 +317,8 @@ class JsonDeserializer { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code skipObject(NestingLimit nestingLimit) { |   DeserializationError::Code skipObject( | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     if (nestingLimit.reached()) |     if (nestingLimit.reached()) | ||||||
| @@ -661,12 +667,17 @@ class JsonDeserializer { | |||||||
|                      // code |                      // code | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
|  | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // Parses a JSON input and puts the result in a JsonDocument. | // Parses a JSON input and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, const TString& input, |     JsonDocument& doc, const TString& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -675,16 +686,21 @@ DeserializationError deserializeJson( | |||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, const TString& input, Filter filter, |     JsonDocument& doc, const TString& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::Filter filter, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeJson(JsonDocument& doc, const TString& input, | DeserializationError deserializeJson( | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |     JsonDocument& doc, const TString& input, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|  |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -693,7 +709,8 @@ DeserializationError deserializeJson(JsonDocument& doc, const TString& input, | |||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, TStream& input, |     JsonDocument& doc, TStream& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -702,16 +719,20 @@ DeserializationError deserializeJson( | |||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, TStream& input, Filter filter, |     JsonDocument& doc, TStream& input, DeserializationOption::Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeJson(JsonDocument& doc, TStream& input, | DeserializationError deserializeJson( | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |     JsonDocument& doc, TStream& input, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|  |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -720,7 +741,8 @@ DeserializationError deserializeJson(JsonDocument& doc, TStream& input, | |||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, TChar* input, |     JsonDocument& doc, TChar* input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -729,16 +751,20 @@ DeserializationError deserializeJson( | |||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, TChar* input, Filter filter, |     JsonDocument& doc, TChar* input, DeserializationOption::Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | DeserializationError deserializeJson( | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |     JsonDocument& doc, TChar* input, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|  |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -747,7 +773,8 @@ DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | |||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, TChar* input, size_t inputSize, |     JsonDocument& doc, TChar* input, size_t inputSize, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -756,8 +783,11 @@ DeserializationError deserializeJson( | |||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument& doc, TChar* input, size_t inputSize, Filter filter, |     JsonDocument& doc, TChar* input, size_t inputSize, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::Filter filter, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit = | ||||||
|  |         DeserializationOption::NestingLimit()) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                        filter); |                                        filter); | ||||||
| } | } | ||||||
| @@ -765,11 +795,13 @@ DeserializationError deserializeJson( | |||||||
| // Parses a JSON input, filters, and puts the result in a JsonDocument. | // Parses a JSON input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/json/deserializejson/ | // https://arduinojson.org/v6/api/json/deserializejson/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | DeserializationError deserializeJson( | ||||||
|                                      size_t inputSize, |     JsonDocument& doc, TChar* input, size_t inputSize, | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|  |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                        filter); |                                        filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include <ArduinoJson/Serialization/serialize.hpp> | #include <ArduinoJson/Serialization/serialize.hpp> | ||||||
| #include <ArduinoJson/Variant/Visitor.hpp> | #include <ArduinoJson/Variant/Visitor.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TWriter> | template <typename TWriter> | ||||||
| class JsonSerializer : public Visitor<size_t> { | class JsonSerializer : public Visitor<size_t> { | ||||||
| @@ -115,10 +115,15 @@ class JsonSerializer : public Visitor<size_t> { | |||||||
|   TextFormatter<TWriter> _formatter; |   TextFormatter<TWriter> _formatter; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
|  | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // Produces a minified JSON document. | // Produces a minified JSON document. | ||||||
| // https://arduinojson.org/v6/api/json/serializejson/ | // https://arduinojson.org/v6/api/json/serializejson/ | ||||||
| template <typename TDestination> | template <typename TDestination> | ||||||
| size_t serializeJson(JsonVariantConst source, TDestination& destination) { | size_t serializeJson(JsonVariantConst source, TDestination& destination) { | ||||||
|  |   using namespace detail; | ||||||
|   return serialize<JsonSerializer>(source, destination); |   return serialize<JsonSerializer>(source, destination); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -126,23 +131,25 @@ size_t serializeJson(JsonVariantConst source, TDestination& destination) { | |||||||
| // https://arduinojson.org/v6/api/json/serializejson/ | // https://arduinojson.org/v6/api/json/serializejson/ | ||||||
| inline size_t serializeJson(JsonVariantConst source, void* buffer, | inline size_t serializeJson(JsonVariantConst source, void* buffer, | ||||||
|                             size_t bufferSize) { |                             size_t bufferSize) { | ||||||
|  |   using namespace detail; | ||||||
|   return serialize<JsonSerializer>(source, buffer, bufferSize); |   return serialize<JsonSerializer>(source, buffer, bufferSize); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Computes the length of the document that serializeJson() produces. | // Computes the length of the document that serializeJson() produces. | ||||||
| // https://arduinojson.org/v6/api/json/measurejson/ | // https://arduinojson.org/v6/api/json/measurejson/ | ||||||
| inline size_t measureJson(JsonVariantConst source) { | inline size_t measureJson(JsonVariantConst source) { | ||||||
|  |   using namespace detail; | ||||||
|   return measure<JsonSerializer>(source); |   return measure<JsonSerializer>(source); | ||||||
| } | } | ||||||
|  |  | ||||||
| #if ARDUINOJSON_ENABLE_STD_STREAM | #if ARDUINOJSON_ENABLE_STD_STREAM | ||||||
| template <typename T> | template <typename T> | ||||||
| inline typename enable_if<is_convertible<T, JsonVariantConst>::value, | inline typename detail::enable_if< | ||||||
|                           std::ostream&>::type |     detail::is_convertible<T, JsonVariantConst>::value, std::ostream&>::type | ||||||
| operator<<(std::ostream& os, const T& source) { | operator<<(std::ostream& os, const T& source) { | ||||||
|   serializeJson(source, os); |   serializeJson(source, os); | ||||||
|   return os; |   return os; | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Polyfills/assert.hpp> | #include <ArduinoJson/Polyfills/assert.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TReader> | template <typename TReader> | ||||||
| class Latch { | class Latch { | ||||||
| @@ -53,4 +53,4 @@ class Latch { | |||||||
| #endif | #endif | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| #include <ArduinoJson/Serialization/measure.hpp> | #include <ArduinoJson/Serialization/measure.hpp> | ||||||
| #include <ArduinoJson/Serialization/serialize.hpp> | #include <ArduinoJson/Serialization/serialize.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TWriter> | template <typename TWriter> | ||||||
| class PrettyJsonSerializer : public JsonSerializer<TWriter> { | class PrettyJsonSerializer : public JsonSerializer<TWriter> { | ||||||
| @@ -71,10 +71,15 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> { | |||||||
|   uint8_t _nesting; |   uint8_t _nesting; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
|  | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // Produces JsonDocument to create a prettified JSON document. | // Produces JsonDocument to create a prettified JSON document. | ||||||
| // https://arduinojson.org/v6/api/json/serializejsonpretty/ | // https://arduinojson.org/v6/api/json/serializejsonpretty/ | ||||||
| template <typename TDestination> | template <typename TDestination> | ||||||
| size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) { | size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) { | ||||||
|  |   using namespace ArduinoJson::detail; | ||||||
|   return serialize<PrettyJsonSerializer>(source, destination); |   return serialize<PrettyJsonSerializer>(source, destination); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -82,13 +87,15 @@ size_t serializeJsonPretty(JsonVariantConst source, TDestination& destination) { | |||||||
| // https://arduinojson.org/v6/api/json/serializejsonpretty/ | // https://arduinojson.org/v6/api/json/serializejsonpretty/ | ||||||
| inline size_t serializeJsonPretty(JsonVariantConst source, void* buffer, | inline size_t serializeJsonPretty(JsonVariantConst source, void* buffer, | ||||||
|                                   size_t bufferSize) { |                                   size_t bufferSize) { | ||||||
|  |   using namespace ArduinoJson::detail; | ||||||
|   return serialize<PrettyJsonSerializer>(source, buffer, bufferSize); |   return serialize<PrettyJsonSerializer>(source, buffer, bufferSize); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Computes the length of the document that serializeJsonPretty() produces. | // Computes the length of the document that serializeJsonPretty() produces. | ||||||
| // https://arduinojson.org/v6/api/json/measurejsonpretty/ | // https://arduinojson.org/v6/api/json/measurejsonpretty/ | ||||||
| inline size_t measureJsonPretty(JsonVariantConst source) { | inline size_t measureJsonPretty(JsonVariantConst source) { | ||||||
|  |   using namespace ArduinoJson::detail; | ||||||
|   return measure<PrettyJsonSerializer>(source); |   return measure<PrettyJsonSerializer>(source); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ | |||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
| #include <ArduinoJson/Serialization/CountingDecorator.hpp> | #include <ArduinoJson/Serialization/CountingDecorator.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TWriter> | template <typename TWriter> | ||||||
| class TextFormatter { | class TextFormatter { | ||||||
| @@ -170,4 +170,5 @@ class TextFormatter { | |||||||
|  private: |  private: | ||||||
|   TextFormatter& operator=(const TextFormatter&);  // cannot be assigned |   TextFormatter& operator=(const TextFormatter&);  // cannot be assigned | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -18,7 +18,7 @@ | |||||||
| #  endif | #  endif | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| namespace Utf16 { | namespace Utf16 { | ||||||
| inline bool isHighSurrogate(uint16_t codeunit) { | inline bool isHighSurrogate(uint16_t codeunit) { | ||||||
| @@ -58,7 +58,7 @@ class Codepoint { | |||||||
|   uint32_t _codepoint; |   uint32_t _codepoint; | ||||||
| }; | }; | ||||||
| }  // namespace Utf16 | }  // namespace Utf16 | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| #if defined(__GNUC__) | #if defined(__GNUC__) | ||||||
| #  if __GNUC__ >= 8 | #  if __GNUC__ >= 8 | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Namespace.hpp> | #include <ArduinoJson/Namespace.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| namespace Utf8 { | namespace Utf8 { | ||||||
| template <typename TStringBuilder> | template <typename TStringBuilder> | ||||||
| @@ -43,4 +43,4 @@ inline void encodeCodepoint(uint32_t codepoint32, TStringBuilder& str) { | |||||||
|   } |   } | ||||||
| } | } | ||||||
| }  // namespace Utf8 | }  // namespace Utf8 | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|  |  | ||||||
| #include <stddef.h>  // size_t | #include <stddef.h>  // size_t | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| #if ARDUINOJSON_ENABLE_ALIGNMENT | #if ARDUINOJSON_ENABLE_ALIGNMENT | ||||||
|  |  | ||||||
| @@ -57,4 +57,4 @@ inline T* addPadding(T* p) { | |||||||
|   return reinterpret_cast<T*>(address); |   return reinterpret_cast<T*>(address); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -17,14 +17,14 @@ | |||||||
| // Computes the size required to store an array in a JsonDocument. | // Computes the size required to store an array in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/how-to/determine-the-capacity-of-the-jsondocument/ | // https://arduinojson.org/v6/how-to/determine-the-capacity-of-the-jsondocument/ | ||||||
| #define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \ | #define JSON_ARRAY_SIZE(NUMBER_OF_ELEMENTS) \ | ||||||
|   ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot)) |   ((NUMBER_OF_ELEMENTS) * sizeof(ArduinoJson::detail::VariantSlot)) | ||||||
|  |  | ||||||
| // Returns the size (in bytes) of an object with n elements. | // Returns the size (in bytes) of an object with n elements. | ||||||
| // Can be very handy to determine the size of a StaticMemoryPool. | // Can be very handy to determine the size of a StaticMemoryPool. | ||||||
| #define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \ | #define JSON_OBJECT_SIZE(NUMBER_OF_ELEMENTS) \ | ||||||
|   ((NUMBER_OF_ELEMENTS) * sizeof(ARDUINOJSON_NAMESPACE::VariantSlot)) |   ((NUMBER_OF_ELEMENTS) * sizeof(ArduinoJson::detail::VariantSlot)) | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| // _begin                                   _end | // _begin                                   _end | ||||||
| // v                                           v | // v                                           v | ||||||
| @@ -250,4 +250,4 @@ bool storeString(MemoryPool* pool, TAdaptedString str, TCallback callback) { | |||||||
|   return storeString(pool, str, str.storagePolicy(), callback); |   return storeString(pool, str, str.storagePolicy(), callback); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // A special type of data that can be used to insert pregenerated JSON portions. | // A special type of data that can be used to insert pregenerated JSON portions. | ||||||
| template <typename T> | template <typename T> | ||||||
| @@ -58,11 +58,12 @@ inline SerializedValue<T> serialized(T str) { | |||||||
|  |  | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline SerializedValue<TChar*> serialized(TChar* p) { | inline SerializedValue<TChar*> serialized(TChar* p) { | ||||||
|   return SerializedValue<TChar*>(p, adaptString(p).size()); |   return SerializedValue<TChar*>(p, detail::adaptString(p).size()); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline SerializedValue<TChar*> serialized(TChar* p, size_t n) { | inline SerializedValue<TChar*> serialized(TChar* p, size_t n) { | ||||||
|   return SerializedValue<TChar*>(p, n); |   return SerializedValue<TChar*>(p, n); | ||||||
| } | } | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ | |||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantData.hpp> | #include <ArduinoJson/Variant/VariantData.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TReader, typename TStringStorage> | template <typename TReader, typename TStringStorage> | ||||||
| class MsgPackDeserializer { | class MsgPackDeserializer { | ||||||
| @@ -25,7 +25,7 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError parse(VariantData& variant, TFilter filter, |   DeserializationError parse(VariantData& variant, TFilter filter, | ||||||
|                              NestingLimit nestingLimit) { |                              DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     err = parseVariant(&variant, filter, nestingLimit); |     err = parseVariant(&variant, filter, nestingLimit); | ||||||
|     return _foundSomething ? err : DeserializationError::EmptyInput; |     return _foundSomething ? err : DeserializationError::EmptyInput; | ||||||
| @@ -33,8 +33,9 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseVariant(VariantData* variant, TFilter filter, |   DeserializationError::Code parseVariant( | ||||||
|                                           NestingLimit nestingLimit) { |       VariantData* variant, TFilter filter, | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     uint8_t code = 0;  // TODO: why do we need to initialize this variable? |     uint8_t code = 0;  // TODO: why do we need to initialize this variable? | ||||||
| @@ -395,8 +396,9 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TSize, typename TFilter> |   template <typename TSize, typename TFilter> | ||||||
|   DeserializationError::Code readArray(VariantData* variant, TFilter filter, |   DeserializationError::Code readArray( | ||||||
|                                        NestingLimit nestingLimit) { |       VariantData* variant, TFilter filter, | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     TSize size; |     TSize size; | ||||||
|  |  | ||||||
| @@ -408,9 +410,9 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code readArray(VariantData* variant, size_t n, |   DeserializationError::Code readArray( | ||||||
|                                        TFilter filter, |       VariantData* variant, size_t n, TFilter filter, | ||||||
|                                        NestingLimit nestingLimit) { |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     if (nestingLimit.reached()) |     if (nestingLimit.reached()) | ||||||
| @@ -449,8 +451,9 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TSize, typename TFilter> |   template <typename TSize, typename TFilter> | ||||||
|   DeserializationError::Code readObject(VariantData* variant, TFilter filter, |   DeserializationError::Code readObject( | ||||||
|                                         NestingLimit nestingLimit) { |       VariantData* variant, TFilter filter, | ||||||
|  |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     TSize size; |     TSize size; | ||||||
|  |  | ||||||
| @@ -462,9 +465,9 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code readObject(VariantData* variant, size_t n, |   DeserializationError::Code readObject( | ||||||
|                                         TFilter filter, |       VariantData* variant, size_t n, TFilter filter, | ||||||
|                                         NestingLimit nestingLimit) { |       DeserializationOption::NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     if (nestingLimit.reached()) |     if (nestingLimit.reached()) | ||||||
| @@ -557,12 +560,17 @@ class MsgPackDeserializer { | |||||||
|   bool _foundSomething; |   bool _foundSomething; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
|  | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // Parses a MessagePack input and puts the result in a JsonDocument. | // Parses a MessagePack input and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, const TString& input, |     JsonDocument& doc, const TString& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -571,17 +579,21 @@ DeserializationError deserializeMsgPack( | |||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, const TString& input, Filter filter, |     JsonDocument& doc, const TString& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::Filter filter, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, const TString& input, | DeserializationError deserializeMsgPack( | ||||||
|                                         NestingLimit nestingLimit, |     JsonDocument& doc, const TString& input, | ||||||
|                                         Filter filter) { |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|  |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -590,7 +602,8 @@ DeserializationError deserializeMsgPack(JsonDocument& doc, const TString& input, | |||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, TStream& input, |     JsonDocument& doc, TStream& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -599,17 +612,20 @@ DeserializationError deserializeMsgPack( | |||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, TStream& input, Filter filter, |     JsonDocument& doc, TStream& input, DeserializationOption::Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, TStream& input, | DeserializationError deserializeMsgPack( | ||||||
|                                         NestingLimit nestingLimit, |     JsonDocument& doc, TStream& input, | ||||||
|                                         Filter filter) { |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|  |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -618,7 +634,8 @@ DeserializationError deserializeMsgPack(JsonDocument& doc, TStream& input, | |||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, TChar* input, |     JsonDocument& doc, TChar* input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -627,17 +644,20 @@ DeserializationError deserializeMsgPack( | |||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, TChar* input, Filter filter, |     JsonDocument& doc, TChar* input, DeserializationOption::Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | DeserializationError deserializeMsgPack( | ||||||
|                                         NestingLimit nestingLimit, |     JsonDocument& doc, TChar* input, | ||||||
|                                         Filter filter) { |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|  |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -646,7 +666,8 @@ DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | |||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, TChar* input, size_t inputSize, |     JsonDocument& doc, TChar* input, size_t inputSize, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| } | } | ||||||
| @@ -655,8 +676,10 @@ DeserializationError deserializeMsgPack( | |||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument& doc, TChar* input, size_t inputSize, Filter filter, |     JsonDocument& doc, TChar* input, size_t inputSize, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     DeserializationOption::Filter filter, | ||||||
|  |     DeserializationOption::NestingLimit nestingLimit = {}) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                           filter); |                                           filter); | ||||||
| } | } | ||||||
| @@ -664,12 +687,13 @@ DeserializationError deserializeMsgPack( | |||||||
| // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | // Parses a MessagePack input, filters, and puts the result in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/deserializemsgpack/ | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | DeserializationError deserializeMsgPack( | ||||||
|                                         size_t inputSize, |     JsonDocument& doc, TChar* input, size_t inputSize, | ||||||
|                                         NestingLimit nestingLimit, |     DeserializationOption::NestingLimit nestingLimit, | ||||||
|                                         Filter filter) { |     DeserializationOption::Filter filter) { | ||||||
|  |   using namespace detail; | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                           filter); |                                           filter); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ | |||||||
| #include <ArduinoJson/Serialization/serialize.hpp> | #include <ArduinoJson/Serialization/serialize.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantData.hpp> | #include <ArduinoJson/Variant/VariantData.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TWriter> | template <typename TWriter> | ||||||
| class MsgPackSerializer : public Visitor<size_t> { | class MsgPackSerializer : public Visitor<size_t> { | ||||||
| @@ -197,10 +197,15 @@ class MsgPackSerializer : public Visitor<size_t> { | |||||||
|   CountingDecorator<TWriter> _writer; |   CountingDecorator<TWriter> _writer; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
|  | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // Produces a MessagePack document. | // Produces a MessagePack document. | ||||||
| // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ | ||||||
| template <typename TDestination> | template <typename TDestination> | ||||||
| inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { | inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { | ||||||
|  |   using namespace ArduinoJson::detail; | ||||||
|   return serialize<MsgPackSerializer>(source, output); |   return serialize<MsgPackSerializer>(source, output); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -208,13 +213,15 @@ inline size_t serializeMsgPack(JsonVariantConst source, TDestination& output) { | |||||||
| // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ | // https://arduinojson.org/v6/api/msgpack/serializemsgpack/ | ||||||
| inline size_t serializeMsgPack(JsonVariantConst source, void* output, | inline size_t serializeMsgPack(JsonVariantConst source, void* output, | ||||||
|                                size_t size) { |                                size_t size) { | ||||||
|  |   using namespace ArduinoJson::detail; | ||||||
|   return serialize<MsgPackSerializer>(source, output, size); |   return serialize<MsgPackSerializer>(source, output, size); | ||||||
| } | } | ||||||
|  |  | ||||||
| // Computes the length of the document that serializeMsgPack() produces. | // Computes the length of the document that serializeMsgPack() produces. | ||||||
| // https://arduinojson.org/v6/api/msgpack/measuremsgpack/ | // https://arduinojson.org/v6/api/msgpack/measuremsgpack/ | ||||||
| inline size_t measureMsgPack(JsonVariantConst source) { | inline size_t measureMsgPack(JsonVariantConst source) { | ||||||
|  |   using namespace ArduinoJson::detail; | ||||||
|   return measure<MsgPackSerializer>(source); |   return measure<MsgPackSerializer>(source); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| #if ARDUINOJSON_LITTLE_ENDIAN | #if ARDUINOJSON_LITTLE_ENDIAN | ||||||
| inline void swapBytes(uint8_t& a, uint8_t& b) { | inline void swapBytes(uint8_t& a, uint8_t& b) { | ||||||
| @@ -43,4 +43,4 @@ template <typename T> | |||||||
| inline void fixEndianess(T&) {} | inline void fixEndianess(T&) {} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Namespace.hpp> | #include <ArduinoJson/Namespace.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) { | inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) { | ||||||
|   f[0] = uint8_t((d[0] & 0xC0) | (d[0] << 3 & 0x3f) | (d[1] >> 5)); |   f[0] = uint8_t((d[0] & 0xC0) | (d[0] << 3 & 0x3f) | (d[1] >> 5)); | ||||||
| @@ -15,4 +15,4 @@ inline void doubleToFloat(const uint8_t d[8], uint8_t f[4]) { | |||||||
|   f[3] = uint8_t((d[3] << 3) | (d[4] >> 5)); |   f[3] = uint8_t((d[3] << 3) | (d[4] >> 5)); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -8,11 +8,11 @@ | |||||||
| #include <ArduinoJson/Polyfills/preprocessor.hpp> | #include <ArduinoJson/Polyfills/preprocessor.hpp> | ||||||
| #include <ArduinoJson/version.hpp> | #include <ArduinoJson/version.hpp> | ||||||
|  |  | ||||||
| #ifndef ARDUINOJSON_NAMESPACE | #ifndef ARDUINOJSON_VERSION_NAMESPACE | ||||||
|  |  | ||||||
| #  define ARDUINOJSON_NAMESPACE                                               \ | #  define ARDUINOJSON_VERSION_NAMESPACE                                       \ | ||||||
|     ARDUINOJSON_CONCAT4(                                                      \ |     ARDUINOJSON_CONCAT4(                                                      \ | ||||||
|         ARDUINOJSON_CONCAT4(ArduinoJson, ARDUINOJSON_VERSION_MAJOR,           \ |         ARDUINOJSON_CONCAT4(V, ARDUINOJSON_VERSION_MAJOR,                     \ | ||||||
|                             ARDUINOJSON_VERSION_MINOR,                        \ |                             ARDUINOJSON_VERSION_MINOR,                        \ | ||||||
|                             ARDUINOJSON_VERSION_REVISION),                    \ |                             ARDUINOJSON_VERSION_REVISION),                    \ | ||||||
|         _,                                                                    \ |         _,                                                                    \ | ||||||
| @@ -24,3 +24,21 @@ | |||||||
|             ARDUINOJSON_ENABLE_COMMENTS, ARDUINOJSON_DECODE_UNICODE)) |             ARDUINOJSON_ENABLE_COMMENTS, ARDUINOJSON_DECODE_UNICODE)) | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #define ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE \ | ||||||
|  |   namespace ArduinoJson {                  \ | ||||||
|  |   inline namespace ARDUINOJSON_VERSION_NAMESPACE { | ||||||
|  |  | ||||||
|  | #define ARDUINOJSON_END_PUBLIC_NAMESPACE \ | ||||||
|  |   }                                      \ | ||||||
|  |   } | ||||||
|  |  | ||||||
|  | #define ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE        \ | ||||||
|  |   namespace ArduinoJson {                          \ | ||||||
|  |   inline namespace ARDUINOJSON_VERSION_NAMESPACE { \ | ||||||
|  |   namespace detail { | ||||||
|  |  | ||||||
|  | #define ARDUINOJSON_END_PRIVATE_NAMESPACE \ | ||||||
|  |   }                                       \ | ||||||
|  |   }                                       \ | ||||||
|  |   } | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
| #include <ArduinoJson/Numbers/FloatTraits.hpp> | #include <ArduinoJson/Numbers/FloatTraits.hpp> | ||||||
| #include <ArduinoJson/Polyfills/math.hpp> | #include <ArduinoJson/Polyfills/math.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TFloat> | template <typename TFloat> | ||||||
| struct FloatParts { | struct FloatParts { | ||||||
| @@ -84,4 +84,5 @@ struct FloatParts { | |||||||
|     return powersOf10; |     return powersOf10; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ | |||||||
| #include <ArduinoJson/Polyfills/preprocessor.hpp> | #include <ArduinoJson/Polyfills/preprocessor.hpp> | ||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename T, size_t = sizeof(T)> | template <typename T, size_t = sizeof(T)> | ||||||
| struct FloatTraits {}; | struct FloatTraits {}; | ||||||
| @@ -262,4 +262,5 @@ struct FloatTraits<T, 4 /*32bits*/> { | |||||||
|     return forge(0xFf7fffff); |     return forge(0xFf7fffff); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -7,11 +7,12 @@ | |||||||
| #include <ArduinoJson/Configuration.hpp> | #include <ArduinoJson/Configuration.hpp> | ||||||
| #include <ArduinoJson/Namespace.hpp> | #include <ArduinoJson/Namespace.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| #if ARDUINOJSON_USE_DOUBLE | #if ARDUINOJSON_USE_DOUBLE | ||||||
| typedef double JsonFloat; | typedef double JsonFloat; | ||||||
| #else | #else | ||||||
| typedef float JsonFloat; | typedef float JsonFloat; | ||||||
| #endif | #endif | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
|  |  | ||||||
| #include <stdint.h>  // int64_t | #include <stdint.h>  // int64_t | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| #if ARDUINOJSON_USE_LONG_LONG | #if ARDUINOJSON_USE_LONG_LONG | ||||||
| typedef int64_t JsonInteger; | typedef int64_t JsonInteger; | ||||||
| @@ -19,10 +19,10 @@ typedef long JsonInteger; | |||||||
| typedef unsigned long JsonUInt; | typedef unsigned long JsonUInt; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| #define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T)                  \ | #define ARDUINOJSON_ASSERT_INTEGER_TYPE_IS_SUPPORTED(T)                  \ | ||||||
|   static_assert(sizeof(T) <= sizeof(ARDUINOJSON_NAMESPACE::JsonInteger), \ |   static_assert(sizeof(T) <= sizeof(ArduinoJson::JsonInteger),           \ | ||||||
|                 "To use 64-bit integers with ArduinoJson, you must set " \ |                 "To use 64-bit integers with ArduinoJson, you must set " \ | ||||||
|                 "ARDUINOJSON_USE_LONG_LONG to 1. See "                   \ |                 "ARDUINOJSON_USE_LONG_LONG to 1. See "                   \ | ||||||
|                 "https://arduinojson.org/v6/api/config/use_long_long/"); |                 "https://arduinojson.org/v6/api/config/use_long_long/"); | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| #include <ArduinoJson/Numbers/JsonInteger.hpp> | #include <ArduinoJson/Numbers/JsonInteger.hpp> | ||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| enum CompareResult { | enum CompareResult { | ||||||
|   COMPARE_RESULT_DIFFER = 0, |   COMPARE_RESULT_DIFFER = 0, | ||||||
| @@ -117,4 +117,4 @@ CompareResult arithmeticCompareNegateRight( | |||||||
|   return arithmeticCompare(static_cast<T1>(rhs), -lhs); |   return arithmeticCompare(static_cast<T1>(rhs), -lhs); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -17,7 +17,7 @@ | |||||||
| #include <ArduinoJson/Polyfills/limits.hpp> | #include <ArduinoJson/Polyfills/limits.hpp> | ||||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| // uint32 -> int32 | // uint32 -> int32 | ||||||
| // uint64 -> int32 | // uint64 -> int32 | ||||||
| @@ -126,7 +126,7 @@ template <typename TOut, typename TIn> | |||||||
| TOut convertNumber(TIn value) { | TOut convertNumber(TIn value) { | ||||||
|   return canConvertNumber<TOut>(value) ? TOut(value) : 0; |   return canConvertNumber<TOut>(value) ? TOut(value) : 0; | ||||||
| } | } | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| #if defined(__clang__) | #if defined(__clang__) | ||||||
| #  pragma clang diagnostic pop | #  pragma clang diagnostic pop | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ | |||||||
| #include <ArduinoJson/Variant/Converter.hpp> | #include <ArduinoJson/Variant/Converter.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantData.hpp> | #include <ArduinoJson/Variant/VariantData.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename A, typename B> | template <typename A, typename B> | ||||||
| struct choose_largest : conditional<(sizeof(A) > sizeof(B)), A, B> {}; | struct choose_largest : conditional<(sizeof(A) > sizeof(B)), A, B> {}; | ||||||
| @@ -150,4 +150,4 @@ inline T parseNumber(const char* s) { | |||||||
|   parseNumber(s, value); |   parseNumber(s, value); | ||||||
|   return Converter<T>::fromJson(JsonVariantConst(&value)); |   return Converter<T>::fromJson(JsonVariantConst(&value)); | ||||||
| } | } | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -7,14 +7,14 @@ | |||||||
| #include <ArduinoJson/Object/JsonObjectConst.hpp> | #include <ArduinoJson/Object/JsonObjectConst.hpp> | ||||||
| #include <ArduinoJson/Object/MemberProxy.hpp> | #include <ArduinoJson/Object/MemberProxy.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| class JsonArray; | class JsonArray; | ||||||
|  |  | ||||||
| // A reference to an object in a JsonDocument. | // A reference to an object in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/jsonobject/ | // https://arduinojson.org/v6/api/jsonobject/ | ||||||
| class JsonObject : public VariantOperators<JsonObject> { | class JsonObject : public detail::VariantOperators<JsonObject> { | ||||||
|   friend class VariantAttorney; |   friend class detail::VariantAttorney; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   typedef JsonObjectIterator iterator; |   typedef JsonObjectIterator iterator; | ||||||
| @@ -23,12 +23,12 @@ class JsonObject : public VariantOperators<JsonObject> { | |||||||
|   FORCE_INLINE JsonObject() : _data(0), _pool(0) {} |   FORCE_INLINE JsonObject() : _data(0), _pool(0) {} | ||||||
|  |  | ||||||
|   // INTERNAL USE ONLY |   // INTERNAL USE ONLY | ||||||
|   FORCE_INLINE JsonObject(MemoryPool* buf, CollectionData* data) |   FORCE_INLINE JsonObject(detail::MemoryPool* buf, detail::CollectionData* data) | ||||||
|       : _data(data), _pool(buf) {} |       : _data(data), _pool(buf) {} | ||||||
|  |  | ||||||
|   operator JsonVariant() const { |   operator JsonVariant() const { | ||||||
|     void* data = _data;  // prevent warning cast-align |     void* data = _data;  // prevent warning cast-align | ||||||
|     return JsonVariant(_pool, reinterpret_cast<VariantData*>(data)); |     return JsonVariant(_pool, reinterpret_cast<detail::VariantData*>(data)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   operator JsonObjectConst() const { |   operator JsonObjectConst() const { | ||||||
| @@ -108,19 +108,21 @@ class JsonObject : public VariantOperators<JsonObject> { | |||||||
|   // Gets or sets the member with specified key. |   // Gets or sets the member with specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobject/subscript/ |   // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, |   FORCE_INLINE typename detail::enable_if< | ||||||
|                                   MemberProxy<JsonObject, TString> >::type |       detail::IsString<TString>::value, | ||||||
|  |       detail::MemberProxy<JsonObject, TString> >::type | ||||||
|   operator[](const TString& key) const { |   operator[](const TString& key) const { | ||||||
|     return MemberProxy<JsonObject, TString>(*this, key); |     return {*this, key}; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets or sets the member with specified key. |   // Gets or sets the member with specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobject/subscript/ |   // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, |   FORCE_INLINE | ||||||
|                                   MemberProxy<JsonObject, TChar*> >::type |       typename detail::enable_if<detail::IsString<TChar*>::value, | ||||||
|   operator[](TChar* key) const { |                                  detail::MemberProxy<JsonObject, TChar*> >::type | ||||||
|     return MemberProxy<JsonObject, TChar*>(*this, key); |       operator[](TChar* key) const { | ||||||
|  |     return {*this, key}; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Removes the member at the specified iterator. |   // Removes the member at the specified iterator. | ||||||
| @@ -137,7 +139,7 @@ class JsonObject : public VariantOperators<JsonObject> { | |||||||
|   // https://arduinojson.org/v6/api/jsonobject/remove/ |   // https://arduinojson.org/v6/api/jsonobject/remove/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE void remove(const TString& key) const { |   FORCE_INLINE void remove(const TString& key) const { | ||||||
|     removeMember(adaptString(key)); |     removeMember(detail::adaptString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Removes the member with the specified key. |   // Removes the member with the specified key. | ||||||
| @@ -145,23 +147,25 @@ class JsonObject : public VariantOperators<JsonObject> { | |||||||
|   // https://arduinojson.org/v6/api/jsonobject/remove/ |   // https://arduinojson.org/v6/api/jsonobject/remove/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE void remove(TChar* key) const { |   FORCE_INLINE void remove(TChar* key) const { | ||||||
|     removeMember(adaptString(key)); |     removeMember(detail::adaptString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Returns true if the object contains the specified key. |   // Returns true if the object contains the specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobject/containskey/ |   // https://arduinojson.org/v6/api/jsonobject/containskey/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type |   FORCE_INLINE | ||||||
|   containsKey(const TString& key) const { |       typename detail::enable_if<detail::IsString<TString>::value, bool>::type | ||||||
|     return getMember(adaptString(key)) != 0; |       containsKey(const TString& key) const { | ||||||
|  |     return getMember(detail::adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Returns true if the object contains the specified key. |   // Returns true if the object contains the specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobject/containskey/ |   // https://arduinojson.org/v6/api/jsonobject/containskey/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type |   FORCE_INLINE | ||||||
|   containsKey(TChar* key) const { |       typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type | ||||||
|     return getMember(adaptString(key)) != 0; |       containsKey(TChar* key) const { | ||||||
|  |     return getMember(detail::adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Creates an array and adds it to the object. |   // Creates an array and adds it to the object. | ||||||
| @@ -189,20 +193,20 @@ class JsonObject : public VariantOperators<JsonObject> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool* getPool() const { |   detail::MemoryPool* getPool() const { | ||||||
|     return _pool; |     return _pool; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData* getData() const { |   detail::VariantData* getData() const { | ||||||
|     return collectionToVariant(_data); |     return detail::collectionToVariant(_data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData* getOrCreateData() const { |   detail::VariantData* getOrCreateData() const { | ||||||
|     return collectionToVariant(_data); |     return detail::collectionToVariant(_data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
|   inline VariantData* getMember(TAdaptedString key) const { |   inline detail::VariantData* getMember(TAdaptedString key) const { | ||||||
|     if (!_data) |     if (!_data) | ||||||
|       return 0; |       return 0; | ||||||
|     return _data->getMember(key); |     return _data->getMember(key); | ||||||
| @@ -215,23 +219,23 @@ class JsonObject : public VariantOperators<JsonObject> { | |||||||
|     _data->removeMember(key); |     _data->removeMember(key); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CollectionData* _data; |   detail::CollectionData* _data; | ||||||
|   MemoryPool* _pool; |   detail::MemoryPool* _pool; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| struct Converter<JsonObject> : private VariantAttorney { | struct Converter<JsonObject> : private detail::VariantAttorney { | ||||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { |   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); |     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static JsonObject fromJson(JsonVariant src) { |   static JsonObject fromJson(JsonVariant src) { | ||||||
|     VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     MemoryPool* pool = getPool(src); |     auto pool = getPool(src); | ||||||
|     return JsonObject(pool, data != 0 ? data->asObject() : 0); |     return JsonObject(pool, data != 0 ? data->asObject() : 0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static InvalidConversion<JsonVariantConst, JsonObject> fromJson( |   static detail::InvalidConversion<JsonVariantConst, JsonObject> fromJson( | ||||||
|       JsonVariantConst); |       JsonVariantConst); | ||||||
|  |  | ||||||
|   static bool checkJson(JsonVariantConst) { |   static bool checkJson(JsonVariantConst) { | ||||||
| @@ -239,8 +243,9 @@ struct Converter<JsonObject> : private VariantAttorney { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   static bool checkJson(JsonVariant src) { |   static bool checkJson(JsonVariant src) { | ||||||
|     VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     return data && data->isObject(); |     return data && data->isObject(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -7,13 +7,13 @@ | |||||||
| #include <ArduinoJson/Object/JsonObjectIterator.hpp> | #include <ArduinoJson/Object/JsonObjectIterator.hpp> | ||||||
| #include <ArduinoJson/Variant/VariantOperators.hpp> | #include <ArduinoJson/Variant/VariantOperators.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // A read-only reference to an object in a JsonDocument. | // A read-only reference to an object in a JsonDocument. | ||||||
| // https://arduinojson.org/v6/api/jsonobjectconst/ | // https://arduinojson.org/v6/api/jsonobjectconst/ | ||||||
| class JsonObjectConst : public VariantOperators<JsonObjectConst> { | class JsonObjectConst : public detail::VariantOperators<JsonObjectConst> { | ||||||
|   friend class JsonObject; |   friend class JsonObject; | ||||||
|   friend class VariantAttorney; |   friend class detail::VariantAttorney; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   typedef JsonObjectConstIterator iterator; |   typedef JsonObjectConstIterator iterator; | ||||||
| @@ -22,7 +22,7 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> { | |||||||
|   JsonObjectConst() : _data(0) {} |   JsonObjectConst() : _data(0) {} | ||||||
|  |  | ||||||
|   // INTERNAL USE ONLY |   // INTERNAL USE ONLY | ||||||
|   JsonObjectConst(const CollectionData* data) : _data(data) {} |   JsonObjectConst(const detail::CollectionData* data) : _data(data) {} | ||||||
|  |  | ||||||
|   operator JsonVariantConst() const { |   operator JsonVariantConst() const { | ||||||
|     return JsonVariantConst(collectionToVariant(_data)); |     return JsonVariantConst(collectionToVariant(_data)); | ||||||
| @@ -76,32 +76,32 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> { | |||||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/containskey/ |   // https://arduinojson.org/v6/api/jsonobjectconst/containskey/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE bool containsKey(const TString& key) const { |   FORCE_INLINE bool containsKey(const TString& key) const { | ||||||
|     return getMember(adaptString(key)) != 0; |     return getMember(detail::adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Returns true if the object contains the specified key. |   // Returns true if the object contains the specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/containskey/ |   // https://arduinojson.org/v6/api/jsonobjectconst/containskey/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE bool containsKey(TChar* key) const { |   FORCE_INLINE bool containsKey(TChar* key) const { | ||||||
|     return getMember(adaptString(key)) != 0; |     return getMember(detail::adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets the member with specified key. |   // Gets the member with specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/subscript/ |   // https://arduinojson.org/v6/api/jsonobjectconst/subscript/ | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE |   FORCE_INLINE typename detail::enable_if<detail::IsString<TString>::value, | ||||||
|       typename enable_if<IsString<TString>::value, JsonVariantConst>::type |                                           JsonVariantConst>::type | ||||||
|       operator[](const TString& key) const { |   operator[](const TString& key) const { | ||||||
|     return JsonVariantConst(getMember(adaptString(key))); |     return JsonVariantConst(getMember(detail::adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Gets the member with specified key. |   // Gets the member with specified key. | ||||||
|   // https://arduinojson.org/v6/api/jsonobjectconst/subscript/ |   // https://arduinojson.org/v6/api/jsonobjectconst/subscript/ | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE |   FORCE_INLINE typename detail::enable_if<detail::IsString<TChar*>::value, | ||||||
|       typename enable_if<IsString<TChar*>::value, JsonVariantConst>::type |                                           JsonVariantConst>::type | ||||||
|       operator[](TChar* key) const { |   operator[](TChar* key) const { | ||||||
|     return JsonVariantConst(getMember(adaptString(key))); |     return JsonVariantConst(getMember(detail::adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Compares objects. |   // Compares objects. | ||||||
| @@ -122,35 +122,35 @@ class JsonObjectConst : public VariantOperators<JsonObjectConst> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const VariantData* getData() const { |   const detail::VariantData* getData() const { | ||||||
|     return collectionToVariant(_data); |     return collectionToVariant(_data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
|   const VariantData* getMember(TAdaptedString key) const { |   const detail::VariantData* getMember(TAdaptedString key) const { | ||||||
|     if (!_data) |     if (!_data) | ||||||
|       return 0; |       return 0; | ||||||
|     return _data->getMember(key); |     return _data->getMember(key); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const CollectionData* _data; |   const detail::CollectionData* _data; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| struct Converter<JsonObjectConst> : private VariantAttorney { | struct Converter<JsonObjectConst> : private detail::VariantAttorney { | ||||||
|   static void toJson(JsonVariantConst src, JsonVariant dst) { |   static void toJson(JsonVariantConst src, JsonVariant dst) { | ||||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); |     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static JsonObjectConst fromJson(JsonVariantConst src) { |   static JsonObjectConst fromJson(JsonVariantConst src) { | ||||||
|     const VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     return data != 0 ? data->asObject() : 0; |     return data != 0 ? data->asObject() : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   static bool checkJson(JsonVariantConst src) { |   static bool checkJson(JsonVariantConst src) { | ||||||
|     const VariantData* data = getData(src); |     auto data = getData(src); | ||||||
|     return data && data->isObject(); |     return data && data->isObject(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| #include <ArduinoJson/Array/JsonArray.hpp> | #include <ArduinoJson/Array/JsonArray.hpp> | ||||||
| #include <ArduinoJson/Object/JsonObject.hpp> | #include <ArduinoJson/Object/JsonObject.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TString> | template <typename TString> | ||||||
| inline JsonArray JsonObject::createNestedArray(const TString& key) const { | inline JsonArray JsonObject::createNestedArray(const TString& key) const { | ||||||
| @@ -19,6 +19,10 @@ inline JsonArray JsonObject::createNestedArray(TChar* key) const { | |||||||
|   return operator[](key).template to<JsonArray>(); |   return operator[](key).template to<JsonArray>(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
|  | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename TDerived> | template <typename TDerived> | ||||||
| template <typename TString> | template <typename TString> | ||||||
| inline JsonArray VariantRefBase<TDerived>::createNestedArray( | inline JsonArray VariantRefBase<TDerived>::createNestedArray( | ||||||
| @@ -78,4 +82,4 @@ VariantRefBase<TDerived>::operator[](const TString& key) const { | |||||||
|   return MemberProxy<TDerived, TString>(derived(), key); |   return MemberProxy<TDerived, TString>(derived(), key); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -7,11 +7,12 @@ | |||||||
| #include <ArduinoJson/Object/JsonPair.hpp> | #include <ArduinoJson/Object/JsonPair.hpp> | ||||||
| #include <ArduinoJson/Variant/SlotFunctions.hpp> | #include <ArduinoJson/Variant/SlotFunctions.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| class JsonPairPtr { | class JsonPairPtr { | ||||||
|  public: |  public: | ||||||
|   JsonPairPtr(MemoryPool* pool, VariantSlot* slot) : _pair(pool, slot) {} |   JsonPairPtr(detail::MemoryPool* pool, detail::VariantSlot* slot) | ||||||
|  |       : _pair(pool, slot) {} | ||||||
|  |  | ||||||
|   const JsonPair* operator->() const { |   const JsonPair* operator->() const { | ||||||
|     return &_pair; |     return &_pair; | ||||||
| @@ -31,7 +32,8 @@ class JsonObjectIterator { | |||||||
|  public: |  public: | ||||||
|   JsonObjectIterator() : _slot(0) {} |   JsonObjectIterator() : _slot(0) {} | ||||||
|  |  | ||||||
|   explicit JsonObjectIterator(MemoryPool* pool, VariantSlot* slot) |   explicit JsonObjectIterator(detail::MemoryPool* pool, | ||||||
|  |                               detail::VariantSlot* slot) | ||||||
|       : _pool(pool), _slot(slot) {} |       : _pool(pool), _slot(slot) {} | ||||||
|  |  | ||||||
|   JsonPair operator*() const { |   JsonPair operator*() const { | ||||||
| @@ -60,13 +62,13 @@ class JsonObjectIterator { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool* _pool; |   detail::MemoryPool* _pool; | ||||||
|   VariantSlot* _slot; |   detail::VariantSlot* _slot; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class JsonPairConstPtr { | class JsonPairConstPtr { | ||||||
|  public: |  public: | ||||||
|   JsonPairConstPtr(const VariantSlot* slot) : _pair(slot) {} |   JsonPairConstPtr(const detail::VariantSlot* slot) : _pair(slot) {} | ||||||
|  |  | ||||||
|   const JsonPairConst* operator->() const { |   const JsonPairConst* operator->() const { | ||||||
|     return &_pair; |     return &_pair; | ||||||
| @@ -86,7 +88,8 @@ class JsonObjectConstIterator { | |||||||
|  public: |  public: | ||||||
|   JsonObjectConstIterator() : _slot(0) {} |   JsonObjectConstIterator() : _slot(0) {} | ||||||
|  |  | ||||||
|   explicit JsonObjectConstIterator(const VariantSlot* slot) : _slot(slot) {} |   explicit JsonObjectConstIterator(const detail::VariantSlot* slot) | ||||||
|  |       : _slot(slot) {} | ||||||
|  |  | ||||||
|   JsonPairConst operator*() const { |   JsonPairConst operator*() const { | ||||||
|     return JsonPairConst(_slot); |     return JsonPairConst(_slot); | ||||||
| @@ -114,6 +117,7 @@ class JsonObjectConstIterator { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const VariantSlot* _slot; |   const detail::VariantSlot* _slot; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -8,14 +8,14 @@ | |||||||
| #include <ArduinoJson/Variant/JsonVariant.hpp> | #include <ArduinoJson/Variant/JsonVariant.hpp> | ||||||
| #include <ArduinoJson/Variant/JsonVariantConst.hpp> | #include <ArduinoJson/Variant/JsonVariantConst.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE | ||||||
|  |  | ||||||
| // A key-value pair. | // A key-value pair. | ||||||
| // https://arduinojson.org/v6/api/jsonobject/begin_end/ | // https://arduinojson.org/v6/api/jsonobject/begin_end/ | ||||||
| class JsonPair { | class JsonPair { | ||||||
|  public: |  public: | ||||||
|   // INTERNAL USE ONLY |   // INTERNAL USE ONLY | ||||||
|   JsonPair(MemoryPool* pool, VariantSlot* slot) { |   JsonPair(detail::MemoryPool* pool, detail::VariantSlot* slot) { | ||||||
|     if (slot) { |     if (slot) { | ||||||
|       _key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied |       _key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied | ||||||
|                                                      : JsonString::Linked); |                                                      : JsonString::Linked); | ||||||
| @@ -42,7 +42,7 @@ class JsonPair { | |||||||
| // https://arduinojson.org/v6/api/jsonobjectconst/begin_end/ | // https://arduinojson.org/v6/api/jsonobjectconst/begin_end/ | ||||||
| class JsonPairConst { | class JsonPairConst { | ||||||
|  public: |  public: | ||||||
|   JsonPairConst(const VariantSlot* slot) { |   JsonPairConst(const detail::VariantSlot* slot) { | ||||||
|     if (slot) { |     if (slot) { | ||||||
|       _key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied |       _key = JsonString(slot->key(), slot->ownsKey() ? JsonString::Copied | ||||||
|                                                      : JsonString::Linked); |                                                      : JsonString::Linked); | ||||||
| @@ -64,4 +64,5 @@ class JsonPairConst { | |||||||
|   JsonString _key; |   JsonString _key; | ||||||
|   JsonVariantConst _value; |   JsonVariantConst _value; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PUBLIC_NAMESPACE | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
|  |  | ||||||
| #include <ArduinoJson/Variant/VariantRefBase.hpp> | #include <ArduinoJson/Variant/VariantRefBase.hpp> | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| // A proxy class to get or set a member of an object. | // A proxy class to get or set a member of an object. | ||||||
| // https://arduinojson.org/v6/api/jsonobject/subscript/ | // https://arduinojson.org/v6/api/jsonobject/subscript/ | ||||||
| @@ -61,4 +61,4 @@ class MemberProxy | |||||||
|   TStringRef _key; |   TStringRef _key; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
| #include <ArduinoJson/Configuration.hpp> | #include <ArduinoJson/Configuration.hpp> | ||||||
| #include "math.hpp" | #include "math.hpp" | ||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE | ||||||
|  |  | ||||||
| template <typename T, typename F> | template <typename T, typename F> | ||||||
| struct alias_cast_t { | struct alias_cast_t { | ||||||
| @@ -26,4 +26,5 @@ T alias_cast(F raw_data) { | |||||||
|   ac.raw = raw_data; |   ac.raw = raw_data; | ||||||
|   return ac.data; |   return ac.data; | ||||||
| } | } | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE |  | ||||||
|  | ARDUINOJSON_END_PRIVATE_NAMESPACE | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user