rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
emit.hpp
Go to the documentation of this file.
1#ifndef _C4_YML_EMIT_HPP_
2#define _C4_YML_EMIT_HPP_
3
4/** @file emit.hpp Umbrella header with all utilities to emit YAML and JSON. */
5
6
7#ifndef _C4_YML_EMIT_BUF_HPP_
8#include "c4/yml/emit_buf.hpp"
9#endif
10#ifndef _C4_YML_EMIT_CONTAINER_HPP_
12#endif
13#ifndef _C4_YML_EMIT_FILE_HPP_
14#include "c4/yml/emit_file.hpp"
15#endif
16#ifndef _C4_YML_EMIT_OSTREAM_HPP_
18#endif
19
20
21namespace c4 {
22namespace yml {
23
24
25//-------------------------------------------------
26// deprecated code
27
28/** @cond dev */ // LCOV_EXCL_START
29
30#define RYML_DEPRECATE_EMIT \
31 RYML_DEPRECATED("use emit_yaml() instead. " \
32 "See https://github.com/biojppm/rapidyaml/issues/120")
33#define RYML_DEPRECATE_EMITRS \
34 RYML_DEPRECATED("use emitrs_yaml() instead. " \
35 "See https://github.com/biojppm/rapidyaml/issues/120")
36
37// workaround for Qt emit which is a macro;
38// see https://github.com/biojppm/rapidyaml/issues/120.
39// emit is defined in qobjectdefs.h (as an empty define).
40#ifdef emit
41#define RYML_TMP_EMIT_ emit
42#undef emit
43#endif
44
45RYML_DEPRECATE_EMIT inline void emit(Tree const& t, id_type id, FILE *f)
46{
47 emit_yaml(t, id, f);
48}
49RYML_DEPRECATE_EMIT inline void emit(Tree const& t, FILE *f=nullptr)
50{
51 emit_yaml(t, f);
52}
53RYML_DEPRECATE_EMIT inline void emit(ConstNodeRef const& r, FILE *f=nullptr)
54{
55 emit_yaml(r, f);
56}
57
58RYML_DEPRECATE_EMIT inline substr emit(Tree const& t, id_type id, substr buf, bool error_on_excess=true)
59{
60 return emit_yaml(t, id, buf, error_on_excess);
61}
62RYML_DEPRECATE_EMIT inline substr emit(Tree const& t, substr buf, bool error_on_excess=true)
63{
64 return emit_yaml(t, buf, error_on_excess);
65}
66RYML_DEPRECATE_EMIT inline substr emit(ConstNodeRef const& r, substr buf, bool error_on_excess=true)
67{
68 return emit_yaml(r, buf, error_on_excess);
69}
70
71#ifdef RYML_TMP_EMIT_
72#define emit
73#undef RYML_TMP_EMIT_
74#endif
75
76template<class CharOwningContainer>
77RYML_DEPRECATE_EMITRS substr emitrs(Tree const& t, id_type id, CharOwningContainer * cont)
78{
79 return emitrs_yaml(t, id, cont);
80}
81template<class CharOwningContainer>
82RYML_DEPRECATE_EMITRS CharOwningContainer emitrs(Tree const& t, id_type id)
83{
85}
86template<class CharOwningContainer>
87RYML_DEPRECATE_EMITRS substr emitrs(Tree const& t, CharOwningContainer * cont)
88{
89 return emitrs_yaml(t, cont);
90}
91template<class CharOwningContainer>
92RYML_DEPRECATE_EMITRS CharOwningContainer emitrs(Tree const& t)
93{
95}
96template<class CharOwningContainer>
97RYML_DEPRECATE_EMITRS substr emitrs(ConstNodeRef const& n, CharOwningContainer * cont)
98{
99 return emitrs_yaml(n, cont);
100}
101template<class CharOwningContainer>
102RYML_DEPRECATE_EMITRS CharOwningContainer emitrs(ConstNodeRef const& n)
103{
105}
106
107#undef RYML_DEPRECATE_EMIT
108#undef RYML_DEPRECATE_EMITRS
109
110/** @endcond */ // LCOV_EXCL_STOP
111
112
113} // namespace yml
114} // namespace c4
115
116#endif /* _C4_YML_EMIT_HPP_ */
Holds a pointer to an existing tree, and a node id.
Definition node.hpp:478
Utilities to emit YAML and JSON to buffers or containers.
emit to STL-like ostreams
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 emitrs_yaml(Tree const &t, id_type id, EmitOptions const &opts, CharOwningContainer *cont, bool append=false)
(1) emit+resize: emit YAML to the given std::string/std::vector<char>-like container,...
basic_substring< char > substr
a mutable string view
Definition substr.hpp:2356
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