forked from bblanchon/ArduinoJson
Removed usages of JsonNodeIterator
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
namespace ArduinoJson {
|
||||
class JsonArray;
|
||||
class JsonArrayIterator;
|
||||
class JsonArrayConstIterator;
|
||||
class JsonBuffer;
|
||||
class JsonObject;
|
||||
class JsonObjectIterator;
|
||||
|
@ -12,9 +12,13 @@
|
||||
namespace ArduinoJson {
|
||||
class JsonArray : public JsonContainer {
|
||||
public:
|
||||
typedef JsonArrayIterator iterator;
|
||||
typedef JsonArrayConstIterator const_iterator;
|
||||
|
||||
JsonArray() {}
|
||||
|
||||
explicit JsonArray(Internals::JsonNode *node) : JsonContainer(node) {}
|
||||
explicit JsonArray(Internals::JsonNode *node)
|
||||
: JsonContainer(node) {} // TODO: hide
|
||||
|
||||
JsonValue operator[](int index) const;
|
||||
|
||||
@ -30,8 +34,10 @@ class JsonArray : public JsonContainer {
|
||||
|
||||
bool success() { return _node && _node->isArray(); }
|
||||
|
||||
JsonArrayIterator begin();
|
||||
iterator begin() { return iterator(firstChild()); }
|
||||
iterator end() { return iterator(0); }
|
||||
|
||||
JsonArrayIterator end() { return JsonArrayIterator(0); }
|
||||
const_iterator begin() const { return const_iterator(firstChild()); }
|
||||
const_iterator end() const { return const_iterator(0); }
|
||||
};
|
||||
}
|
||||
|
@ -36,4 +36,30 @@ class JsonArrayIterator {
|
||||
private:
|
||||
JsonValue _value;
|
||||
};
|
||||
}
|
||||
|
||||
class JsonArrayConstIterator {
|
||||
friend class JsonArray;
|
||||
|
||||
public:
|
||||
explicit JsonArrayConstIterator(Internals::JsonNode *node) : _value(node) {}
|
||||
|
||||
const JsonValue operator*() const { return _value; }
|
||||
const JsonValue *operator->() { return &_value; }
|
||||
|
||||
bool operator==(const JsonArrayConstIterator &other) const {
|
||||
return _value._node == other._value._node;
|
||||
}
|
||||
|
||||
bool operator!=(const JsonArrayConstIterator &other) const {
|
||||
return _value._node != other._value._node;
|
||||
}
|
||||
|
||||
JsonArrayConstIterator &operator++() {
|
||||
_value._node = _value._node->next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
JsonValue _value;
|
||||
};
|
||||
}
|
@ -44,5 +44,6 @@ class JsonContainer : public Printable, public Internals::JsonNodeWrapper {
|
||||
void addChild(Internals::JsonNode *);
|
||||
void removeChild(Internals::JsonNode *);
|
||||
Internals::JsonNode *createNode();
|
||||
Internals::JsonNode* firstChild() const;
|
||||
};
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ class JsonObject : public JsonContainer {
|
||||
|
||||
bool success() { return _node && _node->isObject(); }
|
||||
|
||||
JsonObjectIterator begin();
|
||||
JsonObjectIterator begin() { return JsonObjectIterator(firstChild()); }
|
||||
|
||||
JsonObjectIterator end() { return JsonObjectIterator(0); }
|
||||
|
||||
|
@ -19,11 +19,11 @@ class JsonObjectIterator {
|
||||
JsonObjectKeyValue *operator->() { return &_keyValue; }
|
||||
|
||||
bool operator==(const JsonObjectIterator &other) const {
|
||||
return _keyValue == other._keyValue;
|
||||
return _keyValue._node == other._keyValue._node;
|
||||
}
|
||||
|
||||
bool operator!=(const JsonObjectIterator &other) const {
|
||||
return _keyValue != other._keyValue;
|
||||
return _keyValue._node != other._keyValue._node;
|
||||
}
|
||||
|
||||
JsonObjectIterator &operator++() {
|
||||
|
@ -11,21 +11,13 @@
|
||||
|
||||
namespace ArduinoJson {
|
||||
class JsonObjectKeyValue {
|
||||
friend class JsonObject;
|
||||
friend class JsonObjectIterator;
|
||||
|
||||
public:
|
||||
const char *key() const { return _node->getAsObjectKey(); }
|
||||
|
||||
JsonValue value() { return JsonValue(_node->getAsObjectValue()); }
|
||||
|
||||
bool operator==(const JsonObjectKeyValue &other) const {
|
||||
return _node == other._node;
|
||||
}
|
||||
|
||||
bool operator!=(const JsonObjectKeyValue &other) const {
|
||||
return _node != other._node;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit JsonObjectKeyValue(Internals::JsonNode *node) : _node(node) {}
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace ArduinoJson {
|
||||
class JsonValue : public Internals::JsonNodeWrapper {
|
||||
friend class JsonArray;
|
||||
friend class JsonArrayIterator;
|
||||
friend class JsonArrayConstIterator;
|
||||
friend class JsonBuffer;
|
||||
friend class JsonObject;
|
||||
friend class JsonObjectKeyValue;
|
||||
|
Reference in New Issue
Block a user