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

Functions

substr c4::yml::emit_yaml (Tree const &t, EmitOptions const &opts, substr buf, bool error_on_excess=true)
 (1) emit YAML to the given buffer.
substr c4::yml::emit_yaml (Tree const &t, substr buf, bool error_on_excess=true)
 (2) like (1), but use default emit options
substr c4::yml::emit_json (Tree const &t, EmitOptions const &opts, substr buf, bool error_on_excess=true)
 (1) emit JSON to the given buffer.
substr c4::yml::emit_json (Tree const &t, 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 ( Tree const & t,
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
tthe tree; will be emitted from the root node.
optsemit options.
bufthe output buffer.
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. For example usage, see emitrs_yaml() .

Definition at line 28 of file emit_buf.cpp.

29{
30 EmitterBuf em(opts, buf);
31 em.emit_as(EMIT_YAML, &t);
32 return em.get_result(error_on_excess);
33}
Emitter< WriterBuf > EmitterBuf
Definition emit_buf.hpp:26

◆ emit_yaml() [2/2]

substr c4::yml::emit_yaml ( Tree const & t,
substr buf,
bool error_on_excess )

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

Definition at line 35 of file emit_buf.cpp.

36{
37 EmitterBuf em(EmitOptions{}, buf);
38 em.emit_as(EMIT_YAML, &t);
39 return em.get_result(error_on_excess);
40}
A lightweight object containing options to be used when emitting.

◆ emit_json() [1/2]

substr c4::yml::emit_json ( Tree const & t,
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
tthe tree; will be emitted from the root node.
optsemit options.
bufthe output buffer.
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 42 of file emit_buf.cpp.

43{
44 EmitterBuf em(opts, buf);
45 em.emit_as(EMIT_JSON, &t);
46 return em.get_result(error_on_excess);
47}

◆ emit_json() [2/2]

substr c4::yml::emit_json ( Tree const & t,
substr buf,
bool error_on_excess )

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

Definition at line 49 of file emit_buf.cpp.

50{
51 EmitterBuf em(EmitOptions{}, buf);
52 em.emit_as(EMIT_JSON, &t);
53 return em.get_result(error_on_excess);
54}