Added JsonObjectIterator::operator->()

This commit is contained in:
Benoit Blanchon
2014-10-22 23:32:25 +02:00
parent 40ac60b941
commit 451c0ee70d
3 changed files with 32 additions and 22 deletions

View File

@ -12,41 +12,36 @@ namespace ArduinoJson
public:
explicit JsonObjectIterator(Internals::JsonNode* node)
: _node(node)
: _objectKeyValue(node)
{
}
const char* key() const
{
return operator*().key();
}
JsonValue value() const
{
return operator*().value();
}
void operator++()
{
_node = _node->next;
++_objectKeyValue;
}
JsonObjectKeyValue operator*() const
{
return JsonObjectKeyValue(_node);
return _objectKeyValue;
}
JsonObjectKeyValue* operator->()
{
return &_objectKeyValue;
}
bool operator==(const JsonObjectIterator& other) const
{
return _node == other._node;
return _objectKeyValue == other._objectKeyValue;
}
bool operator!=(const JsonObjectIterator& other) const
{
return _node != other._node;
}
return _objectKeyValue != other._objectKeyValue;
}
private:
Internals::JsonNode* _node;
JsonObjectKeyValue _objectKeyValue;
};
}

View File

@ -12,7 +12,7 @@ namespace ArduinoJson
{
}
const char* key()
const char* key() const
{
return _node->getAsObjectKey();
}
@ -22,6 +22,21 @@ namespace ArduinoJson
return JsonValue(_node->getAsObjectValue());
}
void operator++()
{
_node = _node->next;
}
bool operator==(const JsonObjectKeyValue& other) const
{
return _node == other._node;
}
bool operator!=(const JsonObjectKeyValue& other) const
{
return _node != other._node;
}
private:
Internals::JsonNode* _node;
};