|
rapidyaml
0.12.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 | 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... | |
| id_type | doc (id_type i) const |
gets the i document node index. More... | |
| id_type | ancestor_doc (id_type node) const |
| get the document which is a parent document of node i, or the root if the tree is not a stream 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 |
| TagDirectives | m_tag_directives |
tags and tag directives | |
| typedef TagDirective const * | tag_directive_const_iterator |
| typedef c4::yml::TagDirectiveRange | TagDirectiveProxy |
| void | resolve_tags (TagCache &cache, bool all=true) |
Resolve tags in the tree such as !!str -> <tag:yaml.org,2002:str>, !foo -> <!foo> and custom tags as well, ie tags of the form !handle!tag for which there is a corresponding TAG directive. More... | |
| void | normalize_tags () |
| void | normalize_tags_long () |
| id_type | num_tag_directives () const |
| void | add_tag_directive (csubstr handle, csubstr prefix, id_type id) |
| 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 |
| Wrapper for Tree::resolve_tag(), returning a substring. More... | |
| 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 254 of file tree.hpp.
| c4::yml::Tree::Tree | ( | Callbacks const & | cb | ) |
Definition at line 119 of file tree.cpp.
|
inline |
Definition at line 256 of file tree.hpp.
Definition at line 124 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 292 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 330 of file tree.cpp.
References c4::yml::TagDirectives::clear(), m_buf, m_callbacks, m_cap, m_free_head, m_free_tail, m_size, m_tag_directives, and c4::yml::NONE.
|
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 300 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 310 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 319 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.
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 332 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 56 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 104 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 108 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 86 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 382 of file tree.hpp.
|
inline |
Definition at line 383 of file tree.hpp.
|
inline |
|
inline |
Definition at line 386 of file tree.hpp.
|
inline |
Definition at line 387 of file tree.hpp.
|
inline |
Definition at line 388 of file tree.hpp.
|
inline |
|
inline |
|
inline |
Definition at line 392 of file tree.hpp.
|
inline |
Definition at line 393 of file tree.hpp.
|
inline |
Definition at line 394 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 426 of file tree.hpp.
|
inline |
Definition at line 427 of file tree.hpp.
|
inline |
|
inline |
true if the node key is empty, or its scalar verifies scalar_is_null().
Definition at line 435 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 439 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 443 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 446 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 460 of file tree.hpp.
References c4::yml::NONE.
|
inline |
true when ancestor is parent or parent of a parent of node
Definition at line 1318 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 468 of file tree.hpp.
References c4::yml::VAL.
|
inline |
true if node has a child with key key
Definition at line 473 of file tree.hpp.
References c4::yml::key(), and c4::yml::NONE.
|
inline |
true if node has any children key
Definition at line 475 of file tree.hpp.
References c4::yml::NONE.
|
inline |
true if one of the node's siblings has the given key
Definition at line 480 of file tree.hpp.
References c4::yml::key(), and c4::yml::NONE.
|
inline |
true if node is not a single child
Definition at line 482 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 1213 of file tree.cpp.
References first_child(), next_sibling(), and c4::yml::NONE.
Definition at line 1233 of file tree.cpp.
References first_child(), m_callbacks, next_sibling(), and c4::yml::NONE.
Definition at line 1221 of file tree.cpp.
References first_child(), m_callbacks, next_sibling(), and c4::yml::NONE.
Definition at line 1258 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 517 of file tree.hpp.
does not count with this
Definition at line 519 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 1306 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 1300 of file tree.cpp.
References m_callbacks, and c4::yml::NONE.
get the document which is a parent document of node i, or the root if the tree is not a stream
Definition at line 533 of file tree.hpp.
References c4::yml::NodeType::is_doc(), c4::yml::NodeData::m_parent, c4::yml::NodeData::m_type, and c4::yml::NONE.
|
inline |
Definition at line 553 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 578 of file tree.hpp.
|
inline |
Definition at line 579 of file tree.hpp.
|
inline |
Definition at line 580 of file tree.hpp.
| void c4::yml::Tree::clear_style | ( | id_type | node, |
| bool | recurse = false |
||
| ) |
Definition at line 1407 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 1417 of file tree.cpp.
References _p(), child(), next_sibling(), and c4::yml::NONE.
Definition at line 1343 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 1361 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 1379 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 1334 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 1352 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 1370 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 1388 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 1396 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 604 of file tree.hpp.
References c4::yml::key().
|
inline |
|
inline |
Definition at line 607 of file tree.hpp.
References c4::yml::KEYTAG.
|
inline |
Definition at line 608 of file tree.hpp.
References c4::yml::VALTAG.
|
inline |
Definition at line 610 of file tree.hpp.
References c4::yml::KEYANCH.
|
inline |
Definition at line 611 of file tree.hpp.
References c4::yml::VALANCH.
|
inline |
Definition at line 612 of file tree.hpp.
References c4::yml::KEY, and c4::yml::KEYREF.
|
inline |
Definition at line 613 of file tree.hpp.
References c4::yml::VAL, and c4::yml::VALREF.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 619 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 1203 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 1195 of file tree.cpp.
| void c4::yml::Tree::resolve_tags | ( | TagCache & | cache, |
| bool | all = true |
||
| ) |
Resolve tags in the tree such as !!str -> <tag:yaml.org,2002:str>, !foo -> <!foo> and custom tags as well, ie tags of the form !handle!tag for which there is a corresponding TAG directive.
| cache | an object of type TagCache to minimize memory usage by avoiding repeated instantiation of the resolved tags in the tree's arena. |
| all | if true, resolve all tags; if false resolve only custom tags, ie those that have a prefix such as !m!tag with a matching TAG directive |
Definition at line 1556 of file tree.cpp.
References callbacks(), empty(), and m_arena.
| void c4::yml::Tree::normalize_tags | ( | ) |
| void c4::yml::Tree::normalize_tags_long | ( | ) |
| id_type c4::yml::Tree::num_tag_directives | ( | ) | const |
Definition at line 1437 of file tree.cpp.
References m_tag_directives, and c4::yml::TagDirectives::size().
| void c4::yml::Tree::add_tag_directive | ( | csubstr | handle, |
| csubstr | prefix, | ||
| id_type | id | ||
| ) |
Definition at line 1447 of file tree.cpp.
References c4::yml::TagDirectives::add(), c4::yml::is_valid_tag_handle(), m_callbacks, and m_tag_directives.
| void c4::yml::Tree::clear_tag_directives | ( | ) |
Definition at line 1442 of file tree.cpp.
References c4::yml::TagDirectives::clear(), and 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 1459 of file tree.cpp.
References callbacks(), m_tag_directives, and c4::yml::TagDirectives::resolve().
|
inline |
Wrapper for Tree::resolve_tag(), returning a substring.
Definition at line 683 of file tree.hpp.
|
inline |
Definition at line 689 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 704 of file tree.hpp.
References c4::yml::NONE.
create and insert a node as the first child of parent
Definition at line 714 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 742 of file tree.hpp.
Definition at line 743 of file tree.hpp.
|
inline |
remove an entire branch at once: ie remove the children and the node itself
Definition at line 748 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 918 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 940 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 768 of file tree.hpp.
change the node's position in the parent
Definition at line 819 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 832 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 845 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 857 of file tree.cpp.
References _p(), c4::yml::NodeType::add(), append_child(), c4::yml::DOC, c4::yml::TagDirective::doc_id, first_child(), has_children(), has_key(), id(), is_container(), is_stream(), m_callbacks, m_cap, c4::yml::TagDirectives::m_directives, m_free_head, c4::yml::NodeData::m_parent, m_tag_directives, c4::yml::NodeData::m_type, c4::yml::MAP, move(), next_sibling(), c4::yml::NONE, c4::yml::NodeType::rem(), root_id(), c4::yml::SEQ, c4::yml::STREAM, type(), and c4::yml::VAL.
| 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 964 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 986 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 1018 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 1023 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 1003 of file tree.cpp.
Definition at line 1008 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 1118 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 1915 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 875 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 906 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 927 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 956 of file tree.hpp.
|
inline |
ensure the tree's internal string arena is at least the given capacity
Definition at line 968 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 1611 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 1624 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 1634 of file tree.cpp.
References merge_with().
| id_type c4::yml::Tree::_claim | ( | ) |
Definition at line 414 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().
| TagDirectives c4::yml::Tree::m_tag_directives |