2019-08-12 18:01:33 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <boost/container/flat_set.hpp>
|
|
|
|
#include <boost/serialization/split_free.hpp>
|
2019-12-27 22:07:29 +01:00
|
|
|
#include "common/common_types.h"
|
2019-08-12 18:01:33 +02:00
|
|
|
|
|
|
|
namespace boost::serialization {
|
|
|
|
|
|
|
|
template <class Archive, class T>
|
2019-12-27 22:07:29 +01:00
|
|
|
void save(Archive& ar, const boost::container::flat_set<T>& set, const unsigned int file_version) {
|
2019-08-12 18:01:33 +02:00
|
|
|
ar << static_cast<u64>(set.size());
|
2019-12-27 22:07:29 +01:00
|
|
|
for (auto& v : set) {
|
2019-08-12 18:01:33 +02:00
|
|
|
ar << v;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Archive, class T>
|
2019-12-27 22:07:29 +01:00
|
|
|
void load(Archive& ar, boost::container::flat_set<T>& set, const unsigned int file_version) {
|
2019-08-12 18:01:33 +02:00
|
|
|
u64 count{};
|
|
|
|
ar >> count;
|
|
|
|
set.clear();
|
2020-03-29 12:39:46 +02:00
|
|
|
for (u64 i = 0; i < count; i++) {
|
2019-08-12 18:01:33 +02:00
|
|
|
T value{};
|
|
|
|
ar >> value;
|
|
|
|
set.insert(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Archive, class T>
|
2019-12-27 22:07:29 +01:00
|
|
|
void serialize(Archive& ar, boost::container::flat_set<T>& set, const unsigned int file_version) {
|
2019-08-12 18:01:33 +02:00
|
|
|
boost::serialization::split_free(ar, set, file_version);
|
|
|
|
}
|
|
|
|
|
2019-12-27 22:07:29 +01:00
|
|
|
} // namespace boost::serialization
|