|
rapidyaml
0.8.0
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=0) | |
| 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) |
| 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 () |
| Get the id of the root node. More... | |
| id_type | root_id () const |
| Get the id of the root node. 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 by name, return it as a NodeRef More... | |
| ConstNodeRef | operator[] (csubstr key) const |
| find a root child by name, return it as a NodeRef More... | |
| NodeRef | operator[] (id_type i) |
find a root child by index: return the root node's i-th child as a NodeRef More... | |
| ConstNodeRef | operator[] (id_type i) const |
find a root child 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 |
| 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) |
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... | |
| void | resolve (ReferenceResolver *rr) |
| Resolve references (aliases <- anchors) in the tree. More... | |
| void | resolve () |
| Resolve references using a throw-away resolver. 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... | |
| void | duplicate_contents (id_type node, id_type where) |
| void | duplicate_contents (Tree const *src, id_type node, id_type where) |
| 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 | merge_with (Tree const *src, id_type src_node=NONE, id_type dst_root=NONE) |
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 | 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) |
internal string arena | |
| size_t | arena_pos () const |
| get the current size of the tree's internal arena More... | |
| 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... | |
| 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 > | |
| auto | to_arena (T const &a) -> typename std::enable_if< std::is_floating_point< T >::value, csubstr >::type |
| serialize the given floating-point variable to the tree's arena, growing it as needed to accomodate the serialization. More... | |
| template<class T > | |
| auto | to_arena (T const &a) -> typename std::enable_if<!std::is_floating_point< T >::value, csubstr >::type |
| serialize the given non-floating-point variable to the tree's arena, growing it as needed to accomodate the serialization. More... | |
| csubstr | to_arena (csubstr a) |
| serialize the given csubstr to the tree's arena, growing the arena as needed to accomodate the serialization. More... | |
| csubstr | to_arena (const char *s) |
| substr | copy_to_arena (csubstr s) |
| copy the given substr to the tree's arena, growing it 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) |
| ensure the tree's internal string arena is at least the given capacity More... | |
| static csubstr | to_arena (std::nullptr_t) |
| typedef TagDirective const* c4::yml::Tree::tag_directive_const_iterator |
|
inline |
Definition at line 207 of file tree.hpp.
| c4::yml::Tree::Tree | ( | Callbacks const & | cb | ) |
Definition at line 84 of file tree.cpp.
|
inline |
Definition at line 209 of file tree.hpp.
Definition at line 97 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 | ) |
Definition at line 254 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.
Referenced by Tree(), _claim(), sample::sample_global_allocator(), sample::sample_parse_reuse_tree(), and sample::sample_parse_reuse_tree_and_parser().
| void c4::yml::Tree::clear | ( | ) |
clear the tree and zero every node
Definition at line 292 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.
Referenced by sample::sample_empty_null_values(), sample::sample_parse_reuse_tree(), and sample::sample_parse_reuse_tree_and_parser().
|
inline |
Definition at line 233 of file tree.hpp.
Referenced by sample::sample_empty_null_values(), and sample::sample_parse_reuse_tree().
|
inline |
Definition at line 235 of file tree.hpp.
Referenced by c4::yml::TagDirective::create_from_str(), c4::yml::Emitter< Writer >::emit_as(), c4::yml::emitrs_json(), c4::yml::emitrs_yaml(), normalize_tags(), normalize_tags_long(), and resolve_tags().
|
inline |
Definition at line 237 of file tree.hpp.
Referenced by c4::yml::TagDirective::create_from_str(), sample::sample_base64(), and sample::sample_quick_overview().
|
inline |
Definition at line 238 of file tree.hpp.
Referenced by c4::yml::Emitter< Writer >::emit_as(), and c4::yml::EventHandlerTree::reset().
|
inline |
|
inline |
Definition at line 241 of file tree.hpp.
Referenced by c4::yml::TagDirective::create_from_str(), c4::yml::Emitter< Writer >::emit_as(), c4::yml::emitrs_json(), c4::yml::emitrs_yaml(), c4::yml::parse_in_arena(), c4::yml::parse_in_place(), c4::yml::parse_json_in_arena(), c4::yml::parse_json_in_place(), c4::yml::EventHandlerTree::reset(), and sample::sample_quick_overview().
|
inline |
get the index of a node belonging to this tree. n can be nullptr, in which case NONE is returned
Definition at line 253 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 263 of file tree.hpp.
References c4::yml::NONE.
Referenced by find_child(), and remove_children().
get a pointer to a node's NodeData. i can be NONE, in which case a nullptr is returned.
Definition at line 272 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 282 of file tree.hpp.
References c4::yml::NONE.
Referenced by change_type(), find_child(), merge_with(), set_root_as_stream(), to_doc(), to_keyval(), to_map(), to_seq(), to_stream(), and to_val().
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 285 of file tree.hpp.
References c4::yml::NONE.
|
inline |
Get the id of the root node.
Definition at line 288 of file tree.hpp.
Referenced by c4::yml::Emitter< Writer >::emit_as(), c4::yml::emitrs_json(), c4::yml::emitrs_yaml(), lookup_path(), merge_with(), normalize_tags(), normalize_tags_long(), c4::yml::parse_in_arena(), c4::yml::parse_in_place(), c4::yml::parse_json_in_arena(), c4::yml::parse_json_in_place(), reorder(), resolve_tags(), sample::sample_docs(), sample::sample_quick_overview(), and set_root_as_stream().
|
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 21 of file tree.cpp.
Referenced by sample::sample_base64(), sample::sample_create_trees(), sample::sample_docs(), sample::sample_emit_style(), sample::sample_empty_null_values(), sample::sample_float_precision(), sample::sample_location_tracking(), sample::sample_parse_reuse_tree(), sample::sample_quick_overview(), sample::sample_std_types(), sample::sample_tags(), sample::sample_tree_arena(), sample::sample_user_container_types(), and sample::sample_user_scalar_types().
| ConstNodeRef c4::yml::Tree::rootref | ( | ) | const |
Get the root as a ConstNodeRef.
| ConstNodeRef c4::yml::Tree::crootref | ( | ) | const |
Get the root as a ConstNodeRef.
Definition at line 30 of file tree.cpp.
Referenced by sample::sample_iterate_trees(), sample::sample_parse_in_arena(), sample::sample_parse_in_place(), sample::sample_parse_reuse_tree(), and sample::sample_user_container_types().
get the i-th document of the stream
i is NOT the node id, but the doc position within the stream Definition at line 69 of file tree.cpp.
Referenced by sample::sample_docs().
| 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 73 of file tree.cpp.
| ConstNodeRef c4::yml::Tree::cdocref | ( | id_type | i | ) | const |
| NodeRef c4::yml::Tree::operator[] | ( | csubstr | key | ) |
find a root child by name, return it as a NodeRef
Definition at line 51 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 337 of file tree.hpp.
Referenced by change_type(), and c4::yml::TagDirective::create_from_str().
|
inline |
Definition at line 338 of file tree.hpp.
|
inline |
Definition at line 340 of file tree.hpp.
Referenced by duplicate_children_no_rep(), lookup_path_or_modify(), merge_with(), sample::sample_base64(), sample::sample_quick_overview(), sample::sample_tree_arena(), to_keyval(), to_map(), and to_seq().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 346 of file tree.hpp.
Referenced by sample::sample_base64(), sample::sample_docs(), sample::sample_tree_arena(), to_keyval(), and to_val().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 363 of file tree.hpp.
Referenced by c4::yml::TagDirective::create_from_str(), sample::sample_docs(), and set_root_as_stream().
|
inline |
|
inline |
|
inline |
Definition at line 366 of file tree.hpp.
Referenced by change_type(), duplicate_children_no_rep(), find_child(), merge_with(), c4::yml::EventHandlerTree::reset(), sample::sample_docs(), and sample::sample_quick_overview().
|
inline |
Definition at line 367 of file tree.hpp.
Referenced by change_type(), duplicate_children_no_rep(), merge_with(), sample::sample_docs(), and sample::sample_quick_overview().
|
inline |
Definition at line 368 of file tree.hpp.
Referenced by change_type(), merge_with(), c4::yml::EventHandlerTree::reset(), and set_root_as_stream().
|
inline |
|
inline |
Definition at line 370 of file tree.hpp.
Referenced by change_type(), merge_with(), and set_root_as_stream().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 382 of file tree.hpp.
Referenced by lookup_path_or_modify(), to_keyval(), to_map(), to_seq(), and to_val().
|
inline |
|
inline |
true if the node key is empty, or its scalar verifies scalar_is_null().
Definition at line 390 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 394 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 398 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 401 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 415 of file tree.hpp.
References c4::yml::NONE.
Referenced by c4::yml::TagDirective::create_from_str(), depth_asc(), duplicate(), move(), c4::yml::EventHandlerTree::reset(), and sample::sample_docs().
|
inline |
|
inline |
true when key and val are empty, and has no children
Definition at line 420 of file tree.hpp.
References c4::yml::VAL.
true if node has a child with id ch
Definition at line 423 of file tree.hpp.
Referenced by duplicate_children(), and duplicate_children_no_rep().
|
inline |
true if node has a child with key key
Definition at line 425 of file tree.hpp.
References c4::yml::key(), and c4::yml::NONE.
|
inline |
true if node has any children key
Definition at line 427 of file tree.hpp.
References c4::yml::NONE.
Referenced by merge_with(), set_root_as_stream(), to_doc(), to_keyval(), to_map(), to_seq(), to_stream(), and to_val().
|
inline |
true if one of the node's siblings has the given key
Definition at line 432 of file tree.hpp.
References c4::yml::key(), and c4::yml::NONE.
|
inline |
true if node is not a single child
Definition at line 434 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 |
Definition at line 454 of file tree.hpp.
Referenced by depth_asc(), duplicate(), duplicate_children(), duplicate_children_no_rep(), move(), c4::yml::EventHandlerTree::reset(), to_keyval(), to_map(), to_seq(), and to_val().
Definition at line 457 of file tree.hpp.
Referenced by child(), child_pos(), duplicate_children(), duplicate_children_no_rep(), find_child(), merge_with(), num_children(), sample::sample_docs(), sample::sample_quick_overview(), and set_root_as_stream().
O(num_children)
Definition at line 1131 of file tree.cpp.
References first_child(), next_sibling(), and c4::yml::NONE.
Referenced by sample::sample_docs().
Definition at line 1151 of file tree.cpp.
References first_child(), m_callbacks, next_sibling(), and c4::yml::NONE.
Definition at line 462 of file tree.hpp.
Referenced by child(), child_pos(), duplicate_children(), duplicate_children_no_rep(), find_child(), merge_with(), num_children(), sample::sample_docs(), sample::sample_quick_overview(), and set_root_as_stream().
Definition at line 1139 of file tree.cpp.
References first_child(), m_callbacks, next_sibling(), and c4::yml::NONE.
Referenced by _claim(), and sample::sample_docs().
Definition at line 1177 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.
Referenced by merge_with(), sample::sample_docs(), and sample::sample_quick_overview().
O(num_siblings)
counts with this
Definition at line 469 of file tree.hpp.
does not count with this
Definition at line 471 of file tree.hpp.
gets the i document node index.
requires that the root node is a stream.
Definition at line 478 of file tree.hpp.
Referenced by sample::sample_docs().
O(log(num_tree_nodes)) get the ascending depth of the node: number of levels between root and node.
Definition at line 1225 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 1219 of file tree.cpp.
References m_callbacks, and c4::yml::NONE.
|
inline |
Definition at line 490 of file tree.hpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 512 of file tree.hpp.
|
inline |
Definition at line 513 of file tree.hpp.
|
inline |
Definition at line 514 of file tree.hpp.
Definition at line 1249 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().
Referenced by lookup_path_or_modify().
Definition at line 1267 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().
Referenced by merge_with().
Definition at line 1285 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.
Referenced by merge_with().
Definition at line 1240 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().
Referenced by lookup_path_or_modify().
Definition at line 1258 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 1276 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 1294 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 1302 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 532 of file tree.hpp.
References c4::yml::key().
|
inline |
Definition at line 533 of file tree.hpp.
Referenced by sample::sample_tree_arena().
|
inline |
Definition at line 535 of file tree.hpp.
References c4::yml::KEYTAG.
|
inline |
Definition at line 536 of file tree.hpp.
References c4::yml::VALTAG.
|
inline |
Definition at line 538 of file tree.hpp.
References c4::yml::KEYANCH.
|
inline |
Definition at line 539 of file tree.hpp.
References c4::yml::VALANCH.
|
inline |
Definition at line 540 of file tree.hpp.
References c4::yml::KEY, and c4::yml::KEYREF.
|
inline |
Definition at line 541 of file tree.hpp.
References c4::yml::VAL, and c4::yml::VALREF.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 547 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 | ) |
Resolve references (aliases <- anchors) in the tree.
Dereferencing is opt-in; after parsing, Tree::resolve() has to be called explicitly for obtaining resolved references in the tree. This method will ReferenceResolver::resolve() to resolve all references and substitute the anchored values in place of the reference.
This method first does a full traversal of the tree to gather all anchors and references in a separate collection, then it goes through that collection to locate the names, which it does by obeying the YAML standard diktat that "an alias node refers to the most recent node in the serialization having the specified anchor"
So, depending on the number of anchor/alias nodes, this is a potentially expensive operation, with a best-case linear complexity (from the initial traversal). This potential cost is the reason for requiring an explicit call.
Definition at line 1121 of file tree.cpp.
References m_size.
Referenced by sample::sample_anchors_and_aliases().
| void c4::yml::Tree::resolve | ( | ) |
Resolve references using a throw-away resolver.
Definition at line 1113 of file tree.cpp.
References m_size.
| void c4::yml::Tree::resolve_tags | ( | ) |
Definition at line 1439 of file tree.cpp.
References arena_size(), empty(), reserve_arena(), and root_id().
Referenced by sample::sample_tag_directives().
| 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 1312 of file tree.cpp.
References m_tag_directives, and RYML_MAX_TAG_DIRECTIVES.
Referenced by add_tag_directive().
| bool c4::yml::Tree::add_tag_directive | ( | csubstr | directive | ) |
| id_type c4::yml::Tree::add_tag_directive | ( | TagDirective const & | td | ) |
Definition at line 1327 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 1321 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 1352 of file tree.cpp.
References c4::yml::is_custom_tag(), m_callbacks, m_tag_directives, RYML_MAX_TAG_DIRECTIVES, and c4::yml::TagDirective::transform().
|
inline |
Definition at line 607 of file tree.hpp.
|
inline |
|
inline |
|
inline |
Definition at line 615 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 630 of file tree.hpp.
References c4::yml::NONE.
create and insert a node as the first child of parent
Definition at line 640 of file tree.hpp.
References c4::yml::NONE.
create and insert a node as the last child of parent
Definition at line 642 of file tree.hpp.
Referenced by merge_with(), and set_root_as_stream().
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 668 of file tree.hpp.
Definition at line 669 of file tree.hpp.
|
inline |
remove an entire branch at once: ie remove the children and the node itself
Definition at line 674 of file tree.hpp.
Referenced by duplicate_children_no_rep(), and move().
| void c4::yml::Tree::remove_children | ( | id_type | node | ) |
remove all the node's children, but keep the node itself
Definition at line 857 of file tree.cpp.
References get(), m_callbacks, c4::yml::NodeData::m_first_child, c4::yml::NodeData::m_next_sibling, and c4::yml::NONE.
Referenced by change_type(), and merge_with().
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 873 of file tree.cpp.
References _p(), 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(), m_callbacks, c4::yml::NodeData::m_type, c4::yml::MAP, remove_children(), c4::yml::SEQ, type(), and c4::yml::VAL.
Definition at line 694 of file tree.hpp.
change the node's position in the parent
Definition at line 782 of file tree.cpp.
References has_sibling(), is_root(), m_callbacks, c4::yml::NONE, and parent().
Referenced by duplicate_children_no_rep(), c4::yml::NodeRef::move(), and set_root_as_stream().
change the node's parent and position
Definition at line 795 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 808 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 820 of file tree.cpp.
References _p(), c4::yml::NodeType::add(), append_child(), c4::yml::DOC, first_child(), has_children(), has_key(), is_stream(), is_val(), 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.
recursively duplicate a node from this tree into a new parent, placing it after one of its children
Definition at line 892 of file tree.cpp.
References parent().
Referenced by c4::yml::NodeRef::duplicate(), duplicate_children(), duplicate_children_no_rep(), and move().
| 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 897 of file tree.cpp.
References _claim(), duplicate_children(), is_root(), m_callbacks, c4::yml::NONE, and parent().
recursively duplicate the node's children (but not the node)
Definition at line 914 of file tree.cpp.
References parent().
Referenced by duplicate(), c4::yml::NodeRef::duplicate_children(), and duplicate_contents().
| 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 919 of file tree.cpp.
References duplicate(), first_child(), has_child(), m_callbacks, next_sibling(), c4::yml::NONE, and parent().
Definition at line 936 of file tree.cpp.
Definition at line 941 of file tree.cpp.
References duplicate_children(), last_child(), m_callbacks, and c4::yml::NONE.
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 951 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 956 of file tree.cpp.
References duplicate(), first_child(), has_child(), is_map(), is_seq(), key(), m_callbacks, move(), next_sibling(), c4::yml::NONE, parent(), and remove().
| void c4::yml::Tree::merge_with | ( | Tree const * | src, |
| id_type | src_node = NONE, |
||
| id_type | dst_root = NONE |
||
| ) |
Definition at line 1036 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.
Referenced by lookup_path_or_modify().
|
inline |
|
inline |
get the current size of the tree's internal arena
Definition at line 784 of file tree.hpp.
Referenced by resolve_tags().
|
inline |
get the current capacity of the tree's internal arena
Definition at line 786 of file tree.hpp.
Referenced by Tree(), and sample::sample_tree_arena().
|
inline |
|
inline |
get the current arena
Definition at line 791 of file tree.hpp.
Referenced by sample::sample_empty_null_values(), sample::sample_fundamental_types(), sample::sample_quick_overview(), and sample::sample_tree_arena().
|
inline |
|
inline |
return true if the given substring is part of the tree's string arena
Definition at line 796 of file tree.hpp.
Referenced by sample::sample_quick_overview().
|
inline |
serialize the given floating-point variable to the tree's arena, growing it as needed to accomodate the serialization.
Definition at line 812 of file tree.hpp.
References c4::yml::to_chars_float().
Referenced by sample::sample_fundamental_types(), and sample::sample_tree_arena().
|
inline |
serialize the given non-floating-point variable to the tree's arena, growing it as needed to accomodate the serialization.
Definition at line 838 of file tree.hpp.
References sample::to_chars().
|
inline |
serialize the given csubstr to the tree's arena, growing the arena as needed to accomodate the serialization.
Definition at line 863 of file tree.hpp.
References sample::to_chars().
|
inline |
Definition at line 894 of file tree.hpp.
References c4::to_csubstr().
|
inlinestatic |
|
inline |
copy the given substr to the tree's arena, growing it by the required size
Definition at line 915 of file tree.hpp.
Referenced by c4::yml::parse_in_arena(), c4::yml::parse_json_in_arena(), and sample::sample_tree_arena().
|
inline |
grow the tree's string arena by the given size and return a substr of the added portion
Definition at line 943 of file tree.hpp.
Referenced by sample::sample_tree_arena().
|
inline |
ensure the tree's internal string arena is at least the given capacity
Definition at line 955 of file tree.hpp.
Referenced by Tree(), resolve_tags(), sample::sample_global_allocator(), sample::sample_parse_reuse_tree(), and sample::sample_tree_arena().
| Tree::lookup_result c4::yml::Tree::lookup_path | ( | csubstr | path, |
| id_type | start = NONE |
||
| ) | const |
for example foo.bar[0].baz
Definition at line 1486 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 1499 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 1509 of file tree.cpp.
References merge_with().
| id_type c4::yml::Tree::_claim | ( | ) |
Definition at line 377 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().
Referenced by duplicate().
| NodeData* c4::yml::Tree::m_buf |
| id_type c4::yml::Tree::m_cap |
| id_type c4::yml::Tree::m_size |
| id_type c4::yml::Tree::m_free_head |
| id_type c4::yml::Tree::m_free_tail |
| Callbacks c4::yml::Tree::m_callbacks |
Definition at line 1320 of file tree.hpp.
Referenced by _claim(), add_tag_directive(), change_type(), child(), child_pos(), clear(), depth_asc(), depth_desc(), duplicate(), duplicate_children(), duplicate_children_no_rep(), duplicate_contents(), find_child(), merge_with(), move(), operator=(), remove_children(), reserve(), resolve_tag(), set_root_as_stream(), to_doc(), to_keyval(), to_map(), to_seq(), to_stream(), and to_val().
| TagDirective c4::yml::Tree::m_tag_directives[RYML_MAX_TAG_DIRECTIVES] |
Definition at line 1322 of file tree.hpp.
Referenced by add_tag_directive(), clear(), clear_tag_directives(), num_tag_directives(), and resolve_tag().