#pragma once #include #include #include #include #include #include #include // TODO support custom key types namespace DataStreamAdapters { template struct TslArrayMap { template static void ReadFromDataStream(InputDataStream& stream, tsl::array_map& map) { static_assert(std::is_default_constructible_v); static_assert(std::is_move_constructible_v); uint64_t size; stream.Read(size); map.reserve(size); for (uint64_t i = 0; i < size; ++i) { std::string key; stream.ReadObjectAdapted(key); TValue value; ReadHelper(stream, value); map.insert(key, std::move(value)); } } template static void WriteToDataStream(OutputDataStream& stream, const tsl::array_map& map) { stream.Write((uint64_t)map.size()); for (auto it = map.begin(); it != map.end(); ++it) { stream.WriteObjectAdapted(it.key_sv()); WriteHelper(stream, it.value()); } } }; } // namespace DataStreamAdapters