rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
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
13namespace c4 {
14namespace yml {
15
16// fwd declarations
17/** @cond dev */
18template<class Writer> class Emitter;
19struct WriterFile;
20class Tree;
21class ConstNodeRef;
22struct 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. */
38RYML_EXPORT void emit_yaml(Tree const& t, EmitOptions const& opts, FILE *f=nullptr);
39
40/** (2) like (1), but use default emit options */
41RYML_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. */
45RYML_EXPORT void emit_json(Tree const& t, EmitOptions const& opts, FILE *f=nullptr);
46
47/** (2) like (1), but use default emit options */
48RYML_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. */
63RYML_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 */
66RYML_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. */
71RYML_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 */
74RYML_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. */
89RYML_EXPORT void emit_yaml(ConstNodeRef const& r, EmitOptions const& opts, FILE *f=nullptr);
90
91/** (2) like (1), but use default emit options */
92RYML_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. */
97RYML_EXPORT void emit_json(ConstNodeRef const& r, EmitOptions const& opts, FILE *f=nullptr);
98
99/** (2) like (1), but use default emit options */
100RYML_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_ */
Holds a pointer to an existing tree, and a node id.
Definition node.hpp:737
A YAML/JSON emitter, templated on a writer class such as WriterBuf, WriterFile, or WriterOStream.
Definition emitter.hpp:35
Common utilities and infrastructure used by ryml.
#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:27
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
A lightweight object containing options to be used when emitting.
A writer that outputs to a C file handle, defaulting to stdout.