Disambiguated the name get() with getElement() and getMember()

This commit is contained in:
Benoit Blanchon
2019-02-15 15:53:53 +01:00
parent 7ed92bebd3
commit e9b4c6289b
19 changed files with 172 additions and 200 deletions

View File

@@ -11,12 +11,12 @@ namespace ARDUINOJSON_NAMESPACE {
template <typename TArray>
inline ArrayRef ArrayShortcuts<TArray>::createNestedArray() const {
return impl()->add().template to<ArrayRef>();
return impl()->addElement().template to<ArrayRef>();
}
template <typename TArray>
inline ObjectRef ArrayShortcuts<TArray>::createNestedObject() const {
return impl()->add().template to<ObjectRef>();
return impl()->addElement().template to<ObjectRef>();
}
} // namespace ARDUINOJSON_NAMESPACE

View File

@@ -101,8 +101,7 @@ class ArrayRef : public ArrayRefBase<CollectionData>,
return ArrayConstRef(_data);
}
using ArrayShortcuts::add;
VariantRef add() const {
VariantRef addElement() const {
return VariantRef(_pool, arrayAdd(_data, _pool));
}
@@ -126,7 +125,7 @@ class ArrayRef : public ArrayRefBase<CollectionData>,
}
// Gets the value at the specified index.
FORCE_INLINE VariantRef get(size_t index) const {
FORCE_INLINE VariantRef getElement(size_t index) const {
return VariantRef(_pool, _data ? _data->get(index) : 0);
}

View File

@@ -29,14 +29,14 @@ class ArrayShortcuts {
// std::string, String, ObjectRef
template <typename T>
FORCE_INLINE bool add(const T &value) const {
return impl()->add().set(value);
return impl()->addElement().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);
return impl()->addElement().set(value);
}
private:

View File

@@ -24,7 +24,7 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >,
: _array(array), _index(index) {}
FORCE_INLINE this_type& operator=(const this_type& src) {
getElement().set(src.as<VariantConstRef>());
getUpstreamElement().set(src.as<VariantConstRef>());
return *this;
}
@@ -35,7 +35,7 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >,
// std::string, String, ArrayRef, ObjectRef
template <typename T>
FORCE_INLINE this_type& operator=(const T& src) {
getElement().set(src);
getUpstreamElement().set(src);
return *this;
}
//
@@ -43,27 +43,27 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >,
// TValue = char*, const char*, const __FlashStringHelper*
template <typename T>
FORCE_INLINE this_type& operator=(T* src) {
getElement().set(src);
getUpstreamElement().set(src);
return *this;
}
FORCE_INLINE bool isNull() const {
return getElement().isNull();
return getUpstreamElement().isNull();
}
template <typename T>
FORCE_INLINE typename VariantAs<T>::type as() const {
return getElement().template as<T>();
return getUpstreamElement().template as<T>();
}
template <typename T>
FORCE_INLINE bool is() const {
return getElement().template is<T>();
return getUpstreamElement().template is<T>();
}
template <typename T>
FORCE_INLINE typename VariantTo<T>::type to() const {
return getElement().template to<T>();
return getUpstreamElement().template to<T>();
}
// Replaces the value
@@ -73,53 +73,56 @@ class ElementProxy : public VariantOperators<ElementProxy<TArray> >,
// std::string, String, ArrayRef, ObjectRef
template <typename TValue>
FORCE_INLINE bool set(const TValue& value) const {
return getElement().set(value);
return getUpstreamElement().set(value);
}
//
// bool set(TValue)
// TValue = char*, const char*, const __FlashStringHelper*
template <typename TValue>
FORCE_INLINE bool set(TValue* value) const {
return getElement().set(value);
return getUpstreamElement().set(value);
}
template <typename Visitor>
void accept(Visitor& visitor) const {
return getElement().accept(visitor);
return getUpstreamElement().accept(visitor);
}
FORCE_INLINE size_t size() const {
return getElement().size();
return getUpstreamElement().size();
}
template <typename TNestedKey>
VariantRef get(TNestedKey* key) const {
return getElement().get(key);
VariantRef getMember(TNestedKey* key) const {
return getUpstreamElement().getMember(key);
}
template <typename TNestedKey>
VariantRef get(const TNestedKey& key) const {
return getElement().get(key);
VariantRef getMember(const TNestedKey& key) const {
return getUpstreamElement().getMember(key);
}
template <typename TNestedKey>
VariantRef getOrCreate(TNestedKey* key) const {
return getElement().getOrCreate(key);
VariantRef getOrAddMember(TNestedKey* key) const {
return getUpstreamElement().getOrAddMember(key);
}
template <typename TNestedKey>
VariantRef getOrCreate(const TNestedKey& key) const {
return getElement().getOrCreate(key);
VariantRef getOrAddMember(const TNestedKey& key) const {
return getUpstreamElement().getOrAddMember(key);
}
using ArrayShortcuts<ElementProxy>::add;
VariantRef add() const {
return getElement().add();
VariantRef addElement() const {
return getUpstreamElement().addElement();
}
VariantRef getElement(size_t index) const {
return getUpstreamElement().getElement(index);
}
private:
FORCE_INLINE VariantRef getElement() const {
return _array.get(_index);
FORCE_INLINE VariantRef getUpstreamElement() const {
return _array.getElement(_index);
}
TArray _array;