#ifndef SERIALIZATION_HPP_U2YGHSPB #define SERIALIZATION_HPP_U2YGHSPB #include #include #include #include namespace vanetza { template void serialize(OutputArchive& ar, EndianType value) { typedef typename decltype(value)::network_type network_type; T tmp = static_cast(value).get(); ar << tmp; } template void deserialize(InputArchive& ar, EndianType& value) { T tmp; ar >> tmp; value = network_cast(tmp); } template typename std::enable_if::value>::type serialize(OutputArchive& ar, T value) { auto tmp = hton(value); ar << tmp; } template typename std::enable_if::value>::type deserialize(InputArchive& ar, T& value) { T tmp; ar >> tmp; value = ntoh(tmp); } template void serialize(OutputArchive& ar, boost::units::quantity q) { static_assert(std::is_integral::value, "Only integral based quantities are supported"); auto tmp = hton(q.value()); ar << tmp; } template void deserialize(InputArchive& ar, boost::units::quantity& q) { static_assert(std::is_integral::value, "Only integral based quantities are supported"); T tmp; ar >> tmp; q = boost::units::quantity::from_value(ntoh(tmp)); } template typename std::enable_if::value>::type serialize(OutputArchive& ar, const T& t) { serialize(ar, host_cast(static_cast::type const>(t))); } template typename std::enable_if::value>::type deserialize(InputArchive& ar, T& t) { typename std::underlying_type::type tmp; deserialize(ar, tmp); t = static_cast(tmp); } } // namespace vanetza #endif /* SERIALIZATION_HPP_U2YGHSPB */