mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-31 11:17:34 +02:00
CollectionIterator: rename next()
to move()
This commit is contained in:
@@ -16,7 +16,7 @@ inline VariantImpl::iterator VariantImpl::at(size_t index) const {
|
|||||||
|
|
||||||
auto it = createIterator();
|
auto it = createIterator();
|
||||||
while (!it.done() && index) {
|
while (!it.done() && index) {
|
||||||
it.next();
|
it.move();
|
||||||
--index;
|
--index;
|
||||||
}
|
}
|
||||||
return it;
|
return it;
|
||||||
@@ -35,7 +35,7 @@ inline VariantData* VariantImpl::addElement() {
|
|||||||
inline VariantData* VariantImpl::getOrAddElement(size_t index) {
|
inline VariantData* VariantImpl::getOrAddElement(size_t index) {
|
||||||
auto it = createIterator();
|
auto it = createIterator();
|
||||||
while (!it.done() && index > 0) {
|
while (!it.done() && index > 0) {
|
||||||
it.next();
|
it.move();
|
||||||
index--;
|
index--;
|
||||||
}
|
}
|
||||||
if (it.done())
|
if (it.done())
|
||||||
|
@@ -50,7 +50,7 @@ class JsonArrayIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonArrayIterator& operator++() {
|
JsonArrayIterator& operator++() {
|
||||||
iterator_.next();
|
iterator_.move();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +82,7 @@ class JsonArrayConstIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonArrayConstIterator& operator++() {
|
JsonArrayConstIterator& operator++() {
|
||||||
iterator_.next();
|
iterator_.move();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -98,7 +98,7 @@ inline size_t VariantImpl::nesting() const {
|
|||||||
if (!data_ || !data_->isCollection())
|
if (!data_ || !data_->isCollection())
|
||||||
return 0;
|
return 0;
|
||||||
size_t maxChildNesting = 0;
|
size_t maxChildNesting = 0;
|
||||||
for (auto it = createIterator(); !it.done(); it.next()) {
|
for (auto it = createIterator(); !it.done(); it.move()) {
|
||||||
auto childNesting = it->nesting();
|
auto childNesting = it->nesting();
|
||||||
if (childNesting > maxChildNesting)
|
if (childNesting > maxChildNesting)
|
||||||
maxChildNesting = childNesting;
|
maxChildNesting = childNesting;
|
||||||
@@ -112,7 +112,7 @@ inline size_t VariantImpl::size() const {
|
|||||||
|
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
|
|
||||||
for (auto it = createIterator(); !it.done(); it.next())
|
for (auto it = createIterator(); !it.done(); it.move())
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (data_->type == VariantType::Object)
|
if (data_->type == VariantType::Object)
|
||||||
|
@@ -17,7 +17,7 @@ class CollectionIterator {
|
|||||||
CollectionIterator(SlotId slotId, ResourceManager* resources)
|
CollectionIterator(SlotId slotId, ResourceManager* resources)
|
||||||
: value_(resources->getVariant(slotId), resources), slotId_(slotId) {}
|
: value_(resources->getVariant(slotId), resources), slotId_(slotId) {}
|
||||||
|
|
||||||
void next() {
|
void move() {
|
||||||
ARDUINOJSON_ASSERT(!done());
|
ARDUINOJSON_ASSERT(!done());
|
||||||
auto nextId = value_.data()->next;
|
auto nextId = value_.data()->next;
|
||||||
auto resources = value_.resources();
|
auto resources = value_.resources();
|
||||||
|
@@ -27,7 +27,7 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
|
|||||||
while (!it.done()) {
|
while (!it.done()) {
|
||||||
indent();
|
indent();
|
||||||
it->accept(*this);
|
it->accept(*this);
|
||||||
it.next();
|
it.move();
|
||||||
base::write(it.done() ? "\r\n" : ",\r\n");
|
base::write(it.done() ? "\r\n" : ",\r\n");
|
||||||
}
|
}
|
||||||
nesting_--;
|
nesting_--;
|
||||||
@@ -49,7 +49,7 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
|
|||||||
if (isKey)
|
if (isKey)
|
||||||
indent();
|
indent();
|
||||||
it->accept(*this);
|
it->accept(*this);
|
||||||
it.next();
|
it.move();
|
||||||
if (isKey)
|
if (isKey)
|
||||||
base::write(": ");
|
base::write(": ");
|
||||||
else
|
else
|
||||||
|
@@ -33,8 +33,8 @@ class JsonObjectIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObjectIterator& operator++() {
|
JsonObjectIterator& operator++() {
|
||||||
iterator_.next(); // key
|
iterator_.move(); // key
|
||||||
iterator_.next(); // value
|
iterator_.move(); // value
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +68,8 @@ class JsonObjectConstIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
JsonObjectConstIterator& operator++() {
|
JsonObjectConstIterator& operator++() {
|
||||||
iterator_.next(); // key
|
iterator_.move(); // key
|
||||||
iterator_.next(); // value
|
iterator_.move(); // value
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@ class JsonPair {
|
|||||||
JsonPair(detail::VariantImpl::iterator iterator) {
|
JsonPair(detail::VariantImpl::iterator iterator) {
|
||||||
if (!iterator.done()) {
|
if (!iterator.done()) {
|
||||||
key_ = iterator->asString();
|
key_ = iterator->asString();
|
||||||
iterator.next();
|
iterator.move();
|
||||||
value_ = JsonVariant(*iterator);
|
value_ = JsonVariant(*iterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,7 +45,7 @@ class JsonPairConst {
|
|||||||
JsonPairConst(detail::VariantImpl::iterator iterator) {
|
JsonPairConst(detail::VariantImpl::iterator iterator) {
|
||||||
if (!iterator.done()) {
|
if (!iterator.done()) {
|
||||||
key_ = iterator->asString();
|
key_ = iterator->asString();
|
||||||
iterator.next();
|
iterator.move();
|
||||||
value_ = JsonVariantConst(*iterator);
|
value_ = JsonVariantConst(*iterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ inline VariantData* VariantImpl::getMember(TAdaptedString key) const {
|
|||||||
auto it = findKey(key);
|
auto it = findKey(key);
|
||||||
if (it.done())
|
if (it.done())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
it.next();
|
it.move();
|
||||||
return it->data();
|
return it->data();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ inline VariantImpl::iterator VariantImpl::findKey(TAdaptedString key) const {
|
|||||||
if (key.isNull())
|
if (key.isNull())
|
||||||
return iterator();
|
return iterator();
|
||||||
bool isKey = true;
|
bool isKey = true;
|
||||||
for (auto it = createIterator(); !it.done(); it.next()) {
|
for (auto it = createIterator(); !it.done(); it.move()) {
|
||||||
if (isKey && stringEquals(key, adaptString(it->asString())))
|
if (isKey && stringEquals(key, adaptString(it->asString())))
|
||||||
return it;
|
return it;
|
||||||
isKey = !isKey;
|
isKey = !isKey;
|
||||||
|
Reference in New Issue
Block a user