Improved JsonArrayIterator

This commit is contained in:
Benoit Blanchon
2014-10-24 16:12:05 +02:00
parent 8071434515
commit bbef8931a6
5 changed files with 46 additions and 31 deletions

View File

@@ -9,27 +9,32 @@
#include "ArduinoJson/JsonValue.hpp"
namespace ArduinoJson {
class JsonArray;
class JsonArrayIterator {
friend class JsonArray;
public:
explicit JsonArrayIterator(Internals::JsonNode *node) : _node(node) {}
explicit JsonArrayIterator(Internals::JsonNode *node) : _value(node) {}
void operator++() { _node = _node->next; }
JsonValue operator*() const { return JsonValue(_node); }
JsonValue operator*() const { return _value; }
JsonValue *operator->() { return &_value; }
bool operator==(const JsonArrayIterator &other) const {
return _node == other._node;
return _value._node == other._value._node;
}
bool operator!=(const JsonArrayIterator &other) const {
return _node != other._node;
return _value._node != other._value._node;
}
JsonArrayIterator &operator++() {
_value._node = _value._node->next;
return *this;
}
private:
Internals::JsonNode *_node;
JsonValue _value;
};
}