boost-iostreams

Boost IO Stream and ZLib speed up

丶灬走出姿态 提交于 2019-12-07 04:09:54
问题 I have a large file of data I have compressed with Zlib using boost IOStreams and filtering stream buffers: boost::iostreams::array_source uncompressedArray( reinterpret_cast< const char* >( &uncompressedData[0] ), uncompressedData.size() ); boost::iostreams::filtering_streambuf< boost::iostreams::output > out; out.push( *m_compressor ); out.push( boost::iostreams::char_back_inserter( compressedData ) ); boost::iostreams::copy( uncompressedArray, out ); For speed I am initializing the zlib

Boost Iostreams zlib_error with Custom Source

馋奶兔 提交于 2019-12-05 16:28:02
I am trying to use a zlib_decompressor to decompress data through an istreambuf_iterator . I couldn't find an in built way to use an input iterator as input to a stream (please point out a way if one exists already) so I wrote this source: template <class cha_type, class iterator_type> class IteratorSource { public: typedef cha_type char_type; typedef boost::iostreams::source_tag category; iterator_type& i; iterator_type eof; IteratorSource(iterator_type& it, iterator_type end) : i(it), eof(end) { } std::streamsize read(char* s, std::streamsize n) { for(int j = 0; j < n; j++) { if(i == eof) {

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

為{幸葍}努か 提交于 2019-12-04 11:46:37
问题 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 other would be very helpful. Thanks. 回答1: Short answer Just include #include <boost/iostreams/seek.hpp> and use the seek function as in boost::iostreams::seek

How can I decompress a vector of deflated data with Boost?

情到浓时终转凉″ 提交于 2019-12-04 04:53:50
问题 I have a vector that contains zlib-compressed (deflated) data. I would like to decompress it with Boost's filtering_istream . There is only one example on their site, which operates on a stream of data (as opposed to a vector that I have). vector<char> compressed_buffer; compressed_buffer.resize(cdh.length); file.read(&compressed_buffer[0], cdh.length); filtering_istream in; in.push(zlib_decompressor()); in.push(something(compressed_data)); // what should "something" be? I would like to get

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

醉酒当歌 提交于 2019-12-03 11:58:37
问题 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 memory? I am trying to allow a multi-threaded program to read an array of large double written in a binary file format. Also what is the difference between the

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

我的未来我决定 提交于 2019-12-03 07:20:28
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 other would be very helpful. Thanks. Short answer Just include #include <boost/iostreams/seek.hpp> and use the seek function as in boost::iostreams::seek(device, offset, whence); where device is a file, stream, streambuf or any object convertible to seekable ;

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

故事扮演 提交于 2019-12-03 02:28:28
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 memory? I am trying to allow a multi-threaded program to read an array of large double written in a binary file format. Also what is the difference between the mapped file in iostream and interprocess? Joe D As far as I can tell, iostreams will place the mapped file

How to flush memory-mapped files using Boost's `mapped_file_sink` class?

こ雲淡風輕ζ 提交于 2019-12-02 01:04:08
Using the Boost Libraries version 1.62.0 and the mapped_file_sink class from Boost.IOStreams . I want to flush the written data to disk at will , but there is no mapped_file_sink::flush() member function. My questions are: How can I flush the written data when using mapped_file_sink ? If the above can't be done, why not, considering that msync() and FlushViewOfFile() are available for a portable implementation? If you look at the mapped file support for proposed Boost.AFIO v2 at https://ned14.github.io/boost.afio/classboost_1_1afio_1_1v2__xxx_1_1map__handle.html , you'll notice a lack of

boost gzip decompress byte array

不想你离开。 提交于 2019-12-01 03:15:13
I implemented the gzip/zlib decompression of files as shown in their examples on the boost site. void CompressionUtils::Inflate(std::ifstream& inputFile, std::ofstream& outputFile) { boost::iostreams::filtering_streambuf<boost::iostreams::input> in; in.push(boost::iostreams::gzip_decompressor()); in.push(inputFile); boost::iostreams::copy(in, outputFile); } this works fine. I am also reading data from a socket that I am getting from a rest based JSON service that is compressed as well. I figured I would write a memory based implementation, how hard could that be. Well, I figured out I do not

How to read a file into unsigned char array from std::ifstream?

浪子不回头ぞ 提交于 2019-11-30 07:36:05
So normaly I do stuff like: std::ifstream stream; int buff_length = 8192; boost::shared_array<char> buffer( new char[buff_length]); stream.open( path.string().c_str(), std::ios_base::binary); while (stream) { stream.read(buffer.get(), buff_length); //boost::asio::write(*socket, boost::asio::buffer(buffer.get(), stream.gcount())); } stream.close(); I wonder how to read into unsigned char buffer ( boost::shared_array<unsigned char> buffer( new unsigned char[buff_length]); ) In a simplest form: std::vector<unsigned char> vec( std::istreambuf_iterator<char>(std::cin) , std::istreambuf_iterator