rapidyaml  0.7.0
parse and emit YAML, and do it fast
Parse in arena with temporary parser

parse a read-only (immutable) YAML source buffer. More...

Functions

void c4::yml::parse_in_arena (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 during the parse. More...
 
void c4::yml::parse_in_arena (csubstr yaml, Tree *t, id_type node_id)
 (2) like (1) but no filename will be reported More...
 
void c4::yml::parse_in_arena (csubstr filename, csubstr yaml, Tree *t)
 (3) parse YAML into an existing tree, into its root node. More...
 
void c4::yml::parse_in_arena (csubstr yaml, Tree *t)
 (4) like (3) but no filename will be reported More...
 
void c4::yml::parse_in_arena (csubstr filename, csubstr yaml, NodeRef node)
 (5) like (1) but the node is given as a NodeRef More...
 
void c4::yml::parse_in_arena (csubstr yaml, NodeRef node)
 (6) like (5) but no filename will be reported More...
 
Tree c4::yml::parse_in_arena (csubstr filename, csubstr yaml)
 (7) create a new tree, and parse YAML into its root node. More...
 
Tree c4::yml::parse_in_arena (csubstr yaml)
 (8) like (7) but no filename will be reported More...
 
void c4::yml::parse_json_in_arena (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 during the parse. More...
 
void c4::yml::parse_json_in_arena (csubstr json, Tree *t, id_type node_id)
 (2) like (1) but no filename will be reported More...
 
void c4::yml::parse_json_in_arena (csubstr filename, csubstr json, Tree *t)
 (3) parse JSON into an existing tree, into its root node. More...
 
void c4::yml::parse_json_in_arena (csubstr json, Tree *t)
 (4) like (3) but no filename will be reported More...
 
void c4::yml::parse_json_in_arena (csubstr filename, csubstr json, NodeRef node)
 (5) like (1) but the node is given as a NodeRef More...
 
void c4::yml::parse_json_in_arena (csubstr json, NodeRef node)
 (6) like (5) but no filename will be reported More...
 
Tree c4::yml::parse_json_in_arena (csubstr filename, csubstr json)
 (7) create a new tree, and parse JSON into its root node. More...
 
Tree c4::yml::parse_json_in_arena (csubstr json)
 (8) like (7) but no filename will be reported More...
 

Detailed Description

parse a read-only (immutable) YAML source buffer.

This is achieved by first copying the contents of the buffer to the tree's arena, and then calling parse_in_arena() .

Note
These freestanding functions use a temporary parser object, and are convenience functions to easily one-off parse YAML without the need to instantiate a separate parser. Note that some properties (notably node locations in the original source code) are only available through the parser class. If you need access to any of these properties, use the appropriate overload from Parse in arena with existing parser
Warning
overloads receiving a substr YAML buffer are intentionally left undefined, such that calling parse_in_arena() with a substr will cause a linker error. This is to prevent an accidental copy of the source buffer to the tree's arena, because substr (which is mutable) is implicitly convertible to csubstr (which is immutable). If you really intend to parse a mutable buffer in the tree's arena, convert it first to immutable by assigning the substr to a csubstr prior to calling parse_in_arena(). This is not needed for parse_in_place() because csubstr is not implicitly convertible to substr. To be clear:
{c++}
substr mutable_buffer = ...;
parser.parse_in_arena(mutable_buffer); // linker error
csubstr immutable_buffer = ...;
parser.parse_in_arena(immutable_buffer); // ok

Function Documentation

◆ parse_in_arena() [1/8]

void c4::yml::parse_in_arena ( 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 during the parse.

Definition at line 101 of file parse.cpp.

101 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(yaml); parse_in_place(&parser, filename, src, t, node_id); }
Tree parse_in_place(substr yaml)
(8) like (7) but no filename will be reported
Definition: parse.cpp:67
ParseEngine< EventHandlerTree > Parser
This is the main ryml parser, where the parser events are handled to create a ryml tree.
Definition: fwd.hpp:19

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), and c4::yml::parse_in_place().

◆ parse_in_arena() [2/8]

void c4::yml::parse_in_arena ( csubstr  yaml,
Tree t,
id_type  node_id 
)

(2) like (1) but no filename will be reported

Definition at line 102 of file parse.cpp.

102 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(yaml); parse_in_place(&parser, {} , src, t, node_id); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), and c4::yml::parse_in_place().

◆ parse_in_arena() [3/8]

void c4::yml::parse_in_arena ( csubstr  filename,
csubstr  yaml,
Tree t 
)

(3) parse YAML into an existing tree, into its root node.

Definition at line 103 of file parse.cpp.

103 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(yaml); parse_in_place(&parser, filename, src, t, t->root_id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_in_place(), and c4::yml::Tree::root_id().

◆ parse_in_arena() [4/8]

void c4::yml::parse_in_arena ( csubstr  yaml,
Tree t 
)

(4) like (3) but no filename will be reported

Definition at line 104 of file parse.cpp.

104 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(yaml); parse_in_place(&parser, {} , src, t, t->root_id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_in_place(), and c4::yml::Tree::root_id().

◆ parse_in_arena() [5/8]

void c4::yml::parse_in_arena ( csubstr  filename,
csubstr  yaml,
NodeRef  node 
)

(5) like (1) but the node is given as a NodeRef

Definition at line 105 of file parse.cpp.

105 { RYML_CHECK(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler); substr src = node.tree()->copy_to_arena(yaml); parse_in_place(&parser, filename, src, node.tree(), node.id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::NodeRef::id(), c4::yml::NodeRef::invalid(), c4::yml::parse_in_place(), and c4::yml::NodeRef::tree().

◆ parse_in_arena() [6/8]

void c4::yml::parse_in_arena ( csubstr  yaml,
NodeRef  node 
)

(6) like (5) but no filename will be reported

Definition at line 106 of file parse.cpp.

106 { RYML_CHECK(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler); substr src = node.tree()->copy_to_arena(yaml); parse_in_place(&parser, {} , src, node.tree(), node.id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::NodeRef::id(), c4::yml::NodeRef::invalid(), c4::yml::parse_in_place(), and c4::yml::NodeRef::tree().

◆ parse_in_arena() [7/8]

Tree c4::yml::parse_in_arena ( csubstr  filename,
csubstr  yaml 
)

(7) create a new tree, and parse YAML into its root node.

Definition at line 107 of file parse.cpp.

107 { Parser::handler_type event_handler; Parser parser(&event_handler); Tree tree(parser.callbacks()); substr src = tree.copy_to_arena(yaml); parse_in_place(&parser, filename, src, &tree, tree.root_id()); return tree; }

References c4::yml::ParseEngine< EventHandler >::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_in_place(), and c4::yml::Tree::root_id().

◆ parse_in_arena() [8/8]

Tree c4::yml::parse_in_arena ( csubstr  yaml)

(8) like (7) but no filename will be reported

Definition at line 108 of file parse.cpp.

108 { Parser::handler_type event_handler; Parser parser(&event_handler); Tree tree(parser.callbacks()); substr src = tree.copy_to_arena(yaml); parse_in_place(&parser, {} , src, &tree, tree.root_id()); return tree; }

References c4::yml::ParseEngine< EventHandler >::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_in_place(), and c4::yml::Tree::root_id().

◆ parse_json_in_arena() [1/8]

void c4::yml::parse_json_in_arena ( 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 during the parse.

Definition at line 122 of file parse.cpp.

122 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(json); parse_json_in_place(&parser, filename, src, t, node_id); }
Tree parse_json_in_place(substr json)
(8) like (7) but no filename will be reported
Definition: parse.cpp:87

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), and c4::yml::parse_json_in_place().

◆ parse_json_in_arena() [2/8]

void c4::yml::parse_json_in_arena ( csubstr  json,
Tree t,
id_type  node_id 
)

(2) like (1) but no filename will be reported

Definition at line 123 of file parse.cpp.

123 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(json); parse_json_in_place(&parser, {} , src, t, node_id); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), and c4::yml::parse_json_in_place().

◆ parse_json_in_arena() [3/8]

void c4::yml::parse_json_in_arena ( csubstr  filename,
csubstr  json,
Tree t 
)

(3) parse JSON into an existing tree, into its root node.

Definition at line 124 of file parse.cpp.

124 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(json); parse_json_in_place(&parser, filename, src, t, t->root_id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_json_in_place(), and c4::yml::Tree::root_id().

◆ parse_json_in_arena() [4/8]

void c4::yml::parse_json_in_arena ( csubstr  json,
Tree t 
)

(4) like (3) but no filename will be reported

Definition at line 125 of file parse.cpp.

125 { RYML_CHECK(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler); substr src = t->copy_to_arena(json); parse_json_in_place(&parser, {} , src, t, t->root_id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_json_in_place(), and c4::yml::Tree::root_id().

◆ parse_json_in_arena() [5/8]

void c4::yml::parse_json_in_arena ( csubstr  filename,
csubstr  json,
NodeRef  node 
)

(5) like (1) but the node is given as a NodeRef

Definition at line 126 of file parse.cpp.

126 { RYML_CHECK(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler); substr src = node.tree()->copy_to_arena(json); parse_json_in_place(&parser, filename, src, node.tree(), node.id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::NodeRef::id(), c4::yml::NodeRef::invalid(), c4::yml::parse_json_in_place(), and c4::yml::NodeRef::tree().

◆ parse_json_in_arena() [6/8]

void c4::yml::parse_json_in_arena ( csubstr  json,
NodeRef  node 
)

(6) like (5) but no filename will be reported

Definition at line 127 of file parse.cpp.

127 { RYML_CHECK(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler); substr src = node.tree()->copy_to_arena(json); parse_json_in_place(&parser, {} , src, node.tree(), node.id()); }

References c4::yml::Tree::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::NodeRef::id(), c4::yml::NodeRef::invalid(), c4::yml::parse_json_in_place(), and c4::yml::NodeRef::tree().

◆ parse_json_in_arena() [7/8]

Tree c4::yml::parse_json_in_arena ( csubstr  filename,
csubstr  json 
)

(7) create a new tree, and parse JSON into its root node.

Definition at line 128 of file parse.cpp.

128 { Parser::handler_type event_handler; Parser parser(&event_handler); Tree tree(parser.callbacks()); substr src = tree.copy_to_arena(json); parse_json_in_place(&parser, filename, src, &tree, tree.root_id()); return tree; }

References c4::yml::ParseEngine< EventHandler >::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_json_in_place(), and c4::yml::Tree::root_id().

◆ parse_json_in_arena() [8/8]

Tree c4::yml::parse_json_in_arena ( csubstr  json)

(8) like (7) but no filename will be reported

Definition at line 129 of file parse.cpp.

129 { Parser::handler_type event_handler; Parser parser(&event_handler); Tree tree(parser.callbacks()); substr src = tree.copy_to_arena(json); parse_json_in_place(&parser, {} , src, &tree, tree.root_id()); return tree; }

References c4::yml::ParseEngine< EventHandler >::callbacks(), c4::yml::Tree::copy_to_arena(), c4::yml::parse_json_in_place(), and c4::yml::Tree::root_id().