rapidyaml  0.16.0
parseandemitYAML,anddoitfast
Parse in arena with existing parser

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

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 = mutable_buffer; // convert first to csubstr parser.parse_in_arena(immutable_buffer); // ok

  • ```

Function Documentation

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

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

Definition at line 210 of file parse.cpp.

210 { substr src = checkcp_(parser, tree, yaml); parse_yaml_(parser, {} , src, tree, node_id); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
void c4::yml::parse_in_arena ( Parser *  parser,
csubstr  filename,
csubstr  yaml,
Tree *  tree 
)

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

Definition at line 211 of file parse.cpp.

211 { substr src = checkcp_(parser, tree, yaml); parse_yaml_(parser, filename, src, tree, tree->root_id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
void c4::yml::parse_in_arena ( Parser *  parser,
csubstr  yaml,
Tree *  tree 
)

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

Definition at line 212 of file parse.cpp.

212 { substr src = checkcp_(parser, tree, yaml); parse_yaml_(parser, {} , src, tree, tree->root_id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
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 213 of file parse.cpp.

213 { substr src = checkcp_(parser, node, yaml); parse_yaml_(parser, filename, src, node.tree(), node.id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
void c4::yml::parse_in_arena ( Parser *  parser,
csubstr  yaml,
NodeRef  node 
)

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

Definition at line 214 of file parse.cpp.

214 { substr src = checkcp_(parser, node, yaml); parse_yaml_(parser, {} , src, node.tree(), node.id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
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 215 of file parse.cpp.

215 { check_(parser); Tree tree(parser->callbacks()); substr src = cpsrc_(&tree, yaml); parse_yaml_(parser, filename, src, &tree, tree.root_id()); return tree; }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
Tree c4::yml::parse_in_arena ( Parser *  parser,
csubstr  yaml 
)

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

Definition at line 216 of file parse.cpp.

216 { check_(parser); Tree tree(parser->callbacks()); substr src = cpsrc_(&tree, yaml); parse_yaml_(parser, {} , src, &tree, tree.root_id()); return tree; }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
void c4::yml::parse_json_in_arena ( Parser *  parser,
csubstr  filename,
csubstr  json,
Tree *  tree,
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 231 of file parse.cpp.

Referenced by sample_json().

231 { substr src = checkcp_(parser, tree, json); parse_json_(parser, filename, src, tree, node_id); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
void c4::yml::parse_json_in_arena ( Parser *  parser,
csubstr  json,
Tree *  tree,
id_type  node_id 
)

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

Definition at line 232 of file parse.cpp.

232 { substr src = checkcp_(parser, tree, json); parse_json_(parser, {} , src, tree, node_id); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
void c4::yml::parse_json_in_arena ( Parser *  parser,
csubstr  filename,
csubstr  json,
Tree *  tree 
)

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

Definition at line 233 of file parse.cpp.

233 { substr src = checkcp_(parser, tree, json); parse_json_(parser, filename, src, tree, tree->root_id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
void c4::yml::parse_json_in_arena ( Parser *  parser,
csubstr  json,
Tree *  tree 
)

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

Definition at line 234 of file parse.cpp.

234 { substr src = checkcp_(parser, tree, json); parse_json_(parser, {} , src, tree, tree->root_id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
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 235 of file parse.cpp.

235 { substr src = checkcp_(parser, node, json); parse_json_(parser, filename, src, node.tree(), node.id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
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 236 of file parse.cpp.

236 { substr src = checkcp_(parser, node, json); parse_json_(parser, {} , src, node.tree(), node.id()); }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
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 237 of file parse.cpp.

237 { check_(parser); Tree tree(parser->callbacks()); substr src = cpsrc_(&tree, json); parse_json_(parser, filename, src, &tree, tree.root_id()); return tree; }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
Tree c4::yml::parse_json_in_arena ( Parser *  parser,
csubstr  json 
)

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

Definition at line 238 of file parse.cpp.

238 { check_(parser); Tree tree(parser->callbacks()); substr src = cpsrc_(&tree, json); parse_json_(parser, {} , src, &tree, tree.root_id()); return tree; }
Parser parser
Definition: parse.cpp:117
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355