3 #ifndef _C4_YML_NODE_HPP_
6 #ifndef _C4_YML_PARSE_ENGINE_HPP_
9 #ifndef _C4_YML_PARSE_ENGINE_DEF_HPP_
12 #ifndef _C4_YML_EVENT_HANDLER_TREE_HPP_
23 template class ParseEngine<EventHandlerTree>;
26 inline void _reset_tree_handler(
Parser *parser, Tree *t,
id_type node_id)
30 if(!parser->m_evt_handler)
31 _RYML_CB_ERR(t->m_callbacks,
"event handler is not set");
32 parser->m_evt_handler->reset(t, node_id);
33 RYML_ASSERT(parser->m_evt_handler->m_tree == t);
39 _reset_tree_handler(parser, t, node_id);
45 _reset_tree_handler(parser, t, node_id);
134 if(indentation + 1 > s.len)
136 for(
size_t i = s.len-indentation-1; i !=
size_t(-1); --i)
140 csubstr rem = s.sub(i + 1);
141 size_t first = rem.first_not_of(
' ');
142 first = (first !=
npos) ? first : rem.len;
143 if(first > indentation)
155 for(
size_t i = 0; i < src.len; ++i)
157 const char c = src.str[i];
158 num_nodes += (c ==
'\n') || (c ==
',') || (c ==
'[') || (c ==
'{');
A reference to a node in an existing yaml tree, offering a more convenient API than the index-based A...
id_type id() const noexcept
bool invalid() const noexcept
true if the object is not referring to any existing or seed node.
This is the main driver of parsing logic: it scans the YAML or JSON source for tokens,...
void parse_json_in_place_ev(csubstr filename, substr src)
parse JSON in place, emitting events to the current handler
void parse_in_place_ev(csubstr filename, substr src)
parse YAML in place, emitting events to the current handler
Callbacks const & callbacks() const
Get the current callbacks in the parser.
EventHandler handler_type
Callbacks const & callbacks() const
id_type root_id()
Get the id of the root node.
substr copy_to_arena(csubstr s)
copy the given substr to the tree's arena, growing it by the required size
void parse_in_arena(Parser *parser, csubstr filename, csubstr yaml, Tree *t, id_type node_id)
(1) parse YAML into an existing tree node. The filename will be used in any error messages arising du...
void parse_json_in_arena(Parser *parser, csubstr filename, csubstr json, Tree *t, id_type node_id)
(1) parse JSON into an existing tree node. The filename will be used in any error messages arising du...
void parse_json_in_place(Parser *parser, csubstr filename, substr json, Tree *t, id_type node_id)
(1) parse JSON into an existing tree node. The filename will be used in any error messages arising du...
void parse_in_place(Parser *parser, csubstr filename, substr yaml, Tree *t, id_type node_id)
(1) parse YAML into an existing tree node.
ParseEngine< EventHandlerTree > Parser
This is the main ryml parser, where the parser events are handled to create a ryml tree.
id_type estimate_tree_capacity(csubstr src)
Quickly inspect the source to estimate the number of nodes the resulting tree is likely have.
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...
@ npos
a null string position
size_t _find_last_newline_and_larger_indentation(csubstr s, size_t indentation) noexcept