rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
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
17namespace c4 {
18namespace yml {
19
20// instantiate the template
22
23namespace 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
68static_assert((ievt::MASK & ievt::BSTR) == ievt::BSTR, "overflow?");
69static_assert((ievt::MASK & ievt::ESTR) == ievt::ESTR, "overflow?");
70static_assert((ievt::MASK & ievt::BDOC) == ievt::BDOC, "overflow?");
71static_assert((ievt::MASK & ievt::EDOC) == ievt::EDOC, "overflow?");
72static_assert((ievt::MASK & ievt::BMAP) == ievt::BMAP, "overflow?");
73static_assert((ievt::MASK & ievt::EMAP) == ievt::EMAP, "overflow?");
74static_assert((ievt::MASK & ievt::BSEQ) == ievt::BSEQ, "overflow?");
75static_assert((ievt::MASK & ievt::ESEQ) == ievt::ESEQ, "overflow?");
76static_assert((ievt::MASK & ievt::ANCH) == ievt::ANCH, "overflow?");
77static_assert((ievt::MASK & ievt::ALIA) == ievt::ALIA, "overflow?");
78static_assert((ievt::MASK & ievt::TAG_) == ievt::TAG_, "overflow?");
79static_assert((ievt::MASK & ievt::PLAI) == ievt::PLAI, "overflow?");
80static_assert((ievt::MASK & ievt::SQUO) == ievt::SQUO, "overflow?");
81static_assert((ievt::MASK & ievt::DQUO) == ievt::DQUO, "overflow?");
82static_assert((ievt::MASK & ievt::LITL) == ievt::LITL, "overflow?");
83static_assert((ievt::MASK & ievt::FOLD) == ievt::FOLD, "overflow?");
84static_assert((ievt::MASK & ievt::FLOW) == ievt::FLOW, "overflow?");
85static_assert((ievt::MASK & ievt::BLCK) == ievt::BLCK, "overflow?");
86static_assert((ievt::MASK & ievt::KEY_) == ievt::KEY_, "overflow?");
87static_assert((ievt::MASK & ievt::VAL_) == ievt::VAL_, "overflow?");
88static_assert((ievt::MASK & ievt::EXPL) == ievt::EXPL, "overflow?");
89static_assert((ievt::MASK & ievt::YAML) == ievt::YAML, "overflow?");
90static_assert((ievt::MASK & ievt::TAGH) == ievt::TAGH, "overflow?");
91static_assert((ievt::MASK & ievt::TAGP) == ievt::TAGP, "overflow?");
92static_assert((ievt::MASK & ievt::AREN) == ievt::AREN, "overflow?");
93static_assert((ievt::MASK & ievt::PSTR) == ievt::PSTR, "overflow?");
94static_assert((ievt::MASK & ievt::WSTR) == ievt::WSTR, "overflow?");
95static_assert((ievt::MASK & ievt::LAST) == ievt::LAST, "overflow?");
96static_assert((ievt::MASK & ievt::JUMP) == ievt::JUMP, "overflow?");
97static_assert((ievt::MASK & ievt::PJUMP) == ievt::PJUMP, "overflow?");
98static_assert((ievt::MASK & ievt::UNFILT) == ievt::UNFILT, "overflow?");
99// NOLINTEND(hicpp-signed-bitwise)
100
101} // namespace extra
102} // namespace yml
103} // namespace c4
This is the main driver of parsing logic: it scans the YAML or JSON source for tokens,...
An event handler that creates an integer buffer with a very compact representation of the YAML tree i...
#define RYML_EXPORT
Definition export.hpp:18
int32_t evt_size
data type for integer events size.
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...
basic_substring< const char > csubstr
an immutable string view
Definition substr.hpp:2356
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