|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57604 - in trunk: boost/iostreams boost/iostreams/detail boost/iostreams/detail/adapter boost/iostreams/detail/broken_overload_resolution boost/iostreams/detail/streambuf boost/iostreams/device boost/iostreams/filter libs/iostreams/src
From: daniel_james_at_[hidden]
Date: 2009-11-12 14:18:24
Author: danieljames
Date: 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
New Revision: 57604
URL: http://svn.boost.org/trac/boost/changeset/57604
Log:
Use boost::throw_exception. Refs #2094.
Still some throws left when rethrowing caught exceptions.
Thanks to Richard Smith.
Text files modified:
trunk/boost/iostreams/chain.hpp | 7 ++++---
trunk/boost/iostreams/checked_operations.hpp | 11 ++++++-----
trunk/boost/iostreams/code_converter.hpp | 7 ++++---
trunk/boost/iostreams/detail/adapter/concept_adapter.hpp | 13 +++++++------
trunk/boost/iostreams/detail/adapter/direct_adapter.hpp | 9 +++++----
trunk/boost/iostreams/detail/adapter/range_adapter.hpp | 14 +++++++++-----
trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp | 3 ++-
trunk/boost/iostreams/detail/restrict_impl.hpp | 19 ++++++++++---------
trunk/boost/iostreams/detail/streambuf/direct_streambuf.hpp | 20 ++++++++++++--------
trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp | 3 ++-
trunk/boost/iostreams/detail/system_failure.hpp | 5 +++--
trunk/boost/iostreams/device/mapped_file.hpp | 9 +++++----
trunk/boost/iostreams/filter/gzip.hpp | 13 +++++++------
trunk/boost/iostreams/filter/newline.hpp | 5 +++--
trunk/boost/iostreams/skip.hpp | 5 +++--
trunk/boost/iostreams/stream_buffer.hpp | 5 ++++-
trunk/libs/iostreams/src/bzip2.cpp | 5 +++--
trunk/libs/iostreams/src/file_descriptor.cpp | 19 ++++++++++---------
trunk/libs/iostreams/src/gzip.cpp | 9 +++++----
trunk/libs/iostreams/src/mapped_file.cpp | 31 ++++++++++++++++++++-----------
trunk/libs/iostreams/src/zlib.cpp | 5 +++--
21 files changed, 127 insertions(+), 90 deletions(-)
Modified: trunk/boost/iostreams/chain.hpp
==============================================================================
--- trunk/boost/iostreams/chain.hpp (original)
+++ trunk/boost/iostreams/chain.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -36,6 +36,7 @@
#include <boost/next_prior.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/static_assert.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type.hpp>
#include <boost/iostreams/detail/execute.hpp> // VC6.5 requires this
@@ -172,7 +173,7 @@
const std::type_info& component_type(int n) const
{
if (static_cast<size_type>(n) >= size())
- throw std::out_of_range("bad chain offset");
+ boost::throw_exception(std::out_of_range("bad chain offset"));
return (*boost::next(list().begin(), n))->component_type();
}
@@ -196,7 +197,7 @@
T* component(int n, boost::type<T>) const
{
if (static_cast<size_type>(n) >= size())
- throw std::out_of_range("bad chain offset");
+ boost::throw_exception(std::out_of_range("bad chain offset"));
streambuf_type* link = *boost::next(list().begin(), n);
if (BOOST_IOSTREAMS_COMPARE_TYPE_ID(link->component_type(), typeid(T)))
return static_cast<T*>(link->component_impl());
@@ -238,7 +239,7 @@
typedef typename list_type::iterator iterator;
BOOST_STATIC_ASSERT((is_convertible<category, Mode>::value));
if (is_complete())
- throw std::logic_error("chain complete");
+ boost::throw_exception(std::logic_error("chain complete"));
streambuf_type* prev = !empty() ? list().back() : 0;
buffer_size =
buffer_size != -1 ?
Modified: trunk/boost/iostreams/checked_operations.hpp
==============================================================================
--- trunk/boost/iostreams/checked_operations.hpp (original)
+++ trunk/boost/iostreams/checked_operations.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -20,6 +20,7 @@
#include <boost/iostreams/seek.hpp>
#include <boost/iostreams/traits.hpp>
#include <boost/iostreams/write.hpp>
+#include <boost/throw_exception.hpp>
// Must come last.
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
@@ -93,24 +94,24 @@
template<typename T>
static bool put(T&, typename char_type_of<T>::type)
- { throw cant_write(); }
+ { boost::throw_exception(cant_write()); }
template<typename T>
static std::streamsize
write(T&, const typename char_type_of<T>::type*, std::streamsize)
- { throw cant_write(); }
+ { boost::throw_exception(cant_write()); }
};
template<>
struct read_write_if_impl<output> {
template<typename T>
static typename int_type_of<T>::type get(T&)
- { throw cant_read(); }
+ { boost::throw_exception(cant_read()); }
template<typename T>
static std::streamsize
read(T&, typename char_type_of<T>::type*, std::streamsize)
- { throw cant_read(); }
+ { boost::throw_exception(cant_read()); }
template<typename T>
static bool put(T& t, typename char_type_of<T>::type c)
@@ -139,7 +140,7 @@
template<typename T>
static std::streampos
seek(T&, stream_offset, BOOST_IOS::seekdir, BOOST_IOS::openmode)
- { throw cant_seek(); }
+ { boost::throw_exception(cant_seek()); }
};
} // End namespace detail.
Modified: trunk/boost/iostreams/code_converter.hpp
==============================================================================
--- trunk/boost/iostreams/code_converter.hpp (original)
+++ trunk/boost/iostreams/code_converter.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -44,6 +44,7 @@
#include <boost/iostreams/operations.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/static_assert.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/type_traits/is_same.hpp>
@@ -155,7 +156,7 @@
void open(const Device& dev, int buffer_size)
{
if (flags_ & f_open)
- throw BOOST_IOSTREAMS_FAILURE("already open");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("already open"));
if (buffer_size == -1)
buffer_size = default_filter_buffer_size;
int max_length = cvt_.get().max_length();
@@ -354,7 +355,7 @@
case std::codecvt_base::error:
default:
buf.state() = state_type();
- throw code_conversion_error();
+ boost::throw_exception(code_conversion_error());
}
} while (total < n && status != EOF && status != WOULD_BLOCK);
@@ -407,7 +408,7 @@
case std::codecvt_base::error:
default:
buf.state() = state_type();
- throw code_conversion_error();
+ boost::throw_exception(code_conversion_error());
}
}
return total;
Modified: trunk/boost/iostreams/detail/adapter/concept_adapter.hpp
==============================================================================
--- trunk/boost/iostreams/detail/adapter/concept_adapter.hpp (original)
+++ trunk/boost/iostreams/detail/adapter/concept_adapter.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -22,6 +22,7 @@
#include <boost/iostreams/operations.hpp>
#include <boost/mpl/if.hpp>
#include <boost/static_assert.hpp>
+#include <boost/throw_exception.hpp>
// Must come last.
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
@@ -137,7 +138,7 @@
seek( Device&, stream_offset, BOOST_IOS::seekdir,
BOOST_IOS::openmode, any_tag )
{
- throw cant_seek();
+ boost::throw_exception(cant_seek());
}
template<typename Device>
@@ -171,7 +172,7 @@
static std::streamsize
write( Device&, Dummy*, const typename char_type_of<Device>::type*,
std::streamsize )
- { throw cant_write(); }
+ { boost::throw_exception(cant_write()); }
};
template<>
@@ -179,7 +180,7 @@
template<typename Device, typename Dummy>
static std::streamsize
read(Device&, Dummy*, typename char_type_of<Device>::type*, std::streamsize)
- { throw cant_read(); }
+ { boost::throw_exception(cant_read()); }
template<typename Device, typename Dummy>
static std::streamsize
@@ -205,7 +206,7 @@
static std::streampos
seek( Filter&, Device*, stream_offset,
BOOST_IOS::seekdir, BOOST_IOS::openmode, any_tag )
- { throw cant_seek(); }
+ { boost::throw_exception(cant_seek()); }
template<typename Filter, typename Device>
static std::streampos
@@ -252,7 +253,7 @@
static std::streamsize
write( Filter&, Sink*, const typename char_type_of<Filter>::type*,
std::streamsize )
- { throw cant_write(); }
+ { boost::throw_exception(cant_write()); }
};
template<>
@@ -260,7 +261,7 @@
template<typename Filter, typename Source>
static std::streamsize
read(Filter&, Source*, typename char_type_of<Filter>::type*,std::streamsize)
- { throw cant_read(); }
+ { boost::throw_exception(cant_read()); }
template<typename Filter, typename Sink>
static std::streamsize
Modified: trunk/boost/iostreams/detail/adapter/direct_adapter.hpp
==============================================================================
--- trunk/boost/iostreams/detail/adapter/direct_adapter.hpp (original)
+++ trunk/boost/iostreams/detail/adapter/direct_adapter.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -30,6 +30,7 @@
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/static_assert.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
// Must come last.
@@ -209,7 +210,7 @@
using namespace std;
pointers& put = ptrs_.second();
if (n > static_cast<std::streamsize>(put.end - put.ptr))
- throw write_area_exhausted();
+ boost::throw_exception(write_area_exhausted());
std::copy(s, s + n, put.ptr);
put.ptr += n;
return n;
@@ -224,7 +225,7 @@
pointers& get = ptrs_.first();
pointers& put = ptrs_.second();
if (way == BOOST_IOS::cur && get.ptr != put.ptr)
- throw bad_seek();
+ boost::throw_exception(bad_seek());
ptrdiff_t next = 0;
if ((which & BOOST_IOS::in) || !is_double::value) {
if (way == BOOST_IOS::beg)
@@ -236,7 +237,7 @@
if (next >= 0 && next <= get.end - get.beg)
get.ptr = get.beg + next;
else
- throw bad_seek();
+ boost::throw_exception(bad_seek());
}
if ((which & BOOST_IOS::out) && is_double::value) {
if (way == BOOST_IOS::beg)
@@ -248,7 +249,7 @@
if (next >= 0 && next <= put.end - put.beg)
put.ptr = put.beg + next;
else
- throw bad_seek();
+ boost::throw_exception(bad_seek());
}
return offset_to_position(next);
}
Modified: trunk/boost/iostreams/detail/adapter/range_adapter.hpp
==============================================================================
--- trunk/boost/iostreams/detail/adapter/range_adapter.hpp (original)
+++ trunk/boost/iostreams/detail/adapter/range_adapter.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -21,6 +21,7 @@
#include <boost/iostreams/detail/error.hpp>
#include <boost/iostreams/positioning.hpp>
#include <boost/mpl/if.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/utility/enable_if.hpp>
@@ -116,7 +117,7 @@
{
while (cur != last && n-- > 0) *cur++ = *s++;
if (cur == last && n > 0)
- throw write_area_exhausted();
+ boost::throw_exception(write_area_exhausted());
return n;
}
};
@@ -144,7 +145,7 @@
std::copy(s, s + count, cur);
cur += count;
if (count < n)
- throw write_area_exhausted();
+ boost::throw_exception(write_area_exhausted());
return n;
}
@@ -156,18 +157,21 @@
using namespace std;
switch (way) {
case BOOST_IOS::beg:
- if (off > last - first || off < 0) throw bad_seek();
+ if (off > last - first || off < 0)
+ boost::throw_exception(bad_seek());
cur = first + off;
break;
case BOOST_IOS::cur:
{
std::ptrdiff_t newoff = cur - first + off;
- if (newoff > last - first || newoff < 0) throw bad_seek();
+ if (newoff > last - first || newoff < 0)
+ boost::throw_exception(bad_seek());
cur += off;
break;
}
case BOOST_IOS::end:
- if (last - first + off < 0 || off > 0) throw bad_seek();
+ if (last - first + off < 0 || off > 0)
+ boost::throw_exception(bad_seek());
cur = last + off;
break;
default:
Modified: trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp
==============================================================================
--- trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp (original)
+++ trunk/boost/iostreams/detail/broken_overload_resolution/stream_buffer.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -9,6 +9,7 @@
#define BOOST_IOSTREAMS_DETAIL_BROKEN_OVERLOAD_RESOLUTION_STREAM_BUFFER_HPP_INCLUDED
#include <boost/iostreams/detail/broken_overload_resolution/forward.hpp>
+#include <boost/throw_exception.hpp>
namespace boost { namespace iostreams {
@@ -179,7 +180,7 @@
void check_open()
{
if (this->is_open())
- throw BOOST_IOSTREAMS_FAILURE("already open");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("already open"));
}
};
Modified: trunk/boost/iostreams/detail/restrict_impl.hpp
==============================================================================
--- trunk/boost/iostreams/detail/restrict_impl.hpp (original)
+++ trunk/boost/iostreams/detail/restrict_impl.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -44,6 +44,7 @@
# include <boost/iostreams/traits.hpp> // mode_of, is_direct.
# include <boost/mpl/bool.hpp>
# include <boost/static_assert.hpp>
+# include <boost/throw_exception.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/iostreams/detail/config/disable_warnings.hpp>
@@ -160,7 +161,7 @@
if (!open_)
open(snk, BOOST_IOS::out);
if (end_ != -1 && pos_ + n >= end_)
- throw bad_write();
+ boost::throw_exception(bad_write());
std::streamsize result =
iostreams::write(this->component(), snk, s, n);
pos_ += result;
@@ -181,11 +182,11 @@
// Restriction is half-open; seek relative to the actual end.
pos_ = this->component().seek(dev, off, BOOST_IOS::end);
if (pos_ < beg_)
- throw bad_seek();
+ boost::throw_exception(bad_seek());
return offset_to_position(pos_ - beg_);
}
if (next < beg_ || (end_ != -1 && next >= end_))
- throw bad_seek();
+ boost::throw_exception(bad_seek());
pos_ = this->component().seek(dev, next, BOOST_IOS::cur);
return offset_to_position(pos_ - beg_);
}
@@ -248,7 +249,7 @@
end_(len != -1 ? off + len : -1)
{
if (len < -1 || off < 0)
- throw BOOST_IOSTREAMS_FAILURE("bad offset");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
iostreams::skip(this->component(), off);
}
@@ -272,7 +273,7 @@
(const char_type* s, std::streamsize n)
{
if (end_ != -1 && pos_ + n >= end_)
- throw bad_write();
+ boost::throw_exception(bad_write());
std::streamsize result = iostreams::write(this->component(), s, n);
pos_ += result;
return result;
@@ -293,11 +294,11 @@
// Restriction is half-open; seek relative to the actual end.
pos_ = iostreams::seek(this->component(), off, BOOST_IOS::end);
if (pos_ < beg_)
- throw bad_seek();
+ boost::throw_exception(bad_seek());
return offset_to_position(pos_ - beg_);
}
if (next < beg_ || (end_ != -1 && next >= end_))
- throw bad_seek();
+ boost::throw_exception(bad_seek());
pos_ = iostreams::seek(this->component(), next - pos_, BOOST_IOS::cur);
return offset_to_position(pos_ - beg_);
}
@@ -314,7 +315,7 @@
if ( off < 0 || len < -1 ||
(len != -1 && off + len > seq.second - seq.first) )
{
- throw BOOST_IOSTREAMS_FAILURE("bad offset");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
}
beg_ = seq.first + off;
end_ = len != -1 ?
@@ -357,7 +358,7 @@
pos_(off), end_(len != -1 ? off + len : -1), open_(false)
{
if (len < -1 || off < 0)
- throw BOOST_IOSTREAMS_FAILURE("bad offset");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
}
} // End namespace detail.
Modified: trunk/boost/iostreams/detail/streambuf/direct_streambuf.hpp
==============================================================================
--- trunk/boost/iostreams/detail/streambuf/direct_streambuf.hpp (original)
+++ trunk/boost/iostreams/detail/streambuf/direct_streambuf.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -29,6 +29,7 @@
#include <boost/iostreams/operations.hpp>
#include <boost/iostreams/positioning.hpp>
#include <boost/iostreams/traits.hpp>
+#include <boost/throw_exception.hpp>
// Must come last.
#include <boost/iostreams/detail/config/disable_warnings.hpp> // MSVC.
@@ -138,7 +139,7 @@
direct_streambuf<T, Tr>::underflow()
{
if (!ibeg_)
- throw cant_read();
+ boost::throw_exception(cant_read());
if (!gptr())
init_get_area();
return gptr() != iend_ ?
@@ -152,14 +153,14 @@
{
using namespace std;
if (!ibeg_)
- throw cant_read();
+ boost::throw_exception(cant_read());
if (gptr() != 0 && gptr() != ibeg_) {
gbump(-1);
if (!traits_type::eq_int_type(c, traits_type::eof()))
*gptr() = traits_type::to_char_type(c);
return traits_type::not_eof(c);
}
- throw bad_putback();
+ boost::throw_exception(bad_putback());
}
template<typename T, typename Tr>
@@ -167,11 +168,14 @@
direct_streambuf<T, Tr>::overflow(int_type c)
{
using namespace std;
- if (!obeg_) throw BOOST_IOSTREAMS_FAILURE("no write access");
+ if (!obeg_)
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("no write access"));
if (!pptr()) init_put_area();
if (!traits_type::eq_int_type(c, traits_type::eof())) {
if (pptr() == oend_)
- throw BOOST_IOSTREAMS_FAILURE("write area exhausted");
+ boost::throw_exception(
+ BOOST_IOSTREAMS_FAILURE("write area exhausted")
+ );
*pptr() = traits_type::to_char_type(c);
pbump(1);
return c;
@@ -215,7 +219,7 @@
using namespace std;
BOOST_IOS::openmode both = BOOST_IOS::in | BOOST_IOS::out;
if (two_head() && (which & both) == both)
- throw bad_seek();
+ boost::throw_exception(bad_seek());
stream_offset result = -1;
bool one = one_head();
if (one && (pptr() != 0 || gptr()== 0))
@@ -230,7 +234,7 @@
default: assert(0);
}
if (next < 0 || next > (iend_ - ibeg_))
- throw bad_seek();
+ boost::throw_exception(bad_seek());
setg(ibeg_, ibeg_ + next, iend_);
result = next;
}
@@ -244,7 +248,7 @@
default: assert(0);
}
if (next < 0 || next > (oend_ - obeg_))
- throw bad_seek();
+ boost::throw_exception(bad_seek());
pbump(static_cast<int>(next - (pptr() - obeg_)));
result = next;
}
Modified: trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp
==============================================================================
--- trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp (original)
+++ trunk/boost/iostreams/detail/streambuf/indirect_streambuf.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -35,6 +35,7 @@
#include <boost/iostreams/traits.hpp>
#include <boost/iostreams/operations.hpp>
#include <boost/mpl/if.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
// Must come last.
@@ -274,7 +275,7 @@
*gptr() = traits_type::to_char_type(c);
return traits_type::not_eof(c);
} else {
- throw bad_putback();
+ boost::throw_exception(bad_putback());
}
}
Modified: trunk/boost/iostreams/detail/system_failure.hpp
==============================================================================
--- trunk/boost/iostreams/detail/system_failure.hpp (original)
+++ trunk/boost/iostreams/detail/system_failure.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -18,6 +18,7 @@
#include <cstring>
#include <string>
#include <boost/config.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/iostreams/detail/config/windows_posix.hpp>
#include <boost/iostreams/detail/ios.hpp> // failure.
@@ -73,10 +74,10 @@
{ return system_failure(msg.c_str()); }
inline void throw_system_failure(const char* msg)
-{ throw system_failure(msg); }
+{ boost::throw_exception(system_failure(msg)); }
inline void throw_system_failure(const std::string& msg)
-{ throw system_failure(msg); }
+{ boost::throw_exception(system_failure(msg)); }
} } } // End namespaces detail, iostreams, boost.
Modified: trunk/boost/iostreams/device/mapped_file.hpp
==============================================================================
--- trunk/boost/iostreams/device/mapped_file.hpp (original)
+++ trunk/boost/iostreams/device/mapped_file.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -25,6 +25,7 @@
#include <boost/iostreams/positioning.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/static_assert.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_same.hpp>
// Must come last.
@@ -393,10 +394,10 @@
param_type params(p);
if (params.flags) {
if (params.flags != mapped_file::readonly)
- throw BOOST_IOSTREAMS_FAILURE("invalid flags");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid flags"));
} else {
if (params.mode & BOOST_IOS::out)
- throw BOOST_IOSTREAMS_FAILURE("invalid mode");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid mode"));
params.mode |= BOOST_IOS::in;
}
open_impl(params);
@@ -479,10 +480,10 @@
param_type params(p);
if (params.flags) {
if (params.flags & mapped_file::readonly)
- throw BOOST_IOSTREAMS_FAILURE("invalid flags");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid flags"));
} else {
if (params.mode & BOOST_IOS::in)
- throw BOOST_IOSTREAMS_FAILURE("invalid mode");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid mode"));
params.mode |= BOOST_IOS::out;
}
mapped_file::open(params);
Modified: trunk/boost/iostreams/filter/gzip.hpp
==============================================================================
--- trunk/boost/iostreams/filter/gzip.hpp (original)
+++ trunk/boost/iostreams/filter/gzip.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -36,7 +36,8 @@
#include <boost/iostreams/device/back_inserter.hpp>
#include <boost/iostreams/filter/zlib.hpp>
#include <boost/iostreams/pipeline.hpp>
-#include <boost/iostreams/putback.hpp>
+#include <boost/iostreams/putback.hpp>
+#include <boost/throw_exception.hpp>
// Must come last.
#if defined(BOOST_MSVC)
@@ -417,7 +418,7 @@
if (state_ == s_header) {
int c = boost::iostreams::get(peek);
if (traits_type::is_eof(c)) {
- throw gzip_error(gzip::bad_header);
+ boost::throw_exception(gzip_error(gzip::bad_header));
} else if (traits_type::would_block(c)) {
break;
}
@@ -437,19 +438,19 @@
state_ = s_footer;
}
} catch (const zlib_error& e) {
- throw gzip_error(e);
+ boost::throw_exception(gzip_error(e));
}
} else { // state_ == s_footer
int c = boost::iostreams::get(peek);
if (traits_type::is_eof(c)) {
- throw gzip_error(gzip::bad_footer);
+ boost::throw_exception(gzip_error(gzip::bad_footer));
} else if (traits_type::would_block(c)) {
break;
}
footer_.process(c);
if (footer_.done()) {
if (footer_.crc() != this->crc())
- throw gzip_error(gzip::bad_crc);
+ boost::throw_exception(gzip_error(gzip::bad_crc));
int c = boost::iostreams::get(peek);
if (traits_type::is_eof(c)) {
state_ = s_done;
@@ -482,7 +483,7 @@
state_ = s_start;
header_.reset();
footer_.reset();
- throw gzip_error(e);
+ boost::throw_exception(gzip_error(e));
}
state_ = s_start;
}
Modified: trunk/boost/iostreams/filter/newline.hpp
==============================================================================
--- trunk/boost/iostreams/filter/newline.hpp (original)
+++ trunk/boost/iostreams/filter/newline.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -27,6 +27,7 @@
#include <boost/iostreams/pipeline.hpp>
#include <boost/iostreams/putback.hpp>
#include <boost/mpl/bool.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
// Must come last.
@@ -124,7 +125,7 @@
target != newline::dos &&
target != newline::mac )
{
- throw std::logic_error("bad flags");
+ boost::throw_exception(std::logic_error("bad flags"));
}
}
@@ -420,7 +421,7 @@
}
}
private:
- void fail() { throw newline_error(source()); }
+ void fail() { boost::throw_exception(newline_error(source())); }
int& source() { return flags_; }
int source() const { return flags_; }
Modified: trunk/boost/iostreams/skip.hpp
==============================================================================
--- trunk/boost/iostreams/skip.hpp (original)
+++ trunk/boost/iostreams/skip.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -22,6 +22,7 @@
#include <boost/mpl/and.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/or.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
namespace boost { namespace iostreams {
@@ -40,7 +41,7 @@
for (stream_offset z = 0; z < off; ) {
typename traits_type::int_type c;
if (traits_type::is_eof(c = iostreams::get(dev)))
- throw BOOST_IOSTREAMS_FAILURE("bad skip offset");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad skip offset"));
if (!traits_type::would_block(c))
++z;
}
@@ -60,7 +61,7 @@
for (stream_offset z = 0; z < off; ) {
std::streamsize amt;
if ((amt = iostreams::read(flt, dev, &c, 1)) == -1)
- throw BOOST_IOSTREAMS_FAILURE("bad skip offset");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad skip offset"));
if (amt == 1)
++z;
}
Modified: trunk/boost/iostreams/stream_buffer.hpp
==============================================================================
--- trunk/boost/iostreams/stream_buffer.hpp (original)
+++ trunk/boost/iostreams/stream_buffer.hpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -22,6 +22,7 @@
#include <boost/iostreams/detail/streambuf/indirect_streambuf.hpp>
#include <boost/iostreams/traits.hpp>
#include <boost/static_assert.hpp>
+#include <boost/throw_exception.hpp>
#include <boost/type_traits/is_convertible.hpp>
// Must come last.
@@ -99,7 +100,9 @@
void open_impl(const T& t BOOST_IOSTREAMS_PUSH_PARAMS())
{ // Used for forwarding.
if (this->is_open())
- throw BOOST_IOSTREAMS_FAILURE("already open");
+ boost::throw_exception(
+ BOOST_IOSTREAMS_FAILURE("already open")
+ );
base_type::open(t BOOST_IOSTREAMS_PUSH_ARGS());
}
};
Modified: trunk/libs/iostreams/src/bzip2.cpp
==============================================================================
--- trunk/libs/iostreams/src/bzip2.cpp (original)
+++ trunk/libs/iostreams/src/bzip2.cpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -14,6 +14,7 @@
// than using it (possibly importing code).
#define BOOST_IOSTREAMS_SOURCE
+#include <boost/throw_exception.hpp>
#include <boost/iostreams/detail/config/dyn_link.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include "bzlib.h" // Julian Seward's "bzip.h" header.
@@ -65,9 +66,9 @@
case BZ_STREAM_END:
return;
case BZ_MEM_ERROR:
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
default:
- throw bzip2_error(error);
+ boost::throw_exception(bzip2_error(error));
}
}
Modified: trunk/libs/iostreams/src/file_descriptor.cpp
==============================================================================
--- trunk/libs/iostreams/src/file_descriptor.cpp (original)
+++ trunk/libs/iostreams/src/file_descriptor.cpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -22,6 +22,7 @@
#include <boost/iostreams/detail/ios.hpp> // openmodes, failure.
#include <boost/iostreams/device/file_descriptor.hpp>
#include <boost/integer_traits.hpp>
+#include <boost/throw_exception.hpp>
// OS-specific headers for low-level i/o.
@@ -108,7 +109,7 @@
(BOOST_IOS::in | BOOST_IOS::out) )
{
if (mode & BOOST_IOS::app)
- throw BOOST_IOSTREAMS_FAILURE("bad open mode");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
dwDesiredAccess = GENERIC_READ | GENERIC_WRITE;
dwCreationDisposition =
(mode & BOOST_IOS::trunc) ?
@@ -116,7 +117,7 @@
OPEN_EXISTING;
} else if (mode & BOOST_IOS::in) {
if (mode & (BOOST_IOS::app |BOOST_IOS::trunc))
- throw BOOST_IOSTREAMS_FAILURE("bad open mode");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
dwDesiredAccess = GENERIC_READ;
dwCreationDisposition = OPEN_EXISTING;
} else if (mode & BOOST_IOS::out) {
@@ -125,7 +126,7 @@
if (mode & BOOST_IOS::app)
flags_ |= append;
} else {
- throw BOOST_IOSTREAMS_FAILURE("bad open mode");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open mode"));
}
HANDLE handle = p.is_wide() ?
@@ -186,7 +187,7 @@
int fd = BOOST_IOSTREAMS_FD_OPEN(p.c_str(), oflag, pmode);
if (fd == -1) {
- throw system_failure("failed opening file");
+ boost::throw_exception(system_failure("failed opening file"));
} else {
handle_ = fd;
flags_ = close_on_exit;
@@ -271,7 +272,7 @@
if ( dwResultLow == INVALID_SET_FILE_POINTER &&
::GetLastError() != NO_ERROR )
{
- throw system_failure("failed seeking");
+ boost::throw_exception(system_failure("failed seeking"));
} else {
return offset_to_position(
(stream_offset(lDistanceToMoveHigh) << 32) + dwResultLow
@@ -281,7 +282,7 @@
if ( off > integer_traits<BOOST_IOSTREAMS_FD_OFFSET>::const_max ||
off < integer_traits<BOOST_IOSTREAMS_FD_OFFSET>::const_min )
{
- throw BOOST_IOSTREAMS_FAILURE("bad offset");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
}
stream_offset result =
BOOST_IOSTREAMS_FD_SEEK(
@@ -294,7 +295,7 @@
SEEK_END )
);
if (result == -1)
- throw system_failure("failed seeking");
+ boost::throw_exception(system_failure("failed seeking"));
return offset_to_position(result);
#endif // #ifdef BOOST_IOSTREAMS_WINDOWS
}
@@ -431,7 +432,7 @@
const detail::path& path, BOOST_IOS::openmode mode)
{
if (mode & (BOOST_IOS::out | BOOST_IOS::app | BOOST_IOS::trunc))
- throw BOOST_IOSTREAMS_FAILURE("invalid mode");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid mode"));
file_descriptor::open(path, mode, BOOST_IOS::in);
}
@@ -482,7 +483,7 @@
const detail::path& path, BOOST_IOS::openmode mode)
{
if (mode & BOOST_IOS::in)
- throw BOOST_IOSTREAMS_FAILURE("invalid mode");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid mode"));
file_descriptor::open(path, mode, BOOST_IOS::out);
}
Modified: trunk/libs/iostreams/src/gzip.cpp
==============================================================================
--- trunk/libs/iostreams/src/gzip.cpp (original)
+++ trunk/libs/iostreams/src/gzip.cpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -15,7 +15,8 @@
#define BOOST_IOSTREAMS_SOURCE
#include <boost/iostreams/detail/config/dyn_link.hpp>
-#include <boost/iostreams/filter/gzip.hpp>
+#include <boost/iostreams/filter/gzip.hpp>
+#include <boost/throw_exception.hpp>
namespace boost { namespace iostreams {
@@ -29,17 +30,17 @@
switch (state_) {
case s_id1:
if (value != gzip::magic::id1)
- throw gzip_error(gzip::bad_header);
+ boost::throw_exception(gzip_error(gzip::bad_header));
state_ = s_id2;
break;
case s_id2:
if (value != gzip::magic::id2)
- throw gzip_error(gzip::bad_header);
+ boost::throw_exception(gzip_error(gzip::bad_header));
state_ = s_cm;
break;
case s_cm:
if (value != gzip::method::deflate)
- throw gzip_error(gzip::bad_method);
+ boost::throw_exception(gzip_error(gzip::bad_method));
state_ = s_flg;
break;
case s_flg:
Modified: trunk/libs/iostreams/src/mapped_file.cpp
==============================================================================
--- trunk/libs/iostreams/src/mapped_file.cpp (original)
+++ trunk/libs/iostreams/src/mapped_file.cpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -14,6 +14,7 @@
#include <boost/iostreams/detail/file_handle.hpp>
#include <boost/iostreams/detail/system_failure.hpp>
#include <boost/iostreams/device/mapped_file.hpp>
+#include <boost/throw_exception.hpp>
#ifdef BOOST_IOSTREAMS_WINDOWS
# define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
@@ -82,7 +83,7 @@
void mapped_file_impl::open(param_type p)
{
if (is_open())
- throw BOOST_IOSTREAMS_FAILURE("file already open");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("file already open"));
p.normalize();
open_file(p);
map_file(p); // May modify p.hint
@@ -110,13 +111,19 @@
void mapped_file_impl::resize(stream_offset new_size)
{
if (!is_open())
- throw BOOST_IOSTREAMS_FAILURE("file is closed");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("file is closed"));
if (flags() & mapped_file::priv)
- throw BOOST_IOSTREAMS_FAILURE("can't resize private mapped file");
+ boost::throw_exception(
+ BOOST_IOSTREAMS_FAILURE("can't resize private mapped file")
+ );
if (!(flags() & mapped_file::readwrite))
- throw BOOST_IOSTREAMS_FAILURE("can't resize readonly mapped file");
+ boost::throw_exception(
+ BOOST_IOSTREAMS_FAILURE("can't resize readonly mapped file")
+ );
if (params_.offset >= new_size)
- throw BOOST_IOSTREAMS_FAILURE("can't resize below mapped offset");
+ boost::throw_exception(
+ BOOST_IOSTREAMS_FAILURE("can't resize below mapped offset")
+ );
if (!unmap_file())
cleanup_and_throw("failed unmapping file");
#ifdef BOOST_IOSTREAMS_WINDOWS
@@ -335,7 +342,7 @@
p.hint = 0;
try_map_file(p);
} else {
- throw e;
+ boost::throw_exception(e);
}
}
}
@@ -393,9 +400,9 @@
void mapped_file_params_base::normalize()
{
if (mode && flags)
- throw BOOST_IOSTREAMS_FAILURE(
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE(
"at most one of 'mode' and 'flags' may be specified"
- );
+ ));
if (flags) {
switch (flags) {
case mapped_file::readonly:
@@ -403,7 +410,7 @@
case mapped_file::priv:
break;
default:
- throw BOOST_IOSTREAMS_FAILURE("invalid flags");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid flags"));
}
} else {
flags = (mode & BOOST_IOS::out) ?
@@ -412,9 +419,11 @@
mode = BOOST_IOS::openmode();
}
if (offset < 0)
- throw BOOST_IOSTREAMS_FAILURE("invalid offset");
+ boost::throw_exception(BOOST_IOSTREAMS_FAILURE("invalid offset"));
if (new_file_size < 0)
- throw BOOST_IOSTREAMS_FAILURE("invalid new file size");
+ boost::throw_exception(
+ BOOST_IOSTREAMS_FAILURE("invalid new file size")
+ );
}
} // End namespace detail.
Modified: trunk/libs/iostreams/src/zlib.cpp
==============================================================================
--- trunk/libs/iostreams/src/zlib.cpp (original)
+++ trunk/libs/iostreams/src/zlib.cpp 2009-11-12 14:18:21 EST (Thu, 12 Nov 2009)
@@ -14,6 +14,7 @@
// than using it (possibly importing code).
#define BOOST_IOSTREAMS_SOURCE
+#include <boost/throw_exception.hpp>
#include <boost/iostreams/detail/config/dyn_link.hpp>
#include <boost/iostreams/filter/zlib.hpp>
#include "zlib.h" // Jean-loup Gailly's and Mark Adler's "zlib.h" header.
@@ -78,9 +79,9 @@
//case Z_BUF_ERROR:
return;
case Z_MEM_ERROR:
- throw std::bad_alloc();
+ boost::throw_exception(std::bad_alloc());
default:
- throw zlib_error(error);
+ boost::throw_exception(zlib_error(error));
;
}
}
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