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
 NodeRef (std::nullptr_t) 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
Treetree () noexcept
Tree const * tree () const noexcept
id_type id () const 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 (NodeType_e style)
void set_key_style (NodeType_e style)
void set_val_style (NodeType_e style)
node_modifiers
void change_type (NodeType t)
void clear ()
void clear_key ()
void clear_val ()
void clear_children ()
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)
 serialize a variable to the arena
template<class T>
size_t set_key_serialized (T const &k)
size_t set_key_serialized (std::nullptr_t)
template<class T>
size_t set_val_serialized (T const &v)
size_t set_val_serialized (std::nullptr_t)
NodeRefoperator<< (csubstr s)
 serialize a variable, then assign the result to the node's val
template<class T>
NodeRefoperator<< (T const &v)
template<class T>
NodeRefoperator<< (Key< const T > const &v)
 serialize a variable, then assign the result to the node's key
template<class T>
NodeRefoperator<< (Key< T > const &v)
 serialize a variable, then assign the result to the node's key
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().
NodeRef find_child (csubstr name) RYML_NOEXCEPT
 Forward to Tree::find_child().
ConstNodeRef find_child (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::find_child().
NodeRef prev_sibling () RYML_NOEXCEPT
 Forward to Tree::prev_sibling().
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().
NodeRef find_sibling (csubstr name) RYML_NOEXCEPT
 Forward to Tree::find_sibling().
ConstNodeRef find_sibling (csubstr name) const RYML_NOEXCEPT
 Forward to Tree::find_sibling().
NodeRef ancestor_doc () RYML_NOEXCEPT
 Forward to Tree::ancestor_doc().
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
node property getters
NodeType type () const RYML_NOEXCEPT
 Forward to Tree::type().
const char * type_str () const RYML_NOEXCEPT
 Forward to Tree::type_str().
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().
bool is_key_anchor () const noexcept
bool is_val_hanchor () const noexcept
bool is_anchor () const noexcept
bool is_anchor_or_ref () const noexcept
style predicates
bool type_has_any (NodeType_e bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_any().
bool type_has_all (NodeType_e bits) const RYML_NOEXCEPT
 Forward to Tree::type_has_all().
bool type_has_none (NodeType_e 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().
bool has_siblings () const RYML_NOEXCEPT
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
ConstNodeRef const & operator>> (T &v) const
 deserialize the node's val to the given variable, forwarding to the user-overrideable read() function.
ConstNodeRef const & operator>> (T const &wrapper) const
ConstNodeRef const & operator>> (Key< T > v) const
 deserialize the node's key to the given variable, forwarding to the user-overrideable read() function; use key() to disambiguate; for example: node >> ryml::key(var)
bool get_if (csubstr name, T *var) const
 look for a child by name, if it exists assign to var.
bool get_if (csubstr name, T *var, T const &fallback) const
 look for a child by name, if it exists assign to var, otherwise default to fallback.

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:818
bool invalid() const noexcept
true if the object is not referring to any existing or seed node.
Definition node.hpp:851
bool readable() const noexcept
true if the object is not invalid and not in seed state.
Definition node.hpp:855
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 786 of file node.hpp.

Member Typedef Documentation

◆ tree_type

Definition at line 790 of file node.hpp.

◆ base_type

Definition at line 791 of file node.hpp.

◆ iterator

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

Definition at line 1511 of file node.hpp.

◆ const_iterator

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

Definition at line 1512 of file node.hpp.

◆ children_view

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

Definition at line 1513 of file node.hpp.

◆ const_children_view

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

Definition at line 1514 of file node.hpp.

Constructor & Destructor Documentation

◆ NodeRef() [1/9]

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

Definition at line 818 of file node.hpp.

818: m_tree(nullptr), m_id(NONE), m_seed() { _clear_seed(); }
@ NONE
an index to none
Definition common.hpp:312

◆ NodeRef() [2/9]

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

Definition at line 819 of file node.hpp.

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

◆ NodeRef() [3/9]

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

Definition at line 820 of file node.hpp.

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

◆ NodeRef() [4/9]

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

Definition at line 821 of file node.hpp.

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

◆ NodeRef() [5/9]

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

Definition at line 822 of file node.hpp.

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

◆ NodeRef() [6/9]

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

Definition at line 823 of file node.hpp.

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

◆ NodeRef() [7/9]

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

Definition at line 824 of file node.hpp.

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

◆ NodeRef() [8/9]

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

◆ NodeRef() [9/9]

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

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

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

◆ is_seed()

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

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

See also
the doc for NodeRef

Definition at line 853 of file node.hpp.

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

◆ readable()

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

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

See also
the doc for NodeRef

Definition at line 855 of file node.hpp.

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

◆ operator==() [1/2]

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

Definition at line 884 of file node.hpp.

885 {
886 if(m_tree == that.m_tree && m_id == that.m_id)
887 {
888 bool seed = is_seed();
889 if(seed == that.is_seed())
890 {
891 if(seed)
892 {
893 return (m_seed.len == that.m_seed.len)
894 && (m_seed.str == that.m_seed.str
895 || m_seed == that.m_seed); // do strcmp only in the last resort
896 }
897 return true;
898 }
899 }
900 return false;
901 }
bool is_seed() const noexcept
true if the object is not invalid and in seed state.
Definition node.hpp:853

◆ operator!=() [1/2]

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

Definition at line 902 of file node.hpp.

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

◆ operator==() [2/2]

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

Definition at line 904 of file node.hpp.

904{ 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 905 of file node.hpp.

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

◆ tree() [1/2]

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

Definition at line 914 of file node.hpp.

914{ return m_tree; }

◆ tree() [2/2]

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

Definition at line 915 of file node.hpp.

915{ return m_tree; }

◆ id()

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

Definition at line 917 of file node.hpp.

917{ return m_id; }

◆ get() [1/2]

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

Forward to Tree::type().

Node must be readable.

Definition at line 919 of file node.hpp.

◆ get() [2/2]

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

Forward to Tree::type().

Node must be readable.

Definition at line 920 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 930 of file node.hpp.

931 {
932 _RYML_ASSERT_BASIC(m_tree != nullptr);
933 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, m_id != NONE && m_id < m_tree->capacity(), m_tree, m_id);
934 if(m_seed.str) // we have a seed key: use it to create the new map child
935 {
936 m_id = m_tree->append_child(m_id);
937 m_tree->set_key(m_id, m_seed);
938 m_seed.str = nullptr;
939 m_seed.len = (size_t)NONE;
940 }
941 else if(m_seed.len != (size_t)NONE) // we have a seed index: create a seq child at that position
942 {
943 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, (size_t)m_tree->num_children(m_id) == m_seed.len, m_tree, m_id);
944 m_id = m_tree->append_child(m_id);
945 m_seed.str = nullptr;
946 m_seed.len = (size_t)NONE;
947 }
948 }

◆ set_stream()

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

Definition at line 950 of file node.hpp.

950{ 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:930

◆ set_doc()

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

Definition at line 951 of file node.hpp.

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

◆ set_key() [1/2]

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

Definition at line 953 of file node.hpp.

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

◆ set_key() [2/2]

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

Definition at line 954 of file node.hpp.

954{ 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 956 of file node.hpp.

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

◆ set_val() [2/2]

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

Definition at line 957 of file node.hpp.

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

◆ set_seq() [1/2]

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

Definition at line 959 of file node.hpp.

959{ create(); m_tree->set_seq(m_id); }

◆ set_seq() [2/2]

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

Definition at line 960 of file node.hpp.

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

◆ set_map() [1/2]

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

Definition at line 962 of file node.hpp.

962{ create(); m_tree->set_map(m_id); }

◆ set_map() [2/2]

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

Definition at line 963 of file node.hpp.

963{ 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 965 of file node.hpp.

965{ 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 966 of file node.hpp.

966{ 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 967 of file node.hpp.

967{ 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 968 of file node.hpp.

968{ 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 969 of file node.hpp.

969{ 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 970 of file node.hpp.

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

◆ set_container_style()

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

Definition at line 972 of file node.hpp.

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

◆ set_key_style()

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

Definition at line 973 of file node.hpp.

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

◆ set_val_style()

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

Definition at line 974 of file node.hpp.

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

◆ change_type()

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

Definition at line 983 of file node.hpp.

983{ assert_readable_(); m_tree->change_type(m_id, t); }

◆ clear()

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

Definition at line 985 of file node.hpp.

986 {
987 assert_readable_();
988 m_tree->remove_children(m_id);
989 m_tree->_clear(m_id);
990 }

◆ clear_key()

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

Definition at line 992 of file node.hpp.

993 {
994 assert_readable_();
995 m_tree->_clear_key(m_id);
996 }

◆ clear_val()

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

Definition at line 998 of file node.hpp.

999 {
1000 assert_readable_();
1001 m_tree->_clear_val(m_id);
1002 }

◆ clear_children()

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

Definition at line 1004 of file node.hpp.

1005 {
1006 assert_readable_();
1007 m_tree->remove_children(m_id);
1008 }

◆ clear_style()

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

Definition at line 1010 of file node.hpp.

1011 {
1012 assert_readable_();
1013 m_tree->clear_style(m_id, recurse);
1014 }

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

1020 {
1021 assert_readable_();
1022 m_tree->set_style_conditionally(m_id, type_mask, rem_style_flags, add_style_flags, recurse);
1023 }

◆ to_arena()

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

serialize a variable to the arena

Definition at line 1034 of file node.hpp.

1035 {
1036 _RYML_ASSERT_BASIC(m_tree); // no need for valid or readable
1037 return m_tree->to_arena(s);
1038 }

◆ set_key_serialized() [1/2]

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

Definition at line 1041 of file node.hpp.

1042 {
1043 create();
1044 csubstr s = m_tree->to_arena(k);
1045 m_tree->set_key(m_id, s);
1046 return s.len;
1047 }
basic_substring< const char > csubstr
an immutable string view
Definition substr.hpp:2357
size_t len
the length of the substring
Definition substr.hpp:218

◆ set_key_serialized() [2/2]

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

Definition at line 1048 of file node.hpp.

1049 {
1050 create();
1051 m_tree->set_key(m_id, csubstr{});
1052 return 0;
1053 }

◆ set_val_serialized() [1/2]

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

Definition at line 1056 of file node.hpp.

1057 {
1058 create();
1059 csubstr s = m_tree->to_arena(v);
1060 m_tree->set_val(m_id, s);
1061 return s.len;
1062 }

◆ set_val_serialized() [2/2]

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

Definition at line 1063 of file node.hpp.

1064 {
1065 create();
1066 m_tree->set_val(m_id, csubstr{});
1067 return 0;
1068 }

◆ operator<<() [1/4]

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

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

Definition at line 1071 of file node.hpp.

1072 {
1073 // this overload is needed to prevent ambiguity (there's also
1074 // operator<< for writing a substr to a stream)
1075 create();
1076 write(this, s);
1077 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, val() == s, m_tree, m_id);
1078 return *this;
1079 }
void write(NodeRef *n, T const &v)
Definition node.hpp:1733

◆ operator<<() [2/4]

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

Definition at line 1082 of file node.hpp.

1083 {
1084 create();
1085 write(this, v);
1086 return *this;
1087 }

◆ operator<<() [3/4]

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

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

Definition at line 1091 of file node.hpp.

1092 {
1093 create();
1094 set_key_serialized(v.k);
1095 return *this;
1096 }
size_t set_key_serialized(T const &k)
Definition node.hpp:1041

◆ operator<<() [4/4]

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

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

Definition at line 1100 of file node.hpp.

1101 {
1102 create();
1103 set_key_serialized(v.k);
1104 return *this;
1105 }

◆ parent() [1/2]

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

Forward to Tree::parent().

Node must be readable.

Definition at line 1117 of file node.hpp.

◆ parent() [2/2]

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

Forward to Tree::parent().

Node must be readable.

Definition at line 1118 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 1120 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 1121 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 1123 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 1124 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 1126 of file node.hpp.

◆ child() [2/2]

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

Forward to Tree::child().

Node must be readable.

Definition at line 1127 of file node.hpp.

◆ find_child() [1/2]

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

Forward to Tree::find_child().

Node must be readable.

Definition at line 1129 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 1130 of file node.hpp.

◆ prev_sibling() [1/2]

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

Forward to Tree::prev_sibling().

Node must be readable.

Definition at line 1132 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 1133 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 1135 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 1136 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 1138 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 1139 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 1141 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 1142 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 1144 of file node.hpp.

◆ sibling() [2/2]

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

Forward to Tree::sibling().

Node must be readable.

Definition at line 1145 of file node.hpp.

◆ find_sibling() [1/2]

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

Forward to Tree::find_sibling().

Node must be readable.

Definition at line 1147 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 1148 of file node.hpp.

◆ ancestor_doc() [1/2]

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

Forward to Tree::ancestor_doc().

Node must be readable.

Definition at line 1150 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 1151 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 1153 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 1154 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 1182 of file node.hpp.

1183 {
1184 assert_readable_();
1185 id_type ch = m_tree->find_child(m_id, key);
1186 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, key);
1187 }
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:305

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

1208 {
1209 assert_readable_();
1210 id_type ch = m_tree->child(m_id, pos);
1211 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, pos);
1212 }

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

1224 {
1225 assert_readable_();
1226 id_type ch = m_tree->find_child(m_id, key);
1227 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1228 return {m_tree, ch};
1229 }

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

1241 {
1242 assert_readable_();
1243 id_type ch = m_tree->child(m_id, pos);
1244 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1245 return {m_tree, ch};
1246 }

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

1288 {
1289 _RYML_CHECK_BASIC(m_tree != nullptr);
1290 _RYML_CHECK_VISIT_(m_tree->m_callbacks, (m_id >= 0 && m_id < m_tree->capacity()), m_tree, m_id);
1291 _RYML_CHECK_VISIT_(m_tree->m_callbacks, readable(), m_tree, m_id);
1292 _RYML_CHECK_VISIT_(m_tree->m_callbacks, m_tree->is_map(m_id), m_tree, m_id);
1293 id_type ch = m_tree->find_child(m_id, key);
1294 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, key);
1295 }

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

1323 {
1324 _RYML_CHECK_BASIC(m_tree != nullptr);
1325 const id_type cap = m_tree->capacity();
1326 _RYML_CHECK_VISIT_(m_tree->m_callbacks, (m_id >= 0 && m_id < cap), m_tree, m_id);
1327 _RYML_CHECK_VISIT_(m_tree->m_callbacks, (pos >= 0 && pos < cap), m_tree, m_id);
1328 _RYML_CHECK_VISIT_(m_tree->m_callbacks, readable(), m_tree, m_id);
1329 _RYML_CHECK_VISIT_(m_tree->m_callbacks, m_tree->is_container(m_id), m_tree, m_id);
1330 id_type ch = m_tree->child(m_id, pos);
1331 return ch != NONE ? NodeRef(m_tree, ch) : NodeRef(m_tree, m_id, pos);
1332 }

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

1344 {
1345 _RYML_CHECK_BASIC(m_tree != nullptr);
1346 _RYML_CHECK_VISIT_(m_tree->m_callbacks, (m_id >= 0 && m_id < m_tree->capacity()), m_tree, m_id);
1347 _RYML_CHECK_VISIT_(m_tree->m_callbacks, readable(), m_tree, m_id);
1348 _RYML_CHECK_VISIT_(m_tree->m_callbacks, m_tree->is_map(m_id), m_tree, m_id);
1349 id_type ch = m_tree->find_child(m_id, key);
1350 _RYML_CHECK_VISIT_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1351 return {m_tree, ch};
1352 }

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

1364 {
1365 _RYML_CHECK_BASIC(m_tree != nullptr);
1366 const id_type cap = m_tree->capacity();
1367 _RYML_CHECK_VISIT_(m_tree->m_callbacks, (m_id >= 0 && m_id < cap), m_tree, m_id);
1368 _RYML_CHECK_VISIT_(m_tree->m_callbacks, (pos >= 0 && pos < cap), m_tree, m_id);
1369 _RYML_CHECK_VISIT_(m_tree->m_callbacks, readable(), m_tree, m_id);
1370 _RYML_CHECK_VISIT_(m_tree->m_callbacks, m_tree->is_container(m_id), m_tree, m_id);
1371 const id_type ch = m_tree->child(m_id, pos);
1372 _RYML_CHECK_VISIT_(m_tree->m_callbacks, ch != NONE, m_tree, m_id);
1373 return {m_tree, ch};
1374 }

◆ insert_child()

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

Definition at line 1383 of file node.hpp.

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

◆ prepend_child()

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

Definition at line 1391 of file node.hpp.

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

◆ append_child()

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

Definition at line 1398 of file node.hpp.

1399 {
1400 assert_readable_();
1401 NodeRef r(m_tree, m_tree->append_child(m_id));
1402 return r;
1403 }

◆ insert_sibling()

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

Definition at line 1405 of file node.hpp.

1406 {
1407 assert_readable_();
1408 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1409 NodeRef r(m_tree, m_tree->insert_sibling(m_id, after.m_id));
1410 return r;
1411 }

◆ prepend_sibling()

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

Definition at line 1413 of file node.hpp.

1414 {
1415 assert_readable_();
1416 NodeRef r(m_tree, m_tree->prepend_sibling(m_id));
1417 return r;
1418 }

◆ append_sibling()

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

Definition at line 1420 of file node.hpp.

1421 {
1422 assert_readable_();
1423 NodeRef r(m_tree, m_tree->append_sibling(m_id));
1424 return r;
1425 }

◆ remove_child() [1/3]

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

Definition at line 1429 of file node.hpp.

1430 {
1431 assert_readable_();
1432 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, has_child(child), m_tree, m_id);
1433 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, child.parent().id() == id(), m_tree, m_id);
1434 m_tree->remove(child.id());
1435 child = NodeRef{};
1436 }
NodeRef child(id_type pos) RYML_NOEXCEPT
Forward to Tree::child().
Definition node.hpp:1126
bool has_child(ConstNodeRef const &n) const RYML_NOEXCEPT
Definition node.hpp:305

◆ remove_child() [2/3]

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

remove the nth child of this node

Definition at line 1439 of file node.hpp.

1440 {
1441 assert_readable_();
1442 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, pos >= 0 && pos < num_children(), m_tree, m_id);
1443 id_type child = m_tree->child(m_id, pos);
1444 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, child != NONE, m_tree, m_id);
1445 m_tree->remove(child);
1446 }

◆ remove_child() [3/3]

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

remove a child by name

Definition at line 1449 of file node.hpp.

1450 {
1451 assert_readable_();
1452 id_type child = m_tree->find_child(m_id, key);
1453 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, child != NONE, m_tree, m_id);
1454 m_tree->remove(child);
1455 }

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

1464 {
1465 assert_readable_();
1466 parent.assert_readable_();
1467 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, parent.m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1468 if(parent.m_tree == m_tree)
1469 {
1470 m_tree->move(m_id, parent.m_id, after.m_id);
1471 }
1472 else
1473 {
1474 parent.m_tree->move(m_tree, m_id, parent.m_id, after.m_id);
1475 m_tree = parent.m_tree;
1476 }
1477 }
NodeRef parent() RYML_NOEXCEPT
Forward to Tree::parent().
Definition node.hpp:1117

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

1485 {
1486 assert_readable_();
1487 parent.assert_readable_();
1488 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, parent.m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1489 id_type dup = parent.m_tree->duplicate(m_tree, m_id, parent.m_id, after.m_id);
1490 NodeRef r(parent.m_tree, dup);
1491 return r;
1492 }

◆ duplicate_children()

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

Definition at line 1494 of file node.hpp.

1495 {
1496 assert_readable_();
1497 parent.assert_readable_();
1498 _RYML_ASSERT_VISIT_(m_tree->m_callbacks, parent.m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
1499 id_type last_dup = parent.m_tree->duplicate_children(m_tree, m_id, parent.m_id, after.m_id);
1500 NodeRef r(parent.m_tree, last_dup);
1501 return r;
1502 }

◆ begin() [1/2]

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

get a mutable iterator to the first child.

NOT AVAILABLE for ConstNodeRef.

Definition at line 1517 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 1518 of file node.hpp.

◆ cbegin()

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

get an iterator to the first child

Definition at line 1519 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 1521 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 1522 of file node.hpp.

◆ cend()

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

get an iterator to after the last child

Definition at line 1523 of file node.hpp.

◆ children() [1/2]

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

get an iterable view over children

Definition at line 1526 of file node.hpp.

◆ children() [2/2]

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

get an iterable view over children

Definition at line 1527 of file node.hpp.

◆ cchildren()

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

get an iterable view over children

Definition at line 1528 of file node.hpp.

◆ siblings() [1/2]

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

Definition at line 1530 of file node.hpp.

1530{ 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 1531 of file node.hpp.

1531{ 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 1532 of file node.hpp.

1532{ 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) */

◆ type()

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

Forward to Tree::type().

Node must be readable.

Definition at line 194 of file node.hpp.

◆ type_str()

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

Forward to Tree::type_str().

Node must be readable.

Definition at line 195 of file node.hpp.

◆ key()

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

Forward to Tree::key().

Node must be readable.

Definition at line 197 of file node.hpp.

◆ key_tag()

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

Forward to Tree::key_tag().

Node must be readable.

Definition at line 198 of file node.hpp.

◆ key_ref()

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

Forward to Tree::key_ref().

Node must be readable.

Definition at line 199 of file node.hpp.

◆ key_anchor()

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

Forward to Tree::key_anchor().

Node must be readable.

Definition at line 200 of file node.hpp.

◆ val()

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

Forward to Tree::val().

Node must be readable.

Definition at line 202 of file node.hpp.

◆ val_tag()

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

Forward to Tree::val_tag().

Node must be readable.

Definition at line 203 of file node.hpp.

◆ val_ref()

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

Forward to Tree::val_ref().

Node must be readable.

Definition at line 204 of file node.hpp.

◆ val_anchor()

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

Forward to Tree::val_anchor().

Node must be readable.

Definition at line 205 of file node.hpp.

◆ keysc()

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

Forward to Tree::keysc().

Node must be readable.

Definition at line 207 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 208 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 210 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 211 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 213 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 214 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 223 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 224 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 225 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 226 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 227 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 228 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 229 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 230 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 231 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 232 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 233 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 234 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 235 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 236 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 237 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 238 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 239 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 240 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 241 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 242 of file node.hpp.

◆ is_key_anchor()

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

Definition at line 244 of file node.hpp.

a CRTP base providing read-only methods for ConstNodeRef and NodeRef
Definition node.hpp:178
bool has_key_anchor() const RYML_NOEXCEPT
Forward to Tree::has_key_anchor().
Definition node.hpp:235

◆ is_val_hanchor()

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

Definition at line 245 of file node.hpp.

bool has_val_anchor() const RYML_NOEXCEPT
Forward to Tree::has_val_anchor().
Definition node.hpp:236

◆ is_anchor()

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

Definition at line 246 of file node.hpp.

246{ assert_readable__(); return tree_->has_anchor(id_); }
bool has_anchor() const RYML_NOEXCEPT
Forward to Tree::has_anchor().
Definition node.hpp:237

◆ is_anchor_or_ref()

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

Definition at line 247 of file node.hpp.

bool is_anchor_or_ref() const noexcept
Definition node.hpp:247

◆ type_has_any()

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

Forward to Tree::type_has_any().

Node must be readable.

Definition at line 258 of file node.hpp.

◆ type_has_all()

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

Forward to Tree::type_has_all().

Node must be readable.

Definition at line 259 of file node.hpp.

◆ type_has_none()

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

Forward to Tree::type_has_none().

Node must be readable.

Definition at line 260 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 262 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 263 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 265 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 266 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 267 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 268 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 270 of file node.hpp.

◆ 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 271 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 272 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 273 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 274 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 276 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 277 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 278 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 279 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 280 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 281 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 282 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 283 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 284 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 285 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 286 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 287 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 288 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 289 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 290 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 301 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 302 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 303 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 305 of file node.hpp.

◆ has_child() [2/3]

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

Forward to Tree::has_child().

Node must be readable.

Definition at line 306 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 307 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 308 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 310 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 311 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 312 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 313 of file node.hpp.

◆ has_siblings()

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

Definition at line 315 of file node.hpp.

bool has_siblings() const RYML_NOEXCEPT
Definition node.hpp:315

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

◆ num_siblings()

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

O(num_children).

Forward to Tree::num_siblings().

Definition at line 327 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 328 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 329 of file node.hpp.

◆ sibling_pos()

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

O(num_siblings).

Forward to Tree::sibling_pos().

Definition at line 330 of file node.hpp.

◆ depth_asc()

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

Definition at line 332 of file node.hpp.

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

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

333{ 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:333

◆ location()

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

Definition at line 342 of file node.hpp.

343 {
345 return tree_->location(parser, id_);
346 }
Location location(Parser const &parser) const
Definition node.hpp:342

◆ operator>>() [1/3]

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

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

Definition at line 358 of file node.hpp.

359 {
361 if( ! read((ConstImpl const&)*this, &v))
362 _RYML_ERR_VISIT_(tree_->m_callbacks, tree_, id_, "could not deserialize value");
363 return *((ConstImpl const*)this);
364 }
bool read(ConstNodeRef const &n, T *v)
Definition node.hpp:1739

◆ operator>>() [2/3]

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

Definition at line 366 of file node.hpp.

367 {
369 if( ! read((ConstImpl const&)*this, wrapper))
370 _RYML_ERR_VISIT_(tree_->m_callbacks, tree_, id_, "could not deserialize value");
371 return *((ConstImpl const*)this);
372 }

◆ operator>>() [3/3]

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

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

Definition at line 378 of file node.hpp.

379 {
381 if( ! readkey((ConstImpl const&)*this, &v.k))
382 _RYML_ERR_VISIT_(tree_->m_callbacks, tree_, id_, "could not deserialize key");
383 return *((ConstImpl const*)this);
384 }
bool readkey(ConstNodeRef const &n, T *v)
Definition node.hpp:1761

◆ get_if() [1/2]

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

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

return true if the child existed.

Definition at line 389 of file node.hpp.

390 {
392 ConstImpl ch = ((ConstImpl const*)this)->find_child(name);
393 if(!ch.readable())
394 return false;
395 ch >> *var;
396 return true;
397 }

◆ get_if() [2/2]

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

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

return true if the child existed.

Definition at line 403 of file node.hpp.

404 {
406 ConstImpl ch = ((ConstImpl const*)this)->find_child(name);
407 if(ch.readable())
408 {
409 ch >> *var;
410 return true;
411 }
412 else
413 {
414 *var = fallback;
415 return false;
416 }
417 }

◆ detail::RoNodeMethods< NodeRef, ConstNodeRef >

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

Definition at line 810 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