131 lines
3.0 KiB
C++
131 lines
3.0 KiB
C++
#ifndef SCHEMA_NODE_ITERATOR_HPP
|
|
#define SCHEMA_NODE_ITERATOR_HPP
|
|
|
|
#include "matador/object/schema_node.hpp"
|
|
|
|
#include <iterator>
|
|
|
|
namespace matador::object {
|
|
|
|
class const_schema_node_iterator {
|
|
public:
|
|
using iterator_category = std::bidirectional_iterator_tag;
|
|
using difference_type = std::ptrdiff_t;
|
|
using value_type = schema_node;
|
|
using pointer = value_type*;
|
|
using reference = value_type&;
|
|
|
|
/**
|
|
* Creates an empty iterator
|
|
*/
|
|
const_schema_node_iterator() = default;
|
|
|
|
/**
|
|
* @brief Creates an iterator for a concrete type.
|
|
*
|
|
* This constructor creates an iterator for a concrete
|
|
* type and a concrete object.
|
|
*
|
|
* @param node The schema node of the object
|
|
*/
|
|
explicit const_schema_node_iterator(std::shared_ptr<value_type> node);
|
|
|
|
/**
|
|
* Copy from a given const_object_view_iterator.
|
|
*
|
|
* @param x The prototype_iterator to copy from.
|
|
*/
|
|
const_schema_node_iterator(const const_schema_node_iterator &x) = default;
|
|
|
|
/**
|
|
* Assign from a given prototype_iterator.
|
|
*
|
|
* @param x The prototype_iterator to assign from.
|
|
* @return The assigned prototype_iterator.
|
|
*/
|
|
const_schema_node_iterator& operator=(const const_schema_node_iterator &x) = default;
|
|
|
|
~const_schema_node_iterator() = default;
|
|
|
|
/**
|
|
* @brief Compares this with another iterators.
|
|
*
|
|
* Compares this with another iterators. Returns true
|
|
* if the iterators node prototype_type are the same.
|
|
*
|
|
* @param i The iterator to compare with.
|
|
* @return True if the iterators are the same.
|
|
*/
|
|
bool operator==(const const_schema_node_iterator &i) const;
|
|
|
|
/**
|
|
* @brief Compares this with another iterators.
|
|
*
|
|
* Compares this with another iterators. Returns true
|
|
* if the iterators node prototype_node are not the same.
|
|
*
|
|
* @param i The iterator to compare with.
|
|
* @return True if the iterators are not the same.
|
|
*/
|
|
bool operator!=(const const_schema_node_iterator &i) const;
|
|
|
|
/**
|
|
* Pre increments the iterator
|
|
*
|
|
* @return Returns iterators successor.
|
|
*/
|
|
const_schema_node_iterator& operator++();
|
|
|
|
/**
|
|
* Post increments the iterator
|
|
*
|
|
* @return Returns iterator before incrementing.
|
|
*/
|
|
const_schema_node_iterator operator++(int);
|
|
|
|
/**
|
|
* Pre increments the iterator
|
|
*
|
|
* @return Returns iterators predecessor.
|
|
*/
|
|
const_schema_node_iterator& operator--();
|
|
|
|
/**
|
|
* Post decrements the iterator
|
|
*
|
|
* @return Returns iterator before decrementing.
|
|
*/
|
|
const_schema_node_iterator operator--(int);
|
|
|
|
/**
|
|
* Returns the pointer to the node.
|
|
*
|
|
* @return The pointer to the node.
|
|
*/
|
|
pointer operator->() const;
|
|
|
|
/**
|
|
* Returns the node.
|
|
*
|
|
* @return The iterators underlying node.
|
|
*/
|
|
const reference operator*() const;
|
|
|
|
/**
|
|
* Returns the pointer to the node.
|
|
*
|
|
* @return The pointer to the node.
|
|
*/
|
|
[[nodiscard]] pointer get() const;
|
|
|
|
private:
|
|
void increment();
|
|
void decrement();
|
|
|
|
private:
|
|
std::shared_ptr<value_type> node_;
|
|
};
|
|
|
|
}
|
|
#endif //SCHEMA_NODE_ITERATOR_HPP
|