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