diff options
Diffstat (limited to 'app/source/Cplt/Utils/IO')
-rw-r--r-- | app/source/Cplt/Utils/IO/Archive.cpp | 9 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/Archive.hpp | 3 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/CstdioFile.cpp | 6 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/CstdioFile.hpp | 3 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/DataStream.cpp | 108 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/DataStream.hpp | 69 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/FileStream.hpp | 15 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/Helper.hpp | 6 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/StringIntegration.hpp | 15 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/TslArrayIntegration.hpp | 9 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/TslRobinIntegration.hpp | 18 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/UuidIntegration.hpp | 9 | ||||
-rw-r--r-- | app/source/Cplt/Utils/IO/VectorIntegration.hpp | 9 |
13 files changed, 93 insertions, 186 deletions
diff --git a/app/source/Cplt/Utils/IO/Archive.cpp b/app/source/Cplt/Utils/IO/Archive.cpp index f6e7b27..2be18bc 100644 --- a/app/source/Cplt/Utils/IO/Archive.cpp +++ b/app/source/Cplt/Utils/IO/Archive.cpp @@ -10,13 +10,11 @@ constexpr uint8_t kByteOrderMark = []() { } }(); -std::span<const uint8_t, 8> DataArchive::GetMagicNumbers() -{ +std::span<const uint8_t, 8> DataArchive::GetMagicNumbers() { return std::span<const uint8_t, 8>{ kMagicNumbers }; } -std::optional<InputDataStream> DataArchive::LoadFile(const std::filesystem::path& path) -{ +std::optional<InputDataStream> DataArchive::LoadFile(const std::filesystem::path& path) { InputFileStream fileStream(path); fileStream.SetReadInSize(1024); InputDataStream stream(std::move(fileStream)); @@ -42,8 +40,7 @@ std::optional<InputDataStream> DataArchive::LoadFile(const std::filesystem::path return stream; } -std::optional<OutputDataStream> DataArchive::SaveFile(const std::filesystem::path& path) -{ +std::optional<OutputDataStream> DataArchive::SaveFile(const std::filesystem::path& path) { OutputFileStream fileStream(path, OutputFileStream::TruncateFile); fileStream.SetMaxBufferSize(1024); OutputDataStream stream(std::move(fileStream)); diff --git a/app/source/Cplt/Utils/IO/Archive.hpp b/app/source/Cplt/Utils/IO/Archive.hpp index 7632f3b..179db25 100644 --- a/app/source/Cplt/Utils/IO/Archive.hpp +++ b/app/source/Cplt/Utils/IO/Archive.hpp @@ -7,8 +7,7 @@ #include <optional> #include <span> -class DataArchive -{ +class DataArchive { public: static std::span<const uint8_t, 8> GetMagicNumbers(); diff --git a/app/source/Cplt/Utils/IO/CstdioFile.cpp b/app/source/Cplt/Utils/IO/CstdioFile.cpp index c414dfb..0496fa1 100644 --- a/app/source/Cplt/Utils/IO/CstdioFile.cpp +++ b/app/source/Cplt/Utils/IO/CstdioFile.cpp @@ -12,8 +12,7 @@ #endif namespace CPLT_UNITY_ID { -auto GetModeString(FileUtils::IoMode mode) -{ +auto GetModeString(FileUtils::IoMode mode) { switch (mode) { case FileUtils::IM_Read: return MODE_STRING("rb"); case FileUtils::IM_WriteAppend: return MODE_STRING("ab"); @@ -25,8 +24,7 @@ auto GetModeString(FileUtils::IoMode mode) #pragma pop_macro("MODE_STRING") -FILE* FileUtils::OpenCstdioFile(const std::filesystem::path& path, IoMode mode) -{ +FILE* FileUtils::OpenCstdioFile(const std::filesystem::path& path, IoMode mode) { #ifdef _WIN32 // std::filesystem::path::c_str() returns `const wchar_t*` under Windows, because NT uses UTF-16 natively return _wfopen(path.c_str(), ::GetModeString(mode)); diff --git a/app/source/Cplt/Utils/IO/CstdioFile.hpp b/app/source/Cplt/Utils/IO/CstdioFile.hpp index e863dd5..32957a2 100644 --- a/app/source/Cplt/Utils/IO/CstdioFile.hpp +++ b/app/source/Cplt/Utils/IO/CstdioFile.hpp @@ -5,8 +5,7 @@ namespace FileUtils { -enum IoMode -{ +enum IoMode { IM_Read, IM_WriteAppend, IM_WriteTruncate, diff --git a/app/source/Cplt/Utils/IO/DataStream.cpp b/app/source/Cplt/Utils/IO/DataStream.cpp index c0797e3..14afa04 100644 --- a/app/source/Cplt/Utils/IO/DataStream.cpp +++ b/app/source/Cplt/Utils/IO/DataStream.cpp @@ -11,15 +11,13 @@ static_assert(std::endian::native == std::endian::little || std::endian::native // Reading/writing signed integer byte-by-byte is fine, since the representation got fixed to 2's complements in C++20 -static uint16_t ByteSwap(uint16_t n) -{ +static uint16_t ByteSwap(uint16_t n) { auto bytes = reinterpret_cast<std::byte*>(n); std::swap(bytes[0], bytes[1]); return n; } -static uint32_t ByteSwap(uint32_t n) -{ +static uint32_t ByteSwap(uint32_t n) { #ifdef _MSC_VER return _byteswap_ulong(n); #else @@ -27,8 +25,7 @@ static uint32_t ByteSwap(uint32_t n) #endif } -static uint64_t ByteSwap(uint64_t n) -{ +static uint64_t ByteSwap(uint64_t n) { #ifdef _MSC_VER return _byteswap_uint64(n); #else @@ -37,57 +34,47 @@ static uint64_t ByteSwap(uint64_t n) } template <class TSigned> -static TSigned ByteSwap(TSigned n) -{ +static TSigned ByteSwap(TSigned n) { using Unsigned = std::make_unsigned_t<TSigned>; auto swapped = ::ByteSwap(std::bit_cast<Unsigned>(n)); return std::bit_cast<TSigned>(swapped); } -std::endian BaseDataStream::GetEndianness() const -{ +std::endian BaseDataStream::GetEndianness() const { return mEndian; } -void BaseDataStream::SetEndianness(std::endian endianness) -{ +void BaseDataStream::SetEndianness(std::endian endianness) { mEndian = endianness; } InputDataStream::InputDataStream(InputFileStream stream) - : mBackend{ std::move(stream) } -{ + : mBackend{ std::move(stream) } { } -void InputDataStream::ReadBytes(size_t byteCount, std::byte* buffer) -{ +void InputDataStream::ReadBytes(size_t byteCount, std::byte* buffer) { mBackend.ReadBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<std::byte*>(buffer)); } -void InputDataStream::ReadBytes(size_t byteCount, char* buffer) -{ +void InputDataStream::ReadBytes(size_t byteCount, char* buffer) { mBackend.ReadBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<std::byte*>(buffer)); } -void InputDataStream::ReadBytes(size_t byteCount, signed char* buffer) -{ +void InputDataStream::ReadBytes(size_t byteCount, signed char* buffer) { mBackend.ReadBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<std::byte*>(buffer)); } -void InputDataStream::ReadBytes(size_t byteCount, unsigned char* buffer) -{ +void InputDataStream::ReadBytes(size_t byteCount, unsigned char* buffer) { mBackend.ReadBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<std::byte*>(buffer)); } -void InputDataStream::Read(int8_t& n) -{ +void InputDataStream::Read(int8_t& n) { // sizeof() of a reference type yields the size of the reference mBackend.ReadBytes(sizeof(n), reinterpret_cast<std::byte*>(&n)); } -void InputDataStream::Read(int16_t& n) -{ +void InputDataStream::Read(int16_t& n) { int16_t tmp; mBackend.ReadBytes(sizeof(tmp), reinterpret_cast<std::byte*>(&tmp)); if (GetEndianness() != std::endian::native) { @@ -97,8 +84,7 @@ void InputDataStream::Read(int16_t& n) } } -void InputDataStream::Read(int32_t& n) -{ +void InputDataStream::Read(int32_t& n) { int32_t tmp; mBackend.ReadBytes(sizeof(tmp), reinterpret_cast<std::byte*>(&tmp)); if (GetEndianness() != std::endian::native) { @@ -108,8 +94,7 @@ void InputDataStream::Read(int32_t& n) } } -void InputDataStream::Read(int64_t& n) -{ +void InputDataStream::Read(int64_t& n) { int64_t tmp; mBackend.ReadBytes(sizeof(tmp), reinterpret_cast<std::byte*>(&tmp)); if (GetEndianness() != std::endian::native) { @@ -119,13 +104,11 @@ void InputDataStream::Read(int64_t& n) } } -void InputDataStream::Read(uint8_t& n) -{ +void InputDataStream::Read(uint8_t& n) { mBackend.ReadBytes(sizeof(n), reinterpret_cast<std::byte*>(&n)); } -void InputDataStream::Read(uint16_t& n) -{ +void InputDataStream::Read(uint16_t& n) { uint16_t tmp; mBackend.ReadBytes(sizeof(tmp), reinterpret_cast<std::byte*>(&tmp)); if (GetEndianness() != std::endian::native) { @@ -135,8 +118,7 @@ void InputDataStream::Read(uint16_t& n) } } -void InputDataStream::Read(uint32_t& n) -{ +void InputDataStream::Read(uint32_t& n) { uint32_t tmp; mBackend.ReadBytes(sizeof(tmp), reinterpret_cast<std::byte*>(&tmp)); if (GetEndianness() != std::endian::native) { @@ -146,8 +128,7 @@ void InputDataStream::Read(uint32_t& n) } } -void InputDataStream::Read(uint64_t& n) -{ +void InputDataStream::Read(uint64_t& n) { uint64_t tmp; mBackend.ReadBytes(sizeof(tmp), reinterpret_cast<std::byte*>(&tmp)); if (GetEndianness() != std::endian::native) { @@ -157,8 +138,7 @@ void InputDataStream::Read(uint64_t& n) } } -void InputDataStream::Read(float& n) -{ +void InputDataStream::Read(float& n) { uint32_t buffer; Read(buffer); @@ -169,8 +149,7 @@ void InputDataStream::Read(float& n) n = std::bit_cast<float>(buffer); } -void InputDataStream::Read(double& n) -{ +void InputDataStream::Read(double& n) { uint64_t buffer; Read(buffer); @@ -182,90 +161,76 @@ void InputDataStream::Read(double& n) } OutputDataStream::OutputDataStream(OutputFileStream stream) - : mBackend{ std::move(stream) } -{ + : mBackend{ std::move(stream) } { } -void OutputDataStream::WriteBytes(size_t byteCount, const std::byte* buffer) -{ +void OutputDataStream::WriteBytes(size_t byteCount, const std::byte* buffer) { mBackend.WriteBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<const std::byte*>(buffer)); } -void OutputDataStream::WriteBytes(size_t byteCount, const char* buffer) -{ +void OutputDataStream::WriteBytes(size_t byteCount, const char* buffer) { mBackend.WriteBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<const std::byte*>(buffer)); } -void OutputDataStream::WriteBytes(size_t byteCount, const signed char* buffer) -{ +void OutputDataStream::WriteBytes(size_t byteCount, const signed char* buffer) { mBackend.WriteBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<const std::byte*>(buffer)); } -void OutputDataStream::WriteBytes(size_t byteCount, const unsigned char* buffer) -{ +void OutputDataStream::WriteBytes(size_t byteCount, const unsigned char* buffer) { mBackend.WriteBytes(static_cast<std::streamsize>(byteCount), reinterpret_cast<const std::byte*>(buffer)); } -void OutputDataStream::Write(int8_t n) -{ +void OutputDataStream::Write(int8_t n) { mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(int16_t n) -{ +void OutputDataStream::Write(int16_t n) { if (GetEndianness() != std::endian::native) { n = ::ByteSwap(n); } mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(int32_t n) -{ +void OutputDataStream::Write(int32_t n) { if (GetEndianness() != std::endian::native) { n = ::ByteSwap(n); } mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(int64_t n) -{ +void OutputDataStream::Write(int64_t n) { if (GetEndianness() != std::endian::native) { n = ::ByteSwap(n); } mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(uint8_t n) -{ +void OutputDataStream::Write(uint8_t n) { mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(uint16_t n) -{ +void OutputDataStream::Write(uint16_t n) { if (GetEndianness() != std::endian::native) { n = ::ByteSwap(n); } mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(uint32_t n) -{ +void OutputDataStream::Write(uint32_t n) { if (GetEndianness() != std::endian::native) { n = ::ByteSwap(n); } mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(uint64_t n) -{ +void OutputDataStream::Write(uint64_t n) { if (GetEndianness() != std::endian::native) { n = ::ByteSwap(n); } mBackend.WriteBytes(sizeof(n), reinterpret_cast<const std::byte*>(&n)); } -void OutputDataStream::Write(float n) -{ +void OutputDataStream::Write(float n) { auto buffer = std::bit_cast<uint32_t>(n); if (GetEndianness() != std::endian::native) { buffer = ::ByteSwap(buffer); @@ -273,8 +238,7 @@ void OutputDataStream::Write(float n) mBackend.WriteBytes(sizeof(buffer), reinterpret_cast<const std::byte*>(&buffer)); } -void OutputDataStream::Write(double n) -{ +void OutputDataStream::Write(double n) { auto buffer = std::bit_cast<uint64_t>(n); if (GetEndianness() != std::endian::native) { buffer = ::ByteSwap(buffer); diff --git a/app/source/Cplt/Utils/IO/DataStream.hpp b/app/source/Cplt/Utils/IO/DataStream.hpp index 133adc2..770cebc 100644 --- a/app/source/Cplt/Utils/IO/DataStream.hpp +++ b/app/source/Cplt/Utils/IO/DataStream.hpp @@ -8,8 +8,7 @@ #include <cstdint> #include <span> -class BaseDataStream -{ +class BaseDataStream { private: std::endian mEndian = std::endian::big; @@ -18,14 +17,12 @@ public: void SetEndianness(std::endian endianness); }; -class InputDataStream : public BaseDataStream -{ +class InputDataStream : public BaseDataStream { private: InputFileStream mBackend; public: - static constexpr bool IsSerializer() - { + static constexpr bool IsSerializer() { return false; } @@ -37,8 +34,7 @@ public: void ReadBytes(size_t byteCount, unsigned char* buffer); template <class TInserter> - void ReadBytes(size_t byteCount, TInserter&& inserter) - { + void ReadBytes(size_t byteCount, TInserter&& inserter) { for (size_t i = 0; i < byteCount; ++i) { uint8_t byte; Read(byte); @@ -62,22 +58,19 @@ public: template <class TEnum> requires std::is_enum_v<TEnum> - void ReadEnum(TEnum& e) - { + void ReadEnum(TEnum& e) { std::underlying_type_t<TEnum> n; Read(n); e = static_cast<TEnum>(e); } template <class TObject> - void ReadObject(TObject& obj) - { + void ReadObject(TObject& obj) { obj.ReadFromDataStream(*this); } template <class TAdapter, class TObject> - void ReadObjectAdapted(TObject& obj) - { + void ReadObjectAdapted(TObject& obj) { TAdapter::ReadFromDataStream(*this, obj); } @@ -85,44 +78,37 @@ public: // Proxy functions for writing templated IO functions template <class T> - void Bytes(size_t byteCount, T* buffer) - { + void Bytes(size_t byteCount, T* buffer) { ReadBytes(byteCount, buffer); } template <class T> - void Value(T& t) - { + void Value(T& t) { Read(t); } template <class T> - void Enum(T& t) - { + void Enum(T& t) { ReadEnum(t); } template <class T> - void Object(T& obj) - { + void Object(T& obj) { ReadObject(obj); } template <class TAdapter, class TObject> - void ObjectAdapted(TObject& obj) - { + void ObjectAdapted(TObject& obj) { ReadObjectAdapted<TAdapter>(obj); } }; -class OutputDataStream : public BaseDataStream -{ +class OutputDataStream : public BaseDataStream { private: OutputFileStream mBackend; public: - static constexpr bool IsSerializer() - { + static constexpr bool IsSerializer() { return true; } @@ -134,8 +120,7 @@ public: void WriteBytes(size_t byteCount, const unsigned char* buffer); template <class TIterator> - void WriteBytes(TIterator&& begin, TIterator&& end) - { + void WriteBytes(TIterator&& begin, TIterator&& end) { for (; begin != end; ++begin) { uint8_t byte = *begin; Write(byte); @@ -157,21 +142,18 @@ public: template <class TEnum> requires std::is_enum_v<TEnum> - void WriteEnum(TEnum e) - { + void WriteEnum(TEnum e) { auto n = static_cast<std::underlying_type_t<TEnum>>(e); Write(n); } template <class TObject> - void WriteObject(const TObject& obj) - { + void WriteObject(const TObject& obj) { obj.WriteToDataStream(*this); } template <class TAdapter, class TObject> - void WriteObjectAdapted(const TObject& obj) - { + void WriteObjectAdapted(const TObject& obj) { TAdapter::WriteToDataStream(*this, obj); } @@ -179,32 +161,27 @@ public: // Proxy functions for writing templated IO functions template <class T> - void Bytes(size_t byteCount, T* buffer) - { + void Bytes(size_t byteCount, T* buffer) { WriteBytes(byteCount, buffer); } template <class T> - void Value(T t) - { + void Value(T t) { Write(t); } template <class T> - void Enum(T t) - { + void Enum(T t) { WriteEnum(t); } template <class T> - void Object(T& obj) - { + void Object(T& obj) { WriteObject(obj); } template <class TAdapter, class TObject> - void ObjectAdapted(TObject& obj) - { + void ObjectAdapted(TObject& obj) { WriteObjectAdapted<TAdapter>(obj); } }; diff --git a/app/source/Cplt/Utils/IO/FileStream.hpp b/app/source/Cplt/Utils/IO/FileStream.hpp index 453ddbe..37b2a36 100644 --- a/app/source/Cplt/Utils/IO/FileStream.hpp +++ b/app/source/Cplt/Utils/IO/FileStream.hpp @@ -8,10 +8,8 @@ // TODO switch to custom when unit tests are ready and bugs are fixed #define CPLT_FILESTREAM_USE_CSTDIO -struct IoResult -{ - enum ErrorKind - { +struct IoResult { + enum ErrorKind { ERR_None, ERR_PermissionDenied, ERR_UnexpectedEof, @@ -25,8 +23,7 @@ struct IoResult size_t BytesMoved; }; -class InputFileStream -{ +class InputFileStream { private: #if defined(CPLT_FILESTREAM_USE_CSTDIO) FILE* mFile; @@ -60,11 +57,9 @@ public: IoResult ReadBytes(size_t bufferLength, std::byte* buffer); }; -class OutputFileStream -{ +class OutputFileStream { public: - enum WriteMode - { + enum WriteMode { AppendFile, TruncateFile, }; diff --git a/app/source/Cplt/Utils/IO/Helper.hpp b/app/source/Cplt/Utils/IO/Helper.hpp index 7a84103..b8f4e6f 100644 --- a/app/source/Cplt/Utils/IO/Helper.hpp +++ b/app/source/Cplt/Utils/IO/Helper.hpp @@ -7,8 +7,7 @@ namespace DataStreamAdapters { /// Helper to invoke either Read() or ReadObject(). /// This is intended for writing IO adapters, users that's writing IO logic shouldn't using this - it increases compile time while reducing readability. template <class TAdapter, class T> -void ReadHelper(InputDataStream& stream, T& t) -{ +void ReadHelper(InputDataStream& stream, T& t) { if constexpr (!std::is_same_v<TAdapter, void>) { stream.ReadObjectAdapted<TAdapter>(t); } else if constexpr (requires(T tt, InputDataStream ss) { ss.Read(tt); }) { @@ -25,8 +24,7 @@ void ReadHelper(InputDataStream& stream, T& t) /// Helper to invoke either Write() or WriteObject(). /// This is intended for writing IO adapters, users that's writing IO logic shouldn't using this - it increases compile time while reducing readability. template <class TAdapter, class T> -void WriteHelper(OutputDataStream& stream, T& t) -{ +void WriteHelper(OutputDataStream& stream, T& t) { if constexpr (!std::is_same_v<TAdapter, void>) { stream.WriteObjectAdapted<TAdapter>(t); } else if constexpr (requires(T tt, OutputDataStream ss) { ss.Write(tt); }) { diff --git a/app/source/Cplt/Utils/IO/StringIntegration.hpp b/app/source/Cplt/Utils/IO/StringIntegration.hpp index 66f42b0..3ff715a 100644 --- a/app/source/Cplt/Utils/IO/StringIntegration.hpp +++ b/app/source/Cplt/Utils/IO/StringIntegration.hpp @@ -7,10 +7,8 @@ #include <string_view> namespace DataStreamAdapters { -struct String -{ - static void ReadFromDataStream(InputDataStream& stream, std::string& str) - { +struct String { + static void ReadFromDataStream(InputDataStream& stream, std::string& str) { uint64_t size; stream.Read(size); @@ -19,17 +17,14 @@ struct String stream.ReadBytes(size, std::back_inserter(str)); } - static void WriteToDataStream(OutputDataStream& stream, const std::string& str) - { + static void WriteToDataStream(OutputDataStream& stream, const std::string& str) { stream.Write((uint64_t)str.size()); stream.WriteBytes(str.size(), str.data()); } }; -struct StringView -{ - static void WriteToDataStream(OutputDataStream& stream, const std::string_view& str) - { +struct StringView { + static void WriteToDataStream(OutputDataStream& stream, const std::string_view& str) { stream.Write((uint64_t)str.size()); stream.WriteBytes(str.size(), str.data()); } diff --git a/app/source/Cplt/Utils/IO/TslArrayIntegration.hpp b/app/source/Cplt/Utils/IO/TslArrayIntegration.hpp index b585bee..1215c3b 100644 --- a/app/source/Cplt/Utils/IO/TslArrayIntegration.hpp +++ b/app/source/Cplt/Utils/IO/TslArrayIntegration.hpp @@ -13,11 +13,9 @@ namespace DataStreamAdapters { template <class TAdapter = void> -struct TslArrayMap -{ +struct TslArrayMap { template <class TValue> - static void ReadFromDataStream(InputDataStream& stream, tsl::array_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>); @@ -37,8 +35,7 @@ struct TslArrayMap } template <class TValue> - static void WriteToDataStream(OutputDataStream& stream, const tsl::array_map<char, TValue>& map) - { + static void WriteToDataStream(OutputDataStream& stream, const tsl::array_map<char, TValue>& map) { stream.Write((uint64_t)map.size()); for (auto it = map.begin(); it != map.end(); ++it) { diff --git a/app/source/Cplt/Utils/IO/TslRobinIntegration.hpp b/app/source/Cplt/Utils/IO/TslRobinIntegration.hpp index bdea505..a19a4f1 100644 --- a/app/source/Cplt/Utils/IO/TslRobinIntegration.hpp +++ b/app/source/Cplt/Utils/IO/TslRobinIntegration.hpp @@ -9,11 +9,9 @@ namespace DataStreamAdapters { template <class TKeyAdapter = void, class TValueAdapter = void> -struct TslRobinMap -{ +struct TslRobinMap { template <class TKey, class TValue> - static void ReadFromDataStream(InputDataStream& stream, 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>); @@ -33,8 +31,7 @@ struct TslRobinMap } template <class TKey, class TValue> - static void WriteToDataStream(OutputDataStream& stream, const tsl::robin_map<TKey, TValue>& map) - { + static void WriteToDataStream(OutputDataStream& stream, const tsl::robin_map<TKey, TValue>& map) { stream.Write((uint64_t)map.size()); for (auto it = map.begin(); it != map.end(); ++it) { @@ -45,11 +42,9 @@ struct TslRobinMap }; template <class TAdapter = void> -struct TslRobinSet -{ +struct TslRobinSet { template <class TElement> - static void ReadFromDataStream(InputDataStream& stream, 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>); @@ -66,8 +61,7 @@ struct TslRobinSet } template <class TElement> - static void WriteToDataStream(OutputDataStream& stream, const tsl::robin_set<TElement>& set) - { + static void WriteToDataStream(OutputDataStream& stream, const tsl::robin_set<TElement>& set) { stream.Write((uint64_t)set.size()); for (auto& element : set) { diff --git a/app/source/Cplt/Utils/IO/UuidIntegration.hpp b/app/source/Cplt/Utils/IO/UuidIntegration.hpp index 20c1e7e..49afd19 100644 --- a/app/source/Cplt/Utils/IO/UuidIntegration.hpp +++ b/app/source/Cplt/Utils/IO/UuidIntegration.hpp @@ -8,18 +8,15 @@ #include <iterator> namespace DataStreamAdapters { -struct Uuid -{ - static void ReadFromDataStream(InputDataStream& stream, uuids::uuid& uuid) - { +struct Uuid { + static void ReadFromDataStream(InputDataStream& stream, uuids::uuid& uuid) { uint8_t buffer[16]; stream.ReadBytes(16, buffer); uuid = uuids::uuid(gsl::span<uint8_t, 16>{ buffer }); } - static void WriteToDataStream(OutputDataStream& stream, const uuids::uuid& uuid) - { + static void WriteToDataStream(OutputDataStream& stream, const uuids::uuid& uuid) { auto gslSpan = uuid.as_bytes(); stream.WriteBytes(gslSpan.size(), gslSpan.data()); } diff --git a/app/source/Cplt/Utils/IO/VectorIntegration.hpp b/app/source/Cplt/Utils/IO/VectorIntegration.hpp index 93967f6..e1a6108 100644 --- a/app/source/Cplt/Utils/IO/VectorIntegration.hpp +++ b/app/source/Cplt/Utils/IO/VectorIntegration.hpp @@ -8,11 +8,9 @@ namespace DataStreamAdapters { template <class TAdapter = void> -struct Vector -{ +struct Vector { template <class TElement> - static void ReadFromDataStream(InputDataStream& stream, std::vector<TElement>& vec) - { + static void ReadFromDataStream(InputDataStream& stream, std::vector<TElement>& vec) { static_assert(std::is_default_constructible_v<TElement>); static_assert(std::is_move_constructible_v<TElement>); @@ -31,8 +29,7 @@ struct Vector } template <class TElement> - static void WriteToDataStream(OutputDataStream& stream, const std::vector<TElement>& vec) - { + static void WriteToDataStream(OutputDataStream& stream, const std::vector<TElement>& vec) { stream.Write((uint64_t)vec.size()); for (auto& element : vec) { WriteHelper<TAdapter>(stream, element); |