1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

Do compression in a sink

This commit is contained in:
Eelco Dolstra 2016-05-04 15:46:25 +02:00
parent c6a21aed07
commit 0d4a10e910
6 changed files with 208 additions and 139 deletions

View file

@ -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;