mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2025-01-12 09:49:08 +01:00
Fixed formatting discrepancies
This commit is contained in:
parent
b5af14381c
commit
09196d71bc
@ -26,49 +26,39 @@
|
||||
|
||||
#include <boost/archive/archive_exception.hpp>
|
||||
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/nvp.hpp>
|
||||
#include <boost/serialization/serialization.hpp>
|
||||
#include <boost/serialization/split_free.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template <class Archive>
|
||||
struct std_variant_save_visitor
|
||||
{
|
||||
std_variant_save_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
{}
|
||||
struct std_variant_save_visitor {
|
||||
std_variant_save_visitor(Archive& ar) : m_ar(ar) {}
|
||||
template <class T>
|
||||
void operator()(T const & value) const
|
||||
{
|
||||
void operator()(T const& value) const {
|
||||
m_ar << BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
|
||||
private:
|
||||
Archive& m_ar;
|
||||
};
|
||||
|
||||
|
||||
template <class Archive>
|
||||
struct std_variant_load_visitor
|
||||
{
|
||||
std_variant_load_visitor(Archive& ar) :
|
||||
m_ar(ar)
|
||||
{}
|
||||
struct std_variant_load_visitor {
|
||||
std_variant_load_visitor(Archive& ar) : m_ar(ar) {}
|
||||
template <class T>
|
||||
void operator()(T & value) const
|
||||
{
|
||||
void operator()(T& value) const {
|
||||
m_ar >> BOOST_SERIALIZATION_NVP(value);
|
||||
}
|
||||
|
||||
private:
|
||||
Archive& m_ar;
|
||||
};
|
||||
|
||||
template <class Archive, class... Types>
|
||||
void save(
|
||||
Archive & ar,
|
||||
std::variant<Types...> const & v,
|
||||
unsigned int /*version*/
|
||||
void save(Archive& ar, std::variant<Types...> const& v, unsigned int /*version*/
|
||||
) {
|
||||
const std::size_t which = v.index();
|
||||
ar << BOOST_SERIALIZATION_NVP(which);
|
||||
@ -107,15 +97,9 @@ namespace mp {
|
||||
} // namespace mp
|
||||
|
||||
template <std::size_t N, class Seq>
|
||||
struct variant_impl
|
||||
{
|
||||
struct variant_impl {
|
||||
template <class Archive, class V>
|
||||
static void load (
|
||||
Archive & ar,
|
||||
std::size_t which,
|
||||
V & v,
|
||||
const unsigned int version
|
||||
){
|
||||
static void load(Archive& ar, std::size_t which, V& v, const unsigned int version) {
|
||||
if (which == 0) {
|
||||
// note: A non-intrusive implementation (such as this one)
|
||||
// necessary has to copy the value. This wouldn't be necessary
|
||||
@ -136,48 +120,32 @@ struct variant_impl
|
||||
};
|
||||
|
||||
template <class Seq>
|
||||
struct variant_impl<0, Seq>
|
||||
{
|
||||
struct variant_impl<0, Seq> {
|
||||
template <class Archive, class V>
|
||||
static void load (
|
||||
Archive & /*ar*/,
|
||||
std::size_t /*which*/,
|
||||
V & /*v*/,
|
||||
static void load(Archive& /*ar*/, std::size_t /*which*/, V& /*v*/,
|
||||
const unsigned int /*version*/
|
||||
) {}
|
||||
};
|
||||
|
||||
template <class Archive, class... Types>
|
||||
void load(
|
||||
Archive & ar,
|
||||
std::variant<Types...>& v,
|
||||
const unsigned int version
|
||||
){
|
||||
void load(Archive& ar, std::variant<Types...>& v, const unsigned int version) {
|
||||
std::size_t which;
|
||||
ar >> BOOST_SERIALIZATION_NVP(which);
|
||||
if (which >= sizeof...(Types))
|
||||
// this might happen if a type was removed from the list of variant types
|
||||
boost::serialization::throw_exception(
|
||||
boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unsupported_version
|
||||
)
|
||||
);
|
||||
boost::serialization::throw_exception(boost::archive::archive_exception(
|
||||
boost::archive::archive_exception::unsupported_version));
|
||||
variant_impl<sizeof...(Types), mp::typelist<Types...>>::load(ar, which, v, version);
|
||||
}
|
||||
|
||||
template <class Archive, class... Types>
|
||||
inline void serialize(
|
||||
Archive & ar,
|
||||
std::variant<Types...> & v,
|
||||
const unsigned int file_version
|
||||
){
|
||||
inline void serialize(Archive& ar, std::variant<Types...>& v, const unsigned int file_version) {
|
||||
split_free(ar, v, file_version);
|
||||
}
|
||||
|
||||
// Specialization for std::monostate
|
||||
template <class Archive>
|
||||
void serialize(Archive &ar, std::monostate &, const unsigned int /*version*/)
|
||||
{}
|
||||
void serialize(Archive& ar, std::monostate&, const unsigned int /*version*/) {}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
@ -190,9 +158,7 @@ namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template <class... Types>
|
||||
struct tracking_level<
|
||||
std::variant<Types...>
|
||||
>{
|
||||
struct tracking_level<std::variant<Types...>> {
|
||||
typedef mpl::integral_c_tag tag;
|
||||
typedef mpl::int_<::boost::serialization::track_always> type;
|
||||
BOOST_STATIC_CONSTANT(int, value = type::value);
|
||||
|
Loading…
x
Reference in New Issue
Block a user