rapidyaml  0.13.0
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 
20 /** Create a testsuite event string from integer events.
21  *
22  * This overload receives a buffer where the string is to be written,
23  * and returns the size needed to accomodate the result. The size of
24  * the buffer is strictly respected. The caller must check that the
25  * returned size is smaller than the buffer's size to ensure that the
26  * result is complete. If that's not the case, the user must resize
27  * the buffer and call again. */
28 C4_NODISCARD RYML_EXPORT
29 size_t events_ints_to_testsuite(csubstr parsed_yaml,
30  csubstr arena,
31  ievt::DataType const* evts_ints,
32  ievt::DataType evts_ints_sz,
33  substr evts_testsuite);
34 
35 
36 /** Create a testsuite event string from integer events, writing into
37  * an output container. */
38 template<class Container>
39 void events_ints_to_testsuite(csubstr parsed_yaml,
40  csubstr arena,
41  ievt::DataType const* evts_ints,
42  ievt::DataType evts_ints_sz,
43  Container *evts_testsuite)
44 {
45  size_t len = events_ints_to_testsuite(parsed_yaml, arena, evts_ints, evts_ints_sz, to_substr(*evts_testsuite));
46  if(len > evts_testsuite->size())
47  {
48  evts_testsuite->resize(len);
49  len = events_ints_to_testsuite(parsed_yaml, arena, evts_ints, evts_ints_sz, to_substr(*evts_testsuite));
50  }
51  evts_testsuite->resize(len);
52 }
53 
54 
55 /** Create a testsuite event string from integer events, returning a
56  * new container with the result. */
57 template<class Container>
58 Container events_ints_to_testsuite(csubstr parsed_yaml,
59  csubstr arena,
60  ievt::DataType const* evts_ints,
61  ievt::DataType evts_ints_sz)
62 {
63  Container ret;
64  events_ints_to_testsuite(parsed_yaml, arena, evts_ints, evts_ints_sz, &ret);
65  return ret;
66 }
67 
68 /** @} */
69 
70 } // namespace extra
71 } // namespace yml
72 } // namespace c4
73 
74 #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:18
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:2202
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