rapidyaml 0.15.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
Emit to memory buffer

Topics

 Emit to resizeable container

Functions

bool c4::yml::EmitOptions::operator== (const EmitOptions &that) const noexcept
template<class ... WriterArgs>
 c4::yml::Emitter< Writer >::Emitter (EmitOptions const &opts, WriterArgs &&...args)
 Construct the emitter and its internal Writer state.
template<class ... WriterArgs>
 c4::yml::Emitter< Writer >::Emitter (WriterArgs &&...args)
 Construct the emitter and its internal Writer state, using default emit options.
substr c4::yml::Emitter< Writer >::emit_as (EmitType_e type, Tree const &t, id_type id, bool error_on_excess)
 emit!
substr c4::yml::Emitter< Writer >::emit_as (EmitType_e type, Tree const &t, bool error_on_excess=true)
 emit starting at the root node
substr c4::yml::Emitter< Writer >::emit_as (EmitType_e type, ConstNodeRef const &n, bool error_on_excess=true)
 emit starting at the given node
EmitOptions const & c4::yml::Emitter< Writer >::options () const noexcept
 get the emit options for this object
void c4::yml::Emitter< Writer >::options (EmitOptions opts) noexcept
 set the emit options for this object
void c4::yml::Emitter< Writer >::max_depth (id_type max_depth) noexcept
 set the max depth for emitted trees (to prevent a stack overflow)
id_type c4::yml::Emitter< Writer >::max_depth () const noexcept
 get the max depth for emitted trees (to prevent a stack overflow)
Pws_e c4::yml::Emitter< Writer >::flow_pws::next_pws (size_t col) const noexcept
void c4::yml::Emitter< Writer >::flow_pws::start (NodeType ty, size_t max_cols_) noexcept
void c4::yml::Emitter< Writer >::flow_pws::stop () noexcept
 c4::yml::as_json::as_json (Tree const &t, EmitOptions const &opts={})
 c4::yml::as_json::as_json (Tree const &t, id_type id, EmitOptions const &opts={})
 c4::yml::as_json::as_json (ConstNodeRef const &n, EmitOptions const &opts={})
 c4::yml::as_yaml::as_yaml (Tree const &t, EmitOptions const &opts={})
 c4::yml::as_yaml::as_yaml (Tree const &t, id_type id, EmitOptions const &opts={})
 c4::yml::as_yaml::as_yaml (ConstNodeRef const &n, EmitOptions const &opts={})
substr c4::yml::emit_yaml (Tree const &t, id_type id, 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, id_type id, substr buf, bool error_on_excess=true)
 (2) like (1), but use default emit options
substr c4::yml::emit_json (Tree const &t, id_type id, 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, id_type id, substr buf, bool error_on_excess=true)
 (2) like (1), but use default emit options
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
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

Variables

size_t c4::yml::Emitter< Writer >::flow_pws::max_cols = 0
Pws_e c4::yml::Emitter< Writer >::flow_pws::pend_after_comma = _PWS_NONE
bool c4::yml::Emitter< Writer >::flow_pws::active = false
Tree const * c4::yml::as_json::tree
id_type c4::yml::as_json::node
EmitOptions c4::yml::as_json::options
Tree const * c4::yml::as_yaml::tree
id_type c4::yml::as_yaml::node
EmitOptions c4::yml::as_yaml::options

flow customization

static constexpr const id_type c4::yml::EmitOptions::max_cols_default = 80
bool c4::yml::EmitOptions::indent_flow_ml () const noexcept
 Indent the contents of FLOW_ML1 and FLOW_MLN containers.
EmitOptionsc4::yml::EmitOptions::indent_flow_ml (bool enabled) noexcept
EmitOptionsc4::yml::EmitOptions::force_flow_spc (bool enabled) noexcept
 Force everywhere a space after comma in flow mode, overriding the FLOW_SPC status of individual containers.
bool c4::yml::EmitOptions::force_flow_spc () const noexcept
EmitOptionsc4::yml::EmitOptions::max_cols (id_type cols) noexcept
 Set max columns for the emitted YAML in FLOW_MLN mode.
id_type c4::yml::EmitOptions::max_cols () const noexcept

maximum depth for the emitted tree

This prevents stack overflows by making the emitter fail when the tree exceeds the maximum depth.

static constexpr const id_type c4::yml::EmitOptions::max_depth_default = 64
id_type c4::yml::EmitOptions::max_depth () const noexcept
EmitOptionsc4::yml::EmitOptions::max_depth (id_type d) noexcept

option flags - control emission of non-root (nested) nodes

EmitOptionsc4::yml::EmitOptions::emit_nonroot_key (bool enabled) noexcept
 When emit starts on a node which is not the root node, emit the node key as well.
bool c4::yml::EmitOptions::emit_nonroot_key () const noexcept
EmitOptionsc4::yml::EmitOptions::emit_nonroot_dash (bool enabled) noexcept
 When emit starts on a node which is not the root node, emit a leading dash.
bool c4::yml::EmitOptions::emit_nonroot_dash () const noexcept

option flags - json behavior

EmitOptionsc4::yml::EmitOptions::json_err_on_tag (bool enabled) noexcept
 Whether to trigger an error (or ignore the tag) when finding a tag in json mode.
bool c4::yml::EmitOptions::json_err_on_tag () const noexcept
EmitOptionsc4::yml::EmitOptions::json_err_on_anchor (bool enabled) noexcept
 Whether to trigger an error (or ignore the anchor) when finding an anchor in json mode.
bool c4::yml::EmitOptions::json_err_on_anchor () const noexcept

Detailed Description

Function Documentation

◆ indent_flow_ml() [1/2]

bool c4::yml::EmitOptions::indent_flow_ml ( ) const
inlinenoexcept

Indent the contents of FLOW_ML1 and FLOW_MLN containers.

Enabled by default.

Definition at line 96 of file emit.hpp.

96{ return (m_flags & INDENT_FLOW_ML) != 0; }

◆ indent_flow_ml() [2/2]

EmitOptions & c4::yml::EmitOptions::indent_flow_ml ( bool enabled)
inlinenoexcept

Definition at line 97 of file emit.hpp.

97{ return set_flags_(enabled, INDENT_FLOW_ML); }

◆ force_flow_spc() [1/2]

EmitOptions & c4::yml::EmitOptions::force_flow_spc ( bool enabled)
inlinenoexcept

Force everywhere a space after comma in flow mode, overriding the FLOW_SPC status of individual containers.

This only applies to FLOW_ML1 or FLOW_MLN containers. Disabled by default.

Definition at line 103 of file emit.hpp.

103{ return set_flags_(enabled, FORCE_FLOW_SPC); }

◆ force_flow_spc() [2/2]

bool c4::yml::EmitOptions::force_flow_spc ( ) const
inlinenoexcept

Definition at line 104 of file emit.hpp.

104{ return (m_flags & FORCE_FLOW_SPC) != 0; }

◆ max_cols() [1/2]

EmitOptions & c4::yml::EmitOptions::max_cols ( id_type cols)
inlinenoexcept

Set max columns for the emitted YAML in FLOW_MLN mode.

This will make the emitted YAML wrap around when the line reaches max cols, but only in containers with FLOW_MLN mode. Defaults to 80 columns.

Definition at line 110 of file emit.hpp.

110{ m_max_cols = cols; return *this; }

◆ max_cols() [2/2]

id_type c4::yml::EmitOptions::max_cols ( ) const
inlinenoexcept

Definition at line 111 of file emit.hpp.

111{ return m_max_cols; }

◆ emit_nonroot_key() [1/2]

EmitOptions & c4::yml::EmitOptions::emit_nonroot_key ( bool enabled)
inlinenoexcept

When emit starts on a node which is not the root node, emit the node key as well.

This will make the resuling YAML a map with the node as its single element. Enabled by default.

Definition at line 125 of file emit.hpp.

125{ return set_flags_(enabled, EMIT_NONROOT_KEY); }

◆ emit_nonroot_key() [2/2]

bool c4::yml::EmitOptions::emit_nonroot_key ( ) const
inlinenoexcept

Definition at line 126 of file emit.hpp.

126{ return (m_flags & EMIT_NONROOT_KEY) != 0; }

◆ emit_nonroot_dash() [1/2]

EmitOptions & c4::yml::EmitOptions::emit_nonroot_dash ( bool enabled)
inlinenoexcept

When emit starts on a node which is not the root node, emit a leading dash.

This will make the resulting YAML a seq with the node as its single element. Disabled by default.

Definition at line 131 of file emit.hpp.

131{ return set_flags_(enabled, EMIT_NONROOT_DASH); }

◆ emit_nonroot_dash() [2/2]

bool c4::yml::EmitOptions::emit_nonroot_dash ( ) const
inlinenoexcept

Definition at line 132 of file emit.hpp.

132{ return (m_flags & EMIT_NONROOT_DASH) != 0; }

◆ json_err_on_tag() [1/2]

EmitOptions & c4::yml::EmitOptions::json_err_on_tag ( bool enabled)
inlinenoexcept

Whether to trigger an error (or ignore the tag) when finding a tag in json mode.

Disabled by default.

Definition at line 144 of file emit.hpp.

144{ return set_flags_(enabled, JSON_ERR_ON_TAG); }

◆ json_err_on_tag() [2/2]

bool c4::yml::EmitOptions::json_err_on_tag ( ) const
inlinenoexcept

Definition at line 145 of file emit.hpp.

145{ return (m_flags & JSON_ERR_ON_TAG) != 0; }

◆ json_err_on_anchor() [1/2]

EmitOptions & c4::yml::EmitOptions::json_err_on_anchor ( bool enabled)
inlinenoexcept

Whether to trigger an error (or ignore the anchor) when finding an anchor in json mode.

Disabled by default.

Definition at line 149 of file emit.hpp.

149{ return set_flags_(enabled, JSON_ERR_ON_ANCHOR); }

◆ json_err_on_anchor() [2/2]

bool c4::yml::EmitOptions::json_err_on_anchor ( ) const
inlinenoexcept

Definition at line 150 of file emit.hpp.

150{ return (m_flags & JSON_ERR_ON_ANCHOR) != 0; }

◆ max_depth() [1/4]

id_type c4::yml::EmitOptions::max_depth ( ) const
inlinenoexcept

Definition at line 167 of file emit.hpp.

167{ return m_max_depth; }

◆ max_depth() [2/4]

EmitOptions & c4::yml::EmitOptions::max_depth ( id_type d)
inlinenoexcept

Definition at line 168 of file emit.hpp.

168{ m_max_depth = d; return *this; }

◆ operator==()

bool c4::yml::EmitOptions::operator== ( const EmitOptions & that) const
inlinenoexcept

Definition at line 174 of file emit.hpp.

175 {
176 return m_max_depth == that.m_max_depth &&
177 m_flags == that.m_flags;
178 }

◆ Emitter() [1/2]

template<class Writer>
template<class ... WriterArgs>
c4::yml::Emitter< Writer >::Emitter ( EmitOptions const & opts,
WriterArgs &&... args )
inline

Construct the emitter and its internal Writer state.

Parameters
optsEmitOptions
argsarguments to be forwarded to the constructor of the writer.

Definition at line 207 of file emit.hpp.

209 , m_tree()
210 , m_opts(opts)
211 , m_col()
212 , m_depth()
213 , m_ilevel()
214 , m_pws()
215 , m_flow_pws()
216 {}
A stateful emitter, for use with a writer such as WriterBuf, WriterFile, or WriterOStream.
Definition emit.hpp:198

◆ Emitter() [2/2]

template<class Writer>
template<class ... WriterArgs>
c4::yml::Emitter< Writer >::Emitter ( WriterArgs &&... args)
inline

Construct the emitter and its internal Writer state, using default emit options.

Parameters
argsarguments to be forwarded to the constructor of the writer.

Definition at line 222 of file emit.hpp.

224 , m_tree()
225 , m_opts()
226 , m_col()
227 , m_depth()
228 , m_ilevel()
229 , m_pws()
230 , m_flow_pws()
231 {}

◆ emit_as() [1/3]

template<class Writer>
substr c4::yml::Emitter< Writer >::emit_as ( EmitType_e type,
Tree const & t,
id_type id,
bool error_on_excess )

emit!

When writing to a buffer, returns a substr of the emitted YAML. If the given buffer has insufficient space, the returned substr will be null and its size will be the needed space. Whatever the size of the buffer, it is guaranteed that no writes are done past its end.

When writing to a file, the returned substr will be null, but its length will be set to the number of bytes written.

Parameters
typespecify what to emit (YAML or JSON)
tthe tree to emit
idthe id of the node to emit
error_on_excesswhen true, an error is raised when the output buffer is too small for the emitted YAML/JSON

Definition at line 20 of file emit.def.hpp.

21{
22 if(tree.empty())
23 {
24 _RYML_ASSERT_BASIC_(tree.callbacks(), id == NONE);
25 return {};
26 }
27 if(id == NONE)
28 id = tree.root_id();
29 _RYML_CHECK_VISIT_(tree.callbacks(), id < tree.capacity(), &tree, id);
30 m_tree = &tree;
31 m_col = 0;
32 m_depth = 0;
33 m_ilevel = 0;
34 m_pws = _PWS_NONE;
35 m_flow_pws = {};
36 if(type == EMIT_YAML)
37 _emit_yaml(id);
38 else if(type == EMIT_JSON)
39 _json_emit(id);
40 else
41 _RYML_ERR_BASIC_(m_tree->callbacks(), "unknown emit type"); // LCOV_EXCL_LINE
42 m_tree = nullptr;
43 return this->Writer::_get(error_on_excess);
44}

◆ emit_as() [2/3]

template<class Writer>
substr c4::yml::Emitter< Writer >::emit_as ( EmitType_e type,
Tree const & t,
bool error_on_excess = true )
inline

emit starting at the root node

Definition at line 254 of file emit.hpp.

255 {
256 if(t.empty())
257 return {};
258 return this->emit_as(type, t, t.root_id(), error_on_excess);
259 }
substr emit_as(EmitType_e type, Tree const &t, id_type id, bool error_on_excess)
emit!
Definition emit.def.hpp:20

◆ emit_as() [3/3]

template<class Writer>
substr c4::yml::Emitter< Writer >::emit_as ( EmitType_e type,
ConstNodeRef const & n,
bool error_on_excess = true )
inline

emit starting at the given node

Definition at line 261 of file emit.hpp.

262 {
263 if(!n.readable())
264 return {};
265 return this->emit_as(type, *n.tree(), n.id(), error_on_excess);
266 }

◆ options() [1/2]

template<class Writer>
EmitOptions const & c4::yml::Emitter< Writer >::options ( ) const
inlinenoexcept

get the emit options for this object

Definition at line 271 of file emit.hpp.

271{ return m_opts; }

◆ options() [2/2]

template<class Writer>
void c4::yml::Emitter< Writer >::options ( EmitOptions opts)
inlinenoexcept

set the emit options for this object

Definition at line 273 of file emit.hpp.

273{ m_opts = opts; }

◆ max_depth() [3/4]

template<class Writer>
void c4::yml::Emitter< Writer >::max_depth ( id_type max_depth)
inlinenoexcept

set the max depth for emitted trees (to prevent a stack overflow)

Definition at line 276 of file emit.hpp.

void max_depth(id_type max_depth) noexcept
set the max depth for emitted trees (to prevent a stack overflow)
Definition emit.hpp:276

◆ max_depth() [4/4]

template<class Writer>
id_type c4::yml::Emitter< Writer >::max_depth ( ) const
inlinenoexcept

get the max depth for emitted trees (to prevent a stack overflow)

Definition at line 278 of file emit.hpp.

278{ return m_opts.max_depth(); }

◆ next_pws()

template<class Writer>
Pws_e c4::yml::Emitter< Writer >::flow_pws::next_pws ( size_t col) const
inlinenoexcept

Definition at line 321 of file emit.hpp.

◆ start()

template<class Writer>
void c4::yml::Emitter< Writer >::flow_pws::start ( NodeType ty,
size_t max_cols_ )
noexcept

◆ stop()

template<class Writer>
void c4::yml::Emitter< Writer >::flow_pws::stop ( )
inlinenoexcept

Definition at line 326 of file emit.hpp.

326{ active = false; }

◆ as_json() [1/3]

c4::yml::as_json::as_json ( Tree const & t,
EmitOptions const & opts = {} )
inline

Definition at line 662 of file emit.hpp.

662{}) : tree(&t), node(t.empty() ? NONE : t.root_id()), options(opts) {}
Tree const * tree
Definition emit.hpp:659
EmitOptions options
Definition emit.hpp:661
id_type node
Definition emit.hpp:660
@ NONE
an index to none
Definition common.hpp:263

◆ as_json() [2/3]

c4::yml::as_json::as_json ( Tree const & t,
id_type id,
EmitOptions const & opts = {} )
inline

Definition at line 663 of file emit.hpp.

663{}) : tree(&t), node(id), options(opts) {}

◆ as_json() [3/3]

c4::yml::as_json::as_json ( ConstNodeRef const & n,
EmitOptions const & opts = {} )
inline

Definition at line 664 of file emit.hpp.

664{}) : tree(n.tree()), node(n.id()), options(opts) {}

◆ as_yaml() [1/3]

c4::yml::as_yaml::as_yaml ( Tree const & t,
EmitOptions const & opts = {} )
inline

Definition at line 683 of file emit.hpp.

683{}) : tree(&t), node(t.empty() ? NONE : t.root_id()), options(opts) {}
Tree const * tree
Definition emit.hpp:680
EmitOptions options
Definition emit.hpp:682
id_type node
Definition emit.hpp:681

◆ as_yaml() [2/3]

c4::yml::as_yaml::as_yaml ( Tree const & t,
id_type id,
EmitOptions const & opts = {} )
inline

Definition at line 684 of file emit.hpp.

684{}) : tree(&t), node(id), options(opts) {}

◆ as_yaml() [3/3]

c4::yml::as_yaml::as_yaml ( ConstNodeRef const & n,
EmitOptions const & opts = {} )
inline

Definition at line 685 of file emit.hpp.

685{}) : tree(n.tree()), node(n.id()), options(opts) {}

◆ emit_yaml() [1/6]

substr c4::yml::emit_yaml ( Tree const & t,
id_type id,
EmitOptions const & opts,
substr buf,
bool error_on_excess = true )
inline

(1) emit YAML to the given buffer.

Return a substr trimmed to the emitted YAML.

Parameters
tthe tree to emit.
idthe node where to start emitting.
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 731 of file emit.hpp.

732{
733 EmitterBuf em(opts, buf);
734 return em.emit_as(EMIT_YAML, t, id, error_on_excess);
735}
Emitter< WriterBuf > EmitterBuf
Definition emit.hpp:40
@ EMIT_YAML
emit YAML
Definition emit.hpp:49

◆ emit_yaml() [2/6]

substr c4::yml::emit_yaml ( Tree const & t,
id_type id,
substr buf,
bool error_on_excess = true )
inline

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

Definition at line 737 of file emit.hpp.

738{
739 EmitterBuf em(buf);
740 return em.emit_as(EMIT_YAML, t, id, error_on_excess);
741}

◆ emit_json() [1/6]

substr c4::yml::emit_json ( Tree const & t,
id_type id,
EmitOptions const & opts,
substr buf,
bool error_on_excess = true )
inline

(1) emit JSON to the given buffer.

Return a substr trimmed to the emitted JSON.

Parameters
tthe tree to emit.
idthe node where to start emitting.
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 751 of file emit.hpp.

752{
753 EmitterBuf em(opts, buf);
754 return em.emit_as(EMIT_JSON, t, id, error_on_excess);
755}
@ EMIT_JSON
emit JSON
Definition emit.hpp:50

◆ emit_json() [2/6]

substr c4::yml::emit_json ( Tree const & t,
id_type id,
substr buf,
bool error_on_excess = true )
inline

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

Definition at line 757 of file emit.hpp.

758{
759 EmitterBuf em(buf);
760 return em.emit_as(EMIT_JSON, t, id, error_on_excess);
761}

◆ emit_yaml() [3/6]

substr c4::yml::emit_yaml ( Tree const & t,
EmitOptions const & opts,
substr buf,
bool error_on_excess = true )
inline

(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.

Definition at line 774 of file emit.hpp.

775{
776 EmitterBuf em(opts, buf);
777 return em.emit_as(EMIT_YAML, t, error_on_excess);
778}

◆ emit_yaml() [4/6]

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

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

Definition at line 780 of file emit.hpp.

781{
782 EmitterBuf em(buf);
783 return em.emit_as(EMIT_YAML, t, error_on_excess);
784}

◆ emit_json() [3/6]

substr c4::yml::emit_json ( Tree const & t,
EmitOptions const & opts,
substr buf,
bool error_on_excess = true )
inline

(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 793 of file emit.hpp.

794{
795 EmitterBuf em(opts, buf);
796 return em.emit_as(EMIT_JSON, t, error_on_excess);
797}

◆ emit_json() [4/6]

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

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

Definition at line 799 of file emit.hpp.

800{
801 EmitterBuf em(buf);
802 return em.emit_as(EMIT_JSON, t, error_on_excess);
803}

◆ emit_yaml() [5/6]

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

(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 816 of file emit.hpp.

817{
818 if(!r.readable())
819 return {};
820 EmitterBuf em(opts, buf);
821 return em.emit_as(EMIT_YAML, r, error_on_excess);
822}

◆ emit_yaml() [6/6]

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

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

Definition at line 824 of file emit.hpp.

825{
826 if(!r.readable())
827 return {};
828 EmitterBuf em(buf);
829 return em.emit_as(EMIT_YAML, r, error_on_excess);
830}

◆ emit_json() [5/6]

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

(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 839 of file emit.hpp.

840{
841 if(!r.readable())
842 return {};
843 EmitterBuf em(opts, buf);
844 return em.emit_as(EMIT_JSON, r, error_on_excess);
845}

◆ emit_json() [6/6]

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

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

Definition at line 847 of file emit.hpp.

848{
849 if(!r.readable())
850 return {};
851 EmitterBuf em(buf);
852 return em.emit_as(EMIT_JSON, r, error_on_excess);
853}

Variable Documentation

◆ max_cols_default

const id_type c4::yml::EmitOptions::max_cols_default = 80
staticconstexpr

Definition at line 112 of file emit.hpp.

◆ max_depth_default

const id_type c4::yml::EmitOptions::max_depth_default = 64
staticconstexpr

Definition at line 169 of file emit.hpp.

◆ max_cols

template<class Writer>
size_t c4::yml::Emitter< Writer >::flow_pws::max_cols = 0

Definition at line 318 of file emit.hpp.

◆ pend_after_comma

template<class Writer>
Pws_e c4::yml::Emitter< Writer >::flow_pws::pend_after_comma = _PWS_NONE

Definition at line 319 of file emit.hpp.

◆ active

template<class Writer>
bool c4::yml::Emitter< Writer >::flow_pws::active = false

Definition at line 320 of file emit.hpp.

◆ tree [1/2]

Tree const* c4::yml::as_json::tree

Definition at line 659 of file emit.hpp.

◆ node [1/2]

id_type c4::yml::as_json::node

Definition at line 660 of file emit.hpp.

◆ options [1/2]

EmitOptions c4::yml::as_json::options

Definition at line 661 of file emit.hpp.

◆ tree [2/2]

Tree const* c4::yml::as_yaml::tree

Definition at line 680 of file emit.hpp.

◆ node [2/2]

id_type c4::yml::as_yaml::node

Definition at line 681 of file emit.hpp.

◆ options [2/2]

EmitOptions c4::yml::as_yaml::options

Definition at line 682 of file emit.hpp.