rapidyaml  0.16.0
parseandemitYAML,anddoitfast
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 nested (non-root) nodes.

EmitOptions & emit_nonroot_key (bool enabled) noexcept
 When emit starts on a nested (non-root) node, emit the node's key as well. More...
 
bool emit_nonroot_key () const noexcept
 
EmitOptions & emit_nonroot_dash (bool enabled) noexcept
 When emit starts on a nested (non-root) node, emit a leading dash. More...
 
bool emit_nonroot_dash () const noexcept
 
JSON behavior

Controls the behavior when emitting JSON.

EmitOptions & json_err_on_stream (bool enabled) noexcept
 Whether to trigger an error (or emit as seq) when finding a stream in json mode. More...
 
bool json_err_on_stream () const noexcept
 
EmitOptions & json_err_on_tag (bool enabled) noexcept
 Whether to trigger an error (or ignore the tag) when finding a tag in json mode. More...
 
bool json_err_on_tag () const noexcept
 
EmitOptions & json_err_on_anchor (bool enabled) noexcept
 Whether to trigger an error (or ignore the anchor) when finding an anchor in json mode. More...
 
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. More...
 
EmitOptions & indent_flow_ml (bool enabled) noexcept
 
EmitOptions & force_flow_spc (bool enabled) noexcept
 Force everywhere a space after comma in flow mode, overriding the FLOW_SPC status of individual containers. More...
 
bool force_flow_spc () const noexcept
 
EmitOptions & max_cols (id_type cols) noexcept
 Set max columns for the emitted YAML in FLOW_MLN mode. More...
 
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
 
EmitOptions & max_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

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.

Referenced by sample_style_flow_formatting(), and sample_style_flow_ml_indent().

54 { return (m_flags & INDENT_FLOW_ML) != 0; }
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); }
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.

Referenced by sample_style_flow_formatting().

61 { return set_flags_(enabled, FORCE_FLOW_SPC); }
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; }
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.

Referenced by sample_style(), and sample_style_flow_formatting().

68 { m_max_cols = cols; return *this; }
id_type c4::yml::EmitOptions::max_cols ( ) const
inlinenoexcept

Definition at line 69 of file emit_options.hpp.

69 { return m_max_cols; }
EmitOptions& c4::yml::EmitOptions::emit_nonroot_key ( bool  enabled)
inlinenoexcept

When emit starts on a nested (non-root) node, emit the node's key as well.

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

Definition at line 85 of file emit_options.hpp.

Referenced by sample_emit_nested_node().

85 { return set_flags_(enabled, EMIT_NONROOT_KEY); }
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; }
EmitOptions& c4::yml::EmitOptions::emit_nonroot_dash ( bool  enabled)
inlinenoexcept

When emit starts on a nested (non-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.

Referenced by sample_emit_nested_node().

91 { return set_flags_(enabled, EMIT_NONROOT_DASH); }
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; }
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.

Referenced by sample_docs().

105 { return set_flags_(enabled, JSON_ERR_ON_STREAM); }
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; }
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); }
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; }
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); }
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; }
id_type c4::yml::EmitOptions::max_depth ( ) const
inlinenoexcept

Definition at line 128 of file emit_options.hpp.

128 { return m_max_depth; }
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; }
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

constexpr const id_type c4::yml::EmitOptions::max_cols_default = 80
static

Definition at line 70 of file emit_options.hpp.

constexpr const id_type c4::yml::EmitOptions::max_depth_default = 64
static

Definition at line 130 of file emit_options.hpp.


The documentation for this struct was generated from the following file: