Struct child_iterator

Synopsis

#include <src/c4/yml/node.hpp>

template<class Nd>
struct child_iterator

Description

No description yet.

Summary

child_iterator
operator++
operator--
operator*
operator->
operator!=
operator==

Source

Lines 697-715 in src/c4/yml/node.hpp.

template<class Nd>
struct child_iterator
{
    Tree * m_tree;
    size_t m_child_id;
    using value_type = NodeRef;
    child_iterator(Tree * t, size_t id) : m_tree(t), m_child_id(id) {}
    child_iterator& operator++ () { RYML_ASSERT(m_child_id != NONE); m_child_id = m_tree->next_sibling(m_child_id); return *this; }
    child_iterator& operator-- () { RYML_ASSERT(m_child_id != NONE); m_child_id = m_tree->prev_sibling(m_child_id); return *this; }
    Nd operator*  () const { return Nd(m_tree, m_child_id); }
    Nd operator-> () const { return Nd(m_tree, m_child_id); }
    bool operator!= (child_iterator that) const { RYML_ASSERT(m_tree == that.m_tree); return m_child_id != that.m_child_id; }
    bool operator== (child_iterator that) const { RYML_ASSERT(m_tree == that.m_tree); return m_child_id == that.m_child_id; }
};





Add Discussion as Guest

Log in