diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-05-04 15:46:25 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-05-04 16:16:53 +0200 |
commit | 0d4a10e910e1916a6f36cb9af6b68817172b51a9 (patch) | |
tree | dc2525bab942c3bdddfd22e40fdaacc525c8a937 /src/libutil/serialise.hh | |
parent | c6a21aed07520e11dfae09cf9eff9e34e60906d8 (diff) |
Do compression in a sink
Diffstat (limited to 'src/libutil/serialise.hh')
-rw-r--r-- | src/libutil/serialise.hh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/serialise.hh b/src/libutil/serialise.hh index 9ba6391f8..892ec4aa3 100644 --- a/src/libutil/serialise.hh +++ b/src/libutil/serialise.hh @@ -13,6 +13,11 @@ struct Sink virtual ~Sink() { } virtual void operator () (const unsigned char * data, size_t len) = 0; virtual bool good() { return true; } + + void operator () (const std::string & s) + { + (*this)((const unsigned char *) s.data(), s.size()); + } }; @@ -28,6 +33,11 @@ struct BufferedSink : Sink void operator () (const unsigned char * data, size_t len) override; + void operator () (const std::string & s) + { + Sink::operator()(s); + } + void flush(); virtual void write(const unsigned char * data, size_t len) = 0; |