forked from bblanchon/ArduinoJson
Removed JsonArray::is<T>(i)
and JsonArray::set(i,v)
Removed `JsonObject::is<T>(k)` and `JsonObject::set(k,v)` Replaced `T JsonArray::get<T>(i)` with `JsonVariant JsonArray::get(i)` Replaced `T JsonObject::get<T>(k)` with `JsonVariant JsonObject::get(k)`
This commit is contained in:
@ -191,15 +191,8 @@ class JsonArray : public JsonArrayProxy<JsonArrayData>, public Visitable {
|
||||
}
|
||||
|
||||
// Gets the value at the specified index.
|
||||
template <typename T>
|
||||
FORCE_INLINE typename JsonVariantAs<T>::type get(size_t index) const {
|
||||
return get_impl(index).as<T>();
|
||||
}
|
||||
|
||||
// Check the type of the value at specified index.
|
||||
template <typename T>
|
||||
FORCE_INLINE bool is(size_t index) const {
|
||||
return get_impl(index).is<T>();
|
||||
FORCE_INLINE JsonVariant get(size_t index) const {
|
||||
return JsonVariant(_memoryPool, arrayGet(_data, index));
|
||||
}
|
||||
|
||||
// Removes element at specified position.
|
||||
@ -212,25 +205,6 @@ class JsonArray : public JsonArrayProxy<JsonArrayData>, public Visitable {
|
||||
arrayRemove(_data, index);
|
||||
}
|
||||
|
||||
// Sets the value at specified index.
|
||||
//
|
||||
// bool add(size_t index, const TValue&);
|
||||
// TValue = bool, long, int, short, float, double, serialized, JsonVariant,
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename T>
|
||||
FORCE_INLINE bool set(size_t index, const T& value) const {
|
||||
if (!_data) return false;
|
||||
return get_impl(index).set(value);
|
||||
}
|
||||
//
|
||||
// bool add(size_t index, TValue);
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename T>
|
||||
FORCE_INLINE bool set(size_t index, T* value) const {
|
||||
if (!_data) return false;
|
||||
return get_impl(index).set(value);
|
||||
}
|
||||
|
||||
template <typename Visitor>
|
||||
FORCE_INLINE void accept(Visitor& visitor) const {
|
||||
JsonArrayConst(_data).accept(visitor);
|
||||
@ -242,10 +216,6 @@ class JsonArray : public JsonArrayProxy<JsonArrayData>, public Visitable {
|
||||
return add().set(value);
|
||||
}
|
||||
|
||||
FORCE_INLINE JsonVariant get_impl(size_t index) const {
|
||||
return JsonVariant(_memoryPool, arrayGet(_data, index));
|
||||
}
|
||||
|
||||
MemoryPool* _memoryPool;
|
||||
};
|
||||
} // namespace ARDUINOJSON_NAMESPACE
|
||||
|
@ -90,7 +90,7 @@ class JsonArraySubscript : public JsonVariantBase<JsonArraySubscript>,
|
||||
|
||||
private:
|
||||
FORCE_INLINE JsonVariant get_impl() const {
|
||||
return _array.get<JsonVariant>(_index);
|
||||
return _array.get(_index);
|
||||
}
|
||||
|
||||
JsonArray _array;
|
||||
|
@ -80,18 +80,18 @@ class JsonObjectConst : public JsonObjectProxy<const JsonObjectData>,
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// std::string, String, JsonArrayConst, JsonObjectConst
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE typename JsonVariantAs<TValue>::type get(const TKey& key) const {
|
||||
return get_impl(makeString(key)).template as<TValue>();
|
||||
template <typename TKey>
|
||||
FORCE_INLINE JsonVariantConst get(const TKey& key) const {
|
||||
return get_impl(makeString(key));
|
||||
}
|
||||
//
|
||||
// TValue get<TValue>(TKey) const;
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// std::string, String, JsonArrayConst, JsonObjectConst
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE typename JsonVariantAs<TValue>::type get(TKey* key) const {
|
||||
return get_impl(makeString(key)).template as<TValue>();
|
||||
template <typename TKey>
|
||||
FORCE_INLINE JsonVariantConst get(TKey* key) const {
|
||||
return get_impl(makeString(key));
|
||||
}
|
||||
|
||||
//
|
||||
@ -191,39 +191,18 @@ class JsonObject : public JsonObjectProxy<JsonObjectData>, public Visitable {
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE typename JsonVariantAs<TValue>::type get(const TKey& key) const {
|
||||
return get_impl(makeString(key)).template as<TValue>();
|
||||
template <typename TKey>
|
||||
FORCE_INLINE JsonVariant get(const TKey& key) const {
|
||||
return get_impl(makeString(key));
|
||||
}
|
||||
//
|
||||
// TValue get<TValue>(TKey) const;
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE typename JsonVariantAs<TValue>::type get(TKey* key) const {
|
||||
return get_impl(makeString(key)).template as<TValue>();
|
||||
}
|
||||
|
||||
// Checks the type of the value associated with the specified key.
|
||||
//
|
||||
//
|
||||
// bool is<TValue>(TKey) const;
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE bool is(const TKey& key) const {
|
||||
return get_impl(makeString(key)).template is<TValue>();
|
||||
}
|
||||
//
|
||||
// bool is<TValue>(TKey) const;
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = bool, char, long, int, short, float, double,
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE bool is(TKey* key) const {
|
||||
return get_impl(makeString(key)).template is<TValue>();
|
||||
template <typename TKey>
|
||||
FORCE_INLINE JsonVariant get(TKey* key) const {
|
||||
return get_impl(makeString(key));
|
||||
}
|
||||
|
||||
// Gets or sets the value associated with the specified key.
|
||||
@ -267,42 +246,6 @@ class JsonObject : public JsonObjectProxy<JsonObjectData>, public Visitable {
|
||||
remove_impl(makeString(key));
|
||||
}
|
||||
|
||||
// Sets the specified key with the specified value.
|
||||
//
|
||||
// bool set(TKey, TValue);
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = bool, long, int, short, float, double, serialized, JsonVariant,
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE bool set(const TKey& key, const TValue& value) const {
|
||||
return set(key).set(value);
|
||||
}
|
||||
//
|
||||
// bool set(TKey, TValue);
|
||||
// TKey = const std::string&, const String&
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE bool set(const TKey& key, TValue* value) const {
|
||||
return set(key).set(value);
|
||||
}
|
||||
//
|
||||
// bool set(TKey, const TValue&);
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = bool, long, int, short, float, double, serialized, JsonVariant,
|
||||
// std::string, String, JsonArray, JsonObject
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE bool set(TKey* key, const TValue& value) const {
|
||||
return set(key).set(value);
|
||||
}
|
||||
//
|
||||
// bool set(TKey, TValue);
|
||||
// TKey = char*, const char*, const FlashStringHelper*
|
||||
// TValue = char*, const char*, const FlashStringHelper*
|
||||
template <typename TValue, typename TKey>
|
||||
FORCE_INLINE bool set(TKey* key, TValue* value) const {
|
||||
return set(key).set(value);
|
||||
}
|
||||
|
||||
template <typename TKey>
|
||||
FORCE_INLINE JsonVariant set(TKey* key) const {
|
||||
return set_impl(makeString(key));
|
||||
|
@ -99,7 +99,7 @@ class JsonObjectSubscript
|
||||
|
||||
private:
|
||||
FORCE_INLINE JsonVariant get_impl() const {
|
||||
return _object.get<JsonVariant>(_key);
|
||||
return _object.get(_key);
|
||||
}
|
||||
|
||||
FORCE_INLINE JsonVariant set_impl() const {
|
||||
|
Reference in New Issue
Block a user