mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	link() takes a JsonVariantConst
This commit is contained in:
		| @@ -12,7 +12,7 @@ TEST_CASE("JsonVariant::link()") { | ||||
|   SECTION("JsonVariant::link(JsonDocument&)") { | ||||
|     doc2["hello"] = "world"; | ||||
|  | ||||
|     variant.link(doc2.as<JsonVariant>()); | ||||
|     variant.link(doc2); | ||||
|  | ||||
|     CHECK(variant.as<std::string>() == "{\"hello\":\"world\"}"); | ||||
|     CHECK(variant.memoryUsage() == 0); | ||||
|   | ||||
| @@ -42,7 +42,7 @@ TEST_CASE("JsonVariant::memoryUsage()") { | ||||
|   SECTION("ignore size of link document") { | ||||
|     StaticJsonDocument<128> doc2; | ||||
|     doc2["hello"] = "world"; | ||||
|     var.link(doc2.as<JsonVariant>()); | ||||
|     var.link(doc2); | ||||
|     CHECK(var.memoryUsage() == 0); | ||||
|     CHECK(var.memoryUsage() == doc.memoryUsage()); | ||||
|   } | ||||
|   | ||||
| @@ -51,7 +51,7 @@ union VariantContent { | ||||
|   UInt asUnsignedInteger; | ||||
|   Integer asSignedInteger; | ||||
|   CollectionData asCollection; | ||||
|   class VariantData *asPointer; | ||||
|   const class VariantData *asPointer; | ||||
|   struct { | ||||
|     const char *data; | ||||
|     size_t size; | ||||
|   | ||||
| @@ -212,7 +212,7 @@ class VariantData { | ||||
|     setType(VALUE_IS_NULL); | ||||
|   } | ||||
|  | ||||
|   void setPointer(VariantData *value) { | ||||
|   void setPointer(const VariantData *value) { | ||||
|     setType(VALUE_IS_POINTER); | ||||
|     _content.asPointer = value; | ||||
|   } | ||||
|   | ||||
| @@ -181,4 +181,9 @@ bool CopyStringStoragePolicy::store(TAdaptedString str, MemoryPool *pool, | ||||
|   return copy != 0; | ||||
| } | ||||
|  | ||||
| inline void VariantRef::link(VariantConstRef var) { | ||||
|   if (_data) | ||||
|     _data->setPointer(var._data); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -198,10 +198,7 @@ class VariantRef : public VariantRefBase<VariantData>, | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE VariantRef getOrAddMember(const TString &) const; | ||||
|  | ||||
|   FORCE_INLINE void link(VariantRef var) { | ||||
|     if (_data) | ||||
|       _data->setPointer(var._data); | ||||
|   } | ||||
|   void link(class VariantConstRef var); | ||||
|  | ||||
|   FORCE_INLINE void remove(size_t index) const { | ||||
|     if (_data) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user