Template Struct RoNodeMethods

Struct Documentation

template<class Impl, class ConstImpl>
struct RoNodeMethods

a CRTP base for read-only node methods

iteration

using iterator = detail::child_iterator<Impl>
using const_iterator = detail::child_iterator<ConstImpl>
using children_view = detail::children_view_<Impl>
using const_children_view = detail::children_view_<ConstImpl>
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto begin () noexcept -> _C4_IF_MUTABLE(iterator)
inline C4_ALWAYS_INLINE C4_PURE const_iterator begin () const noexcept
inline C4_ALWAYS_INLINE C4_PURE const_iterator cbegin () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto end () noexcept -> _C4_IF_MUTABLE(iterator)
inline C4_ALWAYS_INLINE C4_PURE const_iterator end () const noexcept
inline C4_ALWAYS_INLINE C4_PURE const_iterator cend () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto children () noexcept -> _C4_IF_MUTABLE(children_view)

get an iterable view over children

inline C4_ALWAYS_INLINE C4_PURE const_children_view children () const noexcept

get an iterable view over children

inline C4_ALWAYS_INLINE C4_PURE const_children_view cchildren () const noexcept

get an iterable view over children

template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto siblings () noexcept -> _C4_IF_MUTABLE(children_view)

get an iterable view over all siblings (including the calling node)

inline C4_ALWAYS_INLINE C4_PURE const_children_view siblings () const noexcept

get an iterable view over all siblings (including the calling node)

inline C4_ALWAYS_INLINE C4_PURE const_children_view csiblings () const noexcept

get an iterable view over all siblings (including the calling node)

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

visit every child node calling fn(node)

template<class Visitor, class U = Impl>
inline auto visit(Visitor fn, size_t indentation_level = 0, bool skip_root = true) noexcept -> _C4_IF_MUTABLE(bool)

visit every child node calling fn(node)

template<class Visitor> inline C4_ALWAYS_INLINE C4_PURE bool visit_stacked (Visitor fn, size_t indentation_level=0, bool skip_root=true) const noexcept

visit every child node calling fn(node, level)

template<class Visitor, class U = Impl>
inline auto visit_stacked(Visitor fn, size_t indentation_level = 0, bool skip_root = true) noexcept -> _C4_IF_MUTABLE(bool)

visit every child node calling fn(node, level)

node property getters

inline C4_ALWAYS_INLINE C4_PURE NodeData const  * get () const noexcept

returns the data or null when the id is NONE

template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto get () noexcept -> _C4_IF_MUTABLE(NodeData *)

returns the data or null when the id is NONE

inline C4_ALWAYS_INLINE C4_PURE NodeType type () const noexcept
inline C4_ALWAYS_INLINE C4_PURE const char * type_str () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr key () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr key_tag () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr key_ref () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr key_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr val () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr val_tag () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr val_ref () const noexcept
inline C4_ALWAYS_INLINE C4_PURE csubstr val_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE NodeScalar const  & keysc () const noexcept
inline C4_ALWAYS_INLINE C4_PURE NodeScalar const  & valsc () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool key_is_null () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool val_is_null () const noexcept

node property predicates

inline C4_ALWAYS_INLINE C4_PURE bool empty () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_stream () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_doc () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_container () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_map () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_seq () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_val () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_key () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_val () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_keyval () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_key_tag () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_val_tag () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_key_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_key_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_val_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_val_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_anchor () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_key_ref () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_val_ref () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_ref () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_anchor_or_ref () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_key_quoted () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_val_quoted () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool is_quoted () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool parent_is_seq () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool parent_is_map () const noexcept

hierarchy predicates

inline C4_ALWAYS_INLINE C4_PURE bool is_root () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_parent () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_child (ConstImpl const &ch) const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_child (csubstr name) const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_children () const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_sibling (ConstImpl const &n) const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_sibling (csubstr name) const noexcept
inline C4_ALWAYS_INLINE C4_PURE bool has_siblings () const noexcept

counts with this

inline C4_ALWAYS_INLINE C4_PURE bool has_other_siblings () const noexcept

does not count with this

hierarchy getters

template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto doc (size_t num) noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl doc (size_t num) const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto parent () noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl parent () const noexcept
inline C4_ALWAYS_INLINE C4_PURE size_t child_pos (ConstImpl const &n) const noexcept

O(#num_children)

inline C4_ALWAYS_INLINE C4_PURE size_t num_children () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto first_child () noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl first_child () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto last_child () noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl last_child () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto child (size_t pos) noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl child (size_t pos) const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto find_child (csubstr name) noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl find_child (csubstr name) const noexcept
inline C4_ALWAYS_INLINE C4_PURE size_t num_siblings () const noexcept

O(num_siblings)

inline C4_ALWAYS_INLINE C4_PURE size_t num_other_siblings () const noexcept
inline C4_ALWAYS_INLINE C4_PURE size_t sibling_pos (ConstImpl const &n) const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto prev_sibling () noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl prev_sibling () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto next_sibling () noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl next_sibling () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto first_sibling () noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl first_sibling () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto last_sibling () noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl last_sibling () const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto sibling (size_t pos) noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl sibling (size_t pos) const noexcept
template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto find_sibling (csubstr name) noexcept -> _C4_IF_MUTABLE(Impl)
inline C4_ALWAYS_INLINE C4_PURE ConstImpl find_sibling (csubstr name) const noexcept
inline C4_ALWAYS_INLINE C4_PURE ConstImpl operator[] (csubstr k) const noexcept

O(num_children)

template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto operator[] (csubstr k) noexcept -> _C4_IF_MUTABLE(Impl)

Find child by key. O(num_children). returns a seed node if no such child is found.

inline C4_ALWAYS_INLINE C4_PURE ConstImpl operator[] (size_t pos) const noexcept

O(num_children)

template<class U = Impl> inline C4_ALWAYS_INLINE C4_PURE auto operator[] (size_t pos) noexcept -> _C4_IF_MUTABLE(Impl)

Find child by position. O(pos). returns a seed node if no such child is found.

Unnamed Group

template<class T>
inline ConstImpl const &operator>>(T &v) const

deserialization

template<class T>
inline ConstImpl const &operator>>(Key<T> v) const

deserialize the node’s key to the given variable

inline ConstImpl const &operator>>(Key<fmt::base64_wrapper> w) const

deserialize the node’s key as base64

inline ConstImpl const &operator>>(fmt::base64_wrapper w) const

deserialize the node’s val as base64

inline size_t deserialize_key(fmt::base64_wrapper v) const

decode the base64-encoded key and assign the decoded blob to the given buffer/

Returns:

the size of base64-decoded blob

inline size_t deserialize_val(fmt::base64_wrapper v) const

decode the base64-encoded key and assign the decoded blob to the given buffer/

Returns:

the size of base64-decoded blob

template<class T>
inline bool get_if(csubstr name, T *var) const
template<class T>
inline bool get_if(csubstr name, T *var, T const &fallback) const