|
rapidyaml
0.11.1
parse and emit YAML, and do it fast
|
#include <tree.hpp>
Classes | |
| struct | lookup_result |
Public Member Functions | |
| id_type | _claim () |
construction and assignment | |
| Tree () | |
| Tree (Callbacks const &cb) | |
| Tree (id_type node_capacity, size_t arena_capacity=RYML_DEFAULT_TREE_ARENA_CAPACITY) | |
| Tree (id_type node_capacity, size_t arena_capacity, Callbacks const &cb) | |
| ~Tree () | |
| Tree (Tree const &that) | |
| Tree (Tree &&that) noexcept | |
| Tree & | operator= (Tree const &that) |
| Tree & | operator= (Tree &&that) noexcept |
memory and sizing | |
| void | reserve (id_type node_capacity=RYML_DEFAULT_TREE_CAPACITY) |
| void | clear () |
| clear the tree and zero every node More... | |
| void | clear_arena () |
| bool | empty () const |
| id_type | size () const |
| id_type | capacity () const |
| id_type | slack () const |
| Callbacks const & | callbacks () const |
| void | callbacks (Callbacks const &cb) |
node getters | |
| id_type | id (NodeData const *n) const |
get the index of a node belonging to this tree. n can be nullptr, in which case NONE is returned More... | |
| NodeData * | get (id_type node) |
| get a pointer to a node's NodeData. i can be NONE, in which case a nullptr is returned More... | |
| NodeData const * | get (id_type node) const |
| get a pointer to a node's NodeData. i can be NONE, in which case a nullptr is returned. More... | |
| NodeData * | _p (id_type node) |
| An if-less form of get() that demands a valid node index. This function is implementation only; use at your own risk. More... | |
| NodeData const * | _p (id_type node) const |
| An if-less form of get() that demands a valid node index. This function is implementation only; use at your own risk. More... | |
| id_type | root_id () const |
| Get the id of the root node. The tree must not be empty. More... | |
| NodeRef | ref (id_type node) |
| Get a NodeRef of a node by id. More... | |
| ConstNodeRef | ref (id_type node) const |
| Get a NodeRef of a node by id. More... | |
| ConstNodeRef | cref (id_type node) const |
| Get a NodeRef of a node by id. More... | |
| NodeRef | rootref () |
| Get the root as a NodeRef. More... | |
| ConstNodeRef | rootref () const |
| Get the root as a ConstNodeRef. More... | |
| ConstNodeRef | crootref () const |
| Get the root as a ConstNodeRef. More... | |
| NodeRef | docref (id_type i) |
| get the i-th document of the stream More... | |
| ConstNodeRef | docref (id_type i) const |
| get the i-th document of the stream More... | |
| ConstNodeRef | cdocref (id_type i) const |
| get the i-th document of the stream More... | |
| NodeRef | operator[] (csubstr key) |
| find a root child (ie child of root) by name, return it as a NodeRef More... | |
| ConstNodeRef | operator[] (csubstr key) const |
| find a root child (ie child of root) by name, return it as a NodeRef More... | |
| NodeRef | operator[] (id_type i) |
find a root child (ie child of root) by index: return the root node's i-th child as a NodeRef More... | |
| ConstNodeRef | operator[] (id_type i) const |
find a root child (ie child of root) by index: return the root node's i-th child as a NodeRef More... | |
node property getters | |
| NodeType | type (id_type node) const |
| const char * | type_str (id_type node) const |
| csubstr const & | key (id_type node) const |
| csubstr const & | key_tag (id_type node) const |
| csubstr const & | key_ref (id_type node) const |
| csubstr const & | key_anchor (id_type node) const |
| NodeScalar const & | keysc (id_type node) const |
| csubstr const & | val (id_type node) const |
| csubstr const & | val_tag (id_type node) const |
| csubstr const & | val_ref (id_type node) const |
| csubstr const & | val_anchor (id_type node) const |
| NodeScalar const & | valsc (id_type node) const |
node type predicates | |
| bool | type_has_any (id_type node, NodeType_e bits) const |
| bool | type_has_all (id_type node, NodeType_e bits) const |
| bool | type_has_none (id_type node, NodeType_e bits) const |
| bool | is_stream (id_type node) const |
| bool | is_doc (id_type node) const |
| bool | is_container (id_type node) const |
| bool | is_map (id_type node) const |
| bool | is_seq (id_type node) const |
| bool | has_key (id_type node) const |
| bool | has_val (id_type node) const |
| bool | is_val (id_type node) const |
| bool | is_keyval (id_type node) const |
| bool | has_key_tag (id_type node) const |
| bool | has_val_tag (id_type node) const |
| bool | has_key_anchor (id_type node) const |
| bool | has_val_anchor (id_type node) const |
| bool | has_anchor (id_type node) const |
| bool | is_key_ref (id_type node) const |
| bool | is_val_ref (id_type node) const |
| bool | is_ref (id_type node) const |
| bool | parent_is_seq (id_type node) const |
| bool | parent_is_map (id_type node) const |
| bool | has_anchor (id_type node, csubstr a) const |
| true when the node has an anchor named a More... | |
| bool | key_is_null (id_type node) const |
| true if the node key is empty, or its scalar verifies scalar_is_null(). More... | |
| bool | val_is_null (id_type node) const |
| true if the node val is empty, or its scalar verifies scalar_is_null(). More... | |
| bool | is_key_unfiltered (id_type node) const |
| true if the key was a scalar requiring filtering and was left unfiltered during the parsing (see ParserOptions) More... | |
| bool | is_val_unfiltered (id_type node) const |
| true if the val was a scalar requiring filtering and was left unfiltered during the parsing (see ParserOptions) More... | |
| bool | is_key_anchor (id_type node) const |
| bool | is_val_anchor (id_type node) const |
| bool | is_anchor (id_type node) const |
| bool | is_anchor_or_ref (id_type node) const |
hierarchy getters | |
| id_type | parent (id_type node) const |
| id_type | prev_sibling (id_type node) const |
| id_type | next_sibling (id_type node) const |
| id_type | num_children (id_type node) const |
| O(num_children) More... | |
| id_type | child_pos (id_type node, id_type ch) const |
| id_type | first_child (id_type node) const |
| id_type | last_child (id_type node) const |
| id_type | child (id_type node, id_type pos) const |
| id_type | find_child (id_type node, csubstr const &key) const |
| id_type | num_siblings (id_type node) const |
| O(num_siblings) More... | |
| id_type | num_other_siblings (id_type node) const |
| does not count with this More... | |
| id_type | sibling_pos (id_type node, id_type sib) const |
| id_type | first_sibling (id_type node) const |
| id_type | last_sibling (id_type node) const |
| id_type | sibling (id_type node, id_type pos) const |
| id_type | find_sibling (id_type node, csubstr const &key) const |
| id_type | doc (id_type i) const |
gets the i document node index. More... | |
| id_type | depth_asc (id_type node) const |
| O(log(num_tree_nodes)) get the ascending depth of the node: number of levels between root and node. More... | |
| id_type | depth_desc (id_type node) const |
| O(num_tree_nodes) get the descending depth of the node: number of levels between node and deepest child. More... | |
node style predicates and modifiers. see the corresponding predicate in NodeType | |
| bool | is_container_styled (id_type node) const |
| bool | is_block (id_type node) const |
| bool | is_flow_sl (id_type node) const |
| bool | is_flow_ml (id_type node) const |
| bool | is_flow (id_type node) const |
| bool | is_key_styled (id_type node) const |
| bool | is_val_styled (id_type node) const |
| bool | is_key_literal (id_type node) const |
| bool | is_val_literal (id_type node) const |
| bool | is_key_folded (id_type node) const |
| bool | is_val_folded (id_type node) const |
| bool | is_key_squo (id_type node) const |
| bool | is_val_squo (id_type node) const |
| bool | is_key_dquo (id_type node) const |
| bool | is_val_dquo (id_type node) const |
| bool | is_key_plain (id_type node) const |
| bool | is_val_plain (id_type node) const |
| bool | is_key_quoted (id_type node) const |
| bool | is_val_quoted (id_type node) const |
| bool | is_quoted (id_type node) const |
| NodeType | key_style (id_type node) const |
| NodeType | val_style (id_type node) const |
| void | set_container_style (id_type node, NodeType_e style) |
| void | set_key_style (id_type node, NodeType_e style) |
| void | set_val_style (id_type node, NodeType_e style) |
| void | clear_style (id_type node, bool recurse=false) |
| void | set_style_conditionally (id_type node, NodeType type_mask, NodeType rem_style_flags, NodeType add_style_flags, bool recurse=false) |
node type modifiers | |
| void | to_keyval (id_type node, csubstr key, csubstr val, type_bits more_flags=0) |
| void | to_map (id_type node, csubstr key, type_bits more_flags=0) |
| void | to_seq (id_type node, csubstr key, type_bits more_flags=0) |
| void | to_val (id_type node, csubstr val, type_bits more_flags=0) |
| void | to_map (id_type node, type_bits more_flags=0) |
| void | to_seq (id_type node, type_bits more_flags=0) |
| void | to_doc (id_type node, type_bits more_flags=0) |
| void | to_stream (id_type node, type_bits more_flags=0) |
| void | set_key (id_type node, csubstr key) |
| void | set_val (id_type node, csubstr val) |
| void | set_key_tag (id_type node, csubstr tag) |
| void | set_val_tag (id_type node, csubstr tag) |
| void | set_key_anchor (id_type node, csubstr anchor) |
| void | set_val_anchor (id_type node, csubstr anchor) |
| void | set_key_ref (id_type node, csubstr ref) |
| void | set_val_ref (id_type node, csubstr ref) |
| void | rem_key_anchor (id_type node) |
| void | rem_val_anchor (id_type node) |
| void | rem_key_ref (id_type node) |
| void | rem_val_ref (id_type node) |
| void | rem_anchor_ref (id_type node) |
tree modifiers | |
| void | reorder () |
| reorder the tree in memory so that all the nodes are stored in a linear sequence when visited in depth-first order. More... | |
anchors and references/aliases | |
| void | resolve (ReferenceResolver *rr, bool clear_anchors=true) |
| Resolve references (aliases <- anchors), by forwarding to ReferenceResolver::resolve(); refer to ReferenceResolver::resolve() for further details. More... | |
| void | resolve (bool clear_anchors=true) |
| Resolve references (aliases <- anchors), by forwarding to ReferenceResolver::resolve(); refer to ReferenceResolver::resolve() for further details. More... | |
modifying hierarchy | |
| id_type | insert_child (id_type parent, id_type after) |
create and insert a new child of parent. More... | |
| id_type | prepend_child (id_type parent) |
create and insert a node as the first child of parent More... | |
| id_type | append_child (id_type parent) |
create and insert a node as the last child of parent More... | |
| id_type | _append_child__unprotected (id_type parent) |
| id_type | insert_sibling (id_type node, id_type after) |
| create and insert a new sibling of n. insert after "after" More... | |
| id_type | prepend_sibling (id_type node) |
create and insert a node as the first node of parent More... | |
| id_type | append_sibling (id_type node) |
| void | remove (id_type node) |
| remove an entire branch at once: ie remove the children and the node itself More... | |
| void | remove_children (id_type node) |
| remove all the node's children, but keep the node itself More... | |
| bool | change_type (id_type node, NodeType type) |
change the type of the node to one of MAP, SEQ or VAL. More... | |
| bool | change_type (id_type node, type_bits type) |
| void | move (id_type node, id_type after) |
| change the node's position in the parent More... | |
| void | move (id_type node, id_type new_parent, id_type after) |
| change the node's parent and position More... | |
| id_type | move (Tree *src, id_type node, id_type new_parent, id_type after) |
| change the node's parent and position to a different tree More... | |
| void | set_root_as_stream () |
| ensure the first node is a stream. More... | |
| id_type | duplicate (id_type node, id_type new_parent, id_type after) |
| recursively duplicate a node from this tree into a new parent, placing it after one of its children More... | |
| id_type | duplicate (Tree const *src, id_type node, id_type new_parent, id_type after) |
| recursively duplicate a node from a different tree into a new parent, placing it after one of its children More... | |
| id_type | duplicate_children (id_type node, id_type parent, id_type after) |
| recursively duplicate the node's children (but not the node) More... | |
| id_type | duplicate_children (Tree const *src, id_type node, id_type parent, id_type after) |
| recursively duplicate the node's children (but not the node), where the node is from a different tree More... | |
| id_type | duplicate_children_no_rep (id_type node, id_type parent, id_type after) |
| duplicate the node's children (but not the node) in a new parent, but omit repetitions where a duplicated node has the same key (in maps) or value (in seqs). More... | |
| id_type | duplicate_children_no_rep (Tree const *src, id_type node, id_type parent, id_type after) |
| void | duplicate_contents (id_type node, id_type where) |
| void | duplicate_contents (Tree const *src, id_type node, id_type where) |
| void | merge_with (Tree const *src, id_type src_node=NONE, id_type dst_root=NONE) |
internal string arena | |
| size_t | arena_size () const |
| get the current size of the tree's internal arena More... | |
| size_t | arena_capacity () const |
| get the current capacity of the tree's internal arena More... | |
| size_t | arena_slack () const |
| get the current slack of the tree's internal arena More... | |
| size_t | arena_pos () const |
| csubstr | arena () const |
| get the current arena More... | |
| substr | arena () |
| get the current arena More... | |
| bool | in_arena (csubstr s) const |
| return true if the given substring is part of the tree's string arena More... | |
| template<class T > | |
| csubstr | to_arena (T const &a) |
| serialize the given variable to the tree's arena, growing it as needed to accomodate the serialization. More... | |
| substr | copy_to_arena (csubstr s) |
| copy the given string to the tree's arena, growing the arena by the required size. More... | |
| substr | alloc_arena (size_t sz) |
| grow the tree's string arena by the given size and return a substr of the added portion More... | |
| void | reserve_arena (size_t arena_cap=RYML_DEFAULT_TREE_ARENA_CAPACITY) |
| ensure the tree's internal string arena is at least the given capacity More... | |
lookup | |
| lookup_result | lookup_path (csubstr path, id_type start=NONE) const |
| for example foo.bar[0].baz More... | |
| id_type | lookup_path_or_modify (csubstr default_value, csubstr path, id_type start=NONE) |
defaulted lookup: lookup path; if the lookup fails, recursively modify the tree so that the corresponding lookup_path() would return the default value. More... | |
| id_type | lookup_path_or_modify (Tree const *src, id_type src_node, csubstr path, id_type start=NONE) |
defaulted lookup: lookup path; if the lookup fails, recursively modify the tree so that the corresponding lookup_path() would return the branch src_node (from the tree src). More... | |
Public Attributes | |
| NodeData * | m_buf |
| id_type | m_cap |
| id_type | m_size |
| id_type | m_free_head |
| id_type | m_free_tail |
| substr | m_arena |
| size_t | m_arena_pos |
| Callbacks | m_callbacks |
| TagDirective | m_tag_directives [RYML_MAX_TAG_DIRECTIVES] |
tag directives | |
| typedef TagDirective const * | tag_directive_const_iterator |
| typedef c4::yml::TagDirectiveRange | TagDirectiveProxy |
| void | resolve_tags () |
| void | normalize_tags () |
| void | normalize_tags_long () |
| id_type | num_tag_directives () const |
| bool | add_tag_directive (csubstr directive) |
| id_type | add_tag_directive (TagDirective const &td) |
| void | clear_tag_directives () |
| size_t | resolve_tag (substr output, csubstr tag, id_type node_id) const |
| resolve the given tag, appearing at node_id. More... | |
| csubstr | resolve_tag_sub (substr output, csubstr tag, id_type node_id) const |
| TagDirective const * | begin_tag_directives () const |
| TagDirective const * | end_tag_directives () const |
| c4::yml::TagDirectiveRange | tag_directives () const |
hierarchy predicates | |
| bool | is_root (id_type node) const |
| bool | has_parent (id_type node) const |
| bool | is_ancestor (id_type node, id_type ancestor) const |
| true when ancestor is parent or parent of a parent of node More... | |
| bool | empty (id_type node) const |
| true when key and val are empty, and has no children More... | |
| bool | has_child (id_type node, id_type ch) const |
true if node has a child with id ch More... | |
| bool | has_child (id_type node, csubstr key) const |
true if node has a child with key key More... | |
| bool | has_children (id_type node) const |
true if node has any children key More... | |
| bool | has_sibling (id_type node, id_type sib) const |
true if node has a sibling with id sib More... | |
| bool | has_sibling (id_type node, csubstr key) const |
| true if one of the node's siblings has the given key More... | |
| bool | has_other_siblings (id_type node) const |
| true if node is not a single child More... | |
| static bool | has_siblings (id_type) |
locations | |
| Location | location (Parser const &p, id_type node) const |
| Get the location of a node from the parse used to parse this tree. More... | |
| typedef TagDirective const* c4::yml::Tree::tag_directive_const_iterator |
|
inline |
Definition at line 251 of file tree.hpp.
| c4::yml::Tree::Tree | ( | Callbacks const & | cb | ) |
Definition at line 118 of file tree.cpp.
|
inline |
Definition at line 253 of file tree.hpp.
Definition at line 123 of file tree.cpp.
References arena_capacity(), reserve(), and reserve_arena().
| c4::yml::Tree::Tree | ( | Tree const & | that | ) |
|
noexcept |
| void c4::yml::Tree::reserve | ( | id_type | node_capacity = RYML_DEFAULT_TREE_CAPACITY | ) |
Definition at line 294 of file tree.cpp.
References m_buf, m_callbacks, m_cap, m_free_head, m_free_tail, c4::yml::NodeData::m_next_sibling, c4::yml::NodeData::m_prev_sibling, m_size, and c4::yml::NONE.
| void c4::yml::Tree::clear | ( | ) |
clear the tree and zero every node
Definition at line 332 of file tree.cpp.
References m_buf, m_callbacks, m_cap, m_free_head, m_free_tail, m_size, m_tag_directives, c4::yml::NONE, and RYML_MAX_TAG_DIRECTIVES.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
get the index of a node belonging to this tree. n can be nullptr, in which case NONE is returned
Definition at line 297 of file tree.hpp.
References c4::yml::NONE.
get a pointer to a node's NodeData. i can be NONE, in which case a nullptr is returned
Definition at line 307 of file tree.hpp.
References c4::yml::NONE.
get a pointer to a node's NodeData. i can be NONE, in which case a nullptr is returned.
Definition at line 316 of file tree.hpp.
References c4::yml::NONE.
An if-less form of get() that demands a valid node index. This function is implementation only; use at your own risk.
Definition at line 326 of file tree.hpp.
References c4::yml::NONE.
An if-less form of get() that demands a valid node index. This function is implementation only; use at your own risk.
Definition at line 329 of file tree.hpp.
References c4::yml::NONE.
|
inline |
| ConstNodeRef c4::yml::Tree::ref | ( | id_type | node | ) | const |
| ConstNodeRef c4::yml::Tree::cref | ( | id_type | node | ) | const |
| NodeRef c4::yml::Tree::rootref | ( | ) |
Get the root as a NodeRef.
Definition at line 55 of file tree.cpp.
| ConstNodeRef c4::yml::Tree::rootref | ( | ) | const |
Get the root as a ConstNodeRef.
| ConstNodeRef c4::yml::Tree::crootref | ( | ) | const |
Get the root as a ConstNodeRef.
get the i-th document of the stream
i is NOT the node id, but the doc position within the stream Definition at line 103 of file tree.cpp.
| ConstNodeRef c4::yml::Tree::docref | ( | id_type | i | ) | const |
get the i-th document of the stream
i is NOT the node id, but the doc position within the stream Definition at line 107 of file tree.cpp.
| ConstNodeRef c4::yml::Tree::cdocref | ( | id_type | i | ) | const |
| NodeRef c4::yml::Tree::operator[] | ( | csubstr | key | ) |
find a root child (ie child of root) by name, return it as a NodeRef
Definition at line 85 of file tree.cpp.
References c4::yml::key().
| ConstNodeRef c4::yml::Tree::operator[] | ( | csubstr | key | ) | const |
| ConstNodeRef c4::yml::Tree::operator[] | ( | id_type | i | ) | const |
Definition at line 379 of file tree.hpp.
|
inline |
Definition at line 380 of file tree.hpp.
|
inline |
|
inline |
Definition at line 383 of file tree.hpp.
|
inline |
Definition at line 384 of file tree.hpp.
|
inline |
Definition at line 385 of file tree.hpp.
|
inline |
|
inline |
|
inline |
Definition at line 389 of file tree.hpp.
|
inline |
Definition at line 390 of file tree.hpp.
|
inline |
Definition at line 391 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 423 of file tree.hpp.
|
inline |
Definition at line 424 of file tree.hpp.
|
inline |
|
inline |
true if the node key is empty, or its scalar verifies scalar_is_null().
Definition at line 432 of file tree.hpp.
References c4::yml::scalar_is_null().
|
inline |
true if the node val is empty, or its scalar verifies scalar_is_null().
Definition at line 436 of file tree.hpp.
References c4::yml::scalar_is_null().
|
inline |
true if the key was a scalar requiring filtering and was left unfiltered during the parsing (see ParserOptions)
Definition at line 440 of file tree.hpp.
|
inline |
true if the val was a scalar requiring filtering and was left unfiltered during the parsing (see ParserOptions)
Definition at line 443 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 457 of file tree.hpp.
References c4::yml::NONE.
|
inline |
true when ancestor is parent or parent of a parent of node
Definition at line 1303 of file tree.cpp.
References m_callbacks, c4::yml::NONE, and parent().
|
inline |
true when key and val are empty, and has no children
Definition at line 465 of file tree.hpp.
References c4::yml::VAL.
|
inline |
true if node has a child with key key
Definition at line 470 of file tree.hpp.
References c4::yml::key(), and c4::yml::NONE.
|
inline |
true if node has any children key
Definition at line 472 of file tree.hpp.
References c4::yml::NONE.
|
inline |
true if one of the node's siblings has the given key
Definition at line 477 of file tree.hpp.
References c4::yml::key(), and c4::yml::NONE.
|
inline |
true if node is not a single child
Definition at line 479 of file tree.hpp.
References c4::yml::NodeData::m_first_child, c4::yml::NodeData::m_last_child, c4::yml::NodeData::m_parent, and c4::yml::NONE.
|
inlinestatic |
O(num_children)
Definition at line 1198 of file tree.cpp.
References first_child(), next_sibling(), and c4::yml::NONE.
Definition at line 1218 of file tree.cpp.
References first_child(), m_callbacks, next_sibling(), and c4::yml::NONE.
Definition at line 1206 of file tree.cpp.
References first_child(), m_callbacks, next_sibling(), and c4::yml::NONE.
Definition at line 1243 of file tree.cpp.
References _p(), first_child(), get(), is_map(), m_callbacks, c4::yml::NodeData::m_key, next_sibling(), c4::yml::NONE, and c4::yml::NodeScalar::scalar.
O(num_siblings)
counts with this
Definition at line 514 of file tree.hpp.
does not count with this
Definition at line 516 of file tree.hpp.
O(log(num_tree_nodes)) get the ascending depth of the node: number of levels between root and node.
Definition at line 1291 of file tree.cpp.
References is_root(), m_callbacks, c4::yml::NONE, and parent().
O(num_tree_nodes) get the descending depth of the node: number of levels between node and deepest child.
Definition at line 1285 of file tree.cpp.
References m_callbacks, and c4::yml::NONE.
|
inline |
Definition at line 535 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 560 of file tree.hpp.
|
inline |
Definition at line 561 of file tree.hpp.
|
inline |
Definition at line 562 of file tree.hpp.
| void c4::yml::Tree::clear_style | ( | id_type | node, |
| bool | recurse = false |
||
| ) |
Definition at line 1392 of file tree.cpp.
References _p(), child(), next_sibling(), and c4::yml::NONE.
| void c4::yml::Tree::set_style_conditionally | ( | id_type | node, |
| NodeType | type_mask, | ||
| NodeType | rem_style_flags, | ||
| NodeType | add_style_flags, | ||
| bool | recurse = false |
||
| ) |
Definition at line 1402 of file tree.cpp.
References _p(), child(), next_sibling(), and c4::yml::NONE.
Definition at line 1328 of file tree.cpp.
References _p(), has_children(), key(), c4::yml::KEYVAL, m_callbacks, c4::yml::NodeData::m_key, c4::yml::NodeData::m_val, c4::yml::NONE, parent(), parent_is_map(), and val().
Definition at line 1346 of file tree.cpp.
References _p(), c4::yml::NodeScalar::clear(), has_children(), c4::yml::KEY, key(), m_callbacks, c4::yml::NodeData::m_key, c4::yml::NodeData::m_val, c4::yml::MAP, c4::yml::NONE, parent(), and parent_is_map().
Definition at line 1364 of file tree.cpp.
References _p(), c4::yml::NodeScalar::clear(), has_children(), c4::yml::KEY, key(), m_callbacks, c4::yml::NodeData::m_key, c4::yml::NodeData::m_val, c4::yml::NONE, parent(), parent_is_map(), and c4::yml::SEQ.
Definition at line 1319 of file tree.cpp.
References _p(), c4::yml::NodeScalar::clear(), has_children(), m_callbacks, c4::yml::NodeData::m_key, c4::yml::NodeData::m_val, c4::yml::NONE, parent(), parent_is_map(), c4::yml::VAL, and val().
Definition at line 1337 of file tree.cpp.
References _p(), c4::yml::NodeScalar::clear(), has_children(), m_callbacks, c4::yml::NodeData::m_key, c4::yml::NodeData::m_val, c4::yml::MAP, c4::yml::NONE, parent(), and parent_is_map().
Definition at line 1355 of file tree.cpp.
References _p(), c4::yml::NodeScalar::clear(), has_children(), m_callbacks, c4::yml::NodeData::m_key, c4::yml::NodeData::m_val, c4::yml::NONE, parent(), parent_is_seq(), and c4::yml::SEQ.
Definition at line 1373 of file tree.cpp.
References _p(), c4::yml::NodeScalar::clear(), c4::yml::DOC, has_children(), m_callbacks, c4::yml::NodeData::m_key, and c4::yml::NodeData::m_val.
Definition at line 1381 of file tree.cpp.
References _p(), c4::yml::NodeScalar::clear(), has_children(), m_callbacks, c4::yml::NodeData::m_key, c4::yml::NodeData::m_val, and c4::yml::STREAM.
|
inline |
Definition at line 586 of file tree.hpp.
References c4::yml::key().
|
inline |
|
inline |
Definition at line 589 of file tree.hpp.
References c4::yml::KEYTAG.
|
inline |
Definition at line 590 of file tree.hpp.
References c4::yml::VALTAG.
|
inline |
Definition at line 592 of file tree.hpp.
References c4::yml::KEYANCH.
|
inline |
Definition at line 593 of file tree.hpp.
References c4::yml::VALANCH.
|
inline |
Definition at line 594 of file tree.hpp.
References c4::yml::KEY, and c4::yml::KEYREF.
|
inline |
Definition at line 595 of file tree.hpp.
References c4::yml::VAL, and c4::yml::VALREF.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 601 of file tree.hpp.
References c4::yml::KEYANCH, c4::yml::KEYREF, c4::yml::VALANCH, and c4::yml::VALREF.
| void c4::yml::Tree::reorder | ( | ) |
| void c4::yml::Tree::resolve | ( | ReferenceResolver * | rr, |
| bool | clear_anchors = true |
||
| ) |
Resolve references (aliases <- anchors), by forwarding to ReferenceResolver::resolve(); refer to ReferenceResolver::resolve() for further details.
Definition at line 1188 of file tree.cpp.
References m_size.
| void c4::yml::Tree::resolve | ( | bool | clear_anchors = true | ) |
Resolve references (aliases <- anchors), by forwarding to ReferenceResolver::resolve(); refer to ReferenceResolver::resolve() for further details.
This overload uses a throwaway resolver object.
Definition at line 1180 of file tree.cpp.
| void c4::yml::Tree::resolve_tags | ( | ) |
Definition at line 1569 of file tree.cpp.
References arena_size(), empty(), reserve_arena(), and root_id().
| void c4::yml::Tree::normalize_tags | ( | ) |
| void c4::yml::Tree::normalize_tags_long | ( | ) |
| id_type c4::yml::Tree::num_tag_directives | ( | ) | const |
| bool c4::yml::Tree::add_tag_directive | ( | csubstr | directive | ) |
| id_type c4::yml::Tree::add_tag_directive | ( | TagDirective const & | td | ) |
Definition at line 1437 of file tree.cpp.
References c4::yml::TagDirective::handle, m_callbacks, m_tag_directives, c4::yml::npos, num_tag_directives(), c4::yml::TagDirective::prefix, and RYML_MAX_TAG_DIRECTIVES.
| void c4::yml::Tree::clear_tag_directives | ( | ) |
Definition at line 1431 of file tree.cpp.
References m_tag_directives.
| size_t c4::yml::Tree::resolve_tag | ( | substr | output, |
| csubstr | tag, | ||
| id_type | node_id | ||
| ) | const |
resolve the given tag, appearing at node_id.
Write the result into output.
Definition at line 1482 of file tree.cpp.
References c4::yml::TagDirective::handle, c4::yml::is_custom_tag(), m_callbacks, m_tag_directives, c4::yml::TagDirective::next_node_id, RYML_MAX_TAG_DIRECTIVES, and c4::yml::TagDirective::transform().
|
inline |
Definition at line 653 of file tree.hpp.
|
inline |
|
inline |
|
inline |
Definition at line 661 of file tree.hpp.
create and insert a new child of parent.
insert after the (to-be) sibling after, which must be a child of parent. To insert as the first child, set after to NONE
Definition at line 676 of file tree.hpp.
References c4::yml::NONE.
create and insert a node as the first child of parent
Definition at line 686 of file tree.hpp.
References c4::yml::NONE.
create and insert a new sibling of n. insert after "after"
create and insert a node as the first node of parent
Definition at line 714 of file tree.hpp.
Definition at line 715 of file tree.hpp.
|
inline |
remove an entire branch at once: ie remove the children and the node itself
Definition at line 720 of file tree.hpp.
| void c4::yml::Tree::remove_children | ( | id_type | node | ) |
remove all the node's children, but keep the node itself
Definition at line 903 of file tree.cpp.
References get(), m_callbacks, c4::yml::NodeData::m_first_child, c4::yml::NodeData::m_next_sibling, and c4::yml::NONE.
change the type of the node to one of MAP, SEQ or VAL.
type must have one and only one of MAP,SEQ,VAL; type may possibly have KEY, but if it does, then the node must also have KEY. Changing to the same type is a no-op. Otherwise, changing to a different type will initialize the node with an empty value of the desired type: changing to VAL will initialize with a null scalar (~), changing to MAP will initialize with an empty map ({}), and changing to SEQ will initialize with an empty seq ([]).
Definition at line 925 of file tree.cpp.
References _p(), c4::yml::CONTAINER_STYLE, c4::yml::NodeType::has_key(), has_key(), c4::yml::NodeType::is_map(), is_map(), c4::yml::NodeType::is_seq(), is_seq(), c4::yml::NodeType::is_val(), is_val(), c4::yml::KEY_STYLE, m_callbacks, c4::yml::NodeData::m_type, c4::yml::MAP, remove_children(), c4::yml::SEQ, type(), c4::yml::VAL, and c4::yml::VAL_STYLE.
Definition at line 740 of file tree.hpp.
change the node's position in the parent
Definition at line 822 of file tree.cpp.
References has_sibling(), is_root(), m_callbacks, c4::yml::NONE, and parent().
change the node's parent and position
Definition at line 835 of file tree.cpp.
References is_root(), m_callbacks, and c4::yml::NONE.
change the node's parent and position to a different tree
Definition at line 848 of file tree.cpp.
References duplicate(), m_callbacks, c4::yml::NONE, and remove().
| void c4::yml::Tree::set_root_as_stream | ( | ) |
ensure the first node is a stream.
Eg, change this tree
DOCMAP MAP KEYVAL KEYVAL SEQ VAL
to
STREAM DOCMAP MAP KEYVAL KEYVAL SEQ VAL
If the root is already a stream, this is a no-op.
Definition at line 860 of file tree.cpp.
References _p(), c4::yml::NodeType::add(), append_child(), c4::yml::DOC, first_child(), has_children(), has_key(), is_container(), is_stream(), m_callbacks, c4::yml::NodeData::m_type, move(), next_sibling(), c4::yml::NONE, c4::yml::NodeType::rem(), root_id(), c4::yml::SEQ, and c4::yml::STREAM.
| id_type c4::yml::Tree::duplicate | ( | Tree const * | src, |
| id_type | node, | ||
| id_type | new_parent, | ||
| id_type | after | ||
| ) |
recursively duplicate a node from a different tree into a new parent, placing it after one of its children
Definition at line 949 of file tree.cpp.
References _claim(), duplicate_children(), is_root(), m_callbacks, c4::yml::NONE, and parent().
| id_type c4::yml::Tree::duplicate_children | ( | Tree const * | src, |
| id_type | node, | ||
| id_type | parent, | ||
| id_type | after | ||
| ) |
recursively duplicate the node's children (but not the node), where the node is from a different tree
Definition at line 971 of file tree.cpp.
References duplicate(), first_child(), has_child(), m_callbacks, next_sibling(), c4::yml::NONE, and parent().
duplicate the node's children (but not the node) in a new parent, but omit repetitions where a duplicated node has the same key (in maps) or value (in seqs).
If one of the duplicated children has the same key (in maps) or value (in seqs) as one of the parent's children, the one that is placed closest to the end will prevail.
Definition at line 1003 of file tree.cpp.
References parent().
| id_type c4::yml::Tree::duplicate_children_no_rep | ( | Tree const * | src, |
| id_type | node, | ||
| id_type | parent, | ||
| id_type | after | ||
| ) |
Definition at line 1008 of file tree.cpp.
References duplicate(), first_child(), has_child(), is_ancestor(), is_map(), is_seq(), key(), m_callbacks, move(), next_sibling(), c4::yml::NONE, parent(), prev_sibling(), and remove().
Definition at line 988 of file tree.cpp.
Definition at line 993 of file tree.cpp.
References duplicate_children(), last_child(), m_callbacks, and c4::yml::NONE.
| void c4::yml::Tree::merge_with | ( | Tree const * | src, |
| id_type | src_node = NONE, |
||
| id_type | dst_root = NONE |
||
| ) |
Definition at line 1103 of file tree.cpp.
References _p(), append_child(), find_child(), first_child(), has_children(), has_key(), has_val(), is_keyval(), is_map(), is_seq(), is_val(), key(), m_callbacks, c4::yml::NodeData::m_type, next_sibling(), c4::yml::NONE, remove_children(), root_id(), c4::yml::STYLE, to_map(), to_seq(), and c4::yml::VAL_STYLE.
Get the location of a node from the parse used to parse this tree.
Definition at line 1918 of file tree.cpp.
References c4::yml::ParseEngine< EventHandler >::source(), and c4::yml::ParseEngine< EventHandler >::val_location().
|
inline |
|
inline |
|
inline |
get the current slack of the tree's internal arena
Definition at line 847 of file tree.hpp.
References c4::yml::NONE.
|
inline |
|
inline |
|
inline |
|
inline |
serialize the given variable to the tree's arena, growing it as needed to accomodate the serialization.
Definition at line 878 of file tree.hpp.
References c4::yml::serialize_to_arena().
|
inline |
copy the given string to the tree's arena, growing the arena by the required size.
Definition at line 899 of file tree.hpp.
References c4::yml::NONE.
|
inline |
grow the tree's string arena by the given size and return a substr of the added portion
Definition at line 928 of file tree.hpp.
|
inline |
ensure the tree's internal string arena is at least the given capacity
Definition at line 940 of file tree.hpp.
References c4::yml::NONE.
| Tree::lookup_result c4::yml::Tree::lookup_path | ( | csubstr | path, |
| id_type | start = NONE |
||
| ) | const |
for example foo.bar[0].baz
Definition at line 1616 of file tree.cpp.
References c4::yml::Tree::lookup_result::closest, c4::yml::NONE, root_id(), and c4::yml::Tree::lookup_result::target.
| id_type c4::yml::Tree::lookup_path_or_modify | ( | csubstr | default_value, |
| csubstr | path, | ||
| id_type | start = NONE |
||
| ) |
defaulted lookup: lookup path; if the lookup fails, recursively modify the tree so that the corresponding lookup_path() would return the default value.
Definition at line 1629 of file tree.cpp.
References key(), parent_is_map(), to_keyval(), and to_val().
| id_type c4::yml::Tree::lookup_path_or_modify | ( | Tree const * | src, |
| id_type | src_node, | ||
| csubstr | path, | ||
| id_type | start = NONE |
||
| ) |
defaulted lookup: lookup path; if the lookup fails, recursively modify the tree so that the corresponding lookup_path() would return the branch src_node (from the tree src).
Definition at line 1639 of file tree.cpp.
References merge_with().
| id_type c4::yml::Tree::_claim | ( | ) |
Definition at line 417 of file tree.cpp.
References child(), m_buf, m_callbacks, m_cap, m_free_head, m_free_tail, m_size, c4::yml::NONE, and reserve().
| TagDirective c4::yml::Tree::m_tag_directives[RYML_MAX_TAG_DIRECTIVES] |