20 #ifndef _XDRC_AUTOCHECK_H_HEADER_INCLUDED_ 21 #define _XDRC_AUTOCHECK_H_HEADER_INCLUDED_ 1 23 #include <autocheck/autocheck.hpp> 28 #ifndef XDR_AUTOCHECK_FUZZY_STRINGS 32 #define XDR_AUTOCHECK_FUZZY_STRINGS 1 33 #endif // !XDR_AUTOCHECK_FUZZY_STRINGS 51 template<
typename T> constexpr T
54 return u <= std::numeric_limits<T>::max() ? u :
55 u + (std::numeric_limits<T>::min() - std::numeric_limits<T>::max());
57 template<> constexpr uint8_t
58 to_int8<uint8_t>(uint8_t u)
67 Constexpr
explicit generator_t(std::size_t size) : size_(size) {}
72 template<
typename T>
typename 73 std::enable_if<(std::is_same<T, char>::value
74 || std::is_same<T, std::uint8_t>::value)>::type
75 operator()(T &t)
const {
76 #if XDR_AUTOCHECK_FUZZY_STRINGS 77 t = detail::to_int8<T>(uint8_t(autocheck::generator<int>{}(0x10000)));
78 #else // !XDR_AUTOCHECK_FUZZY_STRINGS 79 t = detail::to_int8<T>(autocheck::generator<T>{}(size_));
80 #endif // !XDR_AUTOCHECK_FUZZY_STRINGS 83 template<
typename T>
typename 84 std::enable_if<xdr_traits<T>::is_numeric>::type
85 operator()(T &t)
const { t = autocheck::generator<T>{}(size_); }
87 template<
typename T>
typename 88 std::enable_if<xdr_traits<T>::is_enum>::type
89 operator()(T &t)
const {
93 template<
typename T>
typename 94 std::enable_if<xdr_traits<T>::is_struct>::type
97 template<
typename T>
typename 98 std::enable_if<xdr_traits<T>::is_union>::type
99 operator()(T &t)
const {
100 const auto &vals = T::_xdr_discriminant_values();
103 v = autocheck::generator<decltype(v)>{}(size_);
105 size_t n = autocheck::generator<size_t>{}(size_);
106 v = vals[n % vals.size()];
108 t._xdr_discriminant(v,
false);
113 inline size_t elt_size()
const {
return size_ >> 1; }
115 template<
typename T>
typename 116 std::enable_if<xdr_traits<T>::variable_nelem ==
true>::type
117 operator()(T &t)
const {
118 t.resize(autocheck::generator<std::uint32_t>{}(size_) % t.max_size());
119 generator_t g(elt_size());
124 template<
typename T>
typename 125 std::enable_if<xdr_traits<T>::variable_nelem ==
false>::type
126 operator()(T &t)
const {
127 generator_t g(elt_size());
132 template<
typename T>
void 134 if (autocheck::generator<std::uint32_t>{}(size_)) {
135 generator_t g(elt_size());
136 archive(g, t.activate());
147 template<
typename T>
class generator<
148 T, typename std::enable_if<xdr::xdr_traits<T>::valid
149 && !xdr::xdr_traits<T>::is_numeric>::type> {
151 using result_type = T;
152 result_type operator()(
size_t size)
const {
162 #endif // !_XDRC_AUTOCHECK_H_HEADER_INCLUDED_ Type definitions for xdrc compiler output.
Most of the xdrpp library is encapsulated in the xdr namespace.
Optional data (represented with pointer notation in XDR source).
void archive(Archive &ar, T &&t, const char *name=nullptr)
By default, this function simply applies ar (which must be a function object) to t.
Metadata for all marshalable XDR types.
Constexpr const field_archiver_t field_archiver
Passed to _xdr_with_mem_ptr to archive the active union field.