rapidyaml  0.11.0
parse and emit YAML, and do it fast
c4::yml::NodeRef Class Reference

A reference to a node in an existing yaml tree, offering a more convenient API than the index-based API used in the tree. More...

#include <node.hpp>

Inheritance diagram for c4::yml::NodeRef:
c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >

Public Types

using tree_type = Tree
 
using base_type = detail::RoNodeMethods< NodeRef, ConstNodeRef >
 

Public Member Functions

construction
 NodeRef () noexcept
 
 NodeRef (Tree &t) noexcept
 
 NodeRef (Tree *t) noexcept
 
 NodeRef (Tree *t, id_type id) noexcept
 
 NodeRef (Tree *t, id_type id, id_type seed_pos) noexcept
 
 NodeRef (Tree *t, id_type id, csubstr seed_key) noexcept
 
 NodeRef (std::nullptr_t) noexcept
 
void _clear_seed () noexcept
 
assignment
 NodeRef (NodeRef const &) noexcept=default
 
 NodeRef (NodeRef &&) noexcept=default
 
NodeRefoperator= (NodeRef const &) noexcept=default
 
NodeRefoperator= (NodeRef &&) noexcept=default
 
state_queries
bool invalid () const noexcept
 true if the object is not referring to any existing or seed node. More...
 
bool is_seed () const noexcept
 true if the object is not invalid and in seed state. More...
 
bool readable () const noexcept
 true if the object is not invalid and not in seed state. More...
 
bool valid () const
 
comparisons
bool operator== (NodeRef const &that) const
 
bool operator!= (NodeRef const &that) const
 
bool operator== (ConstNodeRef const &that) const
 
bool operator!= (ConstNodeRef const &that) const
 
node_property_getters
Treetree () noexcept
 
Tree const * tree () const noexcept
 
id_type id () const noexcept
 
node_modifiers
void create ()
 
void change_type (NodeType t)
 
void set_type (NodeType t)
 
void set_key (csubstr key)
 
void set_val (csubstr val)
 
void set_key_tag (csubstr key_tag)
 
void set_val_tag (csubstr val_tag)
 
void set_key_anchor (csubstr key_anchor)
 
void set_val_anchor (csubstr val_anchor)
 
void set_key_ref (csubstr key_ref)
 
void set_val_ref (csubstr val_ref)
 
void set_container_style (NodeType_e style)
 
void set_key_style (NodeType_e style)
 
void set_val_style (NodeType_e style)
 
void clear_style (bool recurse=false)
 
void set_style_conditionally (NodeType type_mask, NodeType rem_style_flags, NodeType add_style_flags, bool recurse=false)
 
void clear ()
 
void clear_key ()
 
void clear_val ()
 
void clear_children ()
 
void operator= (NodeType_e t)
 
void operator|= (NodeType_e t)
 
void operator= (NodeInit const &v)
 
void operator= (NodeScalar const &v)
 
void operator= (std::nullptr_t)
 
void operator= (csubstr v)
 
template<size_t N>
void operator= (const char(&v)[N])
 
serialization
template<class T >
csubstr to_arena (T const &s)
 serialize a variable to the arena More...
 
template<class T >
size_t set_key_serialized (T const &k)
 
size_t set_key_serialized (std::nullptr_t)
 
template<class T >
size_t set_val_serialized (T const &v)
 
size_t set_val_serialized (std::nullptr_t)
 
size_t set_key_serialized (fmt::const_base64_wrapper w)
 encode a blob as base64 into the tree's arena, then assign the result to the node's key More...
 
size_t set_val_serialized (fmt::const_base64_wrapper w)
 encode a blob as base64 into the tree's arena, then assign the result to the node's val More...
 
NodeRefoperator<< (csubstr s)
 serialize a variable, then assign the result to the node's val More...
 
template<class T >
NodeRefoperator<< (T const &v)
 
template<class T >
NodeRefoperator<< (Key< const T > const &v)
 serialize a variable, then assign the result to the node's key More...
 
template<class T >
NodeRefoperator<< (Key< T > const &v)
 serialize a variable, then assign the result to the node's key More...
 
NodeRefoperator<< (Key< fmt::const_base64_wrapper > w)
 
NodeRefoperator<< (fmt::const_base64_wrapper w)
 
modification of hierarchy
NodeRef insert_child (NodeRef after)
 
NodeRef insert_child (NodeInit const &i, NodeRef after)
 
NodeRef prepend_child ()
 
NodeRef prepend_child (NodeInit const &i)
 
NodeRef append_child ()
 
NodeRef append_child (NodeInit const &i)
 
NodeRef insert_sibling (ConstNodeRef const &after)
 
NodeRef insert_sibling (NodeInit const &i, ConstNodeRef const &after)
 
NodeRef prepend_sibling ()
 
NodeRef prepend_sibling (NodeInit const &i)
 
NodeRef append_sibling ()
 
NodeRef append_sibling (NodeInit const &i)
 
void remove_child (NodeRef &child)
 
void remove_child (id_type pos)
 remove the nth child of this node More...
 
void remove_child (csubstr key)
 remove a child by name More...
 
void move (ConstNodeRef const &after)
 change the node's position within its parent, placing it after after. More...
 
void move (NodeRef const &parent, ConstNodeRef const &after)
 move the node to a different parent (which may belong to a different tree), placing it after after. More...
 
NodeRef duplicate (ConstNodeRef const &after) const
 duplicate the current node somewhere within its parent, and place it after the node after. More...
 
NodeRef duplicate (NodeRef const &parent, ConstNodeRef const &after) const
 duplicate the current node somewhere into a different parent (possibly from a different tree), and place it after the node after. More...
 
void duplicate_children (NodeRef const &parent, ConstNodeRef const &after) const
 
node property getters
NodeData const * get () const RYML_NOEXCEPT
 returns the data or null when the id is NONE More...
 
auto get () RYML_NOEXCEPT -> NodeData *
 returns the data or null when the id is NONE More...
 
NodeType type () const RYML_NOEXCEPT
 Forward to Tree::type(). More...
 
const char * type_str () const RYML_NOEXCEPT
 Forward to Tree::type_str(). More...
 
csubstr key () const RYML_NOEXCEPT
 Forward to Tree::key(). More...
 
csubstr key_tag () const RYML_NOEXCEPT
 Forward to Tree::key_tag(). More...
 
csubstr key_ref () const RYML_NOEXCEPT
 Forward to Tree::key_ref(). More...
 
csubstr key_anchor () const RYML_NOEXCEPT
 Forward to Tree::key_anchor(). More...
 
csubstr val () const RYML_NOEXCEPT
 Forward to Tree::val(). More...
 
csubstr val_tag () const RYML_NOEXCEPT
 Forward to Tree::val_tag(). More...
 
csubstr val_ref () const RYML_NOEXCEPT
 Forward to Tree::val_ref(). More...
 
csubstr val_anchor () const RYML_NOEXCEPT
 Forward to Tree::val_anchor(). More...
 
NodeScalar const & keysc () const RYML_NOEXCEPT
 Forward to Tree::keysc(). More...
 
NodeScalar const & valsc () const RYML_NOEXCEPT
 Forward to Tree::valsc(). More...
 
bool key_is_null () const RYML_NOEXCEPT
 Forward to Tree::key_is_null(). More...
 
bool val_is_null () const RYML_NOEXCEPT
 Forward to Tree::val_is_null(). More...
 
bool is_key_unfiltered () const noexcept
 Forward to Tree::is_key_unfiltered(). More...
 
bool is_val_unfiltered () const noexcept
 Forward to Tree::is_val_unfiltered(). More...
 
node type predicates
bool empty () const RYML_NOEXCEPT
 Forward to Tree::empty(). More...
 
bool is_stream () const RYML_NOEXCEPT
 Forward to Tree::is_stream(). More...
 
bool is_doc () const RYML_NOEXCEPT
 Forward to Tree::is_doc(). More...
 
bool is_container () const RYML_NOEXCEPT
 Forward to Tree::is_container(). More...
 
bool is_map () const RYML_NOEXCEPT
 Forward to Tree::is_map(). More...
 
bool is_seq () const RYML_NOEXCEPT
 Forward to Tree::is_seq(). More...
 
bool has_val () const RYML_NOEXCEPT
 Forward to Tree::has_val(). More...
 
bool has_key () const RYML_NOEXCEPT
 Forward to Tree::has_key(). More...
 
bool is_val () const RYML_NOEXCEPT
 Forward to Tree::is_val(). More...
 
bool is_keyval () const RYML_NOEXCEPT
 Forward to Tree::is_keyval(). More...
 
bool has_key_tag () const RYML_NOEXCEPT
 Forward to Tree::has_key_tag(). More...
 
bool has_val_tag () const RYML_NOEXCEPT
 Forward to Tree::has_val_tag(). More...
 
bool has_key_anchor () const RYML_NOEXCEPT
 Forward to Tree::has_key_anchor(). More...
 
bool has_val_anchor () const RYML_NOEXCEPT
 Forward to Tree::has_val_anchor(). More...
 
bool has_anchor () const RYML_NOEXCEPT
 Forward to Tree::has_anchor(). More...
 
bool is_key_ref () const RYML_NOEXCEPT
 Forward to Tree::is_key_ref(). More...
 
bool is_val_ref () const RYML_NOEXCEPT
 Forward to Tree::is_val_ref(). More...
 
bool is_ref () const RYML_NOEXCEPT
 Forward to Tree::is_ref(). More...
 
bool parent_is_seq () const RYML_NOEXCEPT
 Forward to Tree::parent_is_seq(). More...
 
bool parent_is_map () const RYML_NOEXCEPT
 Forward to Tree::parent_is_map(). More...
 
bool is_key_anchor () const noexcept
 
bool is_val_hanchor () const noexcept
 
bool is_anchor () const noexcept
 
bool is_anchor_or_ref () const noexcept
 
style predicates
bool type_has_any (NodeType_e bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_any(). More...
 
bool type_has_all (NodeType_e bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_all(). More...
 
bool type_has_none (NodeType_e bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_none(). More...
 
NodeType key_style () const RYML_NOEXCEPT
 Forward to Tree::key_style(). More...
 
NodeType val_style () const RYML_NOEXCEPT
 Forward to Tree::val_style(). More...
 
bool is_container_styled () const RYML_NOEXCEPT
 Forward to Tree::is_container_styled(). More...
 
bool is_block () const RYML_NOEXCEPT
 Forward to Tree::is_block(). More...
 
bool is_flow_sl () const RYML_NOEXCEPT
 Forward to Tree::is_flow_sl(). More...
 
bool is_flow_ml () const RYML_NOEXCEPT
 Forward to Tree::is_flow_ml(). More...
 
bool is_flow () const RYML_NOEXCEPT
 Forward to Tree::is_flow(). More...
 
bool is_key_styled () const RYML_NOEXCEPT
 Forward to Tree::is_key_styled(). More...
 
bool is_val_styled () const RYML_NOEXCEPT
 Forward to Tree::is_val_styled(). More...
 
bool is_key_literal () const RYML_NOEXCEPT
 Forward to Tree::is_key_literal(). More...
 
bool is_val_literal () const RYML_NOEXCEPT
 Forward to Tree::is_val_literal(). More...
 
bool is_key_folded () const RYML_NOEXCEPT
 Forward to Tree::is_key_folded(). More...
 
bool is_val_folded () const RYML_NOEXCEPT
 Forward to Tree::is_val_folded(). More...
 
bool is_key_squo () const RYML_NOEXCEPT
 Forward to Tree::is_key_squo(). More...
 
bool is_val_squo () const RYML_NOEXCEPT
 Forward to Tree::is_val_squo(). More...
 
bool is_key_dquo () const RYML_NOEXCEPT
 Forward to Tree::is_key_dquo(). More...
 
bool is_val_dquo () const RYML_NOEXCEPT
 Forward to Tree::is_val_dquo(). More...
 
bool is_key_plain () const RYML_NOEXCEPT
 Forward to Tree::is_key_plain(). More...
 
bool is_val_plain () const RYML_NOEXCEPT
 Forward to Tree::is_val_plain(). More...
 
bool is_key_quoted () const RYML_NOEXCEPT
 Forward to Tree::is_key_quoted(). More...
 
bool is_val_quoted () const RYML_NOEXCEPT
 Forward to Tree::is_val_quoted(). More...
 
bool is_quoted () const RYML_NOEXCEPT
 Forward to Tree::is_quoted(). More...
 
hierarchy predicates
bool is_root () const RYML_NOEXCEPT
 Forward to Tree::is_root(). More...
 
bool has_parent () const RYML_NOEXCEPT
 Forward to Tree::has_parent() Node must be readable. More...
 
bool is_ancestor (ConstNodeRef const &ancestor) const RYML_NOEXCEPT
 Forward to Tree::is_ancestor() Node must be readable. More...
 
bool has_child (ConstNodeRef const &n) const RYML_NOEXCEPT
 Forward to Tree::has_child(). More...
 
bool has_child (id_type node) const RYML_NOEXCEPT
 Forward to Tree::has_child(). More...
 
bool has_child (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::has_child(). More...
 
bool has_children () const RYML_NOEXCEPT
 Forward to Tree::has_children(). More...
 
bool has_sibling (ConstNodeRef const &n) const RYML_NOEXCEPT
 Forward to Tree::has_sibling(). More...
 
bool has_sibling (id_type node) const RYML_NOEXCEPT
 Forward to Tree::has_sibling(). More...
 
bool has_sibling (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::has_sibling(). More...
 
bool has_other_siblings () const RYML_NOEXCEPT
 Forward to Tree::has_other_siblings(). More...
 
bool has_siblings () const RYML_NOEXCEPT
 
hierarchy getters
auto doc (id_type i) RYML_NOEXCEPT -> NodeRef
 Forward to Tree::doc(). More...
 
ConstNodeRef doc (id_type i) const RYML_NOEXCEPT
 Forward to Tree::doc(). More...
 
auto parent () RYML_NOEXCEPT -> NodeRef
 Forward to Tree::parent(). More...
 
ConstNodeRef parent () const RYML_NOEXCEPT
 Forward to Tree::parent(). More...
 
auto first_child () RYML_NOEXCEPT -> NodeRef
 Forward to Tree::first_child(). More...
 
ConstNodeRef first_child () const RYML_NOEXCEPT
 Forward to Tree::first_child(). More...
 
auto last_child () RYML_NOEXCEPT -> NodeRef
 Forward to Tree::last_child(). More...
 
ConstNodeRef last_child () const RYML_NOEXCEPT
 Forward to Tree::last_child(). More...
 
auto child (id_type pos) RYML_NOEXCEPT -> NodeRef
 Forward to Tree::child(). More...
 
ConstNodeRef child (id_type pos) const RYML_NOEXCEPT
 Forward to Tree::child(). More...
 
auto find_child (csubstr name) RYML_NOEXCEPT -> NodeRef
 Forward to Tree::find_child(). More...
 
ConstNodeRef find_child (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::find_child(). More...
 
auto prev_sibling () RYML_NOEXCEPT -> NodeRef
 Forward to Tree::prev_sibling(). More...
 
ConstNodeRef prev_sibling () const RYML_NOEXCEPT
 Forward to Tree::prev_sibling(). More...
 
auto next_sibling () RYML_NOEXCEPT -> NodeRef
 Forward to Tree::next_sibling(). More...
 
ConstNodeRef next_sibling () const RYML_NOEXCEPT
 Forward to Tree::next_sibling(). More...
 
auto first_sibling () RYML_NOEXCEPT -> NodeRef
 Forward to Tree::first_sibling(). More...
 
ConstNodeRef first_sibling () const RYML_NOEXCEPT
 Forward to Tree::first_sibling(). More...
 
auto last_sibling () RYML_NOEXCEPT -> NodeRef
 Forward to Tree::last_sibling(). More...
 
ConstNodeRef last_sibling () const RYML_NOEXCEPT
 Forward to Tree::last_sibling(). More...
 
auto sibling (id_type pos) RYML_NOEXCEPT -> NodeRef
 Forward to Tree::sibling(). More...
 
ConstNodeRef sibling (id_type pos) const RYML_NOEXCEPT
 Forward to Tree::sibling(). More...
 
auto find_sibling (csubstr name) RYML_NOEXCEPT -> NodeRef
 Forward to Tree::find_sibling(). More...
 
ConstNodeRef find_sibling (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::find_sibling(). More...
 
id_type num_children () const RYML_NOEXCEPT
 O(num_children). More...
 
id_type num_siblings () const RYML_NOEXCEPT
 O(num_children). More...
 
id_type num_other_siblings () const RYML_NOEXCEPT
 O(num_siblings). More...
 
id_type child_pos (ConstNodeRef const &n) const RYML_NOEXCEPT
 O(num_children). More...
 
id_type sibling_pos (ConstNodeRef const &n) const RYML_NOEXCEPT
 O(num_siblings). More...
 
id_type depth_asc () const RYML_NOEXCEPT
 
id_type depth_desc () const RYML_NOEXCEPT
 O(log(num_nodes)). More...
 
square_brackets

O(num_nodes).

Forward to Tree::depth_desc(). Node must be readable.

operator[]

auto operator[] (csubstr key) RYML_NOEXCEPT -> NodeRef
 Find child by key; complexity is O(num_children). More...
 
auto operator[] (id_type pos) RYML_NOEXCEPT -> NodeRef
 Find child by position; complexity is O(pos). More...
 
ConstNodeRef operator[] (csubstr key) const RYML_NOEXCEPT
 Find a child by key; complexity is O(num_children). More...
 
ConstNodeRef operator[] (id_type pos) const RYML_NOEXCEPT
 Find a child by position; complexity is O(pos). More...
 
at

These functions are the analogue to operator[], with the difference that they emit an error instead of an assertion.

That is, if any of the pre or post conditions is violated, an error is always emitted (resulting in a call to the error callback).

auto at (csubstr key) -> NodeRef
 Find child by key; complexity is O(num_children). More...
 
auto at (id_type pos) -> NodeRef
 Find child by position; complexity is O(pos). More...
 
ConstNodeRef at (csubstr key) const
 Get a child by name, with error checking; complexity is O(num_children). More...
 
ConstNodeRef at (id_type pos) const
 Get a child by position, with error checking; complexity is O(pos). More...
 
locations
Location location (Parser const &parser) const
 
deserialization
ConstNodeRef const & operator>> (T &v) const
 deserialize the node's val to the given variable, forwarding to the user-overrideable read() function. More...
 
ConstNodeRef const & operator>> (Key< T > v) const
 deserialize the node's key to the given variable, forwarding to the user-overrideable read() function; use key() to disambiguate; for example: node >> ryml::key(var) More...
 
bool get_if (csubstr name, T *var) const
 look for a child by name, if it exists assign to var. More...
 
bool get_if (csubstr name, T *var, T const &fallback) const
 look for a child by name, if it exists assign to var, otherwise default to fallback. More...
 
deserialization_base64
ConstNodeRef const & operator>> (Key< fmt::base64_wrapper > w) const
 deserialize the node's key as base64. More...
 
ConstNodeRef const & operator>> (fmt::base64_wrapper w) const
 deserialize the node's val as base64. More...
 
size_t deserialize_key (fmt::base64_wrapper v) const
 decode the base64-encoded key and assign the decoded blob to the given buffer/ More...
 
size_t deserialize_val (fmt::base64_wrapper v) const
 decode the base64-encoded key and assign the decoded blob to the given buffer/ More...
 

Friends

struct detail::RoNodeMethods< NodeRef, ConstNodeRef >
 

iteration

using iterator = detail::child_iterator< NodeRef >
 
using const_iterator = detail::child_iterator< ConstNodeRef >
 
using children_view = detail::children_view_< NodeRef >
 
using const_children_view = detail::children_view_< ConstNodeRef >
 
auto begin () RYML_NOEXCEPT -> iterator
 get a mutable iterator to the first child. More...
 
const_iterator begin () const RYML_NOEXCEPT
 get an iterator to the first child More...
 
const_iterator cbegin () const RYML_NOEXCEPT
 get an iterator to the first child More...
 
auto end () RYML_NOEXCEPT -> iterator
 get an iterator to after the last child. More...
 
const_iterator end () const RYML_NOEXCEPT
 get an iterator to after the last child More...
 
const_iterator cend () const RYML_NOEXCEPT
 get an iterator to after the last child More...
 
auto children () RYML_NOEXCEPT -> children_view
 get an iterable view over children. More...
 
const_children_view children () const RYML_NOEXCEPT
 get an iterable view over children More...
 
const_children_view cchildren () const RYML_NOEXCEPT
 get an iterable view over children More...
 
auto siblings () RYML_NOEXCEPT -> children_view
 get an iterable view over all siblings (including the calling node) More...
 
const_children_view siblings () const RYML_NOEXCEPT
 get an iterable view over all siblings (including the calling node) More...
 
const_children_view csiblings () const RYML_NOEXCEPT
 get an iterable view over all siblings (including the calling node) More...
 
bool visit (Visitor fn, id_type indentation_level=0, bool skip_root=true) const RYML_NOEXCEPT
 visit every child node calling fn(node) More...
 
auto visit (Visitor fn, id_type indentation_level=0, bool skip_root=true) RYML_NOEXCEPT -> bool
 visit every child node calling fn(node) More...
 
bool visit_stacked (Visitor fn, id_type indentation_level=0, bool skip_root=true) const RYML_NOEXCEPT
 visit every child node calling fn(node, level) More...
 
auto visit_stacked (Visitor fn, id_type indentation_level=0, bool skip_root=true) RYML_NOEXCEPT -> bool
 visit every child node calling fn(node, level) More...
 

Detailed Description

A reference to a node in an existing yaml tree, offering a more convenient API than the index-based API used in the tree.

Unlike its imutable ConstNodeRef peer, a NodeRef can be used to mutate the tree, both by writing to existing nodes and by creating new nodes to subsequently write to. Semantically, a NodeRef object can be in one of three states:

invalid := not pointing at anything
readable := points at an existing tree/node
seed := points at an existing tree, and the node
may come to exist, if we write to it.

So both readable and seed are states where the node is also valid.

Tree t = parse_in_arena("{a: b}");
NodeRef invalid; // not pointing at anything.
NodeRef readable = t["a"]; // also valid, because "a" exists
NodeRef seed = t["none"]; // also valid, but is seed because "none" is not in the map
NodeRef() noexcept
Definition: node.hpp:1029
bool invalid() const noexcept
true if the object is not referring to any existing or seed node.
Definition: node.hpp:1060
bool readable() const noexcept
true if the object is not invalid and not in seed state.
Definition: node.hpp:1064
void parse_in_arena(Parser *parser, csubstr filename, csubstr yaml, Tree *t, id_type node_id)
(1) parse YAML into an existing tree node. The filename will be used in any error messages arising du...
Definition: parse.cpp:91

When the object is in seed state, using it to read from the tree is UB. The seed node can be used to write to the tree, provided that its create() method is called prior to writing, which happens in most modifying methods in NodeRef.

It is the owners's responsibility to verify that an existing node is readable before subsequently using it to read from the tree.

Warning
The lifetime of the tree must be larger than that of this object. It is up to the user to ensure that this happens.

Definition at line 988 of file node.hpp.

Member Typedef Documentation

◆ tree_type

Definition at line 992 of file node.hpp.

◆ base_type

◆ iterator

using c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::iterator = detail::child_iterator<NodeRef >
inherited

Definition at line 742 of file node.hpp.

◆ const_iterator

using c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::const_iterator = detail::child_iterator<ConstNodeRef >
inherited

Definition at line 743 of file node.hpp.

◆ children_view

using c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::children_view = detail::children_view_<NodeRef >
inherited

Definition at line 744 of file node.hpp.

◆ const_children_view

using c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::const_children_view = detail::children_view_<ConstNodeRef >
inherited

Definition at line 745 of file node.hpp.

Constructor & Destructor Documentation

◆ NodeRef() [1/9]

c4::yml::NodeRef::NodeRef ( )
inlinenoexcept

Definition at line 1029 of file node.hpp.

1029 : m_tree(nullptr), m_id(NONE), m_seed() { _clear_seed(); }
void _clear_seed() noexcept
Definition: node.hpp:1037
@ NONE
an index to none
Definition: common.hpp:251

◆ NodeRef() [2/9]

c4::yml::NodeRef::NodeRef ( Tree t)
inlinenoexcept

Definition at line 1030 of file node.hpp.

1030 : m_tree(&t), m_id(t .root_id()), m_seed() { _clear_seed(); }

◆ NodeRef() [3/9]

c4::yml::NodeRef::NodeRef ( Tree t)
inlinenoexcept

Definition at line 1031 of file node.hpp.

1031 : m_tree(t ), m_id(t->root_id()), m_seed() { _clear_seed(); }

◆ NodeRef() [4/9]

c4::yml::NodeRef::NodeRef ( Tree t,
id_type  id 
)
inlinenoexcept

Definition at line 1032 of file node.hpp.

1032 : m_tree(t), m_id(id), m_seed() { _clear_seed(); }

◆ NodeRef() [5/9]

c4::yml::NodeRef::NodeRef ( Tree t,
id_type  id,
id_type  seed_pos 
)
inlinenoexcept

Definition at line 1033 of file node.hpp.

1033 : m_tree(t), m_id(id), m_seed() { m_seed.str = nullptr; m_seed.len = (size_t)seed_pos; }

◆ NodeRef() [6/9]

c4::yml::NodeRef::NodeRef ( Tree t,
id_type  id,
csubstr  seed_key 
)
inlinenoexcept

Definition at line 1034 of file node.hpp.

1034 : m_tree(t), m_id(id), m_seed(seed_key) {}

◆ NodeRef() [7/9]

c4::yml::NodeRef::NodeRef ( std::nullptr_t  )
inlinenoexcept

Definition at line 1035 of file node.hpp.

1035 : m_tree(nullptr), m_id(NONE), m_seed() {}

◆ NodeRef() [8/9]

c4::yml::NodeRef::NodeRef ( NodeRef const &  )
defaultnoexcept

◆ NodeRef() [9/9]

c4::yml::NodeRef::NodeRef ( NodeRef &&  )
defaultnoexcept

Member Function Documentation

◆ _clear_seed()

void c4::yml::NodeRef::_clear_seed ( )
inlinenoexcept

Definition at line 1037 of file node.hpp.

1037 { /*do the following manually or an assert is triggered: */ m_seed.str = nullptr; m_seed.len = npos; }
@ npos
a null string position
Definition: common.hpp:258

References c4::yml::npos.

◆ operator=() [1/8]

NodeRef& c4::yml::NodeRef::operator= ( NodeRef const &  )
defaultnoexcept

◆ operator=() [2/8]

NodeRef& c4::yml::NodeRef::operator= ( NodeRef &&  )
defaultnoexcept

◆ invalid()

bool c4::yml::NodeRef::invalid ( ) const
inlinenoexcept

true if the object is not referring to any existing or seed node.

See also
the doc for NodeRef

Definition at line 1060 of file node.hpp.

1060 { return m_tree == nullptr || m_id == NONE; }

References c4::yml::NONE.

◆ is_seed()

bool c4::yml::NodeRef::is_seed ( ) const
inlinenoexcept

true if the object is not invalid and in seed state.

See also
the doc for NodeRef

Definition at line 1062 of file node.hpp.

1062 { return (m_tree != nullptr && m_id != NONE) && (m_seed.str != nullptr || m_seed.len != (size_t)NONE); }

References c4::yml::NONE.

◆ readable()

bool c4::yml::NodeRef::readable ( ) const
inlinenoexcept

true if the object is not invalid and not in seed state.

See also
the doc for NodeRef

Definition at line 1064 of file node.hpp.

1064 { return (m_tree != nullptr && m_id != NONE) && (m_seed.str == nullptr && m_seed.len == (size_t)NONE); }

References c4::yml::NONE.

◆ valid()

bool c4::yml::NodeRef::valid ( ) const
inline

Definition at line 1066 of file node.hpp.

1066 { return m_tree != nullptr && m_id != NONE; }

References c4::yml::NONE.

◆ operator==() [1/2]

bool c4::yml::NodeRef::operator== ( NodeRef const &  that) const
inline

Definition at line 1075 of file node.hpp.

1076  {
1077  if(m_tree == that.m_tree && m_id == that.m_id)
1078  {
1079  bool seed = is_seed();
1080  if(seed == that.is_seed())
1081  {
1082  if(seed)
1083  {
1084  return (m_seed.len == that.m_seed.len)
1085  && (m_seed.str == that.m_seed.str
1086  || m_seed == that.m_seed); // do strcmp only in the last resort
1087  }
1088  return true;
1089  }
1090  }
1091  return false;
1092  }
bool is_seed() const noexcept
true if the object is not invalid and in seed state.
Definition: node.hpp:1062

References is_seed().

◆ operator!=() [1/2]

bool c4::yml::NodeRef::operator!= ( NodeRef const &  that) const
inline

Definition at line 1093 of file node.hpp.

1093 { return ! this->operator==(that); }
bool operator==(NodeRef const &that) const
Definition: node.hpp:1075

References c4::operator==().

◆ operator==() [2/2]

bool c4::yml::NodeRef::operator== ( ConstNodeRef const &  that) const
inline

Definition at line 1095 of file node.hpp.

1095 { return m_tree == that.m_tree && m_id == that.m_id && !is_seed(); }

References c4::yml::ConstNodeRef::m_id, and c4::yml::ConstNodeRef::m_tree.

◆ operator!=() [2/2]

bool c4::yml::NodeRef::operator!= ( ConstNodeRef const &  that) const
inline

Definition at line 1096 of file node.hpp.

1096 { return ! this->operator==(that); }

References c4::operator==().

◆ tree() [1/2]

Tree* c4::yml::NodeRef::tree ( )
inlinenoexcept

Definition at line 1111 of file node.hpp.

1111 { return m_tree; }

◆ tree() [2/2]

Tree const* c4::yml::NodeRef::tree ( ) const
inlinenoexcept

Definition at line 1112 of file node.hpp.

1112 { return m_tree; }

◆ id()

id_type c4::yml::NodeRef::id ( ) const
inlinenoexcept

Definition at line 1114 of file node.hpp.

1114 { return m_id; }

◆ create()

void c4::yml::NodeRef::create ( )
inline

Definition at line 1123 of file node.hpp.

1123 { _apply_seed(); }

◆ change_type()

void c4::yml::NodeRef::change_type ( NodeType  t)
inline

Definition at line 1125 of file node.hpp.

1125 { _C4RR(); m_tree->change_type(m_id, t); }
bool change_type(id_type node, NodeType type)
change the type of the node to one of MAP, SEQ or VAL.
Definition: tree.cpp:925
#define _C4RR()
Definition: node.hpp:1016

References _C4RR.

◆ set_type()

void c4::yml::NodeRef::set_type ( NodeType  t)
inline

Definition at line 1127 of file node.hpp.

1127 { _apply_seed(); m_tree->_set_flags(m_id, t); }

◆ set_key()

void c4::yml::NodeRef::set_key ( csubstr  key)
inline

Definition at line 1128 of file node.hpp.

1128 { _apply_seed(); m_tree->_set_key(m_id, key); }
csubstr key() const RYML_NOEXCEPT
Forward to Tree::key().
Definition: node.hpp:208

References c4::yml::key().

◆ set_val()

void c4::yml::NodeRef::set_val ( csubstr  val)
inline

Definition at line 1129 of file node.hpp.

1129 { _apply_seed(); m_tree->_set_val(m_id, val); }
csubstr val() const RYML_NOEXCEPT
Forward to Tree::val().
Definition: node.hpp:213

◆ set_key_tag()

void c4::yml::NodeRef::set_key_tag ( csubstr  key_tag)
inline

Definition at line 1130 of file node.hpp.

1130 { _apply_seed(); m_tree->set_key_tag(m_id, key_tag); }
void set_key_tag(id_type node, csubstr tag)
Definition: tree.hpp:589
csubstr key_tag() const RYML_NOEXCEPT
Forward to Tree::key_tag().
Definition: node.hpp:209

◆ set_val_tag()

void c4::yml::NodeRef::set_val_tag ( csubstr  val_tag)
inline

Definition at line 1131 of file node.hpp.

1131 { _apply_seed(); m_tree->set_val_tag(m_id, val_tag); }
void set_val_tag(id_type node, csubstr tag)
Definition: tree.hpp:590
csubstr val_tag() const RYML_NOEXCEPT
Forward to Tree::val_tag().
Definition: node.hpp:214

◆ set_key_anchor()

void c4::yml::NodeRef::set_key_anchor ( csubstr  key_anchor)
inline

Definition at line 1132 of file node.hpp.

1132 { _apply_seed(); m_tree->set_key_anchor(m_id, key_anchor); }
void set_key_anchor(id_type node, csubstr anchor)
Definition: tree.hpp:592
csubstr key_anchor() const RYML_NOEXCEPT
Forward to Tree::key_anchor().
Definition: node.hpp:211

◆ set_val_anchor()

void c4::yml::NodeRef::set_val_anchor ( csubstr  val_anchor)
inline

Definition at line 1133 of file node.hpp.

1133 { _apply_seed(); m_tree->set_val_anchor(m_id, val_anchor); }
void set_val_anchor(id_type node, csubstr anchor)
Definition: tree.hpp:593
csubstr val_anchor() const RYML_NOEXCEPT
Forward to Tree::val_anchor().
Definition: node.hpp:216

◆ set_key_ref()

void c4::yml::NodeRef::set_key_ref ( csubstr  key_ref)
inline

Definition at line 1134 of file node.hpp.

1134 { _apply_seed(); m_tree->set_key_ref(m_id, key_ref); }
void set_key_ref(id_type node, csubstr ref)
Definition: tree.hpp:594
csubstr key_ref() const RYML_NOEXCEPT
Forward to Tree::key_ref().
Definition: node.hpp:210

◆ set_val_ref()

void c4::yml::NodeRef::set_val_ref ( csubstr  val_ref)
inline

Definition at line 1135 of file node.hpp.

1135 { _apply_seed(); m_tree->set_val_ref(m_id, val_ref); }
void set_val_ref(id_type node, csubstr ref)
Definition: tree.hpp:595
csubstr val_ref() const RYML_NOEXCEPT
Forward to Tree::val_ref().
Definition: node.hpp:215

◆ set_container_style()

void c4::yml::NodeRef::set_container_style ( NodeType_e  style)
inline

Definition at line 1137 of file node.hpp.

1137 { _C4RR(); m_tree->set_container_style(m_id, style); }
void set_container_style(id_type node, NodeType_e style)
Definition: tree.hpp:560

References _C4RR.

◆ set_key_style()

void c4::yml::NodeRef::set_key_style ( NodeType_e  style)
inline

Definition at line 1138 of file node.hpp.

1138 { _C4RR(); m_tree->set_key_style(m_id, style); }
void set_key_style(id_type node, NodeType_e style)
Definition: tree.hpp:561

References _C4RR.

◆ set_val_style()

void c4::yml::NodeRef::set_val_style ( NodeType_e  style)
inline

Definition at line 1139 of file node.hpp.

1139 { _C4RR(); m_tree->set_val_style(m_id, style); }
void set_val_style(id_type node, NodeType_e style)
Definition: tree.hpp:562

References _C4RR.

◆ clear_style()

void c4::yml::NodeRef::clear_style ( bool  recurse = false)
inline

Definition at line 1140 of file node.hpp.

1140 { _C4RR(); m_tree->clear_style(m_id, recurse); }
void clear_style(id_type node, bool recurse=false)
Definition: tree.cpp:1392

References _C4RR.

◆ set_style_conditionally()

void c4::yml::NodeRef::set_style_conditionally ( NodeType  type_mask,
NodeType  rem_style_flags,
NodeType  add_style_flags,
bool  recurse = false 
)
inline

Definition at line 1141 of file node.hpp.

1145  {
1146  _C4RR(); m_tree->set_style_conditionally(m_id, type_mask, rem_style_flags, add_style_flags, recurse);
1147  }
void set_style_conditionally(id_type node, NodeType type_mask, NodeType rem_style_flags, NodeType add_style_flags, bool recurse=false)
Definition: tree.cpp:1402

References _C4RR.

◆ clear()

void c4::yml::NodeRef::clear ( )
inline

Definition at line 1151 of file node.hpp.

1152  {
1153  if(is_seed())
1154  return;
1155  m_tree->remove_children(m_id);
1156  m_tree->_clear(m_id);
1157  }
void remove_children(id_type node)
remove all the node's children, but keep the node itself
Definition: tree.cpp:903

◆ clear_key()

void c4::yml::NodeRef::clear_key ( )
inline

Definition at line 1159 of file node.hpp.

1160  {
1161  if(is_seed())
1162  return;
1163  m_tree->_clear_key(m_id);
1164  }

◆ clear_val()

void c4::yml::NodeRef::clear_val ( )
inline

Definition at line 1166 of file node.hpp.

1167  {
1168  if(is_seed())
1169  return;
1170  m_tree->_clear_val(m_id);
1171  }

◆ clear_children()

void c4::yml::NodeRef::clear_children ( )
inline

Definition at line 1173 of file node.hpp.

1174  {
1175  if(is_seed())
1176  return;
1177  m_tree->remove_children(m_id);
1178  }

◆ operator=() [3/8]

void c4::yml::NodeRef::operator= ( NodeType_e  t)
inline

Definition at line 1180 of file node.hpp.

1181  {
1182  _apply_seed();
1183  m_tree->_add_flags(m_id, t);
1184  }

◆ operator|=()

void c4::yml::NodeRef::operator|= ( NodeType_e  t)
inline

Definition at line 1186 of file node.hpp.

1187  {
1188  _apply_seed();
1189  m_tree->_add_flags(m_id, t);
1190  }

◆ operator=() [4/8]

void c4::yml::NodeRef::operator= ( NodeInit const &  v)
inline

Definition at line 1192 of file node.hpp.

1193  {
1194  _apply_seed();
1195  _apply(v);
1196  }

◆ operator=() [5/8]

void c4::yml::NodeRef::operator= ( NodeScalar const &  v)
inline

Definition at line 1198 of file node.hpp.

1199  {
1200  _apply_seed();
1201  _apply(v);
1202  }

◆ operator=() [6/8]

void c4::yml::NodeRef::operator= ( std::nullptr_t  )
inline

Definition at line 1204 of file node.hpp.

1205  {
1206  _apply_seed();
1207  _apply(csubstr{});
1208  }

◆ operator=() [7/8]

void c4::yml::NodeRef::operator= ( csubstr  v)
inline

Definition at line 1210 of file node.hpp.

1211  {
1212  _apply_seed();
1213  _apply(v);
1214  }

◆ operator=() [8/8]

template<size_t N>
void c4::yml::NodeRef::operator= ( const char(&)  v[N])
inline

Definition at line 1217 of file node.hpp.

1218  {
1219  _apply_seed();
1220  csubstr sv;
1221  sv.assign<N>(v);
1222  _apply(sv);
1223  }

◆ to_arena()

template<class T >
csubstr c4::yml::NodeRef::to_arena ( T const &  s)
inline

serialize a variable to the arena

Definition at line 1234 of file node.hpp.

1235  {
1236  _RYML_ASSERT_BASIC(m_tree); // no need for valid or readable
1237  return m_tree->to_arena(s);
1238  }
csubstr to_arena(T const &a)
serialize the given variable to the tree's arena, growing it as needed to accomodate the serializatio...
Definition: tree.hpp:878

◆ set_key_serialized() [1/3]

template<class T >
size_t c4::yml::NodeRef::set_key_serialized ( T const &  k)
inline

Definition at line 1241 of file node.hpp.

1242  {
1243  _apply_seed();
1244  csubstr s = m_tree->to_arena(k);
1245  m_tree->_set_key(m_id, s);
1246  return s.len;
1247  }

◆ set_key_serialized() [2/3]

size_t c4::yml::NodeRef::set_key_serialized ( std::nullptr_t  )
inline

Definition at line 1248 of file node.hpp.

1249  {
1250  _apply_seed();
1251  m_tree->_set_key(m_id, csubstr{});
1252  return 0;
1253  }

◆ set_val_serialized() [1/3]

template<class T >
size_t c4::yml::NodeRef::set_val_serialized ( T const &  v)
inline

Definition at line 1256 of file node.hpp.

1257  {
1258  _apply_seed();
1259  csubstr s = m_tree->to_arena(v);
1260  m_tree->_set_val(m_id, s);
1261  return s.len;
1262  }

◆ set_val_serialized() [2/3]

size_t c4::yml::NodeRef::set_val_serialized ( std::nullptr_t  )
inline

Definition at line 1263 of file node.hpp.

1264  {
1265  _apply_seed();
1266  m_tree->_set_val(m_id, csubstr{});
1267  return 0;
1268  }

◆ set_key_serialized() [3/3]

size_t c4::yml::NodeRef::set_key_serialized ( fmt::const_base64_wrapper  w)

encode a blob as base64 into the tree's arena, then assign the result to the node's key

Returns
the size of base64-encoded blob

Definition at line 13 of file node.cpp.

14 {
15  _apply_seed();
16  csubstr encoded = this->to_arena(w);
17  this->set_key(encoded);
18  return encoded.len;
19 }
csubstr to_arena(T const &s)
serialize a variable to the arena
Definition: node.hpp:1234
void set_key(csubstr key)
Definition: node.hpp:1128

References set_key(), and to_arena().

◆ set_val_serialized() [3/3]

size_t c4::yml::NodeRef::set_val_serialized ( fmt::const_base64_wrapper  w)

encode a blob as base64 into the tree's arena, then assign the result to the node's val

Returns
the size of base64-encoded blob

Definition at line 21 of file node.cpp.

22 {
23  _apply_seed();
24  csubstr encoded = this->to_arena(w);
25  this->set_val(encoded);
26  return encoded.len;
27 }
void set_val(csubstr val)
Definition: node.hpp:1129

References set_val(), and to_arena().

◆ operator<<() [1/6]

NodeRef& c4::yml::NodeRef::operator<< ( csubstr  s)
inline

serialize a variable, then assign the result to the node's val

Definition at line 1280 of file node.hpp.

1281  {
1282  // this overload is needed to prevent ambiguity (there's also
1283  // operator<< for writing a substr to a stream)
1284  _apply_seed();
1285  write(this, s);
1286  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, val() == s, m_tree, m_id);
1287  return *this;
1288  }
Callbacks m_callbacks
Definition: tree.hpp:1308
void write(NodeRef *n, T const &v)
Definition: node.hpp:1626

References c4::yml::write().

◆ operator<<() [2/6]

template<class T >
NodeRef& c4::yml::NodeRef::operator<< ( T const &  v)
inline

Definition at line 1291 of file node.hpp.

1292  {
1293  _apply_seed();
1294  write(this, v);
1295  return *this;
1296  }

References c4::yml::write().

◆ operator<<() [3/6]

template<class T >
NodeRef& c4::yml::NodeRef::operator<< ( Key< const T > const &  v)
inline

serialize a variable, then assign the result to the node's key

Definition at line 1300 of file node.hpp.

1301  {
1302  _apply_seed();
1303  set_key_serialized(v.k);
1304  return *this;
1305  }
size_t set_key_serialized(T const &k)
Definition: node.hpp:1241

References c4::yml::Key< K >::k.

◆ operator<<() [4/6]

template<class T >
NodeRef& c4::yml::NodeRef::operator<< ( Key< T > const &  v)
inline

serialize a variable, then assign the result to the node's key

Definition at line 1309 of file node.hpp.

1310  {
1311  _apply_seed();
1312  set_key_serialized(v.k);
1313  return *this;
1314  }

References c4::yml::Key< K >::k.

◆ operator<<() [5/6]

NodeRef& c4::yml::NodeRef::operator<< ( Key< fmt::const_base64_wrapper w)
inline

Definition at line 1316 of file node.hpp.

1317  {
1318  set_key_serialized(w.wrapper);
1319  return *this;
1320  }

References c4::yml::Key< fmt::const_base64_wrapper >::wrapper.

◆ operator<<() [6/6]

NodeRef& c4::yml::NodeRef::operator<< ( fmt::const_base64_wrapper  w)
inline

Definition at line 1322 of file node.hpp.

1323  {
1324  set_val_serialized(w);
1325  return *this;
1326  }
size_t set_val_serialized(T const &v)
Definition: node.hpp:1256

◆ insert_child() [1/2]

NodeRef c4::yml::NodeRef::insert_child ( NodeRef  after)
inline

Definition at line 1375 of file node.hpp.

1376  {
1377  _C4RR();
1378  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1379  NodeRef r(m_tree, m_tree->insert_child(m_id, after.m_id));
1380  return r;
1381  }
id_type insert_child(id_type parent, id_type after)
create and insert a new child of parent.
Definition: tree.hpp:676

References _C4RR.

◆ insert_child() [2/2]

NodeRef c4::yml::NodeRef::insert_child ( NodeInit const &  i,
NodeRef  after 
)
inline

Definition at line 1383 of file node.hpp.

1384  {
1385  _C4RR();
1386  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1387  NodeRef r(m_tree, m_tree->insert_child(m_id, after.m_id));
1388  r._apply(i);
1389  return r;
1390  }

References _C4RR.

◆ prepend_child() [1/2]

NodeRef c4::yml::NodeRef::prepend_child ( )
inline

Definition at line 1392 of file node.hpp.

1393  {
1394  _C4RR();
1395  NodeRef r(m_tree, m_tree->insert_child(m_id, NONE));
1396  return r;
1397  }

References _C4RR, and c4::yml::NONE.

◆ prepend_child() [2/2]

NodeRef c4::yml::NodeRef::prepend_child ( NodeInit const &  i)
inline

Definition at line 1399 of file node.hpp.

1400  {
1401  _C4RR();
1402  NodeRef r(m_tree, m_tree->insert_child(m_id, NONE));
1403  r._apply(i);
1404  return r;
1405  }

References _C4RR, and c4::yml::NONE.

◆ append_child() [1/2]

NodeRef c4::yml::NodeRef::append_child ( )
inline

Definition at line 1407 of file node.hpp.

1408  {
1409  _C4RR();
1410  NodeRef r(m_tree, m_tree->append_child(m_id));
1411  return r;
1412  }
id_type append_child(id_type parent)
create and insert a node as the last child of parent
Definition: tree.hpp:688

References _C4RR.

◆ append_child() [2/2]

NodeRef c4::yml::NodeRef::append_child ( NodeInit const &  i)
inline

Definition at line 1414 of file node.hpp.

1415  {
1416  _C4RR();
1417  NodeRef r(m_tree, m_tree->append_child(m_id));
1418  r._apply(i);
1419  return r;
1420  }

References _C4RR.

◆ insert_sibling() [1/2]

NodeRef c4::yml::NodeRef::insert_sibling ( ConstNodeRef const &  after)
inline

Definition at line 1422 of file node.hpp.

1423  {
1424  _C4RR();
1425  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1426  NodeRef r(m_tree, m_tree->insert_sibling(m_id, after.m_id));
1427  return r;
1428  }
id_type insert_sibling(id_type node, id_type after)
create and insert a new sibling of n. insert after "after"
Definition: tree.hpp:709

References _C4RR, c4::yml::ConstNodeRef::m_id, and c4::yml::ConstNodeRef::m_tree.

◆ insert_sibling() [2/2]

NodeRef c4::yml::NodeRef::insert_sibling ( NodeInit const &  i,
ConstNodeRef const &  after 
)
inline

Definition at line 1430 of file node.hpp.

1431  {
1432  _C4RR();
1433  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1434  NodeRef r(m_tree, m_tree->insert_sibling(m_id, after.m_id));
1435  r._apply(i);
1436  return r;
1437  }

References _C4RR, c4::yml::ConstNodeRef::m_id, and c4::yml::ConstNodeRef::m_tree.

◆ prepend_sibling() [1/2]

NodeRef c4::yml::NodeRef::prepend_sibling ( )
inline

Definition at line 1439 of file node.hpp.

1440  {
1441  _C4RR();
1442  NodeRef r(m_tree, m_tree->prepend_sibling(m_id));
1443  return r;
1444  }
id_type prepend_sibling(id_type node)
create and insert a node as the first node of parent
Definition: tree.hpp:714

References _C4RR.

◆ prepend_sibling() [2/2]

NodeRef c4::yml::NodeRef::prepend_sibling ( NodeInit const &  i)
inline

Definition at line 1446 of file node.hpp.

1447  {
1448  _C4RR();
1449  NodeRef r(m_tree, m_tree->prepend_sibling(m_id));
1450  r._apply(i);
1451  return r;
1452  }

References _C4RR.

◆ append_sibling() [1/2]

NodeRef c4::yml::NodeRef::append_sibling ( )
inline

Definition at line 1454 of file node.hpp.

1455  {
1456  _C4RR();
1457  NodeRef r(m_tree, m_tree->append_sibling(m_id));
1458  return r;
1459  }
id_type append_sibling(id_type node)
Definition: tree.hpp:715

References _C4RR.

◆ append_sibling() [2/2]

NodeRef c4::yml::NodeRef::append_sibling ( NodeInit const &  i)
inline

Definition at line 1461 of file node.hpp.

1462  {
1463  _C4RR();
1464  NodeRef r(m_tree, m_tree->append_sibling(m_id));
1465  r._apply(i);
1466  return r;
1467  }

References _C4RR.

◆ remove_child() [1/3]

void c4::yml::NodeRef::remove_child ( NodeRef child)
inline

Definition at line 1471 of file node.hpp.

1472  {
1473  _C4RR();
1474  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, has_child(child), m_tree, m_id);
1475  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, child.parent().id() == id(), m_tree, m_id);
1476  m_tree->remove(child.id());
1477  child.clear();
1478  }
void remove(id_type node)
remove an entire branch at once: ie remove the children and the node itself
Definition: tree.hpp:720
bool has_child(ConstNodeRef const &n) const RYML_NOEXCEPT
Forward to Tree::has_child().
Definition: node.hpp:311
auto child(id_type pos) RYML_NOEXCEPT -> NodeRef
Forward to Tree::child().
Definition: node.hpp:349

References _C4RR, clear(), id(), and c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::parent().

◆ remove_child() [2/3]

void c4::yml::NodeRef::remove_child ( id_type  pos)
inline

remove the nth child of this node

Definition at line 1481 of file node.hpp.

1482  {
1483  _C4RR();
1484  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, pos >= 0 && pos < num_children(), m_tree, m_id);
1485  id_type child = m_tree->child(m_id, pos);
1486  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, child != NONE, m_tree, m_id);
1487  m_tree->remove(child);
1488  }
id_type child(id_type node, id_type pos) const
Definition: tree.cpp:1206
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
Definition: common.hpp:244
id_type num_children() const RYML_NOEXCEPT
O(num_children).
Definition: node.hpp:380

References _C4RR, and c4::yml::NONE.

◆ remove_child() [3/3]

void c4::yml::NodeRef::remove_child ( csubstr  key)
inline

remove a child by name

Definition at line 1491 of file node.hpp.

1492  {
1493  _C4RR();
1494  id_type child = m_tree->find_child(m_id, key);
1495  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, child != NONE, m_tree, m_id);
1496  m_tree->remove(child);
1497  }
id_type find_child(id_type node, csubstr const &key) const
Definition: tree.cpp:1243

References _C4RR, c4::yml::key(), and c4::yml::NONE.

◆ move() [1/2]

void c4::yml::NodeRef::move ( ConstNodeRef const &  after)
inline

change the node's position within its parent, placing it after after.

To move to the first position in the parent, simply pass an empty or default-constructed reference like this: n.move({}).

Definition at line 1505 of file node.hpp.

1506  {
1507  _C4RR();
1508  m_tree->move(m_id, after.m_id);
1509  }
void move(id_type node, id_type after)
change the node's position in the parent
Definition: tree.cpp:822

References _C4RR, and c4::yml::ConstNodeRef::m_id.

◆ move() [2/2]

void c4::yml::NodeRef::move ( NodeRef const &  parent,
ConstNodeRef const &  after 
)
inline

move the node to a different parent (which may belong to a different tree), placing it after after.

When the destination parent is in a new tree, then this node's tree pointer is reset to the tree of the parent node.

Definition at line 1515 of file node.hpp.

1516  {
1517  _C4RR();
1518  if(parent.m_tree == m_tree)
1519  {
1520  m_tree->move(m_id, parent.m_id, after.m_id);
1521  }
1522  else
1523  {
1524  parent.m_tree->move(m_tree, m_id, parent.m_id, after.m_id);
1525  m_tree = parent.m_tree;
1526  }
1527  }
auto parent() RYML_NOEXCEPT -> NodeRef
Forward to Tree::parent().
Definition: node.hpp:337

References _C4RR, c4::yml::ConstNodeRef::m_id, and c4::yml::Tree::move().

◆ duplicate() [1/2]

NodeRef c4::yml::NodeRef::duplicate ( ConstNodeRef const &  after) const
inline

duplicate the current node somewhere within its parent, and place it after the node after.

To place into the first position of the parent, simply pass an empty or default-constructed reference like this: n.move({}).

Definition at line 1533 of file node.hpp.

1534  {
1535  _C4RR();
1536  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1537  id_type dup = m_tree->duplicate(m_id, m_tree->parent(m_id), after.m_id);
1538  NodeRef r(m_tree, dup);
1539  return r;
1540  }
id_type duplicate(id_type node, id_type new_parent, id_type after)
recursively duplicate a node from this tree into a new parent, placing it after one of its children
Definition: tree.cpp:944
id_type parent(id_type node) const
Definition: tree.hpp:499

References _C4RR, c4::yml::ConstNodeRef::m_id, c4::yml::ConstNodeRef::m_tree, and c4::yml::NONE.

◆ duplicate() [2/2]

NodeRef c4::yml::NodeRef::duplicate ( NodeRef const &  parent,
ConstNodeRef const &  after 
) const
inline

duplicate the current node somewhere into a different parent (possibly from a different tree), and place it after the node after.

To place into the first position of the parent, simply pass an empty or default-constructed reference like this: n.move({}).

Definition at line 1547 of file node.hpp.

1548  {
1549  _C4RR();
1550  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, parent.m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1551  if(parent.m_tree == m_tree)
1552  {
1553  id_type dup = m_tree->duplicate(m_id, parent.m_id, after.m_id);
1554  NodeRef r(m_tree, dup);
1555  return r;
1556  }
1557  else
1558  {
1559  id_type dup = parent.m_tree->duplicate(m_tree, m_id, parent.m_id, after.m_id);
1560  NodeRef r(parent.m_tree, dup);
1561  return r;
1562  }
1563  }

References _C4RR, c4::yml::Tree::duplicate(), c4::yml::ConstNodeRef::m_id, c4::yml::ConstNodeRef::m_tree, and c4::yml::NONE.

◆ duplicate_children()

void c4::yml::NodeRef::duplicate_children ( NodeRef const &  parent,
ConstNodeRef const &  after 
) const
inline

Definition at line 1565 of file node.hpp.

1566  {
1567  _C4RR();
1568  _RYML_ASSERT_VISIT_(m_tree->m_callbacks, parent.m_tree == after.m_tree, m_tree, m_id);
1569  if(parent.m_tree == m_tree)
1570  {
1571  m_tree->duplicate_children(m_id, parent.m_id, after.m_id);
1572  }
1573  else
1574  {
1575  parent.m_tree->duplicate_children(m_tree, m_id, parent.m_id, after.m_id);
1576  }
1577  }
id_type duplicate_children(id_type node, id_type parent, id_type after)
recursively duplicate the node's children (but not the node)
Definition: tree.cpp:966

References _C4RR, c4::yml::Tree::duplicate_children(), c4::yml::ConstNodeRef::m_id, and c4::yml::ConstNodeRef::m_tree.

◆ get() [1/2]

NodeData const* c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::get ( ) const
inlineinherited

returns the data or null when the id is NONE

Definition at line 199 of file node.hpp.

199 { return ((Impl const*)this)->readable() ? tree_->get(id_) : nullptr; }

◆ get() [2/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::get ( ) -> NodeData*
inlineinherited

returns the data or null when the id is NONE

Definition at line 203 of file node.hpp.

203 { return ((Impl const*)this)->readable() ? tree__->get(id__) : nullptr; }

◆ type()

NodeType c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::type ( ) const
inlineinherited

Forward to Tree::type().

Node must be readable.

Definition at line 205 of file node.hpp.

◆ type_str()

const char* c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::type_str ( ) const
inlineinherited

Forward to Tree::type_str().

Node must be readable.

Definition at line 206 of file node.hpp.

◆ key()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::key ( ) const
inlineinherited

Forward to Tree::key().

Node must be readable.

Definition at line 208 of file node.hpp.

◆ key_tag()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::key_tag ( ) const
inlineinherited

Forward to Tree::key_tag().

Node must be readable.

Definition at line 209 of file node.hpp.

◆ key_ref()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::key_ref ( ) const
inlineinherited

Forward to Tree::key_ref().

Node must be readable.

Definition at line 210 of file node.hpp.

◆ key_anchor()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::key_anchor ( ) const
inlineinherited

Forward to Tree::key_anchor().

Node must be readable.

Definition at line 211 of file node.hpp.

◆ val()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::val ( ) const
inlineinherited

Forward to Tree::val().

Node must be readable.

Definition at line 213 of file node.hpp.

◆ val_tag()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::val_tag ( ) const
inlineinherited

Forward to Tree::val_tag().

Node must be readable.

Definition at line 214 of file node.hpp.

◆ val_ref()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::val_ref ( ) const
inlineinherited

Forward to Tree::val_ref().

Node must be readable.

Definition at line 215 of file node.hpp.

◆ val_anchor()

csubstr c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::val_anchor ( ) const
inlineinherited

Forward to Tree::val_anchor().

Node must be readable.

Definition at line 216 of file node.hpp.

◆ keysc()

NodeScalar const& c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::keysc ( ) const
inlineinherited

Forward to Tree::keysc().

Node must be readable.

Definition at line 218 of file node.hpp.

◆ valsc()

NodeScalar const& c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::valsc ( ) const
inlineinherited

Forward to Tree::valsc().

Node must be readable.

Definition at line 219 of file node.hpp.

◆ key_is_null()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::key_is_null ( ) const
inlineinherited

Forward to Tree::key_is_null().

Node must be readable.

Definition at line 221 of file node.hpp.

◆ val_is_null()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::val_is_null ( ) const
inlineinherited

Forward to Tree::val_is_null().

Node must be readable.

Definition at line 222 of file node.hpp.

◆ is_key_unfiltered()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_unfiltered ( ) const
inlinenoexceptinherited

Forward to Tree::is_key_unfiltered().

Node must be readable.

Definition at line 224 of file node.hpp.

◆ is_val_unfiltered()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_unfiltered ( ) const
inlinenoexceptinherited

Forward to Tree::is_val_unfiltered().

Node must be readable.

Definition at line 225 of file node.hpp.

◆ empty()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::empty ( ) const
inlineinherited

Forward to Tree::empty().

Node must be readable.

Definition at line 234 of file node.hpp.

◆ is_stream()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_stream ( ) const
inlineinherited

Forward to Tree::is_stream().

Node must be readable.

Definition at line 235 of file node.hpp.

◆ is_doc()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_doc ( ) const
inlineinherited

Forward to Tree::is_doc().

Node must be readable.

Definition at line 236 of file node.hpp.

◆ is_container()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_container ( ) const
inlineinherited

Forward to Tree::is_container().

Node must be readable.

Definition at line 237 of file node.hpp.

◆ is_map()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_map ( ) const
inlineinherited

Forward to Tree::is_map().

Node must be readable.

Definition at line 238 of file node.hpp.

◆ is_seq()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_seq ( ) const
inlineinherited

Forward to Tree::is_seq().

Node must be readable.

Definition at line 239 of file node.hpp.

◆ has_val()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_val ( ) const
inlineinherited

Forward to Tree::has_val().

Node must be readable.

Definition at line 240 of file node.hpp.

◆ has_key()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_key ( ) const
inlineinherited

Forward to Tree::has_key().

Node must be readable.

Definition at line 241 of file node.hpp.

◆ is_val()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val ( ) const
inlineinherited

Forward to Tree::is_val().

Node must be readable.

Definition at line 242 of file node.hpp.

◆ is_keyval()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_keyval ( ) const
inlineinherited

Forward to Tree::is_keyval().

Node must be readable.

Definition at line 243 of file node.hpp.

◆ has_key_tag()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_key_tag ( ) const
inlineinherited

Forward to Tree::has_key_tag().

Node must be readable.

Definition at line 244 of file node.hpp.

◆ has_val_tag()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_val_tag ( ) const
inlineinherited

Forward to Tree::has_val_tag().

Node must be readable.

Definition at line 245 of file node.hpp.

◆ has_key_anchor()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_key_anchor ( ) const
inlineinherited

Forward to Tree::has_key_anchor().

Node must be readable.

Definition at line 246 of file node.hpp.

◆ has_val_anchor()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_val_anchor ( ) const
inlineinherited

Forward to Tree::has_val_anchor().

Node must be readable.

Definition at line 247 of file node.hpp.

◆ has_anchor()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_anchor ( ) const
inlineinherited

Forward to Tree::has_anchor().

Node must be readable.

Definition at line 248 of file node.hpp.

◆ is_key_ref()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_ref ( ) const
inlineinherited

Forward to Tree::is_key_ref().

Node must be readable.

Definition at line 249 of file node.hpp.

◆ is_val_ref()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_ref ( ) const
inlineinherited

Forward to Tree::is_val_ref().

Node must be readable.

Definition at line 250 of file node.hpp.

◆ is_ref()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_ref ( ) const
inlineinherited

Forward to Tree::is_ref().

Node must be readable.

Definition at line 251 of file node.hpp.

◆ parent_is_seq()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::parent_is_seq ( ) const
inlineinherited

Forward to Tree::parent_is_seq().

Node must be readable.

Definition at line 252 of file node.hpp.

◆ parent_is_map()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::parent_is_map ( ) const
inlineinherited

Forward to Tree::parent_is_map().

Node must be readable.

Definition at line 253 of file node.hpp.

◆ is_key_anchor()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_anchor ( ) const
inlinenoexceptinherited

Definition at line 255 of file node.hpp.

255 { _C4RR(); return tree_->has_key_anchor(id_); }

◆ is_val_hanchor()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_hanchor ( ) const
inlinenoexceptinherited

Definition at line 256 of file node.hpp.

256 { _C4RR(); return tree_->has_val_anchor(id_); }

◆ is_anchor()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_anchor ( ) const
inlinenoexceptinherited

Definition at line 257 of file node.hpp.

257 { _C4RR(); return tree_->has_anchor(id_); }

◆ is_anchor_or_ref()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_anchor_or_ref ( ) const
inlinenoexceptinherited

Definition at line 258 of file node.hpp.

258 { _C4RR(); return tree_->is_anchor_or_ref(id_); }

◆ type_has_any()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::type_has_any ( NodeType_e  bits) const
inlineinherited

Forward to Tree::type_has_any().

Node must be readable.

Definition at line 269 of file node.hpp.

◆ type_has_all()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::type_has_all ( NodeType_e  bits) const
inlineinherited

Forward to Tree::type_has_all().

Node must be readable.

Definition at line 270 of file node.hpp.

◆ type_has_none()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::type_has_none ( NodeType_e  bits) const
inlineinherited

Forward to Tree::type_has_none().

Node must be readable.

Definition at line 271 of file node.hpp.

◆ key_style()

NodeType c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::key_style ( ) const
inlineinherited

Forward to Tree::key_style().

Node must be readable.

Definition at line 273 of file node.hpp.

◆ val_style()

NodeType c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::val_style ( ) const
inlineinherited

Forward to Tree::val_style().

Node must be readable.

Definition at line 274 of file node.hpp.

◆ is_container_styled()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_container_styled ( ) const
inlineinherited

Forward to Tree::is_container_styled().

Node must be readable.

Definition at line 276 of file node.hpp.

◆ is_block()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_block ( ) const
inlineinherited

Forward to Tree::is_block().

Node must be readable.

Definition at line 277 of file node.hpp.

◆ is_flow_sl()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_flow_sl ( ) const
inlineinherited

Forward to Tree::is_flow_sl().

Node must be readable.

Definition at line 278 of file node.hpp.

◆ is_flow_ml()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_flow_ml ( ) const
inlineinherited

Forward to Tree::is_flow_ml().

Node must be readable.

Definition at line 279 of file node.hpp.

◆ is_flow()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_flow ( ) const
inlineinherited

Forward to Tree::is_flow().

Node must be readable.

Definition at line 280 of file node.hpp.

◆ is_key_styled()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_styled ( ) const
inlineinherited

Forward to Tree::is_key_styled().

Node must be readable.

Definition at line 282 of file node.hpp.

◆ is_val_styled()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_styled ( ) const
inlineinherited

Forward to Tree::is_val_styled().

Node must be readable.

Definition at line 283 of file node.hpp.

◆ is_key_literal()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_literal ( ) const
inlineinherited

Forward to Tree::is_key_literal().

Node must be readable.

Definition at line 284 of file node.hpp.

◆ is_val_literal()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_literal ( ) const
inlineinherited

Forward to Tree::is_val_literal().

Node must be readable.

Definition at line 285 of file node.hpp.

◆ is_key_folded()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_folded ( ) const
inlineinherited

Forward to Tree::is_key_folded().

Node must be readable.

Definition at line 286 of file node.hpp.

◆ is_val_folded()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_folded ( ) const
inlineinherited

Forward to Tree::is_val_folded().

Node must be readable.

Definition at line 287 of file node.hpp.

◆ is_key_squo()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_squo ( ) const
inlineinherited

Forward to Tree::is_key_squo().

Node must be readable.

Definition at line 288 of file node.hpp.

◆ is_val_squo()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_squo ( ) const
inlineinherited

Forward to Tree::is_val_squo().

Node must be readable.

Definition at line 289 of file node.hpp.

◆ is_key_dquo()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_dquo ( ) const
inlineinherited

Forward to Tree::is_key_dquo().

Node must be readable.

Definition at line 290 of file node.hpp.

◆ is_val_dquo()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_dquo ( ) const
inlineinherited

Forward to Tree::is_val_dquo().

Node must be readable.

Definition at line 291 of file node.hpp.

◆ is_key_plain()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_plain ( ) const
inlineinherited

Forward to Tree::is_key_plain().

Node must be readable.

Definition at line 292 of file node.hpp.

◆ is_val_plain()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_plain ( ) const
inlineinherited

Forward to Tree::is_val_plain().

Node must be readable.

Definition at line 293 of file node.hpp.

◆ is_key_quoted()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_key_quoted ( ) const
inlineinherited

Forward to Tree::is_key_quoted().

Node must be readable.

Definition at line 294 of file node.hpp.

◆ is_val_quoted()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_val_quoted ( ) const
inlineinherited

Forward to Tree::is_val_quoted().

Node must be readable.

Definition at line 295 of file node.hpp.

◆ is_quoted()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_quoted ( ) const
inlineinherited

Forward to Tree::is_quoted().

Node must be readable.

Definition at line 296 of file node.hpp.

◆ is_root()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_root ( ) const
inlineinherited

Forward to Tree::is_root().

Node must be readable.

Definition at line 307 of file node.hpp.

◆ has_parent()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_parent ( ) const
inlineinherited

Forward to Tree::has_parent() Node must be readable.

Definition at line 308 of file node.hpp.

◆ is_ancestor()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::is_ancestor ( ConstNodeRef const &  ancestor) const
inlineinherited

Forward to Tree::is_ancestor() Node must be readable.

Definition at line 309 of file node.hpp.

◆ has_child() [1/3]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_child ( ConstNodeRef const &  n) const
inlineinherited

Forward to Tree::has_child().

Node must be readable.

Definition at line 311 of file node.hpp.

◆ has_child() [2/3]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_child ( id_type  node) const
inlineinherited

Forward to Tree::has_child().

Node must be readable.

Definition at line 312 of file node.hpp.

◆ has_child() [3/3]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_child ( csubstr  name) const
inlineinherited

Forward to Tree::has_child().

Node must be readable.

Definition at line 313 of file node.hpp.

◆ has_children()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_children ( ) const
inlineinherited

Forward to Tree::has_children().

Node must be readable.

Definition at line 314 of file node.hpp.

◆ has_sibling() [1/3]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_sibling ( ConstNodeRef const &  n) const
inlineinherited

Forward to Tree::has_sibling().

Node must be readable.

Definition at line 316 of file node.hpp.

◆ has_sibling() [2/3]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_sibling ( id_type  node) const
inlineinherited

Forward to Tree::has_sibling().

Node must be readable.

Definition at line 317 of file node.hpp.

◆ has_sibling() [3/3]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_sibling ( csubstr  name) const
inlineinherited

Forward to Tree::has_sibling().

Node must be readable.

Definition at line 318 of file node.hpp.

◆ has_other_siblings()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_other_siblings ( ) const
inlineinherited

Forward to Tree::has_other_siblings().

Node must be readable.

Definition at line 319 of file node.hpp.

◆ has_siblings()

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::has_siblings ( ) const
inlineinherited

Definition at line 321 of file node.hpp.

321 { _C4RR(); return tree_->has_siblings(id_); }

◆ doc() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::doc ( id_type  i) -> NodeRef
inlineinherited

Forward to Tree::doc().

Node must be readable.

Definition at line 333 of file node.hpp.

◆ doc() [2/2]

Forward to Tree::doc().

Node must be readable. succeeds even when the node may have invalid or seed id

Definition at line 334 of file node.hpp.

◆ parent() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::parent ( ) -> Impl
inlineinherited

Forward to Tree::parent().

Node must be readable.

Definition at line 337 of file node.hpp.

◆ parent() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::parent ( ) const
inlineinherited

Forward to Tree::parent().

Node must be readable.

Definition at line 338 of file node.hpp.

◆ first_child() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::first_child ( ) -> Impl
inlineinherited

Forward to Tree::first_child().

Node must be readable.

Definition at line 341 of file node.hpp.

◆ first_child() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::first_child ( ) const
inlineinherited

Forward to Tree::first_child().

Node must be readable.

Definition at line 342 of file node.hpp.

◆ last_child() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::last_child ( ) -> Impl
inlineinherited

Forward to Tree::last_child().

Node must be readable.

Definition at line 345 of file node.hpp.

◆ last_child() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::last_child ( ) const
inlineinherited

Forward to Tree::last_child().

Node must be readable.

Definition at line 346 of file node.hpp.

◆ child() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::child ( id_type  pos) -> NodeRef
inlineinherited

Forward to Tree::child().

Node must be readable.

Definition at line 349 of file node.hpp.

◆ child() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::child ( id_type  pos) const
inlineinherited

Forward to Tree::child().

Node must be readable.

Definition at line 350 of file node.hpp.

◆ find_child() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::find_child ( csubstr  name) -> NodeRef
inlineinherited

Forward to Tree::find_child().

Node must be readable.

Definition at line 353 of file node.hpp.

◆ find_child() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::find_child ( csubstr  name) const
inlineinherited

Forward to Tree::find_child().

Node must be readable.

Definition at line 354 of file node.hpp.

◆ prev_sibling() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::prev_sibling ( ) -> Impl
inlineinherited

Forward to Tree::prev_sibling().

Node must be readable.

Definition at line 357 of file node.hpp.

◆ prev_sibling() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::prev_sibling ( ) const
inlineinherited

Forward to Tree::prev_sibling().

Node must be readable.

Definition at line 358 of file node.hpp.

◆ next_sibling() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::next_sibling ( ) -> Impl
inlineinherited

Forward to Tree::next_sibling().

Node must be readable.

Definition at line 361 of file node.hpp.

◆ next_sibling() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::next_sibling ( ) const
inlineinherited

Forward to Tree::next_sibling().

Node must be readable.

Definition at line 362 of file node.hpp.

◆ first_sibling() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::first_sibling ( ) -> Impl
inlineinherited

Forward to Tree::first_sibling().

Node must be readable.

Definition at line 365 of file node.hpp.

◆ first_sibling() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::first_sibling ( ) const
inlineinherited

Forward to Tree::first_sibling().

Node must be readable.

Definition at line 366 of file node.hpp.

◆ last_sibling() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::last_sibling ( ) -> Impl
inlineinherited

Forward to Tree::last_sibling().

Node must be readable.

Definition at line 369 of file node.hpp.

◆ last_sibling() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::last_sibling ( ) const
inlineinherited

Forward to Tree::last_sibling().

Node must be readable.

Definition at line 370 of file node.hpp.

◆ sibling() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::sibling ( id_type  pos) -> NodeRef
inlineinherited

Forward to Tree::sibling().

Node must be readable.

Definition at line 373 of file node.hpp.

◆ sibling() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::sibling ( id_type  pos) const
inlineinherited

Forward to Tree::sibling().

Node must be readable.

Definition at line 374 of file node.hpp.

◆ find_sibling() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::find_sibling ( csubstr  name) -> NodeRef
inlineinherited

Forward to Tree::find_sibling().

Node must be readable.

Definition at line 377 of file node.hpp.

◆ find_sibling() [2/2]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::find_sibling ( csubstr  name) const
inlineinherited

Forward to Tree::find_sibling().

Node must be readable.

Definition at line 378 of file node.hpp.

◆ num_children()

id_type c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::num_children ( ) const
inlineinherited

O(num_children).

Forward to Tree::num_children().

Definition at line 380 of file node.hpp.

◆ num_siblings()

id_type c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::num_siblings ( ) const
inlineinherited

O(num_children).

Forward to Tree::num_siblings().

Definition at line 381 of file node.hpp.

◆ num_other_siblings()

id_type c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::num_other_siblings ( ) const
inlineinherited

O(num_siblings).

Forward to Tree::num_other_siblings().

Definition at line 382 of file node.hpp.

◆ child_pos()

id_type c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::child_pos ( ConstNodeRef const &  n) const
inlineinherited

O(num_children).

Forward to Tree::child_pos().

Definition at line 383 of file node.hpp.

◆ sibling_pos()

id_type c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::sibling_pos ( ConstNodeRef const &  n) const
inlineinherited

O(num_siblings).

Forward to Tree::sibling_pos().

Definition at line 384 of file node.hpp.

◆ depth_asc()

id_type c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::depth_asc ( ) const
inlineinherited

Definition at line 386 of file node.hpp.

386 { _C4RR(); return tree_->depth_asc(id_); } /** O(log(num_nodes)). Forward to Tree::depth_asc(). Node must be readable. */

◆ depth_desc()

id_type c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::depth_desc ( ) const
inlineinherited

O(log(num_nodes)).

Forward to Tree::depth_asc(). Node must be readable.

Definition at line 387 of file node.hpp.

387 { _C4RR(); return tree_->depth_desc(id_); } /** O(num_nodes). Forward to Tree::depth_desc(). Node must be readable. */

◆ operator[]() [1/4]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator[] ( csubstr  key) -> NodeRef
inlineinherited

Find child by key; complexity is O(num_children).

Returns the requested node, or an object in seed state if no such child is found (see NodeRef for an explanation of what is seed state). When the object is in seed state, using it to read from the tree is UB. The seed node can be used to write to the tree provided that its create() method is called prior to writing, which happens in most modifying methods in NodeRef. It is the caller's responsibility to verify that the returned node is readable before subsequently using it to read from the tree.

Warning
the calling object must be readable. This precondition is asserted. The assertion is performed only if RYML_USE_ASSERT is set to true. As with the non-const overload, it is UB to call this method if the node is not readable.
See also
https://github.com/biojppm/rapidyaml/issues/389

Definition at line 416 of file node.hpp.

417  {
418  _C4RR();
419  id_type ch = tree__->find_child(id__, key);
420  return ch != NONE ? Impl(tree__, ch) : Impl(tree__, id__, key);
421  }

◆ operator[]() [2/4]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator[] ( id_type  pos) -> NodeRef
inlineinherited

Find child by position; complexity is O(pos).

Returns the requested node, or an object in seed state if no such child is found (see NodeRef for an explanation of what is seed state). When the object is in seed state, using it to read from the tree is UB. The seed node can be used to write to the tree provided that its create() method is called prior to writing, which happens in most modifying methods in NodeRef. It is the caller's responsibility to verify that the returned node is readable before subsequently using it to read from the tree.

Warning
the calling object must be readable. This precondition is asserted. The assertion is performed only if RYML_USE_ASSERT is set to true. As with the non-const overload, it is UB to call this method if the node is not readable.
See also
https://github.com/biojppm/rapidyaml/issues/389

Definition at line 442 of file node.hpp.

443  {
444  _C4RR();
445  id_type ch = tree__->child(id__, pos);
446  return ch != NONE ? Impl(tree__, ch) : Impl(tree__, id__, pos);
447  }

◆ operator[]() [3/4]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator[] ( csubstr  key) const
inlineinherited

Find a child by key; complexity is O(num_children).

Behaves similar to the non-const overload, but further asserts that the returned node is readable (because it can never be in a seed state). The assertion is performed only if RYML_USE_ASSERT is set to true. As with the non-const overload, it is UB to use the return value if it is not valid.

See also
https://github.com/biojppm/rapidyaml/issues/389

Definition at line 458 of file node.hpp.

459  {
460  _C4RR();
461  id_type ch = tree_->find_child(id_, key);
462  _RYML_ASSERT_VISIT_(tree_->m_callbacks, ch != NONE, tree_, id_);
463  return {tree_, ch};
464  }

◆ operator[]() [4/4]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator[] ( id_type  pos) const
inlineinherited

Find a child by position; complexity is O(pos).

Behaves similar to the non-const overload, but further asserts that the returned node is readable (because it can never be in a seed state). This assertion is performed only if RYML_USE_ASSERT is set to true. As with the non-const overload, it is UB to use the return value if it is not valid.

See also
https://github.com/biojppm/rapidyaml/issues/389

Definition at line 475 of file node.hpp.

476  {
477  _C4RR();
478  id_type ch = tree_->child(id_, pos);
479  _RYML_ASSERT_VISIT_(tree_->m_callbacks, ch != NONE, tree_, id_);
480  return {tree_, ch};
481  }

◆ at() [1/4]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::at ( csubstr  key) -> NodeRef
inlineinherited

Find child by key; complexity is O(num_children).

Returns the requested node, or an object in seed state if no such child is found (see NodeRef for an explanation of what is seed state). When the object is in seed state, using it to read from the tree is UB. The seed node can be subsequently used to write to the tree provided that its create() method is called prior to writing, which happens inside most mutating methods in NodeRef. It is the caller's responsibility to verify that the returned node is readable before subsequently using it to read from the tree.

Warning
This method will call the error callback (regardless of build type or of the value of RYML_USE_ASSERT) whenever any of the following preconditions is violated: a) the object is valid (points at a tree and a node), b) the calling object must be readable (must not be in seed state), c) the calling object must be pointing at a MAP node. The preconditions are similar to the non-const operator[](csubstr), but instead of using assertions, this function directly checks those conditions and calls the error callback if any of the checks fail.
Note
since it is valid behavior for the returned node to be in seed state, the error callback is not invoked when this happens.

Definition at line 523 of file node.hpp.

524  {
525  _RYML_CHECK_BASIC(tree_ != nullptr);
526  _RYML_CHECK_VISIT_(tree_->m_callbacks, (id_ >= 0 && id_ < tree_->capacity()), tree_, id_);
527  _RYML_CHECK_VISIT_(tree_->m_callbacks, ((Impl const*)this)->readable(), tree_, id_);
528  _RYML_CHECK_VISIT_(tree_->m_callbacks, tree_->is_map(id_), tree_, id_);
529  id_type ch = tree__->find_child(id__, key);
530  return ch != NONE ? Impl(tree__, ch) : Impl(tree__, id__, key);
531  }

◆ at() [2/4]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::at ( id_type  pos) -> NodeRef
inlineinherited

Find child by position; complexity is O(pos).

Returns the requested node, or an object in seed state if no such child is found (see NodeRef for an explanation of what is seed state). When the object is in seed state, using it to read from the tree is UB. The seed node can be used to write to the tree provided that its create() method is called prior to writing, which happens in most modifying methods in NodeRef. It is the caller's responsibility to verify that the returned node is readable before subsequently using it to read from the tree.

Warning
This method will call the error callback (regardless of build type or of the value of RYML_USE_ASSERT) whenever any of the following preconditions is violated: a) the object is valid (points at a tree and a node), b) the calling object must be readable (must not be in seed state), c) the calling object must be pointing at a MAP node. The preconditions are similar to the non-const operator[](id_type), but instead of using assertions, this function directly checks those conditions and calls the error callback if any of the checks fail.
Note
since it is valid behavior for the returned node to be in seed state, the error callback is not invoked when this happens.

Definition at line 559 of file node.hpp.

560  {
561  _RYML_CHECK_BASIC(tree_ != nullptr);
562  const id_type cap = tree_->capacity();
563  _RYML_CHECK_VISIT_(tree_->m_callbacks, (id_ >= 0 && id_ < cap), tree_, id_);
564  _RYML_CHECK_VISIT_(tree_->m_callbacks, (pos >= 0 && pos < cap), tree_, id_);
565  _RYML_CHECK_VISIT_(tree_->m_callbacks, ((Impl const*)this)->readable(), tree_, id_);
566  _RYML_CHECK_VISIT_(tree_->m_callbacks, tree_->is_container(id_), tree_, id_);
567  id_type ch = tree__->child(id__, pos);
568  return ch != NONE ? Impl(tree__, ch) : Impl(tree__, id__, pos);
569  }

◆ at() [3/4]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::at ( csubstr  key) const
inlineinherited

Get a child by name, with error checking; complexity is O(num_children).

Behaves as operator[](csubstr) const, but always raises an error (even when RYML_USE_ASSERT is set to false) when the returned node does not exist, or when this node is not readable, or when it is not a map. This behaviour is similar to std::vector::at(), but the error consists in calling the error callback instead of directly raising an exception.

Definition at line 580 of file node.hpp.

581  {
582  _RYML_CHECK_BASIC(tree_ != nullptr);
583  _RYML_CHECK_VISIT_(tree_->m_callbacks, (id_ >= 0 && id_ < tree_->capacity()), tree_, id_);
584  _RYML_CHECK_VISIT_(tree_->m_callbacks, ((Impl const*)this)->readable(), tree_, id_);
585  _RYML_CHECK_VISIT_(tree_->m_callbacks, tree_->is_map(id_), tree_, id_);
586  id_type ch = tree_->find_child(id_, key);
587  _RYML_CHECK_VISIT_(tree_->m_callbacks, ch != NONE, tree_, id_);
588  return {tree_, ch};
589  }

◆ at() [4/4]

ConstNodeRef c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::at ( id_type  pos) const
inlineinherited

Get a child by position, with error checking; complexity is O(pos).

Behaves as operator[](id_type) const, but always raises an error (even when RYML_USE_ASSERT is set to false) when the returned node does not exist, or when this node is not readable, or when it is not a container. This behaviour is similar to std::vector::at(), but the error consists in calling the error callback instead of directly raising an exception.

Definition at line 600 of file node.hpp.

601  {
602  _RYML_CHECK_BASIC(tree_ != nullptr);
603  const id_type cap = tree_->capacity();
604  _RYML_CHECK_VISIT_(tree_->m_callbacks, (id_ >= 0 && id_ < cap), tree_, id_);
605  _RYML_CHECK_VISIT_(tree_->m_callbacks, (pos >= 0 && pos < cap), tree_, id_);
606  _RYML_CHECK_VISIT_(tree_->m_callbacks, ((Impl const*)this)->readable(), tree_, id_);
607  _RYML_CHECK_VISIT_(tree_->m_callbacks, tree_->is_container(id_), tree_, id_);
608  const id_type ch = tree_->child(id_, pos);
609  _RYML_CHECK_VISIT_(tree_->m_callbacks, ch != NONE, tree_, id_);
610  return {tree_, ch};
611  }

◆ location()

Location c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::location ( Parser const &  parser) const
inlineinherited

Definition at line 620 of file node.hpp.

621  {
622  _C4RR();
623  return tree_->location(parser, id_);
624  }

◆ operator>>() [1/4]

ConstNodeRef const& c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator>> ( T &  v) const
inlineinherited

deserialize the node's val to the given variable, forwarding to the user-overrideable read() function.

Definition at line 636 of file node.hpp.

637  {
638  _C4RR();
639  if( ! read((ConstImpl const&)*this, &v))
640  _RYML_ERR_VISIT_(tree_->m_callbacks, tree_, id_, "could not deserialize value");
641  return *((ConstImpl const*)this);
642  }
bool read(NodeRef const &n, T *v)
Definition: node.hpp:1638

◆ operator>>() [2/4]

ConstNodeRef const& c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator>> ( Key< T >  v) const
inlineinherited

deserialize the node's key to the given variable, forwarding to the user-overrideable read() function; use key() to disambiguate; for example: node >> ryml::key(var)

Definition at line 648 of file node.hpp.

649  {
650  _C4RR();
651  if( ! readkey((ConstImpl const&)*this, &v.k))
652  _RYML_ERR_VISIT_(tree_->m_callbacks, tree_, id_, "could not deserialize key");
653  return *((ConstImpl const*)this);
654  }
bool readkey(NodeRef const &n, T *v)
Definition: node.hpp:1650

◆ operator>>() [3/4]

ConstNodeRef const& c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator>> ( Key< fmt::base64_wrapper w) const
inlineinherited

deserialize the node's key as base64.

lightweight wrapper over deserialize_key()

Definition at line 693 of file node.hpp.

694  {
695  deserialize_key(w.wrapper);
696  return *((ConstImpl const*)this);
697  }
size_t deserialize_key(fmt::base64_wrapper v) const
decode the base64-encoded key and assign the decoded blob to the given buffer/
Definition: node.hpp:709

◆ operator>>() [4/4]

ConstNodeRef const& c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::operator>> ( fmt::base64_wrapper  w) const
inlineinherited

deserialize the node's val as base64.

lightweight wrapper over deserialize_val()

Definition at line 700 of file node.hpp.

701  {
702  deserialize_val(w);
703  return *((ConstImpl const*)this);
704  }
size_t deserialize_val(fmt::base64_wrapper v) const
decode the base64-encoded key and assign the decoded blob to the given buffer/
Definition: node.hpp:717

◆ get_if() [1/2]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::get_if ( csubstr  name,
T *  var 
) const
inlineinherited

look for a child by name, if it exists assign to var.

return true if the child existed.

Definition at line 659 of file node.hpp.

660  {
661  _C4RR();
662  ConstImpl ch = find_child(name);
663  if(!ch.readable())
664  return false;
665  ch >> *var;
666  return true;
667  }
auto find_child(csubstr name) RYML_NOEXCEPT -> NodeRef
Forward to Tree::find_child().
Definition: node.hpp:353

◆ get_if() [2/2]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::get_if ( csubstr  name,
T *  var,
T const &  fallback 
) const
inlineinherited

look for a child by name, if it exists assign to var, otherwise default to fallback.

return true if the child existed.

Definition at line 673 of file node.hpp.

674  {
675  _C4RR();
676  ConstImpl ch = find_child(name);
677  if(ch.readable())
678  {
679  ch >> *var;
680  return true;
681  }
682  else
683  {
684  *var = fallback;
685  return false;
686  }
687  }

◆ deserialize_key()

size_t c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::deserialize_key ( fmt::base64_wrapper  v) const
inlineinherited

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

Returns
the size of base64-decoded blob

Definition at line 709 of file node.hpp.

710  {
711  _C4RR();
712  return from_chars(key(), &v);
713  }
bool from_chars(ryml::csubstr buf, vec2< T > *v)

◆ deserialize_val()

size_t c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::deserialize_val ( fmt::base64_wrapper  v) const
inlineinherited

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

Returns
the size of base64-decoded blob

Definition at line 717 of file node.hpp.

718  {
719  _C4RR();
720  return from_chars(val(), &v);
721  };

◆ begin() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::begin ( ) -> iterator
inlineinherited

get a mutable iterator to the first child.

NOT AVAILABLE for ConstNodeRef.

Definition at line 748 of file node.hpp.

◆ begin() [2/2]

const_iterator c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::begin ( ) const
inlineinherited

get an iterator to the first child

Definition at line 749 of file node.hpp.

◆ cbegin()

const_iterator c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::cbegin ( ) const
inlineinherited

get an iterator to the first child

Definition at line 750 of file node.hpp.

◆ end() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::end ( ) -> iterator
inlineinherited

get an iterator to after the last child.

NOT AVAILABLE for ConstNodeRef.

Definition at line 753 of file node.hpp.

◆ end() [2/2]

get an iterator to after the last child

get an iterator to after the last child

Definition at line 755 of file node.hpp.

◆ cend()

const_iterator c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::cend ( ) const
inlineinherited

get an iterator to after the last child

get an iterator to after the last child

Definition at line 757 of file node.hpp.

◆ children() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::children ( ) -> children_view
inlineinherited

get an iterable view over children.

NOT AVAILABLE for ConstNodeRef.

Definition at line 760 of file node.hpp.

◆ children() [2/2]

const_children_view c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::children ( ) const
inlineinherited

get an iterable view over children

Definition at line 761 of file node.hpp.

◆ cchildren()

const_children_view c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::cchildren ( ) const
inlineinherited

get an iterable view over children

Definition at line 762 of file node.hpp.

◆ siblings() [1/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::siblings ( ) -> children_view
inlineinherited

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

Definition at line 766 of file node.hpp.

767  {
768  _C4RR();
769  NodeData const *nd = tree__->get(id__);
770  return (nd->m_parent != NONE) ? // does it have a parent?
771  children_view(iterator(tree__, tree_->get(nd->m_parent)->m_first_child), iterator(tree__, NONE))
772  :
773  children_view(end(), end());
774  }
detail::child_iterator< NodeRef > iterator
Definition: node.hpp:742
auto end() RYML_NOEXCEPT -> iterator
get an iterator to after the last child.
Definition: node.hpp:753
detail::children_view_< NodeRef > children_view
Definition: node.hpp:744

◆ siblings() [2/2]

const_children_view c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::siblings ( ) const
inlineinherited

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

Definition at line 776 of file node.hpp.

777  {
778  _C4RR();
779  NodeData const *nd = tree_->get(id_);
780  return (nd->m_parent != NONE) ? // does it have a parent?
781  const_children_view(const_iterator(tree_, tree_->get(nd->m_parent)->m_first_child), const_iterator(tree_, NONE))
782  :
784  }
detail::children_view_< ConstNodeRef > const_children_view
Definition: node.hpp:745
detail::child_iterator< ConstNodeRef > const_iterator
Definition: node.hpp:743

◆ csiblings()

const_children_view c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::csiblings ( ) const
inlineinherited

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

Definition at line 786 of file node.hpp.

786 { return siblings(); }
auto siblings() RYML_NOEXCEPT -> children_view
get an iterable view over all siblings (including the calling node)
Definition: node.hpp:766

◆ visit() [1/2]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::visit ( Visitor  fn,
id_type  indentation_level = 0,
bool  skip_root = true 
) const
inlineinherited

visit every child node calling fn(node)

Definition at line 790 of file node.hpp.

791  {
792  _C4RR();
793  return detail::_visit(*(ConstImpl const*)this, fn, indentation_level, skip_root);
794  }

◆ visit() [2/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::visit ( Visitor  fn,
id_type  indentation_level = 0,
bool  skip_root = true 
) -> bool
inlineinherited

visit every child node calling fn(node)

Definition at line 797 of file node.hpp.

799  {
800  _C4RR();
801  return detail::_visit(*(Impl*)this, fn, indentation_level, skip_root);
802  }

◆ visit_stacked() [1/2]

bool c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::visit_stacked ( Visitor  fn,
id_type  indentation_level = 0,
bool  skip_root = true 
) const
inlineinherited

visit every child node calling fn(node, level)

Definition at line 806 of file node.hpp.

807  {
808  _C4RR();
809  return detail::_visit_stacked(*(ConstImpl const*)this, fn, indentation_level, skip_root);
810  }

◆ visit_stacked() [2/2]

auto c4::yml::detail::RoNodeMethods< NodeRef , ConstNodeRef >::visit_stacked ( Visitor  fn,
id_type  indentation_level = 0,
bool  skip_root = true 
) -> bool
inlineinherited

visit every child node calling fn(node, level)

Definition at line 813 of file node.hpp.

815  {
816  _C4RR();
817  return detail::_visit_stacked(*(Impl*)this, fn, indentation_level, skip_root);
818  }

Friends And Related Function Documentation

◆ detail::RoNodeMethods< NodeRef, ConstNodeRef >

friend struct detail::RoNodeMethods< NodeRef, ConstNodeRef >
friend

Definition at line 1012 of file node.hpp.


The documentation for this class was generated from the following files: