diff options
author | rtk0c <[email protected]> | 2021-08-15 21:12:35 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2021-08-15 21:12:35 -0700 |
commit | 87b964591c9a93146bd43e8813387392f8520337 (patch) | |
tree | 6e9db197c7fcd584acbcd6655854a3a8612382b9 /core/src/Utils/IO/StringIntegration.hpp | |
parent | b79a244d76c66287c6228e3845aa3af91a847f5d (diff) |
Turn IO adapter's mechanism from function overload into structs that are given by the user
Diffstat (limited to 'core/src/Utils/IO/StringIntegration.hpp')
-rw-r--r-- | core/src/Utils/IO/StringIntegration.hpp | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/core/src/Utils/IO/StringIntegration.hpp b/core/src/Utils/IO/StringIntegration.hpp index 35b1660..a90ea98 100644 --- a/core/src/Utils/IO/StringIntegration.hpp +++ b/core/src/Utils/IO/StringIntegration.hpp @@ -4,26 +4,32 @@ #include <string> #include <string_view> -namespace DataStreamIntegrations { -void ReadFromDataStream(DataStream& s, std::string& str) +namespace DataStreamAdapters { +struct String { - uint64_t size; - s.Read(size); + void ReadFromDataStream(DataStream& s, std::string& str) + { + uint64_t size; + s.Read(size); - str = {}; - str.reserve(size); - s.ReadBytes(size, std::back_inserter(str)); -} + str = {}; + str.reserve(size); + s.ReadBytes(size, std::back_inserter(str)); + } -void WriteToDataStream(DataStream& s, const std::string& str) -{ - s.Write((uint64_t)str.size()); - s.WriteBytes(str.size(), str.data()); -} + void WriteToDataStream(DataStream& s, const std::string& str) + { + s.Write((uint64_t)str.size()); + s.WriteBytes(str.size(), str.data()); + } +}; -void WriteToDataStream(DataStream& s, const std::string_view& str) +struct StringView { - s.Write((uint64_t)str.size()); - s.WriteBytes(str.size(), str.data()); -} -} // namespace DataStreamIntegrations + void WriteToDataStream(DataStream& s, const std::string_view& str) + { + s.Write((uint64_t)str.size()); + s.WriteBytes(str.size(), str.data()); + } +}; +} // namespace DataStreamAdapters |