blob: 35b166099c8af72a2915e462a529c07fbbc8d4c0 (
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
|
#pragma once
#include <iterator>
#include <string>
#include <string_view>
namespace DataStreamIntegrations {
void ReadFromDataStream(DataStream& s, std::string& str)
{
uint64_t size;
s.Read(size);
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_view& str)
{
s.Write((uint64_t)str.size());
s.WriteBytes(str.size(), str.data());
}
} // namespace DataStreamIntegrations
|