mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Remove getElement(), getOrAddElement(), getMember(), and getOrAddMember()
				
					
				
			This commit is contained in:
		
							
								
								
									
										20
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -9,6 +9,26 @@ HEAD | |||||||
| * Fix comparison operators for `JsonArray`, `JsonArrayConst`, `JsonObject`, and `JsonObjectConst` | * Fix comparison operators for `JsonArray`, `JsonArrayConst`, `JsonObject`, and `JsonObjectConst` | ||||||
| * Remove undocumented `accept()` functions | * Remove undocumented `accept()` functions | ||||||
| * Rename `addElement()` to `add()` | * Rename `addElement()` to `add()` | ||||||
|  | * Remove `getElement()`, `getOrAddElement()`, `getMember()`, and `getOrAddMember()` | ||||||
|  |  | ||||||
|  | > ### BREAKING CHANGES | ||||||
|  | > | ||||||
|  | > This release hides `JsonVariant`'s functions that were only intended for internal use. | ||||||
|  | > If you were using them in your programs, you must replace with `operator[]` and `to<JsonVariant>()`, like so: | ||||||
|  | > | ||||||
|  | > ```c++ | ||||||
|  | > // before | ||||||
|  | > JsonVariant a = variant.getElement(idx); | ||||||
|  | > JsonVariant b = variant.getOrAddElement(idx); | ||||||
|  | > JsonVariant c = variant.getMember(key); | ||||||
|  | > JsonVariant d = variant.getOrAddMember(key); | ||||||
|  | > | ||||||
|  | > // after | ||||||
|  | > JsonVariant a = variant[idx]; | ||||||
|  | > JsonVariant b = variant[idx].to<JsonVariant>(); | ||||||
|  | > JsonVariant c = variant[key]; | ||||||
|  | > JsonVariant d = variant[key].to<JsonVariant>(); | ||||||
|  | > ``` | ||||||
|  |  | ||||||
| v6.19.4 (2022-04-05) | v6.19.4 (2022-04-05) | ||||||
| ------- | ------- | ||||||
|   | |||||||
| @@ -9,7 +9,6 @@ add_executable(JsonArrayTests | |||||||
| 	copyArray.cpp | 	copyArray.cpp | ||||||
| 	createNested.cpp | 	createNested.cpp | ||||||
| 	equals.cpp | 	equals.cpp | ||||||
| 	get.cpp |  | ||||||
| 	isNull.cpp | 	isNull.cpp | ||||||
| 	iterator.cpp | 	iterator.cpp | ||||||
| 	memoryUsage.cpp | 	memoryUsage.cpp | ||||||
|   | |||||||
| @@ -1,16 +0,0 @@ | |||||||
| // ArduinoJson - https://arduinojson.org |  | ||||||
| // Copyright © 2014-2022, Benoit BLANCHON |  | ||||||
| // MIT License |  | ||||||
|  |  | ||||||
| #include <ArduinoJson.h> |  | ||||||
| #include <catch.hpp> |  | ||||||
|  |  | ||||||
| TEST_CASE("JsonArray::get()") { |  | ||||||
|   DynamicJsonDocument doc(4096); |  | ||||||
|   deserializeJson(doc, "[1,2,3]"); |  | ||||||
|   JsonArray array = doc.as<JsonArray>(); |  | ||||||
|  |  | ||||||
|   SECTION("Overflow") { |  | ||||||
|     REQUIRE(array.getElement(3).isNull()); |  | ||||||
|   } |  | ||||||
| } |  | ||||||
| @@ -96,10 +96,6 @@ class ArrayConstRef : public ArrayRefBase<const CollectionData>, | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef operator[](size_t index) const { |   FORCE_INLINE VariantConstRef operator[](size_t index) const { | ||||||
|     return getElementConst(index); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef getElementConst(size_t index) const { |  | ||||||
|     return VariantConstRef(_data ? _data->getElement(index) : 0); |     return VariantConstRef(_data ? _data->getElement(index) : 0); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
| @@ -152,21 +148,6 @@ class ArrayRef : public ArrayRefBase<CollectionData>, | |||||||
|     return ArrayConstRef(_data) == ArrayConstRef(rhs._data); |     return ArrayConstRef(_data) == ArrayConstRef(rhs._data); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // Internal use |  | ||||||
|   FORCE_INLINE VariantRef getOrAddElement(size_t index) const { |  | ||||||
|     return VariantRef(_pool, _data ? _data->getOrAddElement(index, _pool) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Gets the value at the specified index. |  | ||||||
|   FORCE_INLINE VariantRef getElement(size_t index) const { |  | ||||||
|     return VariantRef(_pool, _data ? _data->getElement(index) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Gets the value at the specified index. |  | ||||||
|   FORCE_INLINE VariantConstRef getElementConst(size_t index) const { |  | ||||||
|     return VariantConstRef(_data ? _data->getElement(index) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // Removes element at specified position. |   // Removes element at specified position. | ||||||
|   FORCE_INLINE void remove(iterator it) const { |   FORCE_INLINE void remove(iterator it) const { | ||||||
|     if (!_data) |     if (!_data) | ||||||
| @@ -187,6 +168,18 @@ class ArrayRef : public ArrayRefBase<CollectionData>, | |||||||
|     _data->clear(); |     _data->clear(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   MemoryPool* getPool() const { | ||||||
|  |     return _pool; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData* getData() const { | ||||||
|  |     return collectionToVariant(_data); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData* getOrCreateData() const { | ||||||
|  |     return collectionToVariant(_data); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool* _pool; |   MemoryPool* _pool; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -135,54 +135,12 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >, | |||||||
|     return getUpstreamElementConst().memoryUsage(); |     return getUpstreamElementConst().memoryUsage(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   template <typename TNestedKey> |  | ||||||
|   VariantRef getMember(TNestedKey* key) const { |  | ||||||
|     return getUpstreamElement().getMember(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TNestedKey> |  | ||||||
|   VariantRef getMember(const TNestedKey& key) const { |  | ||||||
|     return getUpstreamElement().getMember(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TNestedKey> |  | ||||||
|   VariantConstRef getMemberConst(TNestedKey* key) const { |  | ||||||
|     return getUpstreamElementConst().getMemberConst(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TNestedKey> |  | ||||||
|   VariantConstRef getMemberConst(const TNestedKey& key) const { |  | ||||||
|     return getUpstreamElementConst().getMemberConst(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TNestedKey> |  | ||||||
|   VariantRef getOrAddMember(TNestedKey* key) const { |  | ||||||
|     return getOrAddUpstreamElement().getOrAddMember(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   template <typename TNestedKey> |  | ||||||
|   VariantRef getOrAddMember(const TNestedKey& key) const { |  | ||||||
|     return getOrAddUpstreamElement().getOrAddMember(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   VariantRef add() const { |   VariantRef add() const { | ||||||
|     return getOrAddUpstreamElement().add(); |     return getOrAddUpstreamElement().add(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   using ArrayShortcuts<ElementProxy<TArray> >::add; |   using ArrayShortcuts<ElementProxy<TArray> >::add; | ||||||
|  |  | ||||||
|   VariantRef getElement(size_t index) const { |  | ||||||
|     return getOrAddUpstreamElement().getElement(index); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   VariantConstRef getElementConst(size_t index) const { |  | ||||||
|     return getUpstreamElementConst().getElementConst(index); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   VariantRef getOrAddElement(size_t index) const { |  | ||||||
|     return getOrAddUpstreamElement().getOrAddElement(index); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE void remove(size_t index) const { |   FORCE_INLINE void remove(size_t index) const { | ||||||
|     getUpstreamElement().remove(index); |     getUpstreamElement().remove(index); | ||||||
|   } |   } | ||||||
| @@ -202,17 +160,30 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >, | |||||||
|     getUpstreamElement().remove(key); |     getUpstreamElement().remove(key); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   FORCE_INLINE MemoryPool* getPool() const { | ||||||
|  |     return _array.getPool(); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   FORCE_INLINE VariantData* getData() const { | ||||||
|  |     return variantGetElement(_array.getData(), _index); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   FORCE_INLINE VariantData* getOrCreateData() const { | ||||||
|  |     return variantGetOrAddElement(_array.getOrCreateData(), _index, | ||||||
|  |                                   _array.getPool()); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   FORCE_INLINE VariantRef getUpstreamElement() const { |   FORCE_INLINE VariantRef getUpstreamElement() const { | ||||||
|     return _array.getElement(_index); |     return VariantRef(getPool(), getData()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef getUpstreamElementConst() const { |   FORCE_INLINE VariantConstRef getUpstreamElementConst() const { | ||||||
|     return _array.getElementConst(_index); |     return VariantConstRef(getData()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef getOrAddUpstreamElement() const { |   FORCE_INLINE VariantRef getOrAddUpstreamElement() const { | ||||||
|     return _array.getOrAddElement(_index); |     return VariantRef(getPool(), getOrCreateData()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   friend void convertToJson(const this_type& src, VariantRef dst) { |   friend void convertToJson(const this_type& src, VariantRef dst) { | ||||||
|   | |||||||
| @@ -100,14 +100,14 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   // createNestedArray(const __FlashStringHelper*) |   // createNestedArray(const __FlashStringHelper*) | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   ArrayRef createNestedArray(TChar* key) { |   ArrayRef createNestedArray(TChar* key) { | ||||||
|     return getOrAddMember(key).template to<ArrayRef>(); |     return operator[](key).template to<ArrayRef>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // createNestedArray(const std::string&) |   // createNestedArray(const std::string&) | ||||||
|   // createNestedArray(const String&) |   // createNestedArray(const String&) | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   ArrayRef createNestedArray(const TString& key) { |   ArrayRef createNestedArray(const TString& key) { | ||||||
|     return getOrAddMember(key).template to<ArrayRef>(); |     return operator[](key).template to<ArrayRef>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   ObjectRef createNestedObject() { |   ObjectRef createNestedObject() { | ||||||
| @@ -119,14 +119,14 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   // createNestedObject(const __FlashStringHelper*) |   // createNestedObject(const __FlashStringHelper*) | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   ObjectRef createNestedObject(TChar* key) { |   ObjectRef createNestedObject(TChar* key) { | ||||||
|     return getOrAddMember(key).template to<ObjectRef>(); |     return operator[](key).template to<ObjectRef>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // createNestedObject(const std::string&) |   // createNestedObject(const std::string&) | ||||||
|   // createNestedObject(const String&) |   // createNestedObject(const String&) | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   ObjectRef createNestedObject(const TString& key) { |   ObjectRef createNestedObject(const TString& key) { | ||||||
|     return getOrAddMember(key).template to<ObjectRef>(); |     return operator[](key).template to<ObjectRef>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // containsKey(char*) const |   // containsKey(char*) const | ||||||
| @@ -134,14 +134,14 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   // containsKey(const __FlashStringHelper*) const |   // containsKey(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   bool containsKey(TChar* key) const { |   bool containsKey(TChar* key) const { | ||||||
|     return !getMemberConst(key).isUnbound(); |     return _data.getMember(adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // containsKey(const std::string&) const |   // containsKey(const std::string&) const | ||||||
|   // containsKey(const String&) const |   // containsKey(const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   bool containsKey(const TString& key) const { |   bool containsKey(const TString& key) const { | ||||||
|     return !getMemberConst(key).isUnbound(); |     return _data.getMember(adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // operator[](const std::string&) |   // operator[](const std::string&) | ||||||
| @@ -169,7 +169,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   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 getMemberConst(key); |     return VariantConstRef(_data.getMember(adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // operator[](char*) const |   // operator[](char*) const | ||||||
| @@ -179,7 +179,7 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   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 getMemberConst(key); |     return VariantConstRef(_data.getMember(adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE ElementProxy<JsonDocument&> operator[](size_t index) { |   FORCE_INLINE ElementProxy<JsonDocument&> operator[](size_t index) { | ||||||
| @@ -187,73 +187,9 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef operator[](size_t index) const { |   FORCE_INLINE VariantConstRef operator[](size_t index) const { | ||||||
|     return getElementConst(index); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef getElement(size_t index) { |  | ||||||
|     return VariantRef(&_pool, _data.getElement(index)); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef getElementConst(size_t index) const { |  | ||||||
|     return VariantConstRef(_data.getElement(index)); |     return VariantConstRef(_data.getElement(index)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef getOrAddElement(size_t index) { |  | ||||||
|     return VariantRef(&_pool, _data.getOrAddElement(index, &_pool)); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // JsonVariantConst getMemberConst(char*) const |  | ||||||
|   // JsonVariantConst getMemberConst(const char*) const |  | ||||||
|   // JsonVariantConst getMemberConst(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(TChar* key) const { |  | ||||||
|     return VariantConstRef(_data.getMember(adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // JsonVariantConst getMemberConst(const std::string&) const |  | ||||||
|   // JsonVariantConst getMemberConst(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE |  | ||||||
|       typename enable_if<IsString<TString>::value, VariantConstRef>::type |  | ||||||
|       getMemberConst(const TString& key) const { |  | ||||||
|     return VariantConstRef(_data.getMember(adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // JsonVariant getMember(char*) |  | ||||||
|   // JsonVariant getMember(const char*) |  | ||||||
|   // JsonVariant getMember(const __FlashStringHelper*) |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getMember(TChar* key) { |  | ||||||
|     return VariantRef(&_pool, _data.getMember(adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // JsonVariant getMember(const std::string&) |  | ||||||
|   // JsonVariant getMember(const String&) |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, VariantRef>::type |  | ||||||
|   getMember(const TString& key) { |  | ||||||
|     return VariantRef(&_pool, _data.getMember(adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(char*) |  | ||||||
|   // getOrAddMember(const char*) |  | ||||||
|   // getOrAddMember(const __FlashStringHelper*) |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(TChar* key) { |  | ||||||
|     return VariantRef(&_pool, |  | ||||||
|                       _data.getOrAddMember(adaptString(key), &_pool, |  | ||||||
|                                            getStringStoragePolicy(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(const std::string&) |  | ||||||
|   // getOrAddMember(const String&) |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(const TString& key) { |  | ||||||
|     return VariantRef(&_pool, |  | ||||||
|                       _data.getOrAddMember(adaptString(key), &_pool, |  | ||||||
|                                            getStringStoragePolicy(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef add() { |   FORCE_INLINE VariantRef add() { | ||||||
|     return VariantRef(&_pool, _data.addElement(&_pool)); |     return VariantRef(&_pool, _data.addElement(&_pool)); | ||||||
|   } |   } | ||||||
| @@ -331,6 +267,23 @@ class JsonDocument : public VariantOperators<const JsonDocument&> { | |||||||
|  private: |  private: | ||||||
|   JsonDocument(const JsonDocument&); |   JsonDocument(const JsonDocument&); | ||||||
|   JsonDocument& operator=(const JsonDocument&); |   JsonDocument& operator=(const JsonDocument&); | ||||||
|  |  | ||||||
|  |  public: | ||||||
|  |   MemoryPool* getPool() { | ||||||
|  |     return &_pool; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData* getData() { | ||||||
|  |     return &_data; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   const VariantData* getData() const { | ||||||
|  |     return &_data; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData* getOrCreateData() { | ||||||
|  |     return &_data; | ||||||
|  |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| inline void convertToJson(const JsonDocument& src, VariantRef dst) { | inline void convertToJson(const JsonDocument& src, VariantRef dst) { | ||||||
|   | |||||||
| @@ -160,74 +160,30 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >, | |||||||
|  |  | ||||||
|   using ArrayShortcuts<MemberProxy<TObject, TStringRef> >::add; |   using ArrayShortcuts<MemberProxy<TObject, TStringRef> >::add; | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef getElement(size_t index) const { |   FORCE_INLINE MemoryPool *getPool() const { | ||||||
|     return getUpstreamMember().getElement(index); |     return _object.getPool(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef getElementConst(size_t index) const { |   FORCE_INLINE VariantData *getData() const { | ||||||
|     return getUpstreamMemberConst().getElementConst(index); |     return variantGetMember(_object.getData(), adaptString(_key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef getOrAddElement(size_t index) const { |   FORCE_INLINE VariantData *getOrCreateData() const { | ||||||
|     return getOrAddUpstreamMember().getOrAddElement(index); |     return variantGetOrAddMember(_object.getOrCreateData(), _key, | ||||||
|   } |                                  _object.getPool()); | ||||||
|  |  | ||||||
|   // getMember(char*) const |  | ||||||
|   // getMember(const char*) const |  | ||||||
|   // getMember(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getMember(TChar *key) const { |  | ||||||
|     return getUpstreamMember().getMember(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMember(const std::string&) const |  | ||||||
|   // getMember(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantRef getMember(const TString &key) const { |  | ||||||
|     return getUpstreamMember().getMember(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(char*) const |  | ||||||
|   // getMemberConst(const char*) const |  | ||||||
|   // getMemberConst(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(TChar *key) const { |  | ||||||
|     return getUpstreamMemberConst().getMemberConst(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(const std::string&) const |  | ||||||
|   // getMemberConst(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(const TString &key) const { |  | ||||||
|     return getUpstreamMemberConst().getMemberConst(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(char*) const |  | ||||||
|   // getOrAddMember(const char*) const |  | ||||||
|   // getOrAddMember(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(TChar *key) const { |  | ||||||
|     return getOrAddUpstreamMember().getOrAddMember(key); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(const std::string&) const |  | ||||||
|   // getOrAddMember(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(const TString &key) const { |  | ||||||
|     return getOrAddUpstreamMember().getOrAddMember(key); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   FORCE_INLINE VariantRef getUpstreamMember() const { |   FORCE_INLINE VariantRef getUpstreamMember() const { | ||||||
|     return _object.getMember(_key); |     return VariantRef(getPool(), getData()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef getUpstreamMemberConst() const { |   FORCE_INLINE VariantConstRef getUpstreamMemberConst() const { | ||||||
|     return _object.getMemberConst(_key); |     return VariantConstRef(getData()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef getOrAddUpstreamMember() const { |   FORCE_INLINE VariantRef getOrAddUpstreamMember() const { | ||||||
|     return _object.getOrAddMember(_key); |     return VariantRef(getPool(), getOrCreateData()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   friend void convertToJson(const this_type &src, VariantRef dst) { |   friend void convertToJson(const this_type &src, VariantRef dst) { | ||||||
|   | |||||||
| @@ -22,14 +22,4 @@ void objectRemove(CollectionData *obj, TAdaptedString key) { | |||||||
|     return; |     return; | ||||||
|   obj->removeMember(key); |   obj->removeMember(key); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TAdaptedString, typename TStoragePolicy> |  | ||||||
| inline VariantData *objectGetOrAddMember(CollectionData *obj, |  | ||||||
|                                          TAdaptedString key, MemoryPool *pool, |  | ||||||
|                                          TStoragePolicy storage_policy) { |  | ||||||
|   if (!obj) |  | ||||||
|     return 0; |  | ||||||
|  |  | ||||||
|   return obj->getOrAddMember(key, pool, storage_policy); |  | ||||||
| } |  | ||||||
| }  // namespace ARDUINOJSON_NAMESPACE | }  // namespace ARDUINOJSON_NAMESPACE | ||||||
|   | |||||||
| @@ -13,41 +13,41 @@ template <typename TObject> | |||||||
| template <typename TString> | template <typename TString> | ||||||
| inline ArrayRef ObjectShortcuts<TObject>::createNestedArray( | inline ArrayRef ObjectShortcuts<TObject>::createNestedArray( | ||||||
|     const TString& key) const { |     const TString& key) const { | ||||||
|   return impl()->getOrAddMember(key).template to<ArrayRef>(); |   return impl()->operator[](key).template to<ArrayRef>(); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TObject> | template <typename TObject> | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline ArrayRef ObjectShortcuts<TObject>::createNestedArray(TChar* key) const { | inline ArrayRef ObjectShortcuts<TObject>::createNestedArray(TChar* key) const { | ||||||
|   return impl()->getOrAddMember(key).template to<ArrayRef>(); |   return impl()->operator[](key).template to<ArrayRef>(); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TObject> | template <typename TObject> | ||||||
| template <typename TString> | template <typename TString> | ||||||
| inline ObjectRef ObjectShortcuts<TObject>::createNestedObject( | inline ObjectRef ObjectShortcuts<TObject>::createNestedObject( | ||||||
|     const TString& key) const { |     const TString& key) const { | ||||||
|   return impl()->getOrAddMember(key).template to<ObjectRef>(); |   return impl()->operator[](key).template to<ObjectRef>(); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TObject> | template <typename TObject> | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline ObjectRef ObjectShortcuts<TObject>::createNestedObject( | inline ObjectRef ObjectShortcuts<TObject>::createNestedObject( | ||||||
|     TChar* key) const { |     TChar* key) const { | ||||||
|   return impl()->getOrAddMember(key).template to<ObjectRef>(); |   return impl()->operator[](key).template to<ObjectRef>(); | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TObject> | template <typename TObject> | ||||||
| template <typename TString> | template <typename TString> | ||||||
| inline typename enable_if<IsString<TString>::value, bool>::type | inline typename enable_if<IsString<TString>::value, bool>::type | ||||||
| ObjectShortcuts<TObject>::containsKey(const TString& key) const { | ObjectShortcuts<TObject>::containsKey(const TString& key) const { | ||||||
|   return !impl()->getMemberConst(key).isUnbound(); |   return variantGetMember(impl()->getData(), adaptString(key)) != 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TObject> | template <typename TObject> | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| inline typename enable_if<IsString<TChar*>::value, bool>::type | inline typename enable_if<IsString<TChar*>::value, bool>::type | ||||||
| ObjectShortcuts<TObject>::containsKey(TChar* key) const { | ObjectShortcuts<TObject>::containsKey(TChar* key) const { | ||||||
|   return !impl()->getMemberConst(key).isUnbound(); |   return variantGetMember(impl()->getData(), adaptString(key)) != 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TObject> | template <typename TObject> | ||||||
|   | |||||||
| @@ -71,7 +71,7 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>, | |||||||
|   // containsKey(const String&) const |   // containsKey(const String&) const | ||||||
|   template <typename TString> |   template <typename TString> | ||||||
|   FORCE_INLINE bool containsKey(const TString& key) const { |   FORCE_INLINE bool containsKey(const TString& key) const { | ||||||
|     return !getMemberConst(key).isUnbound(); |     return objectGetMember(_data, adaptString(key)) != 0; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // containsKey(char*) const |   // containsKey(char*) const | ||||||
| @@ -79,22 +79,7 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>, | |||||||
|   // containsKey(const __FlashStringHelper*) const |   // containsKey(const __FlashStringHelper*) const | ||||||
|   template <typename TChar> |   template <typename TChar> | ||||||
|   FORCE_INLINE bool containsKey(TChar* key) const { |   FORCE_INLINE bool containsKey(TChar* key) const { | ||||||
|     return !getMemberConst(key).isUnbound(); |     return objectGetMember(_data, adaptString(key)) != 0; | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(const std::string&) const |  | ||||||
|   // getMemberConst(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(const TString& key) const { |  | ||||||
|     return VariantConstRef(objectGetMember(_data, adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(char*) const |  | ||||||
|   // getMemberConst(const char*) const |  | ||||||
|   // getMemberConst(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(TChar* key) const { |  | ||||||
|     return VariantConstRef(objectGetMember(_data, adaptString(key))); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // operator[](const std::string&) const |   // operator[](const std::string&) const | ||||||
| @@ -103,7 +88,7 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>, | |||||||
|   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 getMemberConst(key); |     return VariantConstRef(objectGetMember(_data, adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // operator[](char*) const |   // operator[](char*) const | ||||||
| @@ -113,7 +98,7 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>, | |||||||
|   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 getMemberConst(key); |     return VariantConstRef(objectGetMember(_data, adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE bool operator==(ObjectConstRef rhs) const { |   FORCE_INLINE bool operator==(ObjectConstRef rhs) const { | ||||||
| @@ -178,55 +163,6 @@ class ObjectRef : public ObjectRefBase<CollectionData>, | |||||||
|     return _data->copyFrom(*src._data, _pool); |     return _data->copyFrom(*src._data, _pool); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // getMember(const std::string&) const |  | ||||||
|   // getMember(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantRef getMember(const TString& key) const { |  | ||||||
|     return VariantRef(_pool, objectGetMember(_data, adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMember(char*) const |  | ||||||
|   // getMember(const char*) const |  | ||||||
|   // getMember(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getMember(TChar* key) const { |  | ||||||
|     return VariantRef(_pool, objectGetMember(_data, adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(const std::string&) const |  | ||||||
|   // getMemberConst(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(const TString& key) const { |  | ||||||
|     return VariantConstRef(objectGetMember(_data, adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(char*) const |  | ||||||
|   // getMemberConst(const char*) const |  | ||||||
|   // getMemberConst(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(TChar* key) const { |  | ||||||
|     return VariantConstRef(objectGetMember(_data, adaptString(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(const std::string&) const |  | ||||||
|   // getOrAddMember(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(const TString& key) const { |  | ||||||
|     return VariantRef(_pool, |  | ||||||
|                       objectGetOrAddMember(_data, adaptString(key), _pool, |  | ||||||
|                                            getStringStoragePolicy(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(char*) const |  | ||||||
|   // getOrAddMember(const char*) const |  | ||||||
|   // getOrAddMember(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(TChar* key) const { |  | ||||||
|     return VariantRef(_pool, |  | ||||||
|                       objectGetOrAddMember(_data, adaptString(key), _pool, |  | ||||||
|                                            getStringStoragePolicy(key))); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE bool operator==(ObjectRef rhs) const { |   FORCE_INLINE bool operator==(ObjectRef rhs) const { | ||||||
|     return ObjectConstRef(_data) == ObjectConstRef(rhs._data); |     return ObjectConstRef(_data) == ObjectConstRef(rhs._data); | ||||||
|   } |   } | ||||||
| @@ -252,6 +188,18 @@ class ObjectRef : public ObjectRefBase<CollectionData>, | |||||||
|     objectRemove(_data, adaptString(key)); |     objectRemove(_data, adaptString(key)); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   MemoryPool* getPool() const { | ||||||
|  |     return _pool; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData* getData() const { | ||||||
|  |     return collectionToVariant(_data); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData* getOrCreateData() const { | ||||||
|  |     return collectionToVariant(_data); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool* _pool; |   MemoryPool* _pool; | ||||||
| }; | }; | ||||||
|   | |||||||
| @@ -59,6 +59,10 @@ inline CollectionData *variantToObject(VariantData *var) { | |||||||
|   return &var->toObject(); |   return &var->toObject(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | inline VariantData *variantGetElement(const VariantData *var, size_t index) { | ||||||
|  |   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; | ||||||
| @@ -70,9 +74,18 @@ inline NO_INLINE VariantData *variantGetOrAddElement(VariantData *var, | |||||||
|   return var != 0 ? var->getOrAddElement(index, pool) : 0; |   return var != 0 ? var->getOrAddElement(index, pool) : 0; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | template <typename AdaptedString> | ||||||
|  | VariantData *variantGetMember(const VariantData *var, AdaptedString key) { | ||||||
|  |   if (!var) | ||||||
|  |     return 0; | ||||||
|  |   return var->getMember(key); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | // TODO: this function is inconsitent with the others: | ||||||
|  | // it should take an adapted string | ||||||
| template <typename TChar> | template <typename TChar> | ||||||
| NO_INLINE 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, | ||||||
| @@ -80,9 +93,8 @@ NO_INLINE VariantData *variantGetOrAddMember(VariantData *var, TChar *key, | |||||||
| } | } | ||||||
|  |  | ||||||
| template <typename TString> | template <typename TString> | ||||||
| NO_INLINE VariantData *variantGetOrAddMember(VariantData *var, | VariantData *variantGetOrAddMember(VariantData *var, const TString &key, | ||||||
|                                              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, | ||||||
|   | |||||||
| @@ -116,27 +116,8 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|     return as<T>(); |     return as<T>(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef getElementConst(size_t index) const { |  | ||||||
|     return VariantConstRef(_data != 0 ? _data->getElement(index) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef operator[](size_t index) const { |   FORCE_INLINE VariantConstRef operator[](size_t index) const { | ||||||
|     return getElementConst(index); |     return VariantConstRef(variantGetElement(_data, index)); | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(const std::string&) const |  | ||||||
|   // getMemberConst(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(const TString &key) const { |  | ||||||
|     return VariantConstRef(_data ? _data->getMember(adaptString(key)) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(char*) const |  | ||||||
|   // getMemberConst(const char*) const |  | ||||||
|   // getMemberConst(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(TChar *key) const { |  | ||||||
|     return VariantConstRef(_data ? _data->getMember(adaptString(key)) : 0); |  | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // operator[](const std::string&) const |   // operator[](const std::string&) const | ||||||
| @@ -145,7 +126,7 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|   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 getMemberConst(key); |     return VariantConstRef(variantGetMember(_data, adaptString(key))); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|   // operator[](char*) const |   // operator[](char*) const | ||||||
| @@ -155,7 +136,11 @@ class VariantConstRef : public VariantRefBase<const VariantData>, | |||||||
|   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 getMemberConst(key); |     return VariantConstRef(variantGetMember(_data, adaptString(key))); | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   const VariantData *getData() const { | ||||||
|  |     return _data; | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -275,62 +260,6 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|  |  | ||||||
|   using ArrayShortcuts<VariantRef>::add; |   using ArrayShortcuts<VariantRef>::add; | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantConstRef getElementConst(size_t index) const { |  | ||||||
|     return VariantConstRef(_data != 0 ? _data->getElement(index) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE VariantRef getOrAddElement(size_t index) const { |  | ||||||
|     return VariantRef(_pool, variantGetOrAddElement(_data, index, _pool)); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMember(const char*) const |  | ||||||
|   // getMember(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getMember(TChar *key) const { |  | ||||||
|     return VariantRef(_pool, |  | ||||||
|                       _data != 0 ? _data->getMember(adaptString(key)) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMember(const std::string&) const |  | ||||||
|   // getMember(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, VariantRef>::type |  | ||||||
|   getMember(const TString &key) const { |  | ||||||
|     return VariantRef(_pool, |  | ||||||
|                       _data != 0 ? _data->getMember(adaptString(key)) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(const char*) const |  | ||||||
|   // getMemberConst(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantConstRef getMemberConst(TChar *key) const { |  | ||||||
|     return VariantConstRef(_data ? _data->getMember(adaptString(key)) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getMemberConst(const std::string&) const |  | ||||||
|   // getMemberConst(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE |  | ||||||
|       typename enable_if<IsString<TString>::value, VariantConstRef>::type |  | ||||||
|       getMemberConst(const TString &key) const { |  | ||||||
|     return VariantConstRef(_data ? _data->getMember(adaptString(key)) : 0); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(char*) const |  | ||||||
|   // getOrAddMember(const char*) const |  | ||||||
|   // getOrAddMember(const __FlashStringHelper*) const |  | ||||||
|   template <typename TChar> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(TChar *key) const { |  | ||||||
|     return VariantRef(_pool, variantGetOrAddMember(_data, key, _pool)); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   // getOrAddMember(const std::string&) const |  | ||||||
|   // getOrAddMember(const String&) const |  | ||||||
|   template <typename TString> |  | ||||||
|   FORCE_INLINE VariantRef getOrAddMember(const TString &key) const { |  | ||||||
|     return VariantRef(_pool, variantGetOrAddMember(_data, key, _pool)); |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   FORCE_INLINE void remove(size_t index) const { |   FORCE_INLINE void remove(size_t index) const { | ||||||
|     if (_data) |     if (_data) | ||||||
|       _data->remove(index); |       _data->remove(index); | ||||||
| @@ -356,13 +285,25 @@ class VariantRef : public VariantRefBase<VariantData>, | |||||||
|   inline void shallowCopy(VariantConstRef target) { |   inline void shallowCopy(VariantConstRef target) { | ||||||
|     if (!_data) |     if (!_data) | ||||||
|       return; |       return; | ||||||
|     const VariantData *targetData = getData(target); |     const VariantData *targetData = target.getData(); | ||||||
|     if (targetData) |     if (targetData) | ||||||
|       *_data = *targetData; |       *_data = *targetData; | ||||||
|     else |     else | ||||||
|       _data->setNull(); |       _data->setNull(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   MemoryPool *getPool() const { | ||||||
|  |     return _pool; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData *getData() const { | ||||||
|  |     return _data; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   VariantData *getOrCreateData() const { | ||||||
|  |     return _data; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  private: |  private: | ||||||
|   MemoryPool *_pool; |   MemoryPool *_pool; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user