forked from bblanchon/ArduinoJson
Convert "collection function" to static member functions
This commit is contained in:
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <ArduinoJson/Array/ElementProxy.hpp>
|
#include <ArduinoJson/Array/ElementProxy.hpp>
|
||||||
#include <ArduinoJson/Array/JsonArrayConst.hpp>
|
#include <ArduinoJson/Array/JsonArrayConst.hpp>
|
||||||
#include <ArduinoJson/Collection/CollectionFunctions.hpp>
|
|
||||||
|
|
||||||
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
ARDUINOJSON_BEGIN_PUBLIC_NAMESPACE
|
||||||
|
|
||||||
@ -93,7 +92,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
|
|||||||
// ⚠️ Doesn't release the memory associated with the removed element.
|
// ⚠️ Doesn't release the memory associated with the removed element.
|
||||||
// https://arduinojson.org/v6/api/jsonarray/remove/
|
// https://arduinojson.org/v6/api/jsonarray/remove/
|
||||||
FORCE_INLINE void remove(iterator it) const {
|
FORCE_INLINE void remove(iterator it) const {
|
||||||
collectionRemove(data_, it.slot_, resources_);
|
detail::ArrayData::removeSlot(data_, it.slot_, resources_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes the element at the specified index.
|
// Removes the element at the specified index.
|
||||||
@ -107,7 +106,7 @@ class JsonArray : public detail::VariantOperators<JsonArray> {
|
|||||||
// ⚠️ Doesn't release the memory associated with the removed elements.
|
// ⚠️ Doesn't release the memory associated with the removed elements.
|
||||||
// https://arduinojson.org/v6/api/jsonarray/clear/
|
// https://arduinojson.org/v6/api/jsonarray/clear/
|
||||||
void clear() const {
|
void clear() const {
|
||||||
collectionClear(data_, resources_);
|
detail::ArrayData::clear(data_, resources_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets or sets the element at the specified index.
|
// Gets or sets the element at the specified index.
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <ArduinoJson/Array/JsonArrayIterator.hpp>
|
#include <ArduinoJson/Array/JsonArrayIterator.hpp>
|
||||||
#include <ArduinoJson/Collection/CollectionFunctions.hpp>
|
|
||||||
#include <ArduinoJson/Variant/VariantAttorney.hpp>
|
#include <ArduinoJson/Variant/VariantAttorney.hpp>
|
||||||
#include <ArduinoJson/Variant/VariantData.hpp>
|
#include <ArduinoJson/Variant/VariantData.hpp>
|
||||||
|
|
||||||
|
@ -31,8 +31,21 @@ class CollectionData {
|
|||||||
|
|
||||||
void clear(ResourceManager* resources);
|
void clear(ResourceManager* resources);
|
||||||
|
|
||||||
|
static void clear(CollectionData* collection, ResourceManager* resources) {
|
||||||
|
if (!collection)
|
||||||
|
return;
|
||||||
|
collection->clear(resources);
|
||||||
|
}
|
||||||
|
|
||||||
void removeSlot(VariantSlot* slot, ResourceManager* resources);
|
void removeSlot(VariantSlot* slot, ResourceManager* resources);
|
||||||
|
|
||||||
|
static void removeSlot(CollectionData* collection, VariantSlot* slot,
|
||||||
|
ResourceManager* resources) {
|
||||||
|
if (!collection)
|
||||||
|
return;
|
||||||
|
collection->removeSlot(slot, resources);
|
||||||
|
}
|
||||||
|
|
||||||
VariantSlot* head() const {
|
VariantSlot* head() const {
|
||||||
return head_;
|
return head_;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
// ArduinoJson - https://arduinojson.org
|
|
||||||
// Copyright © 2014-2023, Benoit BLANCHON
|
|
||||||
// MIT License
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ArduinoJson/Collection/CollectionData.hpp>
|
|
||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
|
||||||
|
|
||||||
inline void collectionClear(CollectionData* c, ResourceManager* resources) {
|
|
||||||
if (!c)
|
|
||||||
return;
|
|
||||||
c->clear(resources);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void collectionRemove(CollectionData* data, VariantSlot* slot,
|
|
||||||
ResourceManager* resources) {
|
|
||||||
if (!data)
|
|
||||||
return;
|
|
||||||
data->removeSlot(slot, resources);
|
|
||||||
}
|
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
|
@ -89,7 +89,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
|||||||
// ⚠️ Doesn't release the memory associated with the removed members.
|
// ⚠️ Doesn't release the memory associated with the removed members.
|
||||||
// https://arduinojson.org/v6/api/jsonobject/clear/
|
// https://arduinojson.org/v6/api/jsonobject/clear/
|
||||||
void clear() const {
|
void clear() const {
|
||||||
collectionClear(data_, resources_);
|
detail::ObjectData::clear(data_, resources_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copies an object.
|
// Copies an object.
|
||||||
@ -127,7 +127,7 @@ class JsonObject : public detail::VariantOperators<JsonObject> {
|
|||||||
// ⚠️ Doesn't release the memory associated with the removed member.
|
// ⚠️ Doesn't release the memory associated with the removed member.
|
||||||
// https://arduinojson.org/v6/api/jsonobject/remove/
|
// https://arduinojson.org/v6/api/jsonobject/remove/
|
||||||
FORCE_INLINE void remove(iterator it) const {
|
FORCE_INLINE void remove(iterator it) const {
|
||||||
collectionRemove(data_, it.slot_, resources_);
|
detail::ObjectData::removeSlot(data_, it.slot_, resources_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Removes the member with the specified key.
|
// Removes the member with the specified key.
|
||||||
|
Reference in New Issue
Block a user