mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 00:38:26 +01:00
Added JsonVariant::containsKey()
This commit is contained in:
@@ -40,9 +40,9 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >,
|
||||
return *this;
|
||||
}
|
||||
|
||||
// operator=(char*) const
|
||||
// operator=(const char*) const
|
||||
// operator=(const __FlashStringHelper*) const
|
||||
// operator=(char*)
|
||||
// operator=(const char*)
|
||||
// operator=(const __FlashStringHelper*)
|
||||
template <typename TChar>
|
||||
FORCE_INLINE this_type &operator=(TChar *src) {
|
||||
getOrAddUpstreamMember().set(src);
|
||||
|
||||
@@ -16,11 +16,6 @@ void objectAccept(const CollectionData *obj, Visitor &visitor) {
|
||||
visitor.visitNull();
|
||||
}
|
||||
|
||||
template <typename TAdaptedString>
|
||||
inline bool objectContainsKey(const CollectionData *obj, TAdaptedString key) {
|
||||
return obj && obj->containsKey(key);
|
||||
}
|
||||
|
||||
inline bool objectEquals(const CollectionData *lhs, const CollectionData *rhs) {
|
||||
if (lhs == rhs) return true;
|
||||
if (!lhs || !rhs) return false;
|
||||
|
||||
@@ -35,4 +35,18 @@ inline ObjectRef ObjectShortcuts<TObject>::createNestedObject(
|
||||
TChar* key) const {
|
||||
return impl()->getOrAddMember(key).template to<ObjectRef>();
|
||||
}
|
||||
|
||||
template <typename TObject>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString>::value, bool>::type
|
||||
ObjectShortcuts<TObject>::containsKey(const TString& key) const {
|
||||
return !impl()->getMember(key).isUndefined();
|
||||
}
|
||||
|
||||
template <typename TObject>
|
||||
template <typename TChar>
|
||||
inline typename enable_if<IsString<TChar*>::value, bool>::type
|
||||
ObjectShortcuts<TObject>::containsKey(TChar* key) const {
|
||||
return !impl()->getMember(key).isUndefined();
|
||||
}
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
@@ -27,21 +27,6 @@ class ObjectRefBase {
|
||||
objectAccept(_data, visitor);
|
||||
}
|
||||
|
||||
// containsKey(const std::string&) const
|
||||
// containsKey(const String&) const
|
||||
template <typename TString>
|
||||
FORCE_INLINE bool containsKey(const TString& key) const {
|
||||
return objectContainsKey(_data, adaptString(key));
|
||||
}
|
||||
|
||||
// containsKey(char*) const
|
||||
// containsKey(const char*) const
|
||||
// containsKey(const __FlashStringHelper*) const
|
||||
template <typename TChar>
|
||||
FORCE_INLINE bool containsKey(TChar* key) const {
|
||||
return objectContainsKey(_data, adaptString(key));
|
||||
}
|
||||
|
||||
FORCE_INLINE bool isNull() const {
|
||||
return _data == 0;
|
||||
}
|
||||
@@ -83,6 +68,21 @@ class ObjectConstRef : public ObjectRefBase<const CollectionData>,
|
||||
return iterator();
|
||||
}
|
||||
|
||||
// containsKey(const std::string&) const
|
||||
// containsKey(const String&) const
|
||||
template <typename TString>
|
||||
FORCE_INLINE bool containsKey(const TString& key) const {
|
||||
return !getMember(key).isUndefined();
|
||||
}
|
||||
|
||||
// containsKey(char*) const
|
||||
// containsKey(const char*) const
|
||||
// containsKey(const __FlashStringHelper*) const
|
||||
template <typename TChar>
|
||||
FORCE_INLINE bool containsKey(TChar* key) const {
|
||||
return !getMember(key).isUndefined();
|
||||
}
|
||||
|
||||
// getMember(const std::string&) const
|
||||
// getMember(const String&) const
|
||||
template <typename TString>
|
||||
|
||||
@@ -15,6 +15,19 @@ class MemberProxy;
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user