Reputation: 742
I'm trying to you boost::iostreams library to decompose gziped data. I do able to do that for simple data.
TEST_F(GzipTest, ZipStringChuncks)
{
using namespace boost::iostreams;
string str_part1 {
char(0x1f), char(0x8b), char(0x08), char(0x00), char(0xca), char(0xb5),
char(0x07), char(0x53), char(0x00), char(0x03), char(0xcb), char(0x48),
char(0xcd), char(0xc9), char(0xc9), char(0x57), char(0x28), char(0xcf),
char(0x2f), char(0xca), char(0x49), char(0xe1), char(0x02), char(0x00),
char(0x2d), char(0x3b), char(0x08), char(0xaf), char(0x0c), char(0x00),
char(0x00), char(0x00)
};
filtering_streambuf<input> decompress;
decompress.push(gzip_decompressor());
decompress.push(boost::iostreams::array_source(str_part1.data(), str_part1.size()));
stringstream sstream_decompress;
try {
boost::iostreams::copy(decompress, sstream_decompress);
} catch (const gzip_error &exception) {
EXPECT_TRUE(false) << exception.what() << endl;
} catch (...) {
EXPECT_TRUE(false) << "ERROR GZIP" << endl;
}
string unziped_str = sstream_decompress.str();
EXPECT_EQ(unziped_str, "hello world\n");
}
The issue is that I need to decompress chunks of related data coming from the network. So I need to be able to decompress the first one before I get the second one. When the second one arrives as I understand it should be aware of the first one some how.
I need something like this:
string some_data = "...data...";
string chunks[2] = compress_in_chunks(some_data);
for(string chunk in chunks) {
string decompressed_str = decompress(chunk);
cout << decompressed_str << endl;
}
Is there a way to do it with boost?
Couldn't find detailed documentation only few examples.
Upvotes: 0
Views: 107