|
Boost Users : |
Subject: [Boost-users] How to use boost::iostreams filter directly
From: Allan Nielsen (a_at_[hidden])
Date: 2011-11-14 12:26:18
Hi
How can I use boost::iostreams::gzip_decompressor to decompress a
sequence of boost::asio::streambuf's?
Here is what I had in mind (non-working pseudo code):
struct Foo {
public:
void sinkData(boost::asio::streambuf & buf) {
z.write(boost::asio::buffer_cast<const char*>(buf.data()), buf.size());
while(write());
}
void flush() {
z.flush();
while(write());
}
private:
bool write() {
char buf[1024];
size_t s = z.read(buf, 1024);
std::cout << std::string(buf, s) << std::endl;
return
}
gzip_decompressor z;
}
The sinkData and the flush functions can not be changed. sinkdata() is
called a number of times, followed by a single call to flush().
Is boost::iostreams::gzip_decompressor the best library for this
purpose, if so how to do it? Otherwise, what could else be suggested?
Best regards
Allan W. Nielsen
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net