rapidyaml  0.12.1
parse and emit YAML, and do it fast
ints_to_testsuite.hpp
Go to the documentation of this file.
1 #ifndef _C4_YML_EXTRA_INTS_TO_TESTSUITE_HPP_
2 #define _C4_YML_EXTRA_INTS_TO_TESTSUITE_HPP_
3 
4 #ifndef _C4_YML_EXTRA_EVENT_HANDLER_INTS_HPP_
6 #endif
7 
8 
9 //-----------------------------------------------------------------------------
10 
11 namespace c4 {
12 namespace yml {
13 namespace extra {
14 
15 
16 /** @addtogroup doc_event_handlers
17  * @{ */
18 
19 /** Create a testsuite event string from integer events.
20  *
21  * This overload receives a buffer where the string should be written,
22  * and returns the size needed for the buffer. If that size is larger
23  * than the buffer's size, the user must resize the buffer and call
24  * again. */
25 RYML_EXPORT C4_NODISCARD
26 size_t events_ints_to_testsuite(csubstr parsed_yaml,
27  csubstr arena,
28  ievt::DataType const* evts_ints,
29  ievt::DataType evts_ints_sz,
30  substr evts_testsuite);
31 
32 /** Create a testsuite event string from integer events, writing into
33  * an output container. */
34 template<class Container>
35 void events_ints_to_testsuite(csubstr parsed_yaml,
36  csubstr arena,
37  ievt::DataType const* evts_ints,
38  ievt::DataType evts_ints_sz,
39  Container *evts_testsuite)
40 {
41  size_t len = events_ints_to_testsuite(parsed_yaml, arena, evts_ints, evts_ints_sz, to_substr(*evts_testsuite));
42  if(len > evts_testsuite->size())
43  {
44  evts_testsuite->resize(len);
45  len = events_ints_to_testsuite(parsed_yaml, arena, evts_ints, evts_ints_sz, to_substr(*evts_testsuite));
46  }
47  evts_testsuite->resize(len);
48 }
49 
50 /** Create a testsuite event string from integer events, returning a
51  * new container with the result. */
52 template<class Container>
53 Container events_ints_to_testsuite(csubstr parsed_yaml,
54  csubstr arena,
55  ievt::DataType const* evts_ints,
56  ievt::DataType evts_ints_sz)
57 {
58  Container ret;
59  events_ints_to_testsuite(parsed_yaml, arena, evts_ints, evts_ints_sz, &ret);
60  return ret;
61 }
62 
63 /** @} */
64 
65 } // namespace extra
66 } // namespace yml
67 } // namespace c4
68 
69 #endif /* _C4_YML_EXTRA_INTS_TO_TESTSUITE_UTILS_HPP_ */
An event handler that creates an integer buffer with a very compact representation of the YAML tree i...
#define RYML_EXPORT
Definition: export.hpp:15
size_t events_ints_to_testsuite(csubstr parsed_yaml, csubstr arena, ievt::DataType const *evts_ints, ievt::DataType evts_ints_sz, substr evts_test_suite)
Create a testsuite event string from integer events.
substr to_substr(substr s) noexcept
neutral version for use in generic code
Definition: substr.hpp:2208
int32_t DataType
data type for integer events.
(Undefined by default) Use shorter error message from checks/asserts: do not show the check condition...
Definition: common.cpp:14