mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 00:32:37 +01:00 
			
		
		
		
	Rename ObjectRef to JsonObject
				
					
				
			This commit is contained in:
		| @@ -187,8 +187,8 @@ TEST_CASE("Polyfills/type_traits") { | ||||
|     CHECK((is_convertible<ElementProxy<JsonArray>, JsonVariantConst>::value == | ||||
|            true)); | ||||
|     CHECK((is_convertible<JsonArrayConst, JsonVariantConst>::value == true)); | ||||
|     CHECK((is_convertible<ObjectRef, JsonVariantConst>::value == true)); | ||||
|     CHECK((is_convertible<MemberProxy<ObjectRef, const char*>, | ||||
|     CHECK((is_convertible<JsonObject, JsonVariantConst>::value == true)); | ||||
|     CHECK((is_convertible<MemberProxy<JsonObject, const char*>, | ||||
|                           JsonVariantConst>::value == true)); | ||||
|     CHECK((is_convertible<ObjectConstRef, JsonVariantConst>::value == true)); | ||||
|     CHECK( | ||||
|   | ||||
| @@ -22,7 +22,7 @@ | ||||
| #endif | ||||
|  | ||||
| #include "ArduinoJson/Array/JsonArray.hpp" | ||||
| #include "ArduinoJson/Object/ObjectRef.hpp" | ||||
| #include "ArduinoJson/Object/JsonObject.hpp" | ||||
| #include "ArduinoJson/Variant/VariantConstRef.hpp" | ||||
|  | ||||
| #include "ArduinoJson/Document/DynamicJsonDocument.hpp" | ||||
| @@ -32,8 +32,8 @@ | ||||
| #include "ArduinoJson/Array/JsonArrayImpl.hpp" | ||||
| #include "ArduinoJson/Array/Utilities.hpp" | ||||
| #include "ArduinoJson/Collection/CollectionImpl.hpp" | ||||
| #include "ArduinoJson/Object/JsonObjectImpl.hpp" | ||||
| #include "ArduinoJson/Object/MemberProxy.hpp" | ||||
| #include "ArduinoJson/Object/ObjectImpl.hpp" | ||||
| #include "ArduinoJson/Variant/ConverterImpl.hpp" | ||||
| #include "ArduinoJson/Variant/VariantCompare.hpp" | ||||
| #include "ArduinoJson/Variant/VariantImpl.hpp" | ||||
| @@ -52,7 +52,7 @@ using ARDUINOJSON_NAMESPACE::JsonArrayConst; | ||||
| typedef ARDUINOJSON_NAMESPACE::Float JsonFloat; | ||||
| typedef ARDUINOJSON_NAMESPACE::Integer JsonInteger; | ||||
| typedef ARDUINOJSON_NAMESPACE::ObjectConstRef JsonObjectConst; | ||||
| typedef ARDUINOJSON_NAMESPACE::ObjectRef JsonObject; | ||||
| using ARDUINOJSON_NAMESPACE::JsonObject; | ||||
| typedef ARDUINOJSON_NAMESPACE::Pair JsonPair; | ||||
| typedef ARDUINOJSON_NAMESPACE::PairConst JsonPairConst; | ||||
| typedef ARDUINOJSON_NAMESPACE::String JsonString; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| class ObjectRef; | ||||
| class JsonObject; | ||||
|  | ||||
| class JsonArray : public VariantOperators<JsonArray> { | ||||
|   friend class VariantAttorney; | ||||
| @@ -92,7 +92,7 @@ class JsonArray : public VariantOperators<JsonArray> { | ||||
|     return ElementProxy<JsonArray>(*this, index); | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE ObjectRef createNestedObject() const; | ||||
|   FORCE_INLINE JsonObject createNestedObject() const; | ||||
|  | ||||
|   FORCE_INLINE JsonArray createNestedArray() const { | ||||
|     return add().to<JsonArray>(); | ||||
|   | ||||
| @@ -10,7 +10,7 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| class ObjectRef; | ||||
| class JsonObject; | ||||
|  | ||||
| class JsonArrayConst : public VariantOperators<JsonArrayConst> { | ||||
|   friend class JsonArray; | ||||
|   | ||||
| @@ -5,12 +5,12 @@ | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/Array/JsonArray.hpp> | ||||
| #include <ArduinoJson/Object/ObjectRef.hpp> | ||||
| #include <ArduinoJson/Object/JsonObject.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| inline ObjectRef JsonArray::createNestedObject() const { | ||||
|   return add().to<ObjectRef>(); | ||||
| inline JsonObject JsonArray::createNestedObject() const { | ||||
|   return add().to<JsonObject>(); | ||||
| } | ||||
|  | ||||
| template <typename TDerived> | ||||
| @@ -19,8 +19,8 @@ inline JsonArray VariantRefBase<TDerived>::createNestedArray() const { | ||||
| } | ||||
|  | ||||
| template <typename TDerived> | ||||
| inline ObjectRef VariantRefBase<TDerived>::createNestedObject() const { | ||||
|   return add().template to<ObjectRef>(); | ||||
| inline JsonObject VariantRefBase<TDerived>::createNestedObject() const { | ||||
|   return add().template to<JsonObject>(); | ||||
| } | ||||
|  | ||||
| template <typename TDerived> | ||||
|   | ||||
| @@ -67,7 +67,7 @@ class BasicJsonDocument : AllocatorOwner<TAllocator>, public JsonDocument { | ||||
|       typename enable_if< | ||||
|           is_same<T, VariantRef>::value || is_same<T, VariantConstRef>::value || | ||||
|           is_same<T, JsonArray>::value || is_same<T, JsonArrayConst>::value || | ||||
|           is_same<T, ObjectRef>::value || | ||||
|           is_same<T, JsonObject>::value || | ||||
|           is_same<T, ObjectConstRef>::value>::type* = 0) | ||||
|       : JsonDocument(allocPool(src.memoryUsage())) { | ||||
|     set(src); | ||||
|   | ||||
| @@ -6,12 +6,13 @@ | ||||
|  | ||||
| #include <ArduinoJson/Array/ElementProxy.hpp> | ||||
| #include <ArduinoJson/Memory/MemoryPool.hpp> | ||||
| #include <ArduinoJson/Object/JsonObject.hpp> | ||||
| #include <ArduinoJson/Object/MemberProxy.hpp> | ||||
| #include <ArduinoJson/Object/ObjectRef.hpp> | ||||
| #include <ArduinoJson/Strings/StoragePolicy.hpp> | ||||
| #include <ArduinoJson/Variant/VariantConstRef.hpp> | ||||
| #include <ArduinoJson/Variant/VariantTo.hpp> | ||||
|  | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
| @@ -102,23 +103,23 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | ||||
|     return operator[](key).template to<JsonArray>(); | ||||
|   } | ||||
|  | ||||
|   ObjectRef createNestedObject() { | ||||
|     return add().to<ObjectRef>(); | ||||
|   JsonObject createNestedObject() { | ||||
|     return add().to<JsonObject>(); | ||||
|   } | ||||
|  | ||||
|   // createNestedObject(char*) | ||||
|   // createNestedObject(const char*) | ||||
|   // createNestedObject(const __FlashStringHelper*) | ||||
|   template <typename TChar> | ||||
|   ObjectRef createNestedObject(TChar* key) { | ||||
|     return operator[](key).template to<ObjectRef>(); | ||||
|   JsonObject createNestedObject(TChar* key) { | ||||
|     return operator[](key).template to<JsonObject>(); | ||||
|   } | ||||
|  | ||||
|   // createNestedObject(const std::string&) | ||||
|   // createNestedObject(const String&) | ||||
|   template <typename TString> | ||||
|   ObjectRef createNestedObject(const TString& key) { | ||||
|     return operator[](key).template to<ObjectRef>(); | ||||
|   JsonObject createNestedObject(const TString& key) { | ||||
|     return operator[](key).template to<JsonObject>(); | ||||
|   } | ||||
|  | ||||
|   // containsKey(char*) const | ||||
|   | ||||
| @@ -11,14 +11,14 @@ namespace ARDUINOJSON_NAMESPACE { | ||||
| 
 | ||||
| class JsonArray; | ||||
| 
 | ||||
| class ObjectRef : public VariantOperators<ObjectRef> { | ||||
| class JsonObject : public VariantOperators<JsonObject> { | ||||
|   friend class VariantAttorney; | ||||
| 
 | ||||
|  public: | ||||
|   typedef ObjectIterator iterator; | ||||
| 
 | ||||
|   FORCE_INLINE ObjectRef() : _data(0), _pool(0) {} | ||||
|   FORCE_INLINE ObjectRef(MemoryPool* buf, CollectionData* data) | ||||
|   FORCE_INLINE JsonObject() : _data(0), _pool(0) {} | ||||
|   FORCE_INLINE JsonObject(MemoryPool* buf, CollectionData* data) | ||||
|       : _data(data), _pool(buf) {} | ||||
| 
 | ||||
|   operator VariantRef() const { | ||||
| @@ -76,22 +76,22 @@ class ObjectRef : public VariantOperators<ObjectRef> { | ||||
|     return _data->copyFrom(*src._data, _pool); | ||||
|   } | ||||
| 
 | ||||
|   FORCE_INLINE bool operator==(ObjectRef rhs) const { | ||||
|   FORCE_INLINE bool operator==(JsonObject rhs) const { | ||||
|     return ObjectConstRef(_data) == ObjectConstRef(rhs._data); | ||||
|   } | ||||
| 
 | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, | ||||
|                                   MemberProxy<ObjectRef, TString> >::type | ||||
|                                   MemberProxy<JsonObject, TString> >::type | ||||
|   operator[](const TString& key) const { | ||||
|     return MemberProxy<ObjectRef, TString>(*this, key); | ||||
|     return MemberProxy<JsonObject, TString>(*this, key); | ||||
|   } | ||||
| 
 | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, | ||||
|                                   MemberProxy<ObjectRef, TChar*> >::type | ||||
|                                   MemberProxy<JsonObject, TChar*> >::type | ||||
|   operator[](TChar* key) const { | ||||
|     return MemberProxy<ObjectRef, TChar*>(*this, key); | ||||
|     return MemberProxy<JsonObject, TChar*>(*this, key); | ||||
|   } | ||||
| 
 | ||||
|   FORCE_INLINE void remove(iterator it) const { | ||||
| @@ -134,13 +134,13 @@ class ObjectRef : public VariantOperators<ObjectRef> { | ||||
|   FORCE_INLINE JsonArray createNestedArray(TChar* key) const; | ||||
| 
 | ||||
|   template <typename TString> | ||||
|   ObjectRef createNestedObject(const TString& key) const { | ||||
|     return operator[](key).template to<ObjectRef>(); | ||||
|   JsonObject createNestedObject(const TString& key) const { | ||||
|     return operator[](key).template to<JsonObject>(); | ||||
|   } | ||||
| 
 | ||||
|   template <typename TChar> | ||||
|   ObjectRef createNestedObject(TChar* key) const { | ||||
|     return operator[](key).template to<ObjectRef>(); | ||||
|   JsonObject createNestedObject(TChar* key) const { | ||||
|     return operator[](key).template to<JsonObject>(); | ||||
|   } | ||||
| 
 | ||||
|  private: | ||||
| @@ -175,18 +175,18 @@ class ObjectRef : public VariantOperators<ObjectRef> { | ||||
| }; | ||||
| 
 | ||||
| template <> | ||||
| struct Converter<ObjectRef> : private VariantAttorney { | ||||
| struct Converter<JsonObject> : private VariantAttorney { | ||||
|   static void toJson(VariantConstRef src, VariantRef dst) { | ||||
|     variantCopyFrom(getData(dst), getData(src), getPool(dst)); | ||||
|   } | ||||
| 
 | ||||
|   static ObjectRef fromJson(VariantRef src) { | ||||
|   static JsonObject fromJson(VariantRef src) { | ||||
|     VariantData* data = getData(src); | ||||
|     MemoryPool* pool = getPool(src); | ||||
|     return ObjectRef(pool, data != 0 ? data->asObject() : 0); | ||||
|     return JsonObject(pool, data != 0 ? data->asObject() : 0); | ||||
|   } | ||||
| 
 | ||||
|   static InvalidConversion<VariantConstRef, ObjectRef> fromJson( | ||||
|   static InvalidConversion<VariantConstRef, JsonObject> fromJson( | ||||
|       VariantConstRef); | ||||
| 
 | ||||
|   static bool checkJson(VariantConstRef) { | ||||
| @@ -5,17 +5,17 @@ | ||||
| #pragma once | ||||
| 
 | ||||
| #include <ArduinoJson/Array/JsonArray.hpp> | ||||
| #include <ArduinoJson/Object/ObjectRef.hpp> | ||||
| #include <ArduinoJson/Object/JsonObject.hpp> | ||||
| 
 | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| 
 | ||||
| template <typename TString> | ||||
| inline JsonArray ObjectRef::createNestedArray(const TString& key) const { | ||||
| inline JsonArray JsonObject::createNestedArray(const TString& key) const { | ||||
|   return operator[](key).template to<JsonArray>(); | ||||
| } | ||||
| 
 | ||||
| template <typename TChar> | ||||
| inline JsonArray ObjectRef::createNestedArray(TChar* key) const { | ||||
| inline JsonArray JsonObject::createNestedArray(TChar* key) const { | ||||
|   return operator[](key).template to<JsonArray>(); | ||||
| } | ||||
| 
 | ||||
| @@ -34,16 +34,16 @@ inline JsonArray VariantRefBase<TDerived>::createNestedArray(TChar* key) const { | ||||
| 
 | ||||
| template <typename TDerived> | ||||
| template <typename TString> | ||||
| inline ObjectRef VariantRefBase<TDerived>::createNestedObject( | ||||
| inline JsonObject VariantRefBase<TDerived>::createNestedObject( | ||||
|     const TString& key) const { | ||||
|   return operator[](key).template to<ObjectRef>(); | ||||
|   return operator[](key).template to<JsonObject>(); | ||||
| } | ||||
| 
 | ||||
| template <typename TDerived> | ||||
| template <typename TChar> | ||||
| inline ObjectRef VariantRefBase<TDerived>::createNestedObject( | ||||
| inline JsonObject VariantRefBase<TDerived>::createNestedObject( | ||||
|     TChar* key) const { | ||||
|   return operator[](key).template to<ObjectRef>(); | ||||
|   return operator[](key).template to<JsonObject>(); | ||||
| } | ||||
| 
 | ||||
| template <typename TDerived> | ||||
| @@ -10,7 +10,7 @@ | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| class ObjectConstRef : public VariantOperators<ObjectConstRef> { | ||||
|   friend class ObjectRef; | ||||
|   friend class JsonObject; | ||||
|   friend class VariantAttorney; | ||||
|  | ||||
|  public: | ||||
|   | ||||
| @@ -26,7 +26,7 @@ class PairPtr { | ||||
| }; | ||||
|  | ||||
| class ObjectIterator { | ||||
|   friend class ObjectRef; | ||||
|   friend class JsonObject; | ||||
|  | ||||
|  public: | ||||
|   ObjectIterator() : _slot(0) {} | ||||
| @@ -81,7 +81,7 @@ class PairConstPtr { | ||||
| }; | ||||
|  | ||||
| class ObjectConstIterator { | ||||
|   friend class ObjectRef; | ||||
|   friend class JsonObject; | ||||
|  | ||||
|  public: | ||||
|   ObjectConstIterator() : _slot(0) {} | ||||
|   | ||||
| @@ -20,7 +20,7 @@ namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| // Forward declarations. | ||||
| class JsonArray; | ||||
| class ObjectRef; | ||||
| class JsonObject; | ||||
|  | ||||
| class VariantConstRef : public VariantTag, | ||||
|                         public VariantOperators<VariantConstRef> { | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #include <ArduinoJson/Configuration.hpp> | ||||
| #include <ArduinoJson/Numbers/convertNumber.hpp> | ||||
| #include <ArduinoJson/Numbers/parseNumber.hpp> | ||||
| #include <ArduinoJson/Object/ObjectRef.hpp> | ||||
| #include <ArduinoJson/Object/JsonObject.hpp> | ||||
| #include <ArduinoJson/Variant/VariantRef.hpp> | ||||
|  | ||||
| #include <string.h>  // for strcmp | ||||
| @@ -128,9 +128,9 @@ VariantRefBase<TDerived>::to() const { | ||||
|  | ||||
| template <typename TDerived> | ||||
| template <typename T> | ||||
| typename enable_if<is_same<T, ObjectRef>::value, ObjectRef>::type | ||||
| typename enable_if<is_same<T, JsonObject>::value, JsonObject>::type | ||||
| VariantRefBase<TDerived>::to() const { | ||||
|   return ObjectRef(getPool(), variantToObject(getOrCreateData())); | ||||
|   return JsonObject(getPool(), variantToObject(getOrCreateData())); | ||||
| } | ||||
|  | ||||
| template <typename TDerived> | ||||
|   | ||||
| @@ -78,9 +78,10 @@ class VariantRefBase : public VariantTag { | ||||
|   template <typename T> | ||||
|   typename enable_if<is_same<T, JsonArray>::value, JsonArray>::type to() const; | ||||
|   // | ||||
|   // ObjectRef to<ObjectRef>() | ||||
|   // JsonObject to<JsonObject>() | ||||
|   template <typename T> | ||||
|   typename enable_if<is_same<T, ObjectRef>::value, ObjectRef>::type to() const; | ||||
|   typename enable_if<is_same<T, JsonObject>::value, JsonObject>::type to() | ||||
|       const; | ||||
|   // | ||||
|   // VariantRef to<VariantRef>() | ||||
|   template <typename T> | ||||
| @@ -200,7 +201,7 @@ class VariantRefBase : public VariantTag { | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE JsonArray createNestedArray() const; | ||||
|   FORCE_INLINE ObjectRef createNestedObject() const; | ||||
|   FORCE_INLINE JsonObject createNestedObject() const; | ||||
|   FORCE_INLINE ElementProxy<TDerived> operator[](size_t index) const; | ||||
|  | ||||
|   template <typename TString> | ||||
| @@ -228,10 +229,10 @@ class VariantRefBase : public VariantTag { | ||||
|   FORCE_INLINE JsonArray createNestedArray(TChar* key) const; | ||||
|  | ||||
|   template <typename TString> | ||||
|   ObjectRef createNestedObject(const TString& key) const; | ||||
|   JsonObject createNestedObject(const TString& key) const; | ||||
|  | ||||
|   template <typename TChar> | ||||
|   ObjectRef createNestedObject(TChar* key) const; | ||||
|   JsonObject createNestedObject(TChar* key) const; | ||||
|  | ||||
|  private: | ||||
|   TDerived& derived() { | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| class JsonArray; | ||||
| class ObjectRef; | ||||
| class JsonObject; | ||||
| class VariantRef; | ||||
|  | ||||
| // A metafunction that returns the type of the value returned by | ||||
| @@ -21,8 +21,8 @@ struct VariantTo<JsonArray> { | ||||
|   typedef JsonArray type; | ||||
| }; | ||||
| template <> | ||||
| struct VariantTo<ObjectRef> { | ||||
|   typedef ObjectRef type; | ||||
| struct VariantTo<JsonObject> { | ||||
|   typedef JsonObject type; | ||||
| }; | ||||
| template <> | ||||
| struct VariantTo<VariantRef> { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user