aboutsummaryrefslogtreecommitdiff
path: root/core/src/Utils/IO/TslArrayIntegration.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/Utils/IO/TslArrayIntegration.hpp')
-rw-r--r--core/src/Utils/IO/TslArrayIntegration.hpp26
1 files changed, 9 insertions, 17 deletions
diff --git a/core/src/Utils/IO/TslArrayIntegration.hpp b/core/src/Utils/IO/TslArrayIntegration.hpp
index eebea02..af1197c 100644
--- a/core/src/Utils/IO/TslArrayIntegration.hpp
+++ b/core/src/Utils/IO/TslArrayIntegration.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "Utils/IO/DataStream.hpp"
+#include "Utils/IO/Helper.hpp"
#include "Utils/IO/StringIntegration.hpp"
#include <tsl/array_map.h>
@@ -15,43 +16,34 @@ template <class TAdapter = void>
struct TslArrayMap
{
template <class TValue>
- static void ReadFromDataStream(InputDataStream& s, tsl::robin_map<char, TValue>& map)
+ static void ReadFromDataStream(InputDataStream& stream, tsl::array_map<char, 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) {
std::string key;
- s.ReadObjectAdapted<DataStreamAdapters::String>(key);
+ stream.ReadObjectAdapted<DataStreamAdapters::String>(key);
TValue value;
- if constexpr (std::is_same_v<TAdapter, void>) {
- s.ReadGeneric(value);
- } else {
- s.ReadObjectAdapted<TAdapter>(value);
- }
+ ReadHelper<TAdapter>(stream, value);
map.insert(key, std::move(value));
}
}
template <class TValue>
- static void WriteToDataStream(OutputDataStream& s, const tsl::robin_map<char, TValue>& map)
+ static void WriteToDataStream(OutputDataStream& stream, const tsl::array_map<char, TValue>& map)
{
- s.Write((uint64_t)map.size());
+ stream.Write((uint64_t)map.size());
for (auto it = map.begin(); it != map.end(); ++it) {
- s.WriteObjectAdapted<DataStreamAdapters::StringView>(it.key_sv());
-
- if constexpr (std::is_same_v<TAdapter, void>) {
- s.WriteGeneric(it.value());
- } else {
- s.WriteObjectAdapted<TAdapter>(it.value());
- }
+ stream.WriteObjectAdapted<DataStreamAdapters::StringView>(it.key_sv());
+ WriteHelper<TAdapter>(stream, it.value());
}
}
};