diff options
Diffstat (limited to 'boost/iostreams')
-rw-r--r-- | boost/iostreams/chain.hpp | 20 | ||||
-rw-r--r-- | boost/iostreams/code_converter.hpp | 8 | ||||
-rw-r--r-- | boost/iostreams/detail/config/codecvt.hpp | 3 | ||||
-rw-r--r-- | boost/iostreams/detail/config/fpos.hpp | 2 | ||||
-rw-r--r-- | boost/iostreams/detail/config/unreachable_return.hpp | 1 | ||||
-rw-r--r-- | boost/iostreams/detail/streambuf/indirect_streambuf.hpp | 39 | ||||
-rw-r--r-- | boost/iostreams/device/mapped_file.hpp | 5 | ||||
-rw-r--r-- | boost/iostreams/device/null.hpp | 2 | ||||
-rw-r--r-- | boost/iostreams/filter/bzip2.hpp | 14 | ||||
-rw-r--r-- | boost/iostreams/filter/gzip.hpp | 22 | ||||
-rw-r--r-- | boost/iostreams/filter/symmetric.hpp | 7 | ||||
-rw-r--r-- | boost/iostreams/filter/zlib.hpp | 34 | ||||
-rw-r--r-- | boost/iostreams/invert.hpp | 4 |
13 files changed, 97 insertions, 64 deletions
diff --git a/boost/iostreams/chain.hpp b/boost/iostreams/chain.hpp index a199c9df38..4e108c8b09 100644 --- a/boost/iostreams/chain.hpp +++ b/boost/iostreams/chain.hpp @@ -14,10 +14,9 @@ #include <boost/assert.hpp> #include <exception> -#include <functional> // unary_function. #include <iterator> // advance. #include <list> -#include <memory> // allocator, auto_ptr. +#include <memory> // allocator, auto_ptr or unique_ptr. #include <typeinfo> #include <stdexcept> // logic_error, out_of_range. #include <boost/checked_delete.hpp> @@ -243,8 +242,19 @@ private: pback_size != -1 ? pback_size : pimpl_->pback_size_; + +#if defined(BOOST_NO_CXX11_SMART_PTR) + std::auto_ptr<streambuf_t> buf(new streambuf_t(t, buffer_size, pback_size)); + +#else + + std::unique_ptr<streambuf_t> + buf(new streambuf_t(t, buffer_size, pback_size)); + +#endif + list().push_back(buf.get()); buf.release(); if (is_device<component_type>::value) { @@ -281,7 +291,9 @@ private: static void set_auto_close(streambuf_type* b, bool close) { b->set_auto_close(close); } - struct closer : public std::unary_function<streambuf_type*, void> { + struct closer { + typedef streambuf_type* argument_type; + typedef void result_type; closer(BOOST_IOS::openmode m) : mode_(m) { } void operator() (streambuf_type* b) { @@ -472,7 +484,7 @@ public: BOOST_IOSTREAMS_DEFINE_PUSH(push, mode, char_type, push_impl) void pop() { chain_->pop(); } bool empty() const { return chain_->empty(); } - size_type size() { return chain_->size(); } + size_type size() const { return chain_->size(); } void reset() { chain_->reset(); } // Returns a copy of the underlying chain. diff --git a/boost/iostreams/code_converter.hpp b/boost/iostreams/code_converter.hpp index 85d5c80eeb..0bac461d44 100644 --- a/boost/iostreams/code_converter.hpp +++ b/boost/iostreams/code_converter.hpp @@ -37,7 +37,7 @@ #include <boost/iostreams/detail/execute.hpp> #include <boost/iostreams/detail/forward.hpp> #include <boost/iostreams/detail/functional.hpp> -#include <boost/iostreams/detail/ios.hpp> // failure, openmode, int types. +#include <boost/iostreams/detail/ios.hpp> // failure, openmode, int types, streamsize. #include <boost/iostreams/detail/optional.hpp> #include <boost/iostreams/detail/select.hpp> #include <boost/iostreams/traits.hpp> @@ -154,13 +154,13 @@ struct code_converter_impl { } template <class T> - void open(const T& dev, int buffer_size) + void open(const T& dev, std::streamsize buffer_size) { if (flags_ & f_open) boost::throw_exception(BOOST_IOSTREAMS_FAILURE("already open")); if (buffer_size == -1) buffer_size = default_filter_buffer_size; - int max_length = cvt_.get().max_length(); + std::streamsize max_length = cvt_.get().max_length(); buffer_size = (std::max)(buffer_size, 2 * max_length); if (can_read::value) { buf_.first().resize(buffer_size); @@ -223,7 +223,7 @@ struct code_converter_impl { //--------------Definition of converter---------------------------------------// -#define BOOST_IOSTREAMS_CONVERTER_PARAMS() , int buffer_size = -1 +#define BOOST_IOSTREAMS_CONVERTER_PARAMS() , std::streamsize buffer_size = -1 #define BOOST_IOSTREAMS_CONVERTER_ARGS() , buffer_size template<typename Device, typename Codecvt, typename Alloc> diff --git a/boost/iostreams/detail/config/codecvt.hpp b/boost/iostreams/detail/config/codecvt.hpp index b525c8435b..6519ddcd44 100644 --- a/boost/iostreams/detail/config/codecvt.hpp +++ b/boost/iostreams/detail/config/codecvt.hpp @@ -20,7 +20,8 @@ //------------------Support for codecvt with user-defined state types---------// #if defined(__MSL_CPP__) || defined(__LIBCOMO__) || \ - BOOST_WORKAROUND(_STLPORT_VERSION, <= 0x450) \ + BOOST_WORKAROUND(_STLPORT_VERSION, <= 0x450) || \ + defined(_LIBCPP_VERSION) \ /**/ # define BOOST_IOSTREAMS_NO_PRIMARY_CODECVT_DEFINITION #endif diff --git a/boost/iostreams/detail/config/fpos.hpp b/boost/iostreams/detail/config/fpos.hpp index e76cc30211..de8bdb84aa 100644 --- a/boost/iostreams/detail/config/fpos.hpp +++ b/boost/iostreams/detail/config/fpos.hpp @@ -25,7 +25,7 @@ #include <boost/config.hpp> # if (defined(_YVALS) || defined(_CPPLIB_VER)) && !defined(__SGI_STL_PORT) && \ - !defined(_STLPORT_VERSION) && !defined(__QNX__) + !defined(_STLPORT_VERSION) && !defined(__QNX__) && !defined(_VX_CPU) /**/ #include <boost/iostreams/detail/ios.hpp> diff --git a/boost/iostreams/detail/config/unreachable_return.hpp b/boost/iostreams/detail/config/unreachable_return.hpp index 97b3709952..65fba609de 100644 --- a/boost/iostreams/detail/config/unreachable_return.hpp +++ b/boost/iostreams/detail/config/unreachable_return.hpp @@ -13,7 +13,6 @@ #include <boost/config.hpp> -// If Boost.Exception has BOOST_ATTRIBUTE_NORETURN #if defined(_MSC_VER) || defined(__GNUC__) #define BOOST_IOSTREAMS_UNREACHABLE_RETURN(x) \ BOOST_UNREACHABLE_RETURN(x) diff --git a/boost/iostreams/detail/streambuf/indirect_streambuf.hpp b/boost/iostreams/detail/streambuf/indirect_streambuf.hpp index 8da5ef3c50..90e1e11531 100644 --- a/boost/iostreams/detail/streambuf/indirect_streambuf.hpp +++ b/boost/iostreams/detail/streambuf/indirect_streambuf.hpp @@ -107,7 +107,7 @@ private: bool can_read() const { return is_convertible<Mode, input>::value; } bool can_write() const { return is_convertible<Mode, output>::value; } bool output_buffered() const { return (flags_ & f_output_buffered) != 0; } - bool shared_buffer() const { return is_convertible<Mode, seekable>::value; } + bool shared_buffer() const { return is_convertible<Mode, seekable>::value || is_convertible<Mode, dual_seekable>::value; } void set_flags(int f) { flags_ = f; } //----------State changing functions--------------------------------------// @@ -169,16 +169,16 @@ void indirect_streambuf<T, Tr, Alloc, Mode>::open pback_size_ = (std::max)(std::streamsize(2), pback_size); // STLPort needs 2. std::streamsize size = pback_size_ + - ( buffer_size ? buffer_size: 1 ); - in().resize(size); + ( buffer_size ? buffer_size: std::streamsize(1) ); + in().resize(static_cast<int>(size)); if (!shared_buffer()) init_get_area(); } // Construct output buffer. if (can_write() && !shared_buffer()) { - if (buffer_size != 0) - out().resize(buffer_size); + if (buffer_size != std::streamsize(0)) + out().resize(static_cast<int>(buffer_size)); init_put_area(); } @@ -346,16 +346,31 @@ indirect_streambuf<T, Tr, Alloc, Mode>::seek_impl if ( gptr() != 0 && way == BOOST_IOS::cur && which == BOOST_IOS::in && eback() - gptr() <= off && off <= egptr() - gptr() ) { // Small seek optimization - gbump(off); - return obj().seek(0, BOOST_IOS::cur, BOOST_IOS::in, next_) - + gbump(static_cast<int>(off)); + return obj().seek(stream_offset(0), BOOST_IOS::cur, BOOST_IOS::in, next_) - static_cast<off_type>(egptr() - gptr()); } if (pptr() != 0) this->BOOST_IOSTREAMS_PUBSYNC(); // sync() confuses VisualAge 6. if (way == BOOST_IOS::cur && gptr()) off -= static_cast<off_type>(egptr() - gptr()); - setg(0, 0, 0); - setp(0, 0); + bool two_head = is_convertible<category, dual_seekable>::value || + is_convertible<category, bidirectional_seekable>::value; + if (two_head) { + BOOST_IOS::openmode both = BOOST_IOS::in | BOOST_IOS::out; + if ((which & both) == both) + boost::throw_exception(bad_seek()); + if (which & BOOST_IOS::in) { + setg(0, 0, 0); + } + if (which & BOOST_IOS::out) { + setp(0, 0); + } + } + else { + setg(0, 0, 0); + setp(0, 0); + } return obj().seek(off, way, which, next_); } @@ -394,7 +409,7 @@ void indirect_streambuf<T, Tr, Alloc, Mode>::sync_impl() else { const char_type* ptr = pptr(); setp(out().begin() + amt, out().end()); - pbump(ptr - pptr()); + pbump(static_cast<int>(ptr - pptr())); } } } @@ -413,8 +428,10 @@ template<typename T, typename Tr, typename Alloc, typename Mode> void indirect_streambuf<T, Tr, Alloc, Mode>::init_put_area() { using namespace std; - if (shared_buffer() && gptr() != 0) + if (shared_buffer() && gptr() != 0) { + obj().seek(static_cast<off_type>(gptr() - egptr()), BOOST_IOS::cur, BOOST_IOS::in, next_); setg(0, 0, 0); + } if (output_buffered()) setp(out().begin(), out().end()); else diff --git a/boost/iostreams/device/mapped_file.hpp b/boost/iostreams/device/mapped_file.hpp index 8ee11c47dd..1332beabd1 100644 --- a/boost/iostreams/device/mapped_file.hpp +++ b/boost/iostreams/device/mapped_file.hpp @@ -309,7 +309,7 @@ public: const char* const_data() const { return delegate_.data(); } iterator begin() const { return data(); } const_iterator const_begin() const { return const_data(); } - iterator end() const { return data() + size(); } + iterator end() const; const_iterator const_end() const { return const_data() + size(); } //--------------Query admissible offsets----------------------------------// @@ -469,6 +469,9 @@ void mapped_file::open( inline char* mapped_file::data() const { return (flags() != readonly) ? const_cast<char*>(delegate_.data()) : 0; } +inline mapped_file::iterator mapped_file::end() const +{ return (flags() != readonly) ? data() + size() : 0; } + //------------------Implementation of mapped_file_sink------------------------// template<typename Path> diff --git a/boost/iostreams/device/null.hpp b/boost/iostreams/device/null.hpp index 031c3e2fa2..a3943d7436 100644 --- a/boost/iostreams/device/null.hpp +++ b/boost/iostreams/device/null.hpp @@ -29,7 +29,7 @@ public: public device_tag, public closable_tag { }; - std::streamsize read(Ch*, std::streamsize) { return 0; } + std::streamsize read(Ch*, std::streamsize) { return -1; } std::streamsize write(const Ch*, std::streamsize n) { return n; } std::streampos seek( stream_offset, BOOST_IOS::seekdir, BOOST_IOS::openmode = diff --git a/boost/iostreams/filter/bzip2.hpp b/boost/iostreams/filter/bzip2.hpp index 7c1d1efc10..029338d1c6 100644 --- a/boost/iostreams/filter/bzip2.hpp +++ b/boost/iostreams/filter/bzip2.hpp @@ -87,9 +87,9 @@ const bool default_small = false; struct bzip2_params { // Non-explicit constructor for compression. - bzip2_params( int block_size = bzip2::default_block_size, - int work_factor = bzip2::default_work_factor ) - : block_size(block_size), work_factor(work_factor) + bzip2_params( int block_size_ = bzip2::default_block_size, + int work_factor_ = bzip2::default_work_factor ) + : block_size(block_size_), work_factor(work_factor_) { } // Constructor for decompression. @@ -242,7 +242,7 @@ public: typedef typename base_type::char_type char_type; typedef typename base_type::category category; basic_bzip2_compressor( const bzip2_params& = bzip2::default_block_size, - int buffer_size = default_device_buffer_size ); + std::streamsize buffer_size = default_device_buffer_size ); }; BOOST_IOSTREAMS_PIPABLE(basic_bzip2_compressor, 1) @@ -264,7 +264,7 @@ public: typedef typename base_type::char_type char_type; typedef typename base_type::category category; basic_bzip2_decompressor( bool small = bzip2::default_small, - int buffer_size = default_device_buffer_size ); + std::streamsize buffer_size = default_device_buffer_size ); }; BOOST_IOSTREAMS_PIPABLE(basic_bzip2_decompressor, 1) @@ -386,7 +386,7 @@ inline void bzip2_decompressor_impl<Alloc>::init() template<typename Alloc> basic_bzip2_compressor<Alloc>::basic_bzip2_compressor - (const bzip2_params& p, int buffer_size) + (const bzip2_params& p, std::streamsize buffer_size) : base_type(buffer_size, p) { } @@ -394,7 +394,7 @@ basic_bzip2_compressor<Alloc>::basic_bzip2_compressor template<typename Alloc> basic_bzip2_decompressor<Alloc>::basic_bzip2_decompressor - (bool small, int buffer_size) + (bool small, std::streamsize buffer_size) : base_type(buffer_size, small) { } diff --git a/boost/iostreams/filter/gzip.hpp b/boost/iostreams/filter/gzip.hpp index fb18224ea1..d7939c82d2 100644 --- a/boost/iostreams/filter/gzip.hpp +++ b/boost/iostreams/filter/gzip.hpp @@ -32,7 +32,7 @@ #include <boost/iostreams/detail/adapter/non_blocking_adapter.hpp> #include <boost/iostreams/detail/adapter/range_adapter.hpp> #include <boost/iostreams/detail/char_traits.hpp> -#include <boost/iostreams/detail/ios.hpp> // failure. +#include <boost/iostreams/detail/ios.hpp> // failure, streamsize. #include <boost/iostreams/detail/error.hpp> #include <boost/iostreams/operations.hpp> #include <boost/iostreams/device/back_inserter.hpp> @@ -143,11 +143,11 @@ struct gzip_params : zlib_params { int window_bits = gzip::default_window_bits, int mem_level = gzip::default_mem_level, int strategy = gzip::default_strategy, - std::string file_name = "", - std::string comment = "", - std::time_t mtime = 0 ) + std::string file_name_ = "", + std::string comment_ = "", + std::time_t mtime_ = 0 ) : zlib_params(level, method, window_bits, mem_level, strategy), - file_name(file_name), comment(comment), mtime(mtime) + file_name(file_name_), comment(comment_), mtime(mtime_) { } std::string file_name; std::string comment; @@ -197,7 +197,7 @@ public: closable_tag { }; basic_gzip_compressor( const gzip_params& = gzip::default_compression, - int buffer_size = default_device_buffer_size ); + std::streamsize buffer_size = default_device_buffer_size ); template<typename Source> std::streamsize read(Source& src, char_type* s, std::streamsize n) @@ -285,7 +285,7 @@ private: boost::iostreams::put(next, static_cast<char>(0xFF & (n >> 24))); } template<typename Sink> - static void write_long(long n, Sink& next, boost::mpl::false_) + static void write_long(long, Sink&, boost::mpl::false_) { } template<typename Sink> @@ -411,7 +411,7 @@ public: closable_tag { }; basic_gzip_decompressor( int window_bits = gzip::default_window_bits, - int buffer_size = default_device_buffer_size ); + std::streamsize buffer_size = default_device_buffer_size ); template<typename Sink> std::streamsize write(Sink& snk, const char_type* s, std::streamsize n) @@ -505,7 +505,7 @@ public: if (footer_.done()) { if (footer_.crc() != this->crc()) boost::throw_exception(gzip_error(gzip::bad_crc)); - int c = boost::iostreams::get(peek); + c = boost::iostreams::get(peek); if (traits_type::is_eof(c)) { state_ = s_done; } else { @@ -645,7 +645,7 @@ typedef basic_gzip_decompressor<> gzip_decompressor; template<typename Alloc> basic_gzip_compressor<Alloc>::basic_gzip_compressor - (const gzip_params& p, int buffer_size) + (const gzip_params& p, std::streamsize buffer_size) : base_type(normalize_params(p), buffer_size), offset_(0), flags_(0) { @@ -731,7 +731,7 @@ std::streamsize basic_gzip_compressor<Alloc>::read_string template<typename Alloc> basic_gzip_decompressor<Alloc>::basic_gzip_decompressor - (int window_bits, int buffer_size) + (int window_bits, std::streamsize buffer_size) : base_type(make_params(window_bits), buffer_size), state_(s_start) { } diff --git a/boost/iostreams/filter/symmetric.hpp b/boost/iostreams/filter/symmetric.hpp index 57ceea7727..f18089f4fb 100644 --- a/boost/iostreams/filter/symmetric.hpp +++ b/boost/iostreams/filter/symmetric.hpp @@ -42,13 +42,14 @@ #endif #include <boost/assert.hpp> -#include <memory> // allocator, auto_ptr. +#include <memory> // allocator. #include <boost/config.hpp> // BOOST_DEDUCED_TYPENAME. #include <boost/iostreams/char_traits.hpp> #include <boost/iostreams/constants.hpp> // buffer size. #include <boost/iostreams/detail/buffer.hpp> #include <boost/iostreams/detail/char_traits.hpp> #include <boost/iostreams/detail/config/limits.hpp> +#include <boost/iostreams/detail/ios.hpp> // streamsize. #include <boost/iostreams/detail/template_params.hpp> #include <boost/iostreams/traits.hpp> #include <boost/iostreams/operations.hpp> // read, write. @@ -85,7 +86,7 @@ public: #define BOOST_PP_LOCAL_MACRO(n) \ BOOST_IOSTREAMS_TEMPLATE_PARAMS(n, T) \ explicit symmetric_filter( \ - int buffer_size BOOST_PP_COMMA_IF(n) \ + std::streamsize buffer_size BOOST_PP_COMMA_IF(n) \ BOOST_PP_ENUM_BINARY_PARAMS(n, const T, &t) ) \ : pimpl_(new impl(buffer_size BOOST_PP_COMMA_IF(n) \ BOOST_PP_ENUM_PARAMS(n, t))) \ @@ -252,7 +253,7 @@ private: // Expands to a sequence of ctors which forward to SymmetricFilter. #define BOOST_PP_LOCAL_MACRO(n) \ BOOST_IOSTREAMS_TEMPLATE_PARAMS(n, T) \ - impl( int buffer_size BOOST_PP_COMMA_IF(n) \ + impl( std::streamsize buffer_size BOOST_PP_COMMA_IF(n) \ BOOST_PP_ENUM_BINARY_PARAMS(n, const T, &t) ) \ : SymmetricFilter(BOOST_PP_ENUM_PARAMS(n, t)), \ buf_(buffer_size), state_(0) \ diff --git a/boost/iostreams/filter/zlib.hpp b/boost/iostreams/filter/zlib.hpp index 848af89255..3d0de14a70 100644 --- a/boost/iostreams/filter/zlib.hpp +++ b/boost/iostreams/filter/zlib.hpp @@ -110,16 +110,16 @@ const bool default_noheader = false; struct zlib_params { // Non-explicit constructor. - zlib_params( int level = zlib::default_compression, - int method = zlib::deflated, - int window_bits = zlib::default_window_bits, - int mem_level = zlib::default_mem_level, - int strategy = zlib::default_strategy, - bool noheader = zlib::default_noheader, - bool calculate_crc = zlib::default_crc ) - : level(level), method(method), window_bits(window_bits), - mem_level(mem_level), strategy(strategy), - noheader(noheader), calculate_crc(calculate_crc) + zlib_params( int level_ = zlib::default_compression, + int method_ = zlib::deflated, + int window_bits_ = zlib::default_window_bits, + int mem_level_ = zlib::default_mem_level, + int strategy_ = zlib::default_strategy, + bool noheader_ = zlib::default_noheader, + bool calculate_crc_ = zlib::default_crc ) + : level(level_), method(method_), window_bits(window_bits_), + mem_level(mem_level_), strategy(strategy_), + noheader(noheader_), calculate_crc(calculate_crc_) { } int level; int method; @@ -263,7 +263,7 @@ public: typedef typename base_type::char_type char_type; typedef typename base_type::category category; basic_zlib_compressor( const zlib_params& = zlib::default_compression, - int buffer_size = default_device_buffer_size ); + std::streamsize buffer_size = default_device_buffer_size ); zlib::ulong crc() { return this->filter().crc(); } int total_in() { return this->filter().total_in(); } }; @@ -287,9 +287,9 @@ public: typedef typename base_type::char_type char_type; typedef typename base_type::category category; basic_zlib_decompressor( int window_bits = zlib::default_window_bits, - int buffer_size = default_device_buffer_size ); + std::streamsize buffer_size = default_device_buffer_size ); basic_zlib_decompressor( const zlib_params& p, - int buffer_size = default_device_buffer_size ); + std::streamsize buffer_size = default_device_buffer_size ); zlib::ulong crc() { return this->filter().crc(); } int total_out() { return this->filter().total_out(); } bool eof() { return this->filter().eof(); } @@ -347,7 +347,7 @@ bool zlib_compressor_impl<Alloc>::filter int result = xdeflate(flush ? zlib::finish : zlib::no_flush); after(src_begin, dest_begin, true); zlib_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result); - return result != zlib::stream_end; + return result != zlib::stream_end; } template<typename Alloc> @@ -396,19 +396,19 @@ void zlib_decompressor_impl<Alloc>::close() { template<typename Alloc> basic_zlib_compressor<Alloc>::basic_zlib_compressor - (const zlib_params& p, int buffer_size) + (const zlib_params& p, std::streamsize buffer_size) : base_type(buffer_size, p) { } //------------------Implementation of zlib_decompressor-----------------------// template<typename Alloc> basic_zlib_decompressor<Alloc>::basic_zlib_decompressor - (int window_bits, int buffer_size) + (int window_bits, std::streamsize buffer_size) : base_type(buffer_size, window_bits) { } template<typename Alloc> basic_zlib_decompressor<Alloc>::basic_zlib_decompressor - (const zlib_params& p, int buffer_size) + (const zlib_params& p, std::streamsize buffer_size) : base_type(buffer_size, p) { } //----------------------------------------------------------------------------// diff --git a/boost/iostreams/invert.hpp b/boost/iostreams/invert.hpp index 1d3787e13f..d4a17bf7f3 100644 --- a/boost/iostreams/invert.hpp +++ b/boost/iostreams/invert.hpp @@ -73,7 +73,7 @@ public: { } template<typename Source> - std::streamsize read(Source& src, char* s, std::streamsize n) + std::streamsize read(Source& src, char_type* s, std::streamsize n) { typedef detail::counted_array_sink<char_type> array_sink; typedef composite<filter_ref, array_sink> filtered_array_sink; @@ -101,7 +101,7 @@ public: } template<typename Sink> - std::streamsize write(Sink& dest, const char* s, std::streamsize n) + std::streamsize write(Sink& dest, const char_type* s, std::streamsize n) { typedef detail::counted_array_source<char_type> array_source; typedef composite<filter_ref, array_source> filtered_array_source; |