1 #ifndef C4_YML_EMIT_OPTIONS_HPP_
2 #define C4_YML_EMIT_OPTIONS_HPP_
4 #ifndef C4_YML_COMMON_HPP_
19 typedef enum : uint32_t {
20 INDENT_FLOW_ML = 1u << 0u,
21 FORCE_FLOW_SPC = 1u << 1u,
22 EMIT_NONROOT_KEY = 1u << 2u,
23 EMIT_NONROOT_DASH = 1u << 3u,
24 EMIT_NONROOT_MARKUP = EMIT_NONROOT_KEY|EMIT_NONROOT_DASH,
25 JSON_ERR_ON_STREAM = 1u << 4u,
26 JSON_ERR_ON_TAG = 1u << 5u,
27 JSON_ERR_ON_ANCHOR = 1u << 6u,
28 JSON_ERR_MASK_ = JSON_ERR_ON_TAG|JSON_ERR_ON_ANCHOR,
29 DEFAULT_FLAGS = EMIT_NONROOT_KEY|INDENT_FLOW_ML,
54 C4_ALWAYS_INLINE
bool indent_flow_ml() const noexcept {
return (m_flags & INDENT_FLOW_ML) != 0; }
62 C4_ALWAYS_INLINE
bool force_flow_spc() const noexcept {
return (m_flags & FORCE_FLOW_SPC) != 0; }
70 static constexpr
const id_type max_cols_default = 80;
86 C4_ALWAYS_INLINE
bool emit_nonroot_key() const noexcept {
return (m_flags & EMIT_NONROOT_KEY) != 0; }
92 C4_ALWAYS_INLINE
bool emit_nonroot_dash() const noexcept {
return (m_flags & EMIT_NONROOT_DASH) != 0; }
106 C4_ALWAYS_INLINE
bool json_err_on_stream() const noexcept {
return (m_flags & JSON_ERR_ON_STREAM) != 0; }
111 C4_ALWAYS_INLINE
bool json_err_on_tag() const noexcept {
return (m_flags & JSON_ERR_ON_TAG) != 0; }
116 C4_ALWAYS_INLINE
bool json_err_on_anchor() const noexcept {
return (m_flags & JSON_ERR_ON_ANCHOR) != 0; }
130 static constexpr
const id_type max_depth_default = 64;
137 return m_max_depth == that.m_max_depth
138 && m_max_cols == that.m_max_cols
139 && m_flags == that.m_flags;
145 id_type m_max_depth{max_depth_default};
146 id_type m_max_cols{max_cols_default};
147 uint32_t m_flags{DEFAULT_FLAGS};
153 RYML_DEPRECATED(
"use .json_err_on_{tag,anchor}()") C4_ALWAYS_INLINE Flags_e json_error_flags() const noexcept {
return static_cast<Flags_e
>(m_flags & JSON_ERR_MASK_); }
154 RYML_DEPRECATED(
"use .json_err_on_{tag,anchor}()") EmitOptions& json_error_flags(Flags_e d) noexcept { m_flags = (d & JSON_ERR_MASK_);
return *
this; }
bool emit_nonroot_dash() const noexcept
bool indent_flow_ml() const noexcept
Indent the contents of FLOW_ML1 and FLOW_MLN containers.
bool force_flow_spc() const noexcept
bool json_err_on_tag() const noexcept
Common utilities and infrastructure used by ryml.
bool json_err_on_stream() const noexcept
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
EmitOptions & json_err_on_tag(bool enabled) noexcept
Whether to trigger an error (or ignore the tag) when finding a tag in json mode.
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 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.
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 conta...
EmitOptions & max_cols(id_type cols) noexcept
Set max columns for the emitted YAML in FLOW_MLN mode.
bool json_err_on_anchor() const noexcept
A lightweight object containing options to be used when emitting.
EmitOptions & max_depth(id_type d) noexcept
id_type max_cols() const noexcept
EmitOptions & emit_nonroot_key(bool enabled) noexcept
When emit starts on a nested (non-root) node, emit the node's key as well.
EmitOptions & json_err_on_stream(bool enabled) noexcept
Whether to trigger an error (or emit as seq) when finding a stream in json mode.
bool operator==(const char c, basic_substring< C > const that) noexcept
id_type max_depth() const noexcept