mirror of
https://github.com/boostorg/iostreams.git
synced 2026-02-22 03:22:24 +00:00
large seek offset support
[SVN r28227]
This commit is contained in:
@@ -24,13 +24,13 @@
|
||||
#include <boost/config.hpp> // BOOST_MSVC, template friends.
|
||||
#include <boost/detail/workaround.hpp>
|
||||
#include <boost/iostreams/constants.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/iostreams/detail/access_control.hpp>
|
||||
#include <boost/iostreams/detail/char_traits.hpp>
|
||||
#include <boost/iostreams/detail/push.hpp>
|
||||
#include <boost/iostreams/detail/streambuf.hpp> // pubsync.
|
||||
#include <boost/iostreams/detail/wrap_unwrap.hpp>
|
||||
#include <boost/iostreams/device/null.hpp>
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
#include <boost/iostreams/traits.hpp> // is_filter.
|
||||
#include <boost/iostreams/streambuf_facade.hpp>
|
||||
#include <boost/next_prior.hpp>
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek(std::streamoff off, BOOST_IOS::seekdir way);
|
||||
stream_offset seek(stream_offset off, BOOST_IOS::seekdir way);
|
||||
|
||||
//----------Direct component access---------------------------------------//
|
||||
|
||||
@@ -488,9 +488,9 @@ inline void chain_base<Self, Ch, Tr, Alloc, Mode>::write
|
||||
{ list().front()->sputn(s, n); }
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
inline std::streamoff chain_base<Self, Ch, Tr, Alloc, Mode>::seek
|
||||
(std::streamoff off, BOOST_IOS::seekdir way)
|
||||
{ return list().front()->pubseekoff(off, way); }
|
||||
inline stream_offset chain_base<Self, Ch, Tr, Alloc, Mode>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way)
|
||||
{ return iostreams::seek(*list().front(), off, way); }
|
||||
|
||||
template<typename Self, typename Ch, typename Tr, typename Alloc, typename Mode>
|
||||
void chain_base<Self, Ch, Tr, Alloc, Mode>::reset()
|
||||
|
||||
@@ -319,8 +319,6 @@ public:
|
||||
|
||||
std::streamsize read(char_type*, std::streamsize);
|
||||
void write(const char_type*, std::streamsize);
|
||||
std::streamoff seek( std::streamoff, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out );
|
||||
void imbue(const std::locale& loc) { impl().cvt_.imbue(loc); }
|
||||
|
||||
// Direct device access.
|
||||
|
||||
@@ -55,9 +55,9 @@ public:
|
||||
composite_device(const Filter& flt, param_type dev);
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek( std::streamoff off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
stream_offset seek( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
|
||||
void close(BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out);
|
||||
bool flush();
|
||||
@@ -112,9 +112,9 @@ public:
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff
|
||||
seek( Device& dev, std::streamoff off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out )
|
||||
stream_offset seek( Device& dev, stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out )
|
||||
{
|
||||
composite_device<Filter2, Device> cmp(filter2_, dev);
|
||||
return iostreams::seek(filter1_, cmp, off, way, which);
|
||||
@@ -286,8 +286,8 @@ inline void composite_device<Filter, Device>::write
|
||||
{ return iostreams::write(filter_, device_, s, n); }
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
std::streamoff composite_device<Filter, Device>::seek
|
||||
(std::streamoff off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
stream_offset composite_device<Filter, Device>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
{ return iostreams::seek(filter_, device_, off, way, which); }
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
|
||||
@@ -78,16 +78,16 @@ public:
|
||||
void write(const char_type* s, std::streamsize n, Sink* snk)
|
||||
{ output_impl::write(t_, snk, s, n); }
|
||||
|
||||
std::streamoff seek( std::streamoff off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
stream_offset seek( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{
|
||||
return this->seek( off, way, which,
|
||||
(basic_null_device<char_type, seekable>*) 0);
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff seek( std::streamoff off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which, Device* dev )
|
||||
stream_offset seek( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which, Device* dev )
|
||||
{ return any_impl::seek(t_, dev, off, way, which); }
|
||||
|
||||
void close(BOOST_IOS::openmode which)
|
||||
@@ -120,8 +120,8 @@ public:
|
||||
template<>
|
||||
struct device_wrapper_impl<any_tag> {
|
||||
template<typename Device, typename Dummy>
|
||||
static std::streamoff
|
||||
seek( Device& dev, Dummy*, std::streamoff off,
|
||||
static stream_offset
|
||||
seek( Device& dev, Dummy*, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which )
|
||||
{
|
||||
typedef typename io_category<Device>::type io_category;
|
||||
@@ -129,16 +129,16 @@ struct device_wrapper_impl<any_tag> {
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
static std::streamoff
|
||||
seek( Device&, std::streamoff, BOOST_IOS::seekdir,
|
||||
static stream_offset
|
||||
seek( Device&, stream_offset, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode, any_tag )
|
||||
{
|
||||
throw cant_seek();
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
static std::streamoff
|
||||
seek( Device& dev, std::streamoff off,
|
||||
static stream_offset
|
||||
seek( Device& dev, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which,
|
||||
random_access )
|
||||
{
|
||||
@@ -188,8 +188,8 @@ struct device_wrapper_impl<output> {
|
||||
template<>
|
||||
struct flt_wrapper_impl<any_tag> {
|
||||
template<typename Filter, typename Device>
|
||||
static std::streamoff
|
||||
seek( Filter& f, Device* dev, std::streamoff off,
|
||||
static stream_offset
|
||||
seek( Filter& f, Device* dev, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which )
|
||||
{
|
||||
typedef typename io_category<Filter>::type io_category;
|
||||
@@ -197,14 +197,14 @@ struct flt_wrapper_impl<any_tag> {
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
static std::streamoff
|
||||
seek( Filter&, Device*, std::streamoff,
|
||||
static stream_offset
|
||||
seek( Filter&, Device*, stream_offset,
|
||||
BOOST_IOS::seekdir, BOOST_IOS::openmode, any_tag )
|
||||
{ throw cant_seek(); }
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
static std::streamoff
|
||||
seek( Filter& f, Device* dev, std::streamoff off,
|
||||
static stream_offset
|
||||
seek( Filter& f, Device* dev, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which,
|
||||
random_access tag )
|
||||
{
|
||||
@@ -213,15 +213,15 @@ struct flt_wrapper_impl<any_tag> {
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
static std::streamoff
|
||||
seek( Filter& f, Device* dev, std::streamoff off,
|
||||
static stream_offset
|
||||
seek( Filter& f, Device* dev, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which,
|
||||
random_access, any_tag )
|
||||
{ return f.seek(*dev, off, way); }
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
static std::streamoff
|
||||
seek( Filter& f, Device* dev, std::streamoff off,
|
||||
static stream_offset
|
||||
seek( Filter& f, Device* dev, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which,
|
||||
random_access, two_sequence )
|
||||
{ return f.seek(*dev, off, way); }
|
||||
|
||||
@@ -108,8 +108,8 @@ public:
|
||||
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek( std::streamoff, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out );
|
||||
stream_offset seek( stream_offset, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out );
|
||||
void close();
|
||||
void close(BOOST_IOS::openmode which);
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
@@ -211,8 +211,8 @@ inline void direct_adapter<Direct>::write
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
inline std::streamoff direct_adapter<Direct>::seek
|
||||
( std::streamoff off, BOOST_IOS::seekdir way,
|
||||
inline stream_offset direct_adapter<Direct>::seek
|
||||
( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{
|
||||
using namespace std;
|
||||
@@ -245,7 +245,7 @@ inline std::streamoff direct_adapter<Direct>::seek
|
||||
else
|
||||
bad_seek();
|
||||
}
|
||||
return static_cast<std::streamoff>(next);
|
||||
return static_cast<stream_offset>(next);
|
||||
}
|
||||
|
||||
template<typename Direct>
|
||||
|
||||
@@ -48,9 +48,9 @@ public:
|
||||
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek( std::streamoff off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
stream_offset seek( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
void close(BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out);
|
||||
#endif
|
||||
@@ -66,12 +66,12 @@ public:
|
||||
{ iostreams::write(t_, snk, s, n); }
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff seek(Device& dev, std::streamoff off, BOOST_IOS::seekdir way)
|
||||
stream_offset seek(Device& dev, stream_offset off, BOOST_IOS::seekdir way)
|
||||
{ return iostreams::seek(t_, dev, off, way); }
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff seek( Device& dev, std::streamoff off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which )
|
||||
stream_offset seek( Device& dev, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode which )
|
||||
{ return iostreams::seek(t_, dev, off, way, which); }
|
||||
|
||||
template<typename Device>
|
||||
@@ -100,8 +100,8 @@ void mode_adapter<Mode, T>::write(const char_type* s, std::streamsize n)
|
||||
{ boost::iostreams::write(t_, s, n); }
|
||||
|
||||
template<typename Mode, typename T>
|
||||
std::streamoff mode_adapter<Mode, T>::seek
|
||||
(std::streamoff off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
stream_offset mode_adapter<Mode, T>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
{ return boost::iostreams::seek(t_, off, way, which); }
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
@@ -64,8 +64,8 @@ public:
|
||||
{ }
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek( std::streamoff, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out );
|
||||
stream_offset seek( std::streamoff, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out );
|
||||
Container container() const { return *pimpl_->cnt_; }
|
||||
void container(const Container& cnt)
|
||||
{
|
||||
@@ -120,8 +120,8 @@ void random_access_container<Container, Mode>::write
|
||||
}
|
||||
|
||||
template<typename Container, typename Mode>
|
||||
std::streamoff random_access_container<Container, Mode>::seek
|
||||
(std::streamoff off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
stream_offset random_access_container<Container, Mode>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
{
|
||||
using namespace std;
|
||||
if (way == BOOST_IOS::cur && pimpl_->gptr() != pimpl_->pptr())
|
||||
@@ -163,7 +163,7 @@ std::streamoff random_access_container<Container, Mode>::seek
|
||||
else
|
||||
bad_seek();
|
||||
}
|
||||
return static_cast<std::streamoff>(
|
||||
return static_cast<stream_offset>(
|
||||
(which & BOOST_IOS::in) ?
|
||||
pimpl_->gptr() :
|
||||
pimpl_->pptr()
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <iosfwd> // streamsize, streamoff.
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/error.hpp>
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
#include <boost/iterator/iterator_traits.hpp>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
@@ -54,7 +55,7 @@ public:
|
||||
range_adapter(iterator first, iterator last);
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek(std::streamoff off, BOOST_IOS::seekdir way);
|
||||
stream_offset seek(stream_offset off, BOOST_IOS::seekdir way);
|
||||
private:
|
||||
iterator first_, cur_, last_;
|
||||
};
|
||||
@@ -81,11 +82,11 @@ void range_adapter<Mode, Range>::write
|
||||
|
||||
|
||||
template<typename Mode, typename Range>
|
||||
std::streamoff range_adapter<Mode, Range>::seek
|
||||
(std::streamoff off, BOOST_IOS::seekdir way)
|
||||
stream_offset range_adapter<Mode, Range>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way)
|
||||
{
|
||||
impl::seek(first_, cur_, last_, off, way);
|
||||
return static_cast<std::streamoff>(cur_ - first_);
|
||||
return static_cast<stream_offset>(cur_ - first_);
|
||||
}
|
||||
|
||||
//------------------Implementation of range_adapter_impl----------------------//
|
||||
@@ -140,7 +141,7 @@ struct range_adapter_impl<random_access_traversal_tag> {
|
||||
|
||||
template<typename Iter>
|
||||
static void seek
|
||||
( Iter& first, Iter& cur, Iter& last, std::streamoff off,
|
||||
( Iter& first, Iter& cur, Iter& last, stream_offset off,
|
||||
BOOST_IOS::seekdir way )
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
#include <boost/iostreams/detail/push.hpp>
|
||||
#include <boost/iostreams/detail/streambuf/linked_streambuf.hpp>
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/iostreams/operations.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
@@ -113,7 +114,7 @@ private:
|
||||
|
||||
//----------Utility function----------------------------------------------//
|
||||
|
||||
pos_type seek_impl( off_type off, BOOST_IOS::seekdir way,
|
||||
pos_type seek_impl( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which );
|
||||
void sync_impl();
|
||||
void close_impl(BOOST_IOS::openmode);
|
||||
@@ -386,7 +387,7 @@ indirect_streambuf<T, Tr, Alloc, Mode>::seekpos
|
||||
template<typename T, typename Tr, typename Alloc, typename Mode>
|
||||
typename indirect_streambuf<T, Tr, Alloc, Mode>::pos_type
|
||||
indirect_streambuf<T, Tr, Alloc, Mode>::seek_impl
|
||||
(off_type off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
(stream_offset off, BOOST_IOS::seekdir way, BOOST_IOS::openmode which)
|
||||
{
|
||||
if (pptr() != 0) sync();
|
||||
if (way == BOOST_IOS::cur && gptr())
|
||||
|
||||
@@ -85,8 +85,8 @@ void write(T& t, Sink& snk, const typename io_char<T>::type* s, std::streamsize
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::streamoff
|
||||
seek( T& t, std::streamoff off, BOOST_IOS::seekdir way,
|
||||
inline stream_offset
|
||||
seek( T& t, stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out )
|
||||
{ return detail::seek_impl<T>::seek(detail::unwrap(t), off, way, which); }
|
||||
|
||||
@@ -371,26 +371,35 @@ struct seek_impl
|
||||
template<>
|
||||
struct seek_impl<any_tag> {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode )
|
||||
static stream_offset seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way, BOOST_IOS::openmode )
|
||||
{ return t.seek(off, way); }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct seek_impl<two_head> {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
static stream_offset seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{ return t.seek(off, way, which); }
|
||||
};
|
||||
|
||||
struct seek_impl_basic_ios {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{ return t.rdbuf()->pubseekoff(off, way, which); }
|
||||
static stream_offset seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{
|
||||
if ( way == BOOST_IOS::beg &&
|
||||
( off < integer_traits<std::streamoff>::const_min ||
|
||||
off > integer_traits<std::streamoff>::const_max ) )
|
||||
{
|
||||
return t.rdbuf()->pubseekpos(offset_to_position(off));
|
||||
} else {
|
||||
return t.rdbuf()->pubseekoff(off, way, which);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -405,10 +414,19 @@ struct seek_impl<iostream_tag> : seek_impl_basic_ios { };
|
||||
template<>
|
||||
struct seek_impl<streambuf_tag> {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{ return t.pubseekoff(off, way, which); }
|
||||
static stream_offset seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{
|
||||
if ( way == BOOST_IOS::beg &&
|
||||
( off < integer_traits<std::streamoff>::const_min ||
|
||||
off > integer_traits<std::streamoff>::const_max ) )
|
||||
{
|
||||
return t.pubseekpos(offset_to_position(off));
|
||||
} else {
|
||||
return t.pubseekoff(off, way, which);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//------------------Definition of close_impl----------------------------------//
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, seekdir, int types.
|
||||
#include <boost/iostreams/detail/fstream.hpp>
|
||||
#include <boost/iostreams/detail/streambuf.hpp> // pubseekoff.
|
||||
#include <boost/iostreams/operations.hpp> // seek.
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
|
||||
@@ -50,9 +50,9 @@ public:
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek( std::streamoff off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
stream_offset seek( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which =
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
void close();
|
||||
#ifndef BOOST_IOSTREAMS_NO_LOCALE
|
||||
void imbue(const std::locale& loc) { pimpl_->file_.pubimbue(loc); }
|
||||
@@ -130,10 +130,10 @@ inline void basic_file<Ch>::write
|
||||
{ pimpl_->file_.sputn(s, n); }
|
||||
|
||||
template<typename Ch>
|
||||
std::streamoff basic_file<Ch>::seek
|
||||
( std::streamoff off, BOOST_IOS::seekdir way,
|
||||
stream_offset basic_file<Ch>::seek
|
||||
( stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode )
|
||||
{ return pimpl_->file_.BOOST_IOSTREAMS_PUBSEEKOFF(off, way); }
|
||||
{ return iostreams::seek(pimpl_->file_, off, way); }
|
||||
|
||||
template<typename Ch>
|
||||
void basic_file<Ch>::close() { pimpl_->file_.close(); }
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <boost/iostreams/detail/config/dyn_link.hpp>
|
||||
#include <boost/iostreams/detail/config/windows_posix.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, seekdir, int types.
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
// Must come last.
|
||||
@@ -61,7 +62,7 @@ public:
|
||||
BOOST_IOS::in | BOOST_IOS::out );
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
boost::intmax_t seek(boost::intmax_t off, BOOST_IOS::seekdir way);
|
||||
stream_offset seek(stream_offset off, BOOST_IOS::seekdir way);
|
||||
void close();
|
||||
private:
|
||||
struct impl {
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#endif
|
||||
|
||||
#include <boost/iostreams/categories.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, streamsize, streamoff.
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmode, streamsize.
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
|
||||
namespace boost { namespace iostreams {
|
||||
|
||||
@@ -29,9 +30,9 @@ public:
|
||||
{ };
|
||||
std::streamsize read(Ch*, std::streamsize) { return 0; }
|
||||
void write(const Ch*, std::streamsize) { }
|
||||
std::streamoff seek( std::streamoff, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode =
|
||||
BOOST_IOS::in | BOOST_IOS::out )
|
||||
stream_offset seek( stream_offset, BOOST_IOS::seekdir,
|
||||
BOOST_IOS::openmode =
|
||||
BOOST_IOS::in | BOOST_IOS::out )
|
||||
{ return -1; }
|
||||
void close(BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out) { }
|
||||
};
|
||||
|
||||
@@ -56,13 +56,13 @@ public:
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
offset_indirect_device( param_type dev, std::streamoff off,
|
||||
std::streamoff len );
|
||||
offset_indirect_device( param_type dev, stream_offset off,
|
||||
stream_offset len );
|
||||
std::streamsize read(char_type* s, std::streamsize n);
|
||||
void write(const char_type* s, std::streamsize n);
|
||||
std::streamoff seek(std::streamoff off, BOOST_IOS::seekdir way);
|
||||
stream_offset seek(stream_offset off, BOOST_IOS::seekdir way);
|
||||
private:
|
||||
std::streamoff beg_, pos_, end_;
|
||||
stream_offset beg_, pos_, end_;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
closable_tag,
|
||||
localizable_tag
|
||||
{ };
|
||||
offset_direct_device( const Device& dev, std::streamoff off,
|
||||
std::streamoff len );
|
||||
offset_direct_device( const Device& dev, stream_offset off,
|
||||
stream_offset len );
|
||||
pair_type input_sequence();
|
||||
pair_type output_sequence();
|
||||
private:
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
localizable_tag,
|
||||
optimally_buffered_tag
|
||||
{ };
|
||||
offset_filter(const Filter& flt, std::streamoff off, std::streamoff len);
|
||||
offset_filter(const Filter& flt, stream_offset off, stream_offset len);
|
||||
|
||||
template<typename Source>
|
||||
std::streamsize read(Source& src, char_type* s, std::streamsize n)
|
||||
@@ -138,9 +138,9 @@ public:
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff seek(Device& dev, std::streamoff off, BOOST_IOS::seekdir way)
|
||||
stream_offset seek(Device& dev, stream_offset off, BOOST_IOS::seekdir way)
|
||||
{
|
||||
std::streamoff next;
|
||||
stream_offset next;
|
||||
if (way == BOOST_IOS::beg) {
|
||||
next = beg_ + off;
|
||||
} else if (way == BOOST_IOS::cur) {
|
||||
@@ -160,8 +160,8 @@ private:
|
||||
open_ = true;
|
||||
pos_ = iostreams::skip(this->component(), dev, beg_);
|
||||
}
|
||||
std::streamoff beg_, pos_, end_;
|
||||
bool open_;
|
||||
stream_offset beg_, pos_, end_;
|
||||
bool open_;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -178,7 +178,7 @@ struct offset_traits
|
||||
template<typename T>
|
||||
struct offset_view : public detail::offset_traits<T>::type {
|
||||
typedef typename detail::param_type<T>::type param_type;
|
||||
offset_view(param_type t, std::streamoff off, std::streamoff len)
|
||||
offset_view(param_type t, stream_offset off, stream_offset len)
|
||||
: detail::offset_traits<T>::type(t, off, len)
|
||||
{ }
|
||||
};
|
||||
@@ -192,7 +192,7 @@ struct offset_view : public detail::offset_traits<T>::type {
|
||||
# ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-------------------------------//
|
||||
|
||||
template<typename T>
|
||||
offset_view<T> offset( const T& t, std::streamoff off, std::streamoff len
|
||||
offset_view<T> offset( const T& t, stream_offset off, stream_offset len
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
|
||||
{ return offset_view<T>(t, off, len); }
|
||||
|
||||
@@ -219,7 +219,7 @@ offset(std::basic_iostream<Ch, Tr>& io)
|
||||
# else // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //---------------------//
|
||||
|
||||
template<typename T>
|
||||
offset_view<T> offset( const T& t, std::streamoff off, std::streamoff len
|
||||
offset_view<T> offset( const T& t, stream_offset off, stream_offset len
|
||||
BOOST_IOSTREAMS_DISABLE_IF_STREAM(T) )
|
||||
{ return offset_view<T>(t, off, len); }
|
||||
|
||||
@@ -269,7 +269,7 @@ namespace detail {
|
||||
|
||||
template<typename Device>
|
||||
offset_indirect_device<Device>::offset_indirect_device
|
||||
(param_type dev, std::streamoff off, std::streamoff len)
|
||||
(param_type dev, stream_offset off, stream_offset len)
|
||||
: basic_adapter<Device>(dev), beg_(off), pos_(off), end_(off + len)
|
||||
{
|
||||
if (len < 0 || off < 0)
|
||||
@@ -300,10 +300,10 @@ inline void offset_indirect_device<Device>::write
|
||||
}
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff offset_indirect_device<Device>::seek
|
||||
(std::streamoff off, BOOST_IOS::seekdir way)
|
||||
stream_offset offset_indirect_device<Device>::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way)
|
||||
{
|
||||
std::streamoff next;
|
||||
stream_offset next;
|
||||
if (way == BOOST_IOS::beg) {
|
||||
next = beg_ + off;
|
||||
} else if (way == BOOST_IOS::cur) {
|
||||
@@ -321,7 +321,7 @@ std::streamoff offset_indirect_device<Device>::seek
|
||||
|
||||
template<typename Device>
|
||||
offset_direct_device<Device>::offset_direct_device
|
||||
(const Device& dev, std::streamoff off, std::streamoff len)
|
||||
(const Device& dev, stream_offset off, stream_offset len)
|
||||
: basic_adapter<Device>(dev), beg_(0), end_(0)
|
||||
{
|
||||
std::pair<char_type*, char_type*> seq =
|
||||
@@ -362,7 +362,7 @@ offset_direct_device<Device>::sequence(mpl::false_)
|
||||
|
||||
template<typename Filter>
|
||||
offset_filter<Filter>::offset_filter
|
||||
(const Filter& flt, std::streamoff off, std::streamoff len)
|
||||
(const Filter& flt, stream_offset off, stream_offset len)
|
||||
: basic_adapter<Filter>(flt), beg_(off),
|
||||
pos_(off), end_(off + len), open_(false)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
#include <boost/iostreams/detail/dispatch.hpp>
|
||||
#include <boost/iostreams/detail/streambuf.hpp>
|
||||
#include <boost/iostreams/detail/wrap_unwrap.hpp>
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
#include <boost/iostreams/traits.hpp>
|
||||
#include <boost/integer_traits.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/identity.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
@@ -27,6 +29,8 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp>
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-----------------------------------//
|
||||
# include <boost/iostreams/detail/vc6/operations.hpp>
|
||||
#else // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //--------------------------//
|
||||
@@ -92,12 +96,13 @@ inline void write(T& t, const typename io_char<T>::type* s, std::streamsize n)
|
||||
{ detail::write_impl<T>::write(detail::unwrap(t), s, n); }
|
||||
|
||||
template<typename T, typename Sink>
|
||||
void write(T& t, Sink& snk, const typename io_char<T>::type* s, std::streamsize n)
|
||||
void write( T& t, Sink& snk, const typename io_char<T>::type* s,
|
||||
std::streamsize n )
|
||||
{ detail::filter_impl<T>::write(detail::unwrap(t), snk, s, n); }
|
||||
|
||||
template<typename T>
|
||||
inline std::streamoff
|
||||
seek( T& t, std::streamoff off, BOOST_IOS::seekdir way,
|
||||
inline std::streampos
|
||||
seek( T& t, stream_offset off, BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which = BOOST_IOS::in | BOOST_IOS::out )
|
||||
{ return detail::seek_impl<T>::seek(detail::unwrap(t), off, way, which); }
|
||||
|
||||
@@ -372,10 +377,19 @@ struct seek_impl
|
||||
|
||||
struct seek_impl_basic_ios {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
static std::streampos seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{ return t.rdbuf()->pubseekoff(off, way, which); }
|
||||
{
|
||||
if ( way == BOOST_IOS::beg &&
|
||||
( off < integer_traits<std::streamoff>::const_min ||
|
||||
off > integer_traits<std::streamoff>::const_max ) )
|
||||
{
|
||||
return t.rdbuf()->pubseekpos(offset_to_position(off));
|
||||
} else {
|
||||
return t.rdbuf()->pubseekoff(off, way, which);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
@@ -390,28 +404,37 @@ struct seek_impl<ostream_tag> : seek_impl_basic_ios { };
|
||||
template<>
|
||||
struct seek_impl<streambuf_tag> {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
static std::streampos seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{ return t.pubseekoff(off, way, which); }
|
||||
{
|
||||
if ( way == BOOST_IOS::beg &&
|
||||
( off < integer_traits<std::streamoff>::const_min ||
|
||||
off > integer_traits<std::streamoff>::const_max ) )
|
||||
{
|
||||
return t.pubseekpos(offset_to_position(off));
|
||||
} else {
|
||||
return t.pubseekoff(off, way, which);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct seek_impl<two_head> {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
static std::streampos seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode which )
|
||||
{ return static_cast<std::streamoff>(t.seek(off, way, which)); }
|
||||
{ return t.seek(off, way, which); }
|
||||
};
|
||||
|
||||
template<>
|
||||
struct seek_impl<any_tag> {
|
||||
template<typename T>
|
||||
static std::streamoff seek( T& t, std::streamoff off,
|
||||
static std::streampos seek( T& t, stream_offset off,
|
||||
BOOST_IOS::seekdir way,
|
||||
BOOST_IOS::openmode )
|
||||
{ return static_cast<std::streamoff>(t.seek(off, way)); }
|
||||
{ return t.seek(off, way); }
|
||||
};
|
||||
|
||||
//------------------Definition of close_impl----------------------------------//
|
||||
@@ -639,5 +662,7 @@ struct optimal_buffer_size_impl<filter_tag> {
|
||||
|
||||
} } // End namespaces iostreams, boost.
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
#endif // #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) //-------------------------//
|
||||
#endif // #ifndef BOOST_IOSTREAMS_OPERATIONS_HPP_INCLUDED //------------------//
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#endif
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/integer_traits.hpp>
|
||||
#include <boost/iostreams/detail/config/codecvt.hpp> // mbstate_t.
|
||||
#include <boost/iostreams/detail/ios.hpp> // streamoff, streampos.
|
||||
|
||||
@@ -22,6 +23,17 @@ namespace boost { namespace iostreams {
|
||||
|
||||
typedef boost::intmax_t stream_offset;
|
||||
|
||||
#include <boost/iostreams/detail/config/disable_warnings.hpp> // VC7.1.
|
||||
|
||||
inline std::streamoff stream_offset_to_streamoff(stream_offset off)
|
||||
{ return static_cast<stream_offset>(off); }
|
||||
|
||||
#include <boost/iostreams/detail/config/enable_warnings.hpp>
|
||||
|
||||
template<typename PosType> // Hande custom pos_type's.
|
||||
inline stream_offset position_to_offset(PosType pos)
|
||||
{ return std::streamoff(pos); }
|
||||
|
||||
#if ((defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)) && \
|
||||
!defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) \
|
||||
/**/
|
||||
|
||||
@@ -24,26 +24,26 @@ namespace boost { namespace iostreams {
|
||||
namespace detail {
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff skip(Device& dev, std::streamoff off, mpl::true_)
|
||||
stream_offset skip(Device& dev, stream_offset off, mpl::true_)
|
||||
{ return iostreams::seek(dev, off, BOOST_IOS::cur); }
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff skip(Device& dev, std::streamoff off, mpl::false_)
|
||||
stream_offset skip(Device& dev, stream_offset off, mpl::false_)
|
||||
{
|
||||
for (std::streamoff z = 0; z < off; ++z)
|
||||
for (stream_offset z = 0; z < off; ++z)
|
||||
iostreams::get(dev);
|
||||
return off;
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
std::streamoff skip(Filter& flt, Device& dev, std::streamoff off, mpl::true_)
|
||||
stream_offset skip(Filter& flt, Device& dev, stream_offset off, mpl::true_)
|
||||
{ return flt.seek(dev, off, BOOST_IOS::cur); }
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
std::streamoff skip(Filter& flt, Device& dev, std::streamoff off, mpl::false_)
|
||||
stream_offset skip(Filter& flt, Device& dev, stream_offset off, mpl::false_)
|
||||
{
|
||||
char c;
|
||||
for (std::streamoff z = 0; z < off; ++z)
|
||||
for (stream_offset z = 0; z < off; ++z)
|
||||
iostreams::read(flt, dev, &c, 1);
|
||||
return off;
|
||||
}
|
||||
@@ -51,14 +51,14 @@ std::streamoff skip(Filter& flt, Device& dev, std::streamoff off, mpl::false_)
|
||||
} // End namespace detail.
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff skip(Device& dev, std::streamoff off)
|
||||
stream_offset skip(Device& dev, stream_offset off)
|
||||
{
|
||||
typedef typename io_mode<Device>::type mode;
|
||||
return detail::skip(dev, off, is_convertible<mode, seekable>());
|
||||
}
|
||||
|
||||
template<typename Filter, typename Device>
|
||||
std::streamoff skip(Filter& flt, Device& dev, std::streamoff off)
|
||||
stream_offset skip(Filter& flt, Device& dev, stream_offset off)
|
||||
{
|
||||
typedef typename io_mode<Filter>::type filter_mode;
|
||||
typedef typename io_mode<Device>::type device_mode;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <boost/iostreams/detail/config/windows_posix.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp> // openmodes, failure.
|
||||
#include <boost/iostreams/device/file_descriptor.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/integer_traits.hpp>
|
||||
|
||||
// OS-specific headers for low-level i/o.
|
||||
|
||||
@@ -174,8 +174,8 @@ void file_descriptor::write(const char_type* s, std::streamsize n)
|
||||
throw detail::bad_write();
|
||||
}
|
||||
|
||||
boost::intmax_t file_descriptor::seek
|
||||
(boost::intmax_t off, BOOST_IOS::seekdir way)
|
||||
stream_offset file_descriptor::seek
|
||||
(stream_offset off, BOOST_IOS::seekdir way)
|
||||
{
|
||||
using namespace std;
|
||||
#ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
@@ -201,20 +201,26 @@ boost::intmax_t file_descriptor::seek
|
||||
dwResultLow;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ( off > (numeric_limits<long>::max)() ||
|
||||
off < (numeric_limits<long>::min)() )
|
||||
#else // #ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
# ifndef BOOST_IOSTREAMS_HAS_LSEEK64
|
||||
if ( off > integer_traits<long>::const_max ||
|
||||
off < integer_traits<long>::const_min )
|
||||
{
|
||||
throw BOOST_IOSTREAMS_FAILURE("bad offset");
|
||||
}
|
||||
std::streamoff result =
|
||||
#if !defined(__BORLANDC__)
|
||||
BOOST_RTL(lseek)
|
||||
# endif
|
||||
stream_offset result =
|
||||
#ifdef BOOST_IOSTREAMS_HAS_LSEEK64
|
||||
lseek64
|
||||
#else
|
||||
lseek
|
||||
#endif
|
||||
( pimpl_->fd_,
|
||||
static_cast<long>(off),
|
||||
#ifdef BOOST_IOSTREAMS_HAS_LSEEK64
|
||||
off,
|
||||
#else
|
||||
static_cast<long>(off),
|
||||
#endif
|
||||
way == BOOST_IOS::beg ?
|
||||
SEEK_SET :
|
||||
way == BOOST_IOS::cur ?
|
||||
@@ -223,6 +229,7 @@ boost::intmax_t file_descriptor::seek
|
||||
if (result == -1)
|
||||
throw detail::bad_seek();
|
||||
return result;
|
||||
#endif // #ifdef BOOST_IOSTREAMS_WINDOWS
|
||||
}
|
||||
|
||||
void file_descriptor::close() { close_impl(*pimpl_); }
|
||||
|
||||
@@ -175,7 +175,7 @@ struct identity_seekable_filter : filter<seekable> {
|
||||
void put(Sink& s, char c) { boost::iostreams::put(s, c); }
|
||||
|
||||
template<typename Device>
|
||||
std::streamoff seek(Device& d, std::streamoff off, BOOST_IOS::seekdir way)
|
||||
stream_offset seek(Device& d, stream_offset off, BOOST_IOS::seekdir way)
|
||||
{ return boost::iostreams::seek(d, off, way); }
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(identity_seekable_filter, 0)
|
||||
@@ -188,7 +188,7 @@ struct identity_seekable_multichar_filter : multichar_filter<seekable> {
|
||||
void write(Sink& s, const char* buf, std::streamsize n)
|
||||
{ boost::iostreams::write(s, buf, n); }
|
||||
template<typename Device>
|
||||
std::streamoff seek(Device& d, std::streamoff off, BOOST_IOS::seekdir way)
|
||||
stream_offset seek(Device& d, stream_offset off, BOOST_IOS::seekdir way)
|
||||
{ return boost::iostreams::seek(d, off, way); }
|
||||
};
|
||||
BOOST_IOSTREAMS_PIPABLE(identity_seekable_multichar_filter, 0)
|
||||
|
||||
@@ -111,7 +111,7 @@ struct tolower_seekable_filter : public seekable_filter {
|
||||
}
|
||||
|
||||
template<typename Sink>
|
||||
std::streamoff seek(Sink& s, std::streamoff off, BOOST_IOS::seekdir way)
|
||||
stream_offset seek(Sink& s, stream_offset off, BOOST_IOS::seekdir way)
|
||||
{
|
||||
return boost::iostreams::seek(s, off, way);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ void read_device()
|
||||
{
|
||||
offset_test_file src1(small_padding);
|
||||
test_file src2;
|
||||
streamoff off = small_padding,
|
||||
stream_offset off = small_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_istream first(offset(file_source(src1.name(), in_mode), off, len));
|
||||
ifstream second(src2.name().c_str(), in_mode);
|
||||
@@ -135,7 +135,7 @@ void read_device()
|
||||
{
|
||||
offset_test_file src1(large_padding);
|
||||
test_file src2;
|
||||
streamoff off = large_padding,
|
||||
stream_offset off = large_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_istream first(offset(file_source(src1.name(), in_mode), off, len));
|
||||
ifstream second(src2.name().c_str(), in_mode);
|
||||
@@ -152,7 +152,7 @@ void read_direct_device()
|
||||
test_sequence<char> first;
|
||||
offset_test_sequence src(small_padding);
|
||||
array_source array_src(&src[0], &src[0] + src.size());
|
||||
streamoff off = small_padding,
|
||||
stream_offset off = small_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_istream second(offset(array_src, off, len));
|
||||
BOOST_CHECK_MESSAGE(
|
||||
@@ -166,7 +166,7 @@ void read_filter()
|
||||
{
|
||||
offset_test_file src1(small_padding);
|
||||
uppercase_file src2;
|
||||
streamoff off = small_padding,
|
||||
stream_offset off = small_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_istream first;
|
||||
first.push(offset(toupper_filter(), off, len));
|
||||
@@ -181,7 +181,7 @@ void read_filter()
|
||||
{
|
||||
offset_test_file src1(large_padding);
|
||||
uppercase_file src2;
|
||||
streamoff off = large_padding,
|
||||
stream_offset off = large_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_istream first;
|
||||
first.push(offset(toupper_filter(), off, len));
|
||||
@@ -199,7 +199,7 @@ void write_device()
|
||||
{
|
||||
offset_uppercase_file dest1(small_padding);
|
||||
offset_test_file dest2(small_padding);
|
||||
streamoff off = small_padding,
|
||||
stream_offset off = small_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_ostream out(offset(file(dest1.name(), BOOST_IOS::binary), off, len));
|
||||
write_data_in_chunks(out);
|
||||
@@ -215,7 +215,7 @@ void write_device()
|
||||
{
|
||||
offset_uppercase_file dest1(large_padding);
|
||||
offset_test_file dest2(large_padding);
|
||||
streamoff off = large_padding,
|
||||
stream_offset off = large_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_ostream out(offset(file(dest1.name(), BOOST_IOS::binary), off, len));
|
||||
write_data_in_chunks(out);
|
||||
@@ -233,7 +233,7 @@ void write_direct_device()
|
||||
{
|
||||
vector<char> dest1(data_reps * data_length() + 2 * small_padding, '\n');
|
||||
offset_test_sequence dest2(small_padding);
|
||||
streamoff off = small_padding,
|
||||
stream_offset off = small_padding,
|
||||
len = data_reps * data_length();
|
||||
array_sink array(&dest1[0], &dest1[0] + dest1.size());
|
||||
filtering_ostream out(offset(array, off, len));
|
||||
@@ -250,7 +250,7 @@ void write_filter()
|
||||
{
|
||||
offset_test_file dest1(small_padding);
|
||||
offset_lowercase_file dest2(small_padding);
|
||||
streamoff off = small_padding,
|
||||
stream_offset off = small_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_ostream out;
|
||||
out.push(offset(tolower_seekable_filter(), off, len));
|
||||
@@ -268,7 +268,7 @@ void write_filter()
|
||||
{
|
||||
offset_test_file dest1(large_padding);
|
||||
offset_lowercase_file dest2(large_padding);
|
||||
streamoff off = large_padding,
|
||||
stream_offset off = large_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_ostream out;
|
||||
out.push(offset(tolower_seekable_filter(), off, len));
|
||||
@@ -287,7 +287,7 @@ void write_filter()
|
||||
void seek_device()
|
||||
{
|
||||
offset_test_file src(small_padding);
|
||||
streamoff off = large_padding,
|
||||
stream_offset off = large_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_stream<seekable> io(offset(file(src.name(), BOOST_IOS::binary), off, len));
|
||||
BOOST_CHECK_MESSAGE(
|
||||
@@ -299,7 +299,7 @@ void seek_device()
|
||||
void seek_direct_device()
|
||||
{
|
||||
vector<char> src(data_reps * data_length() + 2 * small_padding, '\n');
|
||||
streamoff off = small_padding,
|
||||
stream_offset off = small_padding,
|
||||
len = data_reps * data_length();
|
||||
array ar(&src[0], &src[0] + src.size());
|
||||
filtering_stream<seekable> io(offset(ar, off, len));
|
||||
@@ -312,7 +312,7 @@ void seek_direct_device()
|
||||
void seek_filter()
|
||||
{
|
||||
offset_test_file src(small_padding);
|
||||
streamoff off = large_padding,
|
||||
stream_offset off = large_padding,
|
||||
len = data_reps * data_length();
|
||||
filtering_stream<seekable> io;
|
||||
io.push(offset(identity_seekable_filter(), off, len));
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
|
||||
// See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
#include <limits>
|
||||
//#include <boost/limits.hpp>
|
||||
#include <boost/iostreams/detail/ios.hpp>
|
||||
#include <boost/iostreams/positioning.hpp>
|
||||
#include <boost/integer_traits.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
@@ -18,15 +17,15 @@ using namespace boost;
|
||||
using namespace boost::iostreams;
|
||||
using boost::unit_test::test_suite;
|
||||
|
||||
void extrema_test_test()
|
||||
{
|
||||
stream_offset minoff = numeric_limits<stream_offset>::min();
|
||||
stream_offset maxoff = numeric_limits<stream_offset>::max();
|
||||
|
||||
BOOST_CHECK(minoff == position_to_offset(offset_to_position(minoff)));
|
||||
BOOST_CHECK(0 == position_to_offset(offset_to_position(0)));
|
||||
BOOST_CHECK(maxoff == position_to_offset(offset_to_position(maxoff)));
|
||||
}
|
||||
//void extrema_test_test()
|
||||
//{
|
||||
// stream_offset minoff = integer_traits<stream_offset>::const_min;
|
||||
// stream_offset maxoff = integer_traits<stream_offset>::const_max;
|
||||
//
|
||||
// BOOST_CHECK(minoff == position_to_offset(offset_to_position(minoff)));
|
||||
// BOOST_CHECK(0 == position_to_offset(offset_to_position(0)));
|
||||
// BOOST_CHECK(maxoff == position_to_offset(offset_to_position(maxoff)));
|
||||
//}
|
||||
|
||||
void large_file_test()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user