3 #include "hate/type_list.h"
4 #include "hate/visibility.h"
7 #include <cereal/macros.hpp>
9 #if defined(__GENPYBIND__) or defined(__GENPYBIND_GENERATED__)
10 #include <pybind11/pybind11.h>
16 class JSONOutputArchive;
17 class JSONInputArchive;
18 class PortableBinaryOutputArchive;
19 class PortableBinaryInputArchive;
38 #if defined(__GENPYBIND__) or defined(__GENPYBIND_GENERATED__)
39 template <
typename... Ts>
40 struct WrapToFromFunctions
42 static void apply(pybind11::module& m)
45 (m.def(
"to_json", &haldls::vx::to_json<Ts>), ...);
46 (m.def(
"from_json", &haldls::vx::from_json<Ts>), ...);
48 (m.def(
"to_portablebinary", [](Ts
const& t) {
49 return pybind11::bytes(haldls::vx::to_portablebinary<Ts>(t));
52 (m.def(
"from_portablebinary", &haldls::vx::from_portablebinary<Ts>), ...);
56 template <
typename... Ts>
57 struct WrapToFromFunctions<hate::type_list<Ts...>>
59 static void apply(pybind11::module& m)
61 WrapToFromFunctions<Ts...>::apply(m);
75 #define EXTERN_INSTANTIATE_CEREAL_SERIALIZE(CLASS_NAME) \
76 extern template SYMBOL_VISIBLE void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
77 cereal::JSONOutputArchive&, std::uint32_t const); \
78 extern template SYMBOL_VISIBLE void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
79 cereal::JSONInputArchive&, std::uint32_t const); \
80 extern template SYMBOL_VISIBLE void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
81 cereal::PortableBinaryOutputArchive&, std::uint32_t const); \
82 extern template SYMBOL_VISIBLE void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
83 cereal::PortableBinaryInputArchive&, std::uint32_t const); \
84 extern template SYMBOL_VISIBLE std::string haldls::vx::to_json(CLASS_NAME const&); \
85 extern template SYMBOL_VISIBLE std::string haldls::vx::to_portablebinary(CLASS_NAME const&); \
86 extern template SYMBOL_VISIBLE void haldls::vx::from_json(CLASS_NAME&, std::string const&); \
87 extern template SYMBOL_VISIBLE void haldls::vx::from_portablebinary( \
88 CLASS_NAME&, std::string const&);
90 #define EXPLICIT_INSTANTIATE_CEREAL_SERIALIZE(CLASS_NAME) \
91 template void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
92 cereal::JSONOutputArchive&, std::uint32_t const); \
93 template void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
94 cereal::JSONInputArchive&, std::uint32_t const); \
95 template void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
96 cereal::PortableBinaryOutputArchive&, std::uint32_t const); \
97 template void CLASS_NAME ::CEREAL_SERIALIZE_FUNCTION_NAME( \
98 cereal::PortableBinaryInputArchive&, std::uint32_t const); \
99 template std::string haldls::vx::to_json(CLASS_NAME const&); \
100 template std::string haldls::vx::to_portablebinary(CLASS_NAME const&); \
101 template void haldls::vx::from_json(CLASS_NAME&, std::string const&); \
102 template void haldls::vx::from_portablebinary(CLASS_NAME&, std::string const&);
104 #define EXTERN_INSTANTIATE_CEREAL_SERIALIZE_FREE(CLASS_NAME) \
105 extern template SYMBOL_VISIBLE void cereal::CEREAL_SERIALIZE_FUNCTION_NAME( \
106 cereal::JSONOutputArchive&, CLASS_NAME&); \
107 extern template SYMBOL_VISIBLE void cereal::CEREAL_SERIALIZE_FUNCTION_NAME( \
108 cereal::JSONInputArchive&, CLASS_NAME&); \
109 extern template SYMBOL_VISIBLE void cereal::CEREAL_SERIALIZE_FUNCTION_NAME( \
110 cereal::PortableBinaryOutputArchive&, CLASS_NAME&); \
111 extern template SYMBOL_VISIBLE void cereal::CEREAL_SERIALIZE_FUNCTION_NAME( \
112 cereal::PortableBinaryInputArchive&, CLASS_NAME&); \
113 extern template SYMBOL_VISIBLE std::string haldls::vx::to_json(CLASS_NAME const&); \
114 extern template SYMBOL_VISIBLE std::string haldls::vx::to_portablebinary(CLASS_NAME const&); \
115 extern template SYMBOL_VISIBLE void haldls::vx::from_json(CLASS_NAME&, std::string const&); \
116 extern template SYMBOL_VISIBLE void haldls::vx::from_portablebinary( \
117 CLASS_NAME&, std::string const&);
119 #define EXPLICIT_INSTANTIATE_CEREAL_SERIALIZE_FREE(CLASS_NAME) \
120 template void cereal::CEREAL_SERIALIZE_FUNCTION_NAME(cereal::JSONOutputArchive&, CLASS_NAME&); \
121 template void cereal::CEREAL_SERIALIZE_FUNCTION_NAME(cereal::JSONInputArchive&, CLASS_NAME&); \
122 template void cereal::CEREAL_SERIALIZE_FUNCTION_NAME( \
123 cereal::PortableBinaryOutputArchive&, CLASS_NAME&); \
124 template void cereal::CEREAL_SERIALIZE_FUNCTION_NAME( \
125 cereal::PortableBinaryInputArchive&, CLASS_NAME&); \
126 template std::string haldls::vx::to_json(CLASS_NAME const&); \
127 template std::string haldls::vx::to_portablebinary(CLASS_NAME const&); \
128 template void haldls::vx::from_json(CLASS_NAME&, std::string const&); \
129 template void haldls::vx::from_portablebinary(CLASS_NAME&, std::string const&);
std::string to_portablebinary(T const &t)
void from_portablebinary(T &t, std::string const &s)
void from_json(T &t, std::string const &s)
std::string to_json(T const &t)