boost-iostreams

exceptions from boost::iostreams::copy()

我是研究僧i 提交于 2019-12-11 05:43:58
问题 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 main() { using namespace std; using namespace boost::iostreams; ifstream file("hello.bz2", ios_base::in | ios_base::binary); filtering_streambuf<input> in; in.push

Read simple/bz2-compressed-file(line by line) by detecting it is compressed or not (size of file is large)

巧了我就是萌 提交于 2019-12-11 02:59:12
问题 I wrote a code to read simple-text/bz2-compressed-file. I used magic-characters of bz2 file to detect the file is compressed or not NOTE "user may or may not provide file with proper extension" my code #include <iostream> #include <sstream> #include <vector> #include <boost/iostreams/filtering_stream.hpp> #include <boost/iostreams/copy.hpp> #include <boost/iostreams/filter/bzip2.hpp> // compile using // g++ -std=c++11 code.cpp -lboost_iostreams // run using // ./a.out < compressed_file // ./a

Using boost::iostreams::mapped_file_source with wide character strings

不打扰是莪最后的温柔 提交于 2019-12-11 00:54:59
问题 If I instantiate a mapped_file_source (boost 1.46.1 ) with a narrow character string as in the following I don't have a problem: boost::iostreams::mapped_file_source m_file_( "testfile.txt" ); However if I try to use a wide string: boost::iostreams::mapped_file_source m_file_( L"testfile.txt" ); I get the following compiler error in VC2010 SP1: P:\libs\boost_1_46_1\boost/iostreams/device/mapped_file.hpp(128): error C2248: 'boost::iostreams::detail::path::path' : cannot access private member

Using boost::iostreams mapped_file_source and filtering_streambuf to decompress file

青春壹個敷衍的年華 提交于 2019-12-10 18:22:34
问题 I plan to process large compressed files and I would like to memory map the files to speedup reading. I adopted the existing example with regular file input but cannot get it either compile nor work :-) I'm using C++ Boost 1.49 Any suggestion welcome! #include<iostream> #include<boost/iostreams/filtering_streambuf.hpp> #include<boost/iostreams/copy.hpp> #include<boost/iostreams/filter/zlib.hpp> #include<boost/iostreams/device/file.hpp> #include<boost/iostreams/device/mapped_file.hpp> void

insert a string in front of a istream in cpp

一笑奈何 提交于 2019-12-10 17:01:28
问题 My problem is something like I want to append some string in front of a iostream. You can say in front of std::cin. #include <iostream> #include <string> void print(std::istream & in){// function not to be modified std::string str; in >> str; std::cout<< str << std::endl; in >> str; std::cout<< str << std::endl; } int main() { std::string header = "hello "; //boost::iostream::filtering_istream in(std::cin); std::istream & in = std::cin; //you may do someting here //something like inserting

Is there a boost::iostreams (bidirectional) Device for a blocking boost::asio TCP connection?

南楼画角 提交于 2019-12-10 16:38:56
问题 I'm surveying c++ libraries for portable, blocking I/O access to the filesystem and network. It looks like boost::filesystem , boost::iostreams and boost::asio will, between the three of them, do the job. To be clear, I'm not currently interested in the asynchronous aspects of boost::asio ; I just want a portable, blocking interface to the network. Digging in, I see boost::iostreams has a notion of Devices, each of which has an associated mode concept. The bidirectional mode specifically

boost iostreams library exist but i am unable link it

痴心易碎 提交于 2019-12-10 16:17:50
问题 I know that the re plenty of similar questions, but mine is litle bit different and non them helped me. I am using boost-iostreams library and here is my problem, i tried to link my program with libraries: ld -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams/device/ -L/usr/lib/libboost_iostreams.so -lboost-iostreams fd.o -o x And the result was: ld: cannot find -lboost-iostreams When i tried to write it explicitly: ld -I/usr/include/boost/iostreams/ -I/usr/include/boost/iostreams

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

微笑、不失礼 提交于 2019-12-10 13:19:27
问题 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 hard drive (preferences, save game files, etc). Access to such resources should be as simple as making a call like std::auto_ptr<std::istream> defaultConfigIStream(

How to use a compressor Boost::Iostreams filter as a sink in Boost::Log

て烟熏妆下的殇ゞ 提交于 2019-12-07 16:13:54
问题 I'm trying to compress log files created using the Boost Log library instantaneously by utilizing boost::iostreams::gzip_compressor . So when I call BOOST_LOG() , output gets compressed on-the-fly. Here's what I tried so far: #include <fstream> #include <iostream> #include <boost/iostreams/filtering_stream.hpp> #include <boost/iostreams/filtering_streambuf.hpp> #include <boost/iostreams/stream.hpp> #include <boost/iostreams/filter/gzip.hpp> #include <boost/smart_ptr/shared_ptr.hpp> #include

Boost Iostreams zlib_error with Custom Source

爷,独闯天下 提交于 2019-12-07 10:40:50
问题 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