
On 07/28/13 23:28, Stephen Greenfield wrote:
On 7/28/13 8:45 PM, "Larry Evans"
mailto:cppljevans@suddenlink.net> wrote: I thought the filtering_stream would be derived from std::ostream, at least according to:
Derived class of std::basic_istream, std::basic_ostream or std::basic_iostream, used to perform filtering.
quoted from:
http://www.boost.org/doc/libs/1_54_0/libs/iostreams/doc/classes/filtering_st...
Did you not find this so, or do you needs require something more specific than std::ostream& to be passed to the other functions you mention?
Larry --
Thanks! You would've thought that — and you know what? You would be CORRECT.
I thought I had tested every possible case — but I think I did that BEFORE discovering my error with closing the file before destructing the filtering_streambuf/filtering_ostream.
You (and everyone else) were ABSOLUTELY CORRECT. When I changed my code from a filtering_streambuf:
ofstream myXMLFile (destPath, std::ios_base::out | std::ios_base::app | std::ios_base::binary); boost::iostreams::filtering_streambufboost::iostreams::output filteringOStream; filteringOStream.push(boost::iostreams::zlib_compressor()); filteringOStream.push(myXMLFile); std::ostream myExportedXMLFilteringOStream(&filteringOStream); Foo(myExportedXMLFilteringOStream);
TO A filtering_ostream:
ofstream myXMLFile (destPath, std::ios_base::out | std::ios_base::app | std::ios_base::binary); boost::iostreams::filtering_ostream myExportedXMLFilteringOStream; myExportedXMLFilteringOStream.push(boost::iostreams::zlib_compressor()); myExportedXMLFilteringOStream.push(myXMLFile); Foo(myExportedXMLFilteringOStream);
Thank you so much for tying up that loose end! I'm assuming the filtering_ostream is of course more efficient than the filtering_streambuf scenario? I don't know, but I guess so.
BTW, I tried modifying Ken's code to use filtering_ostream instead of filtering_streambuf, and it worked. I also removed the ios_base flags and it still worked. Then I tried using stringstream instead of filestream and it no longer worked. Anyone have any clues about why stringstream doesn't work? The code is attached. With the attached code and attached Jamfile.v2, and with: #define USE_STRINGSTRM in the code, the KenApplebyStrm.output produced by bjam is in the next attachment. In contrast, with: //#define USE_STRINGSTRM int the code, the KenApplebyStrm.output produced by bjam is in the last attachment.
Best Regards,
Stephen
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users