Boost logo

Boost Users :

Subject: Re: [Boost-users] [iostreams] How can I use the Stream Insertion operator (<<) with a filtering_streambuf?
From: Stephen Greenfield (StephenG_at_[hidden])
Date: 2013-07-26 01:17:20


On 7/25/13 8:22 PM, "Larry Evans" <cppljevans_at_[hidden]<mailto:cppljevans_at_[hidden]>> wrote:

> Instead of someStream, try myFile, and see if the resulting hello.z is what you want.

Larry --

I should have mentioned: I TRIED exactly that:

        myFile << "some text I want to be compressed";

And in that case, the text DOES end up in the file — but UNCOMPRESSED. Apparently, that bypasses the filtering_streambuf.

I'm beginning to wonder if 1) it's not possible, or 2) I should try to contact the original authors of that class for their insight. I'm getting the sense this isn't one of the more commonly-understood areas of of the Boost libraries.

One additional note: While I am linking in the ZLIB libraries and including their headers, I don't believe I have ANY Boost binaries linked in — only headers that are relevant. But — I'm compiling, linking and executing…

Stephen

--



On 07/25/13 19:37, Stephen Greenfield wrote:
Partially asked in another question, but so far unanswered: Once I create
a
filtering_streambuf that is connected to the zlib_compressor() and the
output file,
how do I then construct an object that can accept data from the Stream
Insertion Operator?
void CompressUsingFilteringStreambuf()
{
     std::ofstream myFile("hello.z", std::ios_base::out |
std::ios_base::binary);
     boost::iostreams::filtering_streambuf<boost::iostreams::output> out;
     out.push(boost::iostreams::zlib_compressor());
     out.push(myFile);
         // MY QUESTION: How can I use the "stream insertion" operator
(<<)
         // to go through the filtering_streambuf
         // and place compressed text into myFile?
         // HOW DO I CREATE someStream?
         someStream << "text I want to be compressed and end up in the
file...";
         myFile.close();
}
I have scoured the documentation and the web looking for the answer -- and
come up empty.
Stephen


_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]<mailto:Boost-users_at_[hidden]>
http://lists.boost.org/mailman/listinfo.cgi/boost-users



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