rapidyaml  0.10.0
parse and emit YAML, and do it fast
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 ParseEngine<extra::EventHandlerInts>;
22 
23 namespace extra {
24 
25 int32_t estimate_events_ints_size(csubstr src)
26 {
27  int32_t 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  // this has strings preceding/following it
33  case ':':
34  case ',': // overestimate, assume map
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 '?':
48  case '\n':
49  count += 3;
50  break;
51  case '[':
52  case ']':
53  count += 4;
54  break;
55  case '{':
56  case '}':
57  count += 7;
58  break;
59  }
60  }
61  return count;
62 }
63 
64 } // namespace extra
65 } // namespace yml
66 } // namespace c4
An event handler that creates an integer buffer with a very compact representation of the YAML tree i...
int32_t estimate_events_ints_size(csubstr src)
Read YAML source and, without undergoing a full parse, estimate the size of the integer buffer requir...
Definition: common.cpp:12