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)
28 _RYML_ASSERT_BASIC(parser);
29 _RYML_ASSERT_BASIC(t);
30 if(!parser->m_evt_handler)
31 _RYML_ERR_BASIC_(t->m_callbacks,
"event handler is not set");
32 parser->m_evt_handler->reset(t, node_id);
33 _RYML_ASSERT_BASIC(parser->m_evt_handler->m_tree == t);
39 _reset_tree_handler(parser, t, node_id);
45 _reset_tree_handler(parser, t, node_id);
137 for(
size_t i = 0; i < src.len; ++i)
139 const char c = src.str[i];
140 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
id_type root_id() const
Get the id of the root node. The tree must not be empty.
void reserve(id_type node_capacity=RYML_DEFAULT_TREE_CAPACITY)
Callbacks const & callbacks() const
substr copy_to_arena(csubstr s)
copy the given string to the tree's arena, growing the arena 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 to 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...
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
Options to give to the parser to control its behavior.