rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
emit_file.cpp
Go to the documentation of this file.
1#ifndef _C4_YML_EMIT_FILE_HPP_
3#endif
4#ifndef _C4_YML_WRITER_FILE_HPP_
6#endif
7#ifndef _C4_YML_TREE_HPP_
8#include "c4/yml/tree.hpp"
9#endif
10#ifndef _C4_YML_NODE_HPP_
11#include "c4/yml/node.hpp"
12#endif
13#ifndef _C4_YML_EMITTER_DEF_HPP_
15#endif
16
17
18namespace c4 {
19namespace yml {
20
21// instantiate the template class
22template class RYML_EXPORT Emitter<WriterFile>;
23
24
25// emit from root -------------------------
26
27void emit_yaml(Tree const& t, EmitOptions const& opts, FILE *f)
28{
29 EmitterFile em(opts, f);
30 em.emit_as(EMIT_YAML, &t);
31}
32
33void emit_yaml(Tree const& t, FILE *f)
34{
35 EmitterFile em(EmitOptions{}, f);
36 em.emit_as(EMIT_YAML, &t);
37}
38
39
40void emit_json(Tree const& t, EmitOptions const& opts, FILE *f)
41{
42 EmitterFile em(opts, f);
43 em.emit_as(EMIT_JSON, &t);
44}
45
46void emit_json(Tree const& t, FILE *f)
47{
48 EmitterFile em(EmitOptions{}, f);
49 em.emit_as(EMIT_JSON, &t);
50}
51
52
53// emit from tree and node id -----------------------
54
55void emit_yaml(Tree const& t, id_type id, EmitOptions const& opts, FILE *f)
56{
57 EmitterFile em(opts, f);
58 em.emit_as(EMIT_YAML, &t, id);
59}
60
61void emit_yaml(Tree const& t, id_type id, FILE *f)
62{
63 EmitterFile em(EmitOptions{}, f);
64 em.emit_as(EMIT_YAML, &t, id);
65}
66
67void emit_json(Tree const& t, id_type id, EmitOptions const& opts, FILE *f)
68{
69 EmitterFile em(opts, f);
70 em.emit_as(EMIT_JSON, &t, id);
71}
72
73void emit_json(Tree const& t, id_type id, FILE *f)
74{
75 EmitterFile em(EmitOptions{}, f);
76 em.emit_as(EMIT_JSON, &t, id);
77}
78
79
80// emit from ConstNodeRef ------------------------
81
82void emit_yaml(ConstNodeRef const& r, EmitOptions const& opts, FILE *f)
83{
84 EmitterFile em(opts, f);
85 em.emit_as(EMIT_YAML, r.tree(), r.id());
86}
87
88void emit_yaml(ConstNodeRef const& r, FILE *f)
89{
90 EmitterFile em(EmitOptions{}, f);
91 em.emit_as(EMIT_YAML, r.tree(), r.id());
92}
93
94void emit_json(ConstNodeRef const& r, EmitOptions const& opts, FILE *f)
95{
96 EmitterFile em(opts, f);
97 em.emit_as(EMIT_JSON, r.tree(), r.id());
98}
99
100void emit_json(ConstNodeRef const& r, FILE *f)
101{
102 EmitterFile em(EmitOptions{}, f);
103 em.emit_as(EMIT_JSON, r.tree(), r.id());
104}
105
106} // namespace yml
107} // namespace c4
Holds a pointer to an existing tree, and a node id.
Definition node.hpp:478
id_type id() const noexcept
Definition node.hpp:564
Tree const * tree() const noexcept
Definition node.hpp:563
A YAML/JSON emitter, templated on a writer class such as WriterBuf, WriterFile, or WriterOStream.
Definition emitter.hpp:35
void emit_as(EmitType_e type, Tree const *tree, id_type id=NONE)
emit!
#define RYML_EXPORT
Definition export.hpp:18
substr emit_yaml(Tree const &t, EmitOptions const &opts, substr buf, bool error_on_excess)
(1) emit YAML to the given buffer.
Definition emit_buf.cpp:28
substr emit_json(Tree const &t, EmitOptions const &opts, substr buf, bool error_on_excess)
(1) emit JSON to the given buffer.
Definition emit_buf.cpp:42
Emitter< WriterFile > EmitterFile
Definition emit_file.hpp:25
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
Definition common.hpp:305
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
Definition common.cpp:14
Node classes.
A lightweight object containing options to be used when emitting.