rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4::yml::EmitOptions Struct Reference

A lightweight object containing options to be used when emitting. More...

#include <emit_options.hpp>

Public Member Functions

bool operator== (const EmitOptions &that) const noexcept
Nested nodes

Control emission of non-root (nested) nodes.

EmitOptionsemit_nonroot_key (bool enabled) noexcept
 When emit starts on a node which is not the root node, emit the node key as well.
bool emit_nonroot_key () const noexcept
EmitOptionsemit_nonroot_dash (bool enabled) noexcept
 When emit starts on a node which is not the root node, emit a leading dash.
bool emit_nonroot_dash () const noexcept
JSON behavior

Controls the behavior when emitting JSON.

EmitOptionsjson_err_on_stream (bool enabled) noexcept
 Whether to trigger an error (or emit as seq) when finding a stream in json mode.
bool json_err_on_stream () const noexcept
EmitOptionsjson_err_on_tag (bool enabled) noexcept
 Whether to trigger an error (or ignore the tag) when finding a tag in json mode.
bool json_err_on_tag () const noexcept
EmitOptionsjson_err_on_anchor (bool enabled) noexcept
 Whether to trigger an error (or ignore the anchor) when finding an anchor in json mode.
bool json_err_on_anchor () const noexcept

YAML flow customization

Control formatting of YAML flow containers.

static constexpr const id_type max_cols_default = 80
bool indent_flow_ml () const noexcept
 Indent the contents of FLOW_ML1 and FLOW_MLN containers.
EmitOptionsindent_flow_ml (bool enabled) noexcept
EmitOptionsforce_flow_spc (bool enabled) noexcept
 Force everywhere a space after comma in flow mode, overriding the FLOW_SPC status of individual containers.
bool force_flow_spc () const noexcept
EmitOptionsmax_cols (id_type cols) noexcept
 Set max columns for the emitted YAML in FLOW_MLN mode.
id_type 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 max_depth_default = 64
id_type max_depth () const noexcept
EmitOptionsmax_depth (id_type d) noexcept

Detailed Description

A lightweight object containing options to be used when emitting.

Definition at line 14 of file emit_options.hpp.

Member 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 54 of file emit_options.hpp.

54{ 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 55 of file emit_options.hpp.

55{ 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 61 of file emit_options.hpp.

61{ return set_flags_(enabled, FORCE_FLOW_SPC); }

◆ force_flow_spc() [2/2]

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

Definition at line 62 of file emit_options.hpp.

62{ 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 68 of file emit_options.hpp.

68{ m_max_cols = cols; return *this; }

◆ max_cols() [2/2]

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

Definition at line 69 of file emit_options.hpp.

69{ 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 85 of file emit_options.hpp.

85{ return set_flags_(enabled, EMIT_NONROOT_KEY); }

◆ emit_nonroot_key() [2/2]

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

Definition at line 86 of file emit_options.hpp.

86{ 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 91 of file emit_options.hpp.

91{ return set_flags_(enabled, EMIT_NONROOT_DASH); }

◆ emit_nonroot_dash() [2/2]

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

Definition at line 92 of file emit_options.hpp.

92{ 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 (or emit as seq) when finding a stream in json mode.

Disabled by default.

Definition at line 105 of file emit_options.hpp.

105{ 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 106 of file emit_options.hpp.

106{ 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 110 of file emit_options.hpp.

110{ 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 111 of file emit_options.hpp.

111{ 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 115 of file emit_options.hpp.

115{ 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 116 of file emit_options.hpp.

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

◆ max_depth() [1/2]

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

Definition at line 128 of file emit_options.hpp.

128{ return m_max_depth; }

◆ max_depth() [2/2]

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

Definition at line 129 of file emit_options.hpp.

129{ m_max_depth = d; return *this; }

◆ operator==()

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

Definition at line 135 of file emit_options.hpp.

136 {
137 return m_max_depth == that.m_max_depth
138 && m_max_cols == that.m_max_cols
139 && m_flags == that.m_flags;
140 }

Member Data Documentation

◆ max_cols_default

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

Definition at line 70 of file emit_options.hpp.

◆ max_depth_default

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

Definition at line 130 of file emit_options.hpp.


The documentation for this struct was generated from the following file:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/latest/src/c4/yml/emit_options.hpp