rapidyaml  0.16.0
parseandemitYAML,anddoitfast
emit_file.cpp
Go to the documentation of this file.
1 #ifndef C4_YML_EMIT_FILE_HPP_
2 #include "c4/yml/emit_file.hpp"
3 #endif
4 #ifndef C4_YML_WRITER_FILE_HPP_
5 #include "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_
14 #include "c4/yml/emitter.def.hpp"
15 #endif
16 
17 
18 namespace c4 {
19 namespace yml {
20 
21 // instantiate the template class
22 template class RYML_EXPORT Emitter<WriterFile>;
23 
24 
25 // emit from root -------------------------
26 
27 void 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 
33 void emit_yaml(Tree const& t, FILE *f)
34 {
35  EmitterFile em(EmitOptions{}, f);
36  em.emit_as(EMIT_YAML, &t);
37 }
38 
39 
40 void 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 
46 void 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 
55 void 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 
61 void 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 
67 void 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 
73 void 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 
82 void 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 
88 void 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 
94 void 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 
100 void 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
A YAML/JSON emitter, templated on a writer class such as WriterBuf, WriterFile, or WriterOStream...
Definition: emitter.hpp:34
id_type id() const noexcept
Definition: node.hpp:822
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
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:124
void emit_as(EmitType_e type, Tree const *tree, id_type id=NONE)
emit!
Definition: emitter.def.hpp:48
Holds a pointer to an existing tree, and a node id.
Definition: node.hpp:736
Tree const * tree() const noexcept
Definition: node.hpp:821
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
A lightweight object containing options to be used when emitting.
Node classes.
#define RYML_EXPORT
Definition: export.hpp:18