forked from bblanchon/ArduinoJson
Improved JsonObjectIterator
This commit is contained in:
@ -4,44 +4,45 @@
|
|||||||
|
|
||||||
namespace ArduinoJson
|
namespace ArduinoJson
|
||||||
{
|
{
|
||||||
class JsonObject;
|
class JsonObject;
|
||||||
|
|
||||||
class JsonObjectIterator
|
class JsonObjectIterator
|
||||||
{
|
{
|
||||||
friend class JsonObject;
|
friend class JsonObject;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit JsonObjectIterator(Internals::JsonNode* node)
|
explicit JsonObjectIterator(Internals::JsonNode* node)
|
||||||
: _objectKeyValue(node)
|
: _objectKeyValue(node)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator++()
|
JsonObjectIterator& operator++()
|
||||||
{
|
{
|
||||||
++_objectKeyValue;
|
_objectKeyValue = JsonObjectKeyValue(_objectKeyValue.next());
|
||||||
}
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
JsonObjectKeyValue operator*() const
|
JsonObjectKeyValue operator*() const
|
||||||
{
|
{
|
||||||
return _objectKeyValue;
|
return _objectKeyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObjectKeyValue* operator->()
|
JsonObjectKeyValue* operator->()
|
||||||
{
|
{
|
||||||
return &_objectKeyValue;
|
return &_objectKeyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const JsonObjectIterator& other) const
|
bool operator==(const JsonObjectIterator& other) const
|
||||||
{
|
{
|
||||||
return _objectKeyValue == other._objectKeyValue;
|
return _objectKeyValue == other._objectKeyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const JsonObjectIterator& other) const
|
bool operator!=(const JsonObjectIterator& other) const
|
||||||
{
|
{
|
||||||
return _objectKeyValue != other._objectKeyValue;
|
return _objectKeyValue != other._objectKeyValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
JsonObjectKeyValue _objectKeyValue;
|
JsonObjectKeyValue _objectKeyValue;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -4,40 +4,40 @@
|
|||||||
|
|
||||||
namespace ArduinoJson
|
namespace ArduinoJson
|
||||||
{
|
{
|
||||||
class JsonObjectKeyValue
|
class JsonObjectKeyValue
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit JsonObjectKeyValue(Internals::JsonNode* node)
|
explicit JsonObjectKeyValue(Internals::JsonNode* node)
|
||||||
: _node(node)
|
: _node(node)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* key() const
|
const char* key() const
|
||||||
{
|
{
|
||||||
return _node->getAsObjectKey();
|
return _node->getAsObjectKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonValue value()
|
JsonValue value()
|
||||||
{
|
{
|
||||||
return JsonValue(_node->getAsObjectValue());
|
return JsonValue(_node->getAsObjectValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator++()
|
bool operator==(const JsonObjectKeyValue& other) const
|
||||||
{
|
{
|
||||||
_node = _node->next;
|
return _node == other._node;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const JsonObjectKeyValue& other) const
|
bool operator!=(const JsonObjectKeyValue& other) const
|
||||||
{
|
{
|
||||||
return _node == other._node;
|
return _node != other._node;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const JsonObjectKeyValue& other) const
|
Internals::JsonNode* next()
|
||||||
{
|
{
|
||||||
return _node != other._node;
|
return _node->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Internals::JsonNode* _node;
|
Internals::JsonNode* _node;
|
||||||
};
|
};
|
||||||
}
|
}
|
Reference in New Issue
Block a user