rapidyaml 0.16.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4::yml::extra::ievt Namespace Reference

Typedefs

using evt_bits = int32_t
 data type for integer events bits.

Enumerations

enum  EventBits : evt_bits {
  KEY_ = (1 << 0) , VAL_ = (1 << 1) , BEG_ = (1 << 2) , END_ = (1 << 3) ,
  SEQ_ = (1 << 4) , MAP_ = (1 << 5) , DOC_ = (1 << 6) , EXPL = (1 << 7) ,
  STRM = (1 << 8) , BSEQ = BEG_|SEQ_ , ESEQ = END_|SEQ_ , BMAP = BEG_|MAP_ ,
  EMAP = END_|MAP_ , BSTR = BEG_|STRM , ESTR = END_|STRM , BDOC = BEG_|DOC_ ,
  EDOC = END_|DOC_ , SCLR = (1 << 9) , ALIA = (1 << 10) , ANCH = (1 << 11) ,
  TAG_ = (1 << 12) , YAML = (1 << 13) , TAGH = (1 << 14) , TAGP = (1 << 15) ,
  PLAI = (1 << 16) , SQUO = (1 << 17) , DQUO = (1 << 18) , LITL = (1 << 19) ,
  FOLD = (1 << 20) , FLOW = (1 << 21) , BLCK = (1 << 22) , UNFILT = (1 << 23) ,
  AREN = (1 << 24) , WSTR = SCLR|ALIA|ANCH|TAG_|TAGH|TAGP|YAML , PSTR = (1 << 25) , JUMP = (1 << 26) ,
  PJUMP = (1 << 27) , LAST = PJUMP , MASK = (LAST << 1) - 1
}
 enumeration of integer event bits. More...

Functions

size_t to_str (substr buf, yml::extra::ievt::evt_bits flags) noexcept
 Convert bit mask of ievt::EventBits to text.
csubstr to_str_sub (substr buf, yml::extra::ievt::evt_bits flags)
 Convert bit mask of ievt::EventBits to text.

Typedef Documentation

◆ evt_bits

data type for integer events bits.

This is set to an int32_t integer to allow compatibility with a wide range of processing languages.

Definition at line 183 of file event_handler_ints.hpp.

Enumeration Type Documentation

◆ EventBits

enumeration of integer event bits.

Enumerator
KEY_ 

as key

VAL_ 

as value

BEG_ 

scope: begin

END_ 

scope: end

SEQ_ 

scope: seq

MAP_ 

scope: map

DOC_ 

scope: doc

EXPL 

--- (with BDOC) or ... (with EDOC)

STRM 

scope: stream

BSEQ 

begin seq (+SEQ in test suite events)

ESEQ 

end seq (-SEQ in test suite events)

BMAP 

begin map (+MAP in test suite events)

EMAP 

end map (-MAP in test suite events)

BSTR 

begin stream (+STR in test suite events)

ESTR 

end stream (-STR in test suite events)

BDOC 

begin doc (+DOC in test suite events)

EDOC 

end doc (-DOC in test suite events)

SCLR 

scalar (=VAL in test suite events)

ALIA 

*ref (reference)

ANCH 

&anchor

TAG_ 

!tag

YAML 

yaml directive: \YAML <version>

TAGH 

tag directive, handle: \TAG <handle> ........

TAGP 

tag directive, prefix: \TAG ........ <prefix>

PLAI 

scalar: plain

SQUO 

scalar: single-quoted (')

DQUO 

scalar: double-quoted ("")

LITL 

scalar: block literal (|)

FOLD 

scalar: block folded (>)

FLOW 

container: flow: [] for seqs or {} for maps

BLCK 

container: block

UNFILT 

Special flag to mark a scalar as unfiltered (when the parser is set not to filter).

AREN 

Special flag to mark events whose string was placed in the arena. This happens when the filtered string is larger than the original string in the YAML code (eg from tags that resolve to a larger string, or from "\L" or "\P" in double quotes, which expand from two to three bytes). Because of this size expansion, the filtered string cannot be placed in the original source and needs to be placed in the arena.

WSTR 

WithSTRing: mask of all events that encode a string following the event. For such events, the next two integers will provide respectively the string's offset and length. See also PSTR.

PSTR 

Special flag to enable look-back in the event array. It signifies that the previous event has a string, meaning that the jump back to that event is 3 positions. without this flag it would be impossible to jump to the previous event. see also WSTR.

JUMP 

unused: reserved for future use (to enable rope-like buffers)

PJUMP 

unused: reserved for future use (same purpose as PSTR, but for JUMP)

LAST 

the last flag defined above

MASK 

a mask of all bits in this enumeration

Definition at line 187 of file event_handler_ints.hpp.

187 : evt_bits { // NOLINT
188
189 //-------------------------------------------------------------------------
190 // YAML flags
191
192 // YAML structure flags
193 KEY_ = (1 << 0), ///< as key
194 VAL_ = (1 << 1), ///< as value
195
196 // YAML event scopes
197 BEG_ = (1 << 2), ///< scope: begin
198 END_ = (1 << 3), ///< scope: end
199 SEQ_ = (1 << 4), ///< scope: seq
200 MAP_ = (1 << 5), ///< scope: map
201 DOC_ = (1 << 6), ///< scope: doc
202 EXPL = (1 << 7), ///< `---` (with BDOC) or `...` (with EDOC)
203 STRM = (1 << 8), ///< scope: stream
204 BSEQ = BEG_|SEQ_, ///< begin seq (+SEQ in test suite events)
205 ESEQ = END_|SEQ_, ///< end seq (-SEQ in test suite events)
206 BMAP = BEG_|MAP_, ///< begin map (+MAP in test suite events)
207 EMAP = END_|MAP_, ///< end map (-MAP in test suite events)
208 BSTR = BEG_|STRM, ///< begin stream (+STR in test suite events)
209 ESTR = END_|STRM, ///< end stream (-STR in test suite events)
210 BDOC = BEG_|DOC_, ///< begin doc (+DOC in test suite events)
211 EDOC = END_|DOC_, ///< end doc (-DOC in test suite events)
212
213 // YAML string events
214 SCLR = (1 << 9), ///< scalar (=VAL in test suite events)
215 ALIA = (1 << 10), ///< *ref (reference)
216 ANCH = (1 << 11), ///< &anchor
217 TAG_ = (1 << 12), ///< !tag
218 // directives
219 YAML = (1 << 13), ///< yaml directive: `\%YAML <version>`
220 TAGH = (1 << 14), ///< tag directive, handle: `\%TAG <handle> ........`
221 TAGP = (1 << 15), ///< tag directive, prefix: `\%TAG ........ <prefix>`
222
223 // YAML style flags
224 PLAI = (1 << 16), ///< scalar: plain
225 SQUO = (1 << 17), ///< scalar: single-quoted (')
226 DQUO = (1 << 18), ///< scalar: double-quoted ("")
227 LITL = (1 << 19), ///< scalar: block literal (|)
228 FOLD = (1 << 20), ///< scalar: block folded (>)
229 FLOW = (1 << 21), ///< container: flow: [] for seqs or {} for maps
230 BLCK = (1 << 22), ///< container: block
231
232 /// Special flag to mark a scalar as unfiltered (when the parser
233 /// is set not to filter).
234 UNFILT = (1 << 23),
235
236 //-------------------------------------------------------------------------
237 // NON-YAML FLAGS
238
239 /// Special flag to mark events whose string was placed in the
240 /// arena. This happens when the filtered string is larger than
241 /// the original string in the YAML code (eg from tags that
242 /// resolve to a larger string, or from "\L" or "\P" in double
243 /// quotes, which expand from two to three bytes). Because of this
244 /// size expansion, the filtered string cannot be placed in the
245 /// original source and needs to be placed in the arena.
246 AREN = (1 << 24),
247
248 /// WithSTRing: mask of all events that encode a string following
249 /// the event. For such events, the next two integers will provide
250 /// respectively the string's offset and length. See also @ref PSTR
252
253 /// Special flag to enable look-back in the event array. It
254 /// signifies that the previous event has a string, meaning that
255 /// the jump back to that event is 3 positions. without this flag it
256 /// would be impossible to jump to the previous event.
257 /// see also @ref WSTR
258 PSTR = (1 << 25),
259
260 /// unused: reserved for future use (to enable rope-like buffers)
261 JUMP = (1 << 26),
262 /// unused: reserved for future use (same purpose as @ref PSTR,
263 /// but for @ref JUMP)
264 PJUMP = (1 << 27),
265
266 /// the last flag defined above
267 LAST = PJUMP,
268
269 /// a mask of all bits in this enumeration
270 MASK = (LAST << 1) - 1,
271
272} EventBits;
int32_t evt_bits
data type for integer events bits.
EventBits
enumeration of integer event bits.
@ PSTR
Special flag to enable look-back in the event array. It signifies that the previous event has a strin...
@ PJUMP
unused: reserved for future use (same purpose as PSTR, but for JUMP)
@ SCLR
scalar (=VAL in test suite events)
@ LITL
scalar: block literal (|)
@ UNFILT
Special flag to mark a scalar as unfiltered (when the parser is set not to filter).
@ EMAP
end map (-MAP in test suite events)
@ DQUO
scalar: double-quoted ("")
@ FOLD
scalar: block folded (>)
@ BMAP
begin map (+MAP in test suite events)
@ TAGH
tag directive, handle: \TAG <handle> ........
@ MASK
a mask of all bits in this enumeration
@ ESTR
end stream (-STR in test suite events)
@ BSTR
begin stream (+STR in test suite events)
@ BSEQ
begin seq (+SEQ in test suite events)
@ ESEQ
end seq (-SEQ in test suite events)
@ WSTR
WithSTRing: mask of all events that encode a string following the event. For such events,...
@ FLOW
container: flow: [] for seqs or {} for maps
@ JUMP
unused: reserved for future use (to enable rope-like buffers)
@ TAGP
tag directive, prefix: \TAG ........ <prefix>
@ BDOC
begin doc (+DOC in test suite events)
@ AREN
Special flag to mark events whose string was placed in the arena. This happens when the filtered stri...
@ YAML
yaml directive: \YAML <version>
@ EDOC
end doc (-DOC in test suite events)
@ LAST
the last flag defined above
@ EXPL
--- (with BDOC) or ... (with EDOC)
@ SQUO
scalar: single-quoted (')

Function Documentation

◆ to_str()

size_t c4::yml::extra::ievt::to_str ( substr buf,
ievt::evt_bits flags )
noexcept

Convert bit mask of ievt::EventBits to text.

Definition at line 60 of file ints_utils.cpp.

61{
62 detail::SubstrWriter_ writer(buf);
63 for(const FlagSym sym : flag_syms_)
64 {
65 if(flags & sym.flags)
66 {
67 if(writer.pos)
68 writer.append('|');
69 writer.append(sym.str);
70 flags &= ~sym.flags;
71 }
72 }
73 if(!writer.pos)
74 writer.append("NONE");
75 if(buf.len > writer.pos)
76 buf[writer.pos] = '\0';
77 return writer.pos;
78}
size_t len
the length of the substring
Definition substr.hpp:218

Referenced by to_str(), and to_str_sub().

◆ to_str_sub()

csubstr c4::yml::extra::ievt::to_str_sub ( substr buf,
ievt::evt_bits flags )

Convert bit mask of ievt::EventBits to text.

Definition at line 80 of file ints_utils.cpp.

81{
82 size_t reqsize = ievt::to_str(buf, flags);
83 RYML_CHECK_BASIC_(reqsize > 0u);
84 RYML_CHECK_BASIC_(reqsize < buf.len);
85 return buf.first(reqsize);
86}
size_t to_str(substr buf, ievt::evt_bits flags) noexcept
Convert bit mask of ievt::EventBits to text.
basic_substring first(size_t num) const noexcept
return the first num elements: [0,num[
Definition substr.hpp:529

Referenced by c4::yml::extra::events_ints_print(), and to_str_sub().