diff options
author | rtk0c <[email protected]> | 2021-09-06 00:15:35 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-09-06 00:15:35 -0700 |
commit | 04653742243e4bb6452108cfd0fef2f4afd8f23b (patch) | |
tree | a4a5e0cc8d16ffe78859fab9ee5e487a7d22d81e /core/src/Utils/IO/TslArrayIntegration.hpp | |
parent | 70e00f817e9596a746800ba4afec2b7c4ca25142 (diff) |
Fix all compile errors, remove OperateIOProxy requirement from DataStream api
Diffstat (limited to 'core/src/Utils/IO/TslArrayIntegration.hpp')
-rw-r--r-- | core/src/Utils/IO/TslArrayIntegration.hpp | 26 |
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()); } } }; |