|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63303 - in branches/release: . boost boost/algorithm/string boost/archive boost/bimap boost/config boost/detail boost/filesystem boost/functional/hash boost/fusion boost/gil boost/graph boost/integer boost/interprocess boost/intrusive boost/iostreams boost/iostreams/detail boost/iostreams/detail/adapter boost/iostreams/detail/streambuf boost/iostreams/device boost/iostreams/filter boost/math boost/msm boost/numeric/ublas boost/program_options boost/property_tree boost/python boost/range boost/regex boost/serialization boost/signals boost/signals2 boost/spirit boost/spirit/home boost/spirit/home/karma boost/spirit/home/support boost/statechart boost/system boost/thread boost/tr1 boost/type_traits boost/unordered boost/utility boost/uuid boost/variant boost/wave doc libs libs/array/doc libs/array/test libs/bimap libs/config libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/iostreams libs/iostreams/build libs/iostreams/doc/classes libs/iostreams/src libs/iostreams/test libs/iostreams/test/detail libs/math libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/python libs/range libs/range/doc libs/regex libs/serialization libs/signals libs/signals2 libs/spirit libs/spirit/classic/example libs/spirit/doc libs/spirit/example libs/spirit/phoenix libs/spirit/test libs/spirit/test/qi libs/statechart libs/static_assert libs/system libs/thread libs/timer libs/tr1 libs/type_traits libs/unordered libs/utility libs/utility/swap/test libs/uuid libs/wave more more/getting_started people status tools tools/bcp tools/boostbook tools/build/v2 tools/build/v2/tools tools/inspect tools/jam tools/quickbook tools/regression tools/release tools/wave wiki
From: steven_at_[hidden]
Date: 2010-06-25 03:20:00
Author: steven_watanabe
Date: 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
New Revision: 63303
URL: http://svn.boost.org/trac/boost/changeset/63303
Log:
Merge iostreams from the trunk.
Properties modified:
branches/release/ (props changed)
branches/release/INSTALL (props changed)
branches/release/Jamroot (props changed)
branches/release/LICENSE_1_0.txt (props changed)
branches/release/boost/ (props changed)
branches/release/boost-build.jam (props changed)
branches/release/boost.css (props changed)
branches/release/boost.png (props changed)
branches/release/boost/algorithm/string/ (props changed)
branches/release/boost/archive/ (props changed)
branches/release/boost/array.hpp (props changed)
branches/release/boost/bimap/ (props changed)
branches/release/boost/config/ (props changed)
branches/release/boost/config.hpp (props changed)
branches/release/boost/detail/ (props changed)
branches/release/boost/detail/endian.hpp (props changed)
branches/release/boost/filesystem/ (props changed)
branches/release/boost/functional/hash/ (props changed)
branches/release/boost/fusion/ (props changed)
branches/release/boost/gil/ (props changed)
branches/release/boost/graph/ (props changed)
branches/release/boost/integer/ (props changed)
branches/release/boost/interprocess/ (props changed)
branches/release/boost/intrusive/ (props changed)
branches/release/boost/iostreams/ (props changed)
branches/release/boost/math/ (props changed)
branches/release/boost/msm/ (props changed)
branches/release/boost/numeric/ublas/ (props changed)
branches/release/boost/program_options/ (props changed)
branches/release/boost/property_tree/ (props changed)
branches/release/boost/python/ (props changed)
branches/release/boost/range/ (props changed)
branches/release/boost/regex/ (props changed)
branches/release/boost/serialization/ (props changed)
branches/release/boost/serialization/factory.hpp (props changed)
branches/release/boost/signals/ (props changed)
branches/release/boost/signals2/ (props changed)
branches/release/boost/spirit/ (props changed)
branches/release/boost/spirit/home/ (props changed)
branches/release/boost/spirit/home/karma/ (props changed)
branches/release/boost/spirit/home/support/attributes.hpp (props changed)
branches/release/boost/statechart/ (props changed)
branches/release/boost/system/ (props changed)
branches/release/boost/thread/ (props changed)
branches/release/boost/thread.hpp (props changed)
branches/release/boost/tr1/ (props changed)
branches/release/boost/type_traits/ (props changed)
branches/release/boost/unordered/ (props changed)
branches/release/boost/utility/ (props changed)
branches/release/boost/utility/value_init.hpp (props changed)
branches/release/boost/uuid/ (props changed)
branches/release/boost/variant/ (props changed)
branches/release/boost/version.hpp (props changed)
branches/release/boost/wave/ (props changed)
branches/release/bootstrap.bat (props changed)
branches/release/bootstrap.sh (props changed)
branches/release/doc/ (props changed)
branches/release/index.htm (props changed)
branches/release/index.html (props changed)
branches/release/libs/ (props changed)
branches/release/libs/array/doc/array.xml (props changed)
branches/release/libs/array/test/array0.cpp (props changed)
branches/release/libs/bimap/ (props changed)
branches/release/libs/config/ (props changed)
branches/release/libs/filesystem/ (props changed)
branches/release/libs/functional/hash/ (props changed)
branches/release/libs/fusion/ (props changed)
branches/release/libs/graph_parallel/ (props changed)
branches/release/libs/integer/ (props changed)
branches/release/libs/interprocess/ (props changed)
branches/release/libs/intrusive/ (props changed)
branches/release/libs/iostreams/ (props changed)
branches/release/libs/libraries.htm (props changed)
branches/release/libs/maintainers.txt (props changed)
branches/release/libs/math/ (props changed)
branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
branches/release/libs/msm/ (props changed)
branches/release/libs/numeric/ublas/ (props changed)
branches/release/libs/numeric/ublas/doc/ (props changed)
branches/release/libs/program_options/ (props changed)
branches/release/libs/property_tree/ (props changed)
branches/release/libs/python/ (props changed)
branches/release/libs/range/ (props changed)
branches/release/libs/range/doc/ (props changed)
branches/release/libs/regex/ (props changed)
branches/release/libs/serialization/ (props changed)
branches/release/libs/signals/ (props changed)
branches/release/libs/signals2/ (props changed)
branches/release/libs/spirit/ (props changed)
branches/release/libs/spirit/classic/example/ (props changed)
branches/release/libs/spirit/doc/ (props changed)
branches/release/libs/spirit/example/ (props changed)
branches/release/libs/spirit/phoenix/ (props changed)
branches/release/libs/spirit/test/ (props changed)
branches/release/libs/spirit/test/qi/optional.cpp (props changed)
branches/release/libs/statechart/ (props changed)
branches/release/libs/static_assert/ (props changed)
branches/release/libs/system/ (props changed)
branches/release/libs/thread/ (props changed)
branches/release/libs/timer/ (props changed)
branches/release/libs/tr1/ (props changed)
branches/release/libs/type_traits/ (props changed)
branches/release/libs/unordered/ (props changed)
branches/release/libs/utility/ (props changed)
branches/release/libs/utility/swap.html (props changed)
branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
branches/release/libs/utility/value_init.htm (props changed)
branches/release/libs/utility/value_init_test.cpp (props changed)
branches/release/libs/uuid/ (props changed)
branches/release/libs/wave/ (props changed)
branches/release/more/ (props changed)
branches/release/more/getting_started/ (props changed)
branches/release/people/ (props changed)
branches/release/rst.css (props changed)
branches/release/status/ (props changed)
branches/release/status/Jamfile.v2 (props changed)
branches/release/tools/ (props changed)
branches/release/tools/bcp/ (props changed)
branches/release/tools/boostbook/ (props changed)
branches/release/tools/build/v2/ (props changed)
branches/release/tools/build/v2/tools/ (props changed)
branches/release/tools/inspect/ (props changed)
branches/release/tools/jam/ (props changed)
branches/release/tools/quickbook/ (props changed)
branches/release/tools/regression/ (props changed)
branches/release/tools/release/ (props changed)
branches/release/tools/wave/ (props changed)
branches/release/wiki/ (props changed)
Text files modified:
branches/release/boost/iostreams/categories.hpp | 4
branches/release/boost/iostreams/detail/adapter/concept_adapter.hpp | 11
branches/release/boost/iostreams/detail/resolve.hpp | 3
branches/release/boost/iostreams/detail/streambuf/direct_streambuf.hpp | 1
branches/release/boost/iostreams/detail/streambuf/indirect_streambuf.hpp | 1
branches/release/boost/iostreams/device/file.hpp | 12 +
branches/release/boost/iostreams/device/file_descriptor.hpp | 6
branches/release/boost/iostreams/filter/aggregate.hpp | 6
branches/release/boost/iostreams/filter/bzip2.hpp | 31 +++
branches/release/boost/iostreams/filter/gzip.hpp | 99 ++++++++++--
branches/release/boost/iostreams/filter/symmetric.hpp | 24 +-
branches/release/boost/iostreams/filter/test.hpp | 64 ++++++-
branches/release/boost/iostreams/filter/zlib.hpp | 13 +
branches/release/libs/iostreams/build/Jamfile.v2 | 6
branches/release/libs/iostreams/doc/classes/file_descriptor.html | 171 +++++++++++++++++++--
branches/release/libs/iostreams/doc/classes/gzip.html | 2
branches/release/libs/iostreams/doc/classes/mapped_file.html | 126 ++++++++++++++-
branches/release/libs/iostreams/src/bzip2.cpp | 13 +
branches/release/libs/iostreams/src/file_descriptor.cpp | 59 ++++--
branches/release/libs/iostreams/src/mapped_file.cpp | 7
branches/release/libs/iostreams/src/zlib.cpp | 5
branches/release/libs/iostreams/test/Jamfile.v2 | 6
branches/release/libs/iostreams/test/bzip2_test.cpp | 53 ++++++
branches/release/libs/iostreams/test/detail/verification.hpp | 7
branches/release/libs/iostreams/test/file_descriptor_test.cpp | 315 +++++++++++++++++++++++++++++++++++++++
branches/release/libs/iostreams/test/gzip_test.cpp | 11 +
branches/release/libs/iostreams/test/regex_filter_test.cpp | 154 +++++++++++++++++++
branches/release/libs/iostreams/test/symmetric_filter_test.cpp | 42 +++++
branches/release/libs/iostreams/test/zlib_test.cpp | 16 ++
29 files changed, 1136 insertions(+), 132 deletions(-)
Modified: branches/release/boost/iostreams/categories.hpp
==============================================================================
--- branches/release/boost/iostreams/categories.hpp (original)
+++ branches/release/boost/iostreams/categories.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -90,8 +90,8 @@
seekable_filter_tag
{ };
struct multichar_dual_use_filter_tag
- : filter_tag,
- dual_use
+ : multichar_tag,
+ dual_use_filter_tag
{ };
//
Modified: branches/release/boost/iostreams/detail/adapter/concept_adapter.hpp
==============================================================================
--- branches/release/boost/iostreams/detail/adapter/concept_adapter.hpp (original)
+++ branches/release/boost/iostreams/detail/adapter/concept_adapter.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -103,13 +103,10 @@
void close(BOOST_IOS::openmode which, Device* dev)
{ any_impl::close(t_, dev, which); }
- bool flush( BOOST_IOSTREAMS_BASIC_STREAMBUF(char_type,
- BOOST_IOSTREAMS_CHAR_TRAITS(char_type))* sb )
- {
- bool result = any_impl::flush(t_, sb);
- if (sb && sb->BOOST_IOSTREAMS_PUBSYNC() == -1)
- result = false;
- return result;
+ template<typename Device>
+ bool flush( Device* dev )
+ {
+ return any_impl::flush(t_, dev);
}
template<typename Locale> // Avoid dependency on <locale>
Modified: branches/release/boost/iostreams/detail/resolve.hpp
==============================================================================
--- branches/release/boost/iostreams/detail/resolve.hpp (original)
+++ branches/release/boost/iostreams/detail/resolve.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -67,7 +67,8 @@
// be correct, but I'm not sure why :(
#if BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, BOOST_TESTED_AT(810)) ||\
BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3205)) || \
- BOOST_WORKAROUND(BOOST_IOSTREAMS_GCC, BOOST_TESTED_AT(400)) \
+ BOOST_WORKAROUND(BOOST_IOSTREAMS_GCC, BOOST_TESTED_AT(400)) ||\
+ BOOST_WORKAROUND(__IBMCPP__, BOOST_TESTED_AT(1110))
/**/
, typename disable_if< is_iterator_range<T> >::type* = 0
#endif
Modified: branches/release/boost/iostreams/detail/streambuf/direct_streambuf.hpp
==============================================================================
--- branches/release/boost/iostreams/detail/streambuf/direct_streambuf.hpp (original)
+++ branches/release/boost/iostreams/detail/streambuf/direct_streambuf.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -121,6 +121,7 @@
init_output(category());
setg(0, 0, 0);
setp(0, 0);
+ this->set_needs_close();
}
template<typename T, typename Tr>
Modified: branches/release/boost/iostreams/detail/streambuf/indirect_streambuf.hpp
==============================================================================
--- branches/release/boost/iostreams/detail/streambuf/indirect_streambuf.hpp (original)
+++ branches/release/boost/iostreams/detail/streambuf/indirect_streambuf.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -189,6 +189,7 @@
if (can_write() && buffer_size > 1)
flags_ |= f_output_buffered;
this->set_true_eof(false);
+ this->set_needs_close();
}
template<typename T, typename Tr, typename Alloc, typename Mode>
Modified: branches/release/boost/iostreams/device/file.hpp
==============================================================================
--- branches/release/boost/iostreams/device/file.hpp (original)
+++ branches/release/boost/iostreams/device/file.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -35,7 +35,8 @@
struct category
: public seekable_device_tag,
public closable_tag,
- public localizable_tag
+ public localizable_tag,
+ public flushable_tag
{ };
basic_file( const std::string& path,
BOOST_IOS::openmode mode =
@@ -55,6 +56,7 @@
BOOST_IOS::in | BOOST_IOS::out );
bool is_open() const;
void close();
+ bool flush();
#ifndef BOOST_IOSTREAMS_NO_LOCALE
void imbue(const std::locale& loc) { pimpl_->file_.pubimbue(loc); }
#endif
@@ -105,12 +107,14 @@
struct category
: output_seekable,
device_tag,
- closable_tag
+ closable_tag,
+ flushable_tag
{ };
using basic_file<Ch>::write;
using basic_file<Ch>::seek;
using basic_file<Ch>::is_open;
using basic_file<Ch>::close;
+ using basic_file<Ch>::flush;
basic_file_sink( const std::string& path,
BOOST_IOS::openmode mode = BOOST_IOS::out )
: basic_file<Ch>(path, mode & ~BOOST_IOS::in, BOOST_IOS::out)
@@ -174,6 +178,10 @@
template<typename Ch>
void basic_file<Ch>::close() { pimpl_->file_.close(); }
+template<typename Ch>
+bool basic_file<Ch>::flush()
+{ return pimpl_->file_.BOOST_IOSTREAMS_PUBSYNC() == 0; }
+
//----------------------------------------------------------------------------//
} } // End namespaces iostreams, boost.
Modified: branches/release/boost/iostreams/device/file_descriptor.hpp
==============================================================================
--- branches/release/boost/iostreams/device/file_descriptor.hpp (original)
+++ branches/release/boost/iostreams/device/file_descriptor.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -115,13 +115,13 @@
// open overload taking a detail::path
void open( const detail::path& path,
BOOST_IOS::openmode,
- BOOST_IOS::openmode = BOOST_IOS::in | BOOST_IOS::out );
+ BOOST_IOS::openmode = BOOST_IOS::openmode(0) );
typedef detail::file_descriptor_impl impl_type;
shared_ptr<impl_type> pimpl_;
};
-class file_descriptor_source : private file_descriptor {
+class BOOST_IOSTREAMS_DECL file_descriptor_source : private file_descriptor {
public:
#ifdef BOOST_IOSTREAMS_WINDOWS
typedef void* handle_type; // A.k.a HANDLE
@@ -187,7 +187,7 @@
void open(const detail::path& path, BOOST_IOS::openmode);
};
-class file_descriptor_sink : private file_descriptor {
+class BOOST_IOSTREAMS_DECL file_descriptor_sink : private file_descriptor {
public:
#ifdef BOOST_IOSTREAMS_WINDOWS
typedef void* handle_type; // A.k.a HANDLE
Modified: branches/release/boost/iostreams/filter/aggregate.hpp
==============================================================================
--- branches/release/boost/iostreams/filter/aggregate.hpp (original)
+++ branches/release/boost/iostreams/filter/aggregate.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -126,7 +126,7 @@
}
template<typename Sink>
- void do_write(Sink& sink, const char* s, std::streamsize n)
+ void do_write(Sink& sink, const char_type* s, std::streamsize n)
{
typedef typename iostreams::category_of<Sink>::type category;
typedef is_convertible<category, output> can_write;
@@ -134,11 +134,11 @@
}
template<typename Sink>
- void do_write(Sink& sink, const char* s, std::streamsize n, mpl::true_)
+ void do_write(Sink& sink, const char_type* s, std::streamsize n, mpl::true_)
{ iostreams::write(sink, s, n); }
template<typename Sink>
- void do_write(Sink&, const char*, std::streamsize, mpl::false_) { }
+ void do_write(Sink&, const char_type*, std::streamsize, mpl::false_) { }
void close_impl()
{
Modified: branches/release/boost/iostreams/filter/bzip2.hpp
==============================================================================
--- branches/release/boost/iostreams/filter/bzip2.hpp (original)
+++ branches/release/boost/iostreams/filter/bzip2.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -166,6 +166,7 @@
void before( const char*& src_begin, const char* src_end,
char*& dest_begin, char* dest_end );
void after(const char*& src_begin, char*& dest_begin);
+ int check_end(const char* src_begin, const char* dest_begin);
int compress(int action);
int decompress();
void end(bool compress);
@@ -201,6 +202,7 @@
void close();
private:
void init();
+ bool eof_; // Guard to make sure filter() isn't called after it returns false.
};
//
@@ -305,7 +307,7 @@
template<typename Alloc>
bzip2_compressor_impl<Alloc>::bzip2_compressor_impl(const bzip2_params& p)
- : bzip2_base(p) { }
+ : bzip2_base(p), eof_(false) { }
template<typename Alloc>
bool bzip2_compressor_impl<Alloc>::filter
@@ -313,17 +315,24 @@
char*& dest_begin, char* dest_end, bool flush )
{
if (!ready()) init();
+ if (eof_) return false;
before(src_begin, src_end, dest_begin, dest_end);
int result = compress(flush ? bzip2::finish : bzip2::run);
after(src_begin, dest_begin);
bzip2_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
- return result != bzip2::stream_end;
+ return !(eof_ = result == bzip2::stream_end);
}
template<typename Alloc>
void bzip2_compressor_impl<Alloc>::close()
{
- end(true);
+ try {
+ end(true);
+ } catch (...) {
+ eof_ = false;
+ throw;
+ }
+ eof_ = false;
}
template<typename Alloc>
@@ -339,17 +348,25 @@
template<typename Alloc>
bool bzip2_decompressor_impl<Alloc>::filter
( const char*& src_begin, const char* src_end,
- char*& dest_begin, char* dest_end, bool /* flush */ )
+ char*& dest_begin, char* dest_end, bool flush )
{
+ if (eof_) {
+ // reset the stream if there are more characters
+ if(src_begin == src_end)
+ return false;
+ else
+ close();
+ }
if (!ready())
init();
- if (eof_)
- return false;
before(src_begin, src_end, dest_begin, dest_end);
int result = decompress();
+ if(result == bzip2::ok && flush)
+ result = check_end(src_begin, dest_begin);
after(src_begin, dest_begin);
bzip2_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
- return !(eof_ = result == bzip2::stream_end);
+ eof_ = result == bzip2::stream_end;
+ return true;
}
template<typename Alloc>
Modified: branches/release/boost/iostreams/filter/gzip.hpp
==============================================================================
--- branches/release/boost/iostreams/filter/gzip.hpp (original)
+++ branches/release/boost/iostreams/filter/gzip.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -247,27 +247,23 @@
template<typename Sink>
void close(Sink& snk, BOOST_IOS::openmode m)
{
- if (m == BOOST_IOS::out) {
- try {
-
- // Close zlib compressor.
- base_type::close(snk, BOOST_IOS::out);
+ try {
+ // Close zlib compressor.
+ base_type::close(snk, m);
+ if (m == BOOST_IOS::out) {
if (flags_ & f_header_done) {
// Write final fields of gzip file format.
write_long(this->crc(), snk);
write_long(this->total_in(), snk);
}
-
- } catch (...) {
- close_impl();
- throw;
}
+ } catch(...) {
close_impl();
- } else {
- close_impl();
+ throw;
}
+ close_impl();
}
private:
static gzip_params normalize_params(gzip_params p);
@@ -275,13 +271,24 @@
std::streamsize read_string(char* s, std::streamsize n, std::string& str);
template<typename Sink>
- static void write_long(long n, Sink& next)
+ static void write_long(long n, Sink& next, boost::mpl::true_)
{
boost::iostreams::put(next, static_cast<char>(0xFF & n));
boost::iostreams::put(next, static_cast<char>(0xFF & (n >> 8)));
boost::iostreams::put(next, static_cast<char>(0xFF & (n >> 16)));
boost::iostreams::put(next, static_cast<char>(0xFF & (n >> 24)));
}
+ template<typename Sink>
+ static void write_long(long n, Sink& next, boost::mpl::false_)
+ {
+ }
+ template<typename Sink>
+ static void write_long(long n, Sink& next)
+ {
+ typedef typename category_of<Sink>::type category;
+ typedef is_convertible<category, output> can_write;
+ write_long(n, next, can_write());
+ }
void close_impl()
{
@@ -398,12 +405,58 @@
public:
typedef char char_type;
struct category
- : multichar_input_filter_tag,
+ : dual_use,
+ filter_tag,
+ multichar_tag,
closable_tag
{ };
basic_gzip_decompressor( int window_bits = gzip::default_window_bits,
int buffer_size = default_device_buffer_size );
+ template<typename Sink>
+ std::streamsize write(Sink& snk, const char_type* s, std::streamsize n)
+ {
+ std::streamsize result = 0;
+ while(result < n) {
+ if(state_ == s_start) {
+ state_ = s_header;
+ header_.reset();
+ footer_.reset();
+ }
+ if (state_ == s_header) {
+ int c = s[result++];
+ header_.process(c);
+ if (header_.done())
+ state_ = s_body;
+ } else if (state_ == s_body) {
+ try {
+ std::streamsize amt =
+ base_type::write(snk, s + result, n - result);
+ result += amt;
+ if (!this->eof()) {
+ break;
+ } else {
+ state_ = s_footer;
+ }
+ } catch (const zlib_error& e) {
+ boost::throw_exception(gzip_error(e));
+ }
+ } else { // state_ == s_footer
+ if (footer_.done()) {
+ if (footer_.crc() != this->crc())
+ boost::throw_exception(gzip_error(gzip::bad_crc));
+
+ base_type::close(snk, BOOST_IOS::out);
+ state_ = s_start;
+ } else {
+ int c = s[result++];
+ footer_.process(c);
+ }
+ }
+ }
+ return result;
+ }
+
template<typename Source>
std::streamsize read(Source& src, char_type* s, std::streamsize n)
{
@@ -476,16 +529,28 @@
}
template<typename Source>
- void close(Source& src)
+ void close(Source& src, BOOST_IOS::openmode m)
{
try {
- base_type::close(src, BOOST_IOS::in);
+ base_type::close(src, m);
} catch (const zlib_error& e) {
state_ = s_start;
- header_.reset();
- footer_.reset();
boost::throw_exception(gzip_error(e));
}
+ if (m == BOOST_IOS::out) {
+ if (state_ == s_start || state_ == s_header)
+ boost::throw_exception(gzip_error(gzip::bad_header));
+ else if (state_ == s_body)
+ boost::throw_exception(gzip_error(gzip::bad_footer));
+ else if (state_ == s_footer) {
+ if (!footer_.done())
+ boost::throw_exception(gzip_error(gzip::bad_footer));
+ else if(footer_.crc() != this->crc())
+ boost::throw_exception(gzip_error(gzip::bad_crc));
+ } else {
+ assert(!"Bad state");
+ }
+ }
state_ = s_start;
}
Modified: branches/release/boost/iostreams/filter/symmetric.hpp
==============================================================================
--- branches/release/boost/iostreams/filter/symmetric.hpp (original)
+++ branches/release/boost/iostreams/filter/symmetric.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -89,7 +89,7 @@
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))) \
- { } \
+ { assert(buffer_size > 0); } \
/**/
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_IOSTREAMS_MAX_FORWARDING_ARITY)
#include BOOST_PP_LOCAL_ITERATE()
@@ -147,22 +147,28 @@
for (next_s = s, end_s = s + n; next_s != end_s; ) {
if (buf.ptr() == buf.eptr() && !flush(snk))
break;
- filter().filter(next_s, end_s, buf.ptr(), buf.eptr(), false);
+ if(!filter().filter(next_s, end_s, buf.ptr(), buf.eptr(), false)) {
+ flush(snk);
+ break;
+ }
}
return static_cast<std::streamsize>(next_s - s);
}
template<typename Sink>
- void close(Sink& snk, BOOST_IOS::openmode)
+ void close(Sink& snk, BOOST_IOS::openmode mode)
{
- if ((state() & f_write) != 0) {
+ if (mode == BOOST_IOS::out) {
+
+ if (!(state() & f_write))
+ begin_write();
// Repeatedly invoke filter() with no input.
try {
- buffer_type& buf = pimpl_->buf_;
- char dummy;
- const char* end = &dummy;
- bool again = true;
+ buffer_type& buf = pimpl_->buf_;
+ char_type dummy;
+ const char_type* end = &dummy;
+ bool again = true;
while (again) {
if (buf.ptr() != buf.eptr())
again = filter().filter( end, end, buf.ptr(),
@@ -202,7 +208,7 @@
return f_eof;
}
buf().set(0, amt);
- return amt == buf().size() ? f_good : f_would_block;
+ return amt != 0 ? f_good : f_would_block;
}
// Attempts to write the contents of the buffer the given Sink.
Modified: branches/release/boost/iostreams/filter/test.hpp
==============================================================================
--- branches/release/boost/iostreams/filter/test.hpp (original)
+++ branches/release/boost/iostreams/filter/test.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -239,16 +239,60 @@
inc <= default_increment * 40;
inc += default_increment )
{
- array_source src(data.data(), data.data() + data.size());
- std::string temp;
- std::string dest;
- iostreams::copy(src, compose(out, non_blocking_sink(temp, inc)));
- iostreams::copy(
- compose(in, non_blocking_source(temp, inc)),
- iostreams::back_inserter(dest)
- );
- if (dest != data)
- return false;
+ {
+ array_source src(data.data(), data.data() + data.size());
+ std::string temp;
+ std::string dest;
+ iostreams::copy(src, compose(out, non_blocking_sink(temp, inc)));
+ iostreams::copy(
+ compose(in, non_blocking_source(temp, inc)),
+ iostreams::back_inserter(dest)
+ );
+ if (dest != data)
+ return false;
+ }
+ {
+ array_source src(data.data(), data.data() + data.size());
+ std::string temp;
+ std::string dest;
+ iostreams::copy(src, compose(out, non_blocking_sink(temp, inc)));
+ // truncate the file, this should not loop, it may throw
+ // std::ios_base::failure, which we swallow.
+ try {
+ temp.resize(temp.size() / 2);
+ iostreams::copy(
+ compose(in, non_blocking_source(temp, inc)),
+ iostreams::back_inserter(dest)
+ );
+ } catch(std::ios_base::failure&) {}
+ }
+ {
+ array_source src(data.data(), data.data() + data.size());
+ std::string temp;
+ std::string dest;
+ iostreams::copy(compose(out, src), non_blocking_sink(temp, inc));
+ iostreams::copy(
+ non_blocking_source(temp, inc),
+ compose(in, iostreams::back_inserter(dest))
+ );
+ if (dest != data)
+ return false;
+ }
+ {
+ array_source src(data.data(), data.data() + data.size());
+ std::string temp;
+ std::string dest;
+ iostreams::copy(compose(out, src), non_blocking_sink(temp, inc));
+ // truncate the file, this should not loop, it may throw
+ // std::ios_base::failure, which we swallow.
+ try {
+ temp.resize(temp.size() / 2);
+ iostreams::copy(
+ non_blocking_source(temp, inc),
+ compose(in, iostreams::back_inserter(dest))
+ );
+ } catch(std::ios_base::failure&) {}
+ }
}
return true;
}
Modified: branches/release/boost/iostreams/filter/zlib.hpp
==============================================================================
--- branches/release/boost/iostreams/filter/zlib.hpp (original)
+++ branches/release/boost/iostreams/filter/zlib.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -210,6 +210,7 @@
void* stream_; // Actual type: z_stream*.
bool calculate_crc_;
zlib::ulong crc_;
+ zlib::ulong crc_imp_;
int total_in_;
int total_out_;
};
@@ -243,6 +244,9 @@
bool filter( const char*& begin_in, const char* end_in,
char*& begin_out, char* end_out, bool flush );
void close();
+ bool eof() const { return eof_; }
+private:
+ bool eof_;
};
} // End namespace detail.
@@ -292,6 +296,7 @@
int 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(); }
};
BOOST_IOSTREAMS_PIPABLE(basic_zlib_decompressor, 1)
@@ -356,6 +361,7 @@
template<typename Alloc>
zlib_decompressor_impl<Alloc>::zlib_decompressor_impl(const zlib_params& p)
+ : eof_(false)
{ init(p, false, static_cast<zlib_allocator<Alloc>&>(*this)); }
template<typename Alloc>
@@ -379,11 +385,14 @@
int result = xinflate(zlib::sync_flush);
after(src_begin, dest_begin, false);
zlib_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(result);
- return result != zlib::stream_end;
+ return !(eof_ = result == zlib::stream_end);
}
template<typename Alloc>
-void zlib_decompressor_impl<Alloc>::close() { reset(false, true); }
+void zlib_decompressor_impl<Alloc>::close() {
+ eof_ = false;
+ reset(false, true);
+}
} // End namespace detail.
Modified: branches/release/libs/iostreams/build/Jamfile.v2
==============================================================================
--- branches/release/libs/iostreams/build/Jamfile.v2 (original)
+++ branches/release/libs/iostreams/build/Jamfile.v2 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -19,6 +19,7 @@
import modules ;
import os ;
+import path ;
local debug = [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] ;
for local v in NO_COMPRESSION
@@ -89,7 +90,7 @@
if $($(LIB)_SOURCE)
{
return [ lib boost_$(library-name)
- : $($(LIB)_SOURCE)/$(sources).c
+ : [ path.glob $($(LIB)_SOURCE) : $(sources).c ]
: <include>$($(LIB)_INCLUDE)
<location-prefix>$(LIB:L)
$(requirements)
@@ -133,7 +134,8 @@
local sources = file_descriptor.cpp mapped_file.cpp ;
local z = [ create-library zlib : zll z : adler32 compress
- crc32 deflate gzio infback inffast inflate inftrees trees uncompr zutil :
+ crc32 deflate gzclose gzio gzlib gzread gzwrite
+ infback inffast inflate inftrees trees uncompr zutil :
<link>shared:<define>ZLIB_DLL ] ;
if $(z)
Modified: branches/release/libs/iostreams/doc/classes/file_descriptor.html
==============================================================================
--- branches/release/libs/iostreams/doc/classes/file_descriptor.html (original)
+++ branches/release/libs/iostreams/doc/classes/file_descriptor.html 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -91,7 +91,7 @@
<H4>Description</H4>
-<P>Model of Source providing read-only access to a file through an operating system file descriptor.</P>
+<P>Model of SeekableSource and Closable providing read-only access to a file through an operating system file descriptor.</P>
<H4>Synopsis</H4>
@@ -100,8 +100,11 @@
<SPAN CLASS="keyword">class</SPAN> file_descriptor_source {
<SPAN CLASS="keyword">public</SPAN>:
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>char</SPAN> char_type;
+ <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> handle_type;
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> category;
- <A CLASS="documented" HREF="#file_descriptor_source_ctor">file_descriptor_source</A>( <SPAN CLASS="keyword">const</SPAN> std::string& pathname,
+ <A CLASS="documented" HREF="#file_descriptor_source_ctor">file_descriptor_source</A>();
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <A CLASS="documented" HREF="#file_descriptor_source_ctor">file_descriptor_source</A>( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
std::ios_base::open_mode mode =
std::ios_base::in );
<A CLASS="documented" HREF="#file_descriptor_source_ctor">file_descriptor_source</A>( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
@@ -109,7 +112,18 @@
<SPAN CLASS='comment'>// Windows-only</SPAN>
<A CLASS="documented" HREF="#file_descriptor_source_ctor">file_descriptor_source</A>( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_source_open">open</A>( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
+ std::ios_base::open_mode mode =
+ std::ios_base::in );
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_source_open">open</A>( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
+ <SPAN CLASS='comment'>// Windows-only</SPAN>
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_source_open">open</A>( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
<SPAN CLASS="keyword">bool</SPAN> <A CLASS="documented" HREF="#file_descriptor_source_is_open">is_open</A>() <SPAN CLASS="keyword">const</SPAN>;
+
+ handle_type <A CLASS="documented" HREF="#file_descriptor_source_handle">handle</A>() <SPAN CLASS="keyword">const</SPAN>;
};
} } <SPAN CLASS='comment'>// End namespace boost::io</SPAN></PRE>
@@ -117,24 +131,46 @@
<A NAME="file_descriptor_source_ctor"></A>
<H4><CODE>file_descriptor_source::file_descriptor_source</CODE></H4>
-<PRE CLASS="broken_ie"> file_descriptor_source( <SPAN CLASS="keyword">const</SPAN> std::string& pathname,
+<PRE CLASS="broken_ie"> file_descriptor_source();
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ file_descriptor_source( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
std::ios_base::open_mode mode =
std::ios_base::in );
file_descriptor_source( <SPAN CLASS="keyword">int </SPAN>fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
<SPAN CLASS='comment'>// Windows-only</SPAN>
file_descriptor_source( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );</PRE>
-
+
+<P>
+ The first member constructs an empty <CODE>file_descriptor_source</CODE>.
+</P>
+
+<P>
+ The second member constructs a <CODE>file_descriptor_source</CODE> to access the file with the given pathname. <CODE>Path</CODE> should be either a string or a Boost.Filesystem path. The parameter <CODE>mode</CODE> has the same interpretation as <CODE>(mode | std::ios_base::in)</CODE> in <CODE>std::basic_filebuf::open</CODE>.<A CLASS="footnote_ref" NAME="note_1_ref" HREF="#note_1"><SUP>[1]</SUP></A>
+</P>
+
<P>
- The first member constructs a <CODE>file_descriptor_source</CODE> to access the file with the given pathname. The parameter <CODE>mode</CODE> has the same interpretation as <CODE>(mode | std::ios_base::in)</CODE> in <CODE>std::basic_filebuf::open</CODE>.<A CLASS="footnote_ref" NAME="note_1_ref" HREF="#note_1"><SUP>[1]</SUP></A>
+ The third member constructs a <CODE>file_descriptor_source</CODE> to access the file with the given operating system or runtime-library file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the <CODE>file_descriptor_source</CODE> being constructed — or one of its copies — is closed.
</P>
<P>
- The second member constructs a <CODE>file_descriptor_source</CODE> to access the file with the given operating system or runtime-library file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the <CODE>file_descriptor_source</CODE> being constructed — or one of its copies — is closed.
+ The fourth member is the same as the third, except that it accepts a Windows file handle instead of a file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the <CODE>file_descriptor_source</CODE> being constructed — or one of its copies — is closed.
</P>
+<A NAME="file_descriptor_source_open"></A>
+<H4><CODE>file_descriptor_source::open</CODE></H4>
+
+<PRE CLASS="broken_ie"> <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <SPAN CLASS="keyword">void</SPAN> open( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
+ std::ios_base::open_mode mode =
+ std::ios_base::in );
+ <SPAN CLASS="keyword">void</SPAN> open( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
+ <SPAN CLASS='comment'>// Windows-only</SPAN>
+ <SPAN CLASS="keyword">void</SPAN> open( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );</PRE>
+
<P>
- The third member is the same as the second, except that it accepts a Windows file handle instead of a file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the <CODE>file_descriptor_source</CODE> being constructed — or one of its copies — is closed.
+ The parameters of <CODE>open</CODE> the same as those of the corresponding constructors.
</P>
<A NAME="file_descriptor_source_is_open"></A>
@@ -144,12 +180,19 @@
<P>Returns <CODE>true</CODE> if the underlying file was opened successfully.</P>
+<A NAME="file_descriptor_source_handle"></A>
+<H4><CODE>file_descriptor_source::handle</CODE></H4>
+
+<PRE CLASS="broken_ie"> handle_type handle() <SPAN CLASS="keyword">const</SPAN>;</PRE>
+
+<P>Returns the underlying OS file descriptor. On Windows, this is a <CODE>HANDLE</CODE>. On other systems, it is an <CODE><SPAN CLASS="keyword">int</SPAN></CODE>.</P>
+
<A NAME="file_descriptor_sink"></A>
<H3>Class <CODE>file_descriptor_sink</CODE></H3>
<H4>Description</H4>
-<P>Model of Sink providing write-only access to a file through an operating system file descriptor.
+<P>Model of SeekableSink and Closable providing write-only access to a file through an operating system file descriptor.
<H4>Synopsis</H4>
@@ -158,8 +201,11 @@
<SPAN CLASS="keyword">class</SPAN> file_descriptor_sink {
<SPAN CLASS="keyword">public</SPAN>:
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>char</SPAN> char_type;
+ <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> handle_type;
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> category;
- <A CLASS="documented" HREF="#file_descriptor_sink_ctor">file_descriptor_sink</A>( <SPAN CLASS="keyword">const</SPAN> std::string& pathname,
+ <A CLASS="documented" HREF="#file_descriptor_sink_ctor">file_descriptor_sink</A>();
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <A CLASS="documented" HREF="#file_descriptor_sink_ctor">file_descriptor_sink</A>( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
std::ios_base::open_mode mode =
std::ios_base::out );
<A CLASS="documented" HREF="#file_descriptor_sink_ctor">file_descriptor_sink</A>( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
@@ -167,7 +213,18 @@
<SPAN CLASS='comment'>// Windows-only</SPAN>
<A CLASS="documented" HREF="#file_descriptor_sink_ctor">file_descriptor_sink</A>( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_sink_open">open</A>( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
+ std::ios_base::open_mode mode =
+ std::ios_base::out );
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_sink_open">open</A>( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
+ <SPAN CLASS='comment'>// Windows-only</SPAN>
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_sink_open">open</A>( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
<SPAN CLASS="keyword">bool</SPAN> <A CLASS="documented" HREF="#file_descriptor_sink_is_open">is_open</A>() <SPAN CLASS="keyword">const</SPAN>;
+
+ handle_type <A CLASS="documented" HREF="#file_descriptor_sink_handle">handle</A>() <SPAN CLASS="keyword">const</SPAN>;
};
} } <SPAN CLASS='comment'>// End namespace boost::io</SPAN></PRE>
@@ -175,24 +232,46 @@
<A NAME="file_descriptor_sink_ctor"></A>
<H4><CODE>file_descriptor_sink::file_descriptor_sink</CODE></H4>
-<PRE CLASS="broken_ie"> file_descriptor_sink( <SPAN CLASS="keyword">const</SPAN> std::string& pathname,
+<PRE CLASS="broken_ie"> file_descriptor_sink();
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ file_descriptor_sink( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
std::ios_base::open_mode mode =
std::ios_base::out );
file_descriptor_sink( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
<SPAN CLASS='comment'>// Windows-only</SPAN>
file_descriptor_sink( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );</PRE>
-
+
+<P>
+ The first member constructs an empty <CODE>file_descriptor_sink</CODE>.
+</P>
+
+<P>
+ The second member constructs a <CODE>file_descriptor_sink</CODE> to access the file with the given pathname. <CODE>Path</CODE> should be either a string or a Boost.Filesystem path. The parameter <CODE>mode</CODE> has the same interpretation as <CODE>(mode | std::ios_base::out)</CODE> in <CODE>std::basic_filebuf::open</CODE>.<A CLASS="footnote_ref" NAME="note_1_ref2" HREF="#note_1"><SUP>[1]</SUP></A>
+</P>
+
<P>
- The first member constructs a <CODE>file_descriptor_sink</CODE> to access the file with the given pathname. The parameter <CODE>mode</CODE> has the same interpretation as <CODE>(mode | std::ios_base::out)</CODE> in <CODE>std::basic_filebuf::open</CODE>.<A CLASS="footnote_ref" NAME="note_1_ref2" HREF="#note_1"><SUP>[1]</SUP></A>
+ The third member constructs a <CODE>file_descriptor_sink</CODE> to access the file with the given operating system or runtime-library file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor_sink</CODE> — or one of its copies — is closed.
</P>
<P>
- The second member constructs a <CODE>file_descriptor_sink</CODE> to access the file with the given operating system or runtime-library file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor_sink</CODE> — or one of its copies — is closed.
+ The fourth member is the same as the third, except that it accepts a Windows file handle instead of a file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor_sink</CODE> — or one of its copies — is closed.
</P>
+<A NAME="file_descriptor_sink_open"></A>
+<H4><CODE>file_descriptor_sink::open</CODE></H4>
+
+<PRE CLASS="broken_ie"> <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <SPAN CLASS="keyword">void</SPAN> open( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
+ std::ios_base::open_mode mode =
+ std::ios_base::out );
+ <SPAN CLASS="keyword">void</SPAN> open( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
+ <SPAN CLASS='comment'>// Windows-only</SPAN>
+ <SPAN CLASS="keyword">void</SPAN> open( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );</PRE>
+
<P>
- The third member is the same as the second, except that it accepts a Windows file handle instead of a file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor_sink</CODE> — or one of its copies — is closed.
+ The parameters of <CODE>open</CODE> the same as those of the corresponding constructors.
</P>
<A NAME="file_descriptor_sink_is_open"></A>
@@ -202,12 +281,19 @@
<P>Returns <CODE>true</CODE> if the underlying file was opened successfully.</P>
+<A NAME="file_descriptor_sink_handle"></A>
+<H4><CODE>file_descriptor_sink::handle</CODE></H4>
+
+<PRE CLASS="broken_ie"> handle_type handle() <SPAN CLASS="keyword">const</SPAN>;</PRE>
+
+<P>Returns the underlying OS file descriptor. On Windows, this is a <CODE>HANDLE</CODE>. On other systems, it is an <CODE><SPAN CLASS="keyword">int</SPAN></CODE>.</P>
+
<A NAME="file_descriptor"></A>
<H3>Class <CODE>file_descriptor</CODE></H3>
<H4>Description</H4>
-<P>Model of SeekableDevice providing read-write access to a file through an operating system file descriptor.
+<P>Model of SeekableDevice and Closable providing read-write access to a file through an operating system file descriptor.
<H4>Synopsis</H4>
@@ -216,8 +302,11 @@
<SPAN CLASS="keyword">class</SPAN> file_descriptor {
<SPAN CLASS="keyword">public</SPAN>:
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>char</SPAN> char_type;
+ <SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> handle_type;
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> category;
- <A CLASS="documented" HREF="#file_descriptor_constructor">file_descriptor</A>( <SPAN CLASS="keyword">const</SPAN> std::string& pathname,
+ <A CLASS="documented" HREF="#file_descriptor_constructor">file_descriptor</A>();
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <A CLASS="documented" HREF="#file_descriptor_constructor">file_descriptor</A>( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
std::ios_base::open_mode mode =
std::ios_base::in | std::ios_base::out );
<A CLASS="documented" HREF="#file_descriptor_constructor">file_descriptor</A>( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
@@ -225,7 +314,18 @@
<SPAN CLASS='comment'>// Windows-only</SPAN>
<A CLASS="documented" HREF="#file_descriptor_constructor">file_descriptor</A>( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_open">open</A>( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
+ std::ios_base::open_mode mode =
+ std::ios_base::in | std::ios_base::out );
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_open">open</A>( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
+ <SPAN CLASS='comment'>// Windows-only</SPAN>
+ <SPAN CLASS="keyword">void</SPAN> <A CLASS="documented" HREF="#file_descriptor_open">open</A>( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
<SPAN CLASS="keyword">bool</SPAN> <A CLASS="documented" HREF="#file_descriptor_is_open">is_open</A>() <SPAN CLASS="keyword">const</SPAN>;
+
+ handle_type <A CLASS="documented" HREF="#file_descriptor_handle">handle</A>() <SPAN CLASS="keyword">const</SPAN>;
};
} } <SPAN CLASS='comment'>// End namespace boost::io</SPAN></PRE>
@@ -233,7 +333,9 @@
<A NAME="file_descriptor_constructor"></A>
<H4><CODE>file_descriptor::file_descriptor</CODE></H4>
-<PRE CLASS="broken_ie"> file_descriptor( <SPAN CLASS="keyword">const</SPAN> std::string& pathname,
+<PRE CLASS="broken_ie"> file_descriptor();
+ <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ file_descriptor( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
std::ios_base::open_mode mode =
std::ios_base::in | std::ios_base::out );
file_descriptor( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
@@ -242,15 +344,35 @@
file_descriptor( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );</PRE>
<P>
- The first member constructs a <CODE>file_descriptor</CODE> to access the file with the given pathname. The parameter <CODE>mode</CODE> has the same interpretation as in <CODE>std::basic_filebuf::open</CODE>.<A CLASS="footnote_ref" NAME="note_1_ref3" HREF="#note_1"><SUP>[1]</SUP></A>
+ The first member constructs an empty <CODE>file_descriptor</CODE>.
</P>
<P>
- The second member constructs a <CODE>file_descriptor</CODE> to access the file with the given operating system or runtime-library file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor</CODE> — or one of its copies — is closed.
+ The second member constructs a <CODE>file_descriptor</CODE> to access the file with the given pathname. <CODE>Path</CODE> should be either a string or a Boost.Filesystem path. The parameter <CODE>mode</CODE> has the same interpretation as in <CODE>std::basic_filebuf::open</CODE>.<A CLASS="footnote_ref" NAME="note_1_ref3" HREF="#note_1"><SUP>[1]</SUP></A>
</P>
<P>
- The third member is the same as the second, except that it accepts a Windows file handle instead of a file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor</CODE> — or one of its copies — is closed.
+ The third member constructs a <CODE>file_descriptor</CODE> to access the file with the given operating system or runtime-library file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor</CODE> — or one of its copies — is closed.
+</P>
+
+<P>
+ The fourth member is the same as the third, except that it accepts a Windows file handle instead of a file descriptor. If the second argument is <CODE>true</CODE>, the file descriptor is closed when the new <CODE>file_descriptor</CODE> — or one of its copies — is closed.
+</P>
+
+<A NAME="file_descriptor_open"></A>
+<H4><CODE>file_descriptor::open</CODE></H4>
+
+<PRE CLASS="broken_ie"> <SPAN CLASS="keyword">template</SPAN><<SPAN CLASS="keyword">typename</SPAN> Path>
+ <SPAN CLASS="keyword">void</SPAN> open( <SPAN CLASS="keyword">const</SPAN> Path& pathname,
+ std::ios_base::open_mode mode =
+ std::ios_base::in | std::ios_base::out );
+ <SPAN CLASS="keyword">void</SPAN> open( <SPAN CLASS="keyword">int</SPAN> fd, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );
+
+ <SPAN CLASS='comment'>// Windows-only</SPAN>
+ <SPAN CLASS="keyword">void</SPAN> open( HANDLE hFile, <SPAN CLASS="keyword">bool</SPAN> close_on_exit = <SPAN CLASS="keyword">false</SPAN> );</PRE>
+
+<P>
+ The parameters of <CODE>open</CODE> the same as those of the corresponding constructors.
</P>
<A NAME="file_descriptor_is_open"></A>
@@ -258,7 +380,14 @@
<PRE CLASS="broken_ie"> <SPAN CLASS="keyword">bool</SPAN> is_open() <SPAN CLASS="keyword">const</SPAN>;</PRE>
-<P>Returns <CODE>true</CODE> if the underlying file was opened successfully.</P>
+<P>Returns <CODE><SPAN CLASS="keyword">true</SPAN></CODE> if the underlying file was opened successfully.</P>
+
+<A NAME="file_descriptor_handle"></A>
+<H4><CODE>file_descriptor::handle</CODE></H4>
+
+<PRE CLASS="broken_ie"> handle_type handle() <SPAN CLASS="keyword">const</SPAN>;</PRE>
+
+<P>Returns the underlying OS file descriptor. On Windows, this is a <CODE>HANDLE</CODE>. On other systems, it is an <CODE><SPAN CLASS="keyword">int</SPAN></CODE>.</P>
<!-- Begin Footnotes -->
Modified: branches/release/libs/iostreams/doc/classes/gzip.html
==============================================================================
--- branches/release/libs/iostreams/doc/classes/gzip.html (original)
+++ branches/release/libs/iostreams/doc/classes/gzip.html 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -248,7 +248,7 @@
<H4>Description</H4>
-<P>Model of InputFilter which decompresses data in the G<SPAN STYLE="font-size:80%">ZIP</SPAN> format (<A CLASS="bib_ref" HREF="../bibliography.html#deutsch3">[Deutsch3]</A>).</P>
+<P>Model of DualUseFilter which decompresses data in the G<SPAN STYLE="font-size:80%">ZIP</SPAN> format (<A CLASS="bib_ref" HREF="../bibliography.html#deutsch3">[Deutsch3]</A>).</P>
<H4>Synopsis</H4>
Modified: branches/release/libs/iostreams/doc/classes/mapped_file.html
==============================================================================
--- branches/release/libs/iostreams/doc/classes/mapped_file.html (original)
+++ branches/release/libs/iostreams/doc/classes/mapped_file.html 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -90,7 +90,8 @@
<SPAN CLASS='keyword'>explicit</SPAN> mapped_file_params();
<SPAN CLASS='keyword'>explicit</SPAN> mapped_file_params(<SPAN CLASS='keyword'>const</SPAN> std::string& path);
std::string <A CLASS='documented' HREF='#mapped_file_params_hint'>path</A>;
- std::ios_base::openmode <A CLASS='documented' HREF='#mapped_file_params_mode'>mode</A>;
+ mapped_file::mapmode <A CLASS='documented' HREF='#mapped_file_params_flags'>flags</A>;
+ std::ios_base::openmode <A CLASS='documented' HREF='#mapped_file_params_mode'>mode</A>; // Deprecated
stream_offset <A CLASS='documented' HREF='#mapped_file_params_offset'>offset</A>;
std::size_t <A CLASS='documented' HREF='#mapped_file_params_length'>length</A>;
stream_offset <A CLASS="documented" HREF="#mapped_file_params_size">new_file_size</A>;
@@ -111,7 +112,14 @@
<PRE CLASS="broken_ie"> std::ios_base::openmode mode;</PRE>
-<P>Indicates whether the file should be opened with read-access, write-access or both. Ignored by <CODE>mapped_file_source</CODE> and <CODE>mapped_file_sink</CODE> .</P>
+<P>Indicates whether the file should be opened with read-access, write-access or both. Ignored by <CODE>mapped_file_source</CODE> and <CODE>mapped_file_sink</CODE>. This member is deprecated. Please use flags in new code instead.</P>
+
+<A NAME="mapped_file_params_flags"></A>
+<H4><CODE>mapped_file_params::flags</CODE></H4>
+
+<PRE CLASS="broken_ie"> mapped_file::mapmode flags;</PRE>
+
+<P>Indicates whether the file should be opened with read-access, read-write-access, or private access. A file opened with private access can be written to, but the changes will not affect the underlying file.</P>
<A NAME="mapped_file_params_offset"></A>
<H4><CODE>mapped_file_params::offset</CODE></H4>
@@ -289,16 +297,20 @@
<SPAN CLASS="keyword">public</SPAN>:
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>char</SPAN> char_type;
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> category;
+ <SPAN CLASS='keyword'>enum</SPAN> mapmode { readwrite, priv };
<A CLASS='documented' HREF='#mapped_file_sink_default_ctor'>mapped_file_sink</A>();
<SPAN CLASS='keyword'>explicit</SPAN> <A CLASS='documented' HREF='#mapped_file_sink_params_ctor'>mapped_file_sink</A>(<A CLASS='documented' HREF='#mapped_file_params'>mapped_file_params</A> params);
<SPAN CLASS='keyword'>explicit</SPAN> <A CLASS='documented' HREF='#mapped_file_sink_basic_ctor'>mapped_file_sink</A>( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
size_type length = max_length,
- boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN>,
+ mapmode flags = readwrite );
void <A CLASS='documented' HREF='#mapped_file_sink_params_open'>open</A>(<A CLASS='documented' HREF='#mapped_file_params'>mapped_file_params</A> params);
void <A CLASS='documented' HREF='#mapped_file_sink_basic_open'>open</A>( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
size_type length = max_length,
- boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN>,
+ mapmode flags = readwrite );
<SPAN CLASS='keyword'>bool</SPAN> <A CLASS='documented' HREF='#mapped_file_sink_is_open'>is_open</A>() <SPAN CLASS='keyword'>const</SPAN>;
+ mapmode <A CLASS='documented' HREF='#mapped_file_sink_flags'>flags</A>() <SPAN CLASS='keyword'>const</SPAN>;
<SPAN CLASS='keyword'>void</SPAN> <A CLASS='documented' HREF='#mapped_file_sink_close'>close</A>();
size_type <A CLASS='documented' HREF='#mapped_file_sink_size'>size</A>() <SPAN CLASS='keyword'>const</SPAN>;
<SPAN CLASS='keyword'>char</SPAN>* <A CLASS='documented' HREF='#mapped_file_sink_data'>data</A>() <SPAN CLASS='keyword'>const</SPAN>;
@@ -322,7 +334,8 @@
<A NAME="mapped_file_sink_basic_ctor"></A>
<PRE CLASS="broken_ie"> <SPAN CLASS='keyword'>explicit</SPAN> mapped_file_sink( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
size_type length = max_length,
- boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );</PRE>
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN>,
+ mapmode flags );</PRE>
<P>Constructs a <CODE>mapped_file_sink</CODE> to access a specified file. The parameters have the following interpretation:</P>
@@ -340,6 +353,10 @@
<TD VALIGN="top"><I>offset</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
<TD>The offset where the mapping is to begin. This value must be a multiple of the operating system's virtual memory allocation granularity, which can be obtained using the static member function <A HREF='#mapped_file_sink_alignment'><CODE>alignment</CODE></A>.</TD>
</TR>
+ <TR>
+ <TD VALIGN="top"><I>flags</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>Indicates whether the <CODE>mapped_file_sink</CODE> should be opened for read-write access or private access.</TD>
+ </TR>
</TABLE>
<A NAME="mapped_file_sink_params_open"></A>
@@ -352,7 +369,8 @@
<A NAME="mapped_file_sink_basic_open"></A>
<PRE CLASS="broken_ie"> void open( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
size_type length = max_length,
- boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );</PRE>
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN>
+ mapmode flags );</PRE>
<P>Connects this <CODE>mapped_file_sink</CODE> to a memory-mapped file obtained as described by the given parameters, which have the following interpretation:</P>
@@ -370,6 +388,10 @@
<TD VALIGN="top"><I>offset</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
<TD>The offset where the mapping is to begin. This value must be a multiple of the operating system's virtual memory allocation granularity, which can be obtained using the static member function <A HREF='#mapped_file_sink_alignment'><CODE>alignment</CODE></A>.</TD>
</TR>
+ <TR>
+ <TD VALIGN="top"><I>flags</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>Indicates whether the <CODE>mapped_file_sink</CODE> should be opened for read-write access or private access.</TD>
+ </TR>
</TABLE>
<A NAME="mapped_file_sink_is_open"></A>
@@ -379,6 +401,13 @@
<P>Returns <CODE>true</CODE> if this <CODE>mapped_file_sink</CODE> has been successfully opened without subsequently having been closed.</P>
+<A NAME="mapped_file_sink_flags"></A>
+<H4><CODE>mapped_file_sink::flags</CODE></H4>
+
+<PRE CLASS="broken_ie"> mapmode flags() <SPAN CLASS='keyword'>const</SPAN>;</PRE>
+
+<P>Indicates whether the <CODE>mapped_file_sink</CODE> was opened for read/write-access or private-access.</P>
+
<A NAME="mapped_file_sink_close"></A>
<H4><CODE>mapped_file_sink::close</CODE></H4>
@@ -422,20 +451,30 @@
<SPAN CLASS="keyword">public</SPAN>:
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='keyword'>char</SPAN> char_type;
<SPAN CLASS='keyword'>typedef</SPAN> <SPAN CLASS='omitted'>[implementation-defined]</SPAN> category;
+ <SPAN CLASS='keyword'>enum</SPAN> mapmode { readonly, readwrite, priv };
<A CLASS='documented' HREF='#mapped_file_default_ctor'>mapped_file</A>();
<SPAN CLASS='keyword'>explicit</SPAN> <A CLASS='documented' HREF='#mapped_file_params_ctor'>mapped_file</A>(<A CLASS='documented' HREF='#mapped_file_params'>mapped_file_params</A> params);
<SPAN CLASS='keyword'>explicit</SPAN> <A CLASS='documented' HREF='#mapped_file_basic_ctor'>mapped_file</A>( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
std::ios_base::openmode mode =
- std::ios_base | std::ios_base,
+ std::ios_base::in | std::ios_base::out,
size_type length = max_length,
boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );
- void <A CLASS='documented' HREF='#mapped_file_params_open'>open</A>(<A CLASS='documented' HREF='#mapped_file_params'>mapped_file_params</A> params);
- void <A CLASS='documented' HREF='#mapped_file_basic_open'>open</A>( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
+ <SPAN CLASS='keyword'>explicit</SPAN> <A CLASS='documented' HREF='#mapped_file_mapmode_ctor'>mapped_file</A>( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
+ mapmode mode,
+ size_type length = max_length,
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );
+ <SPAN CLASS='keyword'>void</SPAN> <A CLASS='documented' HREF='#mapped_file_params_open'>open</A>(<A CLASS='documented' HREF='#mapped_file_params'>mapped_file_params</A> params);
+ <SPAN CLASS='keyword'>void</SPAN> <A CLASS='documented' HREF='#mapped_file_basic_open'>open</A>( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
std::ios_base::openmode mode =
std::ios_base | std::ios_base,
size_type length = max_length,
boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );
+ <SPAN CLASS='keyword'>void</SPAN> <A CLASS='documented' HREF='#mapped_file_mapmode_open'>open</A>( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
+ mapmode mode,
+ size_type length = max_length,
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );
<SPAN CLASS='keyword'>bool</SPAN> <A CLASS='documented' HREF='#mapped_file_is_open'>is_open</A>() <SPAN CLASS='keyword'>const</SPAN>;
+ mapmode <A CLASS='documented' HREF='#mapped_file_flags'>flags</A>() <SPAN CLASS='keyword'>const</SPAN>;
<SPAN CLASS='keyword'>void</SPAN> <A CLASS='documented' HREF='#mapped_file_close'>close</A>();
size_type <A CLASS='documented' HREF='#mapped_file_size'>size</A>() <SPAN CLASS='keyword'>const</SPAN>;
<SPAN CLASS='keyword'>char</SPAN>* <A CLASS='documented' HREF='#mapped_file_data'>data</A>() <SPAN CLASS='keyword'>const</SPAN>;
@@ -443,7 +482,7 @@
<SPAN CLASS='keyword'>static</SPAN> <SPAN CLASS='keyword'>int</SPAN> <A CLASS='documented' HREF='#mapped_file_alignment'>alignment</A>();
};
-} } // End namespace boost::io</PRE>
+} } // End namespace boost::iostreams</PRE>
<A NAME="mapped_file_default_ctor"></A>
<H4><CODE>mapped_file::mapped_file</CODE></H4>
@@ -474,7 +513,35 @@
</TR>
<TR>
<TD VALIGN="top"><I>mode</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
- <TD>Indicates whether the file should be opened with read-access, write-access or both.</TD>
+ <TD>Indicates whether the file should be opened with read-access, write-access or both. Use of <CODE>std::ios_base::openmode</CODE> with <CODE>mapped_file</CODE> is deprecated. Please use <CODE>mapmode</CODE> instead in new code.</TD>
+ </TR>
+ <TR>
+ <TD VALIGN="top"><I>length</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>The number of bytes to map. If this parameter is not specified, the entire file is mapped.</TD>
+ </TR>
+ <TR>
+ <TD VALIGN="top"><I>offset</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>The offset where the mapping is to begin. This value must be a multiple of the operating system's virtual memory allocation granularity, which can be obtained using the static member function <A HREF='#mapped_file_alignment'><CODE>alignment</CODE></A>.</TD>
+ </TR>
+</TABLE>
+
+<A NAME="mapped_file_mapmode_ctor"></A>
+<PRE CLASS="broken_ie"> <SPAN CLASS='keyword'>explicit</SPAN> mapped_file( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
+ mapmode mode,
+ size_type length = max_length,
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );</PRE>
+
+<P>Constructs a <CODE>mapped_file</CODE> to access a specified file. The parameters have the following interpretation:</P>
+
+<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
+<TR>
+ <TR>
+ <TD VALIGN="top"><I>path</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>The pathname of the file to map.</TD>
+ </TR>
+ <TR>
+ <TD VALIGN="top"><I>mode</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>Indicates whether the file should be opened with read-access, read/write-access or private-access.</TD>
</TR>
<TR>
<TD VALIGN="top"><I>length</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
@@ -510,7 +577,35 @@
</TR>
<TR>
<TD VALIGN="top"><I>mode</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
- <TD>Indicates whether the file should be opened with read-access, write-access or both.</TD>
+ <TD>Indicates whether the file should be opened with read-access, write-access or both. Use of <CODE>std::ios_base::openmode</CODE> with <CODE>mapped_file</CODE> is deprecated. Please use <CODE>mapmode</CODE> in new code.</TD>
+ </TR>
+ <TR>
+ <TD VALIGN="top"><I>length</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>The number of bytes to map. If this parameter is not specified, the entire file is mapped.</TD>
+ </TR>
+ <TR>
+ <TD VALIGN="top"><I>offset</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>The offset where the mapping is to begin. This value must be a multiple of the operating system's virtual memory allocation granularity, which can be obtained using the static member function <A HREF='#mapped_file_alignment'><CODE>alignment</CODE></A>.</TD>
+ </TR>
+</TABLE>
+
+<A NAME="mapped_file_mapmode_open"></A>
+<PRE CLASS="broken_ie"> void open( <SPAN CLASS='keyword'>const</SPAN> std::string& path,
+ mapmode mode,
+ size_type length = max_length,
+ boost::intmax_t offset = <SPAN CLASS='numeric_literal'>0</SPAN> );</PRE>
+
+<P>Connects this <CODE>mapped_file</CODE> to a memory-mapped file obtained as described by the given parameters, which have the following interpretation:</P>
+
+<TABLE STYLE="margin-left:2em" BORDER=0 CELLPADDING=2>
+<TR>
+ <TR>
+ <TD VALIGN="top"><I>path</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>The pathname of the file to map.</TD>
+ </TR>
+ <TR>
+ <TD VALIGN="top"><I>mode</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
+ <TD>Indicates whether the file should be opened with read-access, read/write-access or private access.</TD>
</TR>
<TR>
<TD VALIGN="top"><I>length</I></TD><TD WIDTH="2em" VALIGN="top">-</TD>
@@ -529,6 +624,13 @@
<P>Returns <CODE>true</CODE> if this <CODE>mapped_file</CODE> has been successfully opened without subsequently having been closed.</P>
+<A NAME="mapped_file_flags"></A>
+<H4><CODE>mapped_file::flags</CODE></H4>
+
+<PRE CLASS="broken_ie"> mapmode flags() <SPAN CLASS='keyword'>const</SPAN>;</PRE>
+
+<P>Indicates whether the <CODE>mapped_file</CODE> was opened for read-access, read/write-access or private-access.</P>
+
<A NAME="mapped_file_close"></A>
<H4><CODE>mapped_file::close</CODE></H4>
Modified: branches/release/libs/iostreams/src/bzip2.cpp
==============================================================================
--- branches/release/libs/iostreams/src/bzip2.cpp (original)
+++ branches/release/libs/iostreams/src/bzip2.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -99,8 +99,21 @@
dest_begin = s->next_out;
}
+int bzip2_base::check_end(const char* src_begin, const char* dest_begin)
+{
+ bz_stream* s = static_cast<bz_stream*>(stream_);
+ if( src_begin == s->next_in &&
+ s->avail_in == 0 &&
+ dest_begin == s->next_out) {
+ return bzip2::unexpected_eof;
+ } else {
+ return bzip2::ok;
+ }
+}
+
void bzip2_base::end(bool compress)
{
+ if(!ready_) return;
ready_ = false;
bz_stream* s = static_cast<bz_stream*>(stream_);
bzip2_error::check BOOST_PREVENT_MACRO_SUBSTITUTION(
Modified: branches/release/libs/iostreams/src/file_descriptor.cpp
==============================================================================
--- branches/release/libs/iostreams/src/file_descriptor.cpp (original)
+++ branches/release/libs/iostreams/src/file_descriptor.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -62,8 +62,7 @@
std::streampos seek(stream_offset off, BOOST_IOS::seekdir way);
static file_handle invalid_handle();
enum flags {
- close_on_exit = 1,
- append = 4
+ close_on_exit = 1
};
file_handle handle_;
int flags_;
@@ -113,18 +112,30 @@
dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
dwCreationDisposition =
(mode & BOOST_IOS::trunc) ?
- OPEN_ALWAYS :
+ CREATE_ALWAYS :
OPEN_EXISTING;
} else if (mode & BOOST_IOS::in) {
- if (mode & (BOOST_IOS::app |BOOST_IOS::trunc))
+ if (mode & (BOOST_IOS::app | BOOST_IOS::trunc))
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
dwDesiredAccess = GENERIC_READ;
dwCreationDisposition = OPEN_EXISTING;
} else if (mode & BOOST_IOS::out) {
- dwDesiredAccess = GENERIC_WRITE;
- dwCreationDisposition = OPEN_ALWAYS;
- if (mode & BOOST_IOS::app)
- flags_ |= append;
+ if ( (mode & (BOOST_IOS::app | BOOST_IOS::trunc))
+ ==
+ (BOOST_IOS::app | BOOST_IOS::trunc) )
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
+ if (mode & BOOST_IOS::app) {
+ dwCreationDisposition = OPEN_ALWAYS;
+ dwDesiredAccess =
+ FILE_APPEND_DATA |
+ FILE_WRITE_ATTRIBUTES |
+ FILE_WRITE_EA |
+ STANDARD_RIGHTS_WRITE |
+ SYNCHRONIZE;
+ } else {
+ dwDesiredAccess = GENERIC_WRITE;
+ dwCreationDisposition = CREATE_ALWAYS;
+ }
} else {
boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
}
@@ -160,19 +171,32 @@
==
(BOOST_IOS::in | BOOST_IOS::out) )
{
- assert(!(mode & BOOST_IOS::app));
+ if( mode & BOOST_IOS::app )
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
oflag |= O_RDWR;
+ if( mode & BOOST_IOS::trunc ) {
+ oflag |= O_TRUNC;
+ oflag |= O_CREAT;
+ }
} else if (mode & BOOST_IOS::in) {
- assert(!(mode & (BOOST_IOS::app |BOOST_IOS::trunc)));
+ if( mode & (BOOST_IOS::app | BOOST_IOS::trunc) )
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
oflag |= O_RDONLY;
} else if (mode & BOOST_IOS::out) {
+ if( (mode & (BOOST_IOS::app | BOOST_IOS::trunc))
+ ==
+ (BOOST_IOS::app | BOOST_IOS::trunc) )
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
oflag |= O_WRONLY;
- mode |= BOOST_IOS::trunc;
if (mode & BOOST_IOS::app)
oflag |= O_APPEND;
+ else {
+ oflag |= O_CREAT;
+ oflag |= O_TRUNC;
+ }
+ } else {
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
}
- if (mode & BOOST_IOS::trunc)
- oflag |= O_CREAT;
#ifdef _LARGEFILE64_SOURCE
oflag |= O_LARGEFILE;
#endif
@@ -233,15 +257,6 @@
std::streamsize file_descriptor_impl::write(const char* s, std::streamsize n)
{
#ifdef BOOST_IOSTREAMS_WINDOWS
- if (flags_ & append) {
- DWORD const dwResult =
- ::SetFilePointer(handle_, 0, NULL, FILE_END);
- if ( dwResult == INVALID_SET_FILE_POINTER &&
- ::GetLastError() != NO_ERROR )
- {
- throw_system_failure("failed seeking within file");
- }
- }
DWORD ignore;
if (!::WriteFile(handle_, s, n, &ignore, NULL))
throw_system_failure("failed writing");
Modified: branches/release/libs/iostreams/src/mapped_file.cpp
==============================================================================
--- branches/release/libs/iostreams/src/mapped_file.cpp (original)
+++ branches/release/libs/iostreams/src/mapped_file.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -2,6 +2,8 @@
// (C) Copyright Jonathan Turkanis 2004.
// (C) Copyright Jonathan Graehl 2004.
// (C) Copyright Jorge Lodos 2008.
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// Define BOOST_IOSTREAMS_SOURCE so that <boost/iostreams/detail/config.hpp>
// knows that we are building the library (possibly exporting code), rather
@@ -166,7 +168,10 @@
#ifdef BOOST_IOSTREAMS_WINDOWS
// Open file
- DWORD dwDesiredAccess = readonly ? GENERIC_READ : GENERIC_ALL;
+ DWORD dwDesiredAccess =
+ readonly ?
+ GENERIC_READ :
+ (GENERIC_READ | GENERIC_WRITE);
DWORD dwCreationDisposition = (p.new_file_size != 0 && !readonly) ?
CREATE_ALWAYS :
OPEN_EXISTING;
Modified: branches/release/libs/iostreams/src/zlib.cpp
==============================================================================
--- branches/release/libs/iostreams/src/zlib.cpp (original)
+++ branches/release/libs/iostreams/src/zlib.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -91,7 +91,7 @@
namespace detail {
zlib_base::zlib_base()
- : stream_(new z_stream), calculate_crc_(false), crc_(0)
+ : stream_(new z_stream), calculate_crc_(false), crc_(0), crc_imp_(0)
{ }
zlib_base::~zlib_base() { delete static_cast<z_stream*>(stream_); }
@@ -121,7 +121,7 @@
static_cast<zlib::uint>(next_in - src_begin) :
static_cast<zlib::uint>(next_out - dest_begin);
if (length > 0)
- crc_ = crc32(crc_, buf, length);
+ crc_ = crc_imp_ = crc32(crc_imp_, buf, length);
}
total_in_ = s->total_in;
total_out_ = s->total_out;
@@ -150,6 +150,7 @@
(compress ? deflateEnd(s) : inflateEnd(s))
;
//);
+ crc_imp_ = 0;
}
void zlib_base::do_init
Modified: branches/release/libs/iostreams/test/Jamfile.v2
==============================================================================
--- branches/release/libs/iostreams/test/Jamfile.v2 (original)
+++ branches/release/libs/iostreams/test/Jamfile.v2 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -39,7 +39,7 @@
[ test-iostreams close_test.cpp ]
[ test-iostreams
code_converter_test.cpp
- detail/utf8_codecvt_facet.cpp : <link>static ]
+ detail/utf8_codecvt_facet.cpp ]
[ test-iostreams combine_test.cpp ]
[ test-iostreams compose_test.cpp ]
[ test-iostreams component_access_test.cpp ]
@@ -50,7 +50,7 @@
[ test-iostreams execute_test.cpp ]
[ test-iostreams file_test.cpp ]
[ test-iostreams file_descriptor_test.cpp
- ../src/file_descriptor.cpp : <link>static ]
+ ../build//boost_iostreams ]
[ test-iostreams filtering_stream_test.cpp ]
[ test-iostreams finite_state_filter_test.cpp ]
[ test-iostreams flush_test.cpp ]
@@ -60,7 +60,7 @@
[ test-iostreams invert_test.cpp ]
[ test-iostreams line_filter_test.cpp ]
[ test-iostreams mapped_file_test.cpp
- ../src/mapped_file.cpp : <link>static ]
+ ../build//boost_iostreams ]
[ test-iostreams newline_test.cpp ]
[ test-iostreams null_test.cpp ]
[ test-iostreams operation_sequence_test.cpp ]
Modified: branches/release/libs/iostreams/test/bzip2_test.cpp
==============================================================================
--- branches/release/libs/iostreams/test/bzip2_test.cpp (original)
+++ branches/release/libs/iostreams/test/bzip2_test.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -8,6 +8,7 @@
#include <string>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/filter/test.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include "detail/sequence.hpp"
@@ -17,6 +18,7 @@
using namespace boost::iostreams;
using namespace boost::iostreams::test;
using boost::unit_test::test_suite;
+namespace io = boost::iostreams;
struct bzip2_alloc : std::allocator<char> { };
@@ -33,11 +35,62 @@
basic_bzip2_decompressor<bzip2_alloc>(),
std::string(data.begin(), data.end()) )
);
+ BOOST_CHECK(
+ test_filter_pair( bzip2_compressor(),
+ bzip2_decompressor(),
+ std::string() )
+ );
+ {
+ filtering_istream strm;
+ strm.push( bzip2_compressor() );
+ strm.push( null_source() );
+ }
+ {
+ filtering_istream strm;
+ strm.push( bzip2_decompressor() );
+ strm.push( null_source() );
+ }
}
+void multiple_member_test()
+{
+ text_sequence data;
+ std::vector<char> temp, dest;
+
+ // Write compressed data to temp, twice in succession
+ filtering_ostream out;
+ out.push(bzip2_compressor());
+ out.push(io::back_inserter(temp));
+ io::copy(make_iterator_range(data), out);
+ out.push(io::back_inserter(temp));
+ io::copy(make_iterator_range(data), out);
+
+ // Read compressed data from temp into dest
+ filtering_istream in;
+ in.push(bzip2_decompressor());
+ in.push(array_source(&temp[0], temp.size()));
+ io::copy(in, io::back_inserter(dest));
+
+ // Check that dest consists of two copies of data
+ BOOST_REQUIRE_EQUAL(data.size() * 2, dest.size());
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin()));
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
+
+ dest.clear();
+ io::copy(
+ array_source(&temp[0], temp.size()),
+ io::compose(bzip2_decompressor(), io::back_inserter(dest)));
+
+ // Check that dest consists of two copies of data
+ BOOST_REQUIRE_EQUAL(data.size() * 2, dest.size());
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin()));
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
+}
+
test_suite* init_unit_test_suite(int, char* [])
{
test_suite* test = BOOST_TEST_SUITE("bzip2 test");
test->add(BOOST_TEST_CASE(&bzip2_test));
+ test->add(BOOST_TEST_CASE(&multiple_member_test));
return test;
}
Modified: branches/release/libs/iostreams/test/detail/verification.hpp
==============================================================================
--- branches/release/libs/iostreams/test/detail/verification.hpp (original)
+++ branches/release/libs/iostreams/test/detail/verification.hpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -100,6 +100,13 @@
return true;
}
+template<typename Container>
+bool compare_container_and_file(Container& cnt, const std::string& file)
+{
+ std::ifstream fstrm(file.c_str(), BOOST_IOS::in | BOOST_IOS::binary);
+ return compare_container_and_stream(cnt, fstrm);
+}
+
BOOST_TEMPLATE_DECL
void write_data_in_chars(BOOST_OSTREAM& os)
{
Modified: branches/release/libs/iostreams/test/file_descriptor_test.cpp
==============================================================================
--- branches/release/libs/iostreams/test/file_descriptor_test.cpp (original)
+++ branches/release/libs/iostreams/test/file_descriptor_test.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -80,9 +80,41 @@
first->close();
BOOST_CHECK(!first->is_open());
}
+
+ // test illegal flag combinations
+ {
+ BOOST_CHECK_THROW(
+ file_descriptor_source(test1.name(),
+ BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_source(test1.name(),
+ BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_source(test1.name(),
+ BOOST_IOS::app | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_source(test1.name(),
+ BOOST_IOS::out),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_source(test1.name(),
+ BOOST_IOS::out | BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_source(test1.name(),
+ BOOST_IOS::out | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_source(test1.name(),
+ BOOST_IOS::out | BOOST_IOS::app | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ }
//--------------Test file_descriptor_sink---------------------------------//
-
+
{
temp_file temp;
file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
@@ -142,11 +174,78 @@
file.close();
BOOST_CHECK(!file.is_open());
}
+
+ {
+ temp_file temp;
+ // set up the tests
+ {
+ file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
+ fdostream out(file);
+ write_data_in_chunks(out);
+ out.close();
+ file.close();
+ }
+ // test std::ios_base::app
+ {
+ file_descriptor_sink file(temp.name(), BOOST_IOS::app);
+ fdostream out(file);
+ BOOST_CHECK(out->is_open());
+ write_data_in_chars(out);
+ out.close();
+ std::string expected(narrow_data());
+ expected += narrow_data();
+ BOOST_CHECK_MESSAGE(
+ compare_container_and_file(expected, temp.name()),
+ "failed writing to file_descriptor_sink in append mode"
+ );
+ file.close();
+ BOOST_CHECK(!file.is_open());
+ }
+ // test std::ios_base::trunc
+ {
+ file_descriptor_sink file(temp.name(), BOOST_IOS::trunc);
+ fdostream out(file);
+ BOOST_CHECK(out->is_open());
+ write_data_in_chars(out);
+ out.close();
+ BOOST_CHECK_MESSAGE(
+ compare_files(test1.name(), temp.name()),
+ "failed writing to file_descriptor_sink in trunc mode"
+ );
+ file.close();
+ BOOST_CHECK(!file.is_open());
+ }
+
+ // test illegal flag combinations
+ {
+ BOOST_CHECK_THROW(
+ file_descriptor_sink(temp.name(),
+ BOOST_IOS::trunc | BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_sink(temp.name(),
+ BOOST_IOS::in),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_sink(temp.name(),
+ BOOST_IOS::in | BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_sink(temp.name(),
+ BOOST_IOS::in | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor_sink(temp.name(),
+ BOOST_IOS::in | BOOST_IOS::trunc | BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ }
+ }
//--Test seeking with file_descriptor_source and file_descriptor_sink-----//
+ test_file test3;
{
- file_descriptor_sink sink(test1.name());
+ file_descriptor_sink sink(test3.name());
fdostream out(sink);
BOOST_CHECK(out->is_open());
BOOST_CHECK_MESSAGE(
@@ -156,7 +255,7 @@
out->close();
BOOST_CHECK(!out->is_open());
- file_descriptor_source source(test1.name());
+ file_descriptor_source source(test3.name());
fdistream in(source);
BOOST_CHECK(in->is_open());
BOOST_CHECK_MESSAGE(
@@ -196,6 +295,216 @@
"failed seeking within a file_descriptor, in chunks"
);
}
+
+ //--------------Test read-only file_descriptor----------------------------//
+
+ {
+ fdstream first(file_descriptor(test1.name(), BOOST_IOS::in), 0);
+ ifstream second(test2.name().c_str());
+ BOOST_CHECK(first->is_open());
+ write_data_in_chars(first);
+ BOOST_CHECK(first.fail());
+ first.clear();
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chars(first, second),
+ "failed reading from file_descriptor in chars with no buffer"
+ );
+ first->close();
+ BOOST_CHECK(!first->is_open());
+ }
+
+ {
+ fdstream first(file_descriptor(test1.name(), BOOST_IOS::in), 0);
+ ifstream second(test2.name().c_str());
+ BOOST_CHECK(first->is_open());
+ write_data_in_chunks(first);
+ BOOST_CHECK(first.fail());
+ first.clear();
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chunks(first, second),
+ "failed reading from file_descriptor in chunks with no buffer"
+ );
+ first->close();
+ BOOST_CHECK(!first->is_open());
+ }
+
+ {
+ file_descriptor file(test1.name(), BOOST_IOS::in);
+ fdstream first(file);
+ ifstream second(test2.name().c_str());
+ BOOST_CHECK(first->is_open());
+ write_data_in_chars(first);
+ BOOST_CHECK(first.fail());
+ first.clear();
+ first.seekg(0, BOOST_IOS::beg);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chars(first, second),
+ "failed reading from file_descriptor in chars with buffer"
+ );
+ first->close();
+ BOOST_CHECK(!first->is_open());
+ }
+
+ {
+ file_descriptor file(test1.name(), BOOST_IOS::in);
+ fdstream first(file);
+ ifstream second(test2.name().c_str());
+ BOOST_CHECK(first->is_open());
+ write_data_in_chunks(first);
+ BOOST_CHECK(first.fail());
+ first.clear();
+ first.seekg(0, BOOST_IOS::beg);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chunks(first, second),
+ "failed reading from file_descriptor in chunks with buffer"
+ );
+ first->close();
+ BOOST_CHECK(!first->is_open());
+ }
+
+ //--------------Test write-only file_descriptor---------------------------//
+ {
+ temp_file temp;
+ file_descriptor file( temp.name(),
+ BOOST_IOS::out |
+ BOOST_IOS::trunc );
+ fdstream out(file, 0);
+ BOOST_CHECK(out->is_open());
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ write_data_in_chars(out);
+ out.seekg(0, BOOST_IOS::beg);
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ out.close();
+ BOOST_CHECK_MESSAGE(
+ compare_files(test1.name(), temp.name()),
+ "failed writing to file_descriptor in chars with no buffer"
+ );
+ file.close();
+ BOOST_CHECK(!file.is_open());
+ }
+
+ {
+ temp_file temp;
+ file_descriptor file( temp.name(),
+ BOOST_IOS::out |
+ BOOST_IOS::trunc );
+ fdstream out(file, 0);
+ BOOST_CHECK(out->is_open());
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ write_data_in_chunks(out);
+ out.seekg(0, BOOST_IOS::beg);
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ out.close();
+ BOOST_CHECK_MESSAGE(
+ compare_files(test1.name(), temp.name()),
+ "failed writing to file_descriptor_sink in chunks with no buffer"
+ );
+ file.close();
+ BOOST_CHECK(!file.is_open());
+ }
+
+ {
+ temp_file temp;
+ file_descriptor file( temp.name(),
+ BOOST_IOS::out |
+ BOOST_IOS::trunc );
+ fdstream out(file);
+ BOOST_CHECK(out->is_open());
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ write_data_in_chars(out);
+ out.seekg(0, BOOST_IOS::beg);
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ out.close();
+ BOOST_CHECK_MESSAGE(
+ compare_files(test1.name(), temp.name()),
+ "failed writing to file_descriptor_sink in chars with buffer"
+ );
+ file.close();
+ BOOST_CHECK(!file.is_open());
+ }
+
+ {
+ temp_file temp;
+ file_descriptor file( temp.name(),
+ BOOST_IOS::out |
+ BOOST_IOS::trunc );
+ fdstream out(file);
+ BOOST_CHECK(out->is_open());
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ write_data_in_chunks(out);
+ out.seekg(0, BOOST_IOS::beg);
+ out.get();
+ BOOST_CHECK(out.fail());
+ out.clear();
+ out.close();
+ BOOST_CHECK_MESSAGE(
+ compare_files(test1.name(), temp.name()),
+ "failed writing to file_descriptor_sink in chunks with buffer"
+ );
+ file.close();
+ BOOST_CHECK(!file.is_open());
+ }
+
+ // test illegal flag combinations
+ {
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::openmode(0)),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::app | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::in | BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::in | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::in | BOOST_IOS::app | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::out | BOOST_IOS::app | BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::in | BOOST_IOS::out | BOOST_IOS::app),
+ BOOST_IOSTREAMS_FAILURE);
+ BOOST_CHECK_THROW(
+ file_descriptor(test1.name(),
+ BOOST_IOS::in |
+ BOOST_IOS::out |
+ BOOST_IOS::app |
+ BOOST_IOS::trunc),
+ BOOST_IOSTREAMS_FAILURE);
+ }
}
test_suite* init_unit_test_suite(int, char* [])
Modified: branches/release/libs/iostreams/test/gzip_test.cpp
==============================================================================
--- branches/release/libs/iostreams/test/gzip_test.cpp (original)
+++ branches/release/libs/iostreams/test/gzip_test.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -79,6 +79,17 @@
io::copy(in, io::back_inserter(dest));
// Check that dest consists of two copies of data
+ BOOST_REQUIRE_EQUAL(data.size() * 2, dest.size());
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin()));
+ BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
+
+ dest.clear();
+ io::copy(
+ array_source(&temp[0], temp.size()),
+ io::compose(gzip_decompressor(), io::back_inserter(dest)));
+
+ // Check that dest consists of two copies of data
+ BOOST_REQUIRE_EQUAL(data.size() * 2, dest.size());
BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin()));
BOOST_CHECK(std::equal(data.begin(), data.end(), dest.begin() + dest.size() / 2));
}
Modified: branches/release/libs/iostreams/test/regex_filter_test.cpp
==============================================================================
--- branches/release/libs/iostreams/test/regex_filter_test.cpp (original)
+++ branches/release/libs/iostreams/test/regex_filter_test.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -22,6 +22,10 @@
struct replace_lower {
std::string operator() (const boost::match_results<const char*>&)
{ return "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
+#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
+ std::wstring operator() (const boost::match_results<const wchar_t*>&)
+ { return L"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; }
+#endif
};
void regex_filter_test()
@@ -167,9 +171,159 @@
}
}
+#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
+
+void wregex_filter_test()
+{
+ // Note: Given the basic stream and filter tests, two regex tests
+ // are probably sufficient: reading with a filter based on a function,
+ // and writing with a filter based on a format string.
+
+ test_file test;
+ uppercase_file upper;
+
+ boost::wregex match_lower(L"[a-z]+");
+ std::wstring fmt = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ {
+ // Note: the ifstream second is placed in a nested scope because
+ // closing and reopening a single ifstream failed for CW 9.4 on Windows.
+
+ // Test reading from a regex filter based on a function in chars.
+ filtering_wistream
+ first(boost::iostreams::wregex_filter(match_lower, replace_lower()));
+ first.push(wfile_source(test.name(), in_mode));
+ {
+ wifstream second(upper.name().c_str(), in_mode);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chars(first, second),
+ "failed reading from function-based regex_filter in chars"
+ );
+ }
+ first.pop();
+
+ // Test reading from a regex filter based on a function in chunks.
+ // (Also tests reusing the regex filter.)
+ first.push(wfile_source(test.name(), in_mode));
+ {
+ wifstream second(upper.name().c_str(), in_mode);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chunks(first, second),
+ "failed reading from function-based regex_filter in chunks"
+ );
+ }
+ }
+
+ {
+ // Note: the ifstream second is placed in a nested scope because
+ // closing and reopening a single ifstream failed for CW 9.4 on Windows.
+
+ // Test reading from a regex filter based on a format string in chars.
+ filtering_wistream
+ first(boost::iostreams::wregex_filter(match_lower, fmt));
+ first.push(wfile_source(test.name(), in_mode));
+ {
+ wifstream second(upper.name().c_str(), in_mode);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chars(first, second),
+ "failed reading from format-string-based regex_filter in chars"
+ );
+ }
+ first.pop();
+
+ // Test reading from a regex filter based on a format string in chunks.
+ // (Also tests reusing the regex filter.)
+ first.push(wfile_source(test.name(), in_mode));
+ {
+ wifstream second(upper.name().c_str(), in_mode);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chars(first, second),
+ "failed reading from format-string-based regex_filter in chunks"
+ );
+ }
+ }
+
+ {
+ test_file dest1;
+ test_file dest2;
+
+ // Test writing to a regex filter based on a function in chars.
+ filtering_wostream
+ out(boost::iostreams::wregex_filter(match_lower, replace_lower()));
+ out.push(wfile_sink(dest1.name(), out_mode));
+ write_data_in_chars(out);
+ out.pop();
+ BOOST_CHECK_MESSAGE(
+ compare_files(dest1.name(), upper.name()),
+ "failed writing to function-based regex_filter in chars"
+ );
+
+ // Test writing to a regex filter based on a function in chunks.
+ // (Also tests reusing the regex filter.)
+ out.push(wfile_sink(dest2.name(), out_mode));
+ write_data_in_chunks(out);
+ out.pop();
+ BOOST_CHECK_MESSAGE(
+ compare_files(dest2.name(), upper.name()),
+ "failed writing to function-based regex_filter in chunks"
+ );
+ }
+
+ {
+ test_file dest1;
+ test_file dest2;
+
+ // Test writing to a regex filter based on a format string in chars.
+ filtering_wostream
+ out(boost::iostreams::wregex_filter(match_lower, fmt));
+ out.push(wfile_sink(dest1.name(), out_mode));
+ write_data_in_chars(out);
+ out.pop();
+ BOOST_CHECK_MESSAGE(
+ compare_files(dest1.name(), upper.name()),
+ "failed writing to format-string-based regex_filter in chars"
+ );
+
+ // Test writing to a regex filter based on a format string in chunks.
+ // (Also tests reusing the regex filter.)
+ out.push(wfile_sink(dest2.name(), out_mode));
+ write_data_in_chunks(out);
+ out.pop();
+ BOOST_CHECK_MESSAGE(
+ compare_files(dest2.name(), upper.name()),
+ "failed writing to format-string-based regex_filter in chunks"
+ );
+ }
+
+ {
+ // Note: the ifstream second is placed in a nested scope because
+ // closing and reopening a single ifstream failed for CW 9.4 on Windows.
+
+ // Test reading from a regex filter with no matches; this checks that
+ // Ticket #1139 is fixed
+ boost::wregex match_xxx(L"xxx");
+ test_file test2;
+ filtering_wistream
+ first(boost::iostreams::wregex_filter(match_xxx, replace_lower()));
+ first.push(wfile_source(test.name(), in_mode));
+ {
+ wifstream second(test2.name().c_str(), in_mode);
+ BOOST_CHECK_MESSAGE(
+ compare_streams_in_chars(first, second),
+ "failed reading from a regex filter with no matches"
+ );
+ }
+ }
+}
+
+#endif
+
test_suite* init_unit_test_suite(int, char* [])
{
test_suite* test = BOOST_TEST_SUITE("regex_filter test");
test->add(BOOST_TEST_CASE(®ex_filter_test));
+#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
+ test->add(BOOST_TEST_CASE(&wregex_filter_test));
+#endif
return test;
}
Modified: branches/release/libs/iostreams/test/symmetric_filter_test.cpp
==============================================================================
--- branches/release/libs/iostreams/test/symmetric_filter_test.cpp (original)
+++ branches/release/libs/iostreams/test/symmetric_filter_test.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -111,7 +111,7 @@
chain<input> ch;
ch.push(
io::symmetric_filter<closable_symmetric_filter>
- (0, seq.new_operation(2))
+ (1, seq.new_operation(2))
);
ch.push(closable_device<input>(seq.new_operation(1)));
BOOST_CHECK_NO_THROW(ch.reset());
@@ -124,7 +124,7 @@
chain<output> ch;
ch.push(
io::symmetric_filter<closable_symmetric_filter>
- (0, seq.new_operation(1))
+ (1, seq.new_operation(1))
);
ch.push(closable_device<output>(seq.new_operation(2)));
BOOST_CHECK_NO_THROW(ch.reset());
@@ -132,12 +132,50 @@
}
}
+#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
+
+struct wcopy_filter_impl {
+ typedef wchar_t char_type;
+ bool filter( const wchar_t*& src_begin, const wchar_t* src_end,
+ wchar_t*& dest_begin, wchar_t* dest_end, bool /* flush */ )
+ {
+ if(src_begin != src_end && dest_begin != dest_end) {
+ *dest_begin++ = *src_begin++;
+ }
+ return false;
+ }
+ void close() {}
+};
+
+typedef symmetric_filter<wcopy_filter_impl> wcopy_filter;
+
+void wide_symmetric_filter()
+{
+ {
+ warray_source src(wide_data(), wide_data() + data_length());
+ std::wstring dest;
+ io::copy(src, io::compose(wcopy_filter(16), io::back_inserter(dest)));
+ BOOST_CHECK(dest == wide_data());
+ }
+ {
+ warray_source src(wide_data(), wide_data() + data_length());
+ std::wstring dest;
+ io::copy(io::compose(wcopy_filter(16), src), io::back_inserter(dest));
+ BOOST_CHECK(dest == wide_data());
+ }
+}
+
+#endif
+
test_suite* init_unit_test_suite(int, char* [])
{
test_suite* test = BOOST_TEST_SUITE("symmetric_filter test");
test->add(BOOST_TEST_CASE(&read_symmetric_filter));
test->add(BOOST_TEST_CASE(&write_symmetric_filter));
test->add(BOOST_TEST_CASE(&close_symmetric_filter));
+#ifndef BOOST_IOSTREAMS_NO_WIDE_STREAMS
+ test->add(BOOST_TEST_CASE(&wide_symmetric_filter));
+#endif
return test;
}
Modified: branches/release/libs/iostreams/test/zlib_test.cpp
==============================================================================
--- branches/release/libs/iostreams/test/zlib_test.cpp (original)
+++ branches/release/libs/iostreams/test/zlib_test.cpp 2010-06-25 03:19:54 EDT (Fri, 25 Jun 2010)
@@ -8,6 +8,7 @@
#include <string>
#include <boost/iostreams/filter/test.hpp>
#include <boost/iostreams/filter/zlib.hpp>
+#include <boost/iostreams/filtering_stream.hpp>
#include <boost/test/test_tools.hpp>
#include <boost/test/unit_test.hpp>
#include "detail/sequence.hpp"
@@ -34,6 +35,21 @@
basic_zlib_decompressor<zlib_alloc>(),
std::string(data.begin(), data.end()) )
);
+ BOOST_CHECK(
+ test_filter_pair( zlib_compressor(),
+ zlib_decompressor(),
+ std::string() )
+ );
+ {
+ filtering_istream strm;
+ strm.push( zlib_compressor() );
+ strm.push( null_source() );
+ }
+ {
+ filtering_istream strm;
+ strm.push( zlib_decompressor() );
+ strm.push( null_source() );
+ }
}
test_suite* init_unit_test_suite(int, char* [])
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk