#pragma once #include "base/base.hpp" #include "base/assert.hpp" #include "std/string.hpp" namespace stream { namespace detail { template void ReadString(TStream & s, string & t) { uint32_t count; s >> count; t.reserve(count); while (count > 0) { char c; s >> c; t.push_back(c); --count; } } template void WriteString(TStream & s, TWriter & w, string const & t) { uint32_t const count = static_cast(t.size()); s << count; if (count > 0) w.Write(t.c_str(), count); } template void ReadBool(TStream & s, bool & t) { char tt; s >> tt; ASSERT(tt == 0 || tt == 1, (tt)); t = (tt != 0); } template void WriteBool(TStream & s, bool t) { s << char(t ? 1 : 0); } } }