1#ifndef C4_YML_NODE_HPP_
2#define C4_YML_NODE_HPP_
6#ifndef C4_YML_TREE_HPP_
10C4_SUPPRESS_WARNING_PUSH
11C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wtype-limits")
12C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wold-style-cast")
13C4_SUPPRESS_WARNING_GCC(
"-Wuseless-cast")
14C4_SUPPRESS_WARNING_CLANG(
"-Wnull-dereference")
15#if defined(__GNUC__) && __GNUC__ >= 6
16C4_SUPPRESS_WARNING_GCC(
"-Wnull-dereference")
18C4_SUPPRESS_WARNING_MSVC(4251)
19C4_SUPPRESS_WARNING_MSVC(4296)
20C4_SUPPRESS_WARNING_MSVC(4996)
32template<
class T> ReadResult
read(ConstNodeRef
const& C4_RESTRICT n, T *v);
33template<
class T> ReadResult
read_key(ConstNodeRef
const& C4_RESTRICT n, T *v);
34template<
class T>
void write(NodeRef *n, T
const& v);
35template<
class T>
void write(NodeRef &n, T
const& v);
36template<
class T>
void write_key(NodeRef *n, T
const& v);
37template<
class T>
void write_key(NodeRef &n, T
const& v);
42template<
class NodeRefType>
45 using value_type = NodeRefType;
46 using tree_type =
typename NodeRefType::tree_type;
47 tree_type * C4_RESTRICT m_tree;
49 child_iterator(tree_type * t, id_type
id) noexcept : m_tree(t), m_child_id(
id) {}
50 child_iterator& operator++ ()
RYML_NOEXCEPT { RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, m_child_id != NONE, m_tree, NONE); m_child_id = m_tree->next_sibling(m_child_id);
return *
this; }
51 NodeRefType operator* () const
RYML_NOEXCEPT {
return NodeRefType(m_tree, m_child_id); }
52 bool operator!= (child_iterator that)
const RYML_NOEXCEPT { RYML_ASSERT_VISIT_(m_tree == that.m_tree, m_tree, NONE);
return m_child_id != that.m_child_id; }
55template<
class NodeRefType>
58 using iterator = child_iterator<NodeRefType>;
59 using tree_type =
typename NodeRefType::tree_type;
62 children_view(tree_type *t, id_type
b_, id_type e_) noexcept : tree(t), b(
b_), e(e_) {}
63 C4_ALWAYS_INLINE iterator begin() const noexcept {
return {tree, b}; }
64 C4_ALWAYS_INLINE iterator end () const noexcept {
return {tree, e}; }
67template<
class ViewType,
class TreeType>
68static ViewType make_children_view(TreeType *C4_RESTRICT tree, id_type
id)
RYML_NOEXCEPT
70 return ViewType(tree, tree->get(
id)->m_first_child, NONE);
73template<
class ViewType,
class TreeType>
74static ViewType make_siblings_view(TreeType *C4_RESTRICT tree, id_type
id)
RYML_NOEXCEPT
76 NodeData
const *nd = tree->get(
id);
77 id_type first = (nd->m_parent !=
NONE) ? tree->get(nd->m_parent)->m_first_child :
NONE;
78 return ViewType(tree, first, NONE);
83template<
class NodeRefType,
class Visitor>
84RYML_DEPRECATED(
"") bool _visit(NodeRefType &node, Visitor fn, id_type indentation_level,
bool skip_root=false)
87 if( ! (node.is_root() && skip_root))
89 if(fn(node, indentation_level))
93 if(node.has_children())
95 for(auto ch : node.children())
97 if(_visit(ch, fn, indentation_level + increment, false))
106template<
class NodeRefType,
class Visitor>
107RYML_DEPRECATED(
"") bool _visit_stacked(NodeRefType &node, Visitor fn, id_type indentation_level,
bool skip_root=false)
110 if( ! (node.is_root() && skip_root))
112 if(fn(node, indentation_level))
118 if(node.has_children())
120 fn.push(node, indentation_level);
121 for(auto ch : node.children())
123 if(_visit_stacked(ch, fn, indentation_level + increment, false))
125 fn.pop(node, indentation_level);
129 fn.pop(node, indentation_level);
151template<
class Impl,
class ConstImpl>
156 #define mtree_ ((Impl const* C4_RESTRICT)this)->m_tree
157 #define tree_ ((ConstImpl const* C4_RESTRICT)this)->m_tree
158 #define id_ ((ConstImpl const* C4_RESTRICT)this)->m_id
159 #define this_ ((Impl const* C4_RESTRICT)this)
160 #define this_assert_readable_() ((Impl const* C4_RESTRICT)this)->assert_readable_()
161 C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH(
"-Wcast-align")
190 C4_ALWAYS_INLINE
bool is_key_unfiltered() const noexcept { this_assert_readable_();
return tree_->is_key_unfiltered(id_); }
191 C4_ALWAYS_INLINE
bool is_val_unfiltered() const noexcept { this_assert_readable_();
return tree_->is_val_unfiltered(id_); }
203 C4_ALWAYS_INLINE
bool empty() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->empty(id_); }
205 C4_ALWAYS_INLINE
bool is_doc() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->is_doc(id_); }
207 C4_ALWAYS_INLINE
bool is_map() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->is_map(id_); }
208 C4_ALWAYS_INLINE
bool is_seq() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->is_seq(id_); }
211 C4_ALWAYS_INLINE
bool is_val() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->is_val(id_); }
220 C4_ALWAYS_INLINE
bool is_ref() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->is_ref(id_); }
245 RYML_DEPRECATED(
"use one of .is_flow_ml{1,x,n}()")
280 C4_ALWAYS_INLINE
bool is_ancestor(ConstImpl
const& ancestor)
const RYML_NOEXCEPT { this_assert_readable_();
return tree_->is_ancestor(id_, ancestor.m_id); }
282 C4_ALWAYS_INLINE
bool has_child(ConstImpl
const& n)
const RYML_NOEXCEPT { this_assert_readable_();
return n.readable() ? tree_->has_child(id_, n.m_id) :
false; }
287 C4_ALWAYS_INLINE
bool has_sibling(ConstImpl
const& n)
const RYML_NOEXCEPT { this_assert_readable_();
return n.readable() ? tree_->has_sibling(id_, n.m_id) :
false; }
305 C4_ALWAYS_INLINE
id_type child_pos(ConstImpl
const& n)
const RYML_NOEXCEPT { this_assert_readable_(); RYML_ASSERT_VISIT_CB_(tree_->m_callbacks, n.readable(), n.tree(), n.id());
return tree_->child_pos(id_, n.m_id); }
306 C4_ALWAYS_INLINE
id_type sibling_pos(ConstImpl
const& n)
const RYML_NOEXCEPT { this_assert_readable_(); RYML_ASSERT_VISIT_CB_(tree_->callbacks(), n.readable(), n.tree(), n.id());
return tree_->child_pos(tree_->parent(id_), n.m_id); }
320 this_assert_readable_();
321 return tree_->location(parser, id_);
345 void load(T *v,
bool check_readable=
true)
const
355 if C4_UNLIKELY(!result)
360 template<
class Wrapper>
361 void load(Wrapper
const& wrapper,
bool check_readable=
true)
const
363 RYML_CHECK_TYPE_IS_WRAPPER_LIKE_(Wrapper);
371 const ReadResult result(
read((ConstImpl
const&)*
this, wrapper), id_);
372 if C4_UNLIKELY(!result)
385 void load_key(T *k,
bool check_readable=
true)
const
395 if C4_UNLIKELY(!result)
400 template<
class Wrapper>
401 void load_key(Wrapper
const& wrapper,
bool check_readable=
true)
const
403 RYML_CHECK_TYPE_IS_WRAPPER_LIKE_(Wrapper);
412 if C4_UNLIKELY(!result)
436 template<
class Wrapper>
439 RYML_CHECK_TYPE_IS_WRAPPER_LIKE_(Wrapper);
459 template<
class Wrapper>
462 RYML_CHECK_TYPE_IS_WRAPPER_LIKE_(Wrapper);
487 this_assert_readable_();
489 ReadResult r = this_->find_child_r(child_key, &ch);
491 r = ch.deserialize(v);
498 this_assert_readable_();
500 if(this_->find_child_r(child_key, &ch))
501 return ch.deserialize(v);
506 template<
class Wrapper>
509 this_assert_readable_();
511 ReadResult r = this_->find_child_r(child_key, &ch);
513 r = ch.deserialize(v);
528 this_assert_readable_();
532 r = ch.deserialize(v);
539 this_assert_readable_();
542 return ch.deserialize(v);
548 template<
class Wrapper>
551 this_assert_readable_();
555 r = ch.deserialize(wrapper);
563 C4_SUPPRESS_WARNING_PUSH
564 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated")
565 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated-declarations")
566 C4_SUPPRESS_WARNING_MSVC(4996)
572 RYML_LEGACY_OPERATOR(
"use .load()")
573 Impl const& operator>> (T &v)
const {
load(&v);
return (Impl
const&)*
this; }
576 RYML_LEGACY_OPERATOR(
"use .load()")
577 Impl const& operator>> (T const& wrapper)
const {
load(wrapper);
return (Impl
const&)*
this; }
580 RYML_LEGACY_OPERATOR(
"use .load_key()")
581 Impl const& operator>> (Key<T> const& v)
const {
load_key(&v.k);
return (Impl
const&)*
this; }
585 C4_SUPPRESS_WARNING_POP
591 if C4_UNLIKELY(!tree_)
593 else if C4_UNLIKELY(!(((Impl
const* C4_RESTRICT)
this)->readable()))
595 else if C4_UNLIKELY(!(tree_->type(id_) & (
VAL|
MAP|
SEQ)))
596 err_visit_(tree_, id_,
"node has no contents");
600 if C4_UNLIKELY(!tree_)
602 else if C4_UNLIKELY(!(((Impl
const* C4_RESTRICT)
this)->readable()))
604 else if C4_UNLIKELY(!(tree_->type(id_) &
KEY))
608 C4_NORETURN C4_NO_INLINE C4_COLD
611 RYML_ERR_BASIC_(msg);
614 C4_NORETURN C4_NO_INLINE C4_COLD
617 RYML_ERR_VISIT_CB_(tree->
m_callbacks, tree,
id, msg);
621 void assert_val_()
const { check_val_(); }
622 void assert_key_()
const { check_key_(); }
635 C4_SUPPRESS_WARNING_PUSH
636 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated")
637 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated-declarations")
638 C4_SUPPRESS_WARNING_MSVC(4996)
639 RYML_DEPRECATED(
"use .type().type_str(buf)") const
char* type_str() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->type_str(id_); }
640 RYML_DEPRECATED(
"use has_other_siblings()") bool has_siblings() const
RYML_NOEXCEPT { this_assert_readable_();
return tree_->has_siblings(id_); }
641 RYML_DEPRECATED(
"use has_key_anchor()") bool is_key_anchor() const noexcept { this_assert_readable_();
return tree_->has_key_anchor(id_); }
642 RYML_DEPRECATED(
"use has_val_anchor()") bool is_val_hanchor() const noexcept { this_assert_readable_();
return tree_->has_val_anchor(id_); }
643 RYML_DEPRECATED(
"use has_anchor()") bool is_anchor() const noexcept { this_assert_readable_();
return tree_->has_anchor(id_); }
644 RYML_DEPRECATED(
"use has_anchor() || is_ref()") bool is_anchor_or_ref() const noexcept { this_assert_readable_();
return tree_->is_anchor_or_ref(id_); }
646 RYML_DEPRECATED(
"use .deserialize_child()") bool get_if(csubstr name, T *var)
const
648 this_assert_readable_();
649 ConstImpl ch = ((ConstImpl
const*)
this)->find_child(name);
658 RYML_DEPRECATED(
"use .deserialize_child()") bool get_if(id_type pos, T *var)
const
660 this_assert_readable_();
661 ConstImpl ch = ((ConstImpl
const*)
this)->child(pos);
670 RYML_DEPRECATED(
"use .deserialize_child()")
671 bool get_if(csubstr name, T *var, T const& fallback)
const
673 if(get_if(name, var))
679 RYML_DEPRECATED(
"use .deserialize_child()")
680 bool get_if(id_type pos, T *var, T const& fallback)
const
687 template<
class Visitor>
688 RYML_DEPRECATED(
"") bool visit(Visitor fn, id_type indentation_level=0,
bool skip_root=true) const
RYML_NOEXCEPT
690 this_assert_readable_();
691 return detail::_visit(*(ConstImpl
const*)
this, fn, indentation_level, skip_root);
693 template <
class Visitor,
class U = Impl>
695 auto visit(Visitor fn, id_type indentation_level = 0,
bool skip_root = true)
RYML_NOEXCEPT
696 -> typename std ::enable_if<!std ::is_same<U, ConstImpl>::value,
bool>::type
698 this_assert_readable_();
699 return detail::_visit(*(Impl *)
this, fn, indentation_level, skip_root);
701 template<
class Visitor>
702 RYML_DEPRECATED(
"") bool visit_stacked(Visitor fn, id_type indentation_level=0,
bool skip_root=true) const
RYML_NOEXCEPT
704 this_assert_readable_();
705 return detail::_visit_stacked(*(ConstImpl
const*)
this, fn, indentation_level, skip_root);
707 template<
class Visitor,
class U=Impl>
708 RYML_DEPRECATED(
"") auto visit_stacked(Visitor fn, id_type indentation_level=0,
bool skip_root=true)
RYML_NOEXCEPT
709 -> typename std ::enable_if<!std ::is_same<U, ConstImpl>::value,
bool>::type
711 this_assert_readable_();
712 return detail::_visit_stacked(*(Impl*)
this, fn, indentation_level, skip_root);
715 C4_SUPPRESS_WARNING_POP
717 #undef this_assert_readable_
723 C4_SUPPRESS_WARNING_GCC_CLANG_POP
796 constexpr static C4_ALWAYS_INLINE
bool is_seed() noexcept {
return false; }
802 void assert_readable_()
const
804 RYML_ASSERT_BASIC_(m_tree !=
nullptr);
805 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, m_id !=
NONE && (m_id < m_tree->capacity()), m_tree, m_id);
808 void check_readable_()
const
810 if C4_UNLIKELY(!m_tree)
811 RYML_ERR_BASIC_(
"invalid node");
812 if C4_UNLIKELY(!m_tree || m_id == NONE || (m_id > m_tree->capacity()))
813 RYML_ERR_VISIT_CB_(m_tree->m_callbacks, m_tree, m_id,
"invalid node");
960 RYML_CHECK_VISIT_CB_(
m_tree->m_callbacks, (pos >= 0 && pos < cap),
m_tree,
m_id);
974 using iterator = detail::child_iterator<ConstNodeRef>;
1002 C4_SUPPRESS_WARNING_PUSH
1003 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated")
1004 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated-declarations")
1005 C4_SUPPRESS_WARNING_MSVC(4996)
1007 RYML_DEPRECATED(
"use ConstNodeRef()")
ConstNodeRef(std::nullptr_t) noexcept : m_tree(
nullptr), m_id(
NONE) {}
1008 RYML_DEPRECATED(
"use node = {}") ConstNodeRef& operator= (std::nullptr_t) noexcept { m_tree =
nullptr; m_id = NONE;
return *
this; }
1010 RYML_DEPRECATED(
"use one of readable(), is_seed() or !invalid()") bool valid() const noexcept {
return m_tree !=
nullptr && m_id != NONE; }
1011 RYML_DEPRECATED(
"use invalid()") bool operator== (std::nullptr_t) const noexcept {
return m_tree ==
nullptr || m_id ==
NONE; }
1012 RYML_DEPRECATED(
"use !invalid()") bool operator!= (std::nullptr_t) const noexcept {
return !(m_tree ==
nullptr || m_id ==
NONE); }
1013 RYML_DEPRECATED(
"use (this->val() == s)") bool operator== (csubstr s) const
RYML_NOEXCEPT { RYML_ASSERT_BASIC_(m_tree); RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, m_id != NONE, m_tree, NONE);
return m_tree->val(m_id) == s; }
1014 RYML_DEPRECATED(
"use (this->val() != s)") bool operator!= (csubstr s) const
RYML_NOEXCEPT { RYML_ASSERT_BASIC_(m_tree); RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, m_id != NONE, m_tree, NONE);
return m_tree->val(m_id) != s; }
1071 Tree *C4_RESTRICT m_tree;
1091 C4_ALWAYS_INLINE
void _clear_seed() noexcept
1094 m_seed.str =
nullptr;
1098 friend ConstNodeRef;
1106 NodeRef() noexcept : m_tree(
nullptr), m_id(
NONE), m_seed() { _clear_seed(); }
1107 NodeRef(
Tree &t) noexcept : m_tree(&t), m_id(t .root_id()), m_seed() { _clear_seed(); }
1108 NodeRef(
Tree *t) noexcept : m_tree(t ), m_id(t->root_id()), m_seed() { _clear_seed(); }
1110 NodeRef(
Tree *t,
id_type id,
id_type seed_pos) noexcept : m_tree(t), m_id(
id), m_seed() { m_seed.str =
nullptr; m_seed.len = (size_t)seed_pos; }
1134 bool invalid() const noexcept {
return m_tree ==
nullptr || m_id ==
NONE; }
1136 bool is_seed() const noexcept {
return (m_tree !=
nullptr && m_id !=
NONE) && has_seed_(); }
1138 bool readable() const noexcept {
return (m_tree !=
nullptr && m_id !=
NONE) && !has_seed_(); }
1144 C4_ALWAYS_INLINE
bool valid_id_() const noexcept {
return m_id !=
NONE && m_id < m_tree->capacity(); }
1145 C4_ALWAYS_INLINE
bool has_seed_() const noexcept {
return m_seed.
str !=
nullptr || m_seed.
len != (size_t)NONE; }
1147 void assert_readable_()
const
1149 RYML_ASSERT_BASIC_(m_tree !=
nullptr);
1150 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, valid_id_() && !has_seed_(), m_tree, m_id);
1153 void check_readable_()
const
1155 if C4_UNLIKELY(!m_tree)
1157 if C4_UNLIKELY((m_id == NONE || (m_id > m_tree->capacity()) ||
1158 (m_seed.
str !=
nullptr || m_seed.
len != (
size_t)NONE)))
1162 void check_writeable_()
const
1164 if C4_UNLIKELY(!m_tree)
1168 void assert_writeable_()
const
1170 RYML_ASSERT_BASIC_(m_tree !=
nullptr);
1180 if(m_tree == that.m_tree && m_id == that.m_id)
1187 return (m_seed.len == that.m_seed.
len)
1188 && (m_seed.str == that.m_seed.
str
1189 || m_seed == that.m_seed);
1208 C4_ALWAYS_INLINE
id_type id() const noexcept {
return m_id; }
1210 C4_ALWAYS_INLINE
Tree const*
tree() const noexcept {
return m_tree; }
1211 C4_ALWAYS_INLINE
Tree *
tree() noexcept {
return m_tree; }
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);
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;
1236 else if(m_seed.len != (
size_t)
NONE)
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;
1281 m_tree->change_type(m_id, t);
1288 m_tree->_clear_key(m_id);
1295 m_tree->_clear_val(m_id);
1302 m_tree->remove_children(m_id);
1308 m_tree->clear_style(m_id, recurse);
1317 m_tree->set_style_conditionally(m_id, type_mask, rem_style_flags, add_style_flags, recurse);
1332 RYML_ASSERT_BASIC_(m_tree);
1333 return m_tree->to_arena(s);
1349 RYML_ASSERT_BASIC_(!(style_flags & ~
STYLE));
1350 _add_flags(style_flags);
1366 RYML_ASSERT_BASIC_(!(style_flags & ~
STYLE));
1367 _add_flags(style_flags);
1377 assert_writeable_();
1384 assert_writeable_();
1387 RYML_ASSERT_BASIC_(!(style_flags & ~
STYLE));
1388 _add_flags(style_flags);
1398 assert_writeable_();
1405 assert_writeable_();
1408 RYML_ASSERT_BASIC_(!(style_flags & ~
STYLE));
1409 _add_flags(style_flags);
1423 C4_ALWAYS_INLINE ConstNodeRef
parent() const
RYML_NOEXCEPT { assert_readable_();
return {m_tree, m_tree->parent(m_id)}; }
1429 C4_ALWAYS_INLINE ConstNodeRef
last_child() const
RYML_NOEXCEPT { assert_readable_();
return {m_tree, m_tree->last_child (m_id)}; }
1527 id_type ch = m_tree->child(m_id, pos);
1544 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, ch !=
NONE, m_tree, m_id);
1545 return {m_tree, ch};
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};
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);
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);
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);
1667 RYML_CHECK_VISIT_CB_(m_tree->m_callbacks, ch !=
NONE, m_tree, m_id);
1668 return {m_tree, ch};
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};
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));
1711 NodeRef r(m_tree, m_tree->insert_child(m_id,
NONE));
1718 NodeRef r(m_tree, m_tree->append_child(m_id));
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));
1733 NodeRef r(m_tree, m_tree->prepend_sibling(m_id));
1740 NodeRef r(m_tree, m_tree->append_sibling(m_id));
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());
1759 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, pos >= 0 && pos <
num_children(), m_tree, m_id);
1761 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks,
child !=
NONE, m_tree, m_id);
1762 m_tree->remove(
child);
1770 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks,
child !=
NONE, m_tree, m_id);
1771 m_tree->remove(
child);
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)
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);
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);
1864 RYML_LEGACY_OPERATOR(
".use the appropriate .set_*() overload")
1867 RYML_LEGACY_OPERATOR(
".use the appropriate .set_*() overload")
1870 RYML_LEGACY_OPERATOR(
"use .set_val()")
1874 RYML_LEGACY_OPERATOR(
"use .set_val()")
1877 RYML_LEGACY_OPERATOR(
"use .set_val()")
1881 RYML_LEGACY_OPERATOR(
"use .set_key()")
1885 RYML_LEGACY_OPERATOR(
"use .save()")
1886 NodeRef& operator<< (T const& C4_RESTRICT v) {
save(v);
return *
this; }
1888 RYML_LEGACY_OPERATOR(
"use .save()")
1892 RYML_LEGACY_OPERATOR(
"use .save_key()")
1905 C4_SUPPRESS_WARNING_PUSH
1906 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated")
1907 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wdeprecated-declarations")
1908 C4_SUPPRESS_WARNING_MSVC(4996)
1909 RYML_DEPRECATED(
"use NodeRef()")
NodeRef(std::nullptr_t) noexcept : m_tree(
nullptr), m_id(
NONE), m_seed() {}
1911 RYML_DEPRECATED(
"use one of readable(), is_seed() or !invalid()") inline
bool valid()
const {
return m_tree !=
nullptr && m_id != NONE; }
1912 RYML_DEPRECATED(
"use !readable()") bool operator== (std::nullptr_t)
const {
return m_tree ==
nullptr || m_id == NONE || is_seed(); }
1913 RYML_DEPRECATED(
"use readable()") bool operator!= (std::nullptr_t)
const {
return !(m_tree ==
nullptr || m_id ==
NONE || is_seed()); }
1914 RYML_DEPRECATED(
"use `this->val() == s`") bool operator== (csubstr s)
const { assert_readable_(); RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, has_val(), m_tree, m_id);
return m_tree->val(m_id) == s; }
1915 RYML_DEPRECATED(
"use `this->val() != s`") bool operator!= (csubstr s)
const { assert_readable_(); RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, has_val(), m_tree, m_id);
return m_tree->val(m_id) != s; }
1917 RYML_DEPRECATED(
"use .set_*()") void operator= (NodeInit const& v)
1923 RYML_DEPRECATED(
"use .set_*()") void operator= (NodeScalar const& v)
1929 RYML_DEPRECATED(
"") void clear()
1932 m_tree->remove_children(m_id);
1933 m_tree->_clear(m_id);
1936 RYML_DEPRECATED(
"") void _apply(csubstr v)
1938 m_tree->set_val(m_id, v);
1941 RYML_DEPRECATED(
"") void _apply(NodeScalar const& v)
1943 m_tree->_set_val(m_id, v);
1946 RYML_DEPRECATED(
"") void _apply(NodeInit const& i)
1948 m_tree->_set(m_id, i);
1951 RYML_DEPRECATED(
"") NodeRef insert_child(NodeInit const& i, NodeRef after)
1954 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1955 NodeRef r(m_tree, m_tree->insert_child(m_id, after.m_id));
1960 RYML_DEPRECATED(
"") NodeRef prepend_child(NodeInit const& i)
1963 NodeRef r(m_tree, m_tree->insert_child(m_id, NONE));
1968 RYML_DEPRECATED(
"") NodeRef append_child(NodeInit const& i)
1971 NodeRef r(m_tree, m_tree->append_child(m_id));
1976 RYML_DEPRECATED(
"") NodeRef insert_sibling(NodeInit const& i, ConstNodeRef const& after)
1979 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, after.m_tree == m_tree, m_tree, m_id);
1980 NodeRef r(m_tree, m_tree->insert_sibling(m_id, after.m_id));
1985 RYML_DEPRECATED(
"") NodeRef prepend_sibling(NodeInit const& i)
1988 NodeRef r(m_tree, m_tree->prepend_sibling(m_id));
1993 RYML_DEPRECATED(
"") NodeRef append_sibling(NodeInit const& i)
1996 NodeRef r(m_tree, m_tree->append_sibling(m_id));
2001 RYML_DEPRECATED(
"") void move(ConstNodeRef const& after)
2004 m_tree->move(m_id, after.m_id);
2007 RYML_DEPRECATED(
"") NodeRef duplicate(ConstNodeRef const& after)
const
2010 RYML_ASSERT_VISIT_CB_(m_tree->m_callbacks, m_tree == after.m_tree || after.m_id == NONE, m_tree, m_id);
2011 id_type dup = m_tree->duplicate(m_id, m_tree->parent(m_id), after.m_id);
2012 NodeRef r(m_tree, dup);
2016 C4_SUPPRESS_WARNING_POP
2018 void _add_flags(NodeType f)
2021 m_tree->_add_flags(m_id, f);
2077 return n.m_tree->deserialize(n.m_id, v);
2083 return n.m_tree->deserialize(n.m_id, wrapper);
2091 return n.m_tree->deserialize_key(n.m_id, v);
2097 return n.m_tree->deserialize_key(n.m_id, wrapper);
2149C4_SUPPRESS_WARNING_POP
Holds a pointer to an existing tree, and a node id.
detail::children_view< ConstNodeRef > children_view
NodeData const * get() const RYML_NOEXCEPT
Forward to Tree::type().
ConstNodeRef parent() const RYML_NOEXCEPT
Forward to Tree::parent().
const_iterator cend() const RYML_NOEXCEPT
get an iterator to after the last child
const_iterator cbegin() const RYML_NOEXCEPT
get an iterator to the first child
const_children_view cchildren() const RYML_NOEXCEPT
get an iterable view over children
ReadResult find_child_r(csubstr name, ConstNodeRef *child) const RYML_NOEXCEPT
Forward to Tree::child_r().
ConstNodeRef child(id_type pos) const RYML_NOEXCEPT
Forward to Tree::child().
ConstNodeRef & operator=(ConstNodeRef const &) noexcept=default
ConstNodeRef first_sibling() const RYML_NOEXCEPT
Forward to Tree::first_sibling().
ConstNodeRef(ConstNodeRef const &) noexcept=default
id_type id() const noexcept
ConstNodeRef ancestor_doc() const RYML_NOEXCEPT
Forward to Tree::ancestor_doc().
ConstNodeRef first_child() const RYML_NOEXCEPT
Forward to Tree::first_child().
ConstNodeRef find_child(csubstr name) const RYML_NOEXCEPT
Forward to Tree::find_child().
ReadResult sibling_r(id_type pos, ConstNodeRef *sibling) const RYML_NOEXCEPT
Forward to Tree::find_child_r().
ConstNodeRef last_child() const RYML_NOEXCEPT
Forward to Tree::last_child().
ConstNodeRef(ConstNodeRef &&) noexcept=default
ConstNodeRef(Tree const *t) noexcept
detail::child_iterator< ConstNodeRef > iterator
ConstNodeRef at(id_type pos) const
Get a child by position, with error checking; complexity is O(pos).
bool invalid() const noexcept
ConstNodeRef find_sibling(csubstr name) const RYML_NOEXCEPT
Forward to Tree::find_sibling().
const_iterator begin() const RYML_NOEXCEPT
get an iterator to the first child
detail::child_iterator< ConstNodeRef > const_iterator
ReadResult find_sibling_r(csubstr name, ConstNodeRef *sibling) const RYML_NOEXCEPT
Forward to Tree::sibling_r().
const_children_view children() const RYML_NOEXCEPT
get an iterable view over children
ConstNodeRef last_sibling() const RYML_NOEXCEPT
Forward to Tree::last_sibling().
ConstNodeRef at(csubstr key) const
Get a child by name, with error checking; complexity is O(num_children).
ConstNodeRef(Tree const *t, id_type id) noexcept
ConstNodeRef(Tree const &t) noexcept
Tree const * tree() const noexcept
detail::children_view< ConstNodeRef > const_children_view
ConstNodeRef next_sibling() const RYML_NOEXCEPT
Forward to Tree::next_sibling().
ConstNodeRef doc(id_type i) const RYML_NOEXCEPT
Forward to Tree::doc().
static constexpr bool is_seed() noexcept
because a ConstNodeRef cannot be used to write to the tree, it can never be a seed.
ConstNodeRef prev_sibling() const RYML_NOEXCEPT
Forward to Tree::prev_sibling().
ConstNodeRef sibling(id_type pos) const RYML_NOEXCEPT
Forward to Tree::sibling().
const_children_view siblings() const RYML_NOEXCEPT
const_iterator end() const RYML_NOEXCEPT
get an iterator to after the last child
bool readable() const noexcept
because a ConstNodeRef cannot be used to write to the tree, readable() has the same meaning as !...
ReadResult child_r(id_type pos, ConstNodeRef *child) const RYML_NOEXCEPT
const_children_view csiblings() const RYML_NOEXCEPT
get an iterable view over all siblings (including the calling node)
A reference to a node in an existing yaml tree, offering a more convenient API than the index-based A...
void set_val_anchor(csubstr val_anchor)
NodeRef parent() RYML_NOEXCEPT
Forward to Tree::parent().
const_iterator begin() const RYML_NOEXCEPT
get an iterator to the first child
void set_style_conditionally(NodeType type_mask, NodeType rem_style_flags, NodeType add_style_flags, bool recurse=false)
detail::children_view< NodeRef > children_view
ReadResult find_sibling_r(csubstr name, NodeRef *sibling) RYML_NOEXCEPT
ConstNodeRef prev_sibling() const RYML_NOEXCEPT
Forward to Tree::prev_sibling().
NodeRef last_sibling() RYML_NOEXCEPT
Forward to Tree::last_sibling().
NodeRef prev_sibling() RYML_NOEXCEPT
Forward to Tree::find_child_r().
detail::child_iterator< NodeRef > iterator
ConstNodeRef find_sibling(csubstr name) const RYML_NOEXCEPT
Forward to Tree::find_sibling().
detail::RoNodeMethods< NodeRef, ConstNodeRef > base_type
NodeRef insert_sibling(ConstNodeRef const &after)
NodeRef child(id_type pos) RYML_NOEXCEPT
Forward to Tree::child().
void set_val(csubstr val, NodeType more_flags)
iterator begin() RYML_NOEXCEPT
get a mutable iterator to the first child.
ConstNodeRef last_child() const RYML_NOEXCEPT
Forward to Tree::last_child().
ReadResult child_r(id_type pos, ConstNodeRef *child) const RYML_NOEXCEPT
Forward to Tree::child_r().
NodeRef(Tree *t, id_type id, csubstr seed_key) noexcept
detail::child_iterator< ConstNodeRef > const_iterator
void set_serialized(T const &v)
serialize a variable to this node.
void set_val_tag(csubstr val_tag)
NodeRef next_sibling() RYML_NOEXCEPT
Forward to Tree::next_sibling().
void clear_style(bool recurse=false)
Tree const * tree() const noexcept
void save_key(T const &k)
NodeRef(NodeRef &&) noexcept=default
ReadResult find_child_r(csubstr name, ConstNodeRef *child) const RYML_NOEXCEPT
Forward to Tree::find_child_r().
const_iterator cbegin() const RYML_NOEXCEPT
get an iterator to the first child
NodeRef(Tree *t, id_type id, id_type seed_pos) noexcept
NodeRef at(id_type pos)
Find child by position; complexity is O(pos).
NodeRef at(csubstr key)
Find child by key; complexity is O(num_children).
csubstr to_arena(T const &s)
forward to Tree::to_arena() .
children_view children() RYML_NOEXCEPT
get an iterable view over children
NodeRef insert_child(NodeRef after)
void set_val(csubstr val)
NodeRef prepend_sibling()
ConstNodeRef first_child() const RYML_NOEXCEPT
Forward to Tree::first_child().
void set_key_serialized(T const &k)
serialize a variable, then assign the result to the node's key
void clear_children()
remove the children from a scalar
NodeRef(Tree *t, id_type id) noexcept
void set_map(NodeType more_flags)
ConstNodeRef last_sibling() const RYML_NOEXCEPT
Forward to Tree::last_sibling().
ConstNodeRef at(csubstr key) const
Get a child by name, with error checking; complexity is O(num_children).
ConstNodeRef find_child(csubstr name) const RYML_NOEXCEPT
Forward to Tree::find_child().
void set_key_serialized(T const &k, NodeType style_flags)
ConstNodeRef at(id_type pos) const
Get a child by position, with error checking; complexity is O(pos).
void clear_val()
remove the VAL (flags included) from a scalar
NodeRef ancestor_doc() RYML_NOEXCEPT
Forward to Tree::find_sibling_r().
void set_container_style(type_bits style)
ConstNodeRef first_sibling() const RYML_NOEXCEPT
Forward to Tree::first_sibling().
ReadResult sibling_r(id_type pos, NodeRef *sibling) RYML_NOEXCEPT
const_iterator end() const RYML_NOEXCEPT
get an iterator to after the last child
const_children_view children() const RYML_NOEXCEPT
get an iterable view over children
ReadResult find_child_r(csubstr name, NodeRef *child) RYML_NOEXCEPT
void set_key(csubstr key, NodeType more_flags)
NodeData * get() RYML_NOEXCEPT
Forward to Tree::type().
children_view siblings() RYML_NOEXCEPT
NodeData const * get() const RYML_NOEXCEPT
Forward to Tree::type().
NodeRef last_child() RYML_NOEXCEPT
Forward to Tree::last_child().
id_type id() const noexcept
ConstNodeRef parent() const RYML_NOEXCEPT
Forward to Tree::parent().
bool invalid() const noexcept
true if the object is not referring to any existing or seed node.
detail::children_view< ConstNodeRef > const_children_view
ConstNodeRef child(id_type pos) const RYML_NOEXCEPT
Forward to Tree::child().
ReadResult child_r(id_type pos, NodeRef *child) RYML_NOEXCEPT
ReadResult find_sibling_r(csubstr name, ConstNodeRef *sibling) const RYML_NOEXCEPT
Forward to Tree::find_sibling_r().
NodeRef doc(id_type i) RYML_NOEXCEPT
Forward to Tree::doc().
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.
void save(T const &k, NodeType style_flags)
void set_seq(NodeType more_flags)
void set_key_style(type_bits style)
bool readable() const noexcept
true if the object is not invalid and not in seed state.
ConstNodeRef sibling(id_type pos) const RYML_NOEXCEPT
Forward to Tree::sibling().
NodeRef sibling(id_type pos) RYML_NOEXCEPT
Forward to Tree::sibling().
NodeRef(Tree *t) noexcept
ConstNodeRef ancestor_doc() const RYML_NOEXCEPT
Forward to Tree::ancestor_doc().
NodeRef first_sibling() RYML_NOEXCEPT
Forward to Tree::first_sibling().
void clear_key()
remove the KEY (flags included) from a scalar
void create()
if this node is in seed state, create the node in the tree
NodeRef duplicate(NodeRef const &parent, ConstNodeRef const &after) const
duplicate the current node somewhere into a different parent (possibly from a different tree),...
ConstNodeRef doc(id_type i) const RYML_NOEXCEPT
Forward to Tree::doc().
ReadResult sibling_r(id_type pos, ConstNodeRef *sibling) const RYML_NOEXCEPT
Forward to Tree::sibling_r().
const_iterator cend() const RYML_NOEXCEPT
get an iterator to after the last child
void set_serialized(T const &v, NodeType style_flags)
NodeRef duplicate_children(NodeRef const &parent, ConstNodeRef const &after) const
void remove_child(csubstr key)
remove a child by name
NodeRef(NodeRef const &) noexcept=default
void set_key_tag(csubstr key_tag)
ConstNodeRef next_sibling() const RYML_NOEXCEPT
Forward to Tree::next_sibling().
const_children_view siblings() const RYML_NOEXCEPT
get an iterable view over all siblings (including the calling node)
void set_key_ref(csubstr key_ref)
NodeRef find_sibling(csubstr name) RYML_NOEXCEPT
Forward to Tree::sibling_r().
void remove_child(NodeRef &child)
NodeRef first_child() RYML_NOEXCEPT
Forward to Tree::first_child().
void save_key(T const &k, NodeType style_flags)
void set_val_style(type_bits style)
void set_key_anchor(csubstr key_anchor)
const_children_view cchildren() const RYML_NOEXCEPT
get an iterable view over children
void change_type(NodeType t)
NodeRef(Tree &t) noexcept
iterator end() RYML_NOEXCEPT
get an iterator to after the last child.
bool is_seed() const noexcept
true if the object is not invalid and in seed state.
void set_key(csubstr key)
void set_val_ref(csubstr val_ref)
NodeRef find_child(csubstr name) RYML_NOEXCEPT
Forward to Tree::child_r().
void remove_child(id_type pos)
remove the nth child of this node
const_children_view csiblings() const RYML_NOEXCEPT
get an iterable view over all siblings (including the calling node)
void set_serialized(id_type node, T const &val) RYML_NOEXCEPT
void set_key_serialized(id_type node, T const &key) RYML_NOEXCEPT
#define RYML_NOEXCEPT
Conditionally expands to noexcept when RYML_USE_ASSERT is 0 and is empty otherwise.
uint32_t type_bits
the integral type necessary to cover all the bits for NodeType_e
@ MAP
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
@ KEY
the scalar to the left of : in a map's member
@ VAL
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
@ SEQ
a seq: a parent of VAL/SEQ/MAP nodes
@ STYLE
mask of SCALAR_STYLE | CONTAINER_STYLE : all style flags
ParseEngine< EventHandlerTree > Parser
This is the main ryml parser, where the parser events are handled to create a ryml tree (see Event Ha...
ryml::ReadResult read(ryml::Tree const *tree, ryml::id_type id, my_seq_type< T > *seq)
void write(ryml::Tree *tree, ryml::id_type id, my_seq_type< T > const &seq)
ReadResult read_key(ConstNodeRef const &n, T *v)
ReadResult read(ConstNodeRef const &n, T *v)
void write(NodeRef *n, T const &v)
void write_key(NodeRef *n, T const &v)
bool operator!=(const char c, basic_substring< C > const that) noexcept
bool operator==(const char c, basic_substring< C > const that) noexcept
basic_substring< const char > csubstr
an immutable string view
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...
size_t len
the length of the substring
void assign(C(&s_)[N]) noexcept
Assign from an array.
C * str
a restricted pointer to the first character of the substring
holds a source or yaml file position, for example when an error is detected; See also location_format...
contains the data for each YAML node.
a node scalar is a csubstr, which may be tagged and anchored.
Wraps a type_bits mask of NodeTypeBits flags with some syntactic sugar and predicates.
A lightweight truthy type, used to enable reporting the offending node when a deserializing error hap...
a CRTP base providing read-only methods for ConstNodeRef and NodeRef
void load(Wrapper const &wrapper, bool check_readable=true) const
(2) like (1), but for wrapper tag types such as c4::fmt::base64()
ReadResult deserialize_child(id_type child_pos, Wrapper const &wrapper) const
(3) like (1), but for wrapper tag types such as c4::fmt::base64()
bool type_has_all(type_bits bits) const RYML_NOEXCEPT
Forward to Tree::type_has_all().
id_type depth_asc() const RYML_NOEXCEPT
id_type depth_desc() const RYML_NOEXCEPT
O(log(num_nodes)).
bool has_anchor() const RYML_NOEXCEPT
Forward to Tree::has_anchor().
NodeScalar const & valsc() const RYML_NOEXCEPT
Forward to Tree::valsc().
bool is_flow_ml() const RYML_NOEXCEPT
bool is_val() const RYML_NOEXCEPT
Forward to Tree::is_val().
bool is_key_styled() const RYML_NOEXCEPT
Forward to Tree::is_key_styled().
void assert_val_() const noexcept
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-o...
bool is_root() const RYML_NOEXCEPT
Forward to Tree::is_root().
csubstr key_anchor() const RYML_NOEXCEPT
Forward to Tree::key_anchor().
bool has_val_anchor() const RYML_NOEXCEPT
Forward to Tree::has_val_anchor().
bool type_has_any(type_bits bits) const RYML_NOEXCEPT
Forward to Tree::type_has_any().
bool is_key_plain() const RYML_NOEXCEPT
Forward to Tree::is_key_plain().
bool is_key_quoted() const RYML_NOEXCEPT
Forward to Tree::is_key_quoted().
bool is_stream() const RYML_NOEXCEPT
Forward to Tree::is_stream().
NodeType type() const RYML_NOEXCEPT
Forward to Tree::type().
bool empty() const RYML_NOEXCEPT
Forward to Tree::empty().
bool has_key_anchor() const RYML_NOEXCEPT
Forward to Tree::has_key_anchor().
bool is_key_unfiltered() const noexcept
Forward to Tree::is_key_unfiltered().
id_type sibling_pos(ConstImpl const &n) const RYML_NOEXCEPT
O(num_siblings).
bool is_key_literal() const RYML_NOEXCEPT
Forward to Tree::is_key_literal().
csubstr key_ref() const RYML_NOEXCEPT
Forward to Tree::key_ref().
bool type_has_none(type_bits bits) const RYML_NOEXCEPT
Forward to Tree::type_has_none().
bool has_child(ConstImpl const &n) const RYML_NOEXCEPT
Forward to Tree::has_child().
void load_key(Wrapper const &wrapper, bool check_readable=true) const
(2) like (1), but for wrapper tag types such as c4::fmt::base64()
bool is_quoted() const RYML_NOEXCEPT
Forward to Tree::is_quoted().
bool parent_is_map() const RYML_NOEXCEPT
Forward to Tree::parent_is_map().
bool has_child(csubstr name) const RYML_NOEXCEPT
Forward to Tree::has_child().
bool is_map() const RYML_NOEXCEPT
Forward to Tree::is_map().
bool is_flow_ml1() const RYML_NOEXCEPT
Forward to Tree::is_flow_ml1().
NodeScalar const & keysc() const RYML_NOEXCEPT
Forward to Tree::keysc().
ReadResult deserialize_child(csubstr child_key, Wrapper const &v) const
(3) like (1), but for wrapper tag types such as c4::fmt::base64()
bool is_container() const RYML_NOEXCEPT
Forward to Tree::is_container().
id_type num_siblings() const RYML_NOEXCEPT
O(num_children).
bool has_key() const RYML_NOEXCEPT
Forward to Tree::has_key().
csubstr key_tag() const RYML_NOEXCEPT
Forward to Tree::key_tag().
csubstr val_ref() const RYML_NOEXCEPT
Forward to Tree::val_ref().
csubstr key() const RYML_NOEXCEPT
Forward to Tree::key().
bool has_sibling(csubstr name) const RYML_NOEXCEPT
Forward to Tree::has_sibling().
NodeType key_style() const RYML_NOEXCEPT
Forward to Tree::key_style().
bool has_key_tag() const RYML_NOEXCEPT
Forward to Tree::has_key_tag().
static void err_basic_(const char *msg)
csubstr val_tag() const RYML_NOEXCEPT
Forward to Tree::val_tag().
bool is_ancestor(ConstImpl const &ancestor) const RYML_NOEXCEPT
Forward to Tree::is_ancestor() Node must be readable.
csubstr val_anchor() const RYML_NOEXCEPT
Forward to Tree::val_anchor().
bool has_parent() const RYML_NOEXCEPT
Forward to Tree::has_parent() Node must be readable.
bool is_val_squo() const RYML_NOEXCEPT
Forward to Tree::is_val_squo().
bool is_val_ref() const RYML_NOEXCEPT
Forward to Tree::is_val_ref().
bool has_other_siblings() const RYML_NOEXCEPT
Forward to Tree::has_other_siblings().
bool has_flow_space() const RYML_NOEXCEPT
Forward to Tree::has_flow_space().
bool is_val_styled() const RYML_NOEXCEPT
Forward to Tree::is_val_styled().
bool val_is_null() const RYML_NOEXCEPT
Forward to Tree::val_is_null().
bool has_sibling(id_type node) const RYML_NOEXCEPT
Forward to Tree::has_sibling().
id_type child_pos(ConstImpl const &n) const RYML_NOEXCEPT
O(num_children).
bool is_container_styled() const RYML_NOEXCEPT
Forward to Tree::is_container_styled().
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 ....
csubstr val() const RYML_NOEXCEPT
Forward to Tree::val().
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 ....
bool is_key_ref() const RYML_NOEXCEPT
Forward to Tree::is_key_ref().
bool key_is_null() const RYML_NOEXCEPT
Forward to Tree::key_is_null().
NodeType val_style() const RYML_NOEXCEPT
Forward to Tree::val_style().
ReadResult deserialize_child(csubstr child_key, T *v, T const &fallback) const
(2) like (1), but assign from fallback if no such child exists.
bool parent_is_seq() const RYML_NOEXCEPT
Forward to Tree::parent_is_seq().
bool is_doc() const RYML_NOEXCEPT
Forward to Tree::is_doc().
ReadResult deserialize(Wrapper const &wrapper) const
(2) like (1), but for wrapper tag types such as c4::fmt::base64()
bool is_key_dquo() const RYML_NOEXCEPT
Forward to Tree::is_key_dquo().
id_type num_children() const RYML_NOEXCEPT
O(num_children).
bool is_val_unfiltered() const noexcept
Forward to Tree::is_val_unfiltered().
bool is_flow_mlx() const RYML_NOEXCEPT
Forward to Tree::is_flow_mlx().
ReadResult deserialize(T *v) const
(1) deserialize the node's contents (val or container) to the given variable, forwarding to the user-...
bool is_flow_sl() const RYML_NOEXCEPT
Forward to Tree::is_flow_sl().
bool is_flow() const RYML_NOEXCEPT
Forward to Tree::is_flow().
ReadResult deserialize_key(Wrapper const &wrapper) const
(2) like (1), but for wrapper tag types such as c4::fmt::base64()
bool is_block() const RYML_NOEXCEPT
Forward to Tree::is_block().
bool is_key_folded() const RYML_NOEXCEPT
Forward to Tree::is_key_folded().
Location location(Parser const &parser) const
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
void assert_key_() const noexcept
bool is_val_plain() const RYML_NOEXCEPT
Forward to Tree::is_val_plain().
bool is_seq() const RYML_NOEXCEPT
Forward to Tree::is_seq().
bool is_val_folded() const RYML_NOEXCEPT
Forward to Tree::is_val_folded().
static void err_visit_(Tree const *tree, id_type id, const char *msg)
bool has_children() const RYML_NOEXCEPT
Forward to Tree::has_children().
bool is_val_quoted() const RYML_NOEXCEPT
Forward to Tree::is_val_quoted().
bool is_val_literal() const RYML_NOEXCEPT
Forward to Tree::is_val_literal().
bool has_child(id_type node) const RYML_NOEXCEPT
Forward to Tree::has_child().
bool is_key_squo() const RYML_NOEXCEPT
Forward to Tree::is_key_squo().
bool is_flow_mln() const RYML_NOEXCEPT
Forward to Tree::is_flow_mln().
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-...
ReadResult deserialize_key(T *v) const
(1) deserialize the node's key (necessarily a scalar) to the given variable, forwarding to the user-o...
bool has_val() const RYML_NOEXCEPT
Forward to Tree::has_val().
bool has_sibling(ConstImpl const &n) const RYML_NOEXCEPT
Forward to Tree::has_sibling().
bool is_keyval() const RYML_NOEXCEPT
Forward to Tree::is_keyval().
bool has_val_tag() const RYML_NOEXCEPT
Forward to Tree::has_val_tag().
id_type num_other_siblings() const RYML_NOEXCEPT
O(num_siblings).
bool is_val_dquo() const RYML_NOEXCEPT
Forward to Tree::is_val_dquo().
bool is_ref() const RYML_NOEXCEPT
Forward to Tree::is_ref().