rapidyaml  0.16.0
parseandemitYAML,anddoitfast
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_ints
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::evt_bits const* evts_ints,
32  ievt::evt_bits 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>
40  csubstr arena,
41  ievt::evt_bits const* evts_ints,
42  ievt::evt_bits 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::evt_bits const* evts_ints,
61  ievt::evt_bits 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 } // LCOV_EXCL_LINE
67 
68 /** @} */
69 
70 } // namespace extra
71 } // namespace yml
72 } // namespace c4
73 
74 #endif /* C4_YML_EXTRA_INTS_TO_TESTSUITE_UTILS_HPP_ */
substr to_substr(char(&s)[N]) noexcept
Definition: substr.hpp:2376
basic_substring< char > substr
a mutable string view
Definition: substr.hpp:2355
basic_substring< const char > csubstr
an immutable string view
Definition: substr.hpp:2356
size_t events_ints_to_testsuite(csubstr parsed_yaml, csubstr arena, ievt::evt_bits const *evts_ints, ievt::evt_bits evts_ints_sz, substr evts_test_suite)
Create a testsuite event string from integer events.
int32_t evt_bits
data type for integer events bits.
#define RYML_EXPORT
Definition: export.hpp:18