1 #ifndef _C4_YML_NODE_TYPE_HPP_
2 #define _C4_YML_NODE_TYPE_HPP_
4 #ifndef _C4_YML_COMMON_HPP_
8 C4_SUPPRESS_WARNING_MSVC_PUSH
9 C4_SUPPRESS_WARNING_GCC_CLANG_PUSH
10 C4_SUPPRESS_WARNING_GCC_CLANG(
"-Wold-style-cast")
12 C4_SUPPRESS_WARNING_GCC(
"-Wnull-dereference")
35 #define __(v) (type_bits(1) << v)
145 C4_ALWAYS_INLINE
operator NodeType_e & C4_RESTRICT () noexcept {
return type; }
146 C4_ALWAYS_INLINE
operator NodeType_e const& C4_RESTRICT () const noexcept {
return type; }
156 static const char* type_str(
NodeType_e t) noexcept;
159 C4_ALWAYS_INLINE csubstr
type_str(substr buf)
const noexcept {
return type_str(buf, type); }
161 static csubstr type_str(substr buf,
NodeType_e t) noexcept;
170 C4_ALWAYS_INLINE
bool is_doc() const noexcept {
return (type &
DOC) != 0; }
172 C4_ALWAYS_INLINE
bool is_map() const noexcept {
return (type &
MAP) != 0; }
173 C4_ALWAYS_INLINE
bool is_seq() const noexcept {
return (type &
SEQ) != 0; }
174 C4_ALWAYS_INLINE
bool has_key() const noexcept {
return (type &
KEY) != 0; }
175 C4_ALWAYS_INLINE
bool has_val() const noexcept {
return (type &
VAL) != 0; }
192 RYML_DEPRECATED(
"use has_key_anchor()") bool is_key_anchor() const noexcept {
return has_key_anchor(); }
193 RYML_DEPRECATED(
"use has_val_anchor()") bool is_val_anchor() const noexcept {
return has_val_anchor(); }
194 RYML_DEPRECATED(
"use has_anchor()") bool is_anchor() const noexcept {
return has_anchor(); }
195 RYML_DEPRECATED(
"use has_anchor() || is_ref()") bool is_anchor_or_ref() const noexcept {
return has_anchor() || is_ref(); }
204 C4_ALWAYS_INLINE
bool is_block() const noexcept {
return (type & (
BLOCK)) != 0; }
265 return s.str ==
nullptr ||
280 C4_SUPPRESS_WARNING_MSVC_POP
281 C4_SUPPRESS_WARNING_GCC_CLANG_POP
Common utilities and infrastructure used by ryml.
OStream & operator<<(OStream &s, Tree const &t)
emit YAML to an STL-like ostream
constexpr C4_CONST NodeType_e operator&(NodeType_e lhs, NodeType_e rhs) noexcept
constexpr C4_CONST NodeType_e operator|(NodeType_e lhs, NodeType_e rhs) noexcept
bool scalar_is_null(csubstr s) noexcept
YAML-sense query of nullity.
NodeType_e & operator|=(NodeType_e &subject, NodeType_e bits) noexcept
constexpr C4_CONST NodeType_e operator>>(NodeType_e bits, uint32_t n) noexcept
NodeType_e scalar_style_json_choose(csubstr s) noexcept
choose a json style based on the scalar's contents
bool scalar_style_query_squo(csubstr s) noexcept
query whether a scalar can be encoded using single quotes.
bool scalar_style_query_plain(csubstr s) noexcept
query whether a scalar can be encoded using plain style (no quotes, not a literal/folded block scalar...
NodeType_e scalar_style_choose(csubstr s) noexcept
choose a YAML emitting style based on the scalar's contents
uint32_t type_bits
the integral type necessary to cover all the bits for NodeType_e
NodeType_e & operator&=(NodeType_e &subject, NodeType_e bits) noexcept
constexpr C4_CONST NodeType_e operator~(NodeType_e bits) noexcept
NodeType_e
a bit mask for marking node types and styles
@ VALANCH
the val has an &anchor
@ NOTYPE
no node type or style is set
@ KEY_DQUO
mark key scalar as double quoted "
@ VALREF
a *reference: the val references an &anchor
@ VALNIL
the val is null (eg {a : } results in a null val)
@ MAP
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
@ STREAM
a stream: a seq of docs
@ KEYQUO
key style is one of ', ", > or |
@ VAL_FOLDED
mark val scalar as multiline, block folded >
@ VAL_STYLE
mask of all the scalar styles for val (not container styles!)
@ KEYTAG
the key has a tag
@ FLOW_SL
mark container with single-line flow style (seqs as '[val1,val2], maps as '{key: val,...
@ FLOW_ML
mark container with multi-line flow style (seqs as '[ val1, val2 ], maps as '{ key: val,...
@ VAL_UNFILT
the val scalar was left unfiltered; the parser was set not to filter.
@ VAL
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
@ VALTAG
the val has a tag
@ _TYMASK
all the bits up to here
@ SEQ
a seq: a parent of VAL/SEQ/MAP nodes
@ VAL_SQUO
mark val scalar as single quoted '
@ KEY_STYLE
mask of all the scalar styles for key (not container styles!)
@ VAL_PLAIN
mark val scalar as plain scalar (unquoted, even when multiline)
@ KEYREF
a *reference: the key references an &anchor
@ BLOCK
mark container with block style (seqs as '- val ', maps as 'key: val')
@ KEYANCH
the key has an &anchor
@ VALQUO
val style is one of ', ", > or |
@ VAL_DQUO
mark val scalar as double quoted "
@ KEY_UNFILT
the key scalar was left unfiltered; the parser was set not to filter.
@ KEY_SQUO
mark key scalar as single quoted '
@ VAL_LITERAL
mark val scalar as multiline, block literal |
@ KEY_LITERAL
mark key scalar as multiline, block literal |
@ KEY_PLAIN
mark key scalar as plain scalar (unquoted, even when multiline)
@ KEY_FOLDED
mark key scalar as multiline, block folded >
@ KEYNIL
the key is null (eg { : b} results in a null key)
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
wraps a NodeType_e element with some syntactic sugar and predicates
bool has_all(NodeType_e t) const noexcept
bool is_val_squo() const noexcept
bool is_key_plain() const noexcept
bool has_key() const noexcept
bool is_quoted() const noexcept
bool is_val_folded() const noexcept
bool has_none(NodeType_e t) const noexcept
bool has_key_tag() const noexcept
bool is_ref() const noexcept
NodeType(NodeType_e t) noexcept
void set_container_style(NodeType_e style) noexcept
bool is_key_ref() const noexcept
void set_key_style(NodeType_e style) noexcept
bool key_is_null() const noexcept
bool has_any(NodeType_e t) const noexcept
bool is_key_dquo() const noexcept
bool is_doc() const noexcept
bool is_seq() const noexcept
bool is_val_plain() const noexcept
bool is_notype() const noexcept
bool is_key_quoted() const noexcept
bool is_flow_ml() const noexcept
void rem(NodeType_e t) noexcept
const char * type_str() const noexcept
return a preset string based on the node type
bool has_val_anchor() const noexcept
bool is_key_unfiltered() const noexcept
bool has_val_tag() const noexcept
bool is_key_literal() const noexcept
bool is_key_squo() const noexcept
bool has_anchor() const noexcept
NodeType(type_bits t) noexcept
bool has_key_anchor() const noexcept
bool has_val() const noexcept
bool is_val_unfiltered() const noexcept
bool is_flow_sl() const noexcept
bool is_map() const noexcept
bool is_val_styled() const noexcept
bool is_key_folded() const noexcept
bool is_container() const noexcept
bool is_container_styled() const noexcept
bool is_val_literal() const noexcept
bool is_key_styled() const noexcept
bool is_block() const noexcept
NodeType val_style() const noexcept
bool val_is_null() const noexcept
void set_val_style(NodeType_e style) noexcept
void addrem(NodeType_e bits_to_add, NodeType_e bits_to_remove) noexcept
void add(NodeType_e t) noexcept
csubstr type_str(substr buf) const noexcept
fill a string with the node type flags.
void set(NodeType_e t) noexcept
bool is_keyval() const noexcept
bool is_val() const noexcept
void clear_style() noexcept
bool is_val_ref() const noexcept
bool is_val_quoted() const noexcept
bool is_val_dquo() const noexcept
NodeType key_style() const noexcept
bool is_stream() const noexcept
bool is_flow() const noexcept