rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
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>

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
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.
bool is_seed () const noexcept
 true if the object is not invalid and in seed state.
bool readable () const noexcept
 true if the object is not invalid and not in seed state.
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
id_type id () const noexcept
Tree const * tree () const noexcept
Treetree () noexcept
NodeData const * get () const RYML_NOEXCEPT
 Forward to Tree::type().
NodeDataget () RYML_NOEXCEPT
 Forward to Tree::type().
node_setters
void create ()
 if this node is in seed state, create the node in the tree
void set_stream ()
void set_doc ()
void set_key (csubstr key)
void set_key (csubstr key, NodeType more_flags)
void set_val (csubstr val)
void set_val (csubstr val, NodeType more_flags)
void set_seq ()
void set_seq (NodeType more_flags)
void set_map ()
void set_map (NodeType more_flags)
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 (type_bits style)
void set_key_style (type_bits style)
void set_val_style (type_bits style)
node_modifiers
void change_type (NodeType t)
void clear_key ()
 remove the KEY (flags included) from a scalar
void clear_val ()
 remove the VAL (flags included) from a scalar
void clear_children ()
 remove the children from a scalar
void clear_style (bool recurse=false)
void set_style_conditionally (NodeType type_mask, NodeType rem_style_flags, NodeType add_style_flags, bool recurse=false)
serialization
template<class T>
csubstr to_arena (T const &s)
 forward to Tree::to_arena() .
template<class T>
void save (T const &k)
template<class T>
void save (T const &k, NodeType style_flags)
template<class T>
void save_key (T const &k)
template<class T>
void save_key (T const &k, NodeType style_flags)
template<class T>
void set_serialized (T const &v)
 serialize a variable to this node.
template<class T>
void set_serialized (T const &v, NodeType style_flags)
template<class T>
void set_key_serialized (T const &k)
 serialize a variable, then assign the result to the node's key
template<class T>
void set_key_serialized (T const &k, NodeType style_flags)
hierarchy getters
NodeRef parent () RYML_NOEXCEPT
 Forward to Tree::parent().
ConstNodeRef parent () const RYML_NOEXCEPT
 Forward to Tree::parent().
NodeRef first_child () RYML_NOEXCEPT
 Forward to Tree::first_child().
ConstNodeRef first_child () const RYML_NOEXCEPT
 Forward to Tree::first_child().
NodeRef last_child () RYML_NOEXCEPT
 Forward to Tree::last_child().
ConstNodeRef last_child () const RYML_NOEXCEPT
 Forward to Tree::last_child().
NodeRef child (id_type pos) RYML_NOEXCEPT
 Forward to Tree::child().
ConstNodeRef child (id_type pos) const RYML_NOEXCEPT
 Forward to Tree::child().
ReadResult child_r (id_type pos, NodeRef *child) RYML_NOEXCEPT
ReadResult child_r (id_type pos, ConstNodeRef *child) const RYML_NOEXCEPT
 Forward to Tree::child_r().
NodeRef find_child (csubstr name) RYML_NOEXCEPT
 Forward to Tree::child_r().
ConstNodeRef find_child (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::find_child().
ReadResult find_child_r (csubstr name, NodeRef *child) RYML_NOEXCEPT
ReadResult find_child_r (csubstr name, ConstNodeRef *child) const RYML_NOEXCEPT
 Forward to Tree::find_child_r().
NodeRef prev_sibling () RYML_NOEXCEPT
 Forward to Tree::find_child_r().
ConstNodeRef prev_sibling () const RYML_NOEXCEPT
 Forward to Tree::prev_sibling().
NodeRef next_sibling () RYML_NOEXCEPT
 Forward to Tree::next_sibling().
ConstNodeRef next_sibling () const RYML_NOEXCEPT
 Forward to Tree::next_sibling().
NodeRef first_sibling () RYML_NOEXCEPT
 Forward to Tree::first_sibling().
ConstNodeRef first_sibling () const RYML_NOEXCEPT
 Forward to Tree::first_sibling().
NodeRef last_sibling () RYML_NOEXCEPT
 Forward to Tree::last_sibling().
ConstNodeRef last_sibling () const RYML_NOEXCEPT
 Forward to Tree::last_sibling().
NodeRef sibling (id_type pos) RYML_NOEXCEPT
 Forward to Tree::sibling().
ConstNodeRef sibling (id_type pos) const RYML_NOEXCEPT
 Forward to Tree::sibling().
ReadResult sibling_r (id_type pos, NodeRef *sibling) RYML_NOEXCEPT
ReadResult sibling_r (id_type pos, ConstNodeRef *sibling) const RYML_NOEXCEPT
 Forward to Tree::sibling_r().
NodeRef find_sibling (csubstr name) RYML_NOEXCEPT
 Forward to Tree::sibling_r().
ConstNodeRef find_sibling (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::find_sibling().
ReadResult find_sibling_r (csubstr name, NodeRef *sibling) RYML_NOEXCEPT
ReadResult find_sibling_r (csubstr name, ConstNodeRef *sibling) const RYML_NOEXCEPT
 Forward to Tree::find_sibling_r().
NodeRef ancestor_doc () RYML_NOEXCEPT
 Forward to Tree::find_sibling_r().
ConstNodeRef ancestor_doc () const RYML_NOEXCEPT
 Forward to Tree::ancestor_doc().
NodeRef doc (id_type i) RYML_NOEXCEPT
 Forward to Tree::doc().
ConstNodeRef doc (id_type i) const RYML_NOEXCEPT
 Forward to Tree::doc().
square_brackets

operator[]

NodeRef operator[] (csubstr key) RYML_NOEXCEPT
 Find child by key; complexity is O(num_children).
NodeRef operator[] (id_type pos) RYML_NOEXCEPT
 Find child by position; complexity is O(pos).
ConstNodeRef operator[] (csubstr key) const RYML_NOEXCEPT
 Find a child by key; complexity is O(num_children).
ConstNodeRef operator[] (id_type pos) const RYML_NOEXCEPT
 Find a child by position; complexity is O(pos).
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).

NodeRef at (csubstr key)
 Find child by key; complexity is O(num_children).
NodeRef at (id_type pos)
 Find child by position; complexity is O(pos).
ConstNodeRef at (csubstr key) const
 Get a child by name, with error checking; complexity is O(num_children).
ConstNodeRef at (id_type pos) const
 Get a child by position, with error checking; complexity is O(pos).
modification of hierarchy
NodeRef insert_child (NodeRef after)
NodeRef prepend_child ()
NodeRef append_child ()
NodeRef insert_sibling (ConstNodeRef const &after)
NodeRef prepend_sibling ()
NodeRef append_sibling ()
void remove_child (NodeRef &child)
void remove_child (id_type pos)
 remove the nth child of this node
void remove_child (csubstr key)
 remove a child by name
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.
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.
NodeRef duplicate_children (NodeRef const &parent, ConstNodeRef const &after) const
legacy operators

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

these methods will be removed in future releases. If you disagree with a particular function being deprecated, let us know by opening a new issue at https://github.com/biojppm/rapidyaml/issues

void operator= (type_bits t)
void operator|= (type_bits t)
NodeRefoperator= (csubstr v)
template<size_t N>
NodeRefoperator= (const char(&v)[N])
NodeRefoperator= (std::nullptr_t)
template<class T>
NodeRefoperator= (Key< T > const &v)
template<class T>
NodeRefoperator<< (T const &v)
NodeRefoperator<< (csubstr v)
template<class T>
NodeRefoperator<< (Key< T > const &v)
node property getters
NodeType type () const RYML_NOEXCEPT
 Forward to Tree::type().
csubstr key () const RYML_NOEXCEPT
 Forward to Tree::key().
csubstr key_tag () const RYML_NOEXCEPT
 Forward to Tree::key_tag().
csubstr key_ref () const RYML_NOEXCEPT
 Forward to Tree::key_ref().
csubstr key_anchor () const RYML_NOEXCEPT
 Forward to Tree::key_anchor().
csubstr val () const RYML_NOEXCEPT
 Forward to Tree::val().
csubstr val_tag () const RYML_NOEXCEPT
 Forward to Tree::val_tag().
csubstr val_ref () const RYML_NOEXCEPT
 Forward to Tree::val_ref().
csubstr val_anchor () const RYML_NOEXCEPT
 Forward to Tree::val_anchor().
NodeScalar const & keysc () const RYML_NOEXCEPT
 Forward to Tree::keysc().
NodeScalar const & valsc () const RYML_NOEXCEPT
 Forward to Tree::valsc().
bool key_is_null () const RYML_NOEXCEPT
 Forward to Tree::key_is_null().
bool val_is_null () const RYML_NOEXCEPT
 Forward to Tree::val_is_null().
bool is_key_unfiltered () const noexcept
 Forward to Tree::is_key_unfiltered().
bool is_val_unfiltered () const noexcept
 Forward to Tree::is_val_unfiltered().
node type predicates
bool empty () const RYML_NOEXCEPT
 Forward to Tree::empty().
bool is_stream () const RYML_NOEXCEPT
 Forward to Tree::is_stream().
bool is_doc () const RYML_NOEXCEPT
 Forward to Tree::is_doc().
bool is_container () const RYML_NOEXCEPT
 Forward to Tree::is_container().
bool is_map () const RYML_NOEXCEPT
 Forward to Tree::is_map().
bool is_seq () const RYML_NOEXCEPT
 Forward to Tree::is_seq().
bool has_val () const RYML_NOEXCEPT
 Forward to Tree::has_val().
bool has_key () const RYML_NOEXCEPT
 Forward to Tree::has_key().
bool is_val () const RYML_NOEXCEPT
 Forward to Tree::is_val().
bool is_keyval () const RYML_NOEXCEPT
 Forward to Tree::is_keyval().
bool has_key_tag () const RYML_NOEXCEPT
 Forward to Tree::has_key_tag().
bool has_val_tag () const RYML_NOEXCEPT
 Forward to Tree::has_val_tag().
bool has_key_anchor () const RYML_NOEXCEPT
 Forward to Tree::has_key_anchor().
bool has_val_anchor () const RYML_NOEXCEPT
 Forward to Tree::has_val_anchor().
bool has_anchor () const RYML_NOEXCEPT
 Forward to Tree::has_anchor().
bool is_key_ref () const RYML_NOEXCEPT
 Forward to Tree::is_key_ref().
bool is_val_ref () const RYML_NOEXCEPT
 Forward to Tree::is_val_ref().
bool is_ref () const RYML_NOEXCEPT
 Forward to Tree::is_ref().
bool parent_is_seq () const RYML_NOEXCEPT
 Forward to Tree::parent_is_seq().
bool parent_is_map () const RYML_NOEXCEPT
 Forward to Tree::parent_is_map().
style predicates
bool type_has_any (type_bits bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_any().
bool type_has_all (type_bits bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_all().
bool type_has_none (type_bits bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_none().
NodeType key_style () const RYML_NOEXCEPT
 Forward to Tree::key_style().
NodeType val_style () const RYML_NOEXCEPT
 Forward to Tree::val_style().
bool is_container_styled () const RYML_NOEXCEPT
 Forward to Tree::is_container_styled().
bool is_block () const RYML_NOEXCEPT
 Forward to Tree::is_block().
bool is_flow () const RYML_NOEXCEPT
 Forward to Tree::is_flow().
bool is_flow_sl () const RYML_NOEXCEPT
 Forward to Tree::is_flow_sl().
bool is_flow_ml () const RYML_NOEXCEPT
 Forward to Tree::is_flow_ml1().
bool is_flow_ml1 () const RYML_NOEXCEPT
 Forward to Tree::is_flow_ml1().
bool is_flow_mln () const RYML_NOEXCEPT
 Forward to Tree::is_flow_mln().
bool is_flow_mlx () const RYML_NOEXCEPT
 Forward to Tree::is_flow_mlx().
bool has_flow_space () const RYML_NOEXCEPT
 Forward to Tree::has_flow_space().
bool is_key_styled () const RYML_NOEXCEPT
 Forward to Tree::is_key_styled().
bool is_val_styled () const RYML_NOEXCEPT
 Forward to Tree::is_val_styled().
bool is_key_literal () const RYML_NOEXCEPT
 Forward to Tree::is_key_literal().
bool is_val_literal () const RYML_NOEXCEPT
 Forward to Tree::is_val_literal().
bool is_key_folded () const RYML_NOEXCEPT
 Forward to Tree::is_key_folded().
bool is_val_folded () const RYML_NOEXCEPT
 Forward to Tree::is_val_folded().
bool is_key_squo () const RYML_NOEXCEPT
 Forward to Tree::is_key_squo().
bool is_val_squo () const RYML_NOEXCEPT
 Forward to Tree::is_val_squo().
bool is_key_dquo () const RYML_NOEXCEPT
 Forward to Tree::is_key_dquo().
bool is_val_dquo () const RYML_NOEXCEPT
 Forward to Tree::is_val_dquo().
bool is_key_plain () const RYML_NOEXCEPT
 Forward to Tree::is_key_plain().
bool is_val_plain () const RYML_NOEXCEPT
 Forward to Tree::is_val_plain().
bool is_key_quoted () const RYML_NOEXCEPT
 Forward to Tree::is_key_quoted().
bool is_val_quoted () const RYML_NOEXCEPT
 Forward to Tree::is_val_quoted().
bool is_quoted () const RYML_NOEXCEPT
 Forward to Tree::is_quoted().
hierarchy predicates
bool is_root () const RYML_NOEXCEPT
 Forward to Tree::is_root().
bool has_parent () const RYML_NOEXCEPT
 Forward to Tree::has_parent() Node must be readable.
bool is_ancestor (ConstNodeRef const &ancestor) const RYML_NOEXCEPT
 Forward to Tree::is_ancestor() Node must be readable.
bool has_child (ConstNodeRef const &n) const RYML_NOEXCEPT
 Forward to Tree::has_child().
bool has_child (id_type node) const RYML_NOEXCEPT
 Forward to Tree::has_child().
bool has_child (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::has_child().
bool has_children () const RYML_NOEXCEPT
 Forward to Tree::has_children().
bool has_sibling (ConstNodeRef const &n) const RYML_NOEXCEPT
 Forward to Tree::has_sibling().
bool has_sibling (id_type node) const RYML_NOEXCEPT
 Forward to Tree::has_sibling().
bool has_sibling (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::has_sibling().
bool has_other_siblings () const RYML_NOEXCEPT
 Forward to Tree::has_other_siblings().
hierarchy getters
id_type num_children () const RYML_NOEXCEPT
 O(num_children).
id_type num_siblings () const RYML_NOEXCEPT
 O(num_children).
id_type num_other_siblings () const RYML_NOEXCEPT
 O(num_siblings).
id_type child_pos (ConstNodeRef const &n) const RYML_NOEXCEPT
 O(num_children).
id_type sibling_pos (ConstNodeRef const &n) const RYML_NOEXCEPT
 O(num_siblings).
id_type depth_asc () const RYML_NOEXCEPT
id_type depth_desc () const RYML_NOEXCEPT
 O(log(num_nodes)).
locations

O(num_nodes).

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

Location location (Parser const &parser) const
deserialization: fully checked for lazy code

These methods raise an error if the deserialization failed or optionally if the node is not readable.

void load (T *v, bool check_readable=true) const
 (1) deserialize the node's contents (val or container) to the given variable, forwarding to the user-overrideable read() function, which can be for ConstNodeRef (see Read from ConstNodeRef) or for tree+id (see Read from Tree).
void load (Wrapper const &wrapper, bool check_readable=true) const
 (2) like (1), but for wrapper tag types such as c4::fmt::base64()
void load_key (T *k, bool check_readable=true) const
 (1) deserialize the node's key (necessarily a scalar) to the given variable, forwarding to the user-overrideable read_key() function, which can be for ConstNodeRef (see Read from ConstNodeRef) or for tree+id (see Read from Tree).
void load_key (Wrapper const &wrapper, bool check_readable=true) const
 (2) like (1), but for wrapper tag types such as c4::fmt::base64()
deserialization: asserts node readability, returns success status
ReadResult deserialize (T *v) const
 (1) deserialize the node's contents (val or container) to the given variable, forwarding to the user-overrideable read() function (see Read from ConstNodeRef).
ReadResult deserialize (Wrapper const &wrapper) const
 (2) like (1), but for wrapper tag types such as c4::fmt::base64()
ReadResult deserialize_key (T *v) const
 (1) deserialize the node's key (necessarily a scalar) to the given variable, forwarding to the user-overrideable read_key() function (see Read from ConstNodeRef).
ReadResult deserialize_key (Wrapper const &wrapper) const
 (2) like (1), but for wrapper tag types such as c4::fmt::base64()
lookup and deserialize
ReadResult deserialize_child (csubstr child_key, T *v) const
 (1) find a child by name and deserialize its contents to the given variable (ie call .deserialize() on the child if it exists).
ReadResult deserialize_child (csubstr child_key, T *v, T const &fallback) const
 (2) like (1), but assign from fallback if no such child exists.
ReadResult deserialize_child (csubstr child_key, Wrapper const &v) const
 (3) like (1), but for wrapper tag types such as c4::fmt::base64()
ReadResult deserialize_child (id_type child_pos, T *v) const
 (1) find a child by position and deserialize its contents to the given variable (ie call .deserialize() on the child if it exists).
ReadResult deserialize_child (id_type child_pos, T *v, T const &fallback) const
 (2) like (1), but assign from fallback if no such child exists
ReadResult deserialize_child (id_type child_pos, Wrapper const &wrapper) const
 (3) like (1), but for wrapper tag types such as c4::fmt::base64()
legacy operators
NodeRef const & operator>> (T &v) const
NodeRef const & operator>> (T const &wrapper) const
NodeRef const & operator>> (Key< T > const &v) const

Protected Member Functions

void check_val_ () const
void check_key_ () const
void assert_val_ () const noexcept
void assert_key_ () const noexcept

Static Protected Member Functions

static void err_basic_ (const char *msg)
static void err_visit_ (Tree const *tree, id_type id, const char *msg)

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>
iterator begin () RYML_NOEXCEPT
 get a mutable iterator to the first child.
const_iterator begin () const RYML_NOEXCEPT
 get an iterator to the first child
const_iterator cbegin () const RYML_NOEXCEPT
 get an iterator to the first child
iterator end () RYML_NOEXCEPT
 get an iterator to after the last child.
const_iterator end () const RYML_NOEXCEPT
 get an iterator to after the last child
const_iterator cend () const RYML_NOEXCEPT
 get an iterator to after the last child
children_view children () RYML_NOEXCEPT
 get an iterable view over children
const_children_view children () const RYML_NOEXCEPT
 get an iterable view over children
const_children_view cchildren () const RYML_NOEXCEPT
 get an iterable view over children
children_view siblings () RYML_NOEXCEPT
const_children_view siblings () const RYML_NOEXCEPT
 get an iterable view over all siblings (including the calling node)
const_children_view csiblings () const RYML_NOEXCEPT
 get an iterable view over all siblings (including the calling node)

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:1106
bool invalid() const noexcept
true if the object is not referring to any existing or seed node.
Definition node.hpp:1134
bool readable() const noexcept
true if the object is not invalid and not in seed state.
Definition node.hpp:1138
void parse_in_arena(Parser *parser, csubstr filename, csubstr yaml, Tree *tree, 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:209

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 1062 of file node.hpp.

Member Typedef Documentation

◆ tree_type

Definition at line 1066 of file node.hpp.

◆ base_type

Definition at line 1067 of file node.hpp.

◆ iterator

using c4::yml::NodeRef::iterator = detail::child_iterator<NodeRef>

Definition at line 1828 of file node.hpp.

◆ const_iterator

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

Definition at line 1829 of file node.hpp.

◆ children_view

using c4::yml::NodeRef::children_view = detail::children_view<NodeRef>

Definition at line 1830 of file node.hpp.

◆ const_children_view

using c4::yml::NodeRef::const_children_view = detail::children_view<ConstNodeRef>

Definition at line 1831 of file node.hpp.

Constructor & Destructor Documentation

◆ NodeRef() [1/8]

◆ NodeRef() [2/8]

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

Definition at line 1107 of file node.hpp.

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

◆ NodeRef() [3/8]

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

Definition at line 1108 of file node.hpp.

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

◆ NodeRef() [4/8]

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

Definition at line 1109 of file node.hpp.

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

◆ NodeRef() [5/8]

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

Definition at line 1110 of file node.hpp.

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

◆ NodeRef() [6/8]

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

Definition at line 1111 of file node.hpp.

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

◆ NodeRef() [7/8]

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

◆ NodeRef() [8/8]

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

Member Function Documentation

◆ operator=() [1/7]

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

◆ operator=() [2/7]

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 1134 of file node.hpp.

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

Referenced by invalid(), sample_create_tree(), and sample_quick_overview().

◆ 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 1136 of file node.hpp.

1136{ return (m_tree != nullptr && m_id != NONE) && has_seed_(); }

Referenced by operator==(), operator==(), sample_create_tree(), and sample_quick_overview().

◆ 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 1138 of file node.hpp.

1138{ return (m_tree != nullptr && m_id != NONE) && !has_seed_(); }

Referenced by at(), at(), at(), at(), get(), get(), and sample_quick_overview().

◆ operator==() [1/2]

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

Definition at line 1178 of file node.hpp.

1179 {
1180 if(m_tree == that.m_tree && m_id == that.m_id)
1181 {
1182 bool seed = is_seed();
1183 if(seed == that.is_seed())
1184 {
1185 if(seed)
1186 {
1187 return (m_seed.len == that.m_seed.len)
1188 && (m_seed.str == that.m_seed.str
1189 || m_seed == that.m_seed); // do strcmp only in the last resort
1190 }
1191 return true;
1192 }
1193 }
1194 return false;
1195 }
bool is_seed() const noexcept
true if the object is not invalid and in seed state.
Definition node.hpp:1136

◆ operator!=() [1/2]

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

Definition at line 1196 of file node.hpp.

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

◆ operator==() [2/2]

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

Definition at line 1198 of file node.hpp.

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

◆ operator!=() [2/2]

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

Definition at line 1199 of file node.hpp.

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

◆ id()

◆ tree() [1/2]

◆ tree() [2/2]

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

Definition at line 1211 of file node.hpp.

1211{ return m_tree; }

◆ get() [1/2]

NodeData const * c4::yml::NodeRef::get ( ) const
inline

Forward to Tree::type().

Node must be readable.

Definition at line 1213 of file node.hpp.

◆ get() [2/2]

NodeData * c4::yml::NodeRef::get ( )
inline

Forward to Tree::type().

Node must be readable.

Definition at line 1214 of file node.hpp.

◆ create()

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

if this node is in seed state, create the node in the tree

Definition at line 1225 of file node.hpp.

1226 {
1227 RYML_ASSERT_BASIC_(m_tree != nullptr);
1228 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, m_id != NONE && m_id < m_tree->capacity(), m_tree, m_id);
1229 if(m_seed.str) // we have a seed key: use it to create the new map child
1230 {
1231 m_id = m_tree->append_child(m_id);
1232 m_tree->set_key(m_id, m_seed);
1233 m_seed.str = nullptr;
1234 m_seed.len = (size_t)NONE;
1235 }
1236 else if(m_seed.len != (size_t)NONE) // we have a seed index: create a seq child at that position
1237 {
1238 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, (size_t)m_tree->num_children(m_id) == m_seed.len, m_tree, m_id);
1239 m_id = m_tree->append_child(m_id);
1240 m_seed.str = nullptr;
1241 m_seed.len = (size_t)NONE;
1242 }
1243 }

Referenced by operator=(), operator|=(), save(), save(), save_key(), save_key(), set_container_style(), set_doc(), set_key(), set_key(), set_key_anchor(), set_key_ref(), set_key_serialized(), set_key_serialized(), set_key_style(), set_key_tag(), set_map(), set_map(), set_seq(), set_seq(), set_serialized(), set_serialized(), set_stream(), set_val(), set_val(), set_val_anchor(), set_val_ref(), set_val_style(), and set_val_tag().

◆ set_stream()

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

Definition at line 1245 of file node.hpp.

1245{ create(); m_tree->set_stream(m_id); }
void create()
if this node is in seed state, create the node in the tree
Definition node.hpp:1225

◆ set_doc()

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

Definition at line 1246 of file node.hpp.

1246{ create(); m_tree->set_doc(m_id); }

◆ set_key() [1/2]

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

Definition at line 1248 of file node.hpp.

1248{ create(); m_tree->set_key(m_id, key); }

Referenced by operator=().

◆ set_key() [2/2]

void c4::yml::NodeRef::set_key ( csubstr key,
NodeType more_flags )
inline

Definition at line 1249 of file node.hpp.

1249{ create(); m_tree->set_key(m_id, key, more_flags); }

◆ set_val() [1/2]

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

Definition at line 1251 of file node.hpp.

1251{ create(); m_tree->set_val(m_id, val); }

Referenced by operator=(), operator=(), operator=(), sample_create_tree(), sample_create_tree_style(), and sample_quick_overview().

◆ set_val() [2/2]

void c4::yml::NodeRef::set_val ( csubstr val,
NodeType more_flags )
inline

Definition at line 1252 of file node.hpp.

1252{ create(); m_tree->set_val(m_id, val, more_flags); }

◆ set_seq() [1/2]

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

◆ set_seq() [2/2]

void c4::yml::NodeRef::set_seq ( NodeType more_flags)
inline

Definition at line 1255 of file node.hpp.

1255{ create(); m_tree->set_seq(m_id, more_flags); }

◆ set_map() [1/2]

◆ set_map() [2/2]

void c4::yml::NodeRef::set_map ( NodeType more_flags)
inline

Definition at line 1258 of file node.hpp.

1258{ create(); m_tree->set_map(m_id, more_flags); }

◆ set_key_tag()

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

Definition at line 1260 of file node.hpp.

1260{ create(); m_tree->set_key_tag(m_id, key_tag); }

◆ set_val_tag()

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

Definition at line 1261 of file node.hpp.

1261{ create(); m_tree->set_val_tag(m_id, val_tag); }

◆ set_key_anchor()

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

Definition at line 1262 of file node.hpp.

1262{ create(); m_tree->set_key_anchor(m_id, key_anchor); }

◆ set_val_anchor()

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

Definition at line 1263 of file node.hpp.

1263{ create(); m_tree->set_val_anchor(m_id, val_anchor); }

◆ set_key_ref()

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

Definition at line 1264 of file node.hpp.

1264{ create(); m_tree->set_key_ref(m_id, key_ref); }

◆ set_val_ref()

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

Definition at line 1265 of file node.hpp.

1265{ create(); m_tree->set_val_ref(m_id, val_ref); }

Referenced by sample_anchors_and_aliases_create().

◆ set_container_style()

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

Definition at line 1267 of file node.hpp.

1267{ create(); m_tree->set_container_style(m_id, style); }

Referenced by sample_style(), and sample_style_flow_ml_indent().

◆ set_key_style()

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

Definition at line 1268 of file node.hpp.

1268{ create(); m_tree->set_key_style(m_id, style); }

Referenced by sample_style().

◆ set_val_style()

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

Definition at line 1269 of file node.hpp.

1269{ create(); m_tree->set_val_style(m_id, style); }

Referenced by sample_style().

◆ change_type()

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

Definition at line 1278 of file node.hpp.

1279 {
1280 assert_readable_();
1281 m_tree->change_type(m_id, t);
1282 }

◆ clear_key()

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

remove the KEY (flags included) from a scalar

Definition at line 1285 of file node.hpp.

1286 {
1287 assert_readable_();
1288 m_tree->_clear_key(m_id);
1289 }

◆ clear_val()

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

remove the VAL (flags included) from a scalar

Definition at line 1292 of file node.hpp.

1293 {
1294 assert_readable_();
1295 m_tree->_clear_val(m_id);
1296 }

◆ clear_children()

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

remove the children from a scalar

Definition at line 1299 of file node.hpp.

1300 {
1301 assert_readable_();
1302 m_tree->remove_children(m_id);
1303 }

◆ clear_style()

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

Definition at line 1305 of file node.hpp.

1306 {
1307 assert_readable_();
1308 m_tree->clear_style(m_id, recurse);
1309 }

Referenced by sample_json(), and sample_style().

◆ 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 1311 of file node.hpp.

1315 {
1316 assert_readable_();
1317 m_tree->set_style_conditionally(m_id, type_mask, rem_style_flags, add_style_flags, recurse);
1318 }

Referenced by sample_style().

◆ to_arena()

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

forward to Tree::to_arena() .

Serializes a scalar type to the tree's arena. The type must be serializeable as a scalar.

Definition at line 1330 of file node.hpp.

1331 {
1332 RYML_ASSERT_BASIC_(m_tree); // no need for valid or readable
1333 return m_tree->to_arena(s);
1334 }

◆ save() [1/2]

template<class T>
void c4::yml::NodeRef::save ( T const & k)
inline

Definition at line 1337 of file node.hpp.

1338 {
1339 check_writeable_();
1340 create();
1341 write(*this, k);
1342 }
void write(NodeRef *n, T const &v)
Definition node.hpp:2114

Referenced by operator<<(), operator<<(), sample_float_precision(), sample_lightning_overview(), sample_std_types(), and sample_user_container_types().

◆ save() [2/2]

template<class T>
void c4::yml::NodeRef::save ( T const & k,
NodeType style_flags )
inline

Definition at line 1344 of file node.hpp.

1345 {
1346 check_writeable_();
1347 create();
1348 write(*this, k);
1349 RYML_ASSERT_BASIC_(!(style_flags & ~STYLE));
1350 _add_flags(style_flags);
1351 }
@ STYLE
mask of SCALAR_STYLE | CONTAINER_STYLE : all style flags

◆ save_key() [1/2]

template<class T>
void c4::yml::NodeRef::save_key ( T const & k)
inline

Definition at line 1354 of file node.hpp.

1355 {
1356 check_writeable_();
1357 create();
1358 write_key(*this, k);
1359 }
void write_key(NodeRef *n, T const &v)
Definition node.hpp:2119

Referenced by operator<<().

◆ save_key() [2/2]

template<class T>
void c4::yml::NodeRef::save_key ( T const & k,
NodeType style_flags )
inline

Definition at line 1361 of file node.hpp.

1362 {
1363 check_writeable_();
1364 create();
1365 write_key(*this, k);
1366 RYML_ASSERT_BASIC_(!(style_flags & ~STYLE));
1367 _add_flags(style_flags);
1368 }

◆ set_serialized() [1/2]

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

serialize a variable to this node.

If the variable is a scalar, it is first serialized to the arena, and then assigned to the node's val. Otherwise, the node will be made a container, and its contents populated from the variable.

Definition at line 1375 of file node.hpp.

1376 {
1377 assert_writeable_();
1378 create();
1379 write(*this, v);
1380 }

Referenced by sample_base64(), sample_create_tree(), sample_create_tree_style(), sample_quick_overview(), sample_tree_arena(), and c4::yml::write().

◆ set_serialized() [2/2]

template<class T>
void c4::yml::NodeRef::set_serialized ( T const & v,
NodeType style_flags )
inline

Definition at line 1382 of file node.hpp.

1383 {
1384 assert_writeable_();
1385 create();
1386 write(*this, v);
1387 RYML_ASSERT_BASIC_(!(style_flags & ~STYLE));
1388 _add_flags(style_flags);
1389 }

◆ set_key_serialized() [1/2]

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

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

Warning
The variable must be serialized as a scalar, ie it cannot be serialized as a container.

Definition at line 1396 of file node.hpp.

1397 {
1398 assert_writeable_();
1399 create();
1400 write_key(*this, k);
1401 }

Referenced by sample_base64(), sample_create_tree_style(), sample_quick_overview(), and c4::yml::write().

◆ set_key_serialized() [2/2]

template<class T>
void c4::yml::NodeRef::set_key_serialized ( T const & k,
NodeType style_flags )
inline

Definition at line 1403 of file node.hpp.

1404 {
1405 assert_writeable_();
1406 create();
1407 write_key(*this, k);
1408 RYML_ASSERT_BASIC_(!(style_flags & ~STYLE));
1409 _add_flags(style_flags);
1410 }

◆ parent() [1/2]

NodeRef c4::yml::NodeRef::parent ( )
inline

Forward to Tree::parent().

Node must be readable.

Definition at line 1422 of file node.hpp.

Referenced by duplicate(), duplicate_children(), and move().

◆ parent() [2/2]

ConstNodeRef c4::yml::NodeRef::parent ( ) const
inline

Forward to Tree::parent().

Node must be readable.

Definition at line 1423 of file node.hpp.

◆ first_child() [1/2]

NodeRef c4::yml::NodeRef::first_child ( )
inline

Forward to Tree::first_child().

Node must be readable.

Definition at line 1425 of file node.hpp.

◆ first_child() [2/2]

ConstNodeRef c4::yml::NodeRef::first_child ( ) const
inline

Forward to Tree::first_child().

Node must be readable.

Definition at line 1426 of file node.hpp.

◆ last_child() [1/2]

NodeRef c4::yml::NodeRef::last_child ( )
inline

Forward to Tree::last_child().

Node must be readable.

Definition at line 1428 of file node.hpp.

◆ last_child() [2/2]

ConstNodeRef c4::yml::NodeRef::last_child ( ) const
inline

Forward to Tree::last_child().

Node must be readable.

Definition at line 1429 of file node.hpp.

◆ child() [1/2]

NodeRef c4::yml::NodeRef::child ( id_type pos)
inline

Forward to Tree::child().

Node must be readable.

Definition at line 1431 of file node.hpp.

Referenced by child_r(), child_r(), find_child_r(), find_child_r(), remove_child(), remove_child(), and remove_child().

◆ child() [2/2]

ConstNodeRef c4::yml::NodeRef::child ( id_type pos) const
inline

Forward to Tree::child().

Node must be readable.

Definition at line 1432 of file node.hpp.

◆ child_r() [1/2]

ReadResult c4::yml::NodeRef::child_r ( id_type pos,
NodeRef * child )
inline

Definition at line 1434 of file node.hpp.

1434{ assert_readable_(); child->m_tree = m_tree; ReadResult result = m_tree->child_r(m_id, pos, &child->m_id); return result; }; /**< Forward to @ref Tree::child_r(). Node must be readable. */
NodeRef child(id_type pos) RYML_NOEXCEPT
Forward to Tree::child().
Definition node.hpp:1431

◆ child_r() [2/2]

ReadResult c4::yml::NodeRef::child_r ( id_type pos,
ConstNodeRef * child ) const
inline

Forward to Tree::child_r().

Node must be readable.

Definition at line 1435 of file node.hpp.

1435{ assert_readable_(); child->m_tree = m_tree; ReadResult result = m_tree->child_r(m_id, pos, &child->m_id); return result; }; /**< Forward to @ref Tree::child_r(). Node must be readable. */

◆ find_child() [1/2]

NodeRef c4::yml::NodeRef::find_child ( csubstr name)
inline

Forward to Tree::child_r().

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

Definition at line 1437 of file node.hpp.

◆ find_child() [2/2]

ConstNodeRef c4::yml::NodeRef::find_child ( csubstr name) const
inline

Forward to Tree::find_child().

Node must be readable.

Definition at line 1438 of file node.hpp.

◆ find_child_r() [1/2]

ReadResult c4::yml::NodeRef::find_child_r ( csubstr name,
NodeRef * child )
inline

Definition at line 1440 of file node.hpp.

1440{ assert_readable_(); child->m_tree = m_tree; ReadResult result = m_tree->find_child_r(m_id, name, &child->m_id); return result; }; /**< Forward to @ref Tree::find_child_r(). Node must be readable. */

◆ find_child_r() [2/2]

ReadResult c4::yml::NodeRef::find_child_r ( csubstr name,
ConstNodeRef * child ) const
inline

Forward to Tree::find_child_r().

Node must be readable.

Definition at line 1441 of file node.hpp.

1441{ assert_readable_(); child->m_tree = m_tree; ReadResult result = m_tree->find_child_r(m_id, name, &child->m_id); return result; }; /**< Forward to @ref Tree::find_child_r(). Node must be readable. */

◆ prev_sibling() [1/2]

NodeRef c4::yml::NodeRef::prev_sibling ( )
inline

Forward to Tree::find_child_r().

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

Definition at line 1443 of file node.hpp.

◆ prev_sibling() [2/2]

ConstNodeRef c4::yml::NodeRef::prev_sibling ( ) const
inline

Forward to Tree::prev_sibling().

Node must be readable.

Definition at line 1444 of file node.hpp.

◆ next_sibling() [1/2]

NodeRef c4::yml::NodeRef::next_sibling ( )
inline

Forward to Tree::next_sibling().

Node must be readable.

Definition at line 1446 of file node.hpp.

◆ next_sibling() [2/2]

ConstNodeRef c4::yml::NodeRef::next_sibling ( ) const
inline

Forward to Tree::next_sibling().

Node must be readable.

Definition at line 1447 of file node.hpp.

◆ first_sibling() [1/2]

NodeRef c4::yml::NodeRef::first_sibling ( )
inline

Forward to Tree::first_sibling().

Node must be readable.

Definition at line 1449 of file node.hpp.

◆ first_sibling() [2/2]

ConstNodeRef c4::yml::NodeRef::first_sibling ( ) const
inline

Forward to Tree::first_sibling().

Node must be readable.

Definition at line 1450 of file node.hpp.

◆ last_sibling() [1/2]

NodeRef c4::yml::NodeRef::last_sibling ( )
inline

Forward to Tree::last_sibling().

Node must be readable.

Definition at line 1452 of file node.hpp.

◆ last_sibling() [2/2]

ConstNodeRef c4::yml::NodeRef::last_sibling ( ) const
inline

Forward to Tree::last_sibling().

Node must be readable.

Definition at line 1453 of file node.hpp.

◆ sibling() [1/2]

NodeRef c4::yml::NodeRef::sibling ( id_type pos)
inline

Forward to Tree::sibling().

Node must be readable.

Definition at line 1455 of file node.hpp.

Referenced by find_sibling_r(), find_sibling_r(), sibling_r(), and sibling_r().

◆ sibling() [2/2]

ConstNodeRef c4::yml::NodeRef::sibling ( id_type pos) const
inline

Forward to Tree::sibling().

Node must be readable.

Definition at line 1456 of file node.hpp.

◆ sibling_r() [1/2]

ReadResult c4::yml::NodeRef::sibling_r ( id_type pos,
NodeRef * sibling )
inline

Definition at line 1458 of file node.hpp.

1458{ assert_readable_(); sibling->m_tree = m_tree; ReadResult result = m_tree->sibling_r(m_id, pos, &sibling->m_id); return result; }; /**< Forward to @ref Tree::sibling_r(). Node must be readable. */
NodeRef sibling(id_type pos) RYML_NOEXCEPT
Forward to Tree::sibling().
Definition node.hpp:1455

◆ sibling_r() [2/2]

ReadResult c4::yml::NodeRef::sibling_r ( id_type pos,
ConstNodeRef * sibling ) const
inline

Forward to Tree::sibling_r().

Node must be readable.

Definition at line 1459 of file node.hpp.

1459{ assert_readable_(); sibling->m_tree = m_tree; ReadResult result = m_tree->sibling_r(m_id, pos, &sibling->m_id); return result; }; /**< Forward to @ref Tree::sibling_r(). Node must be readable. */

◆ find_sibling() [1/2]

NodeRef c4::yml::NodeRef::find_sibling ( csubstr name)
inline

Forward to Tree::sibling_r().

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

Definition at line 1461 of file node.hpp.

◆ find_sibling() [2/2]

ConstNodeRef c4::yml::NodeRef::find_sibling ( csubstr name) const
inline

Forward to Tree::find_sibling().

Node must be readable.

Definition at line 1462 of file node.hpp.

◆ find_sibling_r() [1/2]

ReadResult c4::yml::NodeRef::find_sibling_r ( csubstr name,
NodeRef * sibling )
inline

Definition at line 1464 of file node.hpp.

1464{ assert_readable_(); sibling->m_tree = m_tree; ReadResult result = m_tree->find_sibling_r(m_id, name, &sibling->m_id); return result; }; /**< Forward to @ref Tree::find_sibling_r(). Node must be readable. */

◆ find_sibling_r() [2/2]

ReadResult c4::yml::NodeRef::find_sibling_r ( csubstr name,
ConstNodeRef * sibling ) const
inline

Forward to Tree::find_sibling_r().

Node must be readable.

Definition at line 1465 of file node.hpp.

1465{ assert_readable_(); sibling->m_tree = m_tree; ReadResult result = m_tree->find_sibling_r(m_id, name, &sibling->m_id); return result; }; /**< Forward to @ref Tree::find_sibling_r(). Node must be readable. */

◆ ancestor_doc() [1/2]

NodeRef c4::yml::NodeRef::ancestor_doc ( )
inline

Forward to Tree::find_sibling_r().

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

Definition at line 1467 of file node.hpp.

◆ ancestor_doc() [2/2]

ConstNodeRef c4::yml::NodeRef::ancestor_doc ( ) const
inline

Forward to Tree::ancestor_doc().

Node must be readable.

Definition at line 1468 of file node.hpp.

◆ doc() [1/2]

NodeRef c4::yml::NodeRef::doc ( id_type i)
inline

Forward to Tree::doc().

Node must be readable.

Definition at line 1470 of file node.hpp.

◆ doc() [2/2]

ConstNodeRef c4::yml::NodeRef::doc ( id_type i) const
inline

Forward to Tree::doc().

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

Definition at line 1471 of file node.hpp.

◆ operator[]() [1/4]

NodeRef c4::yml::NodeRef::operator[] ( csubstr key)
inline

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 1499 of file node.hpp.

1500 {
1501 assert_readable_();
1502 id_type ch = m_tree->find_child(m_id, key);
1503 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, key);
1504 }
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:124

◆ operator[]() [2/4]

NodeRef c4::yml::NodeRef::operator[] ( id_type pos)
inline

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 1524 of file node.hpp.

1525 {
1526 assert_readable_();
1527 id_type ch = m_tree->child(m_id, pos);
1528 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, pos);
1529 }

◆ operator[]() [3/4]

ConstNodeRef c4::yml::NodeRef::operator[] ( csubstr key) const
inline

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 1540 of file node.hpp.

1541 {
1542 assert_readable_();
1543 id_type ch = m_tree->find_child(m_id, key);
1544 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1545 return {m_tree, ch};
1546 }

◆ operator[]() [4/4]

ConstNodeRef c4::yml::NodeRef::operator[] ( id_type pos) const
inline

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 1557 of file node.hpp.

1558 {
1559 assert_readable_();
1560 id_type ch = m_tree->child(m_id, pos);
1561 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1562 return {m_tree, ch};
1563 }

◆ at() [1/4]

NodeRef c4::yml::NodeRef::at ( csubstr key)
inline

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 1604 of file node.hpp.

1605 {
1606 RYML_CHECK_BASIC_(m_tree != nullptr);
1607 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, (m_id >= 0 && m_id < m_tree->capacity()), m_tree, m_id);
1608 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, readable(), m_tree, m_id);
1609 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, m_tree->is_map(m_id), m_tree, m_id);
1610 id_type ch = m_tree->find_child(m_id, key);
1611 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, key);
1612 }

◆ at() [2/4]

NodeRef c4::yml::NodeRef::at ( id_type pos)
inline

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 1639 of file node.hpp.

1640 {
1641 RYML_CHECK_BASIC_(m_tree != nullptr);
1642 const id_type cap = m_tree->capacity();
1643 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, (m_id >= 0 && m_id < cap), m_tree, m_id);
1644 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, (pos >= 0 && pos < cap), m_tree, m_id);
1645 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, readable(), m_tree, m_id);
1646 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, m_tree->is_container(m_id), m_tree, m_id);
1647 id_type ch = m_tree->child(m_id, pos);
1648 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, pos);
1649 }

◆ at() [3/4]

ConstNodeRef c4::yml::NodeRef::at ( csubstr key) const
inline

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 1660 of file node.hpp.

1661 {
1662 RYML_CHECK_BASIC_(m_tree != nullptr);
1663 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, (m_id >= 0 && m_id < m_tree->capacity()), m_tree, m_id);
1664 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, readable(), m_tree, m_id);
1665 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, m_tree->is_map(m_id), m_tree, m_id);
1666 id_type ch = m_tree->find_child(m_id, key);
1667 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1668 return {m_tree, ch};
1669 }

◆ at() [4/4]

ConstNodeRef c4::yml::NodeRef::at ( id_type pos) const
inline

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 1680 of file node.hpp.

1681 {
1682 RYML_CHECK_BASIC_(m_tree != nullptr);
1683 const id_type cap = m_tree->capacity();
1684 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, (m_id >= 0 && m_id < cap), m_tree, m_id);
1685 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, (pos >= 0 && pos < cap), m_tree, m_id);
1686 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, readable(), m_tree, m_id);
1687 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, m_tree->is_container(m_id), m_tree, m_id);
1688 const id_type ch = m_tree->child(m_id, pos);
1689 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1690 return {m_tree, ch};
1691 }

◆ insert_child()

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

Definition at line 1700 of file node.hpp.

1701 {
1702 assert_readable_();
1703 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1704 NodeRef r(m_tree, m_tree->insert_child(m_id, after.m_id));
1705 return r;
1706 }

◆ prepend_child()

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

Definition at line 1708 of file node.hpp.

1709 {
1710 assert_readable_();
1711 NodeRef r(m_tree, m_tree->insert_child(m_id, NONE));
1712 return r;
1713 }

◆ append_child()

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

Definition at line 1715 of file node.hpp.

1716 {
1717 assert_readable_();
1718 NodeRef r(m_tree, m_tree->append_child(m_id));
1719 return r;
1720 }

Referenced by sample_anchors_and_aliases_create(), sample_base64(), sample_create_tree(), sample_create_tree_style(), sample_float_precision(), sample_lightning_overview(), sample_parse_reuse_tree(), sample_quick_overview(), c4::yml::write(), and c4::yml::write().

◆ insert_sibling()

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

Definition at line 1722 of file node.hpp.

1723 {
1724 assert_readable_();
1725 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1726 NodeRef r(m_tree, m_tree->insert_sibling(m_id, after.m_id));
1727 return r;
1728 }

◆ prepend_sibling()

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

Definition at line 1730 of file node.hpp.

1731 {
1732 assert_readable_();
1733 NodeRef r(m_tree, m_tree->prepend_sibling(m_id));
1734 return r;
1735 }

◆ append_sibling()

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

Definition at line 1737 of file node.hpp.

1738 {
1739 assert_readable_();
1740 NodeRef r(m_tree, m_tree->append_sibling(m_id));
1741 return r;
1742 }

◆ remove_child() [1/3]

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

Definition at line 1746 of file node.hpp.

1747 {
1748 assert_readable_();
1749 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, has_child(child), m_tree, m_id);
1750 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, child.parent().id() == id(), m_tree, m_id);
1751 m_tree->remove(child.id());
1752 child = NodeRef{};
1753 }
bool has_child(ConstNodeRef const &n) const RYML_NOEXCEPT
Definition node.hpp:282

◆ remove_child() [2/3]

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

remove the nth child of this node

Definition at line 1756 of file node.hpp.

1757 {
1758 assert_readable_();
1759 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, pos >= 0 && pos < num_children(), m_tree, m_id);
1760 id_type child = m_tree->child(m_id, pos);
1761 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, child != NONE, m_tree, m_id);
1762 m_tree->remove(child);
1763 }

◆ remove_child() [3/3]

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

remove a child by name

Definition at line 1766 of file node.hpp.

1767 {
1768 assert_readable_();
1769 id_type child = m_tree->find_child(m_id, key);
1770 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, child != NONE, m_tree, m_id);
1771 m_tree->remove(child);
1772 }

◆ move()

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 1780 of file node.hpp.

1781 {
1782 assert_readable_();
1783 parent.assert_readable_();
1784 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, parent.m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1785 if(parent.m_tree == m_tree)
1786 {
1787 m_tree->move(m_id, parent.m_id, after.m_id);
1788 }
1789 else
1790 {
1791 parent.m_tree->move(m_tree, m_id, parent.m_id, after.m_id);
1792 m_tree = parent.m_tree;
1793 }
1794 }
NodeRef parent() RYML_NOEXCEPT
Forward to Tree::parent().
Definition node.hpp:1422

◆ duplicate()

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 1801 of file node.hpp.

1802 {
1803 assert_readable_();
1804 parent.assert_readable_();
1805 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, parent.m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1806 id_type dup = parent.m_tree->duplicate(m_tree, m_id, parent.m_id, after.m_id);
1807 NodeRef r(parent.m_tree, dup);
1808 return r;
1809 }

◆ duplicate_children()

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

Definition at line 1811 of file node.hpp.

1812 {
1813 assert_readable_();
1814 parent.assert_readable_();
1815 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, parent.m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1816 id_type last_dup = parent.m_tree->duplicate_children(m_tree, m_id, parent.m_id, after.m_id);
1817 NodeRef r(parent.m_tree, last_dup);
1818 return r;
1819 }

◆ begin() [1/2]

iterator c4::yml::NodeRef::begin ( )
inline

get a mutable iterator to the first child.

NOT AVAILABLE for ConstNodeRef.

Definition at line 1834 of file node.hpp.

◆ begin() [2/2]

const_iterator c4::yml::NodeRef::begin ( ) const
inline

get an iterator to the first child

Definition at line 1835 of file node.hpp.

◆ cbegin()

const_iterator c4::yml::NodeRef::cbegin ( ) const
inline

get an iterator to the first child

Definition at line 1836 of file node.hpp.

◆ end() [1/2]

iterator c4::yml::NodeRef::end ( )
inline

get an iterator to after the last child.

NOT AVAILABLE for ConstNodeRef.

Definition at line 1838 of file node.hpp.

◆ end() [2/2]

const_iterator c4::yml::NodeRef::end ( ) const
inline

get an iterator to after the last child

Definition at line 1839 of file node.hpp.

◆ cend()

const_iterator c4::yml::NodeRef::cend ( ) const
inline

get an iterator to after the last child

Definition at line 1840 of file node.hpp.

◆ children() [1/2]

children_view c4::yml::NodeRef::children ( )
inline

get an iterable view over children

Definition at line 1843 of file node.hpp.

Referenced by sample_float_precision().

◆ children() [2/2]

const_children_view c4::yml::NodeRef::children ( ) const
inline

get an iterable view over children

Definition at line 1844 of file node.hpp.

◆ cchildren()

const_children_view c4::yml::NodeRef::cchildren ( ) const
inline

get an iterable view over children

Definition at line 1845 of file node.hpp.

◆ siblings() [1/2]

children_view c4::yml::NodeRef::siblings ( )
inline

Definition at line 1847 of file node.hpp.

1847{ assert_readable_(); return detail::make_siblings_view<children_view>(m_tree, m_id); } /** get an iterable view over all siblings (including the calling node) */

◆ siblings() [2/2]

const_children_view c4::yml::NodeRef::siblings ( ) const
inline

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

Definition at line 1848 of file node.hpp.

1848{ assert_readable_(); return detail::make_siblings_view<const_children_view>(m_tree, m_id); } /** get an iterable view over all siblings (including the calling node) */

◆ csiblings()

const_children_view c4::yml::NodeRef::csiblings ( ) const
inline

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

Definition at line 1849 of file node.hpp.

1849{ assert_readable_(); return detail::make_siblings_view<const_children_view>(m_tree, m_id); } /** get an iterable view over all siblings (including the calling node) */

◆ operator=() [3/7]

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

Definition at line 1865 of file node.hpp.

1865{ create(); m_tree->_p(m_id)->m_type = t; }

◆ operator|=()

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

Definition at line 1868 of file node.hpp.

1868{ create(); m_tree->_add_flags(m_id, t); }

◆ operator=() [4/7]

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

Definition at line 1871 of file node.hpp.

1871{ set_val(v); return *this; }
void set_val(csubstr val)
Definition node.hpp:1251

◆ operator=() [5/7]

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

Definition at line 1875 of file node.hpp.

1875{ csubstr sv; sv.assign<N>(v); set_val(sv); return *this; }
basic_substring< const char > csubstr
an immutable string view
Definition substr.hpp:2356
void assign(C(&s_)[N]) noexcept
Assign from an array.
Definition substr.hpp:300

◆ operator=() [6/7]

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

Definition at line 1878 of file node.hpp.

1878{ set_val(csubstr{}); return *this; }

◆ operator=() [7/7]

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

Definition at line 1882 of file node.hpp.

1882{ set_key(v.k); return *this; }
void set_key(csubstr key)
Definition node.hpp:1248

◆ operator<<() [1/3]

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

Definition at line 1886 of file node.hpp.

1886{ save(v); return *this; }
void save(T const &k)
Definition node.hpp:1337

◆ operator<<() [2/3]

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

Definition at line 1889 of file node.hpp.

1889{ save(v); return *this; }

◆ operator<<() [3/3]

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

Definition at line 1893 of file node.hpp.

1893{ save_key(v.k); return *this; }
void save_key(T const &k)
Definition node.hpp:1354

◆ type()

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

Forward to Tree::type().

Node must be readable.

Definition at line 172 of file node.hpp.

◆ key()

◆ 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 175 of file node.hpp.

Referenced by c4::yml::NodeRef::set_key_tag().

◆ 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 176 of file node.hpp.

Referenced by c4::yml::NodeRef::set_key_ref().

◆ 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 177 of file node.hpp.

Referenced by c4::yml::NodeRef::set_key_anchor().

◆ val()

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

Forward to Tree::val().

Node must be readable.

Definition at line 179 of file node.hpp.

Referenced by c4::yml::NodeRef::set_val(), and c4::yml::NodeRef::set_val().

◆ 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 180 of file node.hpp.

Referenced by c4::yml::NodeRef::set_val_tag().

◆ 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 181 of file node.hpp.

Referenced by c4::yml::NodeRef::set_val_ref().

◆ 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 182 of file node.hpp.

Referenced by c4::yml::NodeRef::set_val_anchor().

◆ keysc()

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

Forward to Tree::keysc().

Node must be readable.

Definition at line 184 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 185 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 187 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 188 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 190 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 191 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 203 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 204 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 205 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 206 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 207 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 208 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 209 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 210 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 211 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 212 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 213 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 214 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 215 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 216 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 217 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 218 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 219 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 220 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 221 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 222 of file node.hpp.

◆ type_has_any()

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

Forward to Tree::type_has_any().

Node must be readable.

Definition at line 234 of file node.hpp.

◆ type_has_all()

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

Forward to Tree::type_has_all().

Node must be readable.

Definition at line 235 of file node.hpp.

◆ type_has_none()

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

Forward to Tree::type_has_none().

Node must be readable.

Definition at line 236 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 238 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 239 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 241 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 242 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 243 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 244 of file node.hpp.

◆ is_flow_ml()

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

Forward to Tree::is_flow_ml1().

Node must be readable.

Definition at line 246 of file node.hpp.

Referenced by is_flow_ml().

◆ is_flow_ml1()

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

Forward to Tree::is_flow_ml1().

Node must be readable.

Definition at line 247 of file node.hpp.

◆ is_flow_mln()

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

Forward to Tree::is_flow_mln().

Node must be readable.

Definition at line 248 of file node.hpp.

◆ is_flow_mlx()

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

Forward to Tree::is_flow_mlx().

Node must be readable.

Definition at line 249 of file node.hpp.

◆ has_flow_space()

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

Forward to Tree::has_flow_space().

Node must be readable.

Definition at line 250 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 252 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 253 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 254 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 255 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 256 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 257 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 258 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 259 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 260 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 261 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 262 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 263 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 264 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 265 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 266 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 278 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 279 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 280 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 282 of file node.hpp.

Referenced by c4::yml::NodeRef::remove_child().

◆ 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 283 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 284 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 285 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 287 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 288 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 289 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 290 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 302 of file node.hpp.

Referenced by c4::yml::NodeRef::remove_child().

◆ 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 303 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 304 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 305 of file node.hpp.

Referenced by deserialize_child(), deserialize_child(), and deserialize_child().

◆ 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 306 of file node.hpp.

◆ depth_asc()

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

Definition at line 308 of file node.hpp.

308{ this_assert_readable_(); return tree_->depth_asc(id_); } /** O(log(num_nodes)). Forward to Tree::depth_asc(). Node must be readable. */
a CRTP base providing read-only methods for ConstNodeRef and NodeRef
Definition node.hpp:153
id_type depth_asc() const RYML_NOEXCEPT
Definition node.hpp:308

◆ 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 309 of file node.hpp.

309{ this_assert_readable_(); return tree_->depth_desc(id_); } /** O(num_nodes). Forward to Tree::depth_desc(). Node must be readable. */
id_type depth_desc() const RYML_NOEXCEPT
O(log(num_nodes)).
Definition node.hpp:309

◆ location()

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

Definition at line 318 of file node.hpp.

319 {
321 return tree_->location(parser, id_);
322 }
Location location(Parser const &parser) const
Definition node.hpp:318

◆ load() [1/2]

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::load ( T * v,
bool check_readable = true ) const
inlineinherited

(1) deserialize the node's contents (val or container) to the given variable, forwarding to the user-overrideable read() function, which can be for ConstNodeRef (see Read from ConstNodeRef) or for tree+id (see Read from Tree).

This method differs from ConstNodeRef::deserialize() in that here the error callback is called if the deserialization failed, or (optionally) the node is not readable.

Definition at line 345 of file node.hpp.

346 {
348 check_val_();
349 else
350 assert_val_(); // assert otherwise
351 // we can call read() directly because we checked everything
352 // (or the caller told us so)
353 // use the adapter ctor to accomodate legacy read() implementations
354 const ReadResult result(read((ConstImpl const&)*this, v), id_);
356 err_visit_(tree_, result.node, "could not deserialize node");
357 }
ReadResult read(ConstNodeRef const &n, T *v)
Definition node.hpp:2074
static void err_visit_(Tree const *tree, id_type id, const char *msg)
Definition node.hpp:615

Referenced by operator>>(), and operator>>().

◆ load() [2/2]

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::load ( Wrapper const & wrapper,
bool check_readable = true ) const
inlineinherited

(2) like (1), but for wrapper tag types such as c4::fmt::base64()

Definition at line 361 of file node.hpp.

362 {
365 check_val_();
366 else
367 assert_val_(); // assert otherwise
368 // we can call read() directly because we checked everything
369 // (or the caller told us so)
370 // use the adapter ctor to accomodate legacy read() implementations
371 const ReadResult result(read((ConstImpl const&)*this, wrapper), id_);
373 err_visit_(tree_, result.node, "could not deserialize node");
374 }

◆ load_key() [1/2]

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::load_key ( T * k,
bool check_readable = true ) const
inlineinherited

(1) deserialize the node's key (necessarily a scalar) to the given variable, forwarding to the user-overrideable read_key() function, which can be for ConstNodeRef (see Read from ConstNodeRef) or for tree+id (see Read from Tree).

This method differs from ConstNodeRef::deserialize_key() in that here the error callback is called if the deserialization failed, or (optionally) the node is not readable.

Definition at line 385 of file node.hpp.

386 {
388 check_key_();
389 else
390 assert_key_(); // assert otherwise
391 // we can call read_key() directly because we checked
392 // everything (or the caller told us so)
393 // use the adapter ctor to accomodate legacy read_key() implementations
394 const ReadResult result(read_key((ConstImpl const&)*this, k), id_);
396 err_visit_(tree_, result.node, "could not deserialize key");
397 }
ReadResult read_key(ConstNodeRef const &n, T *v)
Definition node.hpp:2088

Referenced by operator>>().

◆ load_key() [2/2]

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::load_key ( Wrapper const & wrapper,
bool check_readable = true ) const
inlineinherited

(2) like (1), but for wrapper tag types such as c4::fmt::base64()

Definition at line 401 of file node.hpp.

402 {
405 check_key_();
406 else
407 assert_key_(); // assert otherwise
408 // we can call read_key() directly because we checked
409 // everything (or the caller told us so)
410 // use the adapter ctor to accomodate legacy read_key() implementations
411 const ReadResult result(read_key((ConstImpl const&)*this, wrapper), id_);
413 err_visit_(tree_, result.node, "could not deserialize key");
414 }

◆ deserialize() [1/2]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize ( T * v) const
inlineinherited

(1) deserialize the node's contents (val or container) to the given variable, forwarding to the user-overrideable read() function (see Read from ConstNodeRef).

Returns
a ReadResult with the deserialization status.

Definition at line 428 of file node.hpp.

429 {
430 assert_val_();
431 // use the adapter ctor to accomodate legacy read() implementations
432 return ReadResult(read((ConstImpl const&)*this, v), id_);
433 }

◆ deserialize() [2/2]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize ( Wrapper const & wrapper) const
inlineinherited

(2) like (1), but for wrapper tag types such as c4::fmt::base64()

Definition at line 437 of file node.hpp.

438 {
440 assert_val_();
441 // use the adapter ctor to accomodate legacy read() implementations
442 return ReadResult(read((ConstImpl const&)*this, wrapper), id_);
443 }

◆ deserialize_key() [1/2]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_key ( T * v) const
inlineinherited

(1) deserialize the node's key (necessarily a scalar) to the given variable, forwarding to the user-overrideable read_key() function (see Read from ConstNodeRef).

Returns
a ReadResult with the deserialization status.

Definition at line 451 of file node.hpp.

452 {
453 assert_key_();
454 // use the adapter ctor to accomodate legacy read_key() implementations
455 return ReadResult(read_key((ConstImpl const&)*this, v), id_);
456 }

◆ deserialize_key() [2/2]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_key ( Wrapper const & wrapper) const
inlineinherited

(2) like (1), but for wrapper tag types such as c4::fmt::base64()

Definition at line 460 of file node.hpp.

461 {
463 assert_key_();
464 // use the adapter ctor to accomodate legacy read_key() implementations
465 return ReadResult(read_key((ConstImpl const&)*this, wrapper), id_);
466 }

◆ deserialize_child() [1/6]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_child ( csubstr child_key,
T * v ) const
inlineinherited

(1) find a child by name and deserialize its contents to the given variable (ie call .deserialize() on the child if it exists).

Otherwise, the variable is kept unchanged.

Returns
a ReadResult set with this node's id if no child exists, or the ReadResult from the deserialization.
See also
see also ConstNodeRef::find_child_r()

Definition at line 485 of file node.hpp.

486 {
489 ReadResult r = this_->find_child_r(child_key, &ch);
490 if(r)
491 r = ch.deserialize(v);
492 return r;
493 }
ReadResult deserialize(T *v) const
(1) deserialize the node's contents (val or container) to the given variable, forwarding to the user-...
Definition node.hpp:428

◆ deserialize_child() [2/6]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_child ( csubstr child_key,
T * v,
T const & fallback ) const
inlineinherited

(2) like (1), but assign from fallback if no such child exists.

Definition at line 496 of file node.hpp.

497 {
500 if(this_->find_child_r(child_key, &ch))
501 return ch.deserialize(v);
502 *v = fallback;
503 return ReadResult();
504 }

◆ deserialize_child() [3/6]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_child ( csubstr child_key,
Wrapper const & v ) const
inlineinherited

(3) like (1), but for wrapper tag types such as c4::fmt::base64()

Definition at line 507 of file node.hpp.

508 {
511 ReadResult r = this_->find_child_r(child_key, &ch);
512 if(r)
513 r = ch.deserialize(v);
514 return r;
515 }

◆ deserialize_child() [4/6]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_child ( id_type child_pos,
T * v ) const
inlineinherited

(1) find a child by position and deserialize its contents to the given variable (ie call .deserialize() on the child if it exists).

Otherwise, the variable is kept unchanged.

Returns
a ReadResult set with this node's id if no child exists, or the ReadResult from the deserialization.
See also
see also ConstNodeRef::child_r()

Definition at line 526 of file node.hpp.

527 {
530 ReadResult r = this_->child_r(child_pos, &ch);
531 if(r)
532 r = ch.deserialize(v);
533 return r;
534 }

◆ deserialize_child() [5/6]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_child ( id_type child_pos,
T * v,
T const & fallback ) const
inlineinherited

(2) like (1), but assign from fallback if no such child exists

Definition at line 537 of file node.hpp.

538 {
541 if(this_->child_r(child_pos, &ch))
542 return ch.deserialize(v);
543 *v = fallback;
544 return ReadResult();
545 }

◆ deserialize_child() [6/6]

ReadResult c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::deserialize_child ( id_type child_pos,
Wrapper const & wrapper ) const
inlineinherited

(3) like (1), but for wrapper tag types such as c4::fmt::base64()

Definition at line 549 of file node.hpp.

550 {
553 ReadResult r = this_->child_r(child_pos, &ch);
554 if(r)
556 return r;
557 }

◆ operator>>() [1/3]

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

Definition at line 573 of file node.hpp.

573{ load(&v); return (Impl const&)*this; }
void load(T *v, bool check_readable=true) const
Definition node.hpp:345

◆ operator>>() [2/3]

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

Definition at line 577 of file node.hpp.

577{ load(wrapper); return (Impl const&)*this; }

◆ operator>>() [3/3]

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

Definition at line 581 of file node.hpp.

581{ load_key(&v.k); return (Impl const&)*this; }
void load_key(T *k, bool check_readable=true) const
Definition node.hpp:385

◆ check_val_()

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::check_val_ ( ) const
inlineprotectedinherited

Definition at line 589 of file node.hpp.

590 {
591 if C4_UNLIKELY(!tree_)
592 err_basic_("node not readable");
593 else if C4_UNLIKELY(!(((Impl const* C4_RESTRICT)this)->readable()))
594 err_visit_(tree_, id_, "node not readable");
596 err_visit_(tree_, id_, "node has no contents");
597 }

Referenced by load(), and load().

◆ check_key_()

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::check_key_ ( ) const
inlineprotectedinherited

Definition at line 598 of file node.hpp.

599 {
600 if C4_UNLIKELY(!tree_)
601 err_basic_("node not readable");
602 else if C4_UNLIKELY(!(((Impl const* C4_RESTRICT)this)->readable()))
603 err_visit_(tree_, id_, "node not readable");
605 err_visit_(tree_, id_, "node has no key");
606 }

Referenced by load_key(), and load_key().

◆ err_basic_()

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::err_basic_ ( const char * msg)
inlinestaticprotectedinherited

Definition at line 609 of file node.hpp.

610 {
612 }

Referenced by check_key_(), and check_val_().

◆ err_visit_()

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::err_visit_ ( Tree const * tree,
id_type id,
const char * msg )
inlinestaticprotectedinherited

Definition at line 615 of file node.hpp.

616 {
617 RYML_ERR_VISIT_CB_(tree->m_callbacks, tree, id, msg);
618 }

Referenced by check_key_(), check_val_(), load(), load(), load_key(), and load_key().

◆ assert_val_()

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::assert_val_ ( ) const
inlineprotectednoexceptinherited

Definition at line 624 of file node.hpp.

624{}

Referenced by deserialize(), deserialize(), load(), and load().

◆ assert_key_()

void c4::yml::detail::RoNodeMethods< NodeRef, ConstNodeRef >::assert_key_ ( ) const
inlineprotectednoexceptinherited

Definition at line 625 of file node.hpp.

625{}

Referenced by deserialize_key(), deserialize_key(), load_key(), and load_key().

◆ detail::RoNodeMethods< NodeRef, ConstNodeRef >

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

Definition at line 1098 of file node.hpp.


The documentation for this class was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/latest/src/c4/yml/node.hpp