rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
Emit from ConstNodeRef

Functions

substr c4::yml::emit_yaml (ConstNodeRef const &r, EmitOptions const &opts, substr buf, bool error_on_excess=true)
 (1) emit YAML to the given buffer.
substr c4::yml::emit_yaml (ConstNodeRef const &r, substr buf, bool error_on_excess=true)
 (2) like (1), but use default emit options
substr c4::yml::emit_json (ConstNodeRef const &r, EmitOptions const &opts, substr buf, bool error_on_excess=true)
 (1) emit JSON to the given buffer.
substr c4::yml::emit_json (ConstNodeRef const &r, substr buf, bool error_on_excess=true)
 (2) like (1), but use default emit options

Detailed Description

Function Documentation

◆ emit_yaml() [1/2]

substr c4::yml::emit_yaml ( ConstNodeRef const & r,
EmitOptions const & opts,
substr buf,
bool error_on_excess = true )

(1) emit YAML to the given buffer.

Return a substr trimmed to the emitted YAML.

Parameters
rthe starting node.
bufthe output buffer.
optsemit options.
error_on_excessRaise an error if the space in the buffer is insufficient.
Returns
a substr trimmed to the result in the output buffer. If the buffer is insufficient (when error_on_excess is false), the string pointer of the result will be set to null, and the length will report the required buffer size.

Definition at line 90 of file emit_buf.cpp.

91{
92 EmitterBuf em(opts, buf);
93 em.emit_as(EMIT_YAML, r.tree(), r.id());
94 return em.get_result(error_on_excess);
95}
Emitter< WriterBuf > EmitterBuf
Definition emit_buf.hpp:26

◆ emit_yaml() [2/2]

substr c4::yml::emit_yaml ( ConstNodeRef const & r,
substr buf,
bool error_on_excess )

(2) like (1), but use default emit options

Definition at line 97 of file emit_buf.cpp.

98{
99 EmitterBuf em(EmitOptions{}, buf);
100 em.emit_as(EMIT_YAML, r.tree(), r.id());
101 return em.get_result(error_on_excess);
102}
A lightweight object containing options to be used when emitting.

◆ emit_json() [1/2]

substr c4::yml::emit_json ( ConstNodeRef const & r,
EmitOptions const & opts,
substr buf,
bool error_on_excess = true )

(1) emit JSON to the given buffer.

Return a substr trimmed to the emitted JSON.

Parameters
rthe starting node.
bufthe output buffer.
optsemit options.
error_on_excessRaise an error if the space in the buffer is insufficient.
Returns
a substr trimmed to the result in the output buffer. If the buffer is insufficient (when error_on_excess is false), the string pointer of the result will be set to null, and the length will report the required buffer size.

Definition at line 104 of file emit_buf.cpp.

105{
106 EmitterBuf em(opts, buf);
107 em.emit_as(EMIT_JSON, r.tree(), r.id());
108 return em.get_result(error_on_excess);
109}

◆ emit_json() [2/2]

substr c4::yml::emit_json ( ConstNodeRef const & r,
substr buf,
bool error_on_excess )

(2) like (1), but use default emit options

Definition at line 111 of file emit_buf.cpp.

112{
113 EmitterBuf em(EmitOptions{}, buf);
114 em.emit_as(EMIT_JSON, r.tree(), r.id());
115 return em.get_result(error_on_excess);
116}