boost-iostreams

Using boost::iostreams::tee_device?

Can someone help me? I am trying to do something like the following: #include <boost/iostreams/tee.hpp> #include <boost/iostreams/stream.hpp> #include <sstream> #include <cassert> namespace io = boost::iostreams; typedef io::stream<io::tee_device<std::stringstream, std::stringstream> > Tee; std::stringstream ss1, ss2; Tee my_split...

Simple server/client boost example not working

Learning boost, and compiled their daytime server client example. Since I cant use port 13 that is in the example I only changed the port numbers in the server and client example. Server runs fine, but the client doesnt connect it seems, and no error is given. Input data for the client is "127.0.0.1". Server: #include <ctime> #include...

C++ "hello world" Boost tee example program.

The Boost C++ library has Function Template tee The class templates tee_filter and tee_device provide two ways to split an output sequence so that all data is directed simultaneously to two different locations. I am looking for a complete C++ example using Boost tee to output to standard out and to a file like "sample.txt". ...

C++ Boost io streams, error handling

Is it possible to make a custom stream work like the stanadrd ones in regard for errors? That is by default use the good/fail/bad/eof bits rather than exceptions? The boost docs only mention throwing an std::failure for stream errors and letting other error propagate (eg a badalloc from trying to allocate a buffer), however the boost co...

extracting compressed file with boost::iostreams

Hi I'm searching for a way to extract a file in c++ by using the boost::iostreams classes. There is an example in the boost documentation. But it outputs the content of the compressed file to std::cout. I'm looking for a way to extract it to a file structure. Does anybody know how to do that? Thanks! ...

Can someone provide an example of seeking, reading, and writing a >4GB file using boost iostreams

I have read that boost iostreams supposedly supports 64 bit access to large files semi-portable way. Their FAQ mentions 64 bit offset functions, but there is no examples on how to use them. Has anyone used this library for handling large files? A simple example of opening two files, seeking to their middles, and copying one to the oth...

How to hook up Boost serialization & iostreams to serialize & gzip an object to string?

Hi all; I've been using the Boost serialization library, which is actually pretty nice, and lets me make simple wrappers to save my serializable objects to strings, like so: template <class T> inline std::string saveString(const T & o) { std::ostringstream oss; boost::archive::binary_oarchive oa(oss); oa << o; return oss.str(); } te...

Need help on asynchrous non-blocking file loading with boost::asio and boost::iostreams ( or something different? )

I'm coding in c++, and I'm trying to load an image file asynchronously. After some research, I found some mentions about using boost::asio and boost::iostreams to do it. However, the documentation and example for boost::asio is mostly socket related, so it doesn't help me much. Here is what I need: Load a file asynchronously and upon ...

Why doesn't std::istream assume ownership over its streambuf?

Hi, I am writing some sort of virtual file system library for video-games in the likes of CRI Middleware's ROFS (see Wikipedia). My intention with the library is to provide natural means of accessing the resources of the games I develop, which store some data embedded in the executable, some on the media and some on the local user's har...

using boost::iostreams to read specifically crafted data, then based on that create object and append it to list

I have an interesting problem. Let's say that i have file with lines filled like this: name1[xp,y,z321](a,b,c){text};//comment #comment name2(aaaa); also I have (simplified) class: class something { public: something(const std::string& name); addOptionalParam(const std::string& value); addMandatoryParam(const std::string& value); ...

Flushing a boost::iostreams::zlib_compressor. How to obtain a "sync flush" ?

Is there some magic required to obtain a "zlib sync flush" when using boost::iostreams::zlib_compressor ? Just invoking flush on the filter, or strict_sync on a filtering_ostream containing it doesn't see to do the job (ie I want the compressor to flush enough that the decompressor can recover all the bytes consumed by the compressor so...

Is there a difference between boost iostream mapped file and boost interprocess mapped file?

I want to create a mapped binary file into memory; however I am not sure how to create the file to be mapped into the system. I read the documentation several times and realize there are 2 mapped file implementations, one in iostream and the other in interprocess. Do you guys have any idea on how to create a mapped file into shared mem...

BOOST.IOstreams: trouble to write to bzip2.

Hello I am would like to store my data in to bzip2 file using Boost.IOstreams. void test_bzip() { namespace BI = boost::iostreams; { string fname="test.bz2"; { BI::filtering_stream<BI::bidirectional> my_filter; my_filter.push(BI::combine(BI::bzip2_decompressor(), BI::bzip2_compressor())) ; my_filter.push(std::fstream(fna...

Zlib compression in boost::iostreams not compatible with zlib.NET

Hello, I want to send compressed data between my C# to a C++ application in ZLIB format. In C++, I use the zlib_compressor/zlib_decompressor available in boost::iostreams. In C#, I am currently using the ZOutputStream available in the zlib.NET library. First of all, when I compress the same data using both libraries, the results look di...

Recommendations for a C++ polymorphic, seekable, binary I/O interface

I've been using std::istream and ostream as a polymorphic interface for random-access binary I/O in C++, but it seems suboptimal in numerous ways: 64-bit seeks are non-portable and error-prone due to streampos/streamoff limitations; currently using boost/iostreams/positioning.hpp as a workaround, but it requires vigilance Missing opera...

C++ iostreams question

Hello! I am now diving into boost::iostreams and I'm looking for a way to create a stream that iterates over some container<char>. Right now I have the code that work for a std::vector<char>, but it does ONLY for it, because I wrote std::vector-specific code. I am doing the following thing: template <class Object, class Container> vo...

exceptions from boost::iostreams::copy()

In the below code, I have a corrupt "hello.bz2" which has stray characters beyond the EOF. Is there a way to make the boost::iostreams::copy() call to throw ? #include <fstream> #include <iostream> #include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/copy.hpp> #include <boost/iostreams/filter/bzip2.hpp> int mai...

boost::iostreams::zlib::default_noheader seems to be ignored.

Hi stackoverflow, I'm having trouble getting boost::iostreams's zlib filter to ignore gzip headers ... It seems that setting zlib_param's default_noheader to true and then calling zlib_decompressor() produces the 'data_error' error (incorrect header check). This tells me zlib is still expecting to find headers. Has anyone gotten boost::...

How can I compress a wide character stream using boost::iostreams?

Hello everyone, I'm working with some code which writes to a wostream. I'd like take its output and write it to a gzip'ed file. This seemed like a good job for boost::iostreams. However, my attempts so far at this haven't been successful. (in all the below, assume using namespace boost::iostreams and that I have some function void my_...

How can you disable the buffer in a boost::iostreams sink?

Hi all, I've written a 'sink' using boost::iostreams, so that I can essentially have my own code run when someone tries to write to an iostream object. Unfortunately there is a buffer somewhere in the system, so that my Sink's write() function only gets called every 4kB or so. This is a problem because the sink I am implementing is a ...