mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Clang-format: set DerivePointerAlignment to false
				
					
				
			This commit is contained in:
		| @@ -5,6 +5,7 @@ Standard: Cpp03 | |||||||
| AllowShortFunctionsOnASingleLine: Empty | AllowShortFunctionsOnASingleLine: Empty | ||||||
| IncludeBlocks: Preserve | IncludeBlocks: Preserve | ||||||
| IndentPPDirectives: AfterHash | IndentPPDirectives: AfterHash | ||||||
|  | DerivePointerAlignment: false | ||||||
|  |  | ||||||
| # Always break after if to get accurate coverage | # Always break after if to get accurate coverage | ||||||
| AllowShortIfStatementsOnASingleLine: false | AllowShortIfStatementsOnASingleLine: false | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
|  |  | ||||||
| extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   DeserializationError error = deserializeJson(doc, data, size); |   DeserializationError error = deserializeJson(doc, data, size); | ||||||
|   if (!error) { |   if (!error) { | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
|  |  | ||||||
| extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   DeserializationError error = deserializeMsgPack(doc, data, size); |   DeserializationError error = deserializeMsgPack(doc, data, size); | ||||||
|   if (!error) { |   if (!error) { | ||||||
|   | |||||||
| @@ -5,8 +5,8 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| static void eraseString(std::string &str) { | static void eraseString(std::string& str) { | ||||||
|   char *p = const_cast<char *>(str.c_str()); |   char* p = const_cast<char*>(str.c_str()); | ||||||
|   while (*p) *p++ = '*'; |   while (*p) *p++ = '*'; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ using namespace ARDUINOJSON_NAMESPACE; | |||||||
| TEST_CASE("ElementProxy::add()") { | TEST_CASE("ElementProxy::add()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc.add(); |   doc.add(); | ||||||
|   ElementProxy<JsonDocument &> ep = doc[0]; |   ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   SECTION("add(int)") { |   SECTION("add(int)") { | ||||||
|     ep.add(42); |     ep.add(42); | ||||||
| @@ -36,7 +36,7 @@ TEST_CASE("ElementProxy::add()") { | |||||||
| TEST_CASE("ElementProxy::clear()") { | TEST_CASE("ElementProxy::clear()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc.add(); |   doc.add(); | ||||||
|   ElementProxy<JsonDocument &> ep = doc[0]; |   ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   SECTION("size goes back to zero") { |   SECTION("size goes back to zero") { | ||||||
|     ep.add(42); |     ep.add(42); | ||||||
| @@ -96,7 +96,7 @@ TEST_CASE("ElementProxy::operator==()") { | |||||||
| TEST_CASE("ElementProxy::remove()") { | TEST_CASE("ElementProxy::remove()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc.add(); |   doc.add(); | ||||||
|   ElementProxy<JsonDocument &> ep = doc[0]; |   ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   SECTION("remove(int)") { |   SECTION("remove(int)") { | ||||||
|     ep.add(1); |     ep.add(1); | ||||||
| @@ -143,7 +143,7 @@ TEST_CASE("ElementProxy::remove()") { | |||||||
|  |  | ||||||
| TEST_CASE("ElementProxy::set()") { | TEST_CASE("ElementProxy::set()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   ElementProxy<JsonDocument &> ep = doc[0]; |   ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   SECTION("set(int)") { |   SECTION("set(int)") { | ||||||
|     ep.set(42); |     ep.set(42); | ||||||
| @@ -169,7 +169,7 @@ TEST_CASE("ElementProxy::set()") { | |||||||
| TEST_CASE("ElementProxy::size()") { | TEST_CASE("ElementProxy::size()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc.add(); |   doc.add(); | ||||||
|   ElementProxy<JsonDocument &> ep = doc[0]; |   ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   SECTION("returns 0") { |   SECTION("returns 0") { | ||||||
|     REQUIRE(ep.size() == 0); |     REQUIRE(ep.size() == 0); | ||||||
| @@ -191,7 +191,7 @@ TEST_CASE("ElementProxy::size()") { | |||||||
| TEST_CASE("ElementProxy::memoryUsage()") { | TEST_CASE("ElementProxy::memoryUsage()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc.add(); |   doc.add(); | ||||||
|   ElementProxy<JsonDocument &> ep = doc[0]; |   ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   SECTION("returns 0 for null") { |   SECTION("returns 0 for null") { | ||||||
|     REQUIRE(ep.memoryUsage() == 0); |     REQUIRE(ep.memoryUsage() == 0); | ||||||
| @@ -205,7 +205,7 @@ TEST_CASE("ElementProxy::memoryUsage()") { | |||||||
|  |  | ||||||
| TEST_CASE("ElementProxy::operator[]") { | TEST_CASE("ElementProxy::operator[]") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   ElementProxy<JsonDocument &> ep = doc[1]; |   ElementProxy<JsonDocument&> ep = doc[1]; | ||||||
|  |  | ||||||
|   SECTION("set member") { |   SECTION("set member") { | ||||||
|     ep["world"] = 42; |     ep["world"] = 42; | ||||||
| @@ -224,7 +224,7 @@ TEST_CASE("ElementProxy cast to JsonVariantConst") { | |||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc[0] = "world"; |   doc[0] = "world"; | ||||||
|  |  | ||||||
|   const ElementProxy<JsonDocument &> ep = doc[0]; |   const ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   JsonVariantConst var = ep; |   JsonVariantConst var = ep; | ||||||
|  |  | ||||||
| @@ -235,7 +235,7 @@ TEST_CASE("ElementProxy cast to JsonVariant") { | |||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc[0] = "world"; |   doc[0] = "world"; | ||||||
|  |  | ||||||
|   ElementProxy<JsonDocument &> ep = doc[0]; |   ElementProxy<JsonDocument&> ep = doc[0]; | ||||||
|  |  | ||||||
|   JsonVariant var = ep; |   JsonVariant var = ep; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ using namespace ARDUINOJSON_NAMESPACE; | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::add()") { | TEST_CASE("MemberProxy::add()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("add(int)") { |   SECTION("add(int)") { | ||||||
|     mp.add(42); |     mp.add(42); | ||||||
| @@ -26,7 +26,7 @@ TEST_CASE("MemberProxy::add()") { | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::clear()") { | TEST_CASE("MemberProxy::clear()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("size goes back to zero") { |   SECTION("size goes back to zero") { | ||||||
|     mp.add(42); |     mp.add(42); | ||||||
| @@ -85,7 +85,7 @@ TEST_CASE("MemberProxy::operator==()") { | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::containsKey()") { | TEST_CASE("MemberProxy::containsKey()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("containsKey(const char*)") { |   SECTION("containsKey(const char*)") { | ||||||
|     mp["key"] = "value"; |     mp["key"] = "value"; | ||||||
| @@ -115,9 +115,9 @@ TEST_CASE("MemberProxy::operator|()") { | |||||||
|   SECTION("Issue #1411") { |   SECTION("Issue #1411") { | ||||||
|     doc["sensor"] = "gps"; |     doc["sensor"] = "gps"; | ||||||
|  |  | ||||||
|     const char *test = "test";  // <- the literal must be captured in a variable |     const char* test = "test";  // <- the literal must be captured in a variable | ||||||
|                                 // to trigger the bug |                                 // to trigger the bug | ||||||
|     const char *sensor = doc["sensor"] | test;  // "gps" |     const char* sensor = doc["sensor"] | test;  // "gps" | ||||||
|  |  | ||||||
|     REQUIRE(sensor == std::string("gps")); |     REQUIRE(sensor == std::string("gps")); | ||||||
|   } |   } | ||||||
| @@ -136,7 +136,7 @@ TEST_CASE("MemberProxy::operator|()") { | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::remove()") { | TEST_CASE("MemberProxy::remove()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("remove(int)") { |   SECTION("remove(int)") { | ||||||
|     mp.add(1); |     mp.add(1); | ||||||
| @@ -183,7 +183,7 @@ TEST_CASE("MemberProxy::remove()") { | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::set()") { | TEST_CASE("MemberProxy::set()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("set(int)") { |   SECTION("set(int)") { | ||||||
|     mp.set(42); |     mp.set(42); | ||||||
| @@ -208,7 +208,7 @@ TEST_CASE("MemberProxy::set()") { | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::size()") { | TEST_CASE("MemberProxy::size()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("returns 0") { |   SECTION("returns 0") { | ||||||
|     REQUIRE(mp.size() == 0); |     REQUIRE(mp.size() == 0); | ||||||
| @@ -231,7 +231,7 @@ TEST_CASE("MemberProxy::size()") { | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::memoryUsage()") { | TEST_CASE("MemberProxy::memoryUsage()") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("returns 0 when null") { |   SECTION("returns 0 when null") { | ||||||
|     REQUIRE(mp.memoryUsage() == 0); |     REQUIRE(mp.memoryUsage() == 0); | ||||||
| @@ -245,7 +245,7 @@ TEST_CASE("MemberProxy::memoryUsage()") { | |||||||
|  |  | ||||||
| TEST_CASE("MemberProxy::operator[]") { | TEST_CASE("MemberProxy::operator[]") { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   SECTION("set member") { |   SECTION("set member") { | ||||||
|     mp["world"] = 42; |     mp["world"] = 42; | ||||||
| @@ -264,7 +264,7 @@ TEST_CASE("MemberProxy cast to JsonVariantConst") { | |||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc["hello"] = "world"; |   doc["hello"] = "world"; | ||||||
|  |  | ||||||
|   const MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   const MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   JsonVariantConst var = mp; |   JsonVariantConst var = mp; | ||||||
|  |  | ||||||
| @@ -275,7 +275,7 @@ TEST_CASE("MemberProxy cast to JsonVariant") { | |||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc["hello"] = "world"; |   doc["hello"] = "world"; | ||||||
|  |  | ||||||
|   MemberProxy<JsonDocument &, const char *> mp = doc["hello"]; |   MemberProxy<JsonDocument&, const char*> mp = doc["hello"]; | ||||||
|  |  | ||||||
|   JsonVariant var = mp; |   JsonVariant var = mp; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,8 +5,8 @@ | |||||||
| #include <ArduinoJson.h> | #include <ArduinoJson.h> | ||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
|  |  | ||||||
| static void eraseString(std::string &str) { | static void eraseString(std::string& str) { | ||||||
|   char *p = const_cast<char *>(str.c_str()); |   char* p = const_cast<char*>(str.c_str()); | ||||||
|   while (*p) *p++ = '*'; |   while (*p) *p++ = '*'; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -14,18 +14,18 @@ class CustomWriter { | |||||||
|     return 1; |     return 1; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t write(const uint8_t *s, size_t n) { |   size_t write(const uint8_t* s, size_t n) { | ||||||
|     _str.append(reinterpret_cast<const char *>(s), n); |     _str.append(reinterpret_cast<const char*>(s), n); | ||||||
|     return n; |     return n; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const std::string &str() const { |   const std::string& str() const { | ||||||
|     return _str; |     return _str; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   CustomWriter(const CustomWriter &);  // non-copiable |   CustomWriter(const CustomWriter&);  // non-copiable | ||||||
|   CustomWriter &operator=(const CustomWriter &); |   CustomWriter& operator=(const CustomWriter&); | ||||||
|  |  | ||||||
|   std::string _str; |   std::string _str; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ TEST_CASE("serializeJson(JsonArray)") { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Null") { |   SECTION("Null") { | ||||||
|     array.add(static_cast<char *>(0)); |     array.add(static_cast<char*>(0)); | ||||||
|  |  | ||||||
|     check(array, "[null]"); |     check(array, "[null]"); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ | |||||||
| #include <catch.hpp> | #include <catch.hpp> | ||||||
| #include <string> | #include <string> | ||||||
|  |  | ||||||
| static void checkObject(const JsonObject obj, const std::string &expected) { | static void checkObject(const JsonObject obj, const std::string& expected) { | ||||||
|   char actual[256]; |   char actual[256]; | ||||||
|   memset(actual, '!', sizeof(actual)); |   memset(actual, '!', sizeof(actual)); | ||||||
|  |  | ||||||
| @@ -84,8 +84,8 @@ TEST_CASE("serializeJson(JsonObject)") { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("TwoNull") { |   SECTION("TwoNull") { | ||||||
|     obj["a"] = static_cast<char *>(0); |     obj["a"] = static_cast<char*>(0); | ||||||
|     obj["b"] = static_cast<char *>(0); |     obj["b"] = static_cast<char*>(0); | ||||||
|     checkObject(obj, "{\"a\":null,\"b\":null}"); |     checkObject(obj, "{\"a\":null,\"b\":null}"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ | |||||||
| #include <limits> | #include <limits> | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| void check(T value, const std::string &expected) { | void check(T value, const std::string& expected) { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc.to<JsonVariant>().set(value); |   doc.to<JsonVariant>().set(value); | ||||||
|   char buffer[256] = ""; |   char buffer[256] = ""; | ||||||
| @@ -22,7 +22,7 @@ TEST_CASE("serializeJson(JsonVariant)") { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Null string") { |   SECTION("Null string") { | ||||||
|     check(static_cast<char *>(0), "null"); |     check(static_cast<char*>(0), "null"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("const char*") { |   SECTION("const char*") { | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<JsonVariant>() == false); |     CHECK(variant.is<JsonVariant>() == false); | ||||||
|     CHECK(variant.is<JsonVariantConst>() == false); |     CHECK(variant.is<JsonVariantConst>() == false); | ||||||
|     CHECK(variant.is<bool>() == false); |     CHECK(variant.is<bool>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<int>() == false); |     CHECK(variant.is<int>() == false); | ||||||
|     CHECK(variant.is<std::string>() == false); |     CHECK(variant.is<std::string>() == false); | ||||||
|     CHECK(variant.is<JsonString>() == false); |     CHECK(variant.is<JsonString>() == false); | ||||||
| @@ -34,7 +34,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<JsonObject>() == false); |     CHECK(variant.is<JsonObject>() == false); | ||||||
|     CHECK(variant.is<JsonArray>() == false); |     CHECK(variant.is<JsonArray>() == false); | ||||||
|     CHECK(variant.is<bool>() == false); |     CHECK(variant.is<bool>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<int>() == false); |     CHECK(variant.is<int>() == false); | ||||||
|     CHECK(variant.is<std::string>() == false); |     CHECK(variant.is<std::string>() == false); | ||||||
|     CHECK(variant.is<JsonString>() == false); |     CHECK(variant.is<JsonString>() == false); | ||||||
| @@ -50,7 +50,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<JsonVariantConst>() == true); |     CHECK(variant.is<JsonVariantConst>() == true); | ||||||
|     CHECK(variant.is<JsonObject>() == false); |     CHECK(variant.is<JsonObject>() == false); | ||||||
|     CHECK(variant.is<JsonArray>() == false); |     CHECK(variant.is<JsonArray>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<int>() == false); |     CHECK(variant.is<int>() == false); | ||||||
|     CHECK(variant.is<std::string>() == false); |     CHECK(variant.is<std::string>() == false); | ||||||
|     CHECK(variant.is<JsonString>() == false); |     CHECK(variant.is<JsonString>() == false); | ||||||
| @@ -66,7 +66,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<JsonVariantConst>() == true); |     CHECK(variant.is<JsonVariantConst>() == true); | ||||||
|     CHECK(variant.is<JsonObject>() == false); |     CHECK(variant.is<JsonObject>() == false); | ||||||
|     CHECK(variant.is<JsonArray>() == false); |     CHECK(variant.is<JsonArray>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<int>() == false); |     CHECK(variant.is<int>() == false); | ||||||
|     CHECK(variant.is<std::string>() == false); |     CHECK(variant.is<std::string>() == false); | ||||||
|     CHECK(variant.is<JsonString>() == false); |     CHECK(variant.is<JsonString>() == false); | ||||||
| @@ -88,7 +88,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<bool>() == false); |     CHECK(variant.is<bool>() == false); | ||||||
|     CHECK(variant.is<JsonObject>() == false); |     CHECK(variant.is<JsonObject>() == false); | ||||||
|     CHECK(variant.is<JsonArray>() == false); |     CHECK(variant.is<JsonArray>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<std::string>() == false); |     CHECK(variant.is<std::string>() == false); | ||||||
|     CHECK(variant.is<JsonString>() == false); |     CHECK(variant.is<JsonString>() == false); | ||||||
|   } |   } | ||||||
| @@ -103,7 +103,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<bool>() == false); |     CHECK(variant.is<bool>() == false); | ||||||
|     CHECK(variant.is<JsonObject>() == false); |     CHECK(variant.is<JsonObject>() == false); | ||||||
|     CHECK(variant.is<JsonArray>() == false); |     CHECK(variant.is<JsonArray>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<int>() == false); |     CHECK(variant.is<int>() == false); | ||||||
|     CHECK(variant.is<std::string>() == false); |     CHECK(variant.is<std::string>() == false); | ||||||
|     CHECK(variant.is<JsonString>() == false); |     CHECK(variant.is<JsonString>() == false); | ||||||
| @@ -113,8 +113,8 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|   SECTION("const char*") { |   SECTION("const char*") { | ||||||
|     variant.set("4.2"); |     variant.set("4.2"); | ||||||
|  |  | ||||||
|     CHECK(variant.is<const char *>() == true); |     CHECK(variant.is<const char*>() == true); | ||||||
|     CHECK(variant.is<const char *>() == true); |     CHECK(variant.is<const char*>() == true); | ||||||
|     CHECK(variant.is<std::string>() == true); |     CHECK(variant.is<std::string>() == true); | ||||||
|     CHECK(variant.is<JsonString>() == true); |     CHECK(variant.is<JsonString>() == true); | ||||||
|     CHECK(variant.is<JsonVariant>() == true); |     CHECK(variant.is<JsonVariant>() == true); | ||||||
| @@ -140,7 +140,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<int>() == false); |     CHECK(variant.is<int>() == false); | ||||||
|     CHECK(variant.is<float>() == false); |     CHECK(variant.is<float>() == false); | ||||||
|     CHECK(variant.is<bool>() == false); |     CHECK(variant.is<bool>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<MYENUM2>() == false); |     CHECK(variant.is<MYENUM2>() == false); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -156,7 +156,7 @@ TEST_CASE("JsonVariant::is<T>()") { | |||||||
|     CHECK(variant.is<int>() == false); |     CHECK(variant.is<int>() == false); | ||||||
|     CHECK(variant.is<float>() == false); |     CHECK(variant.is<float>() == false); | ||||||
|     CHECK(variant.is<bool>() == false); |     CHECK(variant.is<bool>() == false); | ||||||
|     CHECK(variant.is<const char *>() == false); |     CHECK(variant.is<const char*>() == false); | ||||||
|     CHECK(variant.is<MYENUM2>() == false); |     CHECK(variant.is<MYENUM2>() == false); | ||||||
|     CHECK(variant.is<JsonVariant>() == true); |     CHECK(variant.is<JsonVariant>() == true); | ||||||
|     CHECK(variant.is<JsonVariantConst>() == true); |     CHECK(variant.is<JsonVariantConst>() == true); | ||||||
| @@ -178,7 +178,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<JsonVariant>() == false); |     CHECK(cvariant.is<JsonVariant>() == false); | ||||||
|     CHECK(cvariant.is<JsonVariantConst>() == false); |     CHECK(cvariant.is<JsonVariantConst>() == false); | ||||||
|     CHECK(cvariant.is<bool>() == false); |     CHECK(cvariant.is<bool>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<int>() == false); |     CHECK(cvariant.is<int>() == false); | ||||||
|     CHECK(cvariant.is<std::string>() == false); |     CHECK(cvariant.is<std::string>() == false); | ||||||
|     CHECK(cvariant.is<JsonString>() == false); |     CHECK(cvariant.is<JsonString>() == false); | ||||||
| @@ -192,7 +192,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<JsonArray>() == false); |     CHECK(cvariant.is<JsonArray>() == false); | ||||||
|     CHECK(cvariant.is<JsonVariant>() == false); |     CHECK(cvariant.is<JsonVariant>() == false); | ||||||
|     CHECK(cvariant.is<bool>() == false); |     CHECK(cvariant.is<bool>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<int>() == false); |     CHECK(cvariant.is<int>() == false); | ||||||
|     CHECK(cvariant.is<std::string>() == false); |     CHECK(cvariant.is<std::string>() == false); | ||||||
|     CHECK(cvariant.is<JsonString>() == false); |     CHECK(cvariant.is<JsonString>() == false); | ||||||
| @@ -208,7 +208,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<JsonVariant>() == false); |     CHECK(cvariant.is<JsonVariant>() == false); | ||||||
|     CHECK(cvariant.is<JsonObject>() == false); |     CHECK(cvariant.is<JsonObject>() == false); | ||||||
|     CHECK(cvariant.is<JsonArray>() == false); |     CHECK(cvariant.is<JsonArray>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<int>() == false); |     CHECK(cvariant.is<int>() == false); | ||||||
|     CHECK(cvariant.is<std::string>() == false); |     CHECK(cvariant.is<std::string>() == false); | ||||||
|     CHECK(cvariant.is<JsonString>() == false); |     CHECK(cvariant.is<JsonString>() == false); | ||||||
| @@ -224,7 +224,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<JsonVariant>() == false); |     CHECK(cvariant.is<JsonVariant>() == false); | ||||||
|     CHECK(cvariant.is<JsonObject>() == false); |     CHECK(cvariant.is<JsonObject>() == false); | ||||||
|     CHECK(cvariant.is<JsonArray>() == false); |     CHECK(cvariant.is<JsonArray>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<int>() == false); |     CHECK(cvariant.is<int>() == false); | ||||||
|     CHECK(cvariant.is<std::string>() == false); |     CHECK(cvariant.is<std::string>() == false); | ||||||
|     CHECK(cvariant.is<JsonString>() == false); |     CHECK(cvariant.is<JsonString>() == false); | ||||||
| @@ -246,7 +246,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<JsonObject>() == false); |     CHECK(cvariant.is<JsonObject>() == false); | ||||||
|     CHECK(cvariant.is<JsonArray>() == false); |     CHECK(cvariant.is<JsonArray>() == false); | ||||||
|     CHECK(cvariant.is<JsonVariant>() == false); |     CHECK(cvariant.is<JsonVariant>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<std::string>() == false); |     CHECK(cvariant.is<std::string>() == false); | ||||||
|     CHECK(cvariant.is<JsonString>() == false); |     CHECK(cvariant.is<JsonString>() == false); | ||||||
|   } |   } | ||||||
| @@ -261,7 +261,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<JsonObject>() == false); |     CHECK(cvariant.is<JsonObject>() == false); | ||||||
|     CHECK(cvariant.is<JsonArray>() == false); |     CHECK(cvariant.is<JsonArray>() == false); | ||||||
|     CHECK(cvariant.is<JsonVariant>() == false); |     CHECK(cvariant.is<JsonVariant>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<int>() == false); |     CHECK(cvariant.is<int>() == false); | ||||||
|     CHECK(cvariant.is<std::string>() == false); |     CHECK(cvariant.is<std::string>() == false); | ||||||
|     CHECK(cvariant.is<JsonString>() == false); |     CHECK(cvariant.is<JsonString>() == false); | ||||||
| @@ -271,8 +271,8 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|   SECTION("const char*") { |   SECTION("const char*") { | ||||||
|     variant.set("4.2"); |     variant.set("4.2"); | ||||||
|  |  | ||||||
|     CHECK(cvariant.is<const char *>() == true); |     CHECK(cvariant.is<const char*>() == true); | ||||||
|     CHECK(cvariant.is<const char *>() == true); |     CHECK(cvariant.is<const char*>() == true); | ||||||
|     CHECK(cvariant.is<std::string>() == true); |     CHECK(cvariant.is<std::string>() == true); | ||||||
|     CHECK(cvariant.is<JsonString>() == true); |     CHECK(cvariant.is<JsonString>() == true); | ||||||
|     CHECK(cvariant.is<double>() == false); |     CHECK(cvariant.is<double>() == false); | ||||||
| @@ -297,7 +297,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<int>() == false); |     CHECK(cvariant.is<int>() == false); | ||||||
|     CHECK(cvariant.is<float>() == false); |     CHECK(cvariant.is<float>() == false); | ||||||
|     CHECK(cvariant.is<bool>() == false); |     CHECK(cvariant.is<bool>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<MYENUM2>() == false); |     CHECK(cvariant.is<MYENUM2>() == false); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -313,7 +313,7 @@ TEST_CASE("JsonVariantConst::is<T>()") { | |||||||
|     CHECK(cvariant.is<int>() == false); |     CHECK(cvariant.is<int>() == false); | ||||||
|     CHECK(cvariant.is<float>() == false); |     CHECK(cvariant.is<float>() == false); | ||||||
|     CHECK(cvariant.is<bool>() == false); |     CHECK(cvariant.is<bool>() == false); | ||||||
|     CHECK(cvariant.is<const char *>() == false); |     CHECK(cvariant.is<const char*>() == false); | ||||||
|     CHECK(cvariant.is<MYENUM2>() == false); |     CHECK(cvariant.is<MYENUM2>() == false); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") { | |||||||
|     char str[16]; |     char str[16]; | ||||||
|  |  | ||||||
|     strcpy(str, "hello"); |     strcpy(str, "hello"); | ||||||
|     bool result = variant.set(static_cast<const char *>(str)); |     bool result = variant.set(static_cast<const char*>(str)); | ||||||
|     strcpy(str, "world"); |     strcpy(str, "world"); | ||||||
|  |  | ||||||
|     REQUIRE(result == true); |     REQUIRE(result == true); | ||||||
| @@ -23,7 +23,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("(const char*)0") { |   SECTION("(const char*)0") { | ||||||
|     bool result = variant.set(static_cast<const char *>(0)); |     bool result = variant.set(static_cast<const char*>(0)); | ||||||
|  |  | ||||||
|     REQUIRE(result == true); |     REQUIRE(result == true); | ||||||
|     REQUIRE(variant.isNull()); |     REQUIRE(variant.isNull()); | ||||||
| @@ -41,7 +41,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("(char*)0") { |   SECTION("(char*)0") { | ||||||
|     bool result = variant.set(static_cast<char *>(0)); |     bool result = variant.set(static_cast<char*>(0)); | ||||||
|  |  | ||||||
|     REQUIRE(result == true); |     REQUIRE(result == true); | ||||||
|     REQUIRE(variant.isNull()); |     REQUIRE(variant.isNull()); | ||||||
| @@ -51,7 +51,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") { | |||||||
|     char str[16]; |     char str[16]; | ||||||
|  |  | ||||||
|     strcpy(str, "hello"); |     strcpy(str, "hello"); | ||||||
|     bool result = variant.set(reinterpret_cast<unsigned char *>(str)); |     bool result = variant.set(reinterpret_cast<unsigned char*>(str)); | ||||||
|     strcpy(str, "world"); |     strcpy(str, "world"); | ||||||
|  |  | ||||||
|     REQUIRE(result == true); |     REQUIRE(result == true); | ||||||
| @@ -62,7 +62,7 @@ TEST_CASE("JsonVariant::set() when there is enough memory") { | |||||||
|     char str[16]; |     char str[16]; | ||||||
|  |  | ||||||
|     strcpy(str, "hello"); |     strcpy(str, "hello"); | ||||||
|     bool result = variant.set(reinterpret_cast<signed char *>(str)); |     bool result = variant.set(reinterpret_cast<signed char*>(str)); | ||||||
|     strcpy(str, "world"); |     strcpy(str, "world"); | ||||||
|  |  | ||||||
|     REQUIRE(result == true); |     REQUIRE(result == true); | ||||||
|   | |||||||
| @@ -17,9 +17,9 @@ void checkValue(T expected) { | |||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| void checkReference(T &expected) { | void checkReference(T& expected) { | ||||||
|   JsonVariant variant = expected; |   JsonVariant variant = expected; | ||||||
|   REQUIRE(expected == variant.as<T &>()); |   REQUIRE(expected == variant.as<T&>()); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| @@ -46,10 +46,10 @@ TEST_CASE("JsonVariant set()/get()") { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|   SECTION("Null") { |   SECTION("Null") { | ||||||
|     checkValue<const char *>(NULL); |     checkValue<const char*>(NULL); | ||||||
|   } |   } | ||||||
|   SECTION("const char*") { |   SECTION("const char*") { | ||||||
|     checkValue<const char *>("hello"); |     checkValue<const char*>("hello"); | ||||||
|   } |   } | ||||||
|   SECTION("std::string") { |   SECTION("std::string") { | ||||||
|     checkValue<std::string>("hello"); |     checkValue<std::string>("hello"); | ||||||
|   | |||||||
| @@ -22,7 +22,7 @@ TEST_CASE("MemoryPool::clear()") { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Discards allocated strings") { |   SECTION("Discards allocated strings") { | ||||||
|     pool.saveString(adaptString(const_cast<char *>("123456789"))); |     pool.saveString(adaptString(const_cast<char*>("123456789"))); | ||||||
|     REQUIRE(pool.size() == 10); |     REQUIRE(pool.size() == 10); | ||||||
|  |  | ||||||
|     pool.clear(); |     pool.clear(); | ||||||
|   | |||||||
| @@ -8,11 +8,11 @@ | |||||||
|  |  | ||||||
| using namespace ARDUINOJSON_NAMESPACE; | using namespace ARDUINOJSON_NAMESPACE; | ||||||
|  |  | ||||||
| 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))); | ||||||
| } | } | ||||||
|  |  | ||||||
| static const char *saveString(MemoryPool &pool, const char *s, size_t n) { | static const char* saveString(MemoryPool& pool, const char* s, size_t n) { | ||||||
|   return pool.saveString(adaptString(s, n)); |   return pool.saveString(adaptString(s, n)); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -21,36 +21,36 @@ TEST_CASE("MemoryPool::saveString()") { | |||||||
|   MemoryPool pool(buffer, 32); |   MemoryPool pool(buffer, 32); | ||||||
|  |  | ||||||
|   SECTION("Duplicates different strings") { |   SECTION("Duplicates different strings") { | ||||||
|     const char *a = saveString(pool, "hello"); |     const char* a = saveString(pool, "hello"); | ||||||
|     const char *b = saveString(pool, "world"); |     const char* b = saveString(pool, "world"); | ||||||
|     REQUIRE(a != b); |     REQUIRE(a != b); | ||||||
|     REQUIRE(pool.size() == 6 + 6); |     REQUIRE(pool.size() == 6 + 6); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Deduplicates identical strings") { |   SECTION("Deduplicates identical strings") { | ||||||
|     const char *a = saveString(pool, "hello"); |     const char* a = saveString(pool, "hello"); | ||||||
|     const char *b = saveString(pool, "hello"); |     const char* b = saveString(pool, "hello"); | ||||||
|     REQUIRE(a == b); |     REQUIRE(a == b); | ||||||
|     REQUIRE(pool.size() == 6); |     REQUIRE(pool.size() == 6); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Deduplicates identical strings that contain NUL") { |   SECTION("Deduplicates identical strings that contain NUL") { | ||||||
|     const char *a = saveString(pool, "hello\0world", 11); |     const char* a = saveString(pool, "hello\0world", 11); | ||||||
|     const char *b = saveString(pool, "hello\0world", 11); |     const char* b = saveString(pool, "hello\0world", 11); | ||||||
|     REQUIRE(a == b); |     REQUIRE(a == b); | ||||||
|     REQUIRE(pool.size() == 12); |     REQUIRE(pool.size() == 12); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Reuse part of a string if it ends with NUL") { |   SECTION("Reuse part of a string if it ends with NUL") { | ||||||
|     const char *a = saveString(pool, "hello\0world", 11); |     const char* a = saveString(pool, "hello\0world", 11); | ||||||
|     const char *b = saveString(pool, "hello"); |     const char* b = saveString(pool, "hello"); | ||||||
|     REQUIRE(a == b); |     REQUIRE(a == b); | ||||||
|     REQUIRE(pool.size() == 12); |     REQUIRE(pool.size() == 12); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Don't stop on first NUL") { |   SECTION("Don't stop on first NUL") { | ||||||
|     const char *a = saveString(pool, "hello"); |     const char* a = saveString(pool, "hello"); | ||||||
|     const char *b = saveString(pool, "hello\0world", 11); |     const char* b = saveString(pool, "hello\0world", 11); | ||||||
|     REQUIRE(a != b); |     REQUIRE(a != b); | ||||||
|     REQUIRE(pool.size() == 18); |     REQUIRE(pool.size() == 18); | ||||||
|   } |   } | ||||||
| @@ -58,16 +58,16 @@ TEST_CASE("MemoryPool::saveString()") { | |||||||
|   SECTION("Returns NULL when full") { |   SECTION("Returns NULL when full") { | ||||||
|     REQUIRE(pool.capacity() == 32); |     REQUIRE(pool.capacity() == 32); | ||||||
|  |  | ||||||
|     const void *p1 = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |     const void* p1 = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||||
|     REQUIRE(p1 != 0); |     REQUIRE(p1 != 0); | ||||||
|     REQUIRE(pool.size() == 32); |     REQUIRE(pool.size() == 32); | ||||||
|  |  | ||||||
|     const void *p2 = saveString(pool, "b"); |     const void* p2 = saveString(pool, "b"); | ||||||
|     REQUIRE(p2 == 0); |     REQUIRE(p2 == 0); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Returns NULL when pool is too small") { |   SECTION("Returns NULL when pool is too small") { | ||||||
|     const void *p = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |     const void* p = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||||
|     REQUIRE(0 == p); |     REQUIRE(0 == p); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -82,15 +82,15 @@ TEST_CASE("MemoryPool::saveString()") { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Returns same address after clear()") { |   SECTION("Returns same address after clear()") { | ||||||
|     const void *a = saveString(pool, "hello"); |     const void* a = saveString(pool, "hello"); | ||||||
|     pool.clear(); |     pool.clear(); | ||||||
|     const void *b = saveString(pool, "world"); |     const void* b = saveString(pool, "world"); | ||||||
|  |  | ||||||
|     REQUIRE(a == b); |     REQUIRE(a == b); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   SECTION("Can use full capacity when fresh") { |   SECTION("Can use full capacity when fresh") { | ||||||
|     const void *a = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |     const void* a = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||||
|  |  | ||||||
|     REQUIRE(a != 0); |     REQUIRE(a != 0); | ||||||
|   } |   } | ||||||
| @@ -99,7 +99,7 @@ TEST_CASE("MemoryPool::saveString()") { | |||||||
|     saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); |     saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||||
|     pool.clear(); |     pool.clear(); | ||||||
|  |  | ||||||
|     const void *a = saveString(pool, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); |     const void* a = saveString(pool, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | ||||||
|  |  | ||||||
|     REQUIRE(a != 0); |     REQUIRE(a != 0); | ||||||
|   } |   } | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ TEST_CASE("serialize MsgPack to various destination types") { | |||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   JsonObject object = doc.to<JsonObject>(); |   JsonObject object = doc.to<JsonObject>(); | ||||||
|   object["hello"] = "world"; |   object["hello"] = "world"; | ||||||
|   const char *expected_result = "\x81\xA5hello\xA5world"; |   const char* expected_result = "\x81\xA5hello\xA5world"; | ||||||
|   const size_t expected_length = 13; |   const size_t expected_length = 13; | ||||||
|  |  | ||||||
|   SECTION("std::string") { |   SECTION("std::string") { | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ | |||||||
| #include <limits> | #include <limits> | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| void check(T value, const std::string &expected) { | void check(T value, const std::string& expected) { | ||||||
|   DynamicJsonDocument doc(4096); |   DynamicJsonDocument doc(4096); | ||||||
|   doc.to<JsonVariant>().set(value); |   doc.to<JsonVariant>().set(value); | ||||||
|   char buffer[256] = ""; |   char buffer[256] = ""; | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|  |  | ||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
|  |  | ||||||
| inline VariantData *arrayAdd(CollectionData *arr, MemoryPool *pool) { | inline VariantData* arrayAdd(CollectionData* arr, MemoryPool* pool) { | ||||||
|   return arr ? arr->addElement(pool) : 0; |   return arr ? arr->addElement(pool) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,13 +11,13 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
|  |  | ||||||
| class VariantPtr { | class VariantPtr { | ||||||
|  public: |  public: | ||||||
|   VariantPtr(MemoryPool *pool, VariantData *data) : _variant(pool, data) {} |   VariantPtr(MemoryPool* pool, VariantData* data) : _variant(pool, data) {} | ||||||
|  |  | ||||||
|   VariantRef *operator->() { |   VariantRef* operator->() { | ||||||
|     return &_variant; |     return &_variant; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantRef &operator*() { |   VariantRef& operator*() { | ||||||
|     return _variant; |     return _variant; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -28,7 +28,7 @@ class VariantPtr { | |||||||
| class ArrayIterator { | class ArrayIterator { | ||||||
|  public: |  public: | ||||||
|   ArrayIterator() : _slot(0) {} |   ArrayIterator() : _slot(0) {} | ||||||
|   explicit ArrayIterator(MemoryPool *pool, VariantSlot *slot) |   explicit ArrayIterator(MemoryPool* pool, VariantSlot* slot) | ||||||
|       : _pool(pool), _slot(slot) {} |       : _pool(pool), _slot(slot) {} | ||||||
|  |  | ||||||
|   VariantRef operator*() const { |   VariantRef operator*() const { | ||||||
| @@ -38,42 +38,42 @@ class ArrayIterator { | |||||||
|     return VariantPtr(_pool, _slot->data()); |     return VariantPtr(_pool, _slot->data()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator==(const ArrayIterator &other) const { |   bool operator==(const ArrayIterator& other) const { | ||||||
|     return _slot == other._slot; |     return _slot == other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator!=(const ArrayIterator &other) const { |   bool operator!=(const ArrayIterator& other) const { | ||||||
|     return _slot != other._slot; |     return _slot != other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ArrayIterator &operator++() { |   ArrayIterator& operator++() { | ||||||
|     _slot = _slot->next(); |     _slot = _slot->next(); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ArrayIterator &operator+=(size_t distance) { |   ArrayIterator& operator+=(size_t distance) { | ||||||
|     _slot = _slot->next(distance); |     _slot = _slot->next(distance); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantSlot *internal() { |   VariantSlot* internal() { | ||||||
|     return _slot; |     return _slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool *_pool; |   MemoryPool* _pool; | ||||||
|   VariantSlot *_slot; |   VariantSlot* _slot; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class VariantConstPtr { | class VariantConstPtr { | ||||||
|  public: |  public: | ||||||
|   VariantConstPtr(const VariantData *data) : _variant(data) {} |   VariantConstPtr(const VariantData* data) : _variant(data) {} | ||||||
|  |  | ||||||
|   VariantConstRef *operator->() { |   VariantConstRef* operator->() { | ||||||
|     return &_variant; |     return &_variant; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantConstRef &operator*() { |   VariantConstRef& operator*() { | ||||||
|     return _variant; |     return _variant; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -84,7 +84,7 @@ class VariantConstPtr { | |||||||
| class ArrayConstRefIterator { | class ArrayConstRefIterator { | ||||||
|  public: |  public: | ||||||
|   ArrayConstRefIterator() : _slot(0) {} |   ArrayConstRefIterator() : _slot(0) {} | ||||||
|   explicit ArrayConstRefIterator(const VariantSlot *slot) : _slot(slot) {} |   explicit ArrayConstRefIterator(const VariantSlot* slot) : _slot(slot) {} | ||||||
|  |  | ||||||
|   VariantConstRef operator*() const { |   VariantConstRef operator*() const { | ||||||
|     return VariantConstRef(_slot->data()); |     return VariantConstRef(_slot->data()); | ||||||
| @@ -93,29 +93,29 @@ class ArrayConstRefIterator { | |||||||
|     return VariantConstPtr(_slot->data()); |     return VariantConstPtr(_slot->data()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator==(const ArrayConstRefIterator &other) const { |   bool operator==(const ArrayConstRefIterator& other) const { | ||||||
|     return _slot == other._slot; |     return _slot == other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator!=(const ArrayConstRefIterator &other) const { |   bool operator!=(const ArrayConstRefIterator& other) const { | ||||||
|     return _slot != other._slot; |     return _slot != other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ArrayConstRefIterator &operator++() { |   ArrayConstRefIterator& operator++() { | ||||||
|     _slot = _slot->next(); |     _slot = _slot->next(); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ArrayConstRefIterator &operator+=(size_t distance) { |   ArrayConstRefIterator& operator+=(size_t distance) { | ||||||
|     _slot = _slot->next(distance); |     _slot = _slot->next(distance); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const VariantSlot *internal() { |   const VariantSlot* internal() { | ||||||
|     return _slot; |     return _slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const VariantSlot *_slot; |   const VariantSlot* _slot; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -30,20 +30,20 @@ class ArrayShortcuts { | |||||||
|   // TValue = bool, long, int, short, float, double, serialized, VariantRef, |   // TValue = bool, long, int, short, float, double, serialized, VariantRef, | ||||||
|   //          std::string, String, ObjectRef |   //          std::string, String, ObjectRef | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE bool add(const T &value) const { |   FORCE_INLINE bool add(const T& value) const { | ||||||
|     return impl()->add().set(value); |     return impl()->add().set(value); | ||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // bool add(TValue); |   // bool add(TValue); | ||||||
|   // TValue = char*, const char*, const __FlashStringHelper* |   // TValue = char*, const char*, const __FlashStringHelper* | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE bool add(T *value) const { |   FORCE_INLINE bool add(T* value) const { | ||||||
|     return impl()->add().set(value); |     return impl()->add().set(value); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const TArray *impl() const { |   const TArray* impl() const { | ||||||
|     return static_cast<const TArray *>(this); |     return static_cast<const TArray*>(this); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -16,8 +16,8 @@ class VariantData; | |||||||
| class VariantSlot; | class VariantSlot; | ||||||
|  |  | ||||||
| class CollectionData { | class CollectionData { | ||||||
|   VariantSlot *_head; |   VariantSlot* _head; | ||||||
|   VariantSlot *_tail; |   VariantSlot* _tail; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   // Must be a POD! |   // Must be a POD! | ||||||
| @@ -28,24 +28,24 @@ class CollectionData { | |||||||
|  |  | ||||||
|   // Array only |   // Array only | ||||||
|  |  | ||||||
|   VariantData *addElement(MemoryPool *pool); |   VariantData* addElement(MemoryPool* pool); | ||||||
|  |  | ||||||
|   VariantData *getElement(size_t index) const; |   VariantData* getElement(size_t index) const; | ||||||
|  |  | ||||||
|   VariantData *getOrAddElement(size_t index, MemoryPool *pool); |   VariantData* getOrAddElement(size_t index, MemoryPool* pool); | ||||||
|  |  | ||||||
|   void removeElement(size_t index); |   void removeElement(size_t index); | ||||||
|  |  | ||||||
|   // Object only |   // Object only | ||||||
|  |  | ||||||
|   template <typename TAdaptedString, typename TStoragePolicy> |   template <typename TAdaptedString, typename TStoragePolicy> | ||||||
|   VariantData *addMember(TAdaptedString key, MemoryPool *pool, TStoragePolicy); |   VariantData* addMember(TAdaptedString key, MemoryPool* pool, TStoragePolicy); | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
|   VariantData *getMember(TAdaptedString key) const; |   VariantData* getMember(TAdaptedString key) const; | ||||||
|  |  | ||||||
|   template <typename TAdaptedString, typename TStoragePolicy> |   template <typename TAdaptedString, typename TStoragePolicy> | ||||||
|   VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool, |   VariantData* getOrAddMember(TAdaptedString key, MemoryPool* pool, | ||||||
|                               TStoragePolicy); |                               TStoragePolicy); | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
| @@ -54,7 +54,7 @@ class CollectionData { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
|   bool containsKey(const TAdaptedString &key) const; |   bool containsKey(const TAdaptedString& key) const; | ||||||
|  |  | ||||||
|   // Generic |   // Generic | ||||||
|  |  | ||||||
| @@ -62,34 +62,34 @@ class CollectionData { | |||||||
|   size_t memoryUsage() const; |   size_t memoryUsage() const; | ||||||
|   size_t size() const; |   size_t size() const; | ||||||
|  |  | ||||||
|   VariantSlot *addSlot(MemoryPool *); |   VariantSlot* addSlot(MemoryPool*); | ||||||
|   void removeSlot(VariantSlot *slot); |   void removeSlot(VariantSlot* slot); | ||||||
|  |  | ||||||
|   bool copyFrom(const CollectionData &src, MemoryPool *pool); |   bool copyFrom(const CollectionData& src, MemoryPool* pool); | ||||||
|  |  | ||||||
|   VariantSlot *head() const { |   VariantSlot* head() const { | ||||||
|     return _head; |     return _head; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance); |   void movePointers(ptrdiff_t stringDistance, ptrdiff_t variantDistance); | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   VariantSlot *getSlot(size_t index) const; |   VariantSlot* getSlot(size_t index) const; | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
|   VariantSlot *getSlot(TAdaptedString key) const; |   VariantSlot* getSlot(TAdaptedString key) const; | ||||||
|  |  | ||||||
|   VariantSlot *getPreviousSlot(VariantSlot *) const; |   VariantSlot* getPreviousSlot(VariantSlot*) const; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| inline const VariantData *collectionToVariant( | inline const VariantData* collectionToVariant( | ||||||
|     const CollectionData *collection) { |     const CollectionData* collection) { | ||||||
|   const void *data = collection;  // prevent warning cast-align |   const void* data = collection;  // prevent warning cast-align | ||||||
|   return reinterpret_cast<const VariantData *>(data); |   return reinterpret_cast<const VariantData*>(data); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline VariantData *collectionToVariant(CollectionData *collection) { | 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 | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
|  |  | ||||||
| template <template <typename, typename> class TDeserializer, typename TReader, | template <template <typename, typename> class TDeserializer, typename TReader, | ||||||
|           typename TWriter> |           typename TWriter> | ||||||
| TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool *pool, | TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool* pool, | ||||||
|                                                  TReader reader, |                                                  TReader reader, | ||||||
|                                                  TWriter writer) { |                                                  TWriter writer) { | ||||||
|   ARDUINOJSON_ASSERT(pool != 0); |   ARDUINOJSON_ASSERT(pool != 0); | ||||||
| @@ -29,11 +29,11 @@ TDeserializer<TReader, TWriter> makeDeserializer(MemoryPool *pool, | |||||||
| 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 enable_if<!is_array<TString>::value, DeserializationError>::type | ||||||
| deserialize(JsonDocument &doc, const TString &input, NestingLimit nestingLimit, | deserialize(JsonDocument& doc, const TString& input, NestingLimit nestingLimit, | ||||||
|             TFilter filter) { |             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); | ||||||
|   doc.clear(); |   doc.clear(); | ||||||
|   return makeDeserializer<TDeserializer>(pool, reader, |   return makeDeserializer<TDeserializer>(pool, reader, | ||||||
|                                          makeStringStorage(input, pool)) |                                          makeStringStorage(input, pool)) | ||||||
| @@ -45,12 +45,12 @@ 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(JsonDocument& doc, TChar* input, | ||||||
|                                  size_t inputSize, NestingLimit nestingLimit, |                                  size_t inputSize, NestingLimit nestingLimit, | ||||||
|                                  TFilter filter) { |                                  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); | ||||||
|   doc.clear(); |   doc.clear(); | ||||||
|   return makeDeserializer<TDeserializer>(pool, reader, |   return makeDeserializer<TDeserializer>(pool, reader, | ||||||
|                                          makeStringStorage(input, pool)) |                                          makeStringStorage(input, pool)) | ||||||
| @@ -61,11 +61,11 @@ 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(JsonDocument& doc, TStream& input, | ||||||
|                                  NestingLimit nestingLimit, TFilter filter) { |                                  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); | ||||||
|   doc.clear(); |   doc.clear(); | ||||||
|   return makeDeserializer<TDeserializer>(pool, reader, |   return makeDeserializer<TDeserializer>(pool, reader, | ||||||
|                                          makeStringStorage(input, pool)) |                                          makeStringStorage(input, pool)) | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ class EscapeSequence { | |||||||
|  public: |  public: | ||||||
|   // Optimized for code size on a 8-bit AVR |   // Optimized for code size on a 8-bit AVR | ||||||
|   static char escapeChar(char c) { |   static char escapeChar(char c) { | ||||||
|     const char *p = escapeTable(true); |     const char* p = escapeTable(true); | ||||||
|     while (p[0] && p[1] != c) { |     while (p[0] && p[1] != c) { | ||||||
|       p += 2; |       p += 2; | ||||||
|     } |     } | ||||||
| @@ -21,7 +21,7 @@ class EscapeSequence { | |||||||
|  |  | ||||||
|   // Optimized for code size on a 8-bit AVR |   // Optimized for code size on a 8-bit AVR | ||||||
|   static char unescapeChar(char c) { |   static char unescapeChar(char c) { | ||||||
|     const char *p = escapeTable(false); |     const char* p = escapeTable(false); | ||||||
|     for (;;) { |     for (;;) { | ||||||
|       if (p[0] == '\0') |       if (p[0] == '\0') | ||||||
|         return 0; |         return 0; | ||||||
| @@ -32,7 +32,7 @@ class EscapeSequence { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   static const char *escapeTable(bool excludeSolidus) { |   static const char* escapeTable(bool excludeSolidus) { | ||||||
|     return &"//\"\"\\\\b\bf\fn\nr\rt\t"[excludeSolidus ? 2 : 0]; |     return &"//\"\"\\\\b\bf\fn\nr\rt\t"[excludeSolidus ? 2 : 0]; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
| template <typename TReader, typename TStringStorage> | template <typename TReader, typename TStringStorage> | ||||||
| class JsonDeserializer { | class JsonDeserializer { | ||||||
|  public: |  public: | ||||||
|   JsonDeserializer(MemoryPool *pool, TReader reader, |   JsonDeserializer(MemoryPool* pool, TReader reader, | ||||||
|                    TStringStorage stringStorage) |                    TStringStorage stringStorage) | ||||||
|       : _stringStorage(stringStorage), |       : _stringStorage(stringStorage), | ||||||
|         _foundSomething(false), |         _foundSomething(false), | ||||||
| @@ -28,7 +28,7 @@ class JsonDeserializer { | |||||||
|         _pool(pool) {} |         _pool(pool) {} | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError parse(VariantData &variant, TFilter filter, |   DeserializationError parse(VariantData& variant, TFilter filter, | ||||||
|                              NestingLimit nestingLimit) { |                              NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
| @@ -59,7 +59,7 @@ class JsonDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseVariant(VariantData &variant, TFilter filter, |   DeserializationError::Code parseVariant(VariantData& variant, TFilter filter, | ||||||
|                                           NestingLimit nestingLimit) { |                                           NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
| @@ -143,7 +143,7 @@ class JsonDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseArray(CollectionData &array, TFilter filter, |   DeserializationError::Code parseArray(CollectionData& array, TFilter filter, | ||||||
|                                         NestingLimit nestingLimit) { |                                         NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
| @@ -169,7 +169,7 @@ class JsonDeserializer { | |||||||
|     for (;;) { |     for (;;) { | ||||||
|       if (memberFilter.allow()) { |       if (memberFilter.allow()) { | ||||||
|         // Allocate slot in array |         // Allocate slot in array | ||||||
|         VariantData *value = array.addElement(_pool); |         VariantData* value = array.addElement(_pool); | ||||||
|         if (!value) |         if (!value) | ||||||
|           return DeserializationError::NoMemory; |           return DeserializationError::NoMemory; | ||||||
|  |  | ||||||
| @@ -227,7 +227,7 @@ class JsonDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseObject(CollectionData &object, TFilter filter, |   DeserializationError::Code parseObject(CollectionData& object, TFilter filter, | ||||||
|                                          NestingLimit nestingLimit) { |                                          NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
| @@ -268,14 +268,14 @@ class JsonDeserializer { | |||||||
|       TFilter memberFilter = filter[key.c_str()]; |       TFilter memberFilter = filter[key.c_str()]; | ||||||
|  |  | ||||||
|       if (memberFilter.allow()) { |       if (memberFilter.allow()) { | ||||||
|         VariantData *variant = object.getMember(adaptString(key.c_str())); |         VariantData* variant = object.getMember(adaptString(key.c_str())); | ||||||
|         if (!variant) { |         if (!variant) { | ||||||
|           // Save key in memory pool. |           // Save key in memory pool. | ||||||
|           // This MUST be done before adding the slot. |           // This MUST be done before adding the slot. | ||||||
|           key = _stringStorage.save(); |           key = _stringStorage.save(); | ||||||
|  |  | ||||||
|           // Allocate slot in object |           // Allocate slot in object | ||||||
|           VariantSlot *slot = object.addSlot(_pool); |           VariantSlot* slot = object.addSlot(_pool); | ||||||
|           if (!slot) |           if (!slot) | ||||||
|             return DeserializationError::NoMemory; |             return DeserializationError::NoMemory; | ||||||
|  |  | ||||||
| @@ -378,7 +378,7 @@ class JsonDeserializer { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code parseStringValue(VariantData &variant) { |   DeserializationError::Code parseStringValue(VariantData& variant) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     _stringStorage.startString(); |     _stringStorage.startString(); | ||||||
| @@ -503,7 +503,7 @@ class JsonDeserializer { | |||||||
|     return DeserializationError::Ok; |     return DeserializationError::Ok; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code parseNumericValue(VariantData &result) { |   DeserializationError::Code parseNumericValue(VariantData& result) { | ||||||
|     uint8_t n = 0; |     uint8_t n = 0; | ||||||
|  |  | ||||||
|     char c = current(); |     char c = current(); | ||||||
| @@ -529,7 +529,7 @@ class JsonDeserializer { | |||||||
|     return DeserializationError::Ok; |     return DeserializationError::Ok; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code parseHex4(uint16_t &result) { |   DeserializationError::Code parseHex4(uint16_t& result) { | ||||||
|     result = 0; |     result = 0; | ||||||
|     for (uint8_t i = 0; i < 4; ++i) { |     for (uint8_t i = 0; i < 4; ++i) { | ||||||
|       char digit = current(); |       char digit = current(); | ||||||
| @@ -639,7 +639,7 @@ class JsonDeserializer { | |||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code skipKeyword(const char *s) { |   DeserializationError::Code skipKeyword(const char* s) { | ||||||
|     while (*s) { |     while (*s) { | ||||||
|       char c = current(); |       char c = current(); | ||||||
|       if (c == '\0') |       if (c == '\0') | ||||||
| @@ -655,7 +655,7 @@ class JsonDeserializer { | |||||||
|   TStringStorage _stringStorage; |   TStringStorage _stringStorage; | ||||||
|   bool _foundSomething; |   bool _foundSomething; | ||||||
|   Latch<TReader> _latch; |   Latch<TReader> _latch; | ||||||
|   MemoryPool *_pool; |   MemoryPool* _pool; | ||||||
|   char _buffer[64];  // using a member instead of a local variable because it |   char _buffer[64];  // using a member instead of a local variable because it | ||||||
|                      // ended in the recursive path after compiler inlined the |                      // ended in the recursive path after compiler inlined the | ||||||
|                      // code |                      // code | ||||||
| @@ -667,7 +667,7 @@ class JsonDeserializer { | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument &doc, const TString &input, |     JsonDocument& doc, const TString& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| @@ -675,13 +675,13 @@ DeserializationError deserializeJson( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument &doc, const TString &input, Filter filter, |     JsonDocument& doc, const TString& input, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeJson(JsonDocument &doc, const TString &input, | DeserializationError deserializeJson(JsonDocument& doc, const TString& input, | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |                                      NestingLimit nestingLimit, Filter filter) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| @@ -692,7 +692,7 @@ DeserializationError deserializeJson(JsonDocument &doc, const TString &input, | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument &doc, TStream &input, |     JsonDocument& doc, TStream& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| @@ -700,13 +700,13 @@ DeserializationError deserializeJson( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument &doc, TStream &input, Filter filter, |     JsonDocument& doc, TStream& input, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeJson(JsonDocument &doc, TStream &input, | DeserializationError deserializeJson(JsonDocument& doc, TStream& input, | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |                                      NestingLimit nestingLimit, Filter filter) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| @@ -717,7 +717,7 @@ DeserializationError deserializeJson(JsonDocument &doc, TStream &input, | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument &doc, TChar *input, |     JsonDocument& doc, TChar* input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| @@ -725,13 +725,13 @@ DeserializationError deserializeJson( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson( | DeserializationError deserializeJson( | ||||||
|     JsonDocument &doc, TChar *input, Filter filter, |     JsonDocument& doc, TChar* input, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson(JsonDocument &doc, TChar *input, | DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |                                      NestingLimit nestingLimit, Filter filter) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<JsonDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| @@ -742,7 +742,7 @@ DeserializationError deserializeJson(JsonDocument &doc, TChar *input, | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| 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()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                        AllowAllFilter()); |                                        AllowAllFilter()); | ||||||
| @@ -750,14 +750,14 @@ DeserializationError deserializeJson( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| 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, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                        filter); |                                        filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeJson(JsonDocument &doc, TChar *input, | DeserializationError deserializeJson(JsonDocument& doc, TChar* input, | ||||||
|                                      size_t inputSize, |                                      size_t inputSize, | ||||||
|                                      NestingLimit nestingLimit, Filter filter) { |                                      NestingLimit nestingLimit, Filter filter) { | ||||||
|   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<JsonDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|   | |||||||
| @@ -18,10 +18,10 @@ class JsonSerializer : public Visitor<size_t> { | |||||||
|  |  | ||||||
|   JsonSerializer(TWriter writer) : _formatter(writer) {} |   JsonSerializer(TWriter writer) : _formatter(writer) {} | ||||||
|  |  | ||||||
|   FORCE_INLINE size_t visitArray(const CollectionData &array) { |   FORCE_INLINE size_t visitArray(const CollectionData& array) { | ||||||
|     write('['); |     write('['); | ||||||
|  |  | ||||||
|     const VariantSlot *slot = array.head(); |     const VariantSlot* slot = array.head(); | ||||||
|  |  | ||||||
|     while (slot != 0) { |     while (slot != 0) { | ||||||
|       slot->data()->accept(*this); |       slot->data()->accept(*this); | ||||||
| @@ -37,10 +37,10 @@ class JsonSerializer : public Visitor<size_t> { | |||||||
|     return bytesWritten(); |     return bytesWritten(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t visitObject(const CollectionData &object) { |   size_t visitObject(const CollectionData& object) { | ||||||
|     write('{'); |     write('{'); | ||||||
|  |  | ||||||
|     const VariantSlot *slot = object.head(); |     const VariantSlot* slot = object.head(); | ||||||
|  |  | ||||||
|     while (slot != 0) { |     while (slot != 0) { | ||||||
|       _formatter.writeString(slot->key()); |       _formatter.writeString(slot->key()); | ||||||
| @@ -63,17 +63,17 @@ class JsonSerializer : public Visitor<size_t> { | |||||||
|     return bytesWritten(); |     return bytesWritten(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t visitString(const char *value) { |   size_t visitString(const char* value) { | ||||||
|     _formatter.writeString(value); |     _formatter.writeString(value); | ||||||
|     return bytesWritten(); |     return bytesWritten(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t visitString(const char *value, size_t n) { |   size_t visitString(const char* value, size_t n) { | ||||||
|     _formatter.writeString(value, n); |     _formatter.writeString(value, n); | ||||||
|     return bytesWritten(); |     return bytesWritten(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t visitRawJson(const char *data, size_t n) { |   size_t visitRawJson(const char* data, size_t n) { | ||||||
|     _formatter.writeRaw(data, n); |     _formatter.writeRaw(data, n); | ||||||
|     return bytesWritten(); |     return bytesWritten(); | ||||||
|   } |   } | ||||||
| @@ -107,7 +107,7 @@ class JsonSerializer : public Visitor<size_t> { | |||||||
|     _formatter.writeRaw(c); |     _formatter.writeRaw(c); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void write(const char *s) { |   void write(const char* s) { | ||||||
|     _formatter.writeRaw(s); |     _formatter.writeRaw(s); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -116,11 +116,11 @@ class JsonSerializer : public Visitor<size_t> { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| template <typename TDestination> | template <typename TDestination> | ||||||
| size_t serializeJson(VariantConstRef source, TDestination &destination) { | size_t serializeJson(VariantConstRef source, TDestination& destination) { | ||||||
|   return serialize<JsonSerializer>(source, destination); |   return serialize<JsonSerializer>(source, destination); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline size_t serializeJson(VariantConstRef source, void *buffer, | inline size_t serializeJson(VariantConstRef source, void* buffer, | ||||||
|                             size_t bufferSize) { |                             size_t bufferSize) { | ||||||
|   return serialize<JsonSerializer>(source, buffer, bufferSize); |   return serialize<JsonSerializer>(source, buffer, bufferSize); | ||||||
| } | } | ||||||
| @@ -132,8 +132,8 @@ inline size_t measureJson(VariantConstRef source) { | |||||||
| #if ARDUINOJSON_ENABLE_STD_STREAM | #if ARDUINOJSON_ENABLE_STD_STREAM | ||||||
| template <typename T> | template <typename T> | ||||||
| inline typename enable_if<is_convertible<T, VariantConstRef>::value, | inline typename enable_if<is_convertible<T, VariantConstRef>::value, | ||||||
|                           std::ostream &>::type |                           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; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -18,8 +18,8 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> { | |||||||
|  public: |  public: | ||||||
|   PrettyJsonSerializer(TWriter writer) : base(writer), _nesting(0) {} |   PrettyJsonSerializer(TWriter writer) : base(writer), _nesting(0) {} | ||||||
|  |  | ||||||
|   size_t visitArray(const CollectionData &array) { |   size_t visitArray(const CollectionData& array) { | ||||||
|     const VariantSlot *slot = array.head(); |     const VariantSlot* slot = array.head(); | ||||||
|     if (slot) { |     if (slot) { | ||||||
|       base::write("[\r\n"); |       base::write("[\r\n"); | ||||||
|       _nesting++; |       _nesting++; | ||||||
| @@ -39,8 +39,8 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> { | |||||||
|     return this->bytesWritten(); |     return this->bytesWritten(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t visitObject(const CollectionData &object) { |   size_t visitObject(const CollectionData& object) { | ||||||
|     const VariantSlot *slot = object.head(); |     const VariantSlot* slot = object.head(); | ||||||
|     if (slot) { |     if (slot) { | ||||||
|       base::write("{\r\n"); |       base::write("{\r\n"); | ||||||
|       _nesting++; |       _nesting++; | ||||||
| @@ -71,11 +71,11 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| template <typename TDestination> | template <typename TDestination> | ||||||
| size_t serializeJsonPretty(VariantConstRef source, TDestination &destination) { | size_t serializeJsonPretty(VariantConstRef source, TDestination& destination) { | ||||||
|   return serialize<PrettyJsonSerializer>(source, destination); |   return serialize<PrettyJsonSerializer>(source, destination); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline size_t serializeJsonPretty(VariantConstRef source, void *buffer, | inline size_t serializeJsonPretty(VariantConstRef source, void* buffer, | ||||||
|                                   size_t bufferSize) { |                                   size_t bufferSize) { | ||||||
|   return serialize<PrettyJsonSerializer>(source, buffer, bufferSize); |   return serialize<PrettyJsonSerializer>(source, buffer, bufferSize); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -34,14 +34,14 @@ class TextFormatter { | |||||||
|       writeRaw("false"); |       writeRaw("false"); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void writeString(const char *value) { |   void writeString(const char* value) { | ||||||
|     ARDUINOJSON_ASSERT(value != NULL); |     ARDUINOJSON_ASSERT(value != NULL); | ||||||
|     writeRaw('\"'); |     writeRaw('\"'); | ||||||
|     while (*value) writeChar(*value++); |     while (*value) writeChar(*value++); | ||||||
|     writeRaw('\"'); |     writeRaw('\"'); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void writeString(const char *value, size_t n) { |   void writeString(const char* value, size_t n) { | ||||||
|     ARDUINOJSON_ASSERT(value != NULL); |     ARDUINOJSON_ASSERT(value != NULL); | ||||||
|     writeRaw('\"'); |     writeRaw('\"'); | ||||||
|     while (n--) writeChar(*value++); |     while (n--) writeChar(*value++); | ||||||
| @@ -111,8 +111,8 @@ class TextFormatter { | |||||||
|   template <typename T> |   template <typename T> | ||||||
|   typename enable_if<is_unsigned<T>::value>::type writeInteger(T value) { |   typename enable_if<is_unsigned<T>::value>::type writeInteger(T value) { | ||||||
|     char buffer[22]; |     char buffer[22]; | ||||||
|     char *end = buffer + sizeof(buffer); |     char* end = buffer + sizeof(buffer); | ||||||
|     char *begin = end; |     char* begin = end; | ||||||
|  |  | ||||||
|     // write the string in reverse order |     // write the string in reverse order | ||||||
|     do { |     do { | ||||||
| @@ -127,8 +127,8 @@ class TextFormatter { | |||||||
|   void writeDecimals(uint32_t value, int8_t width) { |   void writeDecimals(uint32_t value, int8_t width) { | ||||||
|     // buffer should be big enough for all digits and the dot |     // buffer should be big enough for all digits and the dot | ||||||
|     char buffer[16]; |     char buffer[16]; | ||||||
|     char *end = buffer + sizeof(buffer); |     char* end = buffer + sizeof(buffer); | ||||||
|     char *begin = end; |     char* begin = end; | ||||||
|  |  | ||||||
|     // write the string in reverse order |     // write the string in reverse order | ||||||
|     while (width--) { |     while (width--) { | ||||||
| @@ -141,22 +141,22 @@ class TextFormatter { | |||||||
|     writeRaw(begin, end); |     writeRaw(begin, end); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void writeRaw(const char *s) { |   void writeRaw(const char* s) { | ||||||
|     _writer.write(reinterpret_cast<const uint8_t *>(s), strlen(s)); |     _writer.write(reinterpret_cast<const uint8_t*>(s), strlen(s)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void writeRaw(const char *s, size_t n) { |   void writeRaw(const char* s, size_t n) { | ||||||
|     _writer.write(reinterpret_cast<const uint8_t *>(s), n); |     _writer.write(reinterpret_cast<const uint8_t*>(s), n); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void writeRaw(const char *begin, const char *end) { |   void writeRaw(const char* begin, const char* end) { | ||||||
|     _writer.write(reinterpret_cast<const uint8_t *>(begin), |     _writer.write(reinterpret_cast<const uint8_t*>(begin), | ||||||
|                   static_cast<size_t>(end - begin)); |                   static_cast<size_t>(end - begin)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <size_t N> |   template <size_t N> | ||||||
|   void writeRaw(const char (&s)[N]) { |   void writeRaw(const char (&s)[N]) { | ||||||
|     _writer.write(reinterpret_cast<const uint8_t *>(s), N - 1); |     _writer.write(reinterpret_cast<const uint8_t*>(s), N - 1); | ||||||
|   } |   } | ||||||
|   void writeRaw(char c) { |   void writeRaw(char c) { | ||||||
|     _writer.write(static_cast<uint8_t>(c)); |     _writer.write(static_cast<uint8_t>(c)); | ||||||
| @@ -166,6 +166,6 @@ class TextFormatter { | |||||||
|   CountingDecorator<TWriter> _writer; |   CountingDecorator<TWriter> _writer; | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   TextFormatter &operator=(const TextFormatter &);  // cannot be assigned |   TextFormatter& operator=(const TextFormatter&);  // cannot be assigned | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -13,19 +13,19 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
| #if ARDUINOJSON_ENABLE_ALIGNMENT | #if ARDUINOJSON_ENABLE_ALIGNMENT | ||||||
|  |  | ||||||
| inline bool isAligned(size_t value) { | inline bool isAligned(size_t value) { | ||||||
|   const size_t mask = sizeof(void *) - 1; |   const size_t mask = sizeof(void*) - 1; | ||||||
|   size_t addr = value; |   size_t addr = value; | ||||||
|   return (addr & mask) == 0; |   return (addr & mask) == 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline size_t addPadding(size_t bytes) { | inline size_t addPadding(size_t bytes) { | ||||||
|   const size_t mask = sizeof(void *) - 1; |   const size_t mask = sizeof(void*) - 1; | ||||||
|   return (bytes + mask) & ~mask; |   return (bytes + mask) & ~mask; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <size_t bytes> | template <size_t bytes> | ||||||
| struct AddPadding { | struct AddPadding { | ||||||
|   static const size_t mask = sizeof(void *) - 1; |   static const size_t mask = sizeof(void*) - 1; | ||||||
|   static const size_t value = (bytes + mask) & ~mask; |   static const size_t value = (bytes + mask) & ~mask; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -47,14 +47,14 @@ struct AddPadding { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| inline bool isAligned(T *ptr) { | inline bool isAligned(T* ptr) { | ||||||
|   return isAligned(reinterpret_cast<size_t>(ptr)); |   return isAligned(reinterpret_cast<size_t>(ptr)); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| inline T *addPadding(T *p) { | inline T* addPadding(T* p) { | ||||||
|   size_t address = addPadding(reinterpret_cast<size_t>(p)); |   size_t address = addPadding(reinterpret_cast<size_t>(p)); | ||||||
|   return reinterpret_cast<T *>(address); |   return reinterpret_cast<T*>(address); | ||||||
| } | } | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
| template <typename TReader, typename TStringStorage> | template <typename TReader, typename TStringStorage> | ||||||
| class MsgPackDeserializer { | class MsgPackDeserializer { | ||||||
|  public: |  public: | ||||||
|   MsgPackDeserializer(MemoryPool *pool, TReader reader, |   MsgPackDeserializer(MemoryPool* pool, TReader reader, | ||||||
|                       TStringStorage stringStorage) |                       TStringStorage stringStorage) | ||||||
|       : _pool(pool), |       : _pool(pool), | ||||||
|         _reader(reader), |         _reader(reader), | ||||||
| @@ -24,7 +24,7 @@ class MsgPackDeserializer { | |||||||
|         _foundSomething(false) {} |         _foundSomething(false) {} | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError parse(VariantData &variant, TFilter filter, |   DeserializationError parse(VariantData& variant, TFilter filter, | ||||||
|                              NestingLimit nestingLimit) { |                              NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     err = parseVariant(&variant, filter, nestingLimit); |     err = parseVariant(&variant, filter, nestingLimit); | ||||||
| @@ -33,7 +33,7 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code parseVariant(VariantData *variant, TFilter filter, |   DeserializationError::Code parseVariant(VariantData* variant, TFilter filter, | ||||||
|                                           NestingLimit nestingLimit) { |                                           NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
| @@ -222,7 +222,7 @@ class MsgPackDeserializer { | |||||||
|     return DeserializationError::Ok; |     return DeserializationError::Ok; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code readByte(uint8_t &value) { |   DeserializationError::Code readByte(uint8_t& value) { | ||||||
|     int c = _reader.read(); |     int c = _reader.read(); | ||||||
|     if (c < 0) |     if (c < 0) | ||||||
|       return DeserializationError::IncompleteInput; |       return DeserializationError::IncompleteInput; | ||||||
| @@ -230,15 +230,15 @@ class MsgPackDeserializer { | |||||||
|     return DeserializationError::Ok; |     return DeserializationError::Ok; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code readBytes(uint8_t *p, size_t n) { |   DeserializationError::Code readBytes(uint8_t* p, size_t n) { | ||||||
|     if (_reader.readBytes(reinterpret_cast<char *>(p), n) == n) |     if (_reader.readBytes(reinterpret_cast<char*>(p), n) == n) | ||||||
|       return DeserializationError::Ok; |       return DeserializationError::Ok; | ||||||
|     return DeserializationError::IncompleteInput; |     return DeserializationError::IncompleteInput; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   DeserializationError::Code readBytes(T &value) { |   DeserializationError::Code readBytes(T& value) { | ||||||
|     return readBytes(reinterpret_cast<uint8_t *>(&value), sizeof(value)); |     return readBytes(reinterpret_cast<uint8_t*>(&value), sizeof(value)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code skipBytes(size_t n) { |   DeserializationError::Code skipBytes(size_t n) { | ||||||
| @@ -250,7 +250,7 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   DeserializationError::Code readInteger(T &value) { |   DeserializationError::Code readInteger(T& value) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     err = readBytes(value); |     err = readBytes(value); | ||||||
| @@ -263,7 +263,7 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   DeserializationError::Code readInteger(VariantData *variant) { |   DeserializationError::Code readInteger(VariantData* variant) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     T value; |     T value; | ||||||
|  |  | ||||||
| @@ -278,7 +278,7 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   typename enable_if<sizeof(T) == 4, DeserializationError::Code>::type |   typename enable_if<sizeof(T) == 4, DeserializationError::Code>::type | ||||||
|   readFloat(VariantData *variant) { |   readFloat(VariantData* variant) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     T value; |     T value; | ||||||
|  |  | ||||||
| @@ -294,7 +294,7 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   typename enable_if<sizeof(T) == 8, DeserializationError::Code>::type |   typename enable_if<sizeof(T) == 8, DeserializationError::Code>::type | ||||||
|   readDouble(VariantData *variant) { |   readDouble(VariantData* variant) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     T value; |     T value; | ||||||
|  |  | ||||||
| @@ -310,11 +310,11 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   typename enable_if<sizeof(T) == 4, DeserializationError::Code>::type |   typename enable_if<sizeof(T) == 4, DeserializationError::Code>::type | ||||||
|   readDouble(VariantData *variant) { |   readDouble(VariantData* variant) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     uint8_t i[8];  // input is 8 bytes |     uint8_t i[8];  // input is 8 bytes | ||||||
|     T value;       // output is 4 bytes |     T value;       // output is 4 bytes | ||||||
|     uint8_t *o = reinterpret_cast<uint8_t *>(&value); |     uint8_t* o = reinterpret_cast<uint8_t*>(&value); | ||||||
|  |  | ||||||
|     err = readBytes(i, 8); |     err = readBytes(i, 8); | ||||||
|     if (err) |     if (err) | ||||||
| @@ -328,7 +328,7 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   DeserializationError::Code readString(VariantData *variant) { |   DeserializationError::Code readString(VariantData* variant) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     T size; |     T size; | ||||||
|  |  | ||||||
| @@ -363,7 +363,7 @@ class MsgPackDeserializer { | |||||||
|     return skipBytes(size); |     return skipBytes(size); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   DeserializationError::Code readString(VariantData *variant, size_t n) { |   DeserializationError::Code readString(VariantData* variant, size_t n) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|  |  | ||||||
|     err = readString(n); |     err = readString(n); | ||||||
| @@ -395,7 +395,7 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TSize, typename TFilter> |   template <typename TSize, typename TFilter> | ||||||
|   DeserializationError::Code readArray(VariantData *variant, TFilter filter, |   DeserializationError::Code readArray(VariantData* variant, TFilter filter, | ||||||
|                                        NestingLimit nestingLimit) { |                                        NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     TSize size; |     TSize size; | ||||||
| @@ -408,7 +408,7 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code readArray(VariantData *variant, size_t n, |   DeserializationError::Code readArray(VariantData* variant, size_t n, | ||||||
|                                        TFilter filter, |                                        TFilter filter, | ||||||
|                                        NestingLimit nestingLimit) { |                                        NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
| @@ -418,12 +418,12 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|     bool allowArray = filter.allowArray(); |     bool allowArray = filter.allowArray(); | ||||||
|  |  | ||||||
|     CollectionData *array = allowArray ? &variant->toArray() : 0; |     CollectionData* array = allowArray ? &variant->toArray() : 0; | ||||||
|  |  | ||||||
|     TFilter memberFilter = filter[0U]; |     TFilter memberFilter = filter[0U]; | ||||||
|  |  | ||||||
|     for (; n; --n) { |     for (; n; --n) { | ||||||
|       VariantData *value; |       VariantData* value; | ||||||
|  |  | ||||||
|       if (memberFilter.allow()) { |       if (memberFilter.allow()) { | ||||||
|         value = array->addElement(_pool); |         value = array->addElement(_pool); | ||||||
| @@ -442,7 +442,7 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TSize, typename TFilter> |   template <typename TSize, typename TFilter> | ||||||
|   DeserializationError::Code readObject(VariantData *variant, TFilter filter, |   DeserializationError::Code readObject(VariantData* variant, TFilter filter, | ||||||
|                                         NestingLimit nestingLimit) { |                                         NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
|     TSize size; |     TSize size; | ||||||
| @@ -455,7 +455,7 @@ class MsgPackDeserializer { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TFilter> |   template <typename TFilter> | ||||||
|   DeserializationError::Code readObject(VariantData *variant, size_t n, |   DeserializationError::Code readObject(VariantData* variant, size_t n, | ||||||
|                                         TFilter filter, |                                         TFilter filter, | ||||||
|                                         NestingLimit nestingLimit) { |                                         NestingLimit nestingLimit) { | ||||||
|     DeserializationError::Code err; |     DeserializationError::Code err; | ||||||
| @@ -463,7 +463,7 @@ class MsgPackDeserializer { | |||||||
|     if (nestingLimit.reached()) |     if (nestingLimit.reached()) | ||||||
|       return DeserializationError::TooDeep; |       return DeserializationError::TooDeep; | ||||||
|  |  | ||||||
|     CollectionData *object = filter.allowObject() ? &variant->toObject() : 0; |     CollectionData* object = filter.allowObject() ? &variant->toObject() : 0; | ||||||
|  |  | ||||||
|     for (; n; --n) { |     for (; n; --n) { | ||||||
|       err = readKey(); |       err = readKey(); | ||||||
| @@ -472,7 +472,7 @@ class MsgPackDeserializer { | |||||||
|  |  | ||||||
|       String key = _stringStorage.str(); |       String key = _stringStorage.str(); | ||||||
|       TFilter memberFilter = filter[key.c_str()]; |       TFilter memberFilter = filter[key.c_str()]; | ||||||
|       VariantData *member; |       VariantData* member; | ||||||
|  |  | ||||||
|       if (memberFilter.allow()) { |       if (memberFilter.allow()) { | ||||||
|         ARDUINOJSON_ASSERT(object); |         ARDUINOJSON_ASSERT(object); | ||||||
| @@ -481,7 +481,7 @@ class MsgPackDeserializer { | |||||||
|         // This MUST be done before adding the slot. |         // This MUST be done before adding the slot. | ||||||
|         key = _stringStorage.save(); |         key = _stringStorage.save(); | ||||||
|  |  | ||||||
|         VariantSlot *slot = object->addSlot(_pool); |         VariantSlot* slot = object->addSlot(_pool); | ||||||
|         if (!slot) |         if (!slot) | ||||||
|           return DeserializationError::NoMemory; |           return DeserializationError::NoMemory; | ||||||
|  |  | ||||||
| @@ -538,7 +538,7 @@ class MsgPackDeserializer { | |||||||
|     return skipBytes(size + 1U); |     return skipBytes(size + 1U); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   MemoryPool *_pool; |   MemoryPool* _pool; | ||||||
|   TReader _reader; |   TReader _reader; | ||||||
|   TStringStorage _stringStorage; |   TStringStorage _stringStorage; | ||||||
|   bool _foundSomething; |   bool _foundSomething; | ||||||
| @@ -550,7 +550,7 @@ class MsgPackDeserializer { | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument &doc, const TString &input, |     JsonDocument& doc, const TString& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| @@ -558,13 +558,13 @@ DeserializationError deserializeMsgPack( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument &doc, const TString &input, Filter filter, |     JsonDocument& doc, const TString& input, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TString> | template <typename TString> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument &doc, const TString &input, | DeserializationError deserializeMsgPack(JsonDocument& doc, const TString& input, | ||||||
|                                         NestingLimit nestingLimit, |                                         NestingLimit nestingLimit, | ||||||
|                                         Filter filter) { |                                         Filter filter) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| @@ -576,7 +576,7 @@ DeserializationError deserializeMsgPack(JsonDocument &doc, const TString &input, | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument &doc, TStream &input, |     JsonDocument& doc, TStream& input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| @@ -584,13 +584,13 @@ DeserializationError deserializeMsgPack( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument &doc, TStream &input, Filter filter, |     JsonDocument& doc, TStream& input, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TStream> | template <typename TStream> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument &doc, TStream &input, | DeserializationError deserializeMsgPack(JsonDocument& doc, TStream& input, | ||||||
|                                         NestingLimit nestingLimit, |                                         NestingLimit nestingLimit, | ||||||
|                                         Filter filter) { |                                         Filter filter) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| @@ -602,7 +602,7 @@ DeserializationError deserializeMsgPack(JsonDocument &doc, TStream &input, | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument &doc, TChar *input, |     JsonDocument& doc, TChar* input, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| @@ -610,13 +610,13 @@ DeserializationError deserializeMsgPack( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack( | DeserializationError deserializeMsgPack( | ||||||
|     JsonDocument &doc, TChar *input, Filter filter, |     JsonDocument& doc, TChar* input, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument &doc, TChar *input, | DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | ||||||
|                                         NestingLimit nestingLimit, |                                         NestingLimit nestingLimit, | ||||||
|                                         Filter filter) { |                                         Filter filter) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); |   return deserialize<MsgPackDeserializer>(doc, input, nestingLimit, filter); | ||||||
| @@ -628,7 +628,7 @@ DeserializationError deserializeMsgPack(JsonDocument &doc, TChar *input, | |||||||
| // ... = NestingLimit | // ... = NestingLimit | ||||||
| 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()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                           AllowAllFilter()); |                                           AllowAllFilter()); | ||||||
| @@ -636,14 +636,14 @@ DeserializationError deserializeMsgPack( | |||||||
| // ... = Filter, NestingLimit | // ... = Filter, NestingLimit | ||||||
| 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, Filter filter, | ||||||
|     NestingLimit nestingLimit = NestingLimit()) { |     NestingLimit nestingLimit = NestingLimit()) { | ||||||
|   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, |   return deserialize<MsgPackDeserializer>(doc, input, inputSize, nestingLimit, | ||||||
|                                           filter); |                                           filter); | ||||||
| } | } | ||||||
| // ... = NestingLimit, Filter | // ... = NestingLimit, Filter | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| DeserializationError deserializeMsgPack(JsonDocument &doc, TChar *input, | DeserializationError deserializeMsgPack(JsonDocument& doc, TChar* input, | ||||||
|                                         size_t inputSize, |                                         size_t inputSize, | ||||||
|                                         NestingLimit nestingLimit, |                                         NestingLimit nestingLimit, | ||||||
|                                         Filter filter) { |                                         Filter filter) { | ||||||
|   | |||||||
| @@ -9,38 +9,38 @@ | |||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_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) { | ||||||
|   uint8_t t(a); |   uint8_t t(a); | ||||||
|   a = b; |   a = b; | ||||||
|   b = t; |   b = t; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline void fixEndianess(uint8_t *p, integral_constant<size_t, 8>) { | inline void fixEndianess(uint8_t* p, integral_constant<size_t, 8>) { | ||||||
|   swapBytes(p[0], p[7]); |   swapBytes(p[0], p[7]); | ||||||
|   swapBytes(p[1], p[6]); |   swapBytes(p[1], p[6]); | ||||||
|   swapBytes(p[2], p[5]); |   swapBytes(p[2], p[5]); | ||||||
|   swapBytes(p[3], p[4]); |   swapBytes(p[3], p[4]); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline void fixEndianess(uint8_t *p, integral_constant<size_t, 4>) { | inline void fixEndianess(uint8_t* p, integral_constant<size_t, 4>) { | ||||||
|   swapBytes(p[0], p[3]); |   swapBytes(p[0], p[3]); | ||||||
|   swapBytes(p[1], p[2]); |   swapBytes(p[1], p[2]); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline void fixEndianess(uint8_t *p, integral_constant<size_t, 2>) { | inline void fixEndianess(uint8_t* p, integral_constant<size_t, 2>) { | ||||||
|   swapBytes(p[0], p[1]); |   swapBytes(p[0], p[1]); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline void fixEndianess(uint8_t *, integral_constant<size_t, 1>) {} | inline void fixEndianess(uint8_t*, integral_constant<size_t, 1>) {} | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| inline void fixEndianess(T &value) { | inline void fixEndianess(T& value) { | ||||||
|   fixEndianess(reinterpret_cast<uint8_t *>(&value), |   fixEndianess(reinterpret_cast<uint8_t*>(&value), | ||||||
|                integral_constant<size_t, sizeof(T)>()); |                integral_constant<size_t, sizeof(T)>()); | ||||||
| } | } | ||||||
| #else | #else | ||||||
| template <typename T> | template <typename T> | ||||||
| inline void fixEndianess(T &) {} | inline void fixEndianess(T&) {} | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ enum CompareResult { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| CompareResult arithmeticCompare(const T &lhs, const T &rhs) { | CompareResult arithmeticCompare(const T& lhs, const T& rhs) { | ||||||
|   if (lhs < rhs) |   if (lhs < rhs) | ||||||
|     return COMPARE_RESULT_LESS; |     return COMPARE_RESULT_LESS; | ||||||
|   else if (lhs > rhs) |   else if (lhs > rhs) | ||||||
| @@ -31,38 +31,38 @@ CompareResult arithmeticCompare(const T &lhs, const T &rhs) { | |||||||
|  |  | ||||||
| template <typename T1, typename T2> | template <typename T1, typename T2> | ||||||
| CompareResult arithmeticCompare( | CompareResult arithmeticCompare( | ||||||
|     const T1 &lhs, const T2 &rhs, |     const T1& lhs, const T2& rhs, | ||||||
|     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && |     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && | ||||||
|                            sizeof(T1) < sizeof(T2), |                            sizeof(T1) < sizeof(T2), | ||||||
|                        int  // Using int instead of void to avoid C2572 on |                        int  // Using int instead of void to avoid C2572 on | ||||||
|                             // Visual Studio 2012, 2013, and 2015 |                             // Visual Studio 2012, 2013, and 2015 | ||||||
|                        >::type * = 0) { |                        >::type* = 0) { | ||||||
|   return arithmeticCompare<T2>(static_cast<T2>(lhs), rhs); |   return arithmeticCompare<T2>(static_cast<T2>(lhs), rhs); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T1, typename T2> | template <typename T1, typename T2> | ||||||
| CompareResult arithmeticCompare( | CompareResult arithmeticCompare( | ||||||
|     const T1 &lhs, const T2 &rhs, |     const T1& lhs, const T2& rhs, | ||||||
|     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && |     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && | ||||||
|                        sizeof(T2) < sizeof(T1)>::type * = 0) { |                        sizeof(T2) < sizeof(T1)>::type* = 0) { | ||||||
|   return arithmeticCompare<T1>(lhs, static_cast<T1>(rhs)); |   return arithmeticCompare<T1>(lhs, static_cast<T1>(rhs)); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T1, typename T2> | template <typename T1, typename T2> | ||||||
| CompareResult arithmeticCompare( | CompareResult arithmeticCompare( | ||||||
|     const T1 &lhs, const T2 &rhs, |     const T1& lhs, const T2& rhs, | ||||||
|     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && |     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && | ||||||
|                        is_signed<T1>::value == is_signed<T2>::value && |                        is_signed<T1>::value == is_signed<T2>::value && | ||||||
|                        sizeof(T2) == sizeof(T1)>::type * = 0) { |                        sizeof(T2) == sizeof(T1)>::type* = 0) { | ||||||
|   return arithmeticCompare<T1>(lhs, static_cast<T1>(rhs)); |   return arithmeticCompare<T1>(lhs, static_cast<T1>(rhs)); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T1, typename T2> | template <typename T1, typename T2> | ||||||
| CompareResult arithmeticCompare( | CompareResult arithmeticCompare( | ||||||
|     const T1 &lhs, const T2 &rhs, |     const T1& lhs, const T2& rhs, | ||||||
|     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && |     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && | ||||||
|                        is_unsigned<T1>::value && is_signed<T2>::value && |                        is_unsigned<T1>::value && is_signed<T2>::value && | ||||||
|                        sizeof(T2) == sizeof(T1)>::type * = 0) { |                        sizeof(T2) == sizeof(T1)>::type* = 0) { | ||||||
|   if (rhs < 0) |   if (rhs < 0) | ||||||
|     return COMPARE_RESULT_GREATER; |     return COMPARE_RESULT_GREATER; | ||||||
|   return arithmeticCompare<T1>(lhs, static_cast<T1>(rhs)); |   return arithmeticCompare<T1>(lhs, static_cast<T1>(rhs)); | ||||||
| @@ -70,10 +70,10 @@ CompareResult arithmeticCompare( | |||||||
|  |  | ||||||
| template <typename T1, typename T2> | template <typename T1, typename T2> | ||||||
| CompareResult arithmeticCompare( | CompareResult arithmeticCompare( | ||||||
|     const T1 &lhs, const T2 &rhs, |     const T1& lhs, const T2& rhs, | ||||||
|     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && |     typename enable_if<is_integral<T1>::value && is_integral<T2>::value && | ||||||
|                        is_signed<T1>::value && is_unsigned<T2>::value && |                        is_signed<T1>::value && is_unsigned<T2>::value && | ||||||
|                        sizeof(T2) == sizeof(T1)>::type * = 0) { |                        sizeof(T2) == sizeof(T1)>::type* = 0) { | ||||||
|   if (lhs < 0) |   if (lhs < 0) | ||||||
|     return COMPARE_RESULT_LESS; |     return COMPARE_RESULT_LESS; | ||||||
|   return arithmeticCompare<T2>(static_cast<T2>(lhs), rhs); |   return arithmeticCompare<T2>(static_cast<T2>(lhs), rhs); | ||||||
| @@ -81,23 +81,23 @@ CompareResult arithmeticCompare( | |||||||
|  |  | ||||||
| template <typename T1, typename T2> | template <typename T1, typename T2> | ||||||
| CompareResult arithmeticCompare( | CompareResult arithmeticCompare( | ||||||
|     const T1 &lhs, const T2 &rhs, |     const T1& lhs, const T2& rhs, | ||||||
|     typename enable_if<is_floating_point<T1>::value || |     typename enable_if<is_floating_point<T1>::value || | ||||||
|                        is_floating_point<T2>::value>::type * = 0) { |                        is_floating_point<T2>::value>::type* = 0) { | ||||||
|   return arithmeticCompare<double>(static_cast<double>(lhs), |   return arithmeticCompare<double>(static_cast<double>(lhs), | ||||||
|                                    static_cast<double>(rhs)); |                                    static_cast<double>(rhs)); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T2> | template <typename T2> | ||||||
| CompareResult arithmeticCompareNegateLeft( | CompareResult arithmeticCompareNegateLeft( | ||||||
|     UInt, const T2 &, typename enable_if<is_unsigned<T2>::value>::type * = 0) { |     UInt, const T2&, typename enable_if<is_unsigned<T2>::value>::type* = 0) { | ||||||
|   return COMPARE_RESULT_LESS; |   return COMPARE_RESULT_LESS; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T2> | template <typename T2> | ||||||
| CompareResult arithmeticCompareNegateLeft( | CompareResult arithmeticCompareNegateLeft( | ||||||
|     UInt lhs, const T2 &rhs, |     UInt lhs, const T2& rhs, | ||||||
|     typename enable_if<is_signed<T2>::value>::type * = 0) { |     typename enable_if<is_signed<T2>::value>::type* = 0) { | ||||||
|   if (rhs > 0) |   if (rhs > 0) | ||||||
|     return COMPARE_RESULT_LESS; |     return COMPARE_RESULT_LESS; | ||||||
|   return arithmeticCompare(-rhs, static_cast<T2>(lhs)); |   return arithmeticCompare(-rhs, static_cast<T2>(lhs)); | ||||||
| @@ -105,14 +105,14 @@ CompareResult arithmeticCompareNegateLeft( | |||||||
|  |  | ||||||
| template <typename T1> | template <typename T1> | ||||||
| CompareResult arithmeticCompareNegateRight( | CompareResult arithmeticCompareNegateRight( | ||||||
|     const T1 &, UInt, typename enable_if<is_unsigned<T1>::value>::type * = 0) { |     const T1&, UInt, typename enable_if<is_unsigned<T1>::value>::type* = 0) { | ||||||
|   return COMPARE_RESULT_GREATER; |   return COMPARE_RESULT_GREATER; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename T1> | template <typename T1> | ||||||
| CompareResult arithmeticCompareNegateRight( | CompareResult arithmeticCompareNegateRight( | ||||||
|     const T1 &lhs, UInt rhs, |     const T1& lhs, UInt rhs, | ||||||
|     typename enable_if<is_signed<T1>::value>::type * = 0) { |     typename enable_if<is_signed<T1>::value>::type* = 0) { | ||||||
|   if (lhs > 0) |   if (lhs > 0) | ||||||
|     return COMPARE_RESULT_GREATER; |     return COMPARE_RESULT_GREATER; | ||||||
|   return arithmeticCompare(static_cast<T1>(rhs), -lhs); |   return arithmeticCompare(static_cast<T1>(rhs), -lhs); | ||||||
|   | |||||||
| @@ -31,21 +31,21 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   FORCE_INLINE MemberProxy(TObject variant, TStringRef key) |   FORCE_INLINE MemberProxy(TObject variant, TStringRef key) | ||||||
|       : _object(variant), _key(key) {} |       : _object(variant), _key(key) {} | ||||||
|  |  | ||||||
|   FORCE_INLINE MemberProxy(const MemberProxy &src) |   FORCE_INLINE MemberProxy(const MemberProxy& src) | ||||||
|       : _object(src._object), _key(src._key) {} |       : _object(src._object), _key(src._key) {} | ||||||
|  |  | ||||||
|   FORCE_INLINE operator VariantConstRef() const { |   FORCE_INLINE operator VariantConstRef() const { | ||||||
|     return getUpstreamMemberConst(); |     return getUpstreamMemberConst(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE this_type &operator=(const this_type &src) { |   FORCE_INLINE this_type& operator=(const this_type& src) { | ||||||
|     getOrAddUpstreamMember().set(src); |     getOrAddUpstreamMember().set(src); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TValue> |   template <typename TValue> | ||||||
|   FORCE_INLINE typename enable_if<!is_array<TValue>::value, this_type &>::type |   FORCE_INLINE typename enable_if<!is_array<TValue>::value, this_type&>::type | ||||||
|   operator=(const TValue &src) { |   operator=(const TValue& src) { | ||||||
|     getOrAddUpstreamMember().set(src); |     getOrAddUpstreamMember().set(src); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
| @@ -54,7 +54,7 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   // operator=(const char*) |   // operator=(const char*) | ||||||
|   // operator=(const __FlashStringHelper*) |   // operator=(const __FlashStringHelper*) | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE this_type &operator=(TChar *src) { |   FORCE_INLINE this_type& operator=(TChar* src) { | ||||||
|     getOrAddUpstreamMember().set(src); |     getOrAddUpstreamMember().set(src); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
| @@ -68,7 +68,7 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE typename enable_if<!is_same<T, char *>::value && |   FORCE_INLINE typename enable_if<!is_same<T, char*>::value && | ||||||
|                                       !ConverterNeedsWriteableRef<T>::value, |                                       !ConverterNeedsWriteableRef<T>::value, | ||||||
|                                   T>::type |                                   T>::type | ||||||
|   as() const { |   as() const { | ||||||
| @@ -82,10 +82,10 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE typename enable_if<is_same<T, char *>::value, const char *>::type |   FORCE_INLINE typename enable_if<is_same<T, char*>::value, const char*>::type | ||||||
|   ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()") |   ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()") | ||||||
|       as() const { |       as() const { | ||||||
|     return as<const char *>(); |     return as<const char*>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
| @@ -122,15 +122,15 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   // remove(const char*) const |   // remove(const char*) const | ||||||
|   // remove(const __FlashStringHelper*) const |   // remove(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar *>::value>::type remove( |   FORCE_INLINE typename enable_if<IsString<TChar*>::value>::type remove( | ||||||
|       TChar *key) const { |       TChar* key) const { | ||||||
|     getUpstreamMember().remove(key); |     getUpstreamMember().remove(key); | ||||||
|   } |   } | ||||||
|   // remove(const std::string&) const |   // remove(const std::string&) const | ||||||
|   // remove(const String&) const |   // remove(const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove( |   FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove( | ||||||
|       const TString &key) const { |       const TString& key) const { | ||||||
|     getUpstreamMember().remove(key); |     getUpstreamMember().remove(key); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -144,7 +144,7 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TValue> |   template <typename TValue> | ||||||
|   FORCE_INLINE bool set(const TValue &value) { |   FORCE_INLINE bool set(const TValue& value) { | ||||||
|     return getOrAddUpstreamMember().set(value); |     return getOrAddUpstreamMember().set(value); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -152,7 +152,7 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   // set(const char*) const |   // set(const char*) const | ||||||
|   // set(const __FlashStringHelper*) const |   // set(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE bool set(TChar *value) { |   FORCE_INLINE bool set(TChar* value) { | ||||||
|     return getOrAddUpstreamMember().set(value); |     return getOrAddUpstreamMember().set(value); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -163,16 +163,16 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|   using ArrayShortcuts<MemberProxy<TObject, TStringRef> >::add; |   using ArrayShortcuts<MemberProxy<TObject, TStringRef> >::add; | ||||||
|  |  | ||||||
|  protected: |  protected: | ||||||
|   FORCE_INLINE MemoryPool *getPool() const { |   FORCE_INLINE MemoryPool* getPool() const { | ||||||
|     return VariantAttorney::getPool(_object); |     return VariantAttorney::getPool(_object); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantData *getData() const { |   FORCE_INLINE VariantData* getData() const { | ||||||
|     return variantGetMember(VariantAttorney::getData(_object), |     return variantGetMember(VariantAttorney::getData(_object), | ||||||
|                             adaptString(_key)); |                             adaptString(_key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantData *getOrCreateData() const { |   FORCE_INLINE VariantData* getOrCreateData() const { | ||||||
|     return variantGetOrAddMember(VariantAttorney::getOrCreateData(_object), |     return variantGetOrAddMember(VariantAttorney::getOrCreateData(_object), | ||||||
|                                  _key, VariantAttorney::getPool(_object)); |                                  _key, VariantAttorney::getPool(_object)); | ||||||
|   } |   } | ||||||
| @@ -190,7 +190,7 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|     return VariantRef(getPool(), getOrCreateData()); |     return VariantRef(getPool(), getOrCreateData()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   friend void convertToJson(const this_type &src, VariantRef dst) { |   friend void convertToJson(const this_type& src, VariantRef dst) { | ||||||
|     dst.set(src.getUpstreamMemberConst()); |     dst.set(src.getUpstreamMemberConst()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -9,7 +9,7 @@ | |||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
|  |  | ||||||
| template <typename TAdaptedString> | template <typename TAdaptedString> | ||||||
| inline VariantData *objectGetMember(const CollectionData *obj, | inline VariantData* objectGetMember(const CollectionData* obj, | ||||||
|                                     TAdaptedString key) { |                                     TAdaptedString key) { | ||||||
|   if (!obj) |   if (!obj) | ||||||
|     return 0; |     return 0; | ||||||
| @@ -17,7 +17,7 @@ inline VariantData *objectGetMember(const CollectionData *obj, | |||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TAdaptedString> | template <typename TAdaptedString> | ||||||
| void objectRemove(CollectionData *obj, TAdaptedString key) { | void objectRemove(CollectionData* obj, TAdaptedString key) { | ||||||
|   if (!obj) |   if (!obj) | ||||||
|     return; |     return; | ||||||
|   obj->removeMember(key); |   obj->removeMember(key); | ||||||
|   | |||||||
| @@ -11,13 +11,13 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
|  |  | ||||||
| class PairPtr { | class PairPtr { | ||||||
|  public: |  public: | ||||||
|   PairPtr(MemoryPool *pool, VariantSlot *slot) : _pair(pool, slot) {} |   PairPtr(MemoryPool* pool, VariantSlot* slot) : _pair(pool, slot) {} | ||||||
|  |  | ||||||
|   const Pair *operator->() const { |   const Pair* operator->() const { | ||||||
|     return &_pair; |     return &_pair; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const Pair &operator*() const { |   const Pair& operator*() const { | ||||||
|     return _pair; |     return _pair; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -29,7 +29,7 @@ class ObjectIterator { | |||||||
|  public: |  public: | ||||||
|   ObjectIterator() : _slot(0) {} |   ObjectIterator() : _slot(0) {} | ||||||
|  |  | ||||||
|   explicit ObjectIterator(MemoryPool *pool, VariantSlot *slot) |   explicit ObjectIterator(MemoryPool* pool, VariantSlot* slot) | ||||||
|       : _pool(pool), _slot(slot) {} |       : _pool(pool), _slot(slot) {} | ||||||
|  |  | ||||||
|   Pair operator*() const { |   Pair operator*() const { | ||||||
| @@ -39,42 +39,42 @@ class ObjectIterator { | |||||||
|     return PairPtr(_pool, _slot); |     return PairPtr(_pool, _slot); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator==(const ObjectIterator &other) const { |   bool operator==(const ObjectIterator& other) const { | ||||||
|     return _slot == other._slot; |     return _slot == other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator!=(const ObjectIterator &other) const { |   bool operator!=(const ObjectIterator& other) const { | ||||||
|     return _slot != other._slot; |     return _slot != other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ObjectIterator &operator++() { |   ObjectIterator& operator++() { | ||||||
|     _slot = _slot->next(); |     _slot = _slot->next(); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ObjectIterator &operator+=(size_t distance) { |   ObjectIterator& operator+=(size_t distance) { | ||||||
|     _slot = _slot->next(distance); |     _slot = _slot->next(distance); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantSlot *internal() { |   VariantSlot* internal() { | ||||||
|     return _slot; |     return _slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool *_pool; |   MemoryPool* _pool; | ||||||
|   VariantSlot *_slot; |   VariantSlot* _slot; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class PairConstPtr { | class PairConstPtr { | ||||||
|  public: |  public: | ||||||
|   PairConstPtr(const VariantSlot *slot) : _pair(slot) {} |   PairConstPtr(const VariantSlot* slot) : _pair(slot) {} | ||||||
|  |  | ||||||
|   const PairConst *operator->() const { |   const PairConst* operator->() const { | ||||||
|     return &_pair; |     return &_pair; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const PairConst &operator*() const { |   const PairConst& operator*() const { | ||||||
|     return _pair; |     return _pair; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -86,7 +86,7 @@ class ObjectConstIterator { | |||||||
|  public: |  public: | ||||||
|   ObjectConstIterator() : _slot(0) {} |   ObjectConstIterator() : _slot(0) {} | ||||||
|  |  | ||||||
|   explicit ObjectConstIterator(const VariantSlot *slot) : _slot(slot) {} |   explicit ObjectConstIterator(const VariantSlot* slot) : _slot(slot) {} | ||||||
|  |  | ||||||
|   PairConst operator*() const { |   PairConst operator*() const { | ||||||
|     return PairConst(_slot); |     return PairConst(_slot); | ||||||
| @@ -95,29 +95,29 @@ class ObjectConstIterator { | |||||||
|     return PairConstPtr(_slot); |     return PairConstPtr(_slot); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator==(const ObjectConstIterator &other) const { |   bool operator==(const ObjectConstIterator& other) const { | ||||||
|     return _slot == other._slot; |     return _slot == other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool operator!=(const ObjectConstIterator &other) const { |   bool operator!=(const ObjectConstIterator& other) const { | ||||||
|     return _slot != other._slot; |     return _slot != other._slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ObjectConstIterator &operator++() { |   ObjectConstIterator& operator++() { | ||||||
|     _slot = _slot->next(); |     _slot = _slot->next(); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ObjectConstIterator &operator+=(size_t distance) { |   ObjectConstIterator& operator+=(size_t distance) { | ||||||
|     _slot = _slot->next(distance); |     _slot = _slot->next(distance); | ||||||
|     return *this; |     return *this; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const VariantSlot *internal() { |   const VariantSlot* internal() { | ||||||
|     return _slot; |     return _slot; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const VariantSlot *_slot; |   const VariantSlot* _slot; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -19,55 +19,55 @@ class ObjectShortcuts { | |||||||
|   // containsKey(const String&) const |   // containsKey(const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type |   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type | ||||||
|   containsKey(const TString &key) const; |   containsKey(const TString& key) const; | ||||||
|  |  | ||||||
|   // containsKey(char*) const |   // containsKey(char*) const | ||||||
|   // containsKey(const char*) const |   // containsKey(const char*) const | ||||||
|   // containsKey(const __FlashStringHelper*) const |   // containsKey(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar *>::value, bool>::type |   FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type | ||||||
|   containsKey(TChar *key) const; |   containsKey(TChar* key) const; | ||||||
|  |  | ||||||
|   // operator[](const std::string&) const |   // operator[](const std::string&) const | ||||||
|   // operator[](const String&) const |   // operator[](const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, |   FORCE_INLINE typename enable_if<IsString<TString>::value, | ||||||
|                                   MemberProxy<TObject, TString> >::type |                                   MemberProxy<TObject, TString> >::type | ||||||
|   operator[](const TString &key) const; |   operator[](const TString& key) const; | ||||||
|  |  | ||||||
|   // operator[](char*) const |   // operator[](char*) const | ||||||
|   // operator[](const char*) const |   // operator[](const char*) const | ||||||
|   // operator[](const __FlashStringHelper*) const |   // operator[](const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar *>::value, |   FORCE_INLINE typename enable_if<IsString<TChar*>::value, | ||||||
|                                   MemberProxy<TObject, TChar *> >::type |                                   MemberProxy<TObject, TChar*> >::type | ||||||
|   operator[](TChar *key) const; |   operator[](TChar* key) const; | ||||||
|  |  | ||||||
|   // createNestedArray(const std::string&) const |   // createNestedArray(const std::string&) const | ||||||
|   // createNestedArray(const String&) const |   // createNestedArray(const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE ArrayRef createNestedArray(const TString &key) const; |   FORCE_INLINE ArrayRef createNestedArray(const TString& key) const; | ||||||
|  |  | ||||||
|   // createNestedArray(char*) const |   // createNestedArray(char*) const | ||||||
|   // createNestedArray(const char*) const |   // createNestedArray(const char*) const | ||||||
|   // createNestedArray(const __FlashStringHelper*) const |   // createNestedArray(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE ArrayRef createNestedArray(TChar *key) const; |   FORCE_INLINE ArrayRef createNestedArray(TChar* key) const; | ||||||
|  |  | ||||||
|   // createNestedObject(const std::string&) const |   // createNestedObject(const std::string&) const | ||||||
|   // createNestedObject(const String&) const |   // createNestedObject(const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   ObjectRef createNestedObject(const TString &key) const; |   ObjectRef createNestedObject(const TString& key) const; | ||||||
|  |  | ||||||
|   // createNestedObject(char*) const |   // createNestedObject(char*) const | ||||||
|   // createNestedObject(const char*) const |   // createNestedObject(const char*) const | ||||||
|   // createNestedObject(const __FlashStringHelper*) const |   // createNestedObject(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   ObjectRef createNestedObject(TChar *key) const; |   ObjectRef createNestedObject(TChar* key) const; | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   const TObject *impl() const { |   const TObject* impl() const { | ||||||
|     return static_cast<const TObject *>(this); |     return static_cast<const TObject*>(this); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -16,11 +16,11 @@ class is_base_of { | |||||||
|   typedef char Yes[1]; |   typedef char Yes[1]; | ||||||
|   typedef char No[2]; |   typedef char No[2]; | ||||||
|  |  | ||||||
|   static Yes &probe(const TBase *); |   static Yes& probe(const TBase*); | ||||||
|   static No &probe(...); |   static No& probe(...); | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   static const bool value = |   static const bool value = | ||||||
|       sizeof(probe(reinterpret_cast<TDerived *>(0))) == sizeof(Yes); |       sizeof(probe(reinterpret_cast<TDerived*>(0))) == sizeof(Yes); | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -15,9 +15,9 @@ struct is_class { | |||||||
|   typedef char No[2]; |   typedef char No[2]; | ||||||
|  |  | ||||||
|   template <typename U> |   template <typename U> | ||||||
|   static Yes &probe(void (U::*)(void)); |   static Yes& probe(void (U::*)(void)); | ||||||
|   template <typename> |   template <typename> | ||||||
|   static No &probe(...); |   static No& probe(...); | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   static const bool value = sizeof(probe<T>(0)) == sizeof(Yes); |   static const bool value = sizeof(probe<T>(0)) == sizeof(Yes); | ||||||
|   | |||||||
| @@ -27,10 +27,10 @@ struct is_convertible { | |||||||
|   typedef char Yes[1]; |   typedef char Yes[1]; | ||||||
|   typedef char No[2]; |   typedef char No[2]; | ||||||
|  |  | ||||||
|   static Yes &probe(To); |   static Yes& probe(To); | ||||||
|   static No &probe(...); |   static No& probe(...); | ||||||
|  |  | ||||||
|   static From &_from; |   static From& _from; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   static const bool value = sizeof(probe(_from)) == sizeof(Yes); |   static const bool value = sizeof(probe(_from)) == sizeof(Yes); | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ class Writer< ::String, void> { | |||||||
|   static const size_t bufferCapacity = ARDUINOJSON_STRING_BUFFER_SIZE; |   static const size_t bufferCapacity = ARDUINOJSON_STRING_BUFFER_SIZE; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   explicit Writer(::String &str) : _destination(&str) { |   explicit Writer(::String& str) : _destination(&str) { | ||||||
|     _size = 0; |     _size = 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -29,7 +29,7 @@ class Writer< ::String, void> { | |||||||
|     return 1; |     return 1; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t write(const uint8_t *s, size_t n) { |   size_t write(const uint8_t* s, size_t n) { | ||||||
|     for (size_t i = 0; i < n; i++) { |     for (size_t i = 0; i < n; i++) { | ||||||
|       write(s[i]); |       write(s[i]); | ||||||
|     } |     } | ||||||
| @@ -45,7 +45,7 @@ class Writer< ::String, void> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   ::String *_destination; |   ::String* _destination; | ||||||
|   char _buffer[bufferCapacity]; |   char _buffer[bufferCapacity]; | ||||||
|   size_t _size; |   size_t _size; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
|  |  | ||||||
| class StaticStringWriter { | class StaticStringWriter { | ||||||
|  public: |  public: | ||||||
|   StaticStringWriter(char *buf, size_t size) : end(buf + size), p(buf) {} |   StaticStringWriter(char* buf, size_t size) : end(buf + size), p(buf) {} | ||||||
|  |  | ||||||
|   size_t write(uint8_t c) { |   size_t write(uint8_t c) { | ||||||
|     if (p >= end) |     if (p >= end) | ||||||
| @@ -19,8 +19,8 @@ class StaticStringWriter { | |||||||
|     return 1; |     return 1; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t write(const uint8_t *s, size_t n) { |   size_t write(const uint8_t* s, size_t n) { | ||||||
|     char *begin = p; |     char* begin = p; | ||||||
|     while (p < end && n > 0) { |     while (p < end && n > 0) { | ||||||
|       *p++ = static_cast<char>(*s++); |       *p++ = static_cast<char>(*s++); | ||||||
|       n--; |       n--; | ||||||
| @@ -29,7 +29,7 @@ class StaticStringWriter { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   char *end; |   char* end; | ||||||
|   char *p; |   char* p; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -22,19 +22,19 @@ template <typename TDestination> | |||||||
| class Writer<TDestination, | class Writer<TDestination, | ||||||
|              typename enable_if<is_std_string<TDestination>::value>::type> { |              typename enable_if<is_std_string<TDestination>::value>::type> { | ||||||
|  public: |  public: | ||||||
|   Writer(TDestination &str) : _str(&str) {} |   Writer(TDestination& str) : _str(&str) {} | ||||||
|  |  | ||||||
|   size_t write(uint8_t c) { |   size_t write(uint8_t c) { | ||||||
|     _str->operator+=(static_cast<char>(c)); |     _str->operator+=(static_cast<char>(c)); | ||||||
|     return 1; |     return 1; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   size_t write(const uint8_t *s, size_t n) { |   size_t write(const uint8_t* s, size_t n) { | ||||||
|     _str->append(reinterpret_cast<const char *>(s), n); |     _str->append(reinterpret_cast<const char*>(s), n); | ||||||
|     return n; |     return n; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   TDestination *_str; |   TDestination* _str; | ||||||
| }; | }; | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -16,26 +16,26 @@ size_t doSerialize(VariantConstRef source, TWriter writer) { | |||||||
| } | } | ||||||
|  |  | ||||||
| template <template <typename> class TSerializer, typename TDestination> | template <template <typename> class TSerializer, typename TDestination> | ||||||
| size_t serialize(VariantConstRef source, TDestination &destination) { | size_t serialize(VariantConstRef source, TDestination& destination) { | ||||||
|   Writer<TDestination> writer(destination); |   Writer<TDestination> writer(destination); | ||||||
|   return doSerialize<TSerializer>(source, writer); |   return doSerialize<TSerializer>(source, writer); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <template <typename> class TSerializer> | template <template <typename> class TSerializer> | ||||||
| typename enable_if<!TSerializer<StaticStringWriter>::producesText, size_t>::type | typename enable_if<!TSerializer<StaticStringWriter>::producesText, size_t>::type | ||||||
| serialize(VariantConstRef source, void *buffer, size_t bufferSize) { | serialize(VariantConstRef source, void* buffer, size_t bufferSize) { | ||||||
|   StaticStringWriter writer(reinterpret_cast<char *>(buffer), bufferSize); |   StaticStringWriter writer(reinterpret_cast<char*>(buffer), bufferSize); | ||||||
|   return doSerialize<TSerializer>(source, writer); |   return doSerialize<TSerializer>(source, writer); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <template <typename> class TSerializer> | template <template <typename> class TSerializer> | ||||||
| typename enable_if<TSerializer<StaticStringWriter>::producesText, size_t>::type | typename enable_if<TSerializer<StaticStringWriter>::producesText, size_t>::type | ||||||
| serialize(VariantConstRef source, void *buffer, size_t bufferSize) { | serialize(VariantConstRef source, void* buffer, size_t bufferSize) { | ||||||
|   StaticStringWriter writer(reinterpret_cast<char *>(buffer), bufferSize); |   StaticStringWriter writer(reinterpret_cast<char*>(buffer), bufferSize); | ||||||
|   size_t n = doSerialize<TSerializer>(source, writer); |   size_t n = doSerialize<TSerializer>(source, writer); | ||||||
|   // add null-terminator for text output (not counted in the size) |   // add null-terminator for text output (not counted in the size) | ||||||
|   if (n < bufferSize) |   if (n < bufferSize) | ||||||
|     reinterpret_cast<char *>(buffer)[n] = 0; |     reinterpret_cast<char*>(buffer)[n] = 0; | ||||||
|   return n; |   return n; | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ namespace ARDUINOJSON_NAMESPACE { | |||||||
|  |  | ||||||
| struct LinkStringStoragePolicy { | struct LinkStringStoragePolicy { | ||||||
|   template <typename TAdaptedString, typename TCallback> |   template <typename TAdaptedString, typename TCallback> | ||||||
|   bool store(TAdaptedString str, MemoryPool *, TCallback callback) { |   bool store(TAdaptedString str, MemoryPool*, TCallback callback) { | ||||||
|     String storedString(str.data(), str.size(), String::Linked); |     String storedString(str.data(), str.size(), String::Linked); | ||||||
|     callback(storedString); |     callback(storedString); | ||||||
|     return !str.isNull(); |     return !str.isNull(); | ||||||
| @@ -20,7 +20,7 @@ struct LinkStringStoragePolicy { | |||||||
|  |  | ||||||
| struct CopyStringStoragePolicy { | struct CopyStringStoragePolicy { | ||||||
|   template <typename TAdaptedString, typename TCallback> |   template <typename TAdaptedString, typename TCallback> | ||||||
|   bool store(TAdaptedString str, MemoryPool *pool, TCallback callback); |   bool store(TAdaptedString str, MemoryPool* pool, TCallback callback); | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class LinkOrCopyStringStoragePolicy : LinkStringStoragePolicy, | class LinkOrCopyStringStoragePolicy : LinkStringStoragePolicy, | ||||||
| @@ -29,7 +29,7 @@ class LinkOrCopyStringStoragePolicy : LinkStringStoragePolicy, | |||||||
|   LinkOrCopyStringStoragePolicy(bool link) : _link(link) {} |   LinkOrCopyStringStoragePolicy(bool link) : _link(link) {} | ||||||
|  |  | ||||||
|   template <typename TAdaptedString, typename TCallback> |   template <typename TAdaptedString, typename TCallback> | ||||||
|   bool store(TAdaptedString str, MemoryPool *pool, TCallback callback) { |   bool store(TAdaptedString str, MemoryPool* pool, TCallback callback) { | ||||||
|     if (_link) |     if (_link) | ||||||
|       return LinkStringStoragePolicy::store(str, pool, callback); |       return LinkStringStoragePolicy::store(str, pool, callback); | ||||||
|     else |     else | ||||||
| @@ -41,15 +41,15 @@ class LinkOrCopyStringStoragePolicy : LinkStringStoragePolicy, | |||||||
| }; | }; | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| inline CopyStringStoragePolicy getStringStoragePolicy(const T &) { | inline CopyStringStoragePolicy getStringStoragePolicy(const T&) { | ||||||
|   return CopyStringStoragePolicy(); |   return CopyStringStoragePolicy(); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline LinkStringStoragePolicy getStringStoragePolicy(const char *) { | inline LinkStringStoragePolicy getStringStoragePolicy(const char*) { | ||||||
|   return LinkStringStoragePolicy(); |   return LinkStringStoragePolicy(); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline LinkOrCopyStringStoragePolicy getStringStoragePolicy(const String &s) { | inline LinkOrCopyStringStoragePolicy getStringStoragePolicy(const String& s) { | ||||||
|   return LinkOrCopyStringStoragePolicy(s.isLinked()); |   return LinkOrCopyStringStoragePolicy(s.isLinked()); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -20,30 +20,30 @@ class VariantAttorney { | |||||||
|     typedef char Yes[1]; |     typedef char Yes[1]; | ||||||
|     typedef char No[2]; |     typedef char No[2]; | ||||||
|  |  | ||||||
|     static Yes &probe(const VariantData *); |     static Yes& probe(const VariantData*); | ||||||
|     static No &probe(VariantData *); |     static No& probe(VariantData*); | ||||||
|  |  | ||||||
|     static TClient &client; |     static TClient& client; | ||||||
|  |  | ||||||
|    public: |    public: | ||||||
|     typedef typename conditional<sizeof(probe(client.getData())) == sizeof(Yes), |     typedef typename conditional<sizeof(probe(client.getData())) == sizeof(Yes), | ||||||
|                                  const VariantData *, VariantData *>::type type; |                                  const VariantData*, VariantData*>::type type; | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   template <typename TClient> |   template <typename TClient> | ||||||
|   FORCE_INLINE static MemoryPool *getPool(TClient &client) { |   FORCE_INLINE static MemoryPool* getPool(TClient& client) { | ||||||
|     return client.getPool(); |     return client.getPool(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TClient> |   template <typename TClient> | ||||||
|   FORCE_INLINE static typename ResultOfGetData<TClient>::type getData( |   FORCE_INLINE static typename ResultOfGetData<TClient>::type getData( | ||||||
|       TClient &client) { |       TClient& client) { | ||||||
|     return client.getData(); |     return client.getData(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TClient> |   template <typename TClient> | ||||||
|   FORCE_INLINE static VariantData *getOrCreateData(TClient &client) { |   FORCE_INLINE static VariantData* getOrCreateData(TClient& client) { | ||||||
|     return client.getOrCreateData(); |     return client.getOrCreateData(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -26,7 +26,7 @@ struct Comparer<T, typename enable_if<IsString<T>::value>::type> | |||||||
|  |  | ||||||
|   explicit Comparer(T value) : rhs(value) {} |   explicit Comparer(T value) : rhs(value) {} | ||||||
|  |  | ||||||
|   CompareResult visitString(const char *lhs, size_t n) { |   CompareResult visitString(const char* lhs, size_t n) { | ||||||
|     int i = stringCompare(adaptString(rhs), adaptString(lhs, n)); |     int i = stringCompare(adaptString(rhs), adaptString(lhs, n)); | ||||||
|     if (i < 0) |     if (i < 0) | ||||||
|       return COMPARE_RESULT_GREATER; |       return COMPARE_RESULT_GREATER; | ||||||
| @@ -83,11 +83,11 @@ struct Comparer<decltype(nullptr), void> : NullComparer { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| struct ArrayComparer : ComparerBase { | struct ArrayComparer : ComparerBase { | ||||||
|   const CollectionData *_rhs; |   const CollectionData* _rhs; | ||||||
|  |  | ||||||
|   explicit ArrayComparer(const CollectionData &rhs) : _rhs(&rhs) {} |   explicit ArrayComparer(const CollectionData& rhs) : _rhs(&rhs) {} | ||||||
|  |  | ||||||
|   CompareResult visitArray(const CollectionData &lhs) { |   CompareResult visitArray(const CollectionData& lhs) { | ||||||
|     if (ArrayConstRef(&lhs) == ArrayConstRef(_rhs)) |     if (ArrayConstRef(&lhs) == ArrayConstRef(_rhs)) | ||||||
|       return COMPARE_RESULT_EQUAL; |       return COMPARE_RESULT_EQUAL; | ||||||
|     else |     else | ||||||
| @@ -96,11 +96,11 @@ struct ArrayComparer : ComparerBase { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| struct ObjectComparer : ComparerBase { | struct ObjectComparer : ComparerBase { | ||||||
|   const CollectionData *_rhs; |   const CollectionData* _rhs; | ||||||
|  |  | ||||||
|   explicit ObjectComparer(const CollectionData &rhs) : _rhs(&rhs) {} |   explicit ObjectComparer(const CollectionData& rhs) : _rhs(&rhs) {} | ||||||
|  |  | ||||||
|   CompareResult visitObject(const CollectionData &lhs) { |   CompareResult visitObject(const CollectionData& lhs) { | ||||||
|     if (ObjectConstRef(&lhs) == ObjectConstRef(_rhs)) |     if (ObjectConstRef(&lhs) == ObjectConstRef(_rhs)) | ||||||
|       return COMPARE_RESULT_EQUAL; |       return COMPARE_RESULT_EQUAL; | ||||||
|     else |     else | ||||||
| @@ -109,13 +109,13 @@ struct ObjectComparer : ComparerBase { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| struct RawComparer : ComparerBase { | struct RawComparer : ComparerBase { | ||||||
|   const char *_rhsData; |   const char* _rhsData; | ||||||
|   size_t _rhsSize; |   size_t _rhsSize; | ||||||
|  |  | ||||||
|   explicit RawComparer(const char *rhsData, size_t rhsSize) |   explicit RawComparer(const char* rhsData, size_t rhsSize) | ||||||
|       : _rhsData(rhsData), _rhsSize(rhsSize) {} |       : _rhsData(rhsData), _rhsSize(rhsSize) {} | ||||||
|  |  | ||||||
|   CompareResult visitRawJson(const char *lhsData, size_t lhsSize) { |   CompareResult visitRawJson(const char* lhsData, size_t lhsSize) { | ||||||
|     size_t size = _rhsSize < lhsSize ? _rhsSize : lhsSize; |     size_t size = _rhsSize < lhsSize ? _rhsSize : lhsSize; | ||||||
|     int n = memcmp(lhsData, _rhsData, size); |     int n = memcmp(lhsData, _rhsData, size); | ||||||
|     if (n < 0) |     if (n < 0) | ||||||
| @@ -132,12 +132,12 @@ struct VariantComparer : ComparerBase { | |||||||
|  |  | ||||||
|   explicit VariantComparer(VariantConstRef value) : rhs(value) {} |   explicit VariantComparer(VariantConstRef value) : rhs(value) {} | ||||||
|  |  | ||||||
|   CompareResult visitArray(const CollectionData &lhs) { |   CompareResult visitArray(const CollectionData& lhs) { | ||||||
|     ArrayComparer comparer(lhs); |     ArrayComparer comparer(lhs); | ||||||
|     return accept(comparer); |     return accept(comparer); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CompareResult visitObject(const CollectionData &lhs) { |   CompareResult visitObject(const CollectionData& lhs) { | ||||||
|     ObjectComparer comparer(lhs); |     ObjectComparer comparer(lhs); | ||||||
|     return accept(comparer); |     return accept(comparer); | ||||||
|   } |   } | ||||||
| @@ -147,12 +147,12 @@ struct VariantComparer : ComparerBase { | |||||||
|     return accept(comparer); |     return accept(comparer); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CompareResult visitString(const char *lhs, size_t) { |   CompareResult visitString(const char* lhs, size_t) { | ||||||
|     Comparer<const char *> comparer(lhs); |     Comparer<const char*> comparer(lhs); | ||||||
|     return accept(comparer); |     return accept(comparer); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CompareResult visitRawJson(const char *lhsData, size_t lhsSize) { |   CompareResult visitRawJson(const char* lhsData, size_t lhsSize) { | ||||||
|     RawComparer comparer(lhsData, lhsSize); |     RawComparer comparer(lhsData, lhsSize); | ||||||
|     return accept(comparer); |     return accept(comparer); | ||||||
|   } |   } | ||||||
| @@ -179,7 +179,7 @@ struct VariantComparer : ComparerBase { | |||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   template <typename TComparer> |   template <typename TComparer> | ||||||
|   CompareResult accept(TComparer &comparer) { |   CompareResult accept(TComparer& comparer) { | ||||||
|     CompareResult reversedResult = |     CompareResult reversedResult = | ||||||
|         variantAccept(VariantAttorney::getData(rhs), comparer); |         variantAccept(VariantAttorney::getData(rhs), comparer); | ||||||
|     switch (reversedResult) { |     switch (reversedResult) { | ||||||
| @@ -197,12 +197,12 @@ template <typename T> | |||||||
| struct Comparer< | struct Comparer< | ||||||
|     T, typename enable_if<is_convertible<T, VariantConstRef>::value>::type> |     T, typename enable_if<is_convertible<T, VariantConstRef>::value>::type> | ||||||
|     : VariantComparer { |     : VariantComparer { | ||||||
|   explicit Comparer(const T &value) |   explicit Comparer(const T& value) | ||||||
|       : VariantComparer(value.operator VariantConstRef()) {} |       : VariantComparer(value.operator VariantConstRef()) {} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| CompareResult compare(VariantConstRef lhs, const T &rhs) { | CompareResult compare(VariantConstRef lhs, const T& rhs) { | ||||||
|   Comparer<T> comparer(rhs); |   Comparer<T> comparer(rhs); | ||||||
|   return variantAccept(VariantAttorney::getData(lhs), comparer); |   return variantAccept(VariantAttorney::getData(lhs), comparer); | ||||||
| } | } | ||||||
|   | |||||||
| @@ -39,7 +39,7 @@ enum { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| struct RawData { | struct RawData { | ||||||
|   const char *data; |   const char* data; | ||||||
|   size_t size; |   size_t size; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -50,7 +50,7 @@ union VariantContent { | |||||||
|   Integer asSignedInteger; |   Integer asSignedInteger; | ||||||
|   CollectionData asCollection; |   CollectionData asCollection; | ||||||
|   struct { |   struct { | ||||||
|     const char *data; |     const char* data; | ||||||
|     size_t size; |     size_t size; | ||||||
|   } asString; |   } asString; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -37,13 +37,13 @@ class VariantData { | |||||||
|     _flags = VALUE_IS_NULL; |     _flags = VALUE_IS_NULL; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void operator=(const VariantData &src) { |   void operator=(const VariantData& src) { | ||||||
|     _content = src._content; |     _content = src._content; | ||||||
|     _flags = uint8_t((_flags & OWNED_KEY_BIT) | (src._flags & ~OWNED_KEY_BIT)); |     _flags = uint8_t((_flags & OWNED_KEY_BIT) | (src._flags & ~OWNED_KEY_BIT)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TVisitor> |   template <typename TVisitor> | ||||||
|   typename TVisitor::result_type accept(TVisitor &visitor) const { |   typename TVisitor::result_type accept(TVisitor& visitor) const { | ||||||
|     switch (type()) { |     switch (type()) { | ||||||
|       case VALUE_IS_FLOAT: |       case VALUE_IS_FLOAT: | ||||||
|         return visitor.visitFloat(_content.asFloat); |         return visitor.visitFloat(_content.asFloat); | ||||||
| @@ -88,27 +88,27 @@ class VariantData { | |||||||
|  |  | ||||||
|   bool asBoolean() const; |   bool asBoolean() const; | ||||||
|  |  | ||||||
|   CollectionData *asArray() { |   CollectionData* asArray() { | ||||||
|     return isArray() ? &_content.asCollection : 0; |     return isArray() ? &_content.asCollection : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const CollectionData *asArray() const { |   const CollectionData* asArray() const { | ||||||
|     return const_cast<VariantData *>(this)->asArray(); |     return const_cast<VariantData*>(this)->asArray(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const CollectionData *asCollection() const { |   const CollectionData* asCollection() const { | ||||||
|     return isCollection() ? &_content.asCollection : 0; |     return isCollection() ? &_content.asCollection : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CollectionData *asObject() { |   CollectionData* asObject() { | ||||||
|     return isObject() ? &_content.asCollection : 0; |     return isObject() ? &_content.asCollection : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   const CollectionData *asObject() const { |   const CollectionData* asObject() const { | ||||||
|     return const_cast<VariantData *>(this)->asObject(); |     return const_cast<VariantData*>(this)->asObject(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   bool copyFrom(const VariantData &src, MemoryPool *pool); |   bool copyFrom(const VariantData& src, MemoryPool* pool); | ||||||
|  |  | ||||||
|   bool isArray() const { |   bool isArray() const { | ||||||
|     return (_flags & VALUE_IS_ARRAY) != 0; |     return (_flags & VALUE_IS_ARRAY) != 0; | ||||||
| @@ -177,7 +177,7 @@ class VariantData { | |||||||
|     _content.asFloat = value; |     _content.asFloat = value; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   void setLinkedRaw(SerializedValue<const char *> value) { |   void setLinkedRaw(SerializedValue<const char*> value) { | ||||||
|     if (value.data()) { |     if (value.data()) { | ||||||
|       setType(VALUE_IS_LINKED_RAW); |       setType(VALUE_IS_LINKED_RAW); | ||||||
|       _content.asString.data = value.data(); |       _content.asString.data = value.data(); | ||||||
| @@ -188,8 +188,8 @@ class VariantData { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   bool storeOwnedRaw(SerializedValue<T> value, MemoryPool *pool) { |   bool storeOwnedRaw(SerializedValue<T> value, MemoryPool* pool) { | ||||||
|     const char *dup = pool->saveString(adaptString(value.data(), value.size())); |     const char* dup = pool->saveString(adaptString(value.data(), value.size())); | ||||||
|     if (dup) { |     if (dup) { | ||||||
|       setType(VALUE_IS_OWNED_RAW); |       setType(VALUE_IS_OWNED_RAW); | ||||||
|       _content.asString.data = dup; |       _content.asString.data = dup; | ||||||
| @@ -227,13 +227,13 @@ class VariantData { | |||||||
|     _content.asString.size = s.size(); |     _content.asString.size = s.size(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CollectionData &toArray() { |   CollectionData& toArray() { | ||||||
|     setType(VALUE_IS_ARRAY); |     setType(VALUE_IS_ARRAY); | ||||||
|     _content.asCollection.clear(); |     _content.asCollection.clear(); | ||||||
|     return _content.asCollection; |     return _content.asCollection; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   CollectionData &toObject() { |   CollectionData& toObject() { | ||||||
|     setType(VALUE_IS_OBJECT); |     setType(VALUE_IS_OBJECT); | ||||||
|     _content.asCollection.clear(); |     _content.asCollection.clear(); | ||||||
|     return _content.asCollection; |     return _content.asCollection; | ||||||
| @@ -258,7 +258,7 @@ class VariantData { | |||||||
|     return isCollection() ? _content.asCollection.size() : 0; |     return isCollection() ? _content.asCollection.size() : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData *addElement(MemoryPool *pool) { |   VariantData* addElement(MemoryPool* pool) { | ||||||
|     if (isNull()) |     if (isNull()) | ||||||
|       toArray(); |       toArray(); | ||||||
|     if (!isArray()) |     if (!isArray()) | ||||||
| @@ -266,12 +266,12 @@ class VariantData { | |||||||
|     return _content.asCollection.addElement(pool); |     return _content.asCollection.addElement(pool); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData *getElement(size_t index) const { |   VariantData* getElement(size_t index) const { | ||||||
|     const CollectionData *col = asArray(); |     const CollectionData* col = asArray(); | ||||||
|     return col ? col->getElement(index) : 0; |     return col ? col->getElement(index) : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData *getOrAddElement(size_t index, MemoryPool *pool) { |   VariantData* getOrAddElement(size_t index, MemoryPool* pool) { | ||||||
|     if (isNull()) |     if (isNull()) | ||||||
|       toArray(); |       toArray(); | ||||||
|     if (!isArray()) |     if (!isArray()) | ||||||
| @@ -280,13 +280,13 @@ class VariantData { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TAdaptedString> |   template <typename TAdaptedString> | ||||||
|   VariantData *getMember(TAdaptedString key) const { |   VariantData* getMember(TAdaptedString key) const { | ||||||
|     const CollectionData *col = asObject(); |     const CollectionData* col = asObject(); | ||||||
|     return col ? col->getMember(key) : 0; |     return col ? col->getMember(key) : 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TAdaptedString, typename TStoragePolicy> |   template <typename TAdaptedString, typename TStoragePolicy> | ||||||
|   VariantData *getOrAddMember(TAdaptedString key, MemoryPool *pool, |   VariantData* getOrAddMember(TAdaptedString key, MemoryPool* pool, | ||||||
|                               TStoragePolicy storage_policy) { |                               TStoragePolicy storage_policy) { | ||||||
|     if (isNull()) |     if (isNull()) | ||||||
|       toObject(); |       toObject(); | ||||||
| @@ -307,7 +307,7 @@ class VariantData { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TAdaptedString, typename TStoragePolicy> |   template <typename TAdaptedString, typename TStoragePolicy> | ||||||
|   inline bool storeString(TAdaptedString value, MemoryPool *pool, |   inline bool storeString(TAdaptedString value, MemoryPool* pool, | ||||||
|                           TStoragePolicy storage) { |                           TStoragePolicy storage) { | ||||||
|     if (value.isNull()) { |     if (value.isNull()) { | ||||||
|       setNull(); |       setNull(); | ||||||
| @@ -324,7 +324,7 @@ class VariantData { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   struct VariantStringSetter { |   struct VariantStringSetter { | ||||||
|     VariantStringSetter(VariantData *instance) : _instance(instance) {} |     VariantStringSetter(VariantData* instance) : _instance(instance) {} | ||||||
|  |  | ||||||
|     template <typename TStoredString> |     template <typename TStoredString> | ||||||
|     void operator()(TStoredString s) { |     void operator()(TStoredString s) { | ||||||
| @@ -334,7 +334,7 @@ class VariantData { | |||||||
|         _instance->setNull(); |         _instance->setNull(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     VariantData *_instance; |     VariantData* _instance; | ||||||
|   }; |   }; | ||||||
| }; | }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -12,16 +12,16 @@ | |||||||
| namespace ARDUINOJSON_NAMESPACE { | namespace ARDUINOJSON_NAMESPACE { | ||||||
|  |  | ||||||
| template <typename TVisitor> | template <typename TVisitor> | ||||||
| inline typename TVisitor::result_type variantAccept(const VariantData *var, | inline typename TVisitor::result_type variantAccept(const VariantData* var, | ||||||
|                                                     TVisitor &visitor) { |                                                     TVisitor& visitor) { | ||||||
|   if (var != 0) |   if (var != 0) | ||||||
|     return var->accept(visitor); |     return var->accept(visitor); | ||||||
|   else |   else | ||||||
|     return visitor.visitNull(); |     return visitor.visitNull(); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline bool variantCopyFrom(VariantData *dst, const VariantData *src, | inline bool variantCopyFrom(VariantData* dst, const VariantData* src, | ||||||
|                             MemoryPool *pool) { |                             MemoryPool* pool) { | ||||||
|   if (!dst) |   if (!dst) | ||||||
|     return false; |     return false; | ||||||
|   if (!src) { |   if (!src) { | ||||||
| @@ -31,51 +31,51 @@ inline bool variantCopyFrom(VariantData *dst, const VariantData *src, | |||||||
|   return dst->copyFrom(*src, pool); |   return dst->copyFrom(*src, pool); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline void variantSetNull(VariantData *var) { | inline void variantSetNull(VariantData* var) { | ||||||
|   if (!var) |   if (!var) | ||||||
|     return; |     return; | ||||||
|   var->setNull(); |   var->setNull(); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TAdaptedString, typename TStoragePolicy> | template <typename TAdaptedString, typename TStoragePolicy> | ||||||
| inline bool variantSetString(VariantData *var, TAdaptedString value, | inline bool variantSetString(VariantData* var, TAdaptedString value, | ||||||
|                              MemoryPool *pool, TStoragePolicy storage_policy) { |                              MemoryPool* pool, TStoragePolicy storage_policy) { | ||||||
|   return var != 0 ? var->storeString(value, pool, storage_policy) : 0; |   return var != 0 ? var->storeString(value, pool, storage_policy) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline size_t variantSize(const VariantData *var) { | inline size_t variantSize(const VariantData* var) { | ||||||
|   return var != 0 ? var->size() : 0; |   return var != 0 ? var->size() : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline CollectionData *variantToArray(VariantData *var) { | inline CollectionData* variantToArray(VariantData* var) { | ||||||
|   if (!var) |   if (!var) | ||||||
|     return 0; |     return 0; | ||||||
|   return &var->toArray(); |   return &var->toArray(); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline CollectionData *variantToObject(VariantData *var) { | inline CollectionData* variantToObject(VariantData* var) { | ||||||
|   if (!var) |   if (!var) | ||||||
|     return 0; |     return 0; | ||||||
|   return &var->toObject(); |   return &var->toObject(); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline VariantData *variantGetElement(const VariantData *var, size_t index) { | inline VariantData* variantGetElement(const VariantData* var, size_t index) { | ||||||
|   return var != 0 ? var->getElement(index) : 0; |   return var != 0 ? var->getElement(index) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline NO_INLINE VariantData *variantAddElement(VariantData *var, | inline NO_INLINE VariantData* variantAddElement(VariantData* var, | ||||||
|                                                 MemoryPool *pool) { |                                                 MemoryPool* pool) { | ||||||
|   return var != 0 ? var->addElement(pool) : 0; |   return var != 0 ? var->addElement(pool) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| inline NO_INLINE VariantData *variantGetOrAddElement(VariantData *var, | inline NO_INLINE VariantData* variantGetOrAddElement(VariantData* var, | ||||||
|                                                      size_t index, |                                                      size_t index, | ||||||
|                                                      MemoryPool *pool) { |                                                      MemoryPool* pool) { | ||||||
|   return var != 0 ? var->getOrAddElement(index, pool) : 0; |   return var != 0 ? var->getOrAddElement(index, pool) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename AdaptedString> | template <typename AdaptedString> | ||||||
| VariantData *variantGetMember(const VariantData *var, AdaptedString key) { | VariantData* variantGetMember(const VariantData* var, AdaptedString key) { | ||||||
|   if (!var) |   if (!var) | ||||||
|     return 0; |     return 0; | ||||||
|   return var->getMember(key); |   return var->getMember(key); | ||||||
| @@ -84,8 +84,8 @@ VariantData *variantGetMember(const VariantData *var, AdaptedString key) { | |||||||
| // TODO: this function is inconsitent with the others: | // TODO: this function is inconsitent with the others: | ||||||
| // it should take an adapted string | // it should take an adapted string | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| VariantData *variantGetOrAddMember(VariantData *var, TChar *key, | VariantData* variantGetOrAddMember(VariantData* var, TChar* key, | ||||||
|                                    MemoryPool *pool) { |                                    MemoryPool* pool) { | ||||||
|   if (!var) |   if (!var) | ||||||
|     return 0; |     return 0; | ||||||
|   return var->getOrAddMember(adaptString(key), pool, |   return var->getOrAddMember(adaptString(key), pool, | ||||||
| @@ -93,28 +93,28 @@ VariantData *variantGetOrAddMember(VariantData *var, TChar *key, | |||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TString> | template <typename TString> | ||||||
| VariantData *variantGetOrAddMember(VariantData *var, const TString &key, | VariantData* variantGetOrAddMember(VariantData* var, const TString& key, | ||||||
|                                    MemoryPool *pool) { |                                    MemoryPool* pool) { | ||||||
|   if (!var) |   if (!var) | ||||||
|     return 0; |     return 0; | ||||||
|   return var->getOrAddMember(adaptString(key), pool, |   return var->getOrAddMember(adaptString(key), pool, | ||||||
|                              getStringStoragePolicy(key)); |                              getStringStoragePolicy(key)); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline bool variantIsNull(const VariantData *var) { | inline bool variantIsNull(const VariantData* var) { | ||||||
|   return var == 0 || var->isNull(); |   return var == 0 || var->isNull(); | ||||||
| } | } | ||||||
|  |  | ||||||
| inline size_t variantNesting(const VariantData *var) { | inline size_t variantNesting(const VariantData* var) { | ||||||
|   if (!var) |   if (!var) | ||||||
|     return 0; |     return 0; | ||||||
|  |  | ||||||
|   const CollectionData *collection = var->asCollection(); |   const CollectionData* collection = var->asCollection(); | ||||||
|   if (!collection) |   if (!collection) | ||||||
|     return 0; |     return 0; | ||||||
|  |  | ||||||
|   size_t maxChildNesting = 0; |   size_t maxChildNesting = 0; | ||||||
|   for (const VariantSlot *s = collection->head(); s; s = s->next()) { |   for (const VariantSlot* s = collection->head(); s; s = s->next()) { | ||||||
|     size_t childNesting = variantNesting(s->data()); |     size_t childNesting = variantNesting(s->data()); | ||||||
|     if (childNesting > maxChildNesting) |     if (childNesting > maxChildNesting) | ||||||
|       maxChildNesting = childNesting; |       maxChildNesting = childNesting; | ||||||
|   | |||||||
| @@ -83,7 +83,7 @@ inline String VariantData::asString() const { | |||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| inline bool VariantData::copyFrom(const VariantData &src, MemoryPool *pool) { | inline bool VariantData::copyFrom(const VariantData& src, MemoryPool* pool) { | ||||||
|   switch (src.type()) { |   switch (src.type()) { | ||||||
|     case VALUE_IS_ARRAY: |     case VALUE_IS_ARRAY: | ||||||
|       return toArray().copyFrom(src._content.asCollection, pool); |       return toArray().copyFrom(src._content.asCollection, pool); | ||||||
| @@ -131,9 +131,9 @@ inline bool VariantRef::set(char value) const { | |||||||
|  |  | ||||||
| // TODO: move somewhere else | // TODO: move somewhere else | ||||||
| template <typename TAdaptedString, typename TCallback> | template <typename TAdaptedString, typename TCallback> | ||||||
| bool CopyStringStoragePolicy::store(TAdaptedString str, MemoryPool *pool, | bool CopyStringStoragePolicy::store(TAdaptedString str, MemoryPool* pool, | ||||||
|                                     TCallback callback) { |                                     TCallback callback) { | ||||||
|   const char *copy = pool->saveString(str); |   const char* copy = pool->saveString(str); | ||||||
|   String storedString(copy, str.size(), String::Copied); |   String storedString(copy, str.size(), String::Copied); | ||||||
|   callback(storedString); |   callback(storedString); | ||||||
|   return copy != 0; |   return copy != 0; | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ class VariantConstRef; | |||||||
|  |  | ||||||
| template <typename T> | template <typename T> | ||||||
| CompareResult compare(VariantConstRef lhs, | CompareResult compare(VariantConstRef lhs, | ||||||
|                       const T &rhs);  // VariantCompare.cpp |                       const T& rhs);  // VariantCompare.cpp | ||||||
|  |  | ||||||
| struct VariantOperatorTag {}; | struct VariantOperatorTag {}; | ||||||
|  |  | ||||||
| @@ -29,7 +29,7 @@ struct VariantOperators : VariantOperatorTag { | |||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend |   friend | ||||||
|       typename enable_if<!IsVariant<T>::value && !is_array<T>::value, T>::type |       typename enable_if<!IsVariant<T>::value && !is_array<T>::value, T>::type | ||||||
|       operator|(const TVariant &variant, const T &defaultValue) { |       operator|(const TVariant& variant, const T& defaultValue) { | ||||||
|     if (variant.template is<T>()) |     if (variant.template is<T>()) | ||||||
|       return variant.template as<T>(); |       return variant.template as<T>(); | ||||||
|     else |     else | ||||||
| @@ -37,10 +37,10 @@ struct VariantOperators : VariantOperatorTag { | |||||||
|   } |   } | ||||||
|   // |   // | ||||||
|   // const char* operator|(JsonVariant, const char*) |   // const char* operator|(JsonVariant, const char*) | ||||||
|   friend const char *operator|(const TVariant &variant, |   friend const char* operator|(const TVariant& variant, | ||||||
|                                const char *defaultValue) { |                                const char* defaultValue) { | ||||||
|     if (variant.template is<const char *>()) |     if (variant.template is<const char*>()) | ||||||
|       return variant.template as<const char *>(); |       return variant.template as<const char*>(); | ||||||
|     else |     else | ||||||
|       return defaultValue; |       return defaultValue; | ||||||
|   } |   } | ||||||
| @@ -48,7 +48,7 @@ struct VariantOperators : VariantOperatorTag { | |||||||
|   // JsonVariant operator|(JsonVariant, JsonVariant) |   // JsonVariant operator|(JsonVariant, JsonVariant) | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend typename enable_if<IsVariant<T>::value, VariantConstRef>::type |   friend typename enable_if<IsVariant<T>::value, VariantConstRef>::type | ||||||
|   operator|(const TVariant &variant, T defaultValue) { |   operator|(const TVariant& variant, T defaultValue) { | ||||||
|     if (variant) |     if (variant) | ||||||
|       return variant; |       return variant; | ||||||
|     else |     else | ||||||
| @@ -57,133 +57,133 @@ struct VariantOperators : VariantOperatorTag { | |||||||
|  |  | ||||||
|   // value == TVariant |   // value == TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator==(T *lhs, TVariant rhs) { |   friend bool operator==(T* lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) == COMPARE_RESULT_EQUAL; |     return compare(rhs, lhs) == COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator==(const T &lhs, TVariant rhs) { |   friend bool operator==(const T& lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) == COMPARE_RESULT_EQUAL; |     return compare(rhs, lhs) == COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant == value |   // TVariant == value | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator==(TVariant lhs, T *rhs) { |   friend bool operator==(TVariant lhs, T* rhs) { | ||||||
|     return compare(lhs, rhs) == COMPARE_RESULT_EQUAL; |     return compare(lhs, rhs) == COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend |   friend | ||||||
|       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type |       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type | ||||||
|       operator==(TVariant lhs, const T &rhs) { |       operator==(TVariant lhs, const T& rhs) { | ||||||
|     return compare(lhs, rhs) == COMPARE_RESULT_EQUAL; |     return compare(lhs, rhs) == COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // value != TVariant |   // value != TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator!=(T *lhs, TVariant rhs) { |   friend bool operator!=(T* lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) != COMPARE_RESULT_EQUAL; |     return compare(rhs, lhs) != COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator!=(const T &lhs, TVariant rhs) { |   friend bool operator!=(const T& lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) != COMPARE_RESULT_EQUAL; |     return compare(rhs, lhs) != COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant != value |   // TVariant != value | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator!=(TVariant lhs, T *rhs) { |   friend bool operator!=(TVariant lhs, T* rhs) { | ||||||
|     return compare(lhs, rhs) != COMPARE_RESULT_EQUAL; |     return compare(lhs, rhs) != COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend |   friend | ||||||
|       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type |       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type | ||||||
|       operator!=(TVariant lhs, const T &rhs) { |       operator!=(TVariant lhs, const T& rhs) { | ||||||
|     return compare(lhs, rhs) != COMPARE_RESULT_EQUAL; |     return compare(lhs, rhs) != COMPARE_RESULT_EQUAL; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // value < TVariant |   // value < TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator<(T *lhs, TVariant rhs) { |   friend bool operator<(T* lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) == COMPARE_RESULT_GREATER; |     return compare(rhs, lhs) == COMPARE_RESULT_GREATER; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator<(const T &lhs, TVariant rhs) { |   friend bool operator<(const T& lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) == COMPARE_RESULT_GREATER; |     return compare(rhs, lhs) == COMPARE_RESULT_GREATER; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant < value |   // TVariant < value | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator<(TVariant lhs, T *rhs) { |   friend bool operator<(TVariant lhs, T* rhs) { | ||||||
|     return compare(lhs, rhs) == COMPARE_RESULT_LESS; |     return compare(lhs, rhs) == COMPARE_RESULT_LESS; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend |   friend | ||||||
|       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type |       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type | ||||||
|       operator<(TVariant lhs, const T &rhs) { |       operator<(TVariant lhs, const T& rhs) { | ||||||
|     return compare(lhs, rhs) == COMPARE_RESULT_LESS; |     return compare(lhs, rhs) == COMPARE_RESULT_LESS; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // value <= TVariant |   // value <= TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator<=(T *lhs, TVariant rhs) { |   friend bool operator<=(T* lhs, TVariant rhs) { | ||||||
|     return (compare(rhs, lhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; |     return (compare(rhs, lhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator<=(const T &lhs, TVariant rhs) { |   friend bool operator<=(const T& lhs, TVariant rhs) { | ||||||
|     return (compare(rhs, lhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; |     return (compare(rhs, lhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant <= value |   // TVariant <= value | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator<=(TVariant lhs, T *rhs) { |   friend bool operator<=(TVariant lhs, T* rhs) { | ||||||
|     return (compare(lhs, rhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; |     return (compare(lhs, rhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend |   friend | ||||||
|       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type |       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type | ||||||
|       operator<=(TVariant lhs, const T &rhs) { |       operator<=(TVariant lhs, const T& rhs) { | ||||||
|     return (compare(lhs, rhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; |     return (compare(lhs, rhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // value > TVariant |   // value > TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator>(T *lhs, TVariant rhs) { |   friend bool operator>(T* lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) == COMPARE_RESULT_LESS; |     return compare(rhs, lhs) == COMPARE_RESULT_LESS; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator>(const T &lhs, TVariant rhs) { |   friend bool operator>(const T& lhs, TVariant rhs) { | ||||||
|     return compare(rhs, lhs) == COMPARE_RESULT_LESS; |     return compare(rhs, lhs) == COMPARE_RESULT_LESS; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant > value |   // TVariant > value | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator>(TVariant lhs, T *rhs) { |   friend bool operator>(TVariant lhs, T* rhs) { | ||||||
|     return compare(lhs, rhs) == COMPARE_RESULT_GREATER; |     return compare(lhs, rhs) == COMPARE_RESULT_GREATER; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend |   friend | ||||||
|       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type |       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type | ||||||
|       operator>(TVariant lhs, const T &rhs) { |       operator>(TVariant lhs, const T& rhs) { | ||||||
|     return compare(lhs, rhs) == COMPARE_RESULT_GREATER; |     return compare(lhs, rhs) == COMPARE_RESULT_GREATER; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // value >= TVariant |   // value >= TVariant | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator>=(T *lhs, TVariant rhs) { |   friend bool operator>=(T* lhs, TVariant rhs) { | ||||||
|     return (compare(rhs, lhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; |     return (compare(rhs, lhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator>=(const T &lhs, TVariant rhs) { |   friend bool operator>=(const T& lhs, TVariant rhs) { | ||||||
|     return (compare(rhs, lhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; |     return (compare(rhs, lhs) & COMPARE_RESULT_LESS_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // TVariant >= value |   // TVariant >= value | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend bool operator>=(TVariant lhs, T *rhs) { |   friend bool operator>=(TVariant lhs, T* rhs) { | ||||||
|     return (compare(lhs, rhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; |     return (compare(lhs, rhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   friend |   friend | ||||||
|       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type |       typename enable_if<!is_base_of<VariantOperatorTag, T>::value, bool>::type | ||||||
|       operator>=(TVariant lhs, const T &rhs) { |       operator>=(TVariant lhs, const T& rhs) { | ||||||
|     return (compare(lhs, rhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; |     return (compare(lhs, rhs) & COMPARE_RESULT_GREATER_OR_EQUAL) != 0; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -49,8 +49,8 @@ class VariantRefBase : public VariantTag { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|  protected: |  protected: | ||||||
|   VariantRefBase(TData *data) : _data(data) {} |   VariantRefBase(TData* data) : _data(data) {} | ||||||
|   TData *_data; |   TData* _data; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| class VariantConstRef : public VariantRefBase<const VariantData>, | class VariantConstRef : public VariantRefBase<const VariantData>, | ||||||
| @@ -62,21 +62,21 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   VariantConstRef() : base_type(0) {} |   VariantConstRef() : base_type(0) {} | ||||||
|   explicit VariantConstRef(const VariantData *data) : base_type(data) {} |   explicit VariantConstRef(const VariantData* data) : base_type(data) {} | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<!is_same<T, char *>::value && !is_same<T, char>::value, |       typename enable_if<!is_same<T, char*>::value && !is_same<T, char>::value, | ||||||
|                          T>::type |                          T>::type | ||||||
|       as() const { |       as() const { | ||||||
|     return Converter<T>::fromJson(*this); |     return Converter<T>::fromJson(*this); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE typename enable_if<is_same<T, char *>::value, const char *>::type |   FORCE_INLINE typename enable_if<is_same<T, char*>::value, const char*>::type | ||||||
|   ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()") |   ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()") | ||||||
|       as() const { |       as() const { | ||||||
|     return as<const char *>(); |     return as<const char*>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
| @@ -89,17 +89,17 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<!is_same<T, char *>::value && !is_same<T, char>::value, |       typename enable_if<!is_same<T, char*>::value && !is_same<T, char>::value, | ||||||
|                          bool>::type |                          bool>::type | ||||||
|       is() const { |       is() const { | ||||||
|     return Converter<T>::checkJson(*this); |     return Converter<T>::checkJson(*this); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE typename enable_if<is_same<T, char *>::value, bool>::type |   FORCE_INLINE typename enable_if<is_same<T, char*>::value, bool>::type | ||||||
|   ARDUINOJSON_DEPRECATED("Replace is<char*>() with is<const char*>()") |   ARDUINOJSON_DEPRECATED("Replace is<char*>() with is<const char*>()") | ||||||
|       is() const { |       is() const { | ||||||
|     return is<const char *>(); |     return is<const char*>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
| @@ -124,7 +124,7 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<IsString<TString>::value, VariantConstRef>::type |       typename enable_if<IsString<TString>::value, VariantConstRef>::type | ||||||
|       operator[](const TString &key) const { |       operator[](const TString& key) const { | ||||||
|     return VariantConstRef(variantGetMember(_data, adaptString(key))); |     return VariantConstRef(variantGetMember(_data, adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -133,13 +133,13 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|   // operator[](const __FlashStringHelper*) const |   // operator[](const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<IsString<TChar *>::value, VariantConstRef>::type |       typename enable_if<IsString<TChar*>::value, VariantConstRef>::type | ||||||
|       operator[](TChar *key) const { |       operator[](TChar* key) const { | ||||||
|     return VariantConstRef(variantGetMember(_data, adaptString(key))); |     return VariantConstRef(variantGetMember(_data, adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  protected: |  protected: | ||||||
|   const VariantData *getData() const { |   const VariantData* getData() const { | ||||||
|     return _data; |     return _data; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| @@ -158,7 +158,7 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|  |  | ||||||
|  public: |  public: | ||||||
|   // Intenal use only |   // Intenal use only | ||||||
|   FORCE_INLINE VariantRef(MemoryPool *pool, VariantData *data) |   FORCE_INLINE VariantRef(MemoryPool* pool, VariantData* data) | ||||||
|       : base_type(data), _pool(pool) {} |       : base_type(data), _pool(pool) {} | ||||||
|  |  | ||||||
|   // Creates an uninitialized VariantRef |   // Creates an uninitialized VariantRef | ||||||
| @@ -169,7 +169,7 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE bool set(const T &value) const { |   FORCE_INLINE bool set(const T& value) const { | ||||||
|     Converter<T>::toJson(value, *this); |     Converter<T>::toJson(value, *this); | ||||||
|     return _pool && !_pool->overflowed(); |     return _pool && !_pool->overflowed(); | ||||||
|   } |   } | ||||||
| @@ -179,24 +179,24 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|       set(char value) const; |       set(char value) const; | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE bool set(T *value) const { |   FORCE_INLINE bool set(T* value) const { | ||||||
|     Converter<T *>::toJson(value, *this); |     Converter<T*>::toJson(value, *this); | ||||||
|     return _pool && !_pool->overflowed(); |     return _pool && !_pool->overflowed(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<!is_same<T, char *>::value && !is_same<T, char>::value, |       typename enable_if<!is_same<T, char*>::value && !is_same<T, char>::value, | ||||||
|                          T>::type |                          T>::type | ||||||
|       as() const { |       as() const { | ||||||
|     return Converter<T>::fromJson(*this); |     return Converter<T>::fromJson(*this); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE typename enable_if<is_same<T, char *>::value, const char *>::type |   FORCE_INLINE typename enable_if<is_same<T, char*>::value, const char*>::type | ||||||
|   ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()") |   ARDUINOJSON_DEPRECATED("Replace as<char*>() with as<const char*>()") | ||||||
|       as() const { |       as() const { | ||||||
|     return as<const char *>(); |     return as<const char*>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
| @@ -209,17 +209,17 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE |   FORCE_INLINE | ||||||
|       typename enable_if<!is_same<T, char *>::value && !is_same<T, char>::value, |       typename enable_if<!is_same<T, char*>::value && !is_same<T, char>::value, | ||||||
|                          bool>::type |                          bool>::type | ||||||
|       is() const { |       is() const { | ||||||
|     return Converter<T>::checkJson(*this); |     return Converter<T>::checkJson(*this); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
|   FORCE_INLINE typename enable_if<is_same<T, char *>::value, bool>::type |   FORCE_INLINE typename enable_if<is_same<T, char*>::value, bool>::type | ||||||
|   ARDUINOJSON_DEPRECATED("Replace is<char*>() with is<const char*>()") |   ARDUINOJSON_DEPRECATED("Replace is<char*>() with is<const char*>()") | ||||||
|       is() const { |       is() const { | ||||||
|     return is<const char *>(); |     return is<const char*>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename T> |   template <typename T> | ||||||
| @@ -268,8 +268,8 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|   // remove(const char*) const |   // remove(const char*) const | ||||||
|   // remove(const __FlashStringHelper*) const |   // remove(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TChar *>::value>::type remove( |   FORCE_INLINE typename enable_if<IsString<TChar*>::value>::type remove( | ||||||
|       TChar *key) const { |       TChar* key) const { | ||||||
|     if (_data) |     if (_data) | ||||||
|       _data->remove(adaptString(key)); |       _data->remove(adaptString(key)); | ||||||
|   } |   } | ||||||
| @@ -277,7 +277,7 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|   // remove(const String&) const |   // remove(const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove( |   FORCE_INLINE typename enable_if<IsString<TString>::value>::type remove( | ||||||
|       const TString &key) const { |       const TString& key) const { | ||||||
|     if (_data) |     if (_data) | ||||||
|       _data->remove(adaptString(key)); |       _data->remove(adaptString(key)); | ||||||
|   } |   } | ||||||
| @@ -285,27 +285,27 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|   inline void shallowCopy(VariantConstRef target) { |   inline void shallowCopy(VariantConstRef target) { | ||||||
|     if (!_data) |     if (!_data) | ||||||
|       return; |       return; | ||||||
|     const VariantData *targetData = VariantAttorney::getData(target); |     const VariantData* targetData = VariantAttorney::getData(target); | ||||||
|     if (targetData) |     if (targetData) | ||||||
|       *_data = *targetData; |       *_data = *targetData; | ||||||
|     else |     else | ||||||
|       _data->setNull(); |       _data->setNull(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   MemoryPool *getPool() const { |   MemoryPool* getPool() const { | ||||||
|     return _pool; |     return _pool; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData *getData() const { |   VariantData* getData() const { | ||||||
|     return _data; |     return _data; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   VariantData *getOrCreateData() const { |   VariantData* getOrCreateData() const { | ||||||
|     return _data; |     return _data; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool *_pool; |   MemoryPool* _pool; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <> | template <> | ||||||
| @@ -322,7 +322,7 @@ struct Converter<VariantRef> : private VariantAttorney { | |||||||
|       VariantConstRef); |       VariantConstRef); | ||||||
|  |  | ||||||
|   static bool checkJson(VariantRef src) { |   static bool checkJson(VariantRef src) { | ||||||
|     VariantData *data = getData(src); |     VariantData* data = getData(src); | ||||||
|     return !!data; |     return !!data; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -342,7 +342,7 @@ struct Converter<VariantConstRef> : private VariantAttorney { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   static bool checkJson(VariantConstRef src) { |   static bool checkJson(VariantConstRef src) { | ||||||
|     const VariantData *data = getData(src); |     const VariantData* data = getData(src); | ||||||
|     return !!data; |     return !!data; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ template <typename TResult> | |||||||
| struct Visitor { | struct Visitor { | ||||||
|   typedef TResult result_type; |   typedef TResult result_type; | ||||||
|  |  | ||||||
|   TResult visitArray(const CollectionData &) { |   TResult visitArray(const CollectionData&) { | ||||||
|     return TResult(); |     return TResult(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -34,7 +34,7 @@ struct Visitor { | |||||||
|     return TResult(); |     return TResult(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   TResult visitObject(const CollectionData &) { |   TResult visitObject(const CollectionData&) { | ||||||
|     return TResult(); |     return TResult(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -42,11 +42,11 @@ struct Visitor { | |||||||
|     return TResult(); |     return TResult(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   TResult visitRawJson(const char *, size_t) { |   TResult visitRawJson(const char*, size_t) { | ||||||
|     return TResult(); |     return TResult(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   TResult visitString(const char *, size_t) { |   TResult visitString(const char*, size_t) { | ||||||
|     return TResult(); |     return TResult(); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user