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")
11 #if defined(__GNUC__) && __GNUC__ >= 6
12 C4_SUPPRESS_WARNING_GCC(
"-Wnull-dereference")
31 #define b_(v) (type_bits(1) << v) // a convenience define, undefined below // NOLINT
190 #ifdef RYML_HAS_DEPRECATED_ENUMS_
191 FLOW_ML RYML_DEPRECATED(
"use one of FLOW_ML{1,N,X}") =
FLOW_ML1,
197 using NodeType_e RYML_DEPRECATED(
"use NodeTypeBits") =
NodeTypeBits;
198 #ifndef RYML_HAS_DEPRECATED_ENUMS_
201 RYML_DEPRECATED(
"use one of FLOW_ML{1,N,X}")
224 C4_ALWAYS_INLINE
operator type_bits & () noexcept {
return m_bits; }
225 C4_ALWAYS_INLINE
operator type_bits const& ()
const noexcept {
return m_bits; }
251 C4_ALWAYS_INLINE
void addrem(
type_bits bits_to_add,
type_bits bits_to_remove) noexcept { m_bits |= bits_to_add; m_bits &= ~bits_to_remove; }
265 static const char* type_str(
type_bits t) noexcept;
278 ret.
len = type_str(buf, t);
279 ret.
str = ret.
len < buf.len ? buf.str :
nullptr;
291 C4_ALWAYS_INLINE
bool is_stream() const noexcept {
return ((m_bits &
STREAM) == STREAM) != 0; }
292 C4_ALWAYS_INLINE
bool is_doc() const noexcept {
return (m_bits &
DOC) != 0; }
294 C4_ALWAYS_INLINE
bool is_map() const noexcept {
return (m_bits &
MAP) != 0; }
295 C4_ALWAYS_INLINE
bool is_seq() const noexcept {
return (m_bits &
SEQ) != 0; }
296 C4_ALWAYS_INLINE
bool has_key() const noexcept {
return (m_bits &
KEY) != 0; }
297 C4_ALWAYS_INLINE
bool has_val() const noexcept {
return (m_bits &
VAL) != 0; }
322 C4_ALWAYS_INLINE
bool is_block() const noexcept {
return (m_bits & (
BLOCK)) != 0; }
324 C4_ALWAYS_INLINE
bool is_flow_ml1() const noexcept {
return (m_bits & (FLOW_ML1)) != 0; }
359 RYML_DEPRECATED(
"use has_key_anchor()") bool is_key_anchor() const noexcept {
return has_key_anchor(); }
360 RYML_DEPRECATED(
"use has_val_anchor()") bool is_val_anchor() const noexcept {
return has_val_anchor(); }
361 RYML_DEPRECATED(
"use has_anchor()") bool is_anchor() const noexcept {
return has_anchor(); }
362 RYML_DEPRECATED(
"use has_anchor() || is_ref()") bool is_anchor_or_ref() const noexcept {
return has_anchor() || is_ref(); }
363 RYML_DEPRECATED(
"use one of .is_flow_ml{1,n,x}()") bool is_flow_ml() const noexcept {
return (m_bits & (FLOW_ML1)) != 0; }
373 C4_SUPPRESS_WARNING_MSVC_POP
374 C4_SUPPRESS_WARNING_GCC_CLANG_POP
const char * type_str() const noexcept
return a preset string based on the node type
mark val scalar as plain scalar (unquoted, even when multiline)
bool is_ref() const noexcept
the val scalar was left unfiltered; the parser was set not to filter.
mark key scalar as double quoted "
void add(type_bits t) noexcept
bool is_doc() const noexcept
bool key_is_null() const noexcept
bool is_val_literal() const noexcept
static csubstr type_str_sub(substr buf, type_bits t) noexcept
fill a string with the node type flags.
mark key scalar as multiline, block literal |
bool is_flow_sl() const noexcept
mark val scalar as single quoted '
void addrem(type_bits bits_to_add, type_bits bits_to_remove) noexcept
the key scalar was left unfiltered; the parser was set not to filter.
val style is one of `'">|`. mask of VAL_SQUO|VAL_DQUO|VAL_FOLDED|VAL_LITERAL
NodeType(type_bits t) noexcept
bool is_val() const noexcept
bool is_flow_mln() const noexcept
C * str
a restricted pointer to the first character of the substring
bool has_val_anchor() const noexcept
mask of CONTAINER_STYLE_FLOW|CONTAINER_STYLE_BLOCK : all container style flags
mark val scalar as double quoted "
bool is_val_ref() const noexcept
bool is_key_literal() const noexcept
bool is_map() const noexcept
bool is_block() const noexcept
mask of KEY_FOLDED|VAL_FOLDED,
bool is_val_styled() const noexcept
bool is_val_unfiltered() const noexcept
bool is_stream() const noexcept
mark container with multi-line flow style, n elements per line, < wrapped (as set by EmitOptions::max...
the key is null (eg { : b} results in a null key)
void set_container_style(type_bits style) noexcept
key style is one of `'">|`. mask of KEY_SQUO|KEY_DQUO|KEY_FOLDED|KEY_LITERAL
bool has_all(type_bits t) const noexcept
mask of KEY_STYLE|VAL_STYLE : all the key+val scalar styles
mask of KEY_SQUO|VAL_SQUO,
Common utilities and infrastructure used by ryml.
a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or S...
bool is_val_quoted() const noexcept
bool has_val() const noexcept
bool is_seq() const noexcept
bool is_key_plain() const noexcept
bool has_flow_space() const noexcept
bool is_notype() const noexcept
mark val scalar as multiline, block folded >
mark key scalar as multiline, block folded >
bool is_keyval() const noexcept
size_t type_str(substr buf) const noexcept
fill a string with the node type flags.
bool is_key_dquo() const noexcept
bool is_val_plain() const noexcept
mask of KEY_PLAIN|VAL_PLAIN,
bool is_key_styled() const noexcept
bool is_key_folded() const noexcept
the val is null (eg {a : } results in a null val)
a *reference: the val references an &anchor
mark container with block style < - seqs as <
bool is_quoted() const noexcept
the scalar to the left of : in a map's member
a *reference: the key references an &anchor
mask of KEYQUO|KEY_PLAIN : all the key scalar styles for key (not container styles!) ...
bool is_flow() const noexcept
void set(type_bits t) noexcept
no node type or style is set
size_t len
the length of the substring
bool is_flow_mlx() const noexcept
bool has_val_tag() const noexcept
bool is_key_quoted() const noexcept
void clear_style() noexcept
mark container with spaces after comma when in flow mode. < Applies to both FLOW_SL and FLOW_MLN (but...
bool is_val_folded() const noexcept
mark key scalar as plain scalar (unquoted, even when multiline)
bool has_key() const noexcept
mask of FLOW_SL|FLOW_MLX|FLOW_SPC : all flow flags
NodeType val_style() const noexcept
bool is_val_squo() const noexcept
csubstr type_str_sub(substr buf) const noexcept
fill a string with the node type flags.
NodeType key_style() const noexcept
bool is_container_styled() const noexcept
bool has_key_anchor() const noexcept
mask of FLOW_ML1|FLOW_MLN : all the flow multiline styles
mask of KEY_DQUO|VAL_DQUO,
mark val scalar as multiline, block literal |
bool has_key_tag() const noexcept
bool has_anchor() const noexcept
uint32_t type_bits
the integral type necessary to cover all the bits for NodeType_e
void set_val_style(type_bits style) noexcept
bool is_key_unfiltered() const noexcept
bool has_any(type_bits t) const noexcept
void rem(type_bits t) noexcept
bool is_flow_ml1() const noexcept
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
NodeTypeBits
a bit mask for marking node types and styles
bool is_val_dquo() const noexcept
bool is_container() const noexcept
Wraps a type_bits mask of NodeTypeBits flags with some syntactic sugar and predicates.
mark key scalar as single quoted '
bool has_none(type_bits t) const noexcept
mark container with multi-line flow style, 1 element per line < - seqs as <
bool is_key_ref() const noexcept
mask of VALQUO|VAL_PLAIN : all the val scalar styles for val (not container styles!) ...
mask of SCALAR_STYLE | CONTAINER_STYLE : all style flags
mask of KEY_LITERAL|VAL_LITERAL,
a seq: a parent of VAL/SEQ/MAP nodes
bool is_key_squo() const noexcept
void set_key_style(type_bits style) noexcept
mark container with single-line flow style < - seqs as <
bool val_is_null() const noexcept