forked from bblanchon/ArduinoJson
Remove ArrayFunctions.hpp
and ObjectFunctions.hpp
This commit is contained in:
@ -1,15 +0,0 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
|
||||||
// Copyright © 2014-2022, Benoit BLANCHON
|
|
||||||
// MIT License
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ArduinoJson/Collection/CollectionData.hpp>
|
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
|
||||||
|
|
||||||
inline VariantData* arrayAdd(CollectionData* arr, MemoryPool* pool) {
|
|
||||||
return arr ? arr->addElement(pool) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ARDUINOJSON_NAMESPACE
|
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ArduinoJson/Array/ArrayFunctions.hpp>
|
|
||||||
#include <ArduinoJson/Array/ArrayIterator.hpp>
|
#include <ArduinoJson/Array/ArrayIterator.hpp>
|
||||||
#include <ArduinoJson/Array/ElementProxy.hpp>
|
#include <ArduinoJson/Array/ElementProxy.hpp>
|
||||||
#include <ArduinoJson/Variant/VariantAttorney.hpp>
|
#include <ArduinoJson/Variant/VariantAttorney.hpp>
|
||||||
@ -124,7 +123,9 @@ class ArrayRef : public ArrayRefBase<CollectionData>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
VariantRef add() const {
|
VariantRef add() const {
|
||||||
return VariantRef(_pool, arrayAdd(_data, _pool));
|
if (!_data)
|
||||||
|
return VariantRef();
|
||||||
|
return VariantRef(_pool, _data->addElement(_pool));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
|
||||||
// Copyright © 2014-2022, Benoit BLANCHON
|
|
||||||
// MIT License
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ArduinoJson/Collection/CollectionData.hpp>
|
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
|
||||||
|
|
||||||
template <typename TAdaptedString>
|
|
||||||
inline VariantData* objectGetMember(const CollectionData* obj,
|
|
||||||
TAdaptedString key) {
|
|
||||||
if (!obj)
|
|
||||||
return 0;
|
|
||||||
return obj->getMember(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename TAdaptedString>
|
|
||||||
void objectRemove(CollectionData* obj, TAdaptedString key) {
|
|
||||||
if (!obj)
|
|
||||||
return;
|
|
||||||
obj->removeMember(key);
|
|
||||||
}
|
|
||||||
} // namespace ARDUINOJSON_NAMESPACE
|
|
@ -5,7 +5,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ArduinoJson/Object/MemberProxy.hpp>
|
#include <ArduinoJson/Object/MemberProxy.hpp>
|
||||||
#include <ArduinoJson/Object/ObjectFunctions.hpp>
|
|
||||||
#include <ArduinoJson/Object/ObjectIterator.hpp>
|
#include <ArduinoJson/Object/ObjectIterator.hpp>
|
||||||
|
|
||||||
namespace ARDUINOJSON_NAMESPACE {
|
namespace ARDUINOJSON_NAMESPACE {
|
||||||
@ -46,6 +45,13 @@ class ObjectRefBase {
|
|||||||
return collectionToVariant(_data);
|
return collectionToVariant(_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename TAdaptedString>
|
||||||
|
inline VariantData* getMember(TAdaptedString key) const {
|
||||||
|
if (!_data)
|
||||||
|
return 0;
|
||||||
|
return _data->getMember(key);
|
||||||
|
}
|
||||||
|
|
||||||
ObjectRefBase(TData* data) : _data(data) {}
|
ObjectRefBase(TData* data) : _data(data) {}
|
||||||
TData* _data;
|
TData* _data;
|
||||||
};
|
};
|
||||||
@ -75,7 +81,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 objectGetMember(_data, adaptString(key)) != 0;
|
return getMember(adaptString(key)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// containsKey(char*) const
|
// containsKey(char*) const
|
||||||
@ -83,7 +89,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 objectGetMember(_data, adaptString(key)) != 0;
|
return getMember(adaptString(key)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// operator[](const std::string&) const
|
// operator[](const std::string&) const
|
||||||
@ -92,7 +98,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 VariantConstRef(objectGetMember(_data, adaptString(key)));
|
return VariantConstRef(getMember(adaptString(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// operator[](char*) const
|
// operator[](char*) const
|
||||||
@ -102,7 +108,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 VariantConstRef(objectGetMember(_data, adaptString(key)));
|
return VariantConstRef(getMember(adaptString(key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCE_INLINE bool operator==(ObjectConstRef rhs) const {
|
FORCE_INLINE bool operator==(ObjectConstRef rhs) const {
|
||||||
@ -194,7 +200,7 @@ class ObjectRef : public ObjectRefBase<CollectionData>,
|
|||||||
// remove(const String&) const
|
// remove(const String&) const
|
||||||
template <typename TString>
|
template <typename TString>
|
||||||
FORCE_INLINE void remove(const TString& key) const {
|
FORCE_INLINE void remove(const TString& key) const {
|
||||||
objectRemove(_data, adaptString(key));
|
removeMember(adaptString(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove(char*) const
|
// remove(char*) const
|
||||||
@ -202,19 +208,19 @@ class ObjectRef : public ObjectRefBase<CollectionData>,
|
|||||||
// remove(const __FlashStringHelper*) const
|
// remove(const __FlashStringHelper*) const
|
||||||
template <typename TChar>
|
template <typename TChar>
|
||||||
FORCE_INLINE void remove(TChar* key) const {
|
FORCE_INLINE void remove(TChar* key) const {
|
||||||
objectRemove(_data, adaptString(key));
|
removeMember(adaptString(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
return objectGetMember(_data, adaptString(key)) != 0;
|
return getMember(adaptString(key)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
return objectGetMember(_data, adaptString(key)) != 0;
|
return getMember(adaptString(key)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename TString>
|
template <typename TString>
|
||||||
@ -246,6 +252,13 @@ class ObjectRef : public ObjectRefBase<CollectionData>,
|
|||||||
return collectionToVariant(_data);
|
return collectionToVariant(_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename TAdaptedString>
|
||||||
|
void removeMember(TAdaptedString key) const {
|
||||||
|
if (!_data)
|
||||||
|
return;
|
||||||
|
_data->removeMember(key);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MemoryPool* _pool;
|
MemoryPool* _pool;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user