aboutsummaryrefslogtreecommitdiff
path: root/core/src/Utils/IO/TslRobinIntegration.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Utils/IO/TslRobinIntegration.hpp')
-rw-r--r--core/src/Utils/IO/TslRobinIntegration.hpp54
1 files changed, 15 insertions, 39 deletions
diff --git a/core/src/Utils/IO/TslRobinIntegration.hpp b/core/src/Utils/IO/TslRobinIntegration.hpp
index c800e52..50775fe 100644
--- a/core/src/Utils/IO/TslRobinIntegration.hpp
+++ b/core/src/Utils/IO/TslRobinIntegration.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "Utils/IO/DataStream.hpp"
+#include "Utils/IO/Helper.hpp"
#include <tsl/robin_map.h>
#include <tsl/robin_set.h>
@@ -11,51 +12,34 @@ template <class TKeyAdapter = void, class TValueAdapter = void>
struct TslRobinMap
{
template <class TKey, class TValue>
- static void ReadFromDataStream(InputDataStream& s, tsl::robin_map<TKey, TValue>& map)
+ static void ReadFromDataStream(InputDataStream& stream, tsl::robin_map<TKey, TValue>& map)
{
static_assert(std::is_default_constructible_v<TValue>);
static_assert(std::is_move_constructible_v<TValue>);
uint64_t size;
- s.Read(size);
+ stream.Read(size);
map.reserve(size);
for (uint64_t i = 0; i < size; ++i) {
TKey key;
- if constexpr (std::is_same_v<TKeyAdapter, void>) {
- s.ReadGeneric(key);
- } else {
- s.ReadObjectAdapted<TKeyAdapter>(key);
- }
+ ReadHelper<TKeyAdapter>(stream, key);
TValue value;
- if constexpr (std::is_same_v<TValueAdapter, void>) {
- s.ReadGeneric(value);
- } else {
- s.ReadObjectAdapted<TValueAdapter>(value);
- }
+ ReadHelper<TValueAdapter>(stream, value);
map.insert(std::move(key), std::move(value));
}
}
template <class TKey, class TValue>
- static void WriteToDataStream(OutputDataStream& s, const tsl::robin_map<TKey, TValue>& map)
+ static void WriteToDataStream(OutputDataStream& stream, const tsl::robin_map<TKey, TValue>& map)
{
- s.Write((uint64_t)map.size());
+ stream.Write((uint64_t)map.size());
for (auto it = map.begin(); it != map.end(); ++it) {
- if constexpr (std::is_same_v<TKeyAdapter, void>) {
- s.WriteGeneric(it.key());
- } else {
- s.WriteObjectAdapted<TKeyAdapter>(it.key());
- }
-
- if constexpr (std::is_same_v<TValueAdapter, void>) {
- s.WriteGeneric(it.value());
- } else {
- s.WriteObjectAdapted<TValueAdapter>(it.value());
- }
+ WriteHelper<TKeyAdapter>(stream, it.key());
+ WriteHelper<TValueAdapter>(stream, it.value());
}
}
};
@@ -64,38 +48,30 @@ template <class TAdapter = void>
struct TslRobinSet
{
template <class TElement>
- static void ReadFromDataStream(InputDataStream& s, tsl::robin_set<TElement>& set)
+ static void ReadFromDataStream(InputDataStream& stream, tsl::robin_set<TElement>& set)
{
static_assert(std::is_default_constructible_v<TElement>);
static_assert(std::is_move_constructible_v<TElement>);
uint64_t size;
- s.Read(size);
+ stream.Read(size);
set.reserve(size);
for (uint64_t i = 0; i < size; ++i) {
TElement element;
- if constexpr (std::is_same_v<TAdapter, void>) {
- s.ReadGeneric(element);
- } else {
- s.ReadObjectAdapted<TAdapter>(element);
- }
+ ReadHelper<TAdapter>(stream, element);
set.insert(std::move(element));
}
}
template <class TElement>
- static void WriteToDataStream(OutputDataStream& s, const tsl::array_set<TElement>& set)
+ static void WriteToDataStream(OutputDataStream& stream, const tsl::robin_set<TElement>& set)
{
- s.Write((uint64_t)set.size());
+ stream.Write((uint64_t)set.size());
for (auto& element : set) {
- if constexpr (std::is_same_v<TAdapter, void>) {
- s.WriteGeneric(element);
- } else {
- s.WriteObjectAdapted<TAdapter>(element);
- }
+ WriteHelper<TAdapter>(stream, element);
}
}
};