rapidyaml 0.15.2
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_stream (bool enabled) noexcept
 Whether to trigger an error when findind a stream in json mode.
bool c4::yml::EmitOptions::json_err_on_stream () const noexcept
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 97 of file emit.hpp.

97{ 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 98 of file emit.hpp.

98{ 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 104 of file emit.hpp.

104{ return set_flags_(enabled, FORCE_FLOW_SPC); }

◆ force_flow_spc() [2/2]

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

Definition at line 105 of file emit.hpp.

105{ 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 111 of file emit.hpp.

111{ m_max_cols = cols; return *this; }

◆ max_cols() [2/2]

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

Definition at line 112 of file emit.hpp.

112{ 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 126 of file emit.hpp.

126{ return set_flags_(enabled, EMIT_NONROOT_KEY); }

◆ emit_nonroot_key() [2/2]

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

Definition at line 127 of file emit.hpp.

127{ 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 132 of file emit.hpp.

132{ return set_flags_(enabled, EMIT_NONROOT_DASH); }

◆ emit_nonroot_dash() [2/2]

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

Definition at line 133 of file emit.hpp.

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

◆ json_err_on_stream() [1/2]

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

Whether to trigger an error when findind a stream in json mode.

Disabled by default.

Definition at line 145 of file emit.hpp.

145{ return set_flags_(enabled, JSON_ERR_ON_STREAM); }

◆ json_err_on_stream() [2/2]

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

Definition at line 146 of file emit.hpp.

146{ return (m_flags & JSON_ERR_ON_STREAM) != 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 150 of file emit.hpp.

150{ 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 151 of file emit.hpp.

151{ 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 155 of file emit.hpp.

155{ 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 156 of file emit.hpp.

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

◆ max_depth() [1/4]

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

Definition at line 173 of file emit.hpp.

173{ return m_max_depth; }

◆ max_depth() [2/4]

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

Definition at line 174 of file emit.hpp.

174{ m_max_depth = d; return *this; }

◆ operator==()

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

Definition at line 180 of file emit.hpp.

181 {
182 return m_max_depth == that.m_max_depth &&
183 m_flags == that.m_flags;
184 }

◆ 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 213 of file emit.hpp.

215 , m_tree()
216 , m_opts(opts)
217 , m_col()
218 , m_depth()
219 , m_ilevel()
220 , m_pws()
221 , m_flow_pws()
222 {}
A stateful emitter, for use with a writer such as WriterBuf, WriterFile, or WriterOStream.
Definition emit.hpp:204

◆ 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 228 of file emit.hpp.

230 , m_tree()
231 , m_opts()
232 , m_col()
233 , m_depth()
234 , m_ilevel()
235 , m_pws()
236 , m_flow_pws()
237 {}

◆ 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 260 of file emit.hpp.

261 {
262 if(t.empty())
263 return {};
264 return this->emit_as(type, t, t.root_id(), error_on_excess);
265 }
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 267 of file emit.hpp.

268 {
269 if(!n.readable())
270 return {};
271 return this->emit_as(type, *n.tree(), n.id(), error_on_excess);
272 }

◆ 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 277 of file emit.hpp.

277{ 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 279 of file emit.hpp.

279{ 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 282 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:282

◆ 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 284 of file emit.hpp.

284{ 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 327 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 332 of file emit.hpp.

332{ active = false; }

◆ as_json() [1/3]

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

Definition at line 668 of file emit.hpp.

668{}) : tree(&t), node(t.empty() ? NONE : t.root_id()), options(opts) {}
Tree const * tree
Definition emit.hpp:665
EmitOptions options
Definition emit.hpp:667
id_type node
Definition emit.hpp:666
@ 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 669 of file emit.hpp.

669{}) : 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 670 of file emit.hpp.

670{}) : 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 689 of file emit.hpp.

689{}) : tree(&t), node(t.empty() ? NONE : t.root_id()), options(opts) {}
Tree const * tree
Definition emit.hpp:686
EmitOptions options
Definition emit.hpp:688
id_type node
Definition emit.hpp:687

◆ as_yaml() [2/3]

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

Definition at line 690 of file emit.hpp.

690{}) : 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 691 of file emit.hpp.

691{}) : 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 737 of file emit.hpp.

738{
739 EmitterBuf em(opts, buf);
740 return em.emit_as(EMIT_YAML, t, id, error_on_excess);
741}
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 743 of file emit.hpp.

744{
745 EmitterBuf em(buf);
746 return em.emit_as(EMIT_YAML, t, id, error_on_excess);
747}

◆ 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 757 of file emit.hpp.

758{
759 EmitterBuf em(opts, buf);
760 return em.emit_as(EMIT_JSON, t, id, error_on_excess);
761}
@ 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 763 of file emit.hpp.

764{
765 EmitterBuf em(buf);
766 return em.emit_as(EMIT_JSON, t, id, error_on_excess);
767}

◆ 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 780 of file emit.hpp.

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

◆ 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 786 of file emit.hpp.

787{
788 EmitterBuf em(buf);
789 return em.emit_as(EMIT_YAML, t, error_on_excess);
790}

◆ 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 799 of file emit.hpp.

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

◆ 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 805 of file emit.hpp.

806{
807 EmitterBuf em(buf);
808 return em.emit_as(EMIT_JSON, t, error_on_excess);
809}

◆ 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 822 of file emit.hpp.

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

◆ 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 830 of file emit.hpp.

831{
832 if(!r.readable())
833 return {};
834 EmitterBuf em(buf);
835 return em.emit_as(EMIT_YAML, r, error_on_excess);
836}

◆ 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 845 of file emit.hpp.

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

◆ 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 853 of file emit.hpp.

854{
855 if(!r.readable())
856 return {};
857 EmitterBuf em(buf);
858 return em.emit_as(EMIT_JSON, r, error_on_excess);
859}

Variable Documentation

◆ max_cols_default

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

Definition at line 113 of file emit.hpp.

◆ max_depth_default

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

Definition at line 175 of file emit.hpp.

◆ max_cols

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

Definition at line 324 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 325 of file emit.hpp.

◆ active

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

Definition at line 326 of file emit.hpp.

◆ tree [1/2]

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

Definition at line 665 of file emit.hpp.

◆ node [1/2]

id_type c4::yml::as_json::node

Definition at line 666 of file emit.hpp.

◆ options [1/2]

EmitOptions c4::yml::as_json::options

Definition at line 667 of file emit.hpp.

◆ tree [2/2]

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

Definition at line 686 of file emit.hpp.

◆ node [2/2]

id_type c4::yml::as_yaml::node

Definition at line 687 of file emit.hpp.

◆ options [2/2]

EmitOptions c4::yml::as_yaml::options

Definition at line 688 of file emit.hpp.