rapidyaml  0.16.0
parseandemitYAML,anddoitfast
c4::yml::EventHandlerTree Struct Reference

The event handler to create a ryml Tree. More...

#include <event_handler_tree.hpp>

Inheritance diagram for c4::yml::EventHandlerTree:
c4::yml::EventHandlerStack< EventHandlerTree, EventHandlerTreeState >

Public Types

types
enum  { requires_strings_on_buffers = false }
 
using state = EventHandlerTreeState
 

Public Member Functions

construction and resetting
 EventHandlerTree () noexcept
 
 EventHandlerTree (Callbacks const &cb) noexcept
 
 EventHandlerTree (Tree *tree, id_type id)
 
void reset (Tree *tree, id_type id)
 
Callbacks const & callbacks () const
 
TagDirectives & tag_directives ()
 
TagCache & tag_cache ()
 
parse events
void start_parse (const char *filename, substr ymlsrc)
 
void finish_parse ()
 
void cancel_parse ()
 
YAML stream events
void begin_stream () const noexcept
 
void end_stream () const noexcept
 
YAML document events
void begin_doc ()
 implicit doc start (without —) More...
 
void end_doc ()
 implicit doc end (without ...) More...
 
void begin_doc_expl ()
 explicit doc start, with — More...
 
void end_doc_expl ()
 explicit doc end, with ... More...
 
YAML map events
void begin_map_key_flow ()
 
void begin_map_key_block ()
 
void begin_map_val_flow ()
 
void begin_map_val_block ()
 
void end_map_block ()
 
void end_map_flow (bool multiline, type_bits multiline_style=FLOW_ML1)
 
YAML seq events
void begin_seq_key_flow ()
 
void begin_seq_key_block ()
 
void begin_seq_val_flow ()
 
void begin_seq_val_block ()
 
void end_seq_block ()
 
void end_seq_flow (bool multiline, type_bits multiline_style=FLOW_ML1)
 
YAML structure events
void add_sibling ()
 
void actually_val_is_first_key_of_new_map_flow ()
 reset the previous val as the first key of a new map, with flow style. More...
 
void actually_val_is_first_key_of_new_map_block ()
 like its flow counterpart, but this function can only be called after the end of a flow-val at root or doc level. More...
 
YAML scalar events
void set_key_scalar_plain_empty () noexcept
 
void set_val_scalar_plain_empty () noexcept
 
void set_key_scalar_plain (csubstr scalar) noexcept
 
void set_val_scalar_plain (csubstr scalar) noexcept
 
void set_key_scalar_dquoted (csubstr scalar) noexcept
 
void set_val_scalar_dquoted (csubstr scalar) noexcept
 
void set_key_scalar_squoted (csubstr scalar) noexcept
 
void set_val_scalar_squoted (csubstr scalar) noexcept
 
void set_key_scalar_literal (csubstr scalar) noexcept
 
void set_val_scalar_literal (csubstr scalar) noexcept
 
void set_key_scalar_folded (csubstr scalar) noexcept
 
void set_val_scalar_folded (csubstr scalar) noexcept
 
void mark_key_scalar_unfiltered () noexcept
 
void mark_val_scalar_unfiltered () noexcept
 
YAML anchor/reference events
void set_key_anchor (csubstr anchor)
 
void set_val_anchor (csubstr anchor)
 
void set_key_ref (csubstr ref)
 
void set_val_ref (csubstr ref)
 
YAML tag events
void set_key_tag (csubstr tag)
 
void set_val_tag (csubstr tag)
 
YAML directive events
void add_directive_yaml (csubstr yaml_version)
 
void add_directive_tag (csubstr handle, csubstr prefix)
 
arena functions
substr arena ()
 
substr arena_rem ()
 
substr alloc_arena (size_t len)
 

Public Attributes

detail::stack< state > m_stack
 
state * m_curr
 current stack level: top of the stack. cached here for easier access. More...
 
state * m_parent
 parent of the current stack level. More...
 
substr m_src
 

Protected Member Functions

void _stack_start_parse (const char *filename, substr ymlsrc)
 
void _stack_finish_parse ()
 
void _stack_reset_root ()
 
void _stack_reset_non_root ()
 
void _stack_push ()
 
void _stack_pop ()
 
bool _stack_should_push_on_begin_doc () const
 
bool _stack_should_pop_on_end_doc () const
 

Detailed Description

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 43 of file event_handler_tree.hpp.

Member Typedef Documentation

using c4::yml::EventHandlerTree::state = EventHandlerTreeState

Definition at line 49 of file event_handler_tree.hpp.

Member Enumeration Documentation

anonymous enum
Enumerator
requires_strings_on_buffers 

Definition at line 50 of file event_handler_tree.hpp.

Constructor & Destructor Documentation

c4::yml::EventHandlerTree::EventHandlerTree ( )
inlinenoexcept
c4::yml::EventHandlerTree::EventHandlerTree ( Callbacks const &  cb)
inlinenoexcept
c4::yml::EventHandlerTree::EventHandlerTree ( Tree *  tree,
id_type  id 
)
inline

Definition at line 78 of file event_handler_tree.hpp.

78  : EventHandlerStack(tree->callbacks()), m_tree(tree), m_curr_doc()
79  {
80  reset(tree, id);
81  }
void reset(Tree *tree, id_type id)

Member Function Documentation

void c4::yml::EventHandlerTree::reset ( Tree *  tree,
id_type  id 
)
inline

Definition at line 83 of file event_handler_tree.hpp.

Referenced by EventHandlerTree().

84  {
85  if C4_UNLIKELY(!tree)
86  RYML_ERR_BASIC_CB_(m_stack.m_callbacks, "null tree");
87  if C4_UNLIKELY(id >= tree->capacity())
88  RYML_ERR_VISIT_CB_(tree->callbacks(), tree, id, "invalid node");
89  if C4_UNLIKELY(!tree->is_root(id))
90  if C4_UNLIKELY(tree->is_map(tree->parent(id)))
91  if C4_UNLIKELY(!tree->has_key(id))
92  RYML_ERR_BASIC_CB_(tree->callbacks(), "destination node belongs to a map and has no key");
93  m_tree = tree;
94  if(m_tree->is_root(id))
95  {
97  _reset_parser_state(m_curr, id, m_tree->root_id());
98  }
99  else
100  {
102  _reset_parser_state(m_parent, id, m_tree->parent(id));
103  _reset_parser_state(m_curr, id, id);
104  }
105  m_curr_doc = m_tree->ancestor_doc(id);
106  m_tag_cache.clear();
107  }
Callbacks const & callbacks() const
state * m_curr
current stack level: top of the stack. cached here for easier access.
Callbacks const& c4::yml::EventHandlerTree::callbacks ( ) const
inline

Definition at line 109 of file event_handler_tree.hpp.

109 { return m_stack.m_callbacks; }
TagDirectives& c4::yml::EventHandlerTree::tag_directives ( )
inline

Definition at line 111 of file event_handler_tree.hpp.

111 { return m_tree->m_tag_directives; } // NOLINT(readability-make-member-function-const)
TagCache& c4::yml::EventHandlerTree::tag_cache ( )
inline

Definition at line 112 of file event_handler_tree.hpp.

112 { return m_tag_cache; }
void c4::yml::EventHandlerTree::start_parse ( const char *  filename,
substr  ymlsrc 
)
inline

Definition at line 121 of file event_handler_tree.hpp.

122  {
123  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_tree != nullptr);
124  this->_stack_start_parse(filename, ymlsrc);
125  }
void c4::yml::EventHandlerTree::finish_parse ( )
inline

Definition at line 127 of file event_handler_tree.hpp.

128  {
129  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_tree != nullptr);
130  this->_stack_finish_parse();
131  /* This pointer is temporary. Remember that:
132  *
133  * - this handler object may be held by the user
134  * - it may be used with a temporary tree inside the parse function
135  * - when the parse function returns the temporary tree, its address
136  * will change
137  *
138  * As a result, the user could try to read the tree from m_tree, and
139  * end up reading the stale temporary object.
140  *
141  * So it is better to clear it here; then the user will get an obvious
142  * segfault if reading from m_tree. */
143  m_tree = nullptr;
144  }
void c4::yml::EventHandlerTree::cancel_parse ( )
inline

Definition at line 146 of file event_handler_tree.hpp.

147  {
148  m_tree = nullptr;
149  }
void c4::yml::EventHandlerTree::begin_stream ( ) const
inlinenoexcept

Definition at line 158 of file event_handler_tree.hpp.

158 { /* nothing to do */ }
void c4::yml::EventHandlerTree::end_stream ( ) const
inlinenoexcept

Definition at line 160 of file event_handler_tree.hpp.

160 { /* nothing to do */ }
void c4::yml::EventHandlerTree::begin_doc ( )
inline

implicit doc start (without —)

Definition at line 170 of file event_handler_tree.hpp.

171  {
172  _c4dbgp("begin_doc");
174  {
175  _c4dbgp("push!");
176  _set_root_as_stream();
177  _push();
178  ryml_enable_(DOC);
179  }
180  m_curr_doc = m_curr->node_id;
181  }
a document
Definition: node_type.hpp:37
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::end_doc ( )
inline

implicit doc end (without ...)

Definition at line 183 of file event_handler_tree.hpp.

184  {
185  _c4dbgp("end_doc");
186  m_curr_doc = m_tree->size();
188  {
189  _remove_speculative();
190  _c4dbgp("pop!");
191  _pop();
192  }
193  }
void c4::yml::EventHandlerTree::begin_doc_expl ( )
inline

explicit doc start, with —

Definition at line 196 of file event_handler_tree.hpp.

197  {
198  _c4dbgp("begin_doc_expl");
199  RYML_ASSERT_VISIT_CB_(m_stack.m_callbacks, m_tree->root_id() == m_curr->node_id, m_tree, m_curr->node_id);
200  if(m_tree->is_stream(m_tree->root_id())) //if(_should_push_on_begin_doc())
201  {
202  _c4dbgp("push!");
203  _push();
204  }
205  else
206  {
207  _c4dbgp("ensure stream");
208  _set_root_as_stream();
209  const id_type root = m_tree->root_id();
210  const id_type first = m_tree->first_child(root);
211  RYML_ASSERT_VISIT_CB_(m_stack.m_callbacks, m_tree->is_stream(root), m_tree, root);
212  RYML_ASSERT_VISIT_CB_(m_stack.m_callbacks, m_tree->num_children(root) == 1u, m_tree, root);
213  if(m_tree->is_container(first) || m_tree->is_val(first))
214  {
215  _c4dbgp("push!");
216  _push();
217  #ifdef RYML_WITH_COMMENTS
218  m_tree->_p(root)->m_first_comment = NONE;
219  m_tree->_p(root)->m_last_comment = NONE;
220  #endif
221  }
222  else
223  {
224  _c4dbgp("tweak");
225  _push();
226  _remove_speculative();
227  m_curr->node_id = m_tree->last_child(root);
228  m_curr->tr_data = m_tree->_p(m_curr->node_id);
229  }
230  }
231  ryml_enable_(DOC);
232  m_curr_doc = m_curr->node_id;
233  }
an index to none
Definition: common.hpp:131
a document
Definition: node_type.hpp:37
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...
Definition: common.hpp:124
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::end_doc_expl ( )
inline

explicit doc end, with ...

Definition at line 235 of file event_handler_tree.hpp.

236  {
237  _c4dbgp("end_doc_expl");
238  m_curr_doc = m_tree->size();
239  _remove_speculative();
241  {
242  _c4dbgp("pop!");
243  _pop();
244  }
245  }
void c4::yml::EventHandlerTree::begin_map_key_flow ( )
inline

Definition at line 254 of file event_handler_tree.hpp.

255  {
256  RYML_ERR_PARSE_CB_(m_stack.m_callbacks, m_curr->pos, "ryml trees cannot handle containers as keys");
257  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::begin_map_key_block ( )
inline

Definition at line 258 of file event_handler_tree.hpp.

259  {
260  RYML_ERR_PARSE_CB_(m_stack.m_callbacks, m_curr->pos, "ryml trees cannot handle containers as keys");
261  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::begin_map_val_flow ( )
inline

Definition at line 263 of file event_handler_tree.hpp.

Referenced by actually_val_is_first_key_of_new_map_flow().

264  {
265  _c4dbgpf("node[{}]: begin_map_val_flow", m_curr->node_id);
266  RYML_CHECK_BASIC_CB_(m_stack.m_callbacks, !ryml_hasany_(VAL));
267  ryml_enable_(MAP|FLOW_SL);
268  _save_loc();
269  _push();
270  }
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
Definition: node_type.hpp:35
state * m_curr
current stack level: top of the stack. cached here for easier access.
mark container with single-line flow style < - seqs as <
Definition: node_type.hpp:56
void c4::yml::EventHandlerTree::begin_map_val_block ( )
inline

Definition at line 271 of file event_handler_tree.hpp.

272  {
273  _c4dbgpf("node[{}]: begin_map_val_block", m_curr->node_id);
274  RYML_CHECK_BASIC_CB_(m_stack.m_callbacks, !ryml_hasany_(VAL));
275  ryml_enable_(MAP|BLOCK);
276  _save_loc();
277  _push();
278  }
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
mark container with block style < - seqs as <
Definition: node_type.hpp:136
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
Definition: node_type.hpp:35
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::end_map_block ( )
inline

Definition at line 280 of file event_handler_tree.hpp.

281  {
282  _c4dbgpf("node[{}]: end_map_block", m_parent->node_id, m_parent->pos.line, m_curr->pos.line);
283  _pop();
284  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::end_map_flow ( bool  multiline,
type_bits  multiline_style = FLOW_ML1 
)
inline

Definition at line 286 of file event_handler_tree.hpp.

287  {
288  _c4dbgpf("node[{}]: end_map. multiline={} startline={} endline={}", m_parent->node_id, multiline, m_parent->pos.line, m_curr->pos.line);
289  _pop();
290  if(multiline)
291  {
292  ryml_disable_(FLOW_SL);
293  enable_(multiline_style);
294  }
295  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
mark container with single-line flow style < - seqs as <
Definition: node_type.hpp:56
void c4::yml::EventHandlerTree::begin_seq_key_flow ( )
inline

Definition at line 304 of file event_handler_tree.hpp.

305  {
306  RYML_ERR_PARSE_CB_(m_stack.m_callbacks, m_curr->pos, "ryml trees cannot handle containers as keys");
307  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::begin_seq_key_block ( )
inline

Definition at line 308 of file event_handler_tree.hpp.

309  {
310  RYML_ERR_PARSE_CB_(m_stack.m_callbacks, m_curr->pos, "ryml trees cannot handle containers as keys");
311  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::begin_seq_val_flow ( )
inline

Definition at line 313 of file event_handler_tree.hpp.

314  {
315  _c4dbgpf("node[{}]: begin_seq_val_flow", m_curr->node_id);
316  RYML_CHECK_BASIC_CB_(m_stack.m_callbacks, !ryml_hasany_(VAL));
317  ryml_enable_(SEQ|FLOW_SL);
318  _save_loc();
319  _push();
320  }
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
a seq: a parent of VAL/SEQ/MAP nodes
Definition: node_type.hpp:36
state * m_curr
current stack level: top of the stack. cached here for easier access.
mark container with single-line flow style < - seqs as <
Definition: node_type.hpp:56
void c4::yml::EventHandlerTree::begin_seq_val_block ( )
inline

Definition at line 321 of file event_handler_tree.hpp.

322  {
323  _c4dbgpf("node[{}]: begin_seq_val_block", m_curr->node_id);
324  RYML_CHECK_BASIC_CB_(m_stack.m_callbacks, !ryml_hasany_(VAL));
325  ryml_enable_(SEQ|BLOCK);
326  _save_loc();
327  _push();
328  }
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
mark container with block style < - seqs as <
Definition: node_type.hpp:136
a seq: a parent of VAL/SEQ/MAP nodes
Definition: node_type.hpp:36
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::end_seq_block ( )
inline

Definition at line 330 of file event_handler_tree.hpp.

331  {
332  _c4dbgpf("node[{}]: end_seq_block", m_parent->node_id, m_parent->pos.line, m_curr->pos.line);
333  _pop();
334  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::end_seq_flow ( bool  multiline,
type_bits  multiline_style = FLOW_ML1 
)
inline

Definition at line 336 of file event_handler_tree.hpp.

337  {
338  _c4dbgpf("node[{}]: end_seq. multiline={} startline={} endline={}", m_parent->node_id, multiline, m_parent->pos.line, m_curr->pos.line);
339  _pop();
340  if(multiline)
341  {
342  ryml_disable_(FLOW_SL);
343  enable_(multiline_style);
344  }
345  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
mark container with single-line flow style < - seqs as <
Definition: node_type.hpp:56
void c4::yml::EventHandlerTree::add_sibling ( )
inline

Definition at line 354 of file event_handler_tree.hpp.

355  {
356  #if defined(__GNUC__) && (__GNUC__ >= 6)
357  C4_SUPPRESS_WARNING_GCC_WITH_PUSH("-Wnull-dereference")
358  #endif
359  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_tree);
360  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_parent);
361  RYML_ASSERT_VISIT_CB_(m_stack.m_callbacks, m_tree->has_children(m_parent->node_id), m_tree, m_parent->node_id);
362  NodeData const* const prev = m_tree->m_buf; // watchout against relocation of the tree nodes
363  _set_state_(m_curr, m_tree->_append_child__unprotected(m_parent->node_id));
364  if(prev != m_tree->m_buf)
365  _refresh_after_relocation();
366  _c4dbgpf("node[{}]: added sibling={} prev={}", m_parent->node_id, m_curr->node_id, m_tree->prev_sibling(m_curr->node_id));
367  #if defined(__GNUC__) && (__GNUC__ >= 6)
368  C4_SUPPRESS_WARNING_GCC_POP
369  #endif
370  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
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 377 of file event_handler_tree.hpp.

378  {
379  if C4_UNLIKELY(m_tree->is_container(m_curr->node_id))
380  RYML_ERR_PARSE_CB_(m_stack.m_callbacks, m_curr->pos, "ryml trees cannot handle containers as keys");
381  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_parent);
382  RYML_ASSERT_VISIT_CB_(m_stack.m_callbacks, m_tree->is_seq(m_parent->node_id), m_tree, m_parent->node_id);
383  RYML_ASSERT_VISIT_CB_(m_stack.m_callbacks, !m_tree->is_container(m_curr->node_id), m_tree, m_curr->node_id);
384  RYML_ASSERT_VISIT_CB_(m_stack.m_callbacks, !m_tree->has_key(m_curr->node_id), m_tree, m_curr->node_id);
385  const NodeData tmp = _val2key_(*m_curr->tr_data);
386  ryml_disable_(VALMASK_|VAL_STYLE|VALNIL);
387  m_curr->tr_data->m_val = {};
389  m_curr->tr_data->m_type = tmp.m_type;
390  m_curr->tr_data->m_key = tmp.m_key;
391  }
the val is null (eg {a : } results in a null val)
Definition: node_type.hpp:46
mask of VALQUO|VAL_PLAIN : all the val scalar styles for val (not container styles!) ...
Definition: node_type.hpp:177
state * m_curr
current stack level: top of the stack. cached here for easier access.
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 399 of file event_handler_tree.hpp.

400  {
401  RYML_ERR_PARSE_CB_(m_stack.m_callbacks, m_curr->pos, "ryml trees cannot handle containers as keys");
402  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_scalar_plain_empty ( )
inlinenoexcept

Definition at line 412 of file event_handler_tree.hpp.

413  {
414  _c4dbgpf("node[{}]: set key scalar plain as empty", m_curr->node_id);
415  m_curr->tr_data->m_key.scalar = {};
416  ryml_enable_(KEY|KEY_PLAIN|KEYNIL);
417  }
the key is null (eg { : b} results in a null key)
Definition: node_type.hpp:45
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
mark key scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:155
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_scalar_plain_empty ( )
inlinenoexcept

Definition at line 418 of file event_handler_tree.hpp.

419  {
420  _c4dbgpf("node[{}]: set val scalar plain as empty", m_curr->node_id);
421  m_curr->tr_data->m_val.scalar = {};
422  ryml_enable_(VAL|VAL_PLAIN|VALNIL);
423  }
mark val scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:156
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
the val is null (eg {a : } results in a null val)
Definition: node_type.hpp:46
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_scalar_plain ( csubstr  scalar)
inlinenoexcept

Definition at line 425 of file event_handler_tree.hpp.

426  {
427  _c4dbgpf("node[{}]: set key scalar plain: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
428  m_curr->tr_data->m_key.scalar = scalar;
429  ryml_enable_(KEY|KEY_PLAIN);
430  }
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
mark key scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:155
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_scalar_plain ( csubstr  scalar)
inlinenoexcept

Definition at line 431 of file event_handler_tree.hpp.

432  {
433  _c4dbgpf("node[{}]: set val scalar plain: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
434  m_curr->tr_data->m_val.scalar = scalar;
435  ryml_enable_(VAL|VAL_PLAIN);
436  }
mark val scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:156
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_scalar_dquoted ( csubstr  scalar)
inlinenoexcept

Definition at line 439 of file event_handler_tree.hpp.

440  {
441  _c4dbgpf("node[{}]: set key scalar dquot: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
442  m_curr->tr_data->m_key.scalar = scalar;
443  ryml_enable_(KEY|KEY_DQUO);
444  }
mark key scalar as double quoted "
Definition: node_type.hpp:153
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_scalar_dquoted ( csubstr  scalar)
inlinenoexcept

Definition at line 445 of file event_handler_tree.hpp.

446  {
447  _c4dbgpf("node[{}]: set val scalar dquot: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
448  m_curr->tr_data->m_val.scalar = scalar;
449  ryml_enable_(VAL|VAL_DQUO);
450  }
mark val scalar as double quoted "
Definition: node_type.hpp:154
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_scalar_squoted ( csubstr  scalar)
inlinenoexcept

Definition at line 453 of file event_handler_tree.hpp.

454  {
455  _c4dbgpf("node[{}]: set key scalar squot: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
456  m_curr->tr_data->m_key.scalar = scalar;
457  ryml_enable_(KEY|KEY_SQUO);
458  }
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
mark key scalar as single quoted '
Definition: node_type.hpp:151
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_scalar_squoted ( csubstr  scalar)
inlinenoexcept

Definition at line 459 of file event_handler_tree.hpp.

460  {
461  _c4dbgpf("node[{}]: set val scalar squot: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
462  m_curr->tr_data->m_val.scalar = scalar;
463  ryml_enable_(VAL|VAL_SQUO);
464  }
mark val scalar as single quoted '
Definition: node_type.hpp:152
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_scalar_literal ( csubstr  scalar)
inlinenoexcept

Definition at line 467 of file event_handler_tree.hpp.

468  {
469  _c4dbgpf("node[{}]: set key scalar literal: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
470  m_curr->tr_data->m_key.scalar = scalar;
471  ryml_enable_(KEY|KEY_LITERAL);
472  }
mark key scalar as multiline, block literal |
Definition: node_type.hpp:147
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_scalar_literal ( csubstr  scalar)
inlinenoexcept

Definition at line 473 of file event_handler_tree.hpp.

474  {
475  _c4dbgpf("node[{}]: set val scalar literal: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
476  m_curr->tr_data->m_val.scalar = scalar;
477  ryml_enable_(VAL|VAL_LITERAL);
478  }
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
mark val scalar as multiline, block literal |
Definition: node_type.hpp:148
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_scalar_folded ( csubstr  scalar)
inlinenoexcept

Definition at line 481 of file event_handler_tree.hpp.

482  {
483  _c4dbgpf("node[{}]: set key scalar folded: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
484  m_curr->tr_data->m_key.scalar = scalar;
485  ryml_enable_(KEY|KEY_FOLDED);
486  }
mark key scalar as multiline, block folded >
Definition: node_type.hpp:149
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_scalar_folded ( csubstr  scalar)
inlinenoexcept

Definition at line 487 of file event_handler_tree.hpp.

488  {
489  _c4dbgpf("node[{}]: set val scalar folded: [{}]~~~{}~~~", m_curr->node_id, scalar.len, scalar);
490  m_curr->tr_data->m_val.scalar = scalar;
491  ryml_enable_(VAL|VAL_FOLDED);
492  }
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
mark val scalar as multiline, block folded >
Definition: node_type.hpp:150
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::mark_key_scalar_unfiltered ( )
inlinenoexcept

Definition at line 495 of file event_handler_tree.hpp.

496  {
497  ryml_enable_(KEY_UNFILT);
498  }
the key scalar was left unfiltered; the parser was set not to filter.
Definition: node_type.hpp:51
void c4::yml::EventHandlerTree::mark_val_scalar_unfiltered ( )
inlinenoexcept

Definition at line 499 of file event_handler_tree.hpp.

500  {
501  ryml_enable_(VAL_UNFILT);
502  }
the val scalar was left unfiltered; the parser was set not to filter.
Definition: node_type.hpp:52
void c4::yml::EventHandlerTree::set_key_anchor ( csubstr  anchor)
inline

Definition at line 511 of file event_handler_tree.hpp.

512  {
513  _c4dbgpf("node[{}]: set key anchor: [{}]~~~{}~~~", m_curr->node_id, anchor.len, anchor);
514  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_tree);
515  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, !ryml_hasany_(KEYREF));
516  RYML_ASSERT_PARSE_CB_(m_tree->callbacks(), !anchor.begins_with('&'), m_curr->pos);
517  ryml_enable_(KEYANCH);
518  m_curr->tr_data->m_key.anchor = anchor;
519  }
the key has an &anchor
Definition: node_type.hpp:41
a *reference: the key references an &anchor
Definition: node_type.hpp:39
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_anchor ( csubstr  anchor)
inline

Definition at line 520 of file event_handler_tree.hpp.

521  {
522  _c4dbgpf("node[{}]: set val anchor: [{}]~~~{}~~~", m_curr->node_id, anchor.len, anchor);
523  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_tree);
524  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, !ryml_hasany_(VALREF));
525  RYML_ASSERT_PARSE_CB_(m_tree->callbacks(), !anchor.begins_with('&'), m_curr->pos);
526  ryml_enable_(VALANCH);
527  m_curr->tr_data->m_val.anchor = anchor;
528  }
the val has an &anchor
Definition: node_type.hpp:42
a *reference: the val references an &anchor
Definition: node_type.hpp:40
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_ref ( csubstr  ref)
inline

Definition at line 530 of file event_handler_tree.hpp.

531  {
532  _c4dbgpf("node[{}]: set key ref: [{}]~~~{}~~~", m_curr->node_id, ref.len, ref);
533  RYML_ASSERT_PARSE_CB_(m_stack.m_callbacks, ref.begins_with('*'), m_curr->pos);
534  RYML_ASSERT_PARSE_CB_(m_stack.m_callbacks, !ryml_hasany_(KEYANCH), m_curr->pos);
535  ryml_enable_(KEY|KEYREF);
536  m_curr->tr_data->m_key.anchor = ref.sub(1);
537  m_curr->tr_data->m_key.scalar = ref;
538  }
the key has an &anchor
Definition: node_type.hpp:41
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
a *reference: the key references an &anchor
Definition: node_type.hpp:39
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_ref ( csubstr  ref)
inline

Definition at line 539 of file event_handler_tree.hpp.

540  {
541  _c4dbgpf("node[{}]: set val ref: [{}]~~~{}~~~", m_curr->node_id, ref.len, ref);
542  RYML_ASSERT_PARSE_CB_(m_stack.m_callbacks, ref.begins_with('*'), m_curr->pos);
543  RYML_ASSERT_PARSE_CB_(m_stack.m_callbacks, !ryml_hasany_(VALANCH), m_curr->pos);
544  ryml_enable_(VAL|VALREF);
545  m_curr->tr_data->m_val.anchor = ref.sub(1);
546  m_curr->tr_data->m_val.scalar = ref;
547  }
the val has an &anchor
Definition: node_type.hpp:42
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
a *reference: the val references an &anchor
Definition: node_type.hpp:40
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_key_tag ( csubstr  tag)
inline

Definition at line 556 of file event_handler_tree.hpp.

557  {
558  _c4dbgpf("node[{}]: set key tag: [{}]~~~{}~~~", m_curr->node_id, tag.len, tag);
559  ryml_enable_(KEYTAG);
560  m_curr->tr_data->m_key.tag = tag;
561  }
the key has a tag
Definition: node_type.hpp:43
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::set_val_tag ( csubstr  tag)
inline

Definition at line 562 of file event_handler_tree.hpp.

563  {
564  _c4dbgpf("node[{}]: set val tag: [{}]~~~{}~~~", m_curr->node_id, tag.len, tag);
565  ryml_enable_(VALTAG);
566  m_curr->tr_data->m_val.tag = tag;
567  }
the val has a tag
Definition: node_type.hpp:44
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerTree::add_directive_yaml ( csubstr  yaml_version)
inline

Definition at line 576 of file event_handler_tree.hpp.

577  {
578  _c4dbgpf("%YAML directive! version={}", yaml_version);
579  (void)yaml_version;
580  }
void c4::yml::EventHandlerTree::add_directive_tag ( csubstr  handle,
csubstr  prefix 
)
inline

Definition at line 582 of file event_handler_tree.hpp.

583  {
584  _c4dbgpf("%TAG directive! handle={} prefix={} id={}", handle, prefix, m_curr_doc);
585  if C4_UNLIKELY(!m_tree->m_tag_directives.add(handle, prefix, m_curr_doc))
586  RYML_ERR_PARSE_CB_(m_stack.m_callbacks, m_curr->pos, "too many %TAG directives");
587  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
substr c4::yml::EventHandlerTree::arena ( )
inline

Definition at line 596 of file event_handler_tree.hpp.

597  {
598  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_tree);
599  return m_tree->m_arena.first(m_tree->m_arena_pos);
600  }
substr c4::yml::EventHandlerTree::arena_rem ( )
inline

Definition at line 601 of file event_handler_tree.hpp.

602  {
603  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_tree);
604  return m_tree->m_arena.sub(m_tree->m_arena_pos);
605  }
substr c4::yml::EventHandlerTree::alloc_arena ( size_t  len)
inline

Definition at line 606 of file event_handler_tree.hpp.

607  {
608  return m_tree->alloc_arena(len);
609  }
void c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_start_parse ( const char *  filename,
substr  ymlsrc 
)
inlineprotectedinherited

Definition at line 58 of file event_handler_stack.hpp.

Referenced by start_parse().

59  {
60  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_curr != nullptr);
61  m_curr->start_parse(filename, m_curr->node_id);
62  m_src = ymlsrc;
63  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_finish_parse ( )
inlineprotectedinherited

Definition at line 65 of file event_handler_stack.hpp.

Referenced by finish_parse().

66  {
67  }
void c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_reset_root ( )
inlineprotectedinherited

Definition at line 71 of file event_handler_stack.hpp.

Referenced by reset().

72  {
73  m_stack.clear();
74  m_stack.push({});
75  m_parent = nullptr;
76  m_curr = &m_stack.top();
77  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_reset_non_root ( )
inlineprotectedinherited

Definition at line 79 of file event_handler_stack.hpp.

Referenced by reset().

80  {
81  m_stack.clear();
82  m_stack.push({}); // parent
83  m_stack.push({}); // node
84  m_parent = &m_stack.top(1);
85  m_curr = &m_stack.top();
86  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_push ( )
inlineprotectedinherited

Definition at line 88 of file event_handler_stack.hpp.

89  {
90  m_stack.push_top();
91  m_parent = &m_stack.top(1); // don't use m_curr. watch out for relocations inside the prev push
92  m_curr = &m_stack.top();
93  m_curr->reset_after_push();
94  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
void c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_pop ( )
inlineprotectedinherited

Definition at line 96 of file event_handler_stack.hpp.

97  {
98  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_parent);
99  RYML_ASSERT_BASIC_CB_(m_stack.m_callbacks, m_stack.size() > 1);
100  m_parent->reset_before_pop(*m_curr);
101  m_stack.pop();
102  m_parent = m_stack.size() > 1 ? &m_stack.top(1) : nullptr;
103  m_curr = &m_stack.top();
104  #ifdef RYML_DBG
105  if(m_parent)
106  _c4dbgpf("popped! top is now node={} (parent={})", m_curr->node_id, m_parent->node_id);
107  else
108  _c4dbgpf("popped! top is now node={} @ ROOT", m_curr->node_id);
109  #endif
110  }
state * m_curr
current stack level: top of the stack. cached here for easier access.
bool c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_should_push_on_begin_doc ( ) const
inlineprotectedinherited

Definition at line 121 of file event_handler_stack.hpp.

Referenced by begin_doc().

122  {
123  const bool is_root = (m_stack.size() == 1u);
124  return is_root && (m_curr->has_children || ryml_has_any_(DOC|VAL|MAP|SEQ));
125  }
#define ryml_has_any_(bits)
a document
Definition: node_type.hpp:37
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
Definition: node_type.hpp:34
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
Definition: node_type.hpp:35
a seq: a parent of VAL/SEQ/MAP nodes
Definition: node_type.hpp:36
state * m_curr
current stack level: top of the stack. cached here for easier access.
bool c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::_stack_should_pop_on_end_doc ( ) const
inlineprotectedinherited

Definition at line 127 of file event_handler_stack.hpp.

Referenced by end_doc(), and end_doc_expl().

128  {
129  const bool is_root = (m_stack.size() == 1u);
130  return !is_root && ryml_has_any_(DOC);
131  }
#define ryml_has_any_(bits)
a document
Definition: node_type.hpp:37

Member Data Documentation

state* c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::m_parent
inherited

parent of the current stack level.

Definition at line 48 of file event_handler_stack.hpp.

Referenced by actually_val_is_first_key_of_new_map_flow(), add_sibling(), end_map_block(), end_map_flow(), end_seq_block(), end_seq_flow(), and reset().

substr c4::yml::EventHandlerStack< EventHandlerTree , EventHandlerTreeState >::m_src
inherited

Definition at line 49 of file event_handler_stack.hpp.


The documentation for this struct was generated from the following file: