libzeep

PrevUpHomeNext

Class template iterator_impl

zeep::xml::iterator_impl — generic iterator class.

Synopsis

// In header: <zeep/xml/node.hpp>

template<typename NodeType, 
         typename ContainerNodeType = std::remove_const_t<NodeType> > 
class iterator_impl {
public:
  // types
  typedef NodeType                               node_type;          
  typedef std::remove_cv_t< ContainerNodeType >  container_node_type;
  typedef basic_node_list< container_node_type > container_type;     
  typedef std::bidirectional_iterator_tag        iterator_category;  
  typedef node_type                              value_type;         
  typedef std::ptrdiff_t                         difference_type;    
  typedef value_type *                           pointer;            
  typedef value_type &                           reference;          

  // construct/copy/destruct
  iterator_impl() = default;
  iterator_impl(const iterator_impl &) = default;
  template<typename OtherNodeType, typename OtherContainerNodeType> 
    iterator_impl(const iterator_impl< OtherNodeType, OtherContainerNodeType > &);
  iterator_impl(const container_type &);
  iterator_impl(const container_type &, node_type *);
  iterator_impl(node_type *);
  iterator_impl(iterator_impl &&);
  template<typename Iterator, 
           std::enable_if_t< not std::is_same_v< std::remove_const_t< typename Iterator::value_type >, element > and std::is_base_of_v< value_type, typename Iterator::value_type >, int >  = 0> 
    iterator_impl(const Iterator &);
  iterator_impl & operator=(const iterator_impl &);
  iterator_impl & operator=(iterator_impl &&);
  template<typename Iterator, 
           std::enable_if_t< std::is_base_of_v< value_type, typename Iterator::value_type >, int >  = 0> 
    iterator_impl & operator=(const Iterator &);

  // public member functions
  reference operator*();
  pointer operator->() const;
  iterator_impl & operator++();
  iterator_impl operator++(int);
  iterator_impl & operator--();
  iterator_impl operator--(int);
  bool operator==(const iterator_impl &) const;
  bool operator!=(const iterator_impl &) const;
  template<typename RNodeType> bool operator==(const RNodeType *) const;
  template<typename RNodeType> bool operator!=(const RNodeType) const;
  iterator_impl & operator+=(difference_type);
  iterator_impl & operator-=(difference_type);
  iterator_impl operator+(difference_type) const;
  iterator_impl operator-(difference_type) const;
  difference_type operator-(const iterator_impl &) const;
  operator const pointer() const;
  operator pointer();

  // private member functions
  node_type * current() const;
  void skip();
  void skip();
  void skip();
  void skip();
  void skip();
};

Description

We can have iterators that point to nodes, elements and attributes. Iterating over nodes is simply following next/prev. But iterating elements is a bit more difficult, since you then have to skip nodes in between that are not an element, like comments or text.

iterator_impl public construct/copy/destruct

  1. iterator_impl() = default;
  2. iterator_impl(const iterator_impl & i) = default;
  3. template<typename OtherNodeType, typename OtherContainerNodeType> 
      iterator_impl(const iterator_impl< OtherNodeType, OtherContainerNodeType > & i);
    copy constructor, kind of
  4. iterator_impl(const container_type & container);
    create iterator pointing to begin of parent element
  5. iterator_impl(const container_type & container, node_type * current);
    create iterator pointing to end of parent element
  6. iterator_impl(node_type * current);
    constructor taking a node pointer
  7. iterator_impl(iterator_impl && i);
  8. template<typename Iterator, 
             std::enable_if_t< not std::is_same_v< std::remove_const_t< typename Iterator::value_type >, element > and std::is_base_of_v< value_type, typename Iterator::value_type >, int >  = 0> 
      iterator_impl(const Iterator & i);
  9. iterator_impl & operator=(const iterator_impl & i);
  10. iterator_impl & operator=(iterator_impl && i);
  11. template<typename Iterator, 
             std::enable_if_t< std::is_base_of_v< value_type, typename Iterator::value_type >, int >  = 0> 
      iterator_impl & operator=(const Iterator & i);

iterator_impl public member functions

  1. reference operator*();
  2. pointer operator->() const;
  3. iterator_impl & operator++();
  4. iterator_impl operator++(int);
  5. iterator_impl & operator--();
  6. iterator_impl operator--(int);
  7. bool operator==(const iterator_impl & other) const;
  8. bool operator!=(const iterator_impl & other) const;
  9. template<typename RNodeType> bool operator==(const RNodeType * n) const;
  10. template<typename RNodeType> bool operator!=(const RNodeType n) const;
  11. iterator_impl & operator+=(difference_type i);
  12. iterator_impl & operator-=(difference_type i);
  13. iterator_impl operator+(difference_type i) const;
  14. iterator_impl operator-(difference_type i) const;
  15. difference_type operator-(const iterator_impl & other) const;
  16. operator const pointer() const;
  17. operator pointer();

iterator_impl private member functions

  1. node_type * current() const;
  2. void skip();
  3. void skip();
  4. void skip();
  5. void skip();
  6. void skip();

PrevUpHomeNext