rapidyaml 0.14.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
Parse in place with temporary parser

parse a mutable YAML source buffer. More...

Functions

void c4::yml::parse_in_place (csubstr filename, substr 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_place (substr yaml, Tree *t, id_type node_id, ParserOptions const &opts={})
 (2) like (1) but no filename will be reported
void c4::yml::parse_in_place (csubstr filename, substr yaml, Tree *t, ParserOptions const &opts={})
 (3) parse YAML into an existing tree, into its root node.
void c4::yml::parse_in_place (substr yaml, Tree *t, ParserOptions const &opts={})
 (4) like (3) but no filename will be reported
void c4::yml::parse_in_place (csubstr filename, substr yaml, NodeRef node, ParserOptions const &opts={})
 (5) like (1) but the node is given as a NodeRef
void c4::yml::parse_in_place (substr yaml, NodeRef node, ParserOptions const &opts={})
 (6) like (5) but no filename will be reported
Tree c4::yml::parse_in_place (csubstr filename, substr yaml, ParserOptions const &opts={})
 (7) create a new tree, and parse YAML into its root node.
Tree c4::yml::parse_in_place (substr yaml, ParserOptions const &opts={})
 (8) like (7) but no filename will be reported
void c4::yml::parse_json_in_place (csubstr filename, substr 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_place (substr 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_place (csubstr filename, substr json, Tree *t, ParserOptions const &opts={})
 (3) parse JSON into an existing tree, into its root node.
void c4::yml::parse_json_in_place (substr json, Tree *t, ParserOptions const &opts={})
 (4) like (3) but no filename will be reported
void c4::yml::parse_json_in_place (csubstr filename, substr json, NodeRef node, ParserOptions const &opts={})
 (5) like (1) but the node is given as a NodeRef
void c4::yml::parse_json_in_place (substr json, NodeRef node, ParserOptions const &opts={})
 (6) like (5) but no filename will be reported
Tree c4::yml::parse_json_in_place (csubstr filename, substr json, ParserOptions const &opts={})
 (7) create a new tree, and parse JSON into its root node.
Tree c4::yml::parse_json_in_place (substr json, ParserOptions const &opts={})
 (8) like (7) but no filename will be reported

Detailed Description

parse a mutable YAML source buffer.

Scalars requiring filtering are mutated in place (except in the rare cases where the filtered scalar is longer than the original scalar).

Note
These freestanding functions use a temporary parser object, and are convenience functions to enable the user to easily parse YAML without the need to explicitly instantiate a parser and event handler. 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 place with existing parser

Function Documentation

◆ parse_in_place() [1/8]

void c4::yml::parse_in_place ( csubstr filename,
substr 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.

Definition at line 61 of file parse.cpp.

61{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); parse_in_place(&parser, filename, yaml, t, node_id); }
Callbacks const & callbacks() const
Definition tree.hpp:290
void parse_in_place(Parser *parser, csubstr filename, substr yaml, Tree *t, id_type node_id)
(1) parse YAML into an existing tree node.
Definition parse.cpp:38
ParseEngine< EventHandlerTree > Parser
This is the main ryml parser, where the parser events are handled to create a ryml tree.
Definition fwd.hpp:19

◆ parse_in_place() [2/8]

void c4::yml::parse_in_place ( substr yaml,
Tree * t,
id_type node_id,
ParserOptions const & opts )

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

Definition at line 62 of file parse.cpp.

62{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); parse_in_place(&parser, {} , yaml, t, node_id); }

◆ parse_in_place() [3/8]

void c4::yml::parse_in_place ( csubstr filename,
substr yaml,
Tree * t,
ParserOptions const & opts )

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

Definition at line 63 of file parse.cpp.

63{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); if(t->empty()) { t->reserve(); } parse_in_place(&parser, filename, yaml, t, t->root_id()); }
id_type root_id() const
Get the id of the root node. The tree must not be empty.
Definition tree.hpp:337
void reserve(id_type node_capacity=RYML_DEFAULT_TREE_CAPACITY)
Definition tree.cpp:292
bool empty() const
Definition tree.hpp:284

◆ parse_in_place() [4/8]

void c4::yml::parse_in_place ( substr yaml,
Tree * t,
ParserOptions const & opts )

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

Definition at line 64 of file parse.cpp.

64{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); if(t->empty()) { t->reserve(); } parse_in_place(&parser, {} , yaml, t, t->root_id()); }

◆ parse_in_place() [5/8]

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

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

Definition at line 65 of file parse.cpp.

65{ _RYML_CHECK_BASIC(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler, opts); parse_in_place(&parser, filename, yaml, node.tree(), node.id()); }
Tree * tree() noexcept
Definition node.hpp:1089
id_type id() const noexcept
Definition node.hpp:1092
bool invalid() const noexcept
true if the object is not referring to any existing or seed node.
Definition node.hpp:1038

◆ parse_in_place() [6/8]

void c4::yml::parse_in_place ( substr yaml,
NodeRef node,
ParserOptions const & opts )

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

Definition at line 66 of file parse.cpp.

66{ _RYML_CHECK_BASIC(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler, opts); parse_in_place(&parser, {} , yaml, node.tree(), node.id()); }

◆ parse_in_place() [7/8]

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

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

Definition at line 67 of file parse.cpp.

67{ Parser::handler_type event_handler; Parser parser(&event_handler, opts); Tree tree(parser.callbacks()); parse_in_place(&parser, filename, yaml, &tree, tree.root_id()); return tree; }

◆ parse_in_place() [8/8]

Tree c4::yml::parse_in_place ( substr yaml,
ParserOptions const & opts )

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

Definition at line 68 of file parse.cpp.

68{ Parser::handler_type event_handler; Parser parser(&event_handler, opts); Tree tree(parser.callbacks()); parse_in_place(&parser, {} , yaml, &tree, tree.root_id()); return tree; }

◆ parse_json_in_place() [1/8]

void c4::yml::parse_json_in_place ( csubstr filename,
substr 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.

Definition at line 81 of file parse.cpp.

81{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); parse_json_in_place(&parser, filename, json, t, node_id); }
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...
Definition parse.cpp:44

◆ parse_json_in_place() [2/8]

void c4::yml::parse_json_in_place ( substr json,
Tree * t,
id_type node_id,
ParserOptions const & opts )

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

Definition at line 82 of file parse.cpp.

82{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); parse_json_in_place(&parser, {} , json, t, node_id); }

◆ parse_json_in_place() [3/8]

void c4::yml::parse_json_in_place ( csubstr filename,
substr json,
Tree * t,
ParserOptions const & opts )

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

Definition at line 83 of file parse.cpp.

83{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); if(t->empty()) { t->reserve(); } parse_json_in_place(&parser, filename, json, t, t->root_id()); }

◆ parse_json_in_place() [4/8]

void c4::yml::parse_json_in_place ( substr json,
Tree * t,
ParserOptions const & opts )

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

Definition at line 84 of file parse.cpp.

84{ _RYML_CHECK_BASIC(t); Parser::handler_type event_handler(t->callbacks()); Parser parser(&event_handler, opts); if(t->empty()) { t->reserve(); } parse_json_in_place(&parser, {} , json, t, t->root_id()); }

◆ parse_json_in_place() [5/8]

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

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

Definition at line 85 of file parse.cpp.

85{ _RYML_CHECK_BASIC(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler, opts); parse_json_in_place(&parser, filename, json, node.tree(), node.id()); }

◆ parse_json_in_place() [6/8]

void c4::yml::parse_json_in_place ( substr json,
NodeRef node,
ParserOptions const & opts )

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

Definition at line 86 of file parse.cpp.

86{ _RYML_CHECK_BASIC(!node.invalid()); Parser::handler_type event_handler(node.tree()->callbacks()); Parser parser(&event_handler, opts); parse_json_in_place(&parser, {} , json, node.tree(), node.id()); }

◆ parse_json_in_place() [7/8]

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

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

Definition at line 87 of file parse.cpp.

87{ Parser::handler_type event_handler; Parser parser(&event_handler, opts); Tree tree(parser.callbacks()); parse_json_in_place(&parser, filename, json, &tree, tree.root_id()); return tree; }

◆ parse_json_in_place() [8/8]

Tree c4::yml::parse_json_in_place ( substr json,
ParserOptions const & opts )

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

Definition at line 88 of file parse.cpp.

88{ Parser::handler_type event_handler; Parser parser(&event_handler, opts); Tree tree(parser.callbacks()); parse_json_in_place(&parser, {} , json, &tree, tree.root_id()); return tree; }