Questions tagged [boost-iostreams]

Boost.Iostreams is a C++ framework for defining streams, stream buffers and I/O filters.

Boost.Iostreams has three aims:

  • To make it easy to create standard C++ streams and stream buffers for accessing new Sources and Sinks.
  • To provide a framework for defining Filters and attaching them to standard streams and stream buffers.
  • To provide a collection of ready-to-use Filters, Sources and Sinks.

For example, Boost.Iostreams can be used to create streams to access TCP connections or as a framework for cryptography and data compression. The library includes components for accessing memory-mapped files, for file access using operating system file descriptors, for code conversion, for text filtering with regular expressions, for line-ending conversion and for compression and decompression in the zlib, gzip and bzip2 formats.

160 questions
2
votes
3 answers

compressed length of a string by boost::iostreams

I have a string (of some fixed length), which I need to compress and then compare the compressed lengths (as a proxy for redundancy in the data or as a rough approximation to the Kolmogorov complexity). Currently, I am using boost::iostreams for…
Nikhil J Joshi
  • 1,177
  • 2
  • 12
  • 25
2
votes
1 answer

How to write binary data to a compressed file

I have some financial data that I am processing in C++. I am storing it in a simple binary format because it requires fewer resources and is fast, however I would like to add compression to the file. I am guessing I will be IO bound so the…
TJB
  • 3,493
  • 4
  • 23
  • 20
2
votes
1 answer

Run-time error reading a .gz file using boost::iostreams and zlib

I am trying to read a .gz file and print the text content on screen by using boost::iostreams. This is just a simple experiment to learn about this library, and I am using the "directors.list.gz" file from IMDb…
Stanley Chu
  • 23
  • 1
  • 3
2
votes
2 answers

How to read a file using boost::iostreams::file_descriptor_source?

I need to use boost::iostreams::file_descriptor::handle_type in my app. I try to read a file using following code, but it keeps looping in the while loop (in.readsome() returns 0 ). using namespace boost::iostreams; file_descriptor_source…
romsky
  • 864
  • 1
  • 8
  • 11
2
votes
1 answer

Boost filtering_stream and tellp

I'm trying to using filtering_streams to compress the serialization of some object into an array_sink or similar device where I can then determine the length of the compressed output and copy it to another stream, say a file. However, using…
MischaNix
  • 730
  • 3
  • 8
1
vote
1 answer

compile error for boost::iostream::filtering_streambuf

Just trying to compress a string with bzip2 so that I can send it over a pipe with ReadFile. The following line earns me the following compile error. in.push(uncompressed_string); Error 6 error C2027: use of undefined type…
Bluebaron
  • 2,289
  • 2
  • 27
  • 37
1
vote
1 answer

How to cast to a shared_ptr from std::shared_ptr>

I have a member that is a shared_ptr. In a specific case, I want to suppress the output, and making the stream a boost::iostreams::stream. Should do what I want. I would prefer to avoid the ofstream(nullptr)…
L Holness
  • 21
  • 1
  • 3
1
vote
1 answer

efficient way of getting chars out of zip file

I am using a function which needs content from zipped xml file. The signature of the function is endgoalFn(const char* s, int len) Below is the code i use for unzipping std::ifstream file; file.open(resultFile, std::ios_base::in |…
nanika
  • 99
  • 6
1
vote
1 answer

Very slow destructors of binary_oarchive and filtering_streambuf

I noticed that destructors of binary_oarchive and filtering_streambuf are extremely slow and I don't know why. I'm running the following code: namespace bfs = boost::filesystem; namespace bar = boost::archive; namespace bio =…
Ehtn8
  • 11
  • 3
1
vote
1 answer

Problem with handling large data using Boost iostreams

I need to handle large amount of data in memory (without using files/fstream) and I know that VS implementation of streambuf doesn't allow for that as it uses 32-bit counter (https://github.com/microsoft/STL/issues/388). I thought that maybe Boost…
Sebastian
  • 21
  • 1
  • 3
1
vote
1 answer

Using boost IOStreams with std::ostream_iterator

I tried to use an array-device based stream and wantet to pass the stream to std::ostream_iterator or std::istream_iterator, but unfortunately, I get a compilation error with gcc 4.3.5. Boost::IOStreams documentation states that the io::stream is…
ovanes
  • 5,483
  • 2
  • 34
  • 60
1
vote
2 answers

boost::iostreams managing resources

I'm new to boost and its iostreams package and finding the documentation a bit thin. Hopefully someone will set me straight. I'm trying to convert a small piece of C# streams code I wrote a while back for reading in a compressed stream. byte[]…
Justin Aquadro
  • 2,280
  • 3
  • 21
  • 31
1
vote
1 answer

Empty file when using boost::filtering_streambuf with newline_filter

I wish to write a piece of data to the file opened via std::fopen using boost::iostreams::filtering_streambuf with newline_filter. Here is a small reproducible test case that I have been trying to work with. It just produces an empty file. #include…
Recker
  • 1,915
  • 25
  • 55
1
vote
1 answer

How to create a member vector of filtering streams?

Let's start with a simple compressed file reader class using boost::iostreams: class SingleFileOpener{ public: SingleFileOpener(const std::string& filename, bool is_compressed) { if(is_compressed)…
tangy
  • 3,056
  • 2
  • 25
  • 42
1
vote
2 answers

Help in managing a iostream

Suppose that I get a stringbuf with some content that include certain character sequences who must be removed: std::stringbuf string_buff; std::iostream io_stream (&string_buff); io_stream << "part-one\r\npart-two\r\npart-three\r\nEND"; There, the…
Old newbie
  • 811
  • 2
  • 11
  • 21