14void append(
const T &src, std::string &dst)
16 static_assert(std::is_standard_layout_v<T>);
17 dst.append(
reinterpret_cast<const char*
>(&src),
sizeof src);
23 append(std::size(src), dst);
27void append(
const T *src,
size_t argN, std::string &dst)
29 static_assert(std::is_standard_layout_v<T>);
30 static_assert(
sizeof(T[10]) ==
sizeof(T) * 10);
31 dst.append(
reinterpret_cast<const char*
>(src),
sizeof(*src)*argN);
35void read(
const std::string &src,
size_t &off, T &data)
noexcept
37 static_assert(std::is_standard_layout_v<T>);
38 data = *
reinterpret_cast<const T*
>(src.data() + off);
42size_t read_size(
const std::string &src,
size_t &off)
noexcept;
45void read(
const std::string &src,
size_t &off, T *data,
size_t count)
47 static_assert(std::is_standard_layout_v<T>);
48 const auto bytes =
sizeof(T) * count;
49 memcpy(data, src.data()+off, bytes);
54auto to_str(
const std::array<char,N> &arr)
56 return std::string{arr.data(), arr.size()};
60std::array<char,N>
read_charr(
const std::string &src,
size_t &off)
noexcept
62 std::array<char,N> ret;
63 memcpy(ret.data(), src.data()+off, N);
68template<
size_t N,
template<
typename>
class C>
69void append(
const C<std::array<char,N>> &src, std::string &dst)
84template<
size_t N,
template<
typename>
class C>
85void read(
const std::string &src,
size_t &off, C<std::array<char,N>> &data)
87 for (
size_t i = 0, n =
read_size(src,off); i < n; ++i)
THE common namespace of bux library.
std::tuple< std::string, size_t, bool > load_hashed_str(std::istream &in)
void read(const std::string &src, size_t &off, T &data) noexcept
void append_size_of(const T &src, std::string &dst)
auto to_str(const std::array< char, N > &arr)
size_t read_size(const std::string &src, size_t &off) noexcept
std::array< char, N > read_charr(const std::string &src, size_t &off) noexcept
size_t save_hashed_str(std::ostream &out, const std::string &s)
void append(const T &src, std::string &dst)