rapidyaml  0.13.0
parse and emit YAML, and do it fast
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 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
27 
28 
29 /** the integral type necessary to cover all the bits for NodeType_e */
30 using type_bits = uint32_t;
31 
32 
33 /** a bit mask for marking node types and styles */
34 typedef enum : type_bits { // NOLINT
35  #define __(v) (type_bits(1) << v) // a convenience define, undefined below // NOLINT
36  NOTYPE = 0, ///< no node type or style is set
37  KEY = __(0), ///< is member of a map
38  VAL = __(1), ///< a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or SEQ
39  MAP = __(2), ///< a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
40  SEQ = __(3), ///< a seq: a parent of VAL/SEQ/MAP nodes
41  DOC = __(4), ///< a document
42  STREAM = __(5)|SEQ, ///< a stream: a seq of docs
43  KEYREF = __(6), ///< a *reference: the key references an &anchor
44  VALREF = __(7), ///< a *reference: the val references an &anchor
45  KEYANCH = __(8), ///< the key has an &anchor
46  VALANCH = __(9), ///< the val has an &anchor
47  KEYTAG = __(10), ///< the key has a tag
48  VALTAG = __(11), ///< the val has a tag
49  KEYNIL = __(12), ///< the key is null (eg `{ : b}` results in a null key)
50  VALNIL = __(13), ///< the val is null (eg `{a : }` results in a null val)
51  _TYMASK = __(14)-1, ///< all the bits up to here
52  //
53  // unfiltered flags:
54  //
55  KEY_UNFILT = __(14), ///< the key scalar was left unfiltered; the parser was set not to filter. @see ParserOptions
56  VAL_UNFILT = __(15), ///< the val scalar was left unfiltered; the parser was set not to filter. @see ParserOptions
57  //
58  // style flags:
59  //
60  FLOW_SL = __(16), ///< mark container with single-line flow style (seqs as '[val1,val2], maps as '{key: val,key2: val2}')
61  FLOW_ML = __(17), ///< mark container with multi-line flow style (seqs as '[\n val1,\n val2\n], maps as '{\n key: val,\n key2: val2\n}')
62  BLOCK = __(18), ///< mark container with block style (seqs as '- val\n', maps as 'key: val')
63  KEY_LITERAL = __(19), ///< mark key scalar as multiline, block literal |
64  VAL_LITERAL = __(20), ///< mark val scalar as multiline, block literal |
65  KEY_FOLDED = __(21), ///< mark key scalar as multiline, block folded >
66  VAL_FOLDED = __(22), ///< mark val scalar as multiline, block folded >
67  KEY_SQUO = __(23), ///< mark key scalar as single quoted '
68  VAL_SQUO = __(24), ///< mark val scalar as single quoted '
69  KEY_DQUO = __(25), ///< mark key scalar as double quoted "
70  VAL_DQUO = __(26), ///< mark val scalar as double quoted "
71  KEY_PLAIN = __(27), ///< mark key scalar as plain scalar (unquoted, even when multiline)
72  VAL_PLAIN = __(28), ///< mark val scalar as plain scalar (unquoted, even when multiline)
73  //
74  // type combination masks:
75  //
82  //
83  // style combination masks:
84  //
90  KEYQUO = KEY_SQUO|KEY_DQUO|KEY_FOLDED|KEY_LITERAL, ///< key style is one of ', ", > or |
91  VALQUO = VAL_SQUO|VAL_DQUO|VAL_FOLDED|VAL_LITERAL, ///< val style is one of ', ", > or |
92  KEY_STYLE = KEY_LITERAL|KEY_FOLDED|KEY_SQUO|KEY_DQUO|KEY_PLAIN, ///< mask of all the scalar styles for key (not container styles!)
93  VAL_STYLE = VAL_LITERAL|VAL_FOLDED|VAL_SQUO|VAL_DQUO|VAL_PLAIN, ///< mask of all the scalar styles for val (not container styles!)
99  //
100  // mixed masks
103  #undef __
104 } NodeType_e;
105 
106 constexpr C4_ALWAYS_INLINE C4_CONST NodeType_e operator| (NodeType_e lhs, NodeType_e rhs) noexcept { return (NodeType_e)(((type_bits)lhs) | ((type_bits)rhs)); }
107 constexpr C4_ALWAYS_INLINE C4_CONST NodeType_e operator& (NodeType_e lhs, NodeType_e rhs) noexcept { return (NodeType_e)(((type_bits)lhs) & ((type_bits)rhs)); }
108 constexpr C4_ALWAYS_INLINE C4_CONST NodeType_e operator>> (NodeType_e bits, uint32_t n) noexcept { return (NodeType_e)(((type_bits)bits) >> n); }
109 constexpr C4_ALWAYS_INLINE C4_CONST NodeType_e operator<< (NodeType_e bits, uint32_t n) noexcept { return (NodeType_e)(((type_bits)bits) << n); }
110 constexpr C4_ALWAYS_INLINE C4_CONST NodeType_e operator~ (NodeType_e bits) noexcept { return (NodeType_e)(~(type_bits)bits); }
111 C4_ALWAYS_INLINE NodeType_e& operator&= (NodeType_e &subject, NodeType_e bits) noexcept { subject = (NodeType_e)((type_bits)subject & (type_bits)bits); return subject; }
112 C4_ALWAYS_INLINE NodeType_e& operator|= (NodeType_e &subject, NodeType_e bits) noexcept { subject = (NodeType_e)((type_bits)subject | (type_bits)bits); return subject; }
113 
114 
115 //-----------------------------------------------------------------------------
116 //-----------------------------------------------------------------------------
117 //-----------------------------------------------------------------------------
118 
119 /** wraps a NodeType_e element with some syntactic sugar and predicates */
121 {
122 public:
123 
125 
126 public:
127 
128  C4_ALWAYS_INLINE NodeType() noexcept : type(NOTYPE) {}
129  C4_ALWAYS_INLINE NodeType(NodeType_e t) noexcept : type(t) {}
130  C4_ALWAYS_INLINE NodeType(type_bits t) noexcept : type((NodeType_e)t) {}
131 
132  C4_ALWAYS_INLINE bool has_any(NodeType_e t) const noexcept { return (type & t) != 0u; }
133  C4_ALWAYS_INLINE bool has_all(NodeType_e t) const noexcept { return (type & t) == t; }
134  C4_ALWAYS_INLINE bool has_none(NodeType_e t) const noexcept { return (type & t) == 0; }
135 
136  C4_ALWAYS_INLINE void set(NodeType_e t) noexcept { type = t; }
137  C4_ALWAYS_INLINE void add(NodeType_e t) noexcept { type = (type|t); }
138  C4_ALWAYS_INLINE void rem(NodeType_e t) noexcept { type = (type & ~t); }
139  C4_ALWAYS_INLINE void addrem(NodeType_e bits_to_add, NodeType_e bits_to_remove) noexcept { type |= bits_to_add; type &= ~bits_to_remove; }
140 
141  C4_ALWAYS_INLINE void clear() noexcept { type = NOTYPE; }
142 
143 public:
144 
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; }
147 
148 public:
149 
150  /** @name node type queries
151  * @{ */
152 
153  /** return a preset string based on the node type */
154  C4_ALWAYS_INLINE const char *type_str() const noexcept { return type_str(type); }
155  /** return a preset string based on the node type */
156  static const char* type_str(NodeType_e t) noexcept;
157 
158  /** fill a string with the node type flags. */
159  C4_ALWAYS_INLINE size_t type_str(substr buf) const noexcept { return type_str(buf, type); }
160  /** fill a string with the node type flags. */
161  static size_t type_str(substr buf, NodeType_e t) noexcept;
162 
163  /** fill a string with the node type flags. If the string is small, returns {null, len} */
164  C4_ALWAYS_INLINE csubstr type_str_sub(substr buf) const noexcept { return type_str_sub(buf, type); }
165  /** fill a string with the node type flags. If the string is small, returns {null, len} */
166  static csubstr type_str_sub(substr buf, NodeType_e t) noexcept
167  {
168  csubstr ret;
169  ret.len = type_str(buf, t);
170  ret.str = ret.len < buf.len ? buf.str : nullptr;
171  return ret;
172  }
173 
174 public:
175 
176  /** @name node type queries
177  * @{ */
178 
179  C4_ALWAYS_INLINE bool is_notype() const noexcept { return type == NOTYPE; }
180  C4_ALWAYS_INLINE bool is_stream() const noexcept { return ((type & STREAM) == STREAM) != 0; }
181  C4_ALWAYS_INLINE bool is_doc() const noexcept { return (type & DOC) != 0; }
182  C4_ALWAYS_INLINE bool is_container() const noexcept { return (type & (MAP|SEQ|STREAM)) != 0; }
183  C4_ALWAYS_INLINE bool is_map() const noexcept { return (type & MAP) != 0; }
184  C4_ALWAYS_INLINE bool is_seq() const noexcept { return (type & SEQ) != 0; }
185  C4_ALWAYS_INLINE bool has_key() const noexcept { return (type & KEY) != 0; }
186  C4_ALWAYS_INLINE bool has_val() const noexcept { return (type & VAL) != 0; }
187  C4_ALWAYS_INLINE bool is_val() const noexcept { return (type & KEYVAL) == VAL; }
188  C4_ALWAYS_INLINE bool is_keyval() const noexcept { return (type & KEYVAL) == KEYVAL; }
189  C4_ALWAYS_INLINE bool key_is_null() const noexcept { return (type & KEYNIL) != 0; }
190  C4_ALWAYS_INLINE bool val_is_null() const noexcept { return (type & VALNIL) != 0; }
191  C4_ALWAYS_INLINE bool has_key_tag() const noexcept { return (type & KEYTAG) != 0; }
192  C4_ALWAYS_INLINE bool has_val_tag() const noexcept { return (type & VALTAG) != 0; }
193  C4_ALWAYS_INLINE bool has_key_anchor() const noexcept { return (type & KEYANCH) != 0; }
194  C4_ALWAYS_INLINE bool has_val_anchor() const noexcept { return (type & VALANCH) != 0; }
195  C4_ALWAYS_INLINE bool has_anchor() const noexcept { return (type & (KEYANCH|VALANCH)) != 0; }
196  C4_ALWAYS_INLINE bool is_key_ref() const noexcept { return (type & KEYREF) != 0; }
197  C4_ALWAYS_INLINE bool is_val_ref() const noexcept { return (type & VALREF) != 0; }
198  C4_ALWAYS_INLINE bool is_ref() const noexcept { return (type & (KEYREF|VALREF)) != 0; }
199 
200  C4_ALWAYS_INLINE bool is_key_unfiltered() const noexcept { return (type & (KEY_UNFILT)) != 0; }
201  C4_ALWAYS_INLINE bool is_val_unfiltered() const noexcept { return (type & (VAL_UNFILT)) != 0; }
202 
203  RYML_DEPRECATED("use has_key_anchor()") bool is_key_anchor() const noexcept { return has_key_anchor(); }
204  RYML_DEPRECATED("use has_val_anchor()") bool is_val_anchor() const noexcept { return has_val_anchor(); }
205  RYML_DEPRECATED("use has_anchor()") bool is_anchor() const noexcept { return has_anchor(); }
206  RYML_DEPRECATED("use has_anchor() || is_ref()") bool is_anchor_or_ref() const noexcept { return has_anchor() || is_ref(); }
207  /** @} */
208 
209 public:
210 
211  /** @name style functions
212  * @{ */
213 
214  C4_ALWAYS_INLINE bool is_container_styled() const noexcept { return (type & (CONTAINER_STYLE)) != 0; }
215  C4_ALWAYS_INLINE bool is_block() const noexcept { return (type & (BLOCK)) != 0; }
216  C4_ALWAYS_INLINE bool is_flow_sl() const noexcept { return (type & (FLOW_SL)) != 0; }
217  C4_ALWAYS_INLINE bool is_flow_ml() const noexcept { return (type & (FLOW_ML)) != 0; }
218  C4_ALWAYS_INLINE bool is_flow() const noexcept { return (type & (FLOW_ML|FLOW_SL)) != 0; }
219 
220  C4_ALWAYS_INLINE bool is_key_styled() const noexcept { return (type & (KEY_STYLE)) != 0; }
221  C4_ALWAYS_INLINE bool is_val_styled() const noexcept { return (type & (VAL_STYLE)) != 0; }
222  C4_ALWAYS_INLINE bool is_key_literal() const noexcept { return (type & (KEY_LITERAL)) != 0; }
223  C4_ALWAYS_INLINE bool is_val_literal() const noexcept { return (type & (VAL_LITERAL)) != 0; }
224  C4_ALWAYS_INLINE bool is_key_folded() const noexcept { return (type & (KEY_FOLDED)) != 0; }
225  C4_ALWAYS_INLINE bool is_val_folded() const noexcept { return (type & (VAL_FOLDED)) != 0; }
226  C4_ALWAYS_INLINE bool is_key_squo() const noexcept { return (type & (KEY_SQUO)) != 0; }
227  C4_ALWAYS_INLINE bool is_val_squo() const noexcept { return (type & (VAL_SQUO)) != 0; }
228  C4_ALWAYS_INLINE bool is_key_dquo() const noexcept { return (type & (KEY_DQUO)) != 0; }
229  C4_ALWAYS_INLINE bool is_val_dquo() const noexcept { return (type & (VAL_DQUO)) != 0; }
230  C4_ALWAYS_INLINE bool is_key_plain() const noexcept { return (type & (KEY_PLAIN)) != 0; }
231  C4_ALWAYS_INLINE bool is_val_plain() const noexcept { return (type & (VAL_PLAIN)) != 0; }
232  C4_ALWAYS_INLINE bool is_key_quoted() const noexcept { return (type & KEYQUO) != 0; }
233  C4_ALWAYS_INLINE bool is_val_quoted() const noexcept { return (type & VALQUO) != 0; }
234  C4_ALWAYS_INLINE bool is_quoted() const noexcept { return (type & (KEYQUO|VALQUO)) != 0; }
235 
236  C4_ALWAYS_INLINE NodeType key_style() const noexcept { return (type & (KEY_STYLE)); }
237  C4_ALWAYS_INLINE NodeType val_style() const noexcept { return (type & (VAL_STYLE)); }
238 
239  C4_ALWAYS_INLINE void set_container_style(NodeType_e style) noexcept { type = ((style & CONTAINER_STYLE) | (type & ~CONTAINER_STYLE)); }
240  C4_ALWAYS_INLINE void set_key_style(NodeType_e style) noexcept { type = ((style & KEY_STYLE) | (type & ~KEY_STYLE)); }
241  C4_ALWAYS_INLINE void set_val_style(NodeType_e style) noexcept { type = ((style & VAL_STYLE) | (type & ~VAL_STYLE)); }
242  C4_ALWAYS_INLINE void clear_style() noexcept { type &= ~STYLE; }
243 
244  /** @} */
245 
246 };
247 
248 
249 //-----------------------------------------------------------------------------
250 //-----------------------------------------------------------------------------
251 //-----------------------------------------------------------------------------
252 
253 /** @name scalar style helpers
254  * @{ */
255 
256 /** choose a YAML scalar style based on the scalar's contents, while
257  * in flow mode. Plain scalars [have more constraints in flow mode
258  * than in block
259  * mode](https://www.yaml.info/learn/quote.html#noplain). @ref
260  * scalar_style_choose_block() is the block mode analogous
261  * function. */
262 RYML_EXPORT NodeType_e scalar_style_choose_flow(csubstr scalar) noexcept;
263 /** choose a YAML scalar style based on the scalar's contents, while
264  * in block mode. Plain scalars [have more constraints in flow mode
265  * than in block
266  * mode](https://www.yaml.info/learn/quote.html#noplain). @ref
267  * scalar_style_choose_block() is the flow mode analogous function. */
268 RYML_EXPORT NodeType_e scalar_style_choose_block(csubstr scalar) noexcept;
269 /** choose a YAML emitting style based on the scalar's
270  * contents. Legacy compatibility function: assumes flow mode which is
271  * more constraining, and delegates to either @ref
272  * scalar_style_choose_flow() or @ref scalar_style_choose_block(). */
273 inline NodeType_e scalar_style_choose(csubstr s, bool flow=true) noexcept
274 {
276 }
277 
278 
279 /** choose a json scalar style based on the scalar's contents */
280 RYML_EXPORT NodeType_e scalar_style_choose_json(csubstr scalar) noexcept;
281 /** @cond dev */
282 // LCOV_EXCL_START
283 RYML_DEPRECATED("use scalar_style_choose_json()")
284 inline NodeType_e scalar_style_json_choose(csubstr scalar) noexcept
285 {
286  return scalar_style_choose_json(scalar);
287 }
288 // LCOV_EXCL_STOP
289 /** @endcond */
290 
291 
292 /** query whether a scalar can be encoded using single quotes.
293  * It may not be possible, notably when there is leading
294  * whitespace after a newline. */
295 RYML_EXPORT bool scalar_style_query_squo(csubstr s) noexcept;
296 
297 /** query whether a scalar can be encoded using plain style while in
298  * flow mode. Plain scalars [have more constraints in flow mode than
299  * in block
300  * mode](https://www.yaml.info/learn/quote.html#noplain). @ref
301  * scalar_style_query_plain_block() is the block mode analogous function.*/
302 RYML_EXPORT bool scalar_style_query_plain_flow(csubstr s) noexcept;
303 /** query whether a scalar can be encoded using plain style while in
304  * block mode. Plain scalars [have more constraints in flow mode than
305  * in block
306  * mode](https://www.yaml.info/learn/quote.html#noplain). @ref
307  * scalar_style_query_plain_flow() is the flow mode analogous function.*/
308 RYML_EXPORT bool scalar_style_query_plain_block(csubstr s) noexcept;
309 /** query whether a scalar can be encoded using plain style. Legacy
310  * compatibility function: assumes flow mode which is more
311  * constraining, and delegates to either @ref
312  * scalar_style_query_plain_flow() or @ref
313  * scalar_style_query_plain_block(). */
314 inline bool scalar_style_query_plain(csubstr s, bool flow=true) noexcept
315 {
317 }
318 
319 /** YAML-sense query of nullity. returns true if the scalar points
320  * to `nullptr` or is otherwise equal to one of the strings
321  * `"~"`,`"null"`,`"Null"`,`"NULL"` */
322 RYML_EXPORT bool scalar_is_null(csubstr s) noexcept;
323 
324 /** @} */
325 
326 /** @} */
327 
328 } // namespace yml
329 } // namespace c4
330 
331 // NOLINTEND(modernize-avoid-c-style-cast)
332 C4_SUPPRESS_WARNING_MSVC_POP
333 C4_SUPPRESS_WARNING_GCC_CLANG_POP
334 
335 #endif /* _C4_YML_NODE_TYPE_HPP_ */
Common utilities and infrastructure used by ryml.
#define RYML_EXPORT
Definition: export.hpp:18
OStream & operator<<(OStream &s, Tree const &t)
emit YAML to an STL-like ostream
Definition: emit.hpp:521
constexpr C4_CONST NodeType_e operator&(NodeType_e lhs, NodeType_e rhs) noexcept
Definition: node_type.hpp:107
bool scalar_style_query_plain_block(csubstr s) noexcept
query whether a scalar can be encoded using plain style while in block mode.
Definition: node_type.cpp:219
constexpr C4_CONST NodeType_e operator|(NodeType_e lhs, NodeType_e rhs) noexcept
Definition: node_type.hpp:106
bool scalar_is_null(csubstr s) noexcept
YAML-sense query of nullity.
Definition: node_type.cpp:289
NodeType_e & operator|=(NodeType_e &subject, NodeType_e bits) noexcept
Definition: node_type.hpp:112
constexpr C4_CONST NodeType_e operator>>(NodeType_e bits, uint32_t n) noexcept
Definition: node_type.hpp:108
bool scalar_style_query_squo(csubstr s) noexcept
query whether a scalar can be encoded using single quotes.
Definition: node_type.cpp:138
NodeType_e scalar_style_choose(csubstr s, bool flow=true) noexcept
choose a YAML emitting style based on the scalar's contents.
Definition: node_type.hpp:273
NodeType_e scalar_style_choose_flow(csubstr s) noexcept
choose a YAML scalar style based on the scalar's contents, while in flow mode.
Definition: node_type.cpp:262
uint32_t type_bits
the integral type necessary to cover all the bits for NodeType_e
Definition: node_type.hpp:30
NodeType_e scalar_style_choose_block(csubstr s) noexcept
choose a YAML scalar style based on the scalar's contents, while in block mode.
Definition: node_type.cpp:275
bool scalar_style_query_plain_flow(csubstr s) noexcept
query whether a scalar can be encoded using plain style while in flow mode.
Definition: node_type.cpp:171
NodeType_e & operator&=(NodeType_e &subject, NodeType_e bits) noexcept
Definition: node_type.hpp:111
constexpr C4_CONST NodeType_e operator~(NodeType_e bits) noexcept
Definition: node_type.hpp:110
NodeType_e
a bit mask for marking node types and styles
Definition: node_type.hpp:34
NodeType_e scalar_style_choose_json(csubstr s) noexcept
choose a json scalar style based on the scalar's contents
Definition: node_type.cpp:359
bool scalar_style_query_plain(csubstr s, bool flow=true) noexcept
query whether a scalar can be encoded using plain style.
Definition: node_type.hpp:314
@ VALANCH
the val has an &anchor
Definition: node_type.hpp:46
@ NOTYPE
no node type or style is set
Definition: node_type.hpp:36
@ SCALAR_FOLDED
Definition: node_type.hpp:86
@ KEY_DQUO
mark key scalar as double quoted "
Definition: node_type.hpp:69
@ VALREF
a *reference: the val references an &anchor
Definition: node_type.hpp:44
@ VALNIL
the val is null (eg {a : } results in a null val)
Definition: node_type.hpp:50
@ MAP
a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes
Definition: node_type.hpp:39
@ STREAM
a stream: a seq of docs
Definition: node_type.hpp:42
@ KEY
is member of a map
Definition: node_type.hpp:37
@ KEYQUO
key style is one of ', ", > or |
Definition: node_type.hpp:90
@ VAL_FOLDED
mark val scalar as multiline, block folded >
Definition: node_type.hpp:66
@ CONTAINER_STYLE_BLOCK
Definition: node_type.hpp:96
@ VAL_STYLE
mask of all the scalar styles for val (not container styles!)
Definition: node_type.hpp:93
@ KEYTAG
the key has a tag
Definition: node_type.hpp:47
@ CONTAINER_STYLE_FLOW
Definition: node_type.hpp:95
@ SCALAR_SQUO
Definition: node_type.hpp:87
@ FLOW_SL
mark container with single-line flow style (seqs as '[val1,val2], maps as '{key: val,...
Definition: node_type.hpp:60
@ FLOW_ML
mark container with multi-line flow style (seqs as '[ val1, val2 ], maps as '{ key: val,...
Definition: node_type.hpp:61
@ VAL_UNFILT
the val scalar was left unfiltered; the parser was set not to filter.
Definition: node_type.hpp:56
@ VAL
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:38
@ VALTAG
the val has a tag
Definition: node_type.hpp:48
@ SCALAR_STYLE
Definition: node_type.hpp:94
@ _TYMASK
all the bits up to here
Definition: node_type.hpp:51
@ SCALAR_LITERAL
Definition: node_type.hpp:85
@ SEQ
a seq: a parent of VAL/SEQ/MAP nodes
Definition: node_type.hpp:40
@ SCALAR_DQUO
Definition: node_type.hpp:88
@ VAL_SQUO
mark val scalar as single quoted '
Definition: node_type.hpp:68
@ KEY_STYLE
mask of all the scalar styles for key (not container styles!)
Definition: node_type.hpp:92
@ VAL_PLAIN
mark val scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:72
@ KEYREF
a *reference: the key references an &anchor
Definition: node_type.hpp:43
@ BLOCK
mark container with block style (seqs as '- val ', maps as 'key: val')
Definition: node_type.hpp:62
@ KEYANCH
the key has an &anchor
Definition: node_type.hpp:45
@ VALQUO
val style is one of ', ", > or |
Definition: node_type.hpp:91
@ VAL_DQUO
mark val scalar as double quoted "
Definition: node_type.hpp:70
@ CONTAINER_STYLE
Definition: node_type.hpp:97
@ KEY_UNFILT
the key scalar was left unfiltered; the parser was set not to filter.
Definition: node_type.hpp:55
@ KEY_SQUO
mark key scalar as single quoted '
Definition: node_type.hpp:67
@ VAL_LITERAL
mark val scalar as multiline, block literal |
Definition: node_type.hpp:64
@ KEY_LITERAL
mark key scalar as multiline, block literal |
Definition: node_type.hpp:63
@ KEY_PLAIN
mark key scalar as plain scalar (unquoted, even when multiline)
Definition: node_type.hpp:71
@ SCALAR_PLAIN
Definition: node_type.hpp:89
@ KEY_FOLDED
mark key scalar as multiline, block folded >
Definition: node_type.hpp:65
@ KEYNIL
the key is null (eg { : b} results in a null key)
Definition: node_type.hpp:49
@ DOC
a document
Definition: node_type.hpp:41
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
Definition: common.cpp:14
#define __(v)
Definition: node_type.hpp:35
wraps a NodeType_e element with some syntactic sugar and predicates
Definition: node_type.hpp:121
bool has_all(NodeType_e t) const noexcept
Definition: node_type.hpp:133
bool is_val_squo() const noexcept
Definition: node_type.hpp:227
bool is_key_plain() const noexcept
Definition: node_type.hpp:230
bool has_key() const noexcept
Definition: node_type.hpp:185
bool is_quoted() const noexcept
Definition: node_type.hpp:234
bool is_val_folded() const noexcept
Definition: node_type.hpp:225
bool has_none(NodeType_e t) const noexcept
Definition: node_type.hpp:134
bool has_key_tag() const noexcept
Definition: node_type.hpp:191
bool is_ref() const noexcept
Definition: node_type.hpp:198
NodeType(NodeType_e t) noexcept
Definition: node_type.hpp:129
void set_container_style(NodeType_e style) noexcept
Definition: node_type.hpp:239
bool is_key_ref() const noexcept
Definition: node_type.hpp:196
void set_key_style(NodeType_e style) noexcept
Definition: node_type.hpp:240
bool key_is_null() const noexcept
Definition: node_type.hpp:189
bool has_any(NodeType_e t) const noexcept
Definition: node_type.hpp:132
bool is_key_dquo() const noexcept
Definition: node_type.hpp:228
bool is_doc() const noexcept
Definition: node_type.hpp:181
bool is_seq() const noexcept
Definition: node_type.hpp:184
bool is_val_plain() const noexcept
Definition: node_type.hpp:231
bool is_notype() const noexcept
Definition: node_type.hpp:179
bool is_key_quoted() const noexcept
Definition: node_type.hpp:232
bool is_flow_ml() const noexcept
Definition: node_type.hpp:217
void rem(NodeType_e t) noexcept
Definition: node_type.hpp:138
const char * type_str() const noexcept
return a preset string based on the node type
Definition: node_type.hpp:154
bool has_val_anchor() const noexcept
Definition: node_type.hpp:194
static csubstr type_str_sub(substr buf, NodeType_e t) noexcept
fill a string with the node type flags.
Definition: node_type.hpp:166
bool is_key_unfiltered() const noexcept
Definition: node_type.hpp:200
bool has_val_tag() const noexcept
Definition: node_type.hpp:192
bool is_key_literal() const noexcept
Definition: node_type.hpp:222
bool is_key_squo() const noexcept
Definition: node_type.hpp:226
bool has_anchor() const noexcept
Definition: node_type.hpp:195
NodeType(type_bits t) noexcept
Definition: node_type.hpp:130
bool has_key_anchor() const noexcept
Definition: node_type.hpp:193
bool has_val() const noexcept
Definition: node_type.hpp:186
void clear() noexcept
Definition: node_type.hpp:141
bool is_val_unfiltered() const noexcept
Definition: node_type.hpp:201
bool is_flow_sl() const noexcept
Definition: node_type.hpp:216
bool is_map() const noexcept
Definition: node_type.hpp:183
bool is_val_styled() const noexcept
Definition: node_type.hpp:221
bool is_key_folded() const noexcept
Definition: node_type.hpp:224
bool is_container() const noexcept
Definition: node_type.hpp:182
bool is_container_styled() const noexcept
Definition: node_type.hpp:214
bool is_val_literal() const noexcept
Definition: node_type.hpp:223
bool is_key_styled() const noexcept
Definition: node_type.hpp:220
NodeType_e type
Definition: node_type.hpp:124
bool is_block() const noexcept
Definition: node_type.hpp:215
NodeType val_style() const noexcept
Definition: node_type.hpp:237
bool val_is_null() const noexcept
Definition: node_type.hpp:190
void set_val_style(NodeType_e style) noexcept
Definition: node_type.hpp:241
void addrem(NodeType_e bits_to_add, NodeType_e bits_to_remove) noexcept
Definition: node_type.hpp:139
void add(NodeType_e t) noexcept
Definition: node_type.hpp:137
size_t type_str(substr buf) const noexcept
fill a string with the node type flags.
Definition: node_type.hpp:159
void set(NodeType_e t) noexcept
Definition: node_type.hpp:136
bool is_keyval() const noexcept
Definition: node_type.hpp:188
bool is_val() const noexcept
Definition: node_type.hpp:187
void clear_style() noexcept
Definition: node_type.hpp:242
bool is_val_ref() const noexcept
Definition: node_type.hpp:197
bool is_val_quoted() const noexcept
Definition: node_type.hpp:233
bool is_val_dquo() const noexcept
Definition: node_type.hpp:229
NodeType key_style() const noexcept
Definition: node_type.hpp:236
bool is_stream() const noexcept
Definition: node_type.hpp:180
NodeType() noexcept
Definition: node_type.hpp:128
bool is_flow() const noexcept
Definition: node_type.hpp:218
csubstr type_str_sub(substr buf) const noexcept
fill a string with the node type flags.
Definition: node_type.hpp:164