Files
ArduinoJson/include/ArduinoJson/Internals/ListConstIterator.hpp

42 lines
889 B
C++
Raw Normal View History

// Copyright Benoit Blanchon 2014-2016
// MIT License
//
// Arduino JSON library
// https://github.com/bblanchon/ArduinoJson
// If you like this project, please add a star!
#pragma once
2014-11-08 21:16:14 +01:00
#include "ListNode.hpp"
namespace ArduinoJson {
namespace Internals {
2014-11-06 14:27:14 +01:00
// A read-only forward itertor for List<T>
template <typename T>
2014-11-05 13:12:20 +01:00
class ListConstIterator {
public:
2014-11-05 13:14:15 +01:00
explicit ListConstIterator(const ListNode<T> *node = NULL) : _node(node) {}
const T &operator*() const { return _node->content; }
const T *operator->() { return &_node->content; }
2014-11-05 13:12:20 +01:00
bool operator==(const ListConstIterator<T> &other) const {
return _node == other._node;
}
2014-11-05 13:12:20 +01:00
bool operator!=(const ListConstIterator<T> &other) const {
return _node != other._node;
}
2014-11-05 13:12:20 +01:00
ListConstIterator<T> &operator++() {
if (_node) _node = _node->next;
return *this;
}
private:
2014-11-05 13:14:15 +01:00
const ListNode<T> *_node;
};
}
}