rapidyaml  0.16.0
parseandemitYAML,anddoitfast
event_handler_ints.cpp
Go to the documentation of this file.
1 #ifdef RYML_SINGLE_HEADER_INTS
2  #ifndef _RYML_SINGLE_HEADER_AMALGAMATED_HPP_
3  #include <ryml_ints.hpp>
4  #endif
5 #elif defined(RYML_SINGLE_HEADER)
6  #ifndef _RYML_SINGLE_HEADER_AMALGAMATED_HPP_
7  #include <ryml_all.hpp>
8  #endif
9 #else
11 #endif
12 
13 #ifndef C4_YML_EXTRA_EVENT_HANDLER_INTS_HPP_
15 #endif
16 
17 namespace c4 {
18 namespace yml {
19 
20 // instantiate the template
21 template class RYML_EXPORT ParseEngine<extra::EventHandlerInts>;
22 
23 namespace extra {
24 
26 {
27  evt_size count = 7; // BSTR + BDOC + =VAL + EDOC + ESTR
28  for(size_t i = 0; i < src.len; ++i)
29  {
30  switch(src.str[i])
31  {
32  case ':': // this has strings preceding/following it
33  case ',': // overestimate, assume map
34  case '%': // assume TAGD->string + TAGV->string
35  count += 6;
36  break;
37  // these have (or are likely to have) a string following it
38  case '-':
39  case '&':
40  case '*':
41  case '<':
42  case '!':
43  case '\'':
44  case '"':
45  case '|':
46  case '>':
47  case '\n':
48  count += 3;
49  break;
50  case '[':
51  case ']':
52  count += 4;
53  break;
54  case '{':
55  case '}':
56  count += 7;
57  break;
58  case '?':
59  count += 5;
60  break;
61  }
62  }
63  return count;
64 }
65 
66 // NOLINTBEGIN(hicpp-signed-bitwise)
67 // ensure the ievt flags work despite being signed
68 static_assert((ievt::MASK & ievt::BSTR) == ievt::BSTR, "overflow?");
69 static_assert((ievt::MASK & ievt::ESTR) == ievt::ESTR, "overflow?");
70 static_assert((ievt::MASK & ievt::BDOC) == ievt::BDOC, "overflow?");
71 static_assert((ievt::MASK & ievt::EDOC) == ievt::EDOC, "overflow?");
72 static_assert((ievt::MASK & ievt::BMAP) == ievt::BMAP, "overflow?");
73 static_assert((ievt::MASK & ievt::EMAP) == ievt::EMAP, "overflow?");
74 static_assert((ievt::MASK & ievt::BSEQ) == ievt::BSEQ, "overflow?");
75 static_assert((ievt::MASK & ievt::ESEQ) == ievt::ESEQ, "overflow?");
76 static_assert((ievt::MASK & ievt::ANCH) == ievt::ANCH, "overflow?");
77 static_assert((ievt::MASK & ievt::ALIA) == ievt::ALIA, "overflow?");
78 static_assert((ievt::MASK & ievt::TAG_) == ievt::TAG_, "overflow?");
79 static_assert((ievt::MASK & ievt::PLAI) == ievt::PLAI, "overflow?");
80 static_assert((ievt::MASK & ievt::SQUO) == ievt::SQUO, "overflow?");
81 static_assert((ievt::MASK & ievt::DQUO) == ievt::DQUO, "overflow?");
82 static_assert((ievt::MASK & ievt::LITL) == ievt::LITL, "overflow?");
83 static_assert((ievt::MASK & ievt::FOLD) == ievt::FOLD, "overflow?");
84 static_assert((ievt::MASK & ievt::FLOW) == ievt::FLOW, "overflow?");
85 static_assert((ievt::MASK & ievt::BLCK) == ievt::BLCK, "overflow?");
86 static_assert((ievt::MASK & ievt::KEY_) == ievt::KEY_, "overflow?");
87 static_assert((ievt::MASK & ievt::VAL_) == ievt::VAL_, "overflow?");
88 static_assert((ievt::MASK & ievt::EXPL) == ievt::EXPL, "overflow?");
89 static_assert((ievt::MASK & ievt::YAML) == ievt::YAML, "overflow?");
90 static_assert((ievt::MASK & ievt::TAGH) == ievt::TAGH, "overflow?");
91 static_assert((ievt::MASK & ievt::TAGP) == ievt::TAGP, "overflow?");
92 static_assert((ievt::MASK & ievt::AREN) == ievt::AREN, "overflow?");
93 static_assert((ievt::MASK & ievt::PSTR) == ievt::PSTR, "overflow?");
94 static_assert((ievt::MASK & ievt::WSTR) == ievt::WSTR, "overflow?");
95 static_assert((ievt::MASK & ievt::LAST) == ievt::LAST, "overflow?");
96 static_assert((ievt::MASK & ievt::JUMP) == ievt::JUMP, "overflow?");
97 static_assert((ievt::MASK & ievt::PJUMP) == ievt::PJUMP, "overflow?");
98 static_assert((ievt::MASK & ievt::UNFILT) == ievt::UNFILT, "overflow?");
99 // NOLINTEND(hicpp-signed-bitwise)
100 
101 } // namespace extra
102 } // namespace yml
103 } // namespace c4
begin doc (+DOC in test suite events)
begin seq (+SEQ in test suite events)
Special flag to mark a scalar as unfiltered (when the parser is set not to filter).
WithSTRing: mask of all events that encode a string following the event. For such events...
C * str
a restricted pointer to the first character of the substring
Definition: substr.hpp:216
scalar: block folded (>)
a mask of all bits in this enumeration
tag directive, handle: \TAG ........
evt_size estimate_events_ints_size(csubstr src)
Read YAML source and, without undergoing a full parse, estimate the size of the integer buffer requir...
unused: reserved for future use (to enable rope-like buffers)
Special flag to enable look-back in the event array. It signifies that the previous event has a strin...
tag directive, prefix: \TAG ........
scalar: block literal (|)
scalar: single-quoted (')
end seq (-SEQ in test suite events)
the last flag defined above
end stream (-STR in test suite events)
size_t len
the length of the substring
Definition: substr.hpp:218
int32_t evt_size
data type for integer events size.
end doc (-DOC in test suite events)
scalar: double-quoted ("")
begin map (+MAP in test suite events)
container: flow: [] for seqs or {} for maps
Special flag to mark events whose string was placed in the arena. This happens when the filtered stri...
--- (with BDOC) or ... (with EDOC)
#define RYML_EXPORT
Definition: export.hpp:18
unused: reserved for future use (same purpose as PSTR, but for JUMP)
end map (-MAP in test suite events)
begin stream (+STR in test suite events)