blob: 8c5588c1d3a2c17af251c9fe2024391bed8644b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#pragma once
#include "Utils/IO/DataStream.hpp"
#include <iterator>
#include <string>
#include <string_view>
namespace DataStreamAdapters {
struct String
{
void ReadFromDataStream(InputDataStream& s, std::string& str)
{
uint64_t size;
s.Read(size);
str = {};
str.reserve(size);
s.ReadBytes(size, std::back_inserter(str));
}
void WriteToDataStream(OutputDataStream& s, const std::string& str)
{
s.Write((uint64_t)str.size());
s.WriteBytes(str.size(), str.data());
}
};
struct StringView
{
void WriteToDataStream(OutputDataStream& s, const std::string_view& str)
{
s.Write((uint64_t)str.size());
s.WriteBytes(str.size(), str.data());
}
};
} // namespace DataStreamAdapters
|