memgraph/include/utils/stream_wrapper.hpp
2016-09-08 13:25:52 +01:00

25 lines
522 B
C++

#pragma once
// Wraps stream with convinient methods which need only one method:
// write (const char* s, n);
template <class STREAM>
class StreamWrapper
{
public:
StreamWrapper() = delete;
StreamWrapper(STREAM &s) : stream(s) {}
void write(const unsigned char value)
{
stream.write(reinterpret_cast<const char *>(&value), 1);
}
void write(const unsigned char *value, size_t n)
{
stream.write(reinterpret_cast<const char *>(value), n);
}
private:
STREAM &stream;
};