mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 08:42:39 +01:00 
			
		
		
		
	Remove ArrayShortcuts and ObjectShortcuts
				
					
				
			This commit is contained in:
		| @@ -9,21 +9,25 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| template <typename TArray> | ||||
| inline ArrayRef ArrayShortcuts<TArray>::createNestedArray() const { | ||||
|   return impl()->add().template to<ArrayRef>(); | ||||
| inline ObjectRef ArrayRef::createNestedObject() const { | ||||
|   return add().to<ObjectRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TArray> | ||||
| inline ObjectRef ArrayShortcuts<TArray>::createNestedObject() const { | ||||
|   return impl()->add().template to<ObjectRef>(); | ||||
| template <typename TDataSource> | ||||
| inline ArrayRef VariantRefBase<TDataSource>::createNestedArray() const { | ||||
|   return add().template to<ArrayRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TArray> | ||||
| inline VariantProxy<ElementDataSource<TArray> > | ||||
| ArrayShortcuts<TArray>::operator[](size_t index) const { | ||||
|   return VariantProxy<ElementDataSource<TArray> >( | ||||
|       ElementDataSource<TArray>(*impl(), index)); | ||||
| template <typename TDataSource> | ||||
| inline ObjectRef VariantRefBase<TDataSource>::createNestedObject() const { | ||||
|   return add().template to<ObjectRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TDataSource> | ||||
| inline VariantProxy<ElementDataSource<VariantRefBase<TDataSource> > > | ||||
| VariantRefBase<TDataSource>::operator[](size_t index) const { | ||||
|   return VariantProxy<ElementDataSource<VariantRefBase<TDataSource> > >( | ||||
|       ElementDataSource<VariantRefBase<TDataSource> >(*this, index)); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
|  | ||||
| #include <ArduinoJson/Array/ArrayFunctions.hpp> | ||||
| #include <ArduinoJson/Array/ArrayIterator.hpp> | ||||
| #include <ArduinoJson/Array/ElementProxy.hpp> | ||||
| #include <ArduinoJson/Variant/VariantAttorney.hpp> | ||||
| #include <ArduinoJson/Variant/VariantData.hpp> | ||||
|  | ||||
| @@ -106,7 +107,6 @@ class ArrayConstRef : public ArrayRefBase<const CollectionData>, | ||||
| }; | ||||
|  | ||||
| class ArrayRef : public ArrayRefBase<CollectionData>, | ||||
|                  public ArrayShortcuts<ArrayRef>, | ||||
|                  public VariantOperators<ArrayRef> { | ||||
|   typedef ArrayRefBase<CollectionData> base_type; | ||||
|  | ||||
| @@ -132,7 +132,15 @@ class ArrayRef : public ArrayRefBase<CollectionData>, | ||||
|     return VariantRef(_pool, arrayAdd(_data, _pool)); | ||||
|   } | ||||
|  | ||||
|   using ArrayShortcuts<ArrayRef>::add; | ||||
|   template <typename T> | ||||
|   FORCE_INLINE bool add(const T& value) const { | ||||
|     return add().set(value); | ||||
|   } | ||||
|  | ||||
|   template <typename T> | ||||
|   FORCE_INLINE bool add(T* value) const { | ||||
|     return add().set(value); | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE iterator begin() const { | ||||
|     if (!_data) | ||||
| @@ -175,6 +183,19 @@ class ArrayRef : public ArrayRefBase<CollectionData>, | ||||
|     _data->clear(); | ||||
|   } | ||||
|  | ||||
|   // Returns the element at specified index if the variant is an array. | ||||
|   FORCE_INLINE VariantProxy<ElementDataSource<ArrayRef> > operator[]( | ||||
|       size_t index) const { | ||||
|     return VariantProxy<ElementDataSource<ArrayRef> >( | ||||
|         ElementDataSource<ArrayRef>(*this, index)); | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE ObjectRef createNestedObject() const; | ||||
|  | ||||
|   FORCE_INLINE ArrayRef createNestedArray() const { | ||||
|     return add().to<ArrayRef>(); | ||||
|   } | ||||
|  | ||||
|  protected: | ||||
|   MemoryPool* getPool() const { | ||||
|     return _pool; | ||||
|   | ||||
| @@ -1,54 +0,0 @@ | ||||
| // ArduinoJson - https://arduinojson.org | ||||
| // Copyright © 2014-2022, Benoit BLANCHON | ||||
| // MIT License | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/attributes.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| // Forward declarations. | ||||
| class ArrayRef; | ||||
| class ObjectRef; | ||||
|  | ||||
| template <typename> | ||||
| class ElementDataSource; | ||||
|  | ||||
| template <typename> | ||||
| class VariantProxy; | ||||
|  | ||||
| template <typename TArray> | ||||
| class ArrayShortcuts { | ||||
|  public: | ||||
|   // Returns the element at specified index if the variant is an array. | ||||
|   FORCE_INLINE VariantProxy<ElementDataSource<TArray> > operator[]( | ||||
|       size_t index) const; | ||||
|  | ||||
|   FORCE_INLINE ObjectRef createNestedObject() const; | ||||
|  | ||||
|   FORCE_INLINE ArrayRef createNestedArray() const; | ||||
|  | ||||
|   // Adds the specified value at the end of the array. | ||||
|   // | ||||
|   // bool add(TValue); | ||||
|   // TValue = bool, long, int, short, float, double, serialized, VariantRef, | ||||
|   //          std::string, String, ObjectRef | ||||
|   template <typename T> | ||||
|   FORCE_INLINE bool add(const T& value) const { | ||||
|     return impl()->add().set(value); | ||||
|   } | ||||
|   // | ||||
|   // bool add(TValue); | ||||
|   // TValue = char*, const char*, const __FlashStringHelper* | ||||
|   template <typename T> | ||||
|   FORCE_INLINE bool add(T* value) const { | ||||
|     return impl()->add().set(value); | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   const TArray* impl() const { | ||||
|     return static_cast<const TArray*>(this); | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| @@ -9,67 +9,78 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TString> | ||||
| inline ArrayRef ObjectShortcuts<TObject>::createNestedArray( | ||||
|     const TString& key) const { | ||||
|   return impl()->operator[](key).template to<ArrayRef>(); | ||||
| inline ArrayRef ObjectRef::createNestedArray(const TString& key) const { | ||||
|   return operator[](key).template to<ArrayRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TChar> | ||||
| inline ArrayRef ObjectShortcuts<TObject>::createNestedArray(TChar* key) const { | ||||
|   return impl()->operator[](key).template to<ArrayRef>(); | ||||
| inline ArrayRef ObjectRef::createNestedArray(TChar* key) const { | ||||
|   return operator[](key).template to<ArrayRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TDataSource> | ||||
| template <typename TString> | ||||
| inline ObjectRef ObjectShortcuts<TObject>::createNestedObject( | ||||
| inline ArrayRef VariantRefBase<TDataSource>::createNestedArray( | ||||
|     const TString& key) const { | ||||
|   return impl()->operator[](key).template to<ObjectRef>(); | ||||
|   return operator[](key).template to<ArrayRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TDataSource> | ||||
| template <typename TChar> | ||||
| inline ObjectRef ObjectShortcuts<TObject>::createNestedObject( | ||||
| inline ArrayRef VariantRefBase<TDataSource>::createNestedArray( | ||||
|     TChar* key) const { | ||||
|   return impl()->operator[](key).template to<ObjectRef>(); | ||||
|   return operator[](key).template to<ArrayRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TDataSource> | ||||
| template <typename TString> | ||||
| inline ObjectRef VariantRefBase<TDataSource>::createNestedObject( | ||||
|     const TString& key) const { | ||||
|   return operator[](key).template to<ObjectRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TDataSource> | ||||
| template <typename TChar> | ||||
| inline ObjectRef VariantRefBase<TDataSource>::createNestedObject( | ||||
|     TChar* key) const { | ||||
|   return operator[](key).template to<ObjectRef>(); | ||||
| } | ||||
|  | ||||
| template <typename TDataSource> | ||||
| template <typename TString> | ||||
| inline typename enable_if<IsString<TString>::value, bool>::type | ||||
| ObjectShortcuts<TObject>::containsKey(const TString& key) const { | ||||
|   return variantGetMember(VariantAttorney::getData(*impl()), | ||||
|                           adaptString(key)) != 0; | ||||
| VariantRefBase<TDataSource>::containsKey(const TString& key) const { | ||||
|   return variantGetMember(VariantAttorney::getData(*this), adaptString(key)) != | ||||
|          0; | ||||
| } | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TDataSource> | ||||
| template <typename TChar> | ||||
| inline typename enable_if<IsString<TChar*>::value, bool>::type | ||||
| ObjectShortcuts<TObject>::containsKey(TChar* key) const { | ||||
|   return variantGetMember(VariantAttorney::getData(*impl()), | ||||
|                           adaptString(key)) != 0; | ||||
| VariantRefBase<TDataSource>::containsKey(TChar* key) const { | ||||
|   return variantGetMember(VariantAttorney::getData(*this), adaptString(key)) != | ||||
|          0; | ||||
| } | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TDataSource> | ||||
| template <typename TString> | ||||
| inline typename enable_if< | ||||
|     IsString<TString*>::value, | ||||
|     VariantProxy<MemberDataSource<TObject, TString*> > >::type | ||||
| ObjectShortcuts<TObject>::operator[](TString* key) const { | ||||
|   return VariantProxy<MemberDataSource<TObject, TString*> >( | ||||
|       MemberDataSource<TObject, TString*>(*impl(), key)); | ||||
| inline typename enable_if<IsString<TString*>::value, | ||||
|                           VariantProxy<MemberDataSource< | ||||
|                               VariantRefBase<TDataSource>, TString*> > >::type | ||||
| VariantRefBase<TDataSource>::operator[](TString* key) const { | ||||
|   return VariantProxy<MemberDataSource<VariantRefBase, TString*> >( | ||||
|       MemberDataSource<VariantRefBase, TString*>(*this, key)); | ||||
| } | ||||
|  | ||||
| template <typename TObject> | ||||
| template <typename TDataSource> | ||||
| template <typename TString> | ||||
| inline | ||||
|     typename enable_if<IsString<TString>::value, | ||||
|                        VariantProxy<MemberDataSource<TObject, TString> > >::type | ||||
|     ObjectShortcuts<TObject>::operator[](const TString& key) const { | ||||
|   return VariantProxy<MemberDataSource<TObject, TString> >( | ||||
|       MemberDataSource<TObject, TString>(*impl(), key)); | ||||
| inline typename enable_if<IsString<TString>::value, | ||||
|                           VariantProxy<MemberDataSource< | ||||
|                               VariantRefBase<TDataSource>, TString> > >::type | ||||
| VariantRefBase<TDataSource>::operator[](const TString& key) const { | ||||
|   return VariantProxy<MemberDataSource<VariantRefBase, TString> >( | ||||
|       MemberDataSource<VariantRefBase, TString>(*this, key)); | ||||
| } | ||||
|  | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
|   | ||||
| @@ -4,6 +4,7 @@ | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/Object/MemberProxy.hpp> | ||||
| #include <ArduinoJson/Object/ObjectFunctions.hpp> | ||||
| #include <ArduinoJson/Object/ObjectIterator.hpp> | ||||
|  | ||||
| @@ -14,6 +15,8 @@ | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| class ArrayRef; | ||||
|  | ||||
| template <typename TData> | ||||
| class ObjectRefBase { | ||||
|   friend class VariantAttorney; | ||||
| @@ -125,7 +128,6 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>, | ||||
| }; | ||||
|  | ||||
| class ObjectRef : public ObjectRefBase<CollectionData>, | ||||
|                   public ObjectShortcuts<ObjectRef>, | ||||
|                   public VariantOperators<ObjectRef> { | ||||
|   typedef ObjectRefBase<CollectionData> base_type; | ||||
|  | ||||
| @@ -173,6 +175,24 @@ class ObjectRef : public ObjectRefBase<CollectionData>, | ||||
|     return ObjectConstRef(_data) == ObjectConstRef(rhs._data); | ||||
|   } | ||||
|  | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if< | ||||
|       IsString<TString>::value, | ||||
|       VariantProxy<MemberDataSource<ObjectRef, TString> > >::type | ||||
|   operator[](const TString& key) const { | ||||
|     return VariantProxy<MemberDataSource<ObjectRef, TString> >( | ||||
|         MemberDataSource<ObjectRef, TString>(*this, key)); | ||||
|   } | ||||
|  | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if< | ||||
|       IsString<TChar*>::value, | ||||
|       VariantProxy<MemberDataSource<ObjectRef, TChar*> > >::type | ||||
|   operator[](TChar* key) const { | ||||
|     return VariantProxy<MemberDataSource<ObjectRef, TChar*> >( | ||||
|         MemberDataSource<ObjectRef, TChar*>(*this, key)); | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE void remove(iterator it) const { | ||||
|     if (!_data) | ||||
|       return; | ||||
| @@ -194,6 +214,34 @@ class ObjectRef : public ObjectRefBase<CollectionData>, | ||||
|     objectRemove(_data, adaptString(key)); | ||||
|   } | ||||
|  | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type | ||||
|   containsKey(const TString& key) const { | ||||
|     return objectGetMember(_data, adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type | ||||
|   containsKey(TChar* key) const { | ||||
|     return objectGetMember(_data, adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE ArrayRef createNestedArray(const TString& key) const; | ||||
|  | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE ArrayRef createNestedArray(TChar* key) const; | ||||
|  | ||||
|   template <typename TString> | ||||
|   ObjectRef createNestedObject(const TString& key) const { | ||||
|     return operator[](key).template to<ObjectRef>(); | ||||
|   } | ||||
|  | ||||
|   template <typename TChar> | ||||
|   ObjectRef createNestedObject(TChar* key) const { | ||||
|     return operator[](key).template to<ObjectRef>(); | ||||
|   } | ||||
|  | ||||
|  protected: | ||||
|   MemoryPool* getPool() const { | ||||
|     return _pool; | ||||
|   | ||||
| @@ -1,78 +0,0 @@ | ||||
| // ArduinoJson - https://arduinojson.org | ||||
| // Copyright © 2014-2022, Benoit BLANCHON | ||||
| // MIT License | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/Polyfills/attributes.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| template <typename TSource> | ||||
| class VariantProxy; | ||||
|  | ||||
| template <typename TParent, typename TStringRef> | ||||
| class MemberDataSource; | ||||
|  | ||||
| template <typename TObject> | ||||
| class ObjectShortcuts { | ||||
|  public: | ||||
|   // containsKey(const std::string&) const | ||||
|   // containsKey(const String&) const | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type | ||||
|   containsKey(const TString& key) const; | ||||
|  | ||||
|   // containsKey(char*) const | ||||
|   // containsKey(const char*) const | ||||
|   // containsKey(const __FlashStringHelper*) const | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type | ||||
|   containsKey(TChar* key) const; | ||||
|  | ||||
|   // operator[](const std::string&) const | ||||
|   // operator[](const String&) const | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if< | ||||
|       IsString<TString>::value, | ||||
|       VariantProxy<MemberDataSource<TObject, TString> > >::type | ||||
|   operator[](const TString& key) const; | ||||
|  | ||||
|   // operator[](char*) const | ||||
|   // operator[](const char*) const | ||||
|   // operator[](const __FlashStringHelper*) const | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if< | ||||
|       IsString<TChar*>::value, | ||||
|       VariantProxy<MemberDataSource<TObject, TChar*> > >::type | ||||
|   operator[](TChar* key) const; | ||||
|  | ||||
|   // createNestedArray(const std::string&) const | ||||
|   // createNestedArray(const String&) const | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE ArrayRef createNestedArray(const TString& key) const; | ||||
|  | ||||
|   // createNestedArray(char*) const | ||||
|   // createNestedArray(const char*) const | ||||
|   // createNestedArray(const __FlashStringHelper*) const | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE ArrayRef createNestedArray(TChar* key) const; | ||||
|  | ||||
|   // createNestedObject(const std::string&) const | ||||
|   // createNestedObject(const String&) const | ||||
|   template <typename TString> | ||||
|   ObjectRef createNestedObject(const TString& key) const; | ||||
|  | ||||
|   // createNestedObject(char*) const | ||||
|   // createNestedObject(const char*) const | ||||
|   // createNestedObject(const __FlashStringHelper*) const | ||||
|   template <typename TChar> | ||||
|   ObjectRef createNestedObject(TChar* key) const; | ||||
|  | ||||
|  private: | ||||
|   const TObject* impl() const { | ||||
|     return static_cast<const TObject*>(this); | ||||
|   } | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
| @@ -9,12 +9,12 @@ | ||||
|  | ||||
| #include <ArduinoJson/Memory/MemoryPool.hpp> | ||||
| #include <ArduinoJson/Polyfills/type_traits.hpp> | ||||
| #include <ArduinoJson/Strings/IsString.hpp> | ||||
| #include <ArduinoJson/Strings/StringAdapters.hpp> | ||||
| #include <ArduinoJson/Variant/VariantAttorney.hpp> | ||||
| #include <ArduinoJson/Variant/VariantConstRef.hpp> | ||||
| #include <ArduinoJson/Variant/VariantFunctions.hpp> | ||||
| #include <ArduinoJson/Variant/VariantOperators.hpp> | ||||
| #include <ArduinoJson/Variant/VariantShortcuts.hpp> | ||||
| #include <ArduinoJson/Variant/VariantTag.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
| @@ -24,8 +24,7 @@ class ArrayRef; | ||||
| class ObjectRef; | ||||
|  | ||||
| class VariantConstRef : public VariantTag, | ||||
|                         public VariantOperators<VariantConstRef>, | ||||
|                         public VariantShortcuts<VariantConstRef> { | ||||
|                         public VariantOperators<VariantConstRef> { | ||||
|   friend class VariantAttorney; | ||||
|  | ||||
|  public: | ||||
| @@ -126,6 +125,23 @@ class VariantConstRef : public VariantTag, | ||||
|     return VariantConstRef(variantGetMember(_data, adaptString(key))); | ||||
|   } | ||||
|  | ||||
|   // containsKey(const std::string&) const | ||||
|   // containsKey(const String&) const | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type | ||||
|   containsKey(const TString& key) const { | ||||
|     return variantGetMember(getData(), adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|   // containsKey(char*) const | ||||
|   // containsKey(const char*) const | ||||
|   // containsKey(const __FlashStringHelper*) const | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type | ||||
|   containsKey(TChar* key) const { | ||||
|     return variantGetMember(getData(), adaptString(key)) != 0; | ||||
|   } | ||||
|  | ||||
|  protected: | ||||
|   const VariantData* getData() const { | ||||
|     return _data; | ||||
|   | ||||
| @@ -8,16 +8,23 @@ | ||||
| #include <ArduinoJson/Variant/Converter.hpp> | ||||
| #include <ArduinoJson/Variant/VariantConstRef.hpp> | ||||
| #include <ArduinoJson/Variant/VariantOperators.hpp> | ||||
| #include <ArduinoJson/Variant/VariantShortcuts.hpp> | ||||
| #include <ArduinoJson/Variant/VariantTo.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| class VariantRef; | ||||
|  | ||||
| template <typename> | ||||
| class ElementDataSource; | ||||
|  | ||||
| template <typename, typename> | ||||
| class MemberDataSource; | ||||
|  | ||||
| template <typename> | ||||
| class VariantProxy; | ||||
|  | ||||
| template <typename TDataSource> | ||||
| class VariantRefBase : public VariantShortcuts<VariantRefBase<TDataSource> >, | ||||
|                        public VariantTag { | ||||
| class VariantRefBase : public VariantTag { | ||||
|   friend class VariantAttorney; | ||||
|  | ||||
|  public: | ||||
| @@ -160,7 +167,17 @@ class VariantRefBase : public VariantShortcuts<VariantRefBase<TDataSource> >, | ||||
|  | ||||
|   FORCE_INLINE VariantRef add() const; | ||||
|  | ||||
|   using ArrayShortcuts<VariantRefBase<TDataSource> >::add; | ||||
|   template <typename T> | ||||
|   FORCE_INLINE bool add(const T& value) const { | ||||
|     return add().set(value); | ||||
|   } | ||||
|   // | ||||
|   // bool add(TValue); | ||||
|   // TValue = char*, const char*, const __FlashStringHelper* | ||||
|   template <typename T> | ||||
|   FORCE_INLINE bool add(T* value) const { | ||||
|     return add().set(value); | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE void remove(size_t index) const { | ||||
|     VariantData* data = getData(); | ||||
| @@ -187,6 +204,43 @@ class VariantRefBase : public VariantShortcuts<VariantRefBase<TDataSource> >, | ||||
|       data->remove(adaptString(key)); | ||||
|   } | ||||
|  | ||||
|   FORCE_INLINE ArrayRef createNestedArray() const; | ||||
|   FORCE_INLINE ObjectRef createNestedObject() const; | ||||
|   FORCE_INLINE VariantProxy<ElementDataSource<VariantRefBase> > operator[]( | ||||
|       size_t index) const; | ||||
|  | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if<IsString<TString>::value, bool>::type | ||||
|   containsKey(const TString& key) const; | ||||
|  | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if<IsString<TChar*>::value, bool>::type | ||||
|   containsKey(TChar* key) const; | ||||
|  | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE typename enable_if< | ||||
|       IsString<TString>::value, | ||||
|       VariantProxy<MemberDataSource<VariantRefBase, TString> > >::type | ||||
|   operator[](const TString& key) const; | ||||
|  | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE typename enable_if< | ||||
|       IsString<TChar*>::value, | ||||
|       VariantProxy<MemberDataSource<VariantRefBase, TChar*> > >::type | ||||
|   operator[](TChar* key) const; | ||||
|  | ||||
|   template <typename TString> | ||||
|   FORCE_INLINE ArrayRef createNestedArray(const TString& key) const; | ||||
|  | ||||
|   template <typename TChar> | ||||
|   FORCE_INLINE ArrayRef createNestedArray(TChar* key) const; | ||||
|  | ||||
|   template <typename TString> | ||||
|   ObjectRef createNestedObject(const TString& key) const; | ||||
|  | ||||
|   template <typename TChar> | ||||
|   ObjectRef createNestedObject(TChar* key) const; | ||||
|  | ||||
|  protected: | ||||
|   FORCE_INLINE MemoryPool* getPool() const { | ||||
|     return _source.getPool(); | ||||
|   | ||||
| @@ -1,23 +0,0 @@ | ||||
| // ArduinoJson - https://arduinojson.org | ||||
| // Copyright © 2014-2022, Benoit BLANCHON | ||||
| // MIT License | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| #include <ArduinoJson/Array/ArrayShortcuts.hpp> | ||||
| #include <ArduinoJson/Object/ObjectShortcuts.hpp> | ||||
|  | ||||
| namespace ARDUINOJSON_NAMESPACE { | ||||
|  | ||||
| template <typename TVariant> | ||||
| class VariantShortcuts : public ObjectShortcuts<TVariant>, | ||||
|                          public ArrayShortcuts<TVariant> { | ||||
|  public: | ||||
|   using ArrayShortcuts<TVariant>::createNestedArray; | ||||
|   using ArrayShortcuts<TVariant>::createNestedObject; | ||||
|   using ArrayShortcuts<TVariant>::operator[]; | ||||
|   using ObjectShortcuts<TVariant>::createNestedArray; | ||||
|   using ObjectShortcuts<TVariant>::createNestedObject; | ||||
|   using ObjectShortcuts<TVariant>::operator[]; | ||||
| }; | ||||
| }  // namespace ARDUINOJSON_NAMESPACE | ||||
		Reference in New Issue
	
	Block a user