From 7fe47a9d5b1727a61dc724523b530762f6d6ba19 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Thu, 30 Jun 2022 21:38:53 -0700 Subject: Restructure project --- app/source/Cplt/Utils/IO/VectorIntegration.hpp | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 app/source/Cplt/Utils/IO/VectorIntegration.hpp (limited to 'app/source/Cplt/Utils/IO/VectorIntegration.hpp') diff --git a/app/source/Cplt/Utils/IO/VectorIntegration.hpp b/app/source/Cplt/Utils/IO/VectorIntegration.hpp new file mode 100644 index 0000000..93967f6 --- /dev/null +++ b/app/source/Cplt/Utils/IO/VectorIntegration.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include +#include + +#include +#include + +namespace DataStreamAdapters { +template +struct Vector +{ + template + static void ReadFromDataStream(InputDataStream& stream, std::vector& vec) + { + static_assert(std::is_default_constructible_v); + static_assert(std::is_move_constructible_v); + + uint64_t size; + stream.Read(size); + + vec.clear(); + vec.reserve(size); + + for (uint64_t i = 0; i < size; ++i) { + TElement element; + ReadHelper(stream, element); + + vec.push_back(std::move(element)); + } + } + + template + static void WriteToDataStream(OutputDataStream& stream, const std::vector& vec) + { + stream.Write((uint64_t)vec.size()); + for (auto& element : vec) { + WriteHelper(stream, element); + } + } +}; +} // namespace DataStreamAdapters -- cgit v1.2.3-70-g09d2