The event handler to create a ryml Tree.
More...
#include <event_handler_tree.hpp>
The event handler to create a ryml Tree.
See the documentation for Event Handlers, which has important notes about the event model used by rapidyaml.
Definition at line 39 of file event_handler_tree.hpp.
◆ state
◆ anonymous enum
| Enumerator |
|---|
| requires_strings_on_buffers | |
Definition at line 46 of file event_handler_tree.hpp.
@ requires_strings_on_buffers
◆ EventHandlerTree() [1/3]
| c4::yml::EventHandlerTree::EventHandlerTree |
( |
| ) |
|
|
inline |
◆ EventHandlerTree() [2/3]
| c4::yml::EventHandlerTree::EventHandlerTree |
( |
Callbacks const & |
cb | ) |
|
|
inline |
◆ EventHandlerTree() [3/3]
| c4::yml::EventHandlerTree::EventHandlerTree |
( |
Tree * |
tree, |
|
|
id_type |
id |
|
) |
| |
|
inline |
◆ reset()
| void c4::yml::EventHandlerTree::reset |
( |
Tree * |
tree, |
|
|
id_type |
id |
|
) |
| |
|
inline |
Definition at line 79 of file event_handler_tree.hpp.
81 if(C4_UNLIKELY(!tree))
82 _RYML_ERR_BASIC_(
m_stack.m_callbacks,
"null tree");
83 if(C4_UNLIKELY(
id >= tree->capacity()))
84 _RYML_ERR_BASIC_(tree->callbacks(),
"invalid node");
85 if(C4_UNLIKELY(!tree->is_root(
id)))
86 if(C4_UNLIKELY(tree->is_map(tree->parent(
id))))
87 if(C4_UNLIKELY(!tree->has_key(
id)))
88 _RYML_ERR_BASIC_(tree->callbacks(),
"destination node belongs to a map and has no key");
90 if(m_tree->is_root(
id))
93 _reset_parser_state(
m_curr,
id, m_tree->root_id());
98 _reset_parser_state(
m_parent,
id, m_tree->parent(
id));
99 _reset_parser_state(
m_curr,
id,
id);
101 m_curr_doc = m_tree->ancestor_doc(
id);
void _stack_reset_non_root()
state * m_curr
current stack level: top of the stack. cached here for easier access.
detail::stack< state > m_stack
state * m_parent
parent of the current stack level.
◆ callbacks()
| Callbacks const& c4::yml::EventHandlerTree::callbacks |
( |
| ) |
const |
|
inline |
◆ tag_directives()
◆ tag_cache()
| TagCache& c4::yml::EventHandlerTree::tag_cache |
( |
| ) |
|
|
inline |
◆ start_parse()
| void c4::yml::EventHandlerTree::start_parse |
( |
const char * |
filename, |
|
|
substr |
ymlsrc |
|
) |
| |
|
inline |
Definition at line 117 of file event_handler_tree.hpp.
119 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree !=
nullptr);
void _stack_start_parse(const char *filename, substr ymlsrc)
◆ finish_parse()
| void c4::yml::EventHandlerTree::finish_parse |
( |
| ) |
|
|
inline |
◆ cancel_parse()
| void c4::yml::EventHandlerTree::cancel_parse |
( |
| ) |
|
|
inline |
◆ begin_stream()
| void c4::yml::EventHandlerTree::begin_stream |
( |
| ) |
const |
|
inlinenoexcept |
◆ end_stream()
| void c4::yml::EventHandlerTree::end_stream |
( |
| ) |
const |
|
inlinenoexcept |
◆ begin_doc()
| void c4::yml::EventHandlerTree::begin_doc |
( |
| ) |
|
|
inline |
implicit doc start (without —)
Definition at line 166 of file event_handler_tree.hpp.
168 _c4dbgp(
"begin_doc");
172 _set_root_as_stream();
176 m_curr_doc =
m_curr->node_id;
bool _stack_should_push_on_begin_doc() const
◆ end_doc()
| void c4::yml::EventHandlerTree::end_doc |
( |
| ) |
|
|
inline |
implicit doc end (without ...)
Definition at line 179 of file event_handler_tree.hpp.
182 m_curr_doc = m_tree->size();
185 _remove_speculative();
bool _stack_should_pop_on_end_doc() const
◆ begin_doc_expl()
| void c4::yml::EventHandlerTree::begin_doc_expl |
( |
| ) |
|
|
inline |
explicit doc start, with —
Definition at line 192 of file event_handler_tree.hpp.
194 _c4dbgp(
"begin_doc_expl");
195 _RYML_ASSERT_VISIT_(
m_stack.m_callbacks, m_tree->root_id() ==
m_curr->node_id, m_tree,
m_curr->node_id);
196 if(m_tree->is_stream(m_tree->root_id()))
203 _c4dbgp(
"ensure stream");
204 _set_root_as_stream();
205 const id_type root = m_tree->root_id();
206 const id_type first = m_tree->first_child(root);
207 _RYML_ASSERT_VISIT_(
m_stack.m_callbacks, m_tree->is_stream(root), m_tree, root);
208 _RYML_ASSERT_VISIT_(
m_stack.m_callbacks, m_tree->num_children(root) == 1u, m_tree, root);
209 if(m_tree->is_container(first) || m_tree->is_val(first))
213 #ifdef RYML_WITH_COMMENTS
214 m_tree->_p(root)->m_first_comment =
NONE;
215 m_tree->_p(root)->m_last_comment =
NONE;
222 _remove_speculative();
223 m_curr->node_id = m_tree->last_child(root);
228 m_curr_doc =
m_curr->node_id;
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
◆ end_doc_expl()
| void c4::yml::EventHandlerTree::end_doc_expl |
( |
| ) |
|
|
inline |
explicit doc end, with ...
Definition at line 231 of file event_handler_tree.hpp.
233 _c4dbgp(
"end_doc_expl");
234 m_curr_doc = m_tree->size();
235 _remove_speculative();
◆ begin_map_key_flow()
| void c4::yml::EventHandlerTree::begin_map_key_flow |
( |
| ) |
|
|
inline |
◆ begin_map_key_block()
| void c4::yml::EventHandlerTree::begin_map_key_block |
( |
| ) |
|
|
inline |
◆ begin_map_val_flow()
| void c4::yml::EventHandlerTree::begin_map_val_flow |
( |
| ) |
|
|
inline |
Definition at line 259 of file event_handler_tree.hpp.
261 _c4dbgpf(
"node[{}]: begin_map_val_flow",
m_curr->node_id);
@ MAP
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
@ FLOW_SL
mark container with single-line flow style (seqs as '[val1,val2], maps as '{key: val,...
@ VAL
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
◆ begin_map_val_block()
| void c4::yml::EventHandlerTree::begin_map_val_block |
( |
| ) |
|
|
inline |
Definition at line 267 of file event_handler_tree.hpp.
269 _c4dbgpf(
"node[{}]: begin_map_val_block",
m_curr->node_id);
@ BLOCK
mark container with block style (seqs as '- val ', maps as 'key: val')
◆ end_map_block()
| void c4::yml::EventHandlerTree::end_map_block |
( |
| ) |
|
|
inline |
◆ end_map_flow()
| void c4::yml::EventHandlerTree::end_map_flow |
( |
bool |
multiline | ) |
|
|
inline |
Definition at line 282 of file event_handler_tree.hpp.
284 _c4dbgpf(
"node[{}]: end_map. multiline={} startline={} endline={}",
m_parent->node_id, multiline,
m_parent->pos.line,
m_curr->pos.line);
@ FLOW_ML
mark container with multi-line flow style (seqs as '[ val1, val2 ], maps as '{ key: val,...
◆ begin_seq_key_flow()
| void c4::yml::EventHandlerTree::begin_seq_key_flow |
( |
| ) |
|
|
inline |
◆ begin_seq_key_block()
| void c4::yml::EventHandlerTree::begin_seq_key_block |
( |
| ) |
|
|
inline |
◆ begin_seq_val_flow()
| void c4::yml::EventHandlerTree::begin_seq_val_flow |
( |
| ) |
|
|
inline |
Definition at line 309 of file event_handler_tree.hpp.
311 _c4dbgpf(
"node[{}]: begin_seq_val_flow",
m_curr->node_id);
@ SEQ
a seq: a parent of VAL/SEQ/MAP nodes
◆ begin_seq_val_block()
| void c4::yml::EventHandlerTree::begin_seq_val_block |
( |
| ) |
|
|
inline |
◆ end_seq_block()
| void c4::yml::EventHandlerTree::end_seq_block |
( |
| ) |
|
|
inline |
◆ end_seq_flow()
| void c4::yml::EventHandlerTree::end_seq_flow |
( |
bool |
multiline | ) |
|
|
inline |
◆ add_sibling()
| void c4::yml::EventHandlerTree::add_sibling |
( |
| ) |
|
|
inline |
Definition at line 350 of file event_handler_tree.hpp.
352 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree);
355 NodeData
const*
const prev = m_tree->m_buf;
356 _set_state_(
m_curr, m_tree->_append_child__unprotected(
m_parent->node_id));
357 if(prev != m_tree->m_buf)
358 _refresh_after_relocation();
359 _c4dbgpf(
"node[{}]: added sibling={} prev={}",
m_parent->node_id,
m_curr->node_id, m_tree->prev_sibling(
m_curr->node_id));
◆ actually_val_is_first_key_of_new_map_flow()
| void c4::yml::EventHandlerTree::actually_val_is_first_key_of_new_map_flow |
( |
| ) |
|
|
inline |
reset the previous val as the first key of a new map, with flow style.
See the documentation for Event Handlers, which has important notes about this event.
Definition at line 367 of file event_handler_tree.hpp.
369 if(C4_UNLIKELY(m_tree->is_container(
m_curr->node_id)))
370 _RYML_ERR_PARSE_(
m_stack.m_callbacks,
m_curr->pos,
"ryml trees cannot handle containers as keys");
373 _RYML_ASSERT_VISIT_(
m_stack.m_callbacks, !m_tree->is_container(
m_curr->node_id), m_tree,
m_curr->node_id);
374 _RYML_ASSERT_VISIT_(
m_stack.m_callbacks, !m_tree->has_key(
m_curr->node_id), m_tree,
m_curr->node_id);
375 const NodeData tmp = _val2key_(*
m_curr->tr_data);
377 m_curr->tr_data->m_val = {};
379 m_curr->tr_data->m_type = tmp.m_type;
380 m_curr->tr_data->m_key = tmp.m_key;
@ VALNIL
the val is null (eg {a : } results in a null val)
@ VAL_STYLE
mask of all the scalar styles for val (not container styles!)
void begin_map_val_flow()
◆ actually_val_is_first_key_of_new_map_block()
| void c4::yml::EventHandlerTree::actually_val_is_first_key_of_new_map_block |
( |
| ) |
|
|
inline |
like its flow counterpart, but this function can only be called after the end of a flow-val at root or doc level.
See the documentation for Event Handlers, which has important notes about this event.
Definition at line 389 of file event_handler_tree.hpp.
391 _RYML_ERR_PARSE_(
m_stack.m_callbacks,
m_curr->pos,
"ryml trees cannot handle containers as keys");
◆ set_key_scalar_plain_empty()
| void c4::yml::EventHandlerTree::set_key_scalar_plain_empty |
( |
| ) |
|
|
inlinenoexcept |
Definition at line 402 of file event_handler_tree.hpp.
404 _c4dbgpf(
"node[{}]: set key scalar plain as empty",
m_curr->node_id);
405 m_curr->tr_data->m_key.scalar = {};
@ KEY_PLAIN
mark key scalar as plain scalar (unquoted, even when multiline)
@ KEYNIL
the key is null (eg { : b} results in a null key)
◆ set_val_scalar_plain_empty()
| void c4::yml::EventHandlerTree::set_val_scalar_plain_empty |
( |
| ) |
|
|
inlinenoexcept |
Definition at line 408 of file event_handler_tree.hpp.
410 _c4dbgpf(
"node[{}]: set val scalar plain as empty",
m_curr->node_id);
411 m_curr->tr_data->m_val.scalar = {};
@ VAL_PLAIN
mark val scalar as plain scalar (unquoted, even when multiline)
◆ set_key_scalar_plain()
| void c4::yml::EventHandlerTree::set_key_scalar_plain |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 415 of file event_handler_tree.hpp.
417 _c4dbgpf(
"node[{}]: set key scalar plain: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
418 m_curr->tr_data->m_key.scalar = scalar;
◆ set_val_scalar_plain()
| void c4::yml::EventHandlerTree::set_val_scalar_plain |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 421 of file event_handler_tree.hpp.
423 _c4dbgpf(
"node[{}]: set val scalar plain: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
424 m_curr->tr_data->m_val.scalar = scalar;
◆ set_key_scalar_dquoted()
| void c4::yml::EventHandlerTree::set_key_scalar_dquoted |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 429 of file event_handler_tree.hpp.
431 _c4dbgpf(
"node[{}]: set key scalar dquot: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
432 m_curr->tr_data->m_key.scalar = scalar;
@ KEY_DQUO
mark key scalar as double quoted "
◆ set_val_scalar_dquoted()
| void c4::yml::EventHandlerTree::set_val_scalar_dquoted |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 435 of file event_handler_tree.hpp.
437 _c4dbgpf(
"node[{}]: set val scalar dquot: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
438 m_curr->tr_data->m_val.scalar = scalar;
@ VAL_DQUO
mark val scalar as double quoted "
◆ set_key_scalar_squoted()
| void c4::yml::EventHandlerTree::set_key_scalar_squoted |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 443 of file event_handler_tree.hpp.
445 _c4dbgpf(
"node[{}]: set key scalar squot: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
446 m_curr->tr_data->m_key.scalar = scalar;
@ KEY_SQUO
mark key scalar as single quoted '
◆ set_val_scalar_squoted()
| void c4::yml::EventHandlerTree::set_val_scalar_squoted |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 449 of file event_handler_tree.hpp.
451 _c4dbgpf(
"node[{}]: set val scalar squot: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
452 m_curr->tr_data->m_val.scalar = scalar;
@ VAL_SQUO
mark val scalar as single quoted '
◆ set_key_scalar_literal()
| void c4::yml::EventHandlerTree::set_key_scalar_literal |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 457 of file event_handler_tree.hpp.
459 _c4dbgpf(
"node[{}]: set key scalar literal: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
460 m_curr->tr_data->m_key.scalar = scalar;
@ KEY_LITERAL
mark key scalar as multiline, block literal |
◆ set_val_scalar_literal()
| void c4::yml::EventHandlerTree::set_val_scalar_literal |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 463 of file event_handler_tree.hpp.
465 _c4dbgpf(
"node[{}]: set val scalar literal: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
466 m_curr->tr_data->m_val.scalar = scalar;
@ VAL_LITERAL
mark val scalar as multiline, block literal |
◆ set_key_scalar_folded()
| void c4::yml::EventHandlerTree::set_key_scalar_folded |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 471 of file event_handler_tree.hpp.
473 _c4dbgpf(
"node[{}]: set key scalar folded: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
474 m_curr->tr_data->m_key.scalar = scalar;
@ KEY_FOLDED
mark key scalar as multiline, block folded >
◆ set_val_scalar_folded()
| void c4::yml::EventHandlerTree::set_val_scalar_folded |
( |
csubstr |
scalar | ) |
|
|
inlinenoexcept |
Definition at line 477 of file event_handler_tree.hpp.
479 _c4dbgpf(
"node[{}]: set val scalar folded: [{}]~~~{}~~~",
m_curr->node_id, scalar.len, scalar);
480 m_curr->tr_data->m_val.scalar = scalar;
@ VAL_FOLDED
mark val scalar as multiline, block folded >
◆ mark_key_scalar_unfiltered()
| void c4::yml::EventHandlerTree::mark_key_scalar_unfiltered |
( |
| ) |
|
|
inlinenoexcept |
Definition at line 485 of file event_handler_tree.hpp.
@ KEY_UNFILT
the key scalar was left unfiltered; the parser was set not to filter.
◆ mark_val_scalar_unfiltered()
| void c4::yml::EventHandlerTree::mark_val_scalar_unfiltered |
( |
| ) |
|
|
inlinenoexcept |
Definition at line 489 of file event_handler_tree.hpp.
@ VAL_UNFILT
the val scalar was left unfiltered; the parser was set not to filter.
◆ set_key_anchor()
| void c4::yml::EventHandlerTree::set_key_anchor |
( |
csubstr |
anchor | ) |
|
|
inline |
Definition at line 501 of file event_handler_tree.hpp.
503 _c4dbgpf(
"node[{}]: set key anchor: [{}]~~~{}~~~",
m_curr->node_id, anchor.len, anchor);
504 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree);
506 _RYML_ASSERT_PARSE_(m_tree->callbacks(), !anchor.begins_with(
'&'),
m_curr->pos);
508 m_curr->tr_data->m_key.anchor = anchor;
@ KEYREF
a *reference: the key references an &anchor
@ KEYANCH
the key has an &anchor
◆ set_val_anchor()
| void c4::yml::EventHandlerTree::set_val_anchor |
( |
csubstr |
anchor | ) |
|
|
inline |
Definition at line 510 of file event_handler_tree.hpp.
512 _c4dbgpf(
"node[{}]: set val anchor: [{}]~~~{}~~~",
m_curr->node_id, anchor.len, anchor);
513 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree);
515 _RYML_ASSERT_PARSE_(m_tree->callbacks(), !anchor.begins_with(
'&'),
m_curr->pos);
517 m_curr->tr_data->m_val.anchor = anchor;
@ VALANCH
the val has an &anchor
@ VALREF
a *reference: the val references an &anchor
◆ set_key_ref()
| void c4::yml::EventHandlerTree::set_key_ref |
( |
csubstr |
ref | ) |
|
|
inline |
Definition at line 520 of file event_handler_tree.hpp.
522 _c4dbgpf(
"node[{}]: set key ref: [{}]~~~{}~~~",
m_curr->node_id, ref.len, ref);
523 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree);
525 _RYML_ERR_PARSE_(m_tree->callbacks(),
m_curr->pos,
"key cannot have both anchor and ref");
526 _RYML_ASSERT_PARSE_(m_tree->callbacks(), ref.begins_with(
'*'),
m_curr->pos);
528 m_curr->tr_data->m_key.anchor = ref.sub(1);
529 m_curr->tr_data->m_key.scalar = ref;
◆ set_val_ref()
| void c4::yml::EventHandlerTree::set_val_ref |
( |
csubstr |
ref | ) |
|
|
inline |
Definition at line 531 of file event_handler_tree.hpp.
533 _c4dbgpf(
"node[{}]: set val ref: [{}]~~~{}~~~",
m_curr->node_id, ref.len, ref);
534 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree);
536 _RYML_ERR_PARSE_(m_tree->callbacks(),
m_curr->pos,
"val cannot have both anchor and ref");
537 _RYML_ASSERT_PARSE_(m_tree->callbacks(), ref.begins_with(
'*'),
m_curr->pos);
539 m_curr->tr_data->m_val.anchor = ref.sub(1);
540 m_curr->tr_data->m_val.scalar = ref;
◆ set_key_tag()
| void c4::yml::EventHandlerTree::set_key_tag |
( |
csubstr |
tag | ) |
|
|
inline |
Definition at line 550 of file event_handler_tree.hpp.
552 _c4dbgpf(
"node[{}]: set key tag: [{}]~~~{}~~~",
m_curr->node_id, tag.len, tag);
554 m_curr->tr_data->m_key.tag = tag;
@ KEYTAG
the key has a tag
◆ set_val_tag()
| void c4::yml::EventHandlerTree::set_val_tag |
( |
csubstr |
tag | ) |
|
|
inline |
Definition at line 556 of file event_handler_tree.hpp.
558 _c4dbgpf(
"node[{}]: set val tag: [{}]~~~{}~~~",
m_curr->node_id, tag.len, tag);
560 m_curr->tr_data->m_val.tag = tag;
@ VALTAG
the val has a tag
◆ add_directive_yaml()
| void c4::yml::EventHandlerTree::add_directive_yaml |
( |
csubstr |
yaml_version | ) |
|
|
inline |
◆ add_directive_tag()
| void c4::yml::EventHandlerTree::add_directive_tag |
( |
csubstr |
handle, |
|
|
csubstr |
prefix |
|
) |
| |
|
inline |
Definition at line 576 of file event_handler_tree.hpp.
578 _c4dbgpf(
"%TAG directive! handle={} prefix={} id={}", handle, prefix, m_curr_doc);
579 if(C4_UNLIKELY(!m_tree->m_tag_directives.add(handle, prefix, m_curr_doc)))
580 _RYML_ERR_PARSE_(
m_stack.m_callbacks,
m_curr->pos,
"too many %TAG directives");
◆ arena()
| substr c4::yml::EventHandlerTree::arena |
( |
| ) |
|
|
inline |
Definition at line 590 of file event_handler_tree.hpp.
592 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree);
593 return m_tree->m_arena.first(m_tree->m_arena_pos);
◆ arena_rem()
| substr c4::yml::EventHandlerTree::arena_rem |
( |
| ) |
|
|
inline |
Definition at line 595 of file event_handler_tree.hpp.
597 _RYML_ASSERT_BASIC_(
m_stack.m_callbacks, m_tree);
598 return m_tree->m_arena.sub(m_tree->m_arena_pos);
◆ alloc_arena()
| substr c4::yml::EventHandlerTree::alloc_arena |
( |
size_t |
len | ) |
|
|
inline |
◆ _stack_start_parse()
◆ _stack_finish_parse()
◆ _stack_reset_root()
◆ _stack_reset_non_root()
◆ _stack_push()
◆ _stack_pop()
◆ _stack_should_push_on_begin_doc()
◆ _stack_should_pop_on_end_doc()
◆ m_stack
◆ m_curr
◆ m_parent
◆ m_src
The documentation for this struct was generated from the following file:
- /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/v0.13.0/src/c4/yml/event_handler_tree.hpp