Files
ArduinoJson/include/ArduinoJson/Internals/ListIterator.hpp

40 lines
744 B
C++
Raw Normal View History

// Copyright Benoit Blanchon 2014
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
#pragma once
2014-11-05 13:14:15 +01:00
#include "ListNode.hpp"
namespace ArduinoJson {
namespace Internals {
template <typename T>
2014-11-05 13:12:20 +01:00
class ListIterator {
public:
2014-11-05 13:14:15 +01:00
explicit ListIterator(ListNode<T> *node = NULL) : _node(node) {}
T &operator*() const { return _node->content; }
T *operator->() { return &_node->content; }
2014-11-05 13:12:20 +01:00
bool operator==(const ListIterator<T> &other) const {
return _node == other._node;
}
2014-11-05 13:12:20 +01:00
bool operator!=(const ListIterator<T> &other) const {
return _node != other._node;
}
2014-11-05 13:12:20 +01:00
ListIterator<T> &operator++() {
if (_node) _node = _node->next;
return *this;
}
private:
2014-11-05 13:14:15 +01:00
ListNode<T> *_node;
};
}
}