Function visit

Summary

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

(1) template <class Visitor>
    bool visit(Visitor fn, size_t indentation_level=0, bool skip_root=true)

(2) template <class Visitor>
    bool visit(Visitor fn, size_t indentation_level=0, bool skip_root=true) const

Function overload

Synopsis

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

template <class Visitor>
bool visit(Visitor fn, size_t indentation_level=0, bool skip_root=true)

Description

visit every child node calling fn(node)

Source

Lines 800-804 in src/c4/yml/node.hpp. Line 773 in src/c4/yml/node.hpp.

template<class Visitor>
bool NodeRef::visit(Visitor fn, size_t indentation_level, bool skip_root)
{
    return const_cast<NodeRef const*>(this)->visit(fn, indentation_level, skip_root);
}

Synopsis

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

template <class Visitor>
bool visit(Visitor fn, size_t indentation_level=0, bool skip_root=true) const

Description

visit every child node calling fn(node)

Source

Lines 806-829 in src/c4/yml/node.hpp. Line 775 in src/c4/yml/node.hpp.

template<class Visitor>
bool NodeRef::visit(Visitor fn, size_t indentation_level, bool skip_root) const
{
    size_t increment = 0;
    if( ! (is_root() && skip_root))
    {
        if(fn(this, indentation_level))
        {
            return true;
        }
        ++increment;
    }
    if(has_children())
    {
        for(auto ch : children())
        {
            if(ch.visit(fn, indentation_level + increment)) // no need to forward skip_root as it won't be root
            {
                return true;
            }
        }
    }
    return false;
}





Add Discussion as Guest

Log in