15 #include "../config/config.hpp" 30 inline void write(std::ostream& os, T value)
32 os.write((
char*) &value,
sizeof(T));
37 inline T
read(std::istream& is)
40 is.read((
char*) &value,
sizeof(T));
46 inline T
read(
const char *buf)
49 std::copy(buf, buf +
sizeof(T), reinterpret_cast<char*>(&value));
57 const char *ptr =
reinterpret_cast<const char*
>(&val);
58 vec.insert(vec.end(), ptr, ptr +
sizeof(T));
63 void WriteBase64(std::ostream &
out,
const void *bytes,
size_t nbytes);
68 void DecodeBase64(
const char *src,
size_t len, std::vector<char> &buf);
void DecodeBase64(const char *src, size_t len, std::vector< char > &buf)
Decode len base-64 encoded characters in the buffer src, and store the resulting decoded data in buf...
void write(std::ostream &os, T value)
Write 'value' to stream.
void WriteBase64(std::ostream &out, const void *bytes, size_t nbytes)
Given a buffer bytes of length nbytes, encode the data in base-64 format, and write the encoded data ...
T read(std::istream &is)
Read a value from the stream and return it.
size_t NumBase64Chars(size_t nbytes)
Return the number of characters needed to encode nbytes in base-64.
OutStream out(std::cout)
Global stream used by the library for standard output. Initially it uses the same std::streambuf as s...
void AppendBytes(std::vector< char > &vec, const T &val)
Append the binary representation of val to the byte buffer vec.