forked from bblanchon/ArduinoJson
Change naming convention from _member
to member_
(fixes #1905)
Ported from 31ce648e63
This commit is contained in:
@ -20,61 +20,61 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
typedef JsonObjectIterator iterator;
|
||||
|
||||
// Creates an unbound reference.
|
||||
FORCE_INLINE JsonObject() : _data(0), _pool(0) {}
|
||||
FORCE_INLINE JsonObject() : data_(0), pool_(0) {}
|
||||
|
||||
// INTERNAL USE ONLY
|
||||
FORCE_INLINE JsonObject(detail::MemoryPool* buf, detail::CollectionData* data)
|
||||
: _data(data), _pool(buf) {}
|
||||
: data_(data), pool_(buf) {}
|
||||
|
||||
operator JsonVariant() const {
|
||||
void* data = _data; // prevent warning cast-align
|
||||
return JsonVariant(_pool, reinterpret_cast<detail::VariantData*>(data));
|
||||
void* data = data_; // prevent warning cast-align
|
||||
return JsonVariant(pool_, reinterpret_cast<detail::VariantData*>(data));
|
||||
}
|
||||
|
||||
operator JsonObjectConst() const {
|
||||
return JsonObjectConst(_data);
|
||||
return JsonObjectConst(data_);
|
||||
}
|
||||
|
||||
operator JsonVariantConst() const {
|
||||
return JsonVariantConst(collectionToVariant(_data));
|
||||
return JsonVariantConst(collectionToVariant(data_));
|
||||
}
|
||||
|
||||
// Returns true if the reference is unbound.
|
||||
// https://arduinojson.org/v6/api/jsonobject/isnull/
|
||||
FORCE_INLINE bool isNull() const {
|
||||
return _data == 0;
|
||||
return data_ == 0;
|
||||
}
|
||||
|
||||
// Returns true if the reference is bound.
|
||||
// https://arduinojson.org/v6/api/jsonobject/isnull/
|
||||
FORCE_INLINE operator bool() const {
|
||||
return _data != 0;
|
||||
return data_ != 0;
|
||||
}
|
||||
|
||||
// Returns the number of bytes occupied by the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/memoryusage/
|
||||
FORCE_INLINE size_t memoryUsage() const {
|
||||
return _data ? _data->memoryUsage() : 0;
|
||||
return data_ ? data_->memoryUsage() : 0;
|
||||
}
|
||||
|
||||
// Returns the depth (nesting level) of the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/nesting/
|
||||
FORCE_INLINE size_t nesting() const {
|
||||
return variantNesting(collectionToVariant(_data));
|
||||
return variantNesting(collectionToVariant(data_));
|
||||
}
|
||||
|
||||
// Returns the number of members in the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/size/
|
||||
FORCE_INLINE size_t size() const {
|
||||
return _data ? _data->size() : 0;
|
||||
return data_ ? data_->size() : 0;
|
||||
}
|
||||
|
||||
// Returns an iterator to the first key-value pair of the object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/begin/
|
||||
FORCE_INLINE iterator begin() const {
|
||||
if (!_data)
|
||||
if (!data_)
|
||||
return iterator();
|
||||
return iterator(_pool, _data->head());
|
||||
return iterator(pool_, data_->head());
|
||||
}
|
||||
|
||||
// Returns an iterator following the last key-value pair of the object.
|
||||
@ -87,18 +87,18 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
// ⚠️ Doesn't release the memory associated with the removed members.
|
||||
// https://arduinojson.org/v6/api/jsonobject/clear/
|
||||
void clear() const {
|
||||
collectionClear(_data, _pool);
|
||||
collectionClear(data_, pool_);
|
||||
}
|
||||
|
||||
// Copies an object.
|
||||
// https://arduinojson.org/v6/api/jsonobject/set/
|
||||
FORCE_INLINE bool set(JsonObjectConst src) {
|
||||
return collectionCopy(_data, src._data, _pool);
|
||||
return collectionCopy(data_, src.data_, pool_);
|
||||
}
|
||||
|
||||
// Compares the content of two objects.
|
||||
FORCE_INLINE bool operator==(JsonObject rhs) const {
|
||||
return JsonObjectConst(_data) == JsonObjectConst(rhs._data);
|
||||
return JsonObjectConst(data_) == JsonObjectConst(rhs.data_);
|
||||
}
|
||||
|
||||
// Gets or sets the member with specified key.
|
||||
@ -125,7 +125,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
// ⚠️ Doesn't release the memory associated with the removed member.
|
||||
// https://arduinojson.org/v6/api/jsonobject/remove/
|
||||
FORCE_INLINE void remove(iterator it) const {
|
||||
collectionRemove(_data, it._slot, _pool);
|
||||
collectionRemove(data_, it.slot_, pool_);
|
||||
}
|
||||
|
||||
// Removes the member with the specified key.
|
||||
@ -133,7 +133,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
// https://arduinojson.org/v6/api/jsonobject/remove/
|
||||
template <typename TString>
|
||||
FORCE_INLINE void remove(const TString& key) const {
|
||||
collectionRemoveMember(_data, detail::adaptString(key), _pool);
|
||||
collectionRemoveMember(data_, detail::adaptString(key), pool_);
|
||||
}
|
||||
|
||||
// Removes the member with the specified key.
|
||||
@ -141,7 +141,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
// https://arduinojson.org/v6/api/jsonobject/remove/
|
||||
template <typename TChar>
|
||||
FORCE_INLINE void remove(TChar* key) const {
|
||||
collectionRemoveMember(_data, detail::adaptString(key), _pool);
|
||||
collectionRemoveMember(data_, detail::adaptString(key), pool_);
|
||||
}
|
||||
|
||||
// Returns true if the object contains the specified key.
|
||||
@ -150,7 +150,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
FORCE_INLINE
|
||||
typename detail::enable_if<detail::IsString<TString>::value, bool>::type
|
||||
containsKey(const TString& key) const {
|
||||
return collectionGetMember(_data, detail::adaptString(key)) != 0;
|
||||
return collectionGetMember(data_, detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Returns true if the object contains the specified key.
|
||||
@ -159,7 +159,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
FORCE_INLINE
|
||||
typename detail::enable_if<detail::IsString<TChar*>::value, bool>::type
|
||||
containsKey(TChar* key) const {
|
||||
return collectionGetMember(_data, detail::adaptString(key)) != 0;
|
||||
return collectionGetMember(data_, detail::adaptString(key)) != 0;
|
||||
}
|
||||
|
||||
// Creates an array and adds it to the object.
|
||||
@ -188,24 +188,24 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
||||
|
||||
private:
|
||||
detail::MemoryPool* getPool() const {
|
||||
return _pool;
|
||||
return pool_;
|
||||
}
|
||||
|
||||
detail::VariantData* getData() const {
|
||||
return detail::collectionToVariant(_data);
|
||||
return detail::collectionToVariant(data_);
|
||||
}
|
||||
|
||||
detail::VariantData* getOrCreateData() const {
|
||||
return detail::collectionToVariant(_data);
|
||||
return detail::collectionToVariant(data_);
|
||||
}
|
||||
|
||||
template <typename TAdaptedString>
|
||||
void removeMember(TAdaptedString key) const {
|
||||
collectionRemove(_data, _data->get(key), _pool);
|
||||
collectionRemove(data_, data_->get(key), pool_);
|
||||
}
|
||||
|
||||
detail::CollectionData* _data;
|
||||
detail::MemoryPool* _pool;
|
||||
detail::CollectionData* data_;
|
||||
detail::MemoryPool* pool_;
|
||||
};
|
||||
|
||||
template <>
|
||||
|
Reference in New Issue
Block a user