rapidyaml 0.15.2
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 45 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 49 of file event_handler_ints.hpp.

49 : evt_bits { // NOLINT
50
51 //-------------------------------------------------------------------------
52 // YAML flags
53
54 // YAML structure flags
55 KEY_ = (1 << 0), ///< as key
56 VAL_ = (1 << 1), ///< as value
57
58 // YAML event scopes
59 BEG_ = (1 << 2), ///< scope: begin
60 END_ = (1 << 3), ///< scope: end
61 SEQ_ = (1 << 4), ///< scope: seq
62 MAP_ = (1 << 5), ///< scope: map
63 DOC_ = (1 << 6), ///< scope: doc
64 EXPL = (1 << 7), ///< `---` (with BDOC) or `...` (with EDOC)
65 STRM = (1 << 8), ///< scope: stream
66 BSEQ = BEG_|SEQ_, ///< begin seq (+SEQ in test suite events)
67 ESEQ = END_|SEQ_, ///< end seq (-SEQ in test suite events)
68 BMAP = BEG_|MAP_, ///< begin map (+MAP in test suite events)
69 EMAP = END_|MAP_, ///< end map (-MAP in test suite events)
70 BSTR = BEG_|STRM, ///< begin stream (+STR in test suite events)
71 ESTR = END_|STRM, ///< end stream (-STR in test suite events)
72 BDOC = BEG_|DOC_, ///< begin doc (+DOC in test suite events)
73 EDOC = END_|DOC_, ///< end doc (-DOC in test suite events)
74
75 // YAML string events
76 SCLR = (1 << 9), ///< scalar (=VAL in test suite events)
77 ALIA = (1 << 10), ///< *ref (reference)
78 ANCH = (1 << 11), ///< &anchor
79 TAG_ = (1 << 12), ///< !tag
80 // directives
81 YAML = (1 << 13), ///< yaml directive: `\%YAML <version>`
82 TAGH = (1 << 14), ///< tag directive, handle: `\%TAG <handle> ........`
83 TAGP = (1 << 15), ///< tag directive, prefix: `\%TAG ........ <prefix>`
84
85 // YAML style flags
86 PLAI = (1 << 16), ///< scalar: plain
87 SQUO = (1 << 17), ///< scalar: single-quoted (')
88 DQUO = (1 << 18), ///< scalar: double-quoted ("")
89 LITL = (1 << 19), ///< scalar: block literal (|)
90 FOLD = (1 << 20), ///< scalar: block folded (>)
91 FLOW = (1 << 21), ///< container: flow: [] for seqs or {} for maps
92 BLCK = (1 << 22), ///< container: block
93
94 /// Special flag to mark a scalar as unfiltered (when the parser
95 /// is set not to filter).
96 UNFILT = (1 << 23),
97
98 //-------------------------------------------------------------------------
99 // NON-YAML FLAGS
100
101 /// Special flag to mark events whose string was placed in the
102 /// arena. This happens when the filtered string is larger than
103 /// the original string in the YAML code (eg from tags that
104 /// resolve to a larger string, or from "\L" or "\P" in double
105 /// quotes, which expand from two to three bytes). Because of this
106 /// size expansion, the filtered string cannot be placed in the
107 /// original source and needs to be placed in the arena.
108 AREN = (1 << 24),
109
110 /// WithSTRing: mask of all events that encode a string following
111 /// the event. For such events, the next two integers will provide
112 /// respectively the string's offset and length. See also @ref PSTR
114
115 /// Special flag to enable look-back in the event array. It
116 /// signifies that the previous event has a string, meaning that
117 /// the jump back to that event is 3 positions. without this flag it
118 /// would be impossible to jump to the previous event.
119 /// see also @ref WSTR
120 PSTR = (1 << 25),
121
122 /// unused: reserved for future use (to enable rope-like buffers)
123 JUMP = (1 << 26),
124 /// unused: reserved for future use (same purpose as @ref PSTR,
125 /// but for @ref JUMP)
126 PJUMP = (1 << 27),
127
128 /// the last flag defined above
129 LAST = PJUMP,
130
131 /// a mask of all bits in this enumeration
132 MASK = (LAST << 1) - 1,
133
134} 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().