rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
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, ParserOptions const &opts={})
 (1) parse YAML into an existing tree node. The filename will be used in any error messages arising during the parse.
void c4::yml::parse_in_arena (csubstr yaml, Tree *t, id_type node_id, ParserOptions const &opts={})
 (2) like (1) but no filename will be reported
void c4::yml::parse_in_arena (csubstr filename, csubstr yaml, Tree *t, ParserOptions const &opts={})
 (3) parse YAML into an existing tree, into its root node.
void c4::yml::parse_in_arena (csubstr yaml, Tree *t, ParserOptions const &opts={})
 (4) like (3) but no filename will be reported
void c4::yml::parse_in_arena (csubstr filename, csubstr yaml, NodeRef node, ParserOptions const &opts={})
 (5) like (1) but the node is given as a NodeRef
void c4::yml::parse_in_arena (csubstr yaml, NodeRef node, ParserOptions const &opts={})
 (6) like (5) but no filename will be reported
Tree c4::yml::parse_in_arena (csubstr filename, csubstr yaml, ParserOptions const &opts={})
 (7) create a new tree, and parse YAML into its root node.
Tree c4::yml::parse_in_arena (csubstr yaml, ParserOptions const &opts={})
 (8) like (7) but no filename will be reported
void c4::yml::parse_json_in_arena (csubstr filename, csubstr json, Tree *t, id_type node_id, ParserOptions const &opts={})
 (1) parse JSON into an existing tree node. The filename will be used in any error messages arising during the parse.
void c4::yml::parse_json_in_arena (csubstr json, Tree *t, id_type node_id, ParserOptions const &opts={})
 (2) like (1) but no filename will be reported
void c4::yml::parse_json_in_arena (csubstr filename, csubstr json, Tree *t, ParserOptions const &opts={})
 (3) parse JSON into an existing tree, into its root node.
void c4::yml::parse_json_in_arena (csubstr json, Tree *t, ParserOptions const &opts={})
 (4) like (3) but no filename will be reported
void c4::yml::parse_json_in_arena (csubstr filename, csubstr json, NodeRef node, ParserOptions const &opts={})
 (5) like (1) but the node is given as a NodeRef
void c4::yml::parse_json_in_arena (csubstr json, NodeRef node, ParserOptions const &opts={})
 (6) like (5) but no filename will be reported
Tree c4::yml::parse_json_in_arena (csubstr filename, csubstr json, ParserOptions const &opts={})
 (7) create a new tree, and parse JSON into its root node.
Tree c4::yml::parse_json_in_arena (csubstr json, ParserOptions const &opts={})
 (8) like (7) but no filename will be reported

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:
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 now
basic_substring< char > substr
a mutable string view
Definition substr.hpp:2356
basic_substring< const char > csubstr
an immutable string view
Definition substr.hpp:2357

Function Documentation

◆ parse_in_arena() [1/8]

void c4::yml::parse_in_arena ( csubstr filename,
csubstr yaml,
Tree * tree,
id_type node_id,
ParserOptions const & opts )

(1) parse YAML into an existing tree node. The filename will be used in any error messages arising during the parse.

Definition at line 219 of file parse.cpp.

219{ substr src = checkcp_(tree, yaml); TmpParser tmp(tree, opts); parse_yaml_(&tmp.parser, filename, src, tree, node_id); }

◆ parse_in_arena() [2/8]

void c4::yml::parse_in_arena ( csubstr yaml,
Tree * tree,
id_type node_id,
ParserOptions const & opts )

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

Definition at line 220 of file parse.cpp.

220{ substr src = checkcp_(tree, yaml); TmpParser tmp(tree, opts); parse_yaml_(&tmp.parser, {} , src, tree, node_id); }

◆ parse_in_arena() [3/8]

void c4::yml::parse_in_arena ( csubstr filename,
csubstr yaml,
Tree * tree,
ParserOptions const & opts )

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

Definition at line 221 of file parse.cpp.

221{ substr src = checkcp_(tree, yaml); TmpParser tmp(tree, opts); parse_yaml_(&tmp.parser, filename, src, tree, tree->root_id()); }
id_type root_id() const
Get the id of the root node. The tree must not be empty. The tree can be empty only when constructed ...
Definition tree.hpp:333

◆ parse_in_arena() [4/8]

void c4::yml::parse_in_arena ( csubstr yaml,
Tree * tree,
ParserOptions const & opts )

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

Definition at line 222 of file parse.cpp.

222{ substr src = checkcp_(tree, yaml); TmpParser tmp(tree, opts); parse_yaml_(&tmp.parser, {} , src, tree, tree->root_id()); }

◆ parse_in_arena() [5/8]

void c4::yml::parse_in_arena ( csubstr filename,
csubstr yaml,
NodeRef node,
ParserOptions const & opts )

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

Definition at line 223 of file parse.cpp.

223{ substr src = checkcp_(node, yaml); TmpParser tmp(node, opts); parse_yaml_(&tmp.parser, filename, src, node.tree(), node.id()); }
Tree * tree() noexcept
Definition node.hpp:914
id_type id() const noexcept
Definition node.hpp:917

◆ parse_in_arena() [6/8]

void c4::yml::parse_in_arena ( csubstr yaml,
NodeRef node,
ParserOptions const & opts )

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

Definition at line 224 of file parse.cpp.

224{ substr src = checkcp_(node, yaml); TmpParser tmp(node, opts); parse_yaml_(&tmp.parser, {} , src, node.tree(), node.id()); }

◆ parse_in_arena() [7/8]

Tree c4::yml::parse_in_arena ( csubstr filename,
csubstr yaml,
ParserOptions const & opts )

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

Definition at line 225 of file parse.cpp.

225{ TmpParser tmp(opts); Tree tree; substr src = cpsrc_(&tree, yaml); parse_yaml_(&tmp.parser, filename, src, &tree, tree.root_id()); return tree; }

◆ parse_in_arena() [8/8]

Tree c4::yml::parse_in_arena ( csubstr yaml,
ParserOptions const & opts )

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

Definition at line 226 of file parse.cpp.

226{ TmpParser tmp(opts); Tree tree; substr src = cpsrc_(&tree, yaml); parse_yaml_(&tmp.parser, {} , src, &tree, tree.root_id()); return tree; }

◆ parse_json_in_arena() [1/8]

void c4::yml::parse_json_in_arena ( csubstr filename,
csubstr json,
Tree * tree,
id_type node_id,
ParserOptions const & opts )

(1) parse JSON into an existing tree node. The filename will be used in any error messages arising during the parse.

Definition at line 241 of file parse.cpp.

241{ substr src = checkcp_(tree, json); TmpParser tmp(tree, opts); parse_json_(&tmp.parser, filename, src, tree, node_id); }

◆ parse_json_in_arena() [2/8]

void c4::yml::parse_json_in_arena ( csubstr json,
Tree * tree,
id_type node_id,
ParserOptions const & opts )

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

Definition at line 242 of file parse.cpp.

242{ substr src = checkcp_(tree, json); TmpParser tmp(tree, opts); parse_json_(&tmp.parser, {} , src, tree, node_id); }

◆ parse_json_in_arena() [3/8]

void c4::yml::parse_json_in_arena ( csubstr filename,
csubstr json,
Tree * tree,
ParserOptions const & opts )

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

Definition at line 243 of file parse.cpp.

243{ substr src = checkcp_(tree, json); TmpParser tmp(tree, opts); parse_json_(&tmp.parser, filename, src, tree, tree->root_id()); }

◆ parse_json_in_arena() [4/8]

void c4::yml::parse_json_in_arena ( csubstr json,
Tree * tree,
ParserOptions const & opts )

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

Definition at line 244 of file parse.cpp.

244{ substr src = checkcp_(tree, json); TmpParser tmp(tree, opts); parse_json_(&tmp.parser, {} , src, tree, tree->root_id()); }

◆ parse_json_in_arena() [5/8]

void c4::yml::parse_json_in_arena ( csubstr filename,
csubstr json,
NodeRef node,
ParserOptions const & opts )

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

Definition at line 245 of file parse.cpp.

245{ substr src = checkcp_(node, json); TmpParser tmp(node, opts); parse_json_(&tmp.parser, filename, src, node.tree(), node.id()); }

◆ parse_json_in_arena() [6/8]

void c4::yml::parse_json_in_arena ( csubstr json,
NodeRef node,
ParserOptions const & opts )

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

Definition at line 246 of file parse.cpp.

246{ substr src = checkcp_(node, json); TmpParser tmp(node, opts); parse_json_(&tmp.parser, {} , src, node.tree(), node.id()); }

◆ parse_json_in_arena() [7/8]

Tree c4::yml::parse_json_in_arena ( csubstr filename,
csubstr json,
ParserOptions const & opts )

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

Definition at line 247 of file parse.cpp.

247{ TmpParser tmp(opts); Tree tree; substr src = cpsrc_(&tree, json); parse_json_(&tmp.parser, filename, src, &tree, tree.root_id()); return tree; }

◆ parse_json_in_arena() [8/8]

Tree c4::yml::parse_json_in_arena ( csubstr json,
ParserOptions const & opts )

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

Definition at line 248 of file parse.cpp.

248{ TmpParser tmp(opts); Tree tree; substr src = cpsrc_(&tree, json); parse_json_(&tmp.parser, {} , src, &tree, tree.root_id()); return tree; }