rapidyaml  0.16.0
parseandemitYAML,anddoitfast
emit_file.hpp
Go to the documentation of this file.
1 #ifndef C4_YML_EMIT_FILE_HPP_
2 #define C4_YML_EMIT_FILE_HPP_
3 
4 /** @file emit_file.hpp */
5 
6 #include <cstdio>
7 
8 #ifndef C4_YML_COMMON_HPP_
9 #include "c4/yml/common.hpp"
10 #endif
11 
12 
13 namespace c4 {
14 namespace yml {
15 
16 // fwd declarations
17 /** @cond dev */
18 template<class Writer> class Emitter;
19 struct WriterFile;
20 class Tree;
21 class ConstNodeRef;
22 struct EmitOptions;
23 /** @endcond */
24 
25 
26 /** @ingroup doc_emit_to_file */
28 
29 
30 // emit from root -------------------------
31 
32 /** @addtogroup doc_emit_to_file_from_root
33  *
34  * @{
35  */
36 
37 /** (1) emit YAML to the given file, starting at the root node. A null file defaults to stdout. */
38 RYML_EXPORT void emit_yaml(Tree const& t, EmitOptions const& opts, FILE *f=nullptr);
39 
40 /** (2) like (1), but use default emit options */
41 RYML_EXPORT void emit_yaml(Tree const& t, FILE *f=nullptr);
42 
43 
44 /** (1) emit JSON to the given file. A null file defaults to stdout. */
45 RYML_EXPORT void emit_json(Tree const& t, EmitOptions const& opts, FILE *f=nullptr);
46 
47 /** (2) like (1), but use default emit options */
48 RYML_EXPORT void emit_json(Tree const& t, FILE *f=nullptr);
49 
50 /** @} */
51 
52 
53 // emit from tree and node id -----------------------
54 
55 /** @addtogroup doc_emit_to_file_from_node_id
56  *
57  * @{
58  */
59 
60 
61 /** (1) emit YAML to the given file, starting at the given node. A null
62  * file defaults to stdout. */
63 RYML_EXPORT void emit_yaml(Tree const& t, id_type id, EmitOptions const& opts, FILE *f);
64 
65 /** (2) like (1), but use default emit options */
66 RYML_EXPORT void emit_yaml(Tree const& t, id_type id, FILE *f);
67 
68 
69 /** (1) emit JSON to the given file, starting at the given node. A null
70  * file defaults to stdout. */
71 RYML_EXPORT void emit_json(Tree const& t, id_type id, EmitOptions const& opts, FILE *f);
72 
73 /** (2) like (1), but use default emit options */
74 RYML_EXPORT void emit_json(Tree const& t, id_type id, FILE *f);
75 
76 
77 /** @} */
78 
79 
80 // emit from ConstNodeRef ------------------------
81 
82 /** @addtogroup doc_emit_to_file_from_noderef
83  *
84  * @{
85  */
86 
87 /** (1) emit YAML to the given file. A null file defaults to stdout.
88  * Return the number of bytes written. */
89 RYML_EXPORT void emit_yaml(ConstNodeRef const& r, EmitOptions const& opts, FILE *f=nullptr);
90 
91 /** (2) like (1), but use default emit options */
92 RYML_EXPORT void emit_yaml(ConstNodeRef const& r, FILE *f=nullptr);
93 
94 
95 /** (1) emit JSON to the given file. A null file defaults to stdout.
96  * Return the number of bytes written. */
97 RYML_EXPORT void emit_json(ConstNodeRef const& r, EmitOptions const& opts, FILE *f=nullptr);
98 
99 /** (2) like (1), but use default emit options */
100 RYML_EXPORT void emit_json(ConstNodeRef const& r, FILE *f=nullptr);
101 
102 /** @} */
103 
104 
105 } // namespace yml
106 } // namespace c4
107 
108 #endif /* C4_YML_EMIT_FILE_HPP_ */
A YAML/JSON emitter, templated on a writer class such as WriterBuf, WriterFile, or WriterOStream...
Definition: emitter.hpp:34
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
Common utilities and infrastructure used by ryml.
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
Holds a pointer to an existing tree, and a node id.
Definition: node.hpp:736
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.
#define RYML_EXPORT
Definition: export.hpp:18