Boost logo

Boost Users :

From: Holger Bast (bast_at_[hidden])
Date: 2008-02-15 15:05:57


>> I want to read line by line from a gzipped document.
>>
>> I first do:
>>
>> std::ifstream file(fileName.c_str());
>> boost::iostreams::filtering_streambuf<boost::iostreams::input> in;
>> in.push(boost::iostreams::gzip_decompressor());
>> in.push(documentFile);
>>
>> However, then the obvious:
>>
>> string line;
>> while(std::getline(in, line)) { ... }
>>
>> does not compile.
>>
>> Is there really no getline for filtering_streambuf?
>>
>
> getline() is provided by the C++ standard library for use with input
> streams. The above should compile if you use filtering_stream instead of
> filtering_streambuf (and possibly make some unrelated changes -- e.g.,
> it doesn't look like "documentFile" is defined).
>

Thanks for the clarification: when switching from filtering_streambuf to
filtering_stream it indeed compiles.

However, getline(in, line) then gives the *compressed* lines, despite
the in.push(boost::iostreams::gzip_decompressor());

I don't understand why and how that is happening, any ideas?

Holger

PS: The "documentFile" in my example code should be "file", that was
just a copy&paste error.


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