2020-03-31 16:54:28 +00:00
|
|
|
// Copyright 2020 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <boost/icl/interval_set.hpp>
|
2020-03-31 17:27:33 +00:00
|
|
|
#include <boost/serialization/split_free.hpp>
|
2020-03-31 16:54:28 +00:00
|
|
|
#include "common/serialization/boost_discrete_interval.hpp"
|
|
|
|
|
|
|
|
namespace boost::serialization {
|
|
|
|
|
|
|
|
template <class Archive, class T>
|
2020-03-31 17:27:33 +00:00
|
|
|
void save(Archive& ar, const boost::icl::interval_set<T>& set, const unsigned int file_version) {
|
2020-04-01 21:06:22 +00:00
|
|
|
ar << static_cast<u64>(set.iterative_size());
|
2020-03-31 17:27:33 +00:00
|
|
|
for (auto& v : set) {
|
|
|
|
ar << v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Archive, class T>
|
|
|
|
void load(Archive& ar, boost::icl::interval_set<T>& set, const unsigned int file_version) {
|
|
|
|
u64 count{};
|
|
|
|
ar >> count;
|
|
|
|
set.clear();
|
|
|
|
for (u64 i = 0; i < count; i++) {
|
2020-04-01 21:06:22 +00:00
|
|
|
typename boost::icl::interval_set<T>::interval_type value{};
|
2020-03-31 17:27:33 +00:00
|
|
|
ar >> value;
|
2020-04-10 15:51:01 +00:00
|
|
|
set += value;
|
2020-03-31 17:27:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Archive, class T>
|
|
|
|
void serialize(Archive& ar, boost::icl::interval_set<T>& set, const unsigned int file_version) {
|
|
|
|
boost::serialization::split_free(ar, set, file_version);
|
2020-03-31 16:54:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace boost::serialization
|