rapidyaml  0.16.0
parseandemitYAML,anddoitfast
node_type.hpp
Go to the documentation of this file.
1 #ifndef C4_YML_NODE_TYPE_HPP_
2 #define C4_YML_NODE_TYPE_HPP_
3 
4 #ifndef C4_YML_COMMON_HPP_
5 #include "c4/yml/common.hpp"
6 #endif
7 
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")
13 #endif
14 // NOLINTBEGIN(modernize-avoid-c-style-cast)
15 
16 namespace c4 {
17 namespace yml {
18 
19 /** @addtogroup doc_node_type
20  *
21  * @{
22  */
23 
24 
25 /** the integral type necessary to cover all the bits for NodeType_e */
26 using type_bits = uint32_t;
27 
28 
29 /** a bit mask for marking node types and styles */
30 typedef enum : type_bits { // NOLINT
31  #define b_(v) (type_bits(1) << v) // a convenience define, undefined below // NOLINT
32  NOTYPE = 0, ///< no node type or style is set
33  KEY = b_(0), ///< the scalar to the left of `:` in a map's member
34  VAL = b_(1), ///< a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or SEQ
35  MAP = b_(2), ///< a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
36  SEQ = b_(3), ///< a seq: a parent of VAL/SEQ/MAP nodes
37  DOC = b_(4), ///< a document
38  STREAM = b_(5)|SEQ, ///< a stream: a seq of docs
39  KEYREF = b_(6), ///< a *reference: the key references an &anchor
40  VALREF = b_(7), ///< a *reference: the val references an &anchor
41  KEYANCH = b_(8), ///< the key has an &anchor
42  VALANCH = b_(9), ///< the val has an &anchor
43  KEYTAG = b_(10), ///< the key has a tag
44  VALTAG = b_(11), ///< the val has a tag
45  KEYNIL = b_(12), ///< the key is null (eg `{ : b}` results in a null key)
46  VALNIL = b_(13), ///< the val is null (eg `{a : }` results in a null val)
47  TYMASK_ = b_(14)-1, ///< all the bits up to here
48  //
49  // unfiltered flags:
50  //
51  KEY_UNFILT = b_(14), ///< the key scalar was left unfiltered; the parser was set not to filter. @see @ref ParserOptions::scalar_filtering()
52  VAL_UNFILT = b_(15), ///< the val scalar was left unfiltered; the parser was set not to filter. @see @ref ParserOptions::scalar_filtering()
53  //
54  // style flags:
55  //
56  FLOW_SL = b_(16), ///< mark container with single-line flow style
57  ///< - seqs as
58  ///< @code{yaml}
59  ///< [val1,val2]
60  ///< @endcode
61  ///< when @ref FLOW_SPC is not set, or
62  ///< @code{yaml}
63  ///< [val1, val2]
64  ///< @endcode
65  ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
66  ///< - maps as
67  ///< @code{yaml}
68  ///< {key1: val1,key2: val2}
69  ///< @endcode
70  ///< when @ref FLOW_SPC is not set, or
71  ///< @code{yaml}
72  ///< {key1: val1, key2: val2}
73  ///< @endcode
74  ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
75  FLOW_ML1 = b_(17), ///< mark container with multi-line flow style, 1 element per line
76  ///< - seqs as
77  ///< @code{yaml}
78  ///< [
79  ///< val1,
80  ///< val2
81  ///< ]
82  ///< @endcode
83  ///< - maps as
84  ///< @code{yaml}
85  ///< {
86  ///< key: val,
87  ///< key2: val2
88  ///< }
89  ///< @endcode
90  FLOW_MLN = b_(18), ///< mark container with multi-line flow style, n elements per line,
91  ///< wrapped (as set by @ref EmitOptions::max_cols()):
92  ///< - seqs as
93  ///< @code{yaml}
94  ///< [
95  ///< val,val,...
96  ///< val,val,...
97  ///< val,val,...
98  ///< ...
99  ///< val
100  ///< ]
101  ///< @endcode
102  ///< when @ref FLOW_SPC is not set, or
103  ///< @code{yaml}
104  ///< [
105  ///< val, val,...
106  ///< val, val,...
107  ///< val, val,...
108  ///< ...
109  ///< val
110  ///< ]
111  ///< @endcode
112  ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
113  ///< - maps as
114  ///< @code{yaml}
115  ///< {
116  ///< key: val,key: val,...
117  ///< key: val,key: val,...
118  ///< ...
119  ///< key: val
120  ///< }
121  ///< @endcode
122  ///< when @ref FLOW_SPC is not set, or
123  ///< @code{yaml}
124  ///< {
125  ///< key: val, key: val,...
126  ///< key: val, key: val,...
127  ///< ...
128  ///< key: val
129  ///< }
130  ///< @endcode
131  ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
132  FLOW_SPC = b_(19), ///< mark container with spaces after comma when in flow mode.
133  ///< Applies to both @ref FLOW_SL and @ref FLOW_MLN (but not
134  ///< to @ref FLOW_ML1), and can be overriden globally by
135  ///< @ref EmitOptions::force_flow_spc().
136  BLOCK = b_(20), ///< mark container with block style
137  ///< - seqs as
138  ///< @code{yaml}
139  ///< - val1
140  ///< - val2
141  ///< @endcode
142  ///< - maps as
143  ///< @code{yaml}
144  ///< key1: val1
145  ///< key2: val2
146  ///< @endcode
147  KEY_LITERAL = b_(21), ///< mark key scalar as multiline, block literal |
148  VAL_LITERAL = b_(22), ///< mark val scalar as multiline, block literal |
149  KEY_FOLDED = b_(23), ///< mark key scalar as multiline, block folded >
150  VAL_FOLDED = b_(24), ///< mark val scalar as multiline, block folded >
151  KEY_SQUO = b_(25), ///< mark key scalar as single quoted '
152  VAL_SQUO = b_(26), ///< mark val scalar as single quoted '
153  KEY_DQUO = b_(27), ///< mark key scalar as double quoted "
154  VAL_DQUO = b_(28), ///< mark val scalar as double quoted "
155  KEY_PLAIN = b_(29), ///< mark key scalar as plain scalar (unquoted, even when multiline)
156  VAL_PLAIN = b_(30), ///< mark val scalar as plain scalar (unquoted, even when multiline)
157  //
158  // type combination masks:
159  //
160  KEYVAL = KEY|VAL, ///< mask of @ref KEY|@ref VAL
161  KEYSEQ = KEY|SEQ, ///< mask of @ref KEY|@ref SEQ
162  KEYMAP = KEY|MAP, ///< mask of @ref KEY|@ref MAP
163  DOCMAP = DOC|MAP, ///< mask of @ref DOC|@ref MAP
164  DOCSEQ = DOC|SEQ, ///< mask of @ref DOC|@ref SEQ
165  DOCVAL = DOC|VAL, ///< mask of @ref DOC|@ref VAL
166  //
167  // style combination masks:
168  //
169  SCALAR_LITERAL = KEY_LITERAL|VAL_LITERAL, ///< mask of @ref KEY_LITERAL|@ref VAL_LITERAL,
170  SCALAR_FOLDED = KEY_FOLDED|VAL_FOLDED, ///< mask of @ref KEY_FOLDED|@ref VAL_FOLDED,
171  SCALAR_SQUO = KEY_SQUO|VAL_SQUO, ///< mask of @ref KEY_SQUO|@ref VAL_SQUO,
172  SCALAR_DQUO = KEY_DQUO|VAL_DQUO, ///< mask of @ref KEY_DQUO|@ref VAL_DQUO,
173  SCALAR_PLAIN = KEY_PLAIN|VAL_PLAIN, ///< mask of @ref KEY_PLAIN|@ref VAL_PLAIN,
174  KEYQUO = KEY_SQUO|KEY_DQUO|KEY_FOLDED|KEY_LITERAL, ///< key style is one of `'">|`. mask of @ref KEY_SQUO|@ref KEY_DQUO|@ref KEY_FOLDED|@ref KEY_LITERAL
175  VALQUO = VAL_SQUO|VAL_DQUO|VAL_FOLDED|VAL_LITERAL, ///< val style is one of `'">|`. mask of @ref VAL_SQUO|@ref VAL_DQUO|@ref VAL_FOLDED|@ref VAL_LITERAL
176  KEY_STYLE = KEYQUO|KEY_PLAIN, ///< mask of @ref KEYQUO|@ref KEY_PLAIN : all the key scalar styles for key (not container styles!)
177  VAL_STYLE = VALQUO|VAL_PLAIN, ///< mask of @ref VALQUO|@ref VAL_PLAIN : all the val scalar styles for val (not container styles!)
178  SCALAR_STYLE = KEY_STYLE|VAL_STYLE, ///< mask of @ref KEY_STYLE|@ref VAL_STYLE : all the key+val scalar styles
179  FLOW_MLX = FLOW_ML1|FLOW_MLN, ///< mask of @ref FLOW_ML1|@ref FLOW_MLN : all the flow multiline styles
180  CONTAINER_STYLE_FLOW = FLOW_SL|FLOW_MLX|FLOW_SPC, ///< mask of @ref FLOW_SL|@ref FLOW_MLX|@ref FLOW_SPC : all flow flags
181  CONTAINER_STYLE_BLOCK = BLOCK, ///< alias to @ref BLOCK
182  CONTAINER_STYLE = CONTAINER_STYLE_FLOW|CONTAINER_STYLE_BLOCK, ///< mask of @ref CONTAINER_STYLE_FLOW|@ref CONTAINER_STYLE_BLOCK : all container style flags
183  STYLE = SCALAR_STYLE | CONTAINER_STYLE, ///< mask of @ref SCALAR_STYLE | @ref CONTAINER_STYLE : all style flags
184  //
185  // mixed masks
186  /** @cond dev */
187  KEYMASK_ = KEY | KEYQUO | KEYANCH | KEYREF | KEYTAG,
188  VALMASK_ = VAL | VALQUO | VALANCH | VALREF | VALTAG,
189  #undef b_
190  #ifdef RYML_HAS_DEPRECATED_ENUMS_
191  FLOW_ML RYML_DEPRECATED("use one of FLOW_ML{1,N,X}") = FLOW_ML1,
192  #endif
193  /** @endcond */
194 } NodeTypeBits;
195 
196 /** @cond dev */
197 using NodeType_e RYML_DEPRECATED("use NodeTypeBits") = NodeTypeBits;
198 #ifndef RYML_HAS_DEPRECATED_ENUMS_
199 // defined here because the current c++ standard / compiler cannot
200 // handle deprecated enums
201 RYML_DEPRECATED("use one of FLOW_ML{1,N,X}")
202 constexpr const type_bits FLOW_ML = FLOW_ML1;
203 #endif
204 /** @endcond */
205 
206 
207 //-----------------------------------------------------------------------------
208 //-----------------------------------------------------------------------------
209 //-----------------------------------------------------------------------------
210 
211 /** Wraps a @ref type_bits mask of @ref NodeTypeBits flags with some
212  * syntactic sugar and predicates. */
214 {
215 public:
216 
218 
219 public:
220 
221  /** @name auto convert to type_bits
222  * @{ */
223 
224  C4_ALWAYS_INLINE operator type_bits & () noexcept { return m_bits; }
225  C4_ALWAYS_INLINE operator type_bits const& () const noexcept { return m_bits; }
226 
227  /** @} */
228 
229 public:
230 
231  /** @name ctor
232  * @{ */
233 
234  C4_ALWAYS_INLINE NodeType() noexcept : m_bits(NOTYPE) {}
235  C4_ALWAYS_INLINE NodeType(type_bits t) noexcept : m_bits(t) {}
236 
237  /** @} */
238 
239 public:
240 
241  /** @name query / set
242  * @{ */
243 
244  C4_ALWAYS_INLINE bool has_any(type_bits t) const noexcept { return (m_bits & t) != 0u; }
245  C4_ALWAYS_INLINE bool has_all(type_bits t) const noexcept { return (m_bits & t) == t; }
246  C4_ALWAYS_INLINE bool has_none(type_bits t) const noexcept { return (m_bits & t) == 0; }
247 
248  C4_ALWAYS_INLINE void set(type_bits t) noexcept { m_bits = t; }
249  C4_ALWAYS_INLINE void add(type_bits t) noexcept { m_bits |= t; }
250  C4_ALWAYS_INLINE void rem(type_bits t) noexcept { m_bits &= ~t; }
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; }
252 
253  C4_ALWAYS_INLINE void clear() noexcept { m_bits = NOTYPE; }
254 
255  /** @} */
256 
257 public:
258 
259  /** @name convert to string
260  * @{ */
261 
262  /** return a preset string based on the node type */
263  C4_ALWAYS_INLINE const char *type_str() const noexcept { return type_str(m_bits); }
264  /** return a preset string based on the node type */
265  static const char* type_str(type_bits t) noexcept;
266 
267  /** fill a string with the node type flags. */
268  C4_ALWAYS_INLINE size_t type_str(substr buf) const noexcept { return type_str(buf, m_bits); }
269  /** fill a string with the node type flags. */
270  static size_t type_str(substr buf, type_bits t) noexcept;
271 
272  /** fill a string with the node type flags. If the string is small, returns {null, len} */
273  C4_ALWAYS_INLINE csubstr type_str_sub(substr buf) const noexcept { return type_str_sub(buf, m_bits); }
274  /** fill a string with the node type flags. If the string is small, returns {null, len} */
275  static csubstr type_str_sub(substr buf, type_bits t) noexcept
276  {
277  csubstr ret;
278  ret.len = type_str(buf, t);
279  ret.str = ret.len < buf.len ? buf.str : nullptr;
280  return ret;
281  }
282 
283  /** @} */
284 
285 public:
286 
287  /** @name node type predicates
288  * @{ */
289 
290  C4_ALWAYS_INLINE bool is_notype() const noexcept { return m_bits == NOTYPE; }
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; }
293  C4_ALWAYS_INLINE bool is_container() const noexcept { return (m_bits & (MAP|SEQ|STREAM)) != 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; }
298  C4_ALWAYS_INLINE bool is_val() const noexcept { return (m_bits & KEYVAL) == VAL; }
299  C4_ALWAYS_INLINE bool is_keyval() const noexcept { return (m_bits & KEYVAL) == KEYVAL; }
300  C4_ALWAYS_INLINE bool key_is_null() const noexcept { return (m_bits & KEYNIL) != 0; }
301  C4_ALWAYS_INLINE bool val_is_null() const noexcept { return (m_bits & VALNIL) != 0; }
302  C4_ALWAYS_INLINE bool has_key_tag() const noexcept { return (m_bits & KEYTAG) != 0; }
303  C4_ALWAYS_INLINE bool has_val_tag() const noexcept { return (m_bits & VALTAG) != 0; }
304  C4_ALWAYS_INLINE bool has_key_anchor() const noexcept { return (m_bits & KEYANCH) != 0; }
305  C4_ALWAYS_INLINE bool has_val_anchor() const noexcept { return (m_bits & VALANCH) != 0; }
306  C4_ALWAYS_INLINE bool has_anchor() const noexcept { return (m_bits & (KEYANCH|VALANCH)) != 0; }
307  C4_ALWAYS_INLINE bool is_key_ref() const noexcept { return (m_bits & KEYREF) != 0; }
308  C4_ALWAYS_INLINE bool is_val_ref() const noexcept { return (m_bits & VALREF) != 0; }
309  C4_ALWAYS_INLINE bool is_ref() const noexcept { return (m_bits & (KEYREF|VALREF)) != 0; }
310 
311  C4_ALWAYS_INLINE bool is_key_unfiltered() const noexcept { return (m_bits & (KEY_UNFILT)) != 0; }
312  C4_ALWAYS_INLINE bool is_val_unfiltered() const noexcept { return (m_bits & (VAL_UNFILT)) != 0; }
313 
314  /** @} */
315 
316 public:
317 
318  /** @name node style predicates
319  * @{ */
320 
321  C4_ALWAYS_INLINE bool is_container_styled() const noexcept { return (m_bits & (CONTAINER_STYLE)) != 0; }
322  C4_ALWAYS_INLINE bool is_block() const noexcept { return (m_bits & (BLOCK)) != 0; }
323  C4_ALWAYS_INLINE bool is_flow_sl() const noexcept { return (m_bits & (FLOW_SL)) != 0; }
324  C4_ALWAYS_INLINE bool is_flow_ml1() const noexcept { return (m_bits & (FLOW_ML1)) != 0; }
325  C4_ALWAYS_INLINE bool is_flow_mln() const noexcept { return (m_bits & (FLOW_MLN)) != 0; }
326  C4_ALWAYS_INLINE bool is_flow_mlx() const noexcept { return (m_bits & (FLOW_ML1|FLOW_MLN)) != 0; }
327  C4_ALWAYS_INLINE bool is_flow() const noexcept { return (m_bits & (FLOW_ML1|FLOW_MLN|FLOW_SL)) != 0; }
328  C4_ALWAYS_INLINE bool has_flow_space() const noexcept { return (m_bits & (FLOW_SPC)) != 0; }
329 
330  C4_ALWAYS_INLINE bool is_key_styled() const noexcept { return (m_bits & (KEY_STYLE)) != 0; }
331  C4_ALWAYS_INLINE bool is_val_styled() const noexcept { return (m_bits & (VAL_STYLE)) != 0; }
332  C4_ALWAYS_INLINE bool is_key_literal() const noexcept { return (m_bits & (KEY_LITERAL)) != 0; }
333  C4_ALWAYS_INLINE bool is_val_literal() const noexcept { return (m_bits & (VAL_LITERAL)) != 0; }
334  C4_ALWAYS_INLINE bool is_key_folded() const noexcept { return (m_bits & (KEY_FOLDED)) != 0; }
335  C4_ALWAYS_INLINE bool is_val_folded() const noexcept { return (m_bits & (VAL_FOLDED)) != 0; }
336  C4_ALWAYS_INLINE bool is_key_squo() const noexcept { return (m_bits & (KEY_SQUO)) != 0; }
337  C4_ALWAYS_INLINE bool is_val_squo() const noexcept { return (m_bits & (VAL_SQUO)) != 0; }
338  C4_ALWAYS_INLINE bool is_key_dquo() const noexcept { return (m_bits & (KEY_DQUO)) != 0; }
339  C4_ALWAYS_INLINE bool is_val_dquo() const noexcept { return (m_bits & (VAL_DQUO)) != 0; }
340  C4_ALWAYS_INLINE bool is_key_plain() const noexcept { return (m_bits & (KEY_PLAIN)) != 0; }
341  C4_ALWAYS_INLINE bool is_val_plain() const noexcept { return (m_bits & (VAL_PLAIN)) != 0; }
342  C4_ALWAYS_INLINE bool is_key_quoted() const noexcept { return (m_bits & KEYQUO) != 0; }
343  C4_ALWAYS_INLINE bool is_val_quoted() const noexcept { return (m_bits & VALQUO) != 0; }
344  C4_ALWAYS_INLINE bool is_quoted() const noexcept { return (m_bits & (KEYQUO|VALQUO)) != 0; }
345 
346  C4_ALWAYS_INLINE NodeType key_style() const noexcept { return (m_bits & (KEY_STYLE)); }
347  C4_ALWAYS_INLINE NodeType val_style() const noexcept { return (m_bits & (VAL_STYLE)); }
348 
349  C4_ALWAYS_INLINE void set_container_style(type_bits style) noexcept { m_bits = ((style & CONTAINER_STYLE) | (m_bits & ~CONTAINER_STYLE)); }
350  C4_ALWAYS_INLINE void set_key_style(type_bits style) noexcept { m_bits = ((style & KEY_STYLE) | (m_bits & ~KEY_STYLE)); }
351  C4_ALWAYS_INLINE void set_val_style(type_bits style) noexcept { m_bits = ((style & VAL_STYLE) | (m_bits & ~VAL_STYLE)); }
352  C4_ALWAYS_INLINE void clear_style() noexcept { m_bits &= ~STYLE; }
353 
354  /** @} */
355 
356 public: // deprecated methods
357 
358  /** @cond dev */ // LCOV_EXCL_START
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; }
364  /** @endcond */ // LCOV_EXCL_STOP
365 };
366 
367 /** @} */
368 
369 } // namespace yml
370 } // namespace c4
371 
372 // NOLINTEND(modernize-avoid-c-style-cast)
373 C4_SUPPRESS_WARNING_MSVC_POP
374 C4_SUPPRESS_WARNING_GCC_CLANG_POP
375 
376 #endif /* C4_YML_NODE_TYPE_HPP_ */
const char * type_str() const noexcept
return a preset string based on the node type
Definition: node_type.hpp:263
mark val scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:156
bool is_ref() const noexcept
Definition: node_type.hpp:309
the val has an &anchor
Definition: node_type.hpp:42
the key has a tag
Definition: node_type.hpp:43
the val scalar was left unfiltered; the parser was set not to filter.
Definition: node_type.hpp:52
mark key scalar as double quoted "
Definition: node_type.hpp:153
#define b_(v)
Definition: node_type.hpp:31
void add(type_bits t) noexcept
Definition: node_type.hpp:249
bool is_doc() const noexcept
Definition: node_type.hpp:292
bool key_is_null() const noexcept
Definition: node_type.hpp:300
bool is_val_literal() const noexcept
Definition: node_type.hpp:333
static csubstr type_str_sub(substr buf, type_bits t) noexcept
fill a string with the node type flags.
Definition: node_type.hpp:275
mark key scalar as multiline, block literal |
Definition: node_type.hpp:147
bool is_flow_sl() const noexcept
Definition: node_type.hpp:323
mark val scalar as single quoted '
Definition: node_type.hpp:152
void addrem(type_bits bits_to_add, type_bits bits_to_remove) noexcept
Definition: node_type.hpp:251
the key scalar was left unfiltered; the parser was set not to filter.
Definition: node_type.hpp:51
val style is one of `'">|`. mask of VAL_SQUO|VAL_DQUO|VAL_FOLDED|VAL_LITERAL
Definition: node_type.hpp:175
NodeType(type_bits t) noexcept
Definition: node_type.hpp:235
bool is_val() const noexcept
Definition: node_type.hpp:298
bool is_flow_mln() const noexcept
Definition: node_type.hpp:325
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
bool has_val_anchor() const noexcept
Definition: node_type.hpp:305
the val has a tag
Definition: node_type.hpp:44
mask of CONTAINER_STYLE_FLOW|CONTAINER_STYLE_BLOCK : all container style flags
Definition: node_type.hpp:182
mark val scalar as double quoted "
Definition: node_type.hpp:154
bool is_val_ref() const noexcept
Definition: node_type.hpp:308
bool is_key_literal() const noexcept
Definition: node_type.hpp:332
bool is_map() const noexcept
Definition: node_type.hpp:294
bool is_block() const noexcept
Definition: node_type.hpp:322
mask of KEY_FOLDED|VAL_FOLDED,
Definition: node_type.hpp:170
bool is_val_styled() const noexcept
Definition: node_type.hpp:331
a document
Definition: node_type.hpp:37
bool is_val_unfiltered() const noexcept
Definition: node_type.hpp:312
bool is_stream() const noexcept
Definition: node_type.hpp:291
mask of DOC|VAL
Definition: node_type.hpp:165
mark container with multi-line flow style, n elements per line, < wrapped (as set by EmitOptions::max...
Definition: node_type.hpp:90
the key is null (eg { : b} results in a null key)
Definition: node_type.hpp:45
mask of KEY|VAL
Definition: node_type.hpp:160
void set_container_style(type_bits style) noexcept
Definition: node_type.hpp:349
key style is one of `'">|`. mask of KEY_SQUO|KEY_DQUO|KEY_FOLDED|KEY_LITERAL
Definition: node_type.hpp:174
bool has_all(type_bits t) const noexcept
Definition: node_type.hpp:245
mask of KEY_STYLE|VAL_STYLE : all the key+val scalar styles
Definition: node_type.hpp:178
mask of KEY_SQUO|VAL_SQUO,
Definition: node_type.hpp:171
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...
Definition: node_type.hpp:34
bool is_val_quoted() const noexcept
Definition: node_type.hpp:343
the key has an &anchor
Definition: node_type.hpp:41
bool has_val() const noexcept
Definition: node_type.hpp:297
bool is_seq() const noexcept
Definition: node_type.hpp:295
bool is_key_plain() const noexcept
Definition: node_type.hpp:340
mask of KEY|SEQ
Definition: node_type.hpp:161
bool has_flow_space() const noexcept
Definition: node_type.hpp:328
bool is_notype() const noexcept
Definition: node_type.hpp:290
mark val scalar as multiline, block folded >
Definition: node_type.hpp:150
mark key scalar as multiline, block folded >
Definition: node_type.hpp:149
all the bits up to here
Definition: node_type.hpp:47
bool is_keyval() const noexcept
Definition: node_type.hpp:299
size_t type_str(substr buf) const noexcept
fill a string with the node type flags.
Definition: node_type.hpp:268
bool is_key_dquo() const noexcept
Definition: node_type.hpp:338
bool is_val_plain() const noexcept
Definition: node_type.hpp:341
NodeType() noexcept
Definition: node_type.hpp:234
mask of KEY_PLAIN|VAL_PLAIN,
Definition: node_type.hpp:173
mask of DOC|MAP
Definition: node_type.hpp:163
bool is_key_styled() const noexcept
Definition: node_type.hpp:330
bool is_key_folded() const noexcept
Definition: node_type.hpp:334
the val is null (eg {a : } results in a null val)
Definition: node_type.hpp:46
a *reference: the val references an &anchor
Definition: node_type.hpp:40
mark container with block style < - seqs as <
Definition: node_type.hpp:136
bool is_quoted() const noexcept
Definition: node_type.hpp:344
mask of DOC|SEQ
Definition: node_type.hpp:164
the scalar to the left of : in a map's member
Definition: node_type.hpp:33
a *reference: the key references an &anchor
Definition: node_type.hpp:39
mask of KEYQUO|KEY_PLAIN : all the key scalar styles for key (not container styles!) ...
Definition: node_type.hpp:176
bool is_flow() const noexcept
Definition: node_type.hpp:327
void set(type_bits t) noexcept
Definition: node_type.hpp:248
no node type or style is set
Definition: node_type.hpp:32
a stream: a seq of docs
Definition: node_type.hpp:38
size_t len
the length of the substring
Definition: substr.hpp:218
bool is_flow_mlx() const noexcept
Definition: node_type.hpp:326
bool has_val_tag() const noexcept
Definition: node_type.hpp:303
bool is_key_quoted() const noexcept
Definition: node_type.hpp:342
void clear_style() noexcept
Definition: node_type.hpp:352
mark container with spaces after comma when in flow mode. < Applies to both FLOW_SL and FLOW_MLN (but...
Definition: node_type.hpp:132
bool is_val_folded() const noexcept
Definition: node_type.hpp:335
mark key scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:155
bool has_key() const noexcept
Definition: node_type.hpp:296
mask of FLOW_SL|FLOW_MLX|FLOW_SPC : all flow flags
Definition: node_type.hpp:180
NodeType val_style() const noexcept
Definition: node_type.hpp:347
bool is_val_squo() const noexcept
Definition: node_type.hpp:337
csubstr type_str_sub(substr buf) const noexcept
fill a string with the node type flags.
Definition: node_type.hpp:273
NodeType key_style() const noexcept
Definition: node_type.hpp:346
bool is_container_styled() const noexcept
Definition: node_type.hpp:321
bool has_key_anchor() const noexcept
Definition: node_type.hpp:304
mask of FLOW_ML1|FLOW_MLN : all the flow multiline styles
Definition: node_type.hpp:179
mask of KEY_DQUO|VAL_DQUO,
Definition: node_type.hpp:172
mark val scalar as multiline, block literal |
Definition: node_type.hpp:148
bool has_key_tag() const noexcept
Definition: node_type.hpp:302
bool has_anchor() const noexcept
Definition: node_type.hpp:306
uint32_t type_bits
the integral type necessary to cover all the bits for NodeType_e
Definition: node_type.hpp:26
void set_val_style(type_bits style) noexcept
Definition: node_type.hpp:351
bool is_key_unfiltered() const noexcept
Definition: node_type.hpp:311
bool has_any(type_bits t) const noexcept
Definition: node_type.hpp:244
void rem(type_bits t) noexcept
Definition: node_type.hpp:250
bool is_flow_ml1() const noexcept
Definition: node_type.hpp:324
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
Definition: node_type.hpp:35
NodeTypeBits
a bit mask for marking node types and styles
Definition: node_type.hpp:30
bool is_val_dquo() const noexcept
Definition: node_type.hpp:339
type_bits m_bits
Definition: node_type.hpp:217
bool is_container() const noexcept
Definition: node_type.hpp:293
#define RYML_EXPORT
Definition: export.hpp:18
Wraps a type_bits mask of NodeTypeBits flags with some syntactic sugar and predicates.
Definition: node_type.hpp:213
mark key scalar as single quoted '
Definition: node_type.hpp:151
bool has_none(type_bits t) const noexcept
Definition: node_type.hpp:246
mark container with multi-line flow style, 1 element per line < - seqs as <
Definition: node_type.hpp:75
bool is_key_ref() const noexcept
Definition: node_type.hpp:307
mask of VALQUO|VAL_PLAIN : all the val scalar styles for val (not container styles!) ...
Definition: node_type.hpp:177
mask of SCALAR_STYLE | CONTAINER_STYLE : all style flags
Definition: node_type.hpp:183
mask of KEY|MAP
Definition: node_type.hpp:162
mask of KEY_LITERAL|VAL_LITERAL,
Definition: node_type.hpp:169
a seq: a parent of VAL/SEQ/MAP nodes
Definition: node_type.hpp:36
void clear() noexcept
Definition: node_type.hpp:253
bool is_key_squo() const noexcept
Definition: node_type.hpp:336
void set_key_style(type_bits style) noexcept
Definition: node_type.hpp:350
mark container with single-line flow style < - seqs as <
Definition: node_type.hpp:56
bool val_is_null() const noexcept
Definition: node_type.hpp:301