mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-02 00:38:26 +01:00
Fixed dangling reference in MemberProxy and ElementProxy (fixes #1120)
This commit is contained in:
@@ -174,22 +174,6 @@ class MemberProxy : public VariantOperators<MemberProxy<TObject, TStringRef> >,
|
||||
TStringRef _key;
|
||||
};
|
||||
|
||||
template <typename TObject>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString>::value,
|
||||
MemberProxy<const TObject &, const TString &> >::type
|
||||
ObjectShortcuts<TObject>::operator[](const TString &key) const {
|
||||
return MemberProxy<const TObject &, const TString &>(*impl(), key);
|
||||
}
|
||||
|
||||
template <typename TObject>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString *>::value,
|
||||
MemberProxy<const TObject &, TString *> >::type
|
||||
ObjectShortcuts<TObject>::operator[](TString *key) const {
|
||||
return MemberProxy<const TObject &, TString *>(*impl(), key);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
@@ -49,4 +49,21 @@ inline typename enable_if<IsString<TChar*>::value, bool>::type
|
||||
ObjectShortcuts<TObject>::containsKey(TChar* key) const {
|
||||
return !impl()->getMember(key).isUndefined();
|
||||
}
|
||||
|
||||
template <typename TObject>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString*>::value,
|
||||
MemberProxy<TObject, TString*> >::type
|
||||
ObjectShortcuts<TObject>::operator[](TString* key) const {
|
||||
return MemberProxy<TObject, TString*>(*impl(), key);
|
||||
}
|
||||
|
||||
template <typename TObject>
|
||||
template <typename TString>
|
||||
inline typename enable_if<IsString<TString>::value,
|
||||
MemberProxy<TObject, TString> >::type
|
||||
ObjectShortcuts<TObject>::operator[](const TString& key) const {
|
||||
return MemberProxy<TObject, TString>(*impl(), key);
|
||||
}
|
||||
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
||||
@@ -31,17 +31,16 @@ class ObjectShortcuts {
|
||||
// operator[](const std::string&) const
|
||||
// operator[](const String&) const
|
||||
template <typename TString>
|
||||
FORCE_INLINE
|
||||
typename enable_if<IsString<TString>::value,
|
||||
MemberProxy<const TObject &, const TString &> >::type
|
||||
operator[](const TString &key) const;
|
||||
FORCE_INLINE typename enable_if<IsString<TString>::value,
|
||||
MemberProxy<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,
|
||||
MemberProxy<const TObject &, TChar *> >::type
|
||||
MemberProxy<TObject, TChar *> >::type
|
||||
operator[](TChar *key) const;
|
||||
|
||||
// createNestedArray(const std::string&) const
|
||||
|
||||
Reference in New Issue
Block a user