mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-30 02:37:35 +02:00
CollectionIterator: remove friendship with VariantImpl
This commit is contained in:
@ -74,7 +74,7 @@ inline void VariantImpl::removeOne(iterator it) {
|
|||||||
coll->head = next;
|
coll->head = next;
|
||||||
if (next == NULL_SLOT)
|
if (next == NULL_SLOT)
|
||||||
coll->tail = prev.id();
|
coll->tail = prev.id();
|
||||||
freeVariant({it->data(), it.currentId_});
|
freeVariant({it->data(), it.slotId()});
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void VariantImpl::removePair(VariantImpl::iterator it) {
|
inline void VariantImpl::removePair(VariantImpl::iterator it) {
|
||||||
|
@ -8,26 +8,21 @@
|
|||||||
#include <ArduinoJson/Polyfills/assert.hpp>
|
#include <ArduinoJson/Polyfills/assert.hpp>
|
||||||
#include <ArduinoJson/Variant/VariantImpl.hpp>
|
#include <ArduinoJson/Variant/VariantImpl.hpp>
|
||||||
|
|
||||||
#include <stddef.h> // size_t
|
|
||||||
|
|
||||||
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
ARDUINOJSON_BEGIN_PRIVATE_NAMESPACE
|
||||||
|
|
||||||
struct VariantData;
|
|
||||||
class ResourceManager;
|
|
||||||
class VariantImpl;
|
|
||||||
|
|
||||||
class CollectionIterator {
|
class CollectionIterator {
|
||||||
friend class VariantImpl;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CollectionIterator() {}
|
CollectionIterator() {}
|
||||||
|
|
||||||
|
CollectionIterator(SlotId slotId, ResourceManager* resources)
|
||||||
|
: value_(resources->getVariant(slotId), resources), slotId_(slotId) {}
|
||||||
|
|
||||||
void next() {
|
void next() {
|
||||||
ARDUINOJSON_ASSERT(!done());
|
ARDUINOJSON_ASSERT(!done());
|
||||||
auto nextId = value_.data()->next;
|
auto nextId = value_.data()->next;
|
||||||
auto resources = value_.resources();
|
auto resources = value_.resources();
|
||||||
value_ = VariantImpl(resources->getVariant(nextId), resources);
|
value_ = VariantImpl(resources->getVariant(nextId), resources);
|
||||||
currentId_ = nextId;
|
slotId_ = nextId;
|
||||||
}
|
}
|
||||||
|
|
||||||
const VariantImpl& operator*() const {
|
const VariantImpl& operator*() const {
|
||||||
@ -50,12 +45,13 @@ class CollectionIterator {
|
|||||||
return !operator==(other);
|
return !operator==(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
SlotId slotId() const {
|
||||||
CollectionIterator(SlotId slotId, ResourceManager* resources)
|
return slotId_;
|
||||||
: value_(resources->getVariant(slotId), resources), currentId_(slotId) {}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
VariantImpl value_;
|
VariantImpl value_;
|
||||||
SlotId currentId_ = NULL_SLOT;
|
SlotId slotId_ = NULL_SLOT;
|
||||||
};
|
};
|
||||||
|
|
||||||
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
ARDUINOJSON_END_PRIVATE_NAMESPACE
|
||||||
|
Reference in New Issue
Block a user