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 918-922 in src/c4/yml/node.hpp. Line 883 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 924-947 in src/c4/yml/node.hpp. Line 885 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;
}