rapidyaml 0.15.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
Node types

Classes

struct  c4::yml::NodeType
 wraps a NodeType_e element with some syntactic sugar and predicates More...

Typedefs

using c4::yml::type_bits = uint32_t
 the integral type necessary to cover all the bits for NodeType_e

Enumerations

enum  c4::yml::NodeType_e : type_bits {
  c4::yml::NOTYPE = 0 , c4::yml::KEY = __(0) , c4::yml::VAL = __(1) , c4::yml::MAP = __(2) ,
  c4::yml::SEQ = __(3) , c4::yml::DOC = __(4) , c4::yml::STREAM = __(5)|SEQ , c4::yml::KEYREF = __(6) ,
  c4::yml::VALREF = __(7) , c4::yml::KEYANCH = __(8) , c4::yml::VALANCH = __(9) , c4::yml::KEYTAG = __(10) ,
  c4::yml::VALTAG = __(11) , c4::yml::KEYNIL = __(12) , c4::yml::VALNIL = __(13) , c4::yml::_TYMASK = __(14)-1 ,
  c4::yml::KEY_UNFILT = __(14) , c4::yml::VAL_UNFILT = __(15) , c4::yml::FLOW_SL = __(16) , c4::yml::FLOW_ML1 = __(17) ,
  c4::yml::FLOW_MLN = __(18) , c4::yml::FLOW_SPC = __(19) , c4::yml::BLOCK = __(20) , c4::yml::KEY_LITERAL = __(21) ,
  c4::yml::VAL_LITERAL = __(22) , c4::yml::KEY_FOLDED = __(23) , c4::yml::VAL_FOLDED = __(24) , c4::yml::KEY_SQUO = __(25) ,
  c4::yml::VAL_SQUO = __(26) , c4::yml::KEY_DQUO = __(27) , c4::yml::VAL_DQUO = __(28) , c4::yml::KEY_PLAIN = __(29) ,
  c4::yml::VAL_PLAIN = __(30) , c4::yml::KEYVAL = KEY|VAL , c4::yml::KEYSEQ = KEY|SEQ , c4::yml::KEYMAP = KEY|MAP ,
  c4::yml::DOCMAP = DOC|MAP , c4::yml::DOCSEQ = DOC|SEQ , c4::yml::DOCVAL = DOC|VAL , c4::yml::SCALAR_LITERAL = KEY_LITERAL|VAL_LITERAL ,
  c4::yml::SCALAR_FOLDED = KEY_FOLDED|VAL_FOLDED , c4::yml::SCALAR_SQUO = KEY_SQUO|VAL_SQUO , c4::yml::SCALAR_DQUO = KEY_DQUO|VAL_DQUO , c4::yml::SCALAR_PLAIN = KEY_PLAIN|VAL_PLAIN ,
  c4::yml::KEYQUO = KEY_SQUO|KEY_DQUO|KEY_FOLDED|KEY_LITERAL , c4::yml::VALQUO = VAL_SQUO|VAL_DQUO|VAL_FOLDED|VAL_LITERAL , c4::yml::KEY_STYLE = KEYQUO|KEY_PLAIN , c4::yml::VAL_STYLE = VALQUO|VAL_PLAIN ,
  c4::yml::SCALAR_STYLE = KEY_STYLE|VAL_STYLE , c4::yml::FLOW_MLX = FLOW_ML1|FLOW_MLN , c4::yml::CONTAINER_STYLE_FLOW = FLOW_SL|FLOW_MLX|FLOW_SPC , c4::yml::CONTAINER_STYLE_BLOCK = BLOCK ,
  c4::yml::CONTAINER_STYLE = CONTAINER_STYLE_FLOW|CONTAINER_STYLE_BLOCK , c4::yml::STYLE = SCALAR_STYLE | CONTAINER_STYLE
}
 a bit mask for marking node types and styles More...

Functions

constexpr C4_CONST NodeType_e c4::yml::operator| (NodeType_e lhs, NodeType_e rhs) noexcept
constexpr C4_CONST NodeType_e c4::yml::operator& (NodeType_e lhs, NodeType_e rhs) noexcept
constexpr C4_CONST NodeType_e c4::yml::operator>> (NodeType_e bits, uint32_t n) noexcept
constexpr C4_CONST NodeType_e c4::yml::operator<< (NodeType_e bits, uint32_t n) noexcept
constexpr C4_CONST NodeType_e c4::yml::operator~ (NodeType_e bits) noexcept
NodeType_ec4::yml::operator&= (NodeType_e &subject, NodeType_e bits) noexcept
NodeType_ec4::yml::operator|= (NodeType_e &subject, NodeType_e bits) noexcept

scalar style helpers

NodeType_e c4::yml::scalar_style_choose_flow (csubstr scalar) noexcept
 choose a YAML scalar style based on the scalar's contents, while in flow mode.
NodeType_e c4::yml::scalar_style_choose_block (csubstr scalar) noexcept
 choose a YAML scalar style based on the scalar's contents, while in block mode.
NodeType_e c4::yml::scalar_style_choose (csubstr s, bool flow=true) noexcept
 choose a YAML emitting style based on the scalar's contents.
NodeType_e c4::yml::scalar_style_choose_json (csubstr scalar) noexcept
 choose a json scalar style based on the scalar's contents
bool c4::yml::scalar_style_query_squo (csubstr s) noexcept
 query whether a scalar can be encoded using single quotes.
bool c4::yml::scalar_style_query_plain_flow (csubstr s) noexcept
 query whether a scalar can be encoded using plain style while in flow mode.
bool c4::yml::scalar_style_query_plain_block (csubstr s) noexcept
 query whether a scalar can be encoded using plain style while in block mode.
bool c4::yml::scalar_style_query_plain (csubstr s, bool flow=true) noexcept
 query whether a scalar can be encoded using plain style.
bool c4::yml::scalar_is_null (csubstr s) noexcept
 YAML-sense query of nullity.

Detailed Description

Typedef Documentation

◆ type_bits

using c4::yml::type_bits = uint32_t

the integral type necessary to cover all the bits for NodeType_e

Definition at line 30 of file node_type.hpp.

Enumeration Type Documentation

◆ NodeType_e

a bit mask for marking node types and styles

Enumerator
NOTYPE 

no node type or style is set

KEY 

the scalar to the left of : in a map's member

VAL 

a scalar: has a scalar (ie string) value, possibly empty. must be a leaf node, and cannot be MAP or SEQ

MAP 

a map: a parent of KEYVAL/KEYSEQ/KEYMAP nodes

SEQ 

a seq: a parent of VAL/SEQ/MAP nodes

DOC 

a document

STREAM 

a stream: a seq of docs

KEYREF 

a *reference: the key references an &anchor

VALREF 

a *reference: the val references an &anchor

KEYANCH 

the key has an &anchor

VALANCH 

the val has an &anchor

KEYTAG 

the key has a tag

VALTAG 

the val has a tag

KEYNIL 

the key is null (eg { : b} results in a null key)

VALNIL 

the val is null (eg {a : } results in a null val)

_TYMASK 

all the bits up to here

KEY_UNFILT 

the key scalar was left unfiltered; the parser was set not to filter.

See also
ParserOptions::scalar_filtering()
VAL_UNFILT 

the val scalar was left unfiltered; the parser was set not to filter.

See also
ParserOptions::scalar_filtering()
FLOW_SL 

mark container with single-line flow style

FLOW_ML1 

mark container with multi-line flow style, 1 element per line

  • seqs as
    [
    val1,
    val2
    ]
  • maps as
    {
    key: val,
    key2: val2
    }
FLOW_MLN 

mark container with multi-line flow style, n elements per line, wrapped (as set by EmitOptions::max_cols()):

FLOW_SPC 

mark container with spaces after comma when in flow mode. Applies to both FLOW_SL and FLOW_MLN (but not to FLOW_ML1), and can be overriden globally by EmitOptions::force_flow_spc().

BLOCK 

mark container with block style

  • seqs as
    - val1
    - val2
  • maps as
    key1: val1
    key2: val2
KEY_LITERAL 

mark key scalar as multiline, block literal |

VAL_LITERAL 

mark val scalar as multiline, block literal |

KEY_FOLDED 

mark key scalar as multiline, block folded >

VAL_FOLDED 

mark val scalar as multiline, block folded >

KEY_SQUO 

mark key scalar as single quoted '

VAL_SQUO 

mark val scalar as single quoted '

KEY_DQUO 

mark key scalar as double quoted "

VAL_DQUO 

mark val scalar as double quoted "

KEY_PLAIN 

mark key scalar as plain scalar (unquoted, even when multiline)

VAL_PLAIN 

mark val scalar as plain scalar (unquoted, even when multiline)

KEYVAL 

mask of KEY|VAL

KEYSEQ 

mask of KEY|SEQ

KEYMAP 

mask of KEY|MAP

DOCMAP 

mask of DOC|MAP

DOCSEQ 

mask of DOC|SEQ

DOCVAL 

mask of DOC|VAL

SCALAR_LITERAL 

mask of KEY_LITERAL|VAL_LITERAL,

SCALAR_FOLDED 

mask of KEY_FOLDED|VAL_FOLDED,

SCALAR_SQUO 

mask of KEY_SQUO|VAL_SQUO,

SCALAR_DQUO 

mask of KEY_DQUO|VAL_DQUO,

SCALAR_PLAIN 

mask of KEY_PLAIN|VAL_PLAIN,

KEYQUO 

key style is one of '">|. mask of KEY_SQUO|KEY_DQUO|KEY_FOLDED|KEY_LITERAL

VALQUO 

val style is one of '">|. mask of VAL_SQUO|VAL_DQUO|VAL_FOLDED|VAL_LITERAL

KEY_STYLE 

mask of KEYQUO|KEY_PLAIN : all the key scalar styles for key (not container styles!)

VAL_STYLE 

mask of VALQUO|VAL_PLAIN : all the val scalar styles for val (not container styles!)

SCALAR_STYLE 

mask of KEY_STYLE|VAL_STYLE : all the key+val scalar styles

FLOW_MLX 

mask of FLOW_ML1|FLOW_MLN : all the flow multiline styles

CONTAINER_STYLE_FLOW 

mask of FLOW_SL|FLOW_MLX|FLOW_SPC : all flow flags

CONTAINER_STYLE_BLOCK 

alias to BLOCK

CONTAINER_STYLE 

mask of CONTAINER_STYLE_FLOW|CONTAINER_STYLE_BLOCK : all container style flags

STYLE 

mask of SCALAR_STYLE | CONTAINER_STYLE : all style flags

Definition at line 34 of file node_type.hpp.

34 : 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), ///< the scalar to the left of `:` in a map's member
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 @ref ParserOptions::scalar_filtering()
56 VAL_UNFILT = __(15), ///< the val scalar was left unfiltered; the parser was set not to filter. @see @ref ParserOptions::scalar_filtering()
57 //
58 // style flags:
59 //
60 FLOW_SL = __(16), ///< mark container with single-line flow style
61 ///< - seqs as
62 ///< @code{yaml}
63 ///< [val1,val2]
64 ///< @endcode
65 ///< when @ref FLOW_SPC is not set, or
66 ///< @code{yaml}
67 ///< [val1, val2]
68 ///< @endcode
69 ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
70 ///< - maps as
71 ///< @code{yaml}
72 ///< {key1: val1,key2: val2}
73 ///< @endcode
74 ///< when @ref FLOW_SPC is not set, or
75 ///< @code{yaml}
76 ///< {key1: val1, key2: val2}
77 ///< @endcode
78 ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
79 FLOW_ML1 = __(17), ///< mark container with multi-line flow style, 1 element per line
80 ///< - seqs as
81 ///< @code{yaml}
82 ///< [
83 ///< val1,
84 ///< val2
85 ///< ]
86 ///< @endcode
87 ///< - maps as
88 ///< @code{yaml}
89 ///< {
90 ///< key: val,
91 ///< key2: val2
92 ///< }
93 ///< @endcode
94 FLOW_MLN = __(18), ///< mark container with multi-line flow style, n elements per line,
95 ///< wrapped (as set by @ref EmitOptions::max_cols()):
96 ///< - seqs as
97 ///< @code{yaml}
98 ///< [
99 ///< val,val,...
100 ///< val,val,...
101 ///< val,val,...
102 ///< ...
103 ///< val
104 ///< ]
105 ///< @endcode
106 ///< when @ref FLOW_SPC is not set, or
107 ///< @code{yaml}
108 ///< [
109 ///< val, val,...
110 ///< val, val,...
111 ///< val, val,...
112 ///< ...
113 ///< val
114 ///< ]
115 ///< @endcode
116 ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
117 ///< - maps as
118 ///< @code{yaml}
119 ///< {
120 ///< key: val,key: val,...
121 ///< key: val,key: val,...
122 ///< ...
123 ///< key: val
124 ///< }
125 ///< @endcode
126 ///< when @ref FLOW_SPC is not set, or
127 ///< @code{yaml}
128 ///< {
129 ///< key: val, key: val,...
130 ///< key: val, key: val,...
131 ///< ...
132 ///< key: val
133 ///< }
134 ///< @endcode
135 ///< when @ref FLOW_SPC is set (or @ref EmitOptions::force_flow_spc() is set)
136 FLOW_SPC = __(19), ///< mark container with spaces after comma when in flow mode.
137 ///< Applies to both @ref FLOW_SL and @ref FLOW_MLN (but not
138 ///< to @ref FLOW_ML1), and can be overriden globally by
139 ///< @ref EmitOptions::force_flow_spc().
140 BLOCK = __(20), ///< mark container with block style
141 ///< - seqs as
142 ///< @code{yaml}
143 ///< - val1
144 ///< - val2
145 ///< @endcode
146 ///< - maps as
147 ///< @code{yaml}
148 ///< key1: val1
149 ///< key2: val2
150 ///< @endcode
151 KEY_LITERAL = __(21), ///< mark key scalar as multiline, block literal |
152 VAL_LITERAL = __(22), ///< mark val scalar as multiline, block literal |
153 KEY_FOLDED = __(23), ///< mark key scalar as multiline, block folded >
154 VAL_FOLDED = __(24), ///< mark val scalar as multiline, block folded >
155 KEY_SQUO = __(25), ///< mark key scalar as single quoted '
156 VAL_SQUO = __(26), ///< mark val scalar as single quoted '
157 KEY_DQUO = __(27), ///< mark key scalar as double quoted "
158 VAL_DQUO = __(28), ///< mark val scalar as double quoted "
159 KEY_PLAIN = __(29), ///< mark key scalar as plain scalar (unquoted, even when multiline)
160 VAL_PLAIN = __(30), ///< mark val scalar as plain scalar (unquoted, even when multiline)
161 //
162 // type combination masks:
163 //
164 KEYVAL = KEY|VAL, ///< mask of @ref KEY|@ref VAL
165 KEYSEQ = KEY|SEQ, ///< mask of @ref KEY|@ref SEQ
166 KEYMAP = KEY|MAP, ///< mask of @ref KEY|@ref MAP
167 DOCMAP = DOC|MAP, ///< mask of @ref DOC|@ref MAP
168 DOCSEQ = DOC|SEQ, ///< mask of @ref DOC|@ref SEQ
169 DOCVAL = DOC|VAL, ///< mask of @ref DOC|@ref VAL
170 //
171 // style combination masks:
172 //
173 SCALAR_LITERAL = KEY_LITERAL|VAL_LITERAL, ///< mask of @ref KEY_LITERAL|@ref VAL_LITERAL,
174 SCALAR_FOLDED = KEY_FOLDED|VAL_FOLDED, ///< mask of @ref KEY_FOLDED|@ref VAL_FOLDED,
175 SCALAR_SQUO = KEY_SQUO|VAL_SQUO, ///< mask of @ref KEY_SQUO|@ref VAL_SQUO,
176 SCALAR_DQUO = KEY_DQUO|VAL_DQUO, ///< mask of @ref KEY_DQUO|@ref VAL_DQUO,
177 SCALAR_PLAIN = KEY_PLAIN|VAL_PLAIN, ///< mask of @ref KEY_PLAIN|@ref VAL_PLAIN,
178 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
179 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
180 KEY_STYLE = KEYQUO|KEY_PLAIN, ///< mask of @ref KEYQUO|@ref KEY_PLAIN : all the key scalar styles for key (not container styles!)
181 VAL_STYLE = VALQUO|VAL_PLAIN, ///< mask of @ref VALQUO|@ref VAL_PLAIN : all the val scalar styles for val (not container styles!)
182 SCALAR_STYLE = KEY_STYLE|VAL_STYLE, ///< mask of @ref KEY_STYLE|@ref VAL_STYLE : all the key+val scalar styles
183 FLOW_MLX = FLOW_ML1|FLOW_MLN, ///< mask of @ref FLOW_ML1|@ref FLOW_MLN : all the flow multiline styles
184 CONTAINER_STYLE_FLOW = FLOW_SL|FLOW_MLX|FLOW_SPC, ///< mask of @ref FLOW_SL|@ref FLOW_MLX|@ref FLOW_SPC : all flow flags
185 CONTAINER_STYLE_BLOCK = BLOCK, ///< alias to @ref BLOCK
186 CONTAINER_STYLE = CONTAINER_STYLE_FLOW|CONTAINER_STYLE_BLOCK, ///< mask of @ref CONTAINER_STYLE_FLOW|@ref CONTAINER_STYLE_BLOCK : all container style flags
187 STYLE = SCALAR_STYLE | CONTAINER_STYLE, ///< mask of @ref SCALAR_STYLE | @ref CONTAINER_STYLE : all style flags
188 /** @cond dev */
189 //
190 // mixed masks
191 _KEYMASK = KEY | KEYQUO | KEYANCH | KEYREF | KEYTAG,
192 _VALMASK = VAL | VALQUO | VALANCH | VALREF | VALTAG,
193 #undef __
194 #if C4_CPP >= 17 \
195 || (defined(__GNUC__) && __GNUC__ >= 6) \
196 || (defined(_MSC_VER) && !defined(__clang__))
197 #define RYML_HAS_DEPRECATED_ENUMS__
198 FLOW_ML RYML_DEPRECATED("use one of FLOW_ML{1,N,X}") = FLOW_ML1,
199 #endif
200 /** @endcond */
201} NodeType_e;
NodeType_e
a bit mask for marking node types and styles
Definition node_type.hpp:34
uint32_t type_bits
the integral type necessary to cover all the bits for NodeType_e
Definition node_type.hpp:30
@ 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
mask of KEY_FOLDED|VAL_FOLDED,
@ KEY_DQUO
mark key scalar as double quoted "
@ 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
@ FLOW_MLX
mask of FLOW_ML1|FLOW_MLN : all the flow multiline styles
@ STREAM
a stream: a seq of docs
Definition node_type.hpp:42
@ KEY
the scalar to the left of : in a map's member
Definition node_type.hpp:37
@ KEYQUO
key style is one of '">|. mask of KEY_SQUO|KEY_DQUO|KEY_FOLDED|KEY_LITERAL
@ FLOW_ML1
mark container with multi-line flow style, 1 element per line
Definition node_type.hpp:79
@ VAL_FOLDED
mark val scalar as multiline, block folded >
@ CONTAINER_STYLE_BLOCK
alias to BLOCK
@ VAL_STYLE
mask of VALQUO|VAL_PLAIN : all the val scalar styles for val (not container styles!...
@ KEYTAG
the key has a tag
Definition node_type.hpp:47
@ CONTAINER_STYLE_FLOW
mask of FLOW_SL|FLOW_MLX|FLOW_SPC : all flow flags
@ SCALAR_SQUO
mask of KEY_SQUO|VAL_SQUO,
@ FLOW_SL
mark container with single-line flow style
Definition node_type.hpp:60
@ 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
@ KEYMAP
mask of KEY|MAP
@ VALTAG
the val has a tag
Definition node_type.hpp:48
@ SCALAR_STYLE
mask of KEY_STYLE|VAL_STYLE : all the key+val scalar styles
@ KEYSEQ
mask of KEY|SEQ
@ _TYMASK
all the bits up to here
Definition node_type.hpp:51
@ FLOW_MLN
mark container with multi-line flow style, n elements per line, wrapped (as set by EmitOptions::max_c...
Definition node_type.hpp:94
@ SCALAR_LITERAL
mask of KEY_LITERAL|VAL_LITERAL,
@ SEQ
a seq: a parent of VAL/SEQ/MAP nodes
Definition node_type.hpp:40
@ SCALAR_DQUO
mask of KEY_DQUO|VAL_DQUO,
@ VAL_SQUO
mark val scalar as single quoted '
@ DOCSEQ
mask of DOC|SEQ
@ KEY_STYLE
mask of KEYQUO|KEY_PLAIN : all the key 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
Definition node_type.hpp:43
@ DOCMAP
mask of DOC|MAP
@ BLOCK
mark container with block style
@ FLOW_SPC
mark container with spaces after comma when in flow mode. Applies to both FLOW_SL and FLOW_MLN (but n...
@ DOCVAL
mask of DOC|VAL
@ STYLE
mask of SCALAR_STYLE | CONTAINER_STYLE : all style flags
@ KEYVAL
mask of KEY|VAL
@ KEYANCH
the key has an &anchor
Definition node_type.hpp:45
@ VALQUO
val style is one of '">|. mask of VAL_SQUO|VAL_DQUO|VAL_FOLDED|VAL_LITERAL
@ VAL_DQUO
mark val scalar as double quoted "
@ CONTAINER_STYLE
mask of CONTAINER_STYLE_FLOW|CONTAINER_STYLE_BLOCK : all container style flags
@ 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 '
@ 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)
@ SCALAR_PLAIN
mask of KEY_PLAIN|VAL_PLAIN,
@ KEY_FOLDED
mark key scalar as multiline, block folded >
@ 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
#define __(v)
Definition node_type.hpp:35

Function Documentation

◆ operator|()

C4_CONST NodeType_e c4::yml::operator| ( NodeType_e lhs,
NodeType_e rhs )
inlineconstexprnoexcept

Definition at line 211 of file node_type.hpp.

211{ return (NodeType_e)(((type_bits)lhs) | ((type_bits)rhs)); }

◆ operator&()

C4_CONST NodeType_e c4::yml::operator& ( NodeType_e lhs,
NodeType_e rhs )
inlineconstexprnoexcept

Definition at line 212 of file node_type.hpp.

212{ return (NodeType_e)(((type_bits)lhs) & ((type_bits)rhs)); }

◆ operator>>()

C4_CONST NodeType_e c4::yml::operator>> ( NodeType_e bits,
uint32_t n )
inlineconstexprnoexcept

Definition at line 213 of file node_type.hpp.

213{ return (NodeType_e)(((type_bits)bits) >> n); }

◆ operator<<()

C4_CONST NodeType_e c4::yml::operator<< ( NodeType_e bits,
uint32_t n )
inlineconstexprnoexcept

Definition at line 214 of file node_type.hpp.

214{ return (NodeType_e)(((type_bits)bits) << n); }

◆ operator~()

C4_CONST NodeType_e c4::yml::operator~ ( NodeType_e bits)
inlineconstexprnoexcept

Definition at line 215 of file node_type.hpp.

215{ return (NodeType_e)(~(type_bits)bits); }

◆ operator&=()

NodeType_e & c4::yml::operator&= ( NodeType_e & subject,
NodeType_e bits )
inlinenoexcept

Definition at line 216 of file node_type.hpp.

216{ subject = (NodeType_e)((type_bits)subject & (type_bits)bits); return subject; }

◆ operator|=()

NodeType_e & c4::yml::operator|= ( NodeType_e & subject,
NodeType_e bits )
inlinenoexcept

Definition at line 217 of file node_type.hpp.

217{ subject = (NodeType_e)((type_bits)subject | (type_bits)bits); return subject; }

◆ scalar_style_choose_flow()

NodeType_e c4::yml::scalar_style_choose_flow ( csubstr scalar)
noexcept

choose a YAML scalar style based on the scalar's contents, while in flow mode.

Plain scalars [have more constraints in flow mode than in block mode](https://www.yaml.info/learn/quote.html#noplain). scalar_style_choose_block() is the block mode analogous function.

Definition at line 264 of file node_type.cpp.

265{
266 if(s.len)
267 {
269 return SCALAR_PLAIN;
270 else if(scalar_style_query_squo(s))
271 return SCALAR_SQUO;
272 return SCALAR_DQUO;
273 }
274 return s.str ? SCALAR_SQUO : SCALAR_PLAIN;
275}
bool scalar_style_query_squo(csubstr s) noexcept
query whether a scalar can be encoded using single quotes.
bool scalar_style_query_plain_flow(csubstr s) noexcept
query whether a scalar can be encoded using plain style while in flow mode.

◆ scalar_style_choose_block()

NodeType_e c4::yml::scalar_style_choose_block ( csubstr scalar)
noexcept

choose a YAML scalar style based on the scalar's contents, while in block mode.

Plain scalars [have more constraints in flow mode than in block mode](https://www.yaml.info/learn/quote.html#noplain). scalar_style_choose_block() is the flow mode analogous function.

Definition at line 277 of file node_type.cpp.

278{
279 if(s.len)
280 {
282 return SCALAR_PLAIN;
283 _RYML_ASSERT_BASIC(scalar_style_query_squo(s)
284 && "if this assertion fires, please submit an issue!");
285 return SCALAR_SQUO;
286 }
287 return s.str ? SCALAR_SQUO : SCALAR_PLAIN;
288}
bool scalar_style_query_plain_block(csubstr s) noexcept
query whether a scalar can be encoded using plain style while in block mode.

◆ scalar_style_choose()

NodeType_e c4::yml::scalar_style_choose ( csubstr s,
bool flow = true )
inlinenoexcept

choose a YAML emitting style based on the scalar's contents.

Legacy compatibility function: assumes flow mode which is more constraining, and delegates to either scalar_style_choose_flow() or scalar_style_choose_block().

Definition at line 388 of file node_type.hpp.

389{
391}
NodeType_e scalar_style_choose_flow(csubstr s) noexcept
choose a YAML scalar style based on the scalar's contents, while in flow mode.
NodeType_e scalar_style_choose_block(csubstr s) noexcept
choose a YAML scalar style based on the scalar's contents, while in block mode.

◆ scalar_style_choose_json()

NodeType_e c4::yml::scalar_style_choose_json ( csubstr s)
noexcept

choose a json scalar style based on the scalar's contents

Definition at line 361 of file node_type.cpp.

362{
363 // do not quote numbers or special scalars
364 return json_is_plain_number(s) || json_is_special_scalar(s) ? SCALAR_PLAIN : SCALAR_DQUO;
365}

◆ scalar_style_query_squo()

bool c4::yml::scalar_style_query_squo ( csubstr s)
noexcept

query whether a scalar can be encoded using single quotes.

It may not be possible, notably when there is leading whitespace after a newline.

Definition at line 140 of file node_type.cpp.

141{
142 // cannot have leading whitespace after a newline
143 for(size_t i = 0; i < s.len; ++i)
144 {
145 if(s.str[i] == '\n' && i + 1 < s.len)
146 {
147 char next = s.str[i + 1];
148 if(next == ' ' || next == '\t')
149 return false;
150 }
151 }
152 return true;
153}
size_t len
the length of the substring
Definition substr.hpp:218
C * str
a restricted pointer to the first character of the substring
Definition substr.hpp:216

◆ scalar_style_query_plain_flow()

bool c4::yml::scalar_style_query_plain_flow ( csubstr s)
noexcept

query whether a scalar can be encoded using plain style while in flow mode.

Plain scalars [have more constraints in flow mode than in block mode](https://www.yaml.info/learn/quote.html#noplain). scalar_style_query_plain_block() is the block mode analogous function.

Definition at line 173 of file node_type.cpp.

174{
175 if(!s.len)
176 return !s.str;
177 // first
178 switch(s.str[0])
179 {
180 case ' ': case '\n': case '\t': case '\r':
181 case '!': case '&': case '*': case ',':
182 case '"': case '\'': case '|': case '>':
183 case '{': case '}': case '[': case ']':
184 case '#': case '`': case '%': case '@':
185 return false;
186 case '-': case ':': case '?':
187 if(s.len == 1 || (s.str[1] == ' ' || s.str[1] == '\t'))
188 return false;
189 break;
190 }
191 // bulk
192 for(size_t i = 1; i + 1 < s.len; ++i)
193 {
194 switch(s.str[i])
195 {
196 case ',': case '{': case '}': case '[': case ']':
197 return false;
198 case ':': case '#':
199 if(!_is_valid_bulk(s, i))
200 return false;
201 break;
202 }
203 }
204 // last
205 if(s.len > 1)
206 {
207 switch(s.back())
208 {
209 case ' ': case '\n': case '\t': case '\r':
210 case ',':
211 case '{': case '}':
212 case '[': case ']':
213 case '#':
214 case ':':
215 return false;
216 }
217 }
218 return true;
219}
C & back() noexcept
Definition substr.hpp:375

◆ scalar_style_query_plain_block()

bool c4::yml::scalar_style_query_plain_block ( csubstr s)
noexcept

query whether a scalar can be encoded using plain style while in block mode.

Plain scalars [have more constraints in flow mode than in block mode](https://www.yaml.info/learn/quote.html#noplain). scalar_style_query_plain_flow() is the flow mode analogous function.

Definition at line 221 of file node_type.cpp.

222{
223 if(!s.len)
224 return !s.str;
225 // first
226 switch(s.str[0])
227 {
228 case ' ': case '\n': case '\t': case '\r':
229 case '!': case '&': case '*': case ',':
230 case '"': case '\'': case '|': case '>':
231 case '{': case '}': case '[': case ']':
232 case '#': case '`': case '%': case '@':
233 return false;
234 case '-': case ':': case '?':
235 if (s.len == 1 || (s.str[1] == ' ' || s.str[1] == '\t'))
236 return false;
237 break;
238 }
239 // bulk
240 for(size_t i = 1; i + 1 < s.len; ++i)
241 {
242 switch(s.str[i])
243 {
244 case ':': case '#':
245 if(!_is_valid_bulk(s, i))
246 return false;
247 break;
248 }
249 }
250 // last
251 if(s.len > 1)
252 {
253 switch(s.back())
254 {
255 case ' ': case '\n': case '\t': case '\r':
256 case '#':
257 case ':':
258 return false;
259 }
260 }
261 return true;
262}

◆ scalar_style_query_plain()

bool c4::yml::scalar_style_query_plain ( csubstr s,
bool flow = true )
inlinenoexcept

query whether a scalar can be encoded using plain style.

Legacy compatibility function: assumes flow mode which is more constraining, and delegates to either scalar_style_query_plain_flow() or scalar_style_query_plain_block().

Definition at line 427 of file node_type.hpp.

428{
430}

◆ scalar_is_null()

bool c4::yml::scalar_is_null ( csubstr s)
noexcept

YAML-sense query of nullity.

returns true if the scalar points to nullptr or is otherwise equal to one of the strings "~","null","Null","NULL"

Definition at line 291 of file node_type.cpp.

292{
293 return s.str == nullptr ||
294 (s.len == 1 && (s.str[0] == '~')) ||
295 (s.len == 4 && ((0 == memcmp("null", s.str, 4))
296 || (0 == memcmp("Null", s.str, 4))
297 || (0 == memcmp("NULL", s.str, 4))));
298}