rapidyaml  0.8.0
parse and emit YAML, and do it fast
Parse in arena with existing parser

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

Macros

#define RYML_DONT_PARSE_SUBSTR_IN_ARENA
 

Functions

void c4::yml::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 during the parse. More...
 
void c4::yml::parse_in_arena (Parser *parser, csubstr yaml, Tree *t, id_type node_id)
 (2) like (1) but no filename will be reported More...
 
void c4::yml::parse_in_arena (Parser *parser, csubstr filename, csubstr yaml, Tree *t)
 (3) parse YAML into an existing tree, into its root node. More...
 
void c4::yml::parse_in_arena (Parser *parser, csubstr yaml, Tree *t)
 (4) like (3) but no filename will be reported More...
 
void c4::yml::parse_in_arena (Parser *parser, csubstr filename, csubstr yaml, NodeRef node)
 (5) like (1) but the node is given as a NodeRef More...
 
void c4::yml::parse_in_arena (Parser *parser, csubstr yaml, NodeRef node)
 (6) like (5) but no filename will be reported More...
 
Tree c4::yml::parse_in_arena (Parser *parser, csubstr filename, csubstr yaml)
 (7) create a new tree, and parse YAML into its root node. More...
 
Tree c4::yml::parse_in_arena (Parser *parser, csubstr yaml)
 (8) like (7) but no filename will be reported More...
 
void c4::yml::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 during the parse. More...
 
void c4::yml::parse_json_in_arena (Parser *parser, 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 (Parser *parser, 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 (Parser *parser, csubstr json, Tree *t)
 (4) like (3) but no filename will be reported More...
 
void c4::yml::parse_json_in_arena (Parser *parser, 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 (Parser *parser, csubstr json, NodeRef node)
 (6) like (5) but no filename will be reported More...
 
Tree c4::yml::parse_json_in_arena (Parser *parser, csubstr filename, csubstr json)
 (7) create a new tree, and parse JSON into its root node. More...
 
Tree c4::yml::parse_json_in_arena (Parser *parser, 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() . All the resulting scalars will be filtered in the arena. These overloads accept an existing parser object, and provide the opportunity to use special parser options.

See also
ParserOptions
Note
These freestanding functions use a temporary parser object, and are convenience functions to easily 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

Macro Definition Documentation

◆ RYML_DONT_PARSE_SUBSTR_IN_ARENA

#define RYML_DONT_PARSE_SUBSTR_IN_ARENA
Value:
"" \
"Do not pass a (mutable) substr to parse_in_arena(); " \
"if you have a substr, it should be parsed in place. " \
"Consider using parse_in_place() instead, or convert " \
"the buffer to csubstr prior to calling. This function " \
" is deliberately left undefined, so that calling it " \
"will cause a linker error."

Definition at line 179 of file parse.hpp.

Function Documentation

◆ parse_in_arena() [1/8]

◆ parse_in_arena() [2/8]

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

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

Definition at line 92 of file parse.cpp.

92 { RYML_CHECK(t); substr src = t->copy_to_arena(yaml); parse_in_place(parser, {} , src, t, node_id); }

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

◆ parse_in_arena() [3/8]

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

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

Definition at line 93 of file parse.cpp.

93 { RYML_CHECK(t); substr src = t->copy_to_arena(yaml); parse_in_place(parser, filename, src, t, t->root_id()); }

References 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 ( Parser parser,
csubstr  yaml,
Tree t 
)

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

Definition at line 94 of file parse.cpp.

94 { RYML_CHECK(t); substr src = t->copy_to_arena(yaml); parse_in_place(parser, {} , src, t, t->root_id()); }

References 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 ( Parser parser,
csubstr  filename,
csubstr  yaml,
NodeRef  node 
)

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

Definition at line 95 of file parse.cpp.

95 { RYML_CHECK(!node.invalid()); substr src = node.tree()->copy_to_arena(yaml); parse_in_place(parser, filename, src, node.tree(), node.id()); }

References 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 ( Parser parser,
csubstr  yaml,
NodeRef  node 
)

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

Definition at line 96 of file parse.cpp.

96 { RYML_CHECK(!node.invalid()); substr src = node.tree()->copy_to_arena(yaml); parse_in_place(parser, {} , src, node.tree(), node.id()); }

References 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 ( Parser parser,
csubstr  filename,
csubstr  yaml 
)

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

Definition at line 97 of file parse.cpp.

97 { RYML_CHECK(parser); RYML_CHECK(parser->m_evt_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 ( Parser parser,
csubstr  yaml 
)

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

Definition at line 98 of file parse.cpp.

98 { RYML_CHECK(parser); RYML_CHECK(parser->m_evt_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 ( 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 during the parse.

Definition at line 112 of file parse.cpp.

112 { RYML_CHECK(t); 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::copy_to_arena(), and c4::yml::parse_json_in_place().

Referenced by sample::sample_json().

◆ parse_json_in_arena() [2/8]

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

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

Definition at line 113 of file parse.cpp.

113 { RYML_CHECK(t); substr src = t->copy_to_arena(json); parse_json_in_place(parser, {} , src, t, node_id); }

References 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 ( Parser parser,
csubstr  filename,
csubstr  json,
Tree t 
)

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

Definition at line 114 of file parse.cpp.

114 { RYML_CHECK(t); substr src = t->copy_to_arena(json); parse_json_in_place(parser, filename, src, t, t->root_id()); }

References 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 ( Parser parser,
csubstr  json,
Tree t 
)

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

Definition at line 115 of file parse.cpp.

115 { RYML_CHECK(t); substr src = t->copy_to_arena(json); parse_json_in_place(parser, {} , src, t, t->root_id()); }

References 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 ( Parser parser,
csubstr  filename,
csubstr  json,
NodeRef  node 
)

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

Definition at line 116 of file parse.cpp.

116 { RYML_CHECK(!node.invalid()); substr src = node.tree()->copy_to_arena(json); parse_json_in_place(parser, filename, src, node.tree(), node.id()); }

References 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 ( Parser parser,
csubstr  json,
NodeRef  node 
)

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

Definition at line 117 of file parse.cpp.

117 { RYML_CHECK(!node.invalid()); substr src = node.tree()->copy_to_arena(json); parse_json_in_place(parser, {} , src, node.tree(), node.id()); }

References 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 ( Parser parser,
csubstr  filename,
csubstr  json 
)

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

Definition at line 118 of file parse.cpp.

118 { RYML_CHECK(parser); RYML_CHECK(parser->m_evt_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 ( Parser parser,
csubstr  json 
)

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

Definition at line 119 of file parse.cpp.

119 { RYML_CHECK(parser); RYML_CHECK(parser->m_evt_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().