memgraph/include/utils/stream_wrapper.hpp

25 lines
522 B
C++
Raw Normal View History

2016-09-08 20:25:52 +08:00
#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;
};