Ticket #2094: boost_iostreams_no_exceptions.diff

File boost_iostreams_no_exceptions.diff, 6.9 KB (added by anonymous, 14 years ago)
  • boost/iostreams/detail/system_failure.hpp

    diff -r 510d5bd079ad boost/iostreams/detail/system_failure.hpp
    a b  
    1818#include <cstring>
    1919#include <string>
    2020#include <boost/config.hpp>
     21#include <boost/throw_exception.hpp>
    2122#include <boost/iostreams/detail/config/windows_posix.hpp>
    2223#include <boost/iostreams/detail/ios.hpp>  // failure.
    2324
     
    7374{ return system_failure(msg.c_str()); }
    7475
    7576inline void throw_system_failure(const char* msg)
    76 { throw system_failure(msg); }
     77{ boost::throw_exception(system_failure(msg)); }
    7778
    7879inline void throw_system_failure(const std::string& msg)
    79 { throw system_failure(msg); }
     80{ boost::throw_exception(system_failure(msg)); }
    8081
    8182} } } // End namespaces detail, iostreams, boost.
    8283
  • libs/iostreams/src/bzip2.cpp

    diff -r 510d5bd079ad libs/iostreams/src/bzip2.cpp
    a b  
    1414// than using it (possibly importing code).
    1515#define BOOST_IOSTREAMS_SOURCE
    1616
     17#include <boost/throw_exception.hpp>
    1718#include <boost/iostreams/detail/config/dyn_link.hpp>
    1819#include <boost/iostreams/filter/bzip2.hpp>
    1920#include "bzlib.h"  // Julian Seward's "bzip.h" header.
     
    6566    case BZ_STREAM_END:
    6667        return;
    6768    case BZ_MEM_ERROR:
    68         throw std::bad_alloc();
     69        boost::throw_exception(std::bad_alloc());
    6970    default:
    70         throw bzip2_error(error);
     71        boost::throw_exception(bzip2_error(error));
    7172    }
    7273}
    7374
  • libs/iostreams/src/file_descriptor.cpp

    diff -r 510d5bd079ad libs/iostreams/src/file_descriptor.cpp
    a b  
    2424#include <boost/iostreams/detail/ios.hpp>         // openmodes, failure.
    2525#include <boost/iostreams/device/file_descriptor.hpp>
    2626#include <boost/integer_traits.hpp>
     27#include <boost/throw_exception.hpp>
    2728
    2829    // OS-specific headers for low-level i/o.
    2930
     
    154155
    155156    int fd = BOOST_IOSTREAMS_FD_OPEN(path.c_str(), oflag, pmode);
    156157    if (fd == -1) {
    157         throw BOOST_IOSTREAMS_FAILURE("bad open");
     158        boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad open"));
    158159    } else {
    159160        pimpl_->handle_ = fd;
    160161        pimpl_->flags_ = impl::close_on_exit;
     
    172173#ifdef BOOST_IOSTREAMS_WINDOWS
    173174    DWORD result;
    174175    if (!::ReadFile(pimpl_->handle_, s, n, &result, NULL))
    175         throw detail::bad_read();
     176        boost::throw_exception(detail::bad_read());
    176177    return result == 0 ? -1 : static_cast<std::streamsize>(result);
    177178#else // #ifdef BOOST_IOSTREAMS_WINDOWS
    178179    errno = 0;
    179180    std::streamsize result = BOOST_IOSTREAMS_FD_READ(pimpl_->handle_, s, n);
    180181    if (errno != 0)
    181         throw detail::bad_read();
     182        boost::throw_exception(detail::bad_read());
    182183    return result == 0 ? -1 : result;
    183184#endif // #ifdef BOOST_IOSTREAMS_WINDOWS
    184185}
     
    192193        if ( dwResult == INVALID_SET_FILE_POINTER &&
    193194             ::GetLastError() != NO_ERROR )
    194195        {
    195             throw detail::bad_seek();
     196            boost::throw_exception(detail::bad_seek());
    196197        }
    197198    }
    198199    DWORD ignore;
    199200    if (!::WriteFile(pimpl_->handle_, s, n, &ignore, NULL))
    200         throw detail::bad_write();
     201        boost::throw_exception(detail::bad_write());
    201202    return n;
    202203#else // #ifdef BOOST_IOSTREAMS_WINDOWS
    203204    int amt = BOOST_IOSTREAMS_FD_WRITE(pimpl_->handle_, s, n);
    204205    if (amt < n)
    205         throw detail::bad_write(); // Handles blocking fd's only.
     206        boost::throw_exception(detail::bad_write()); // Handles blocking fd's only.
    206207    return n;
    207208#endif // #ifdef BOOST_IOSTREAMS_WINDOWS
    208209}
     
    226227    if ( dwResultLow == INVALID_SET_FILE_POINTER &&
    227228         ::GetLastError() != NO_ERROR )
    228229    {
    229         throw detail::bad_seek();
     230        boost::throw_exception(detail::bad_seek());
    230231    } else {
    231232       return offset_to_position(
    232233                      (stream_offset(lDistanceToMoveHigh) << 32) + dwResultLow
     
    236237    if ( off > integer_traits<BOOST_IOSTREAMS_FD_OFFSET>::const_max ||
    237238         off < integer_traits<BOOST_IOSTREAMS_FD_OFFSET>::const_min )
    238239    {
    239         throw BOOST_IOSTREAMS_FAILURE("bad offset");
     240        boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad offset"));
    240241    }
    241242    stream_offset result =
    242243        BOOST_IOSTREAMS_FD_SEEK(
     
    249250                      SEEK_END )
    250251        );
    251252    if (result == -1)
    252         throw detail::bad_seek();
     253        boost::throw_exception(detail::bad_seek());
    253254    return offset_to_position(result);
    254255#endif // #ifdef BOOST_IOSTREAMS_WINDOWS
    255256}
     
    261262#ifdef BOOST_IOSTREAMS_WINDOWS
    262263    if (i.handle_ != reinterpret_cast<handle_type>(-1)) {
    263264        if (!::CloseHandle(i.handle_))
    264             throw BOOST_IOSTREAMS_FAILURE("bad close");
     265            boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad close"));
    265266        i.handle_ = reinterpret_cast<handle_type>(-1);
    266267        i.flags_ = 0;
    267268        return;
     
    269270#else // #ifdef BOOST_IOSTREAMS_WINDOWS
    270271    if (i.handle_ != -1) {
    271272        if (BOOST_IOSTREAMS_FD_CLOSE(i.handle_) == -1)
    272             throw BOOST_IOSTREAMS_FAILURE("bad close");
     273            boost::throw_exception(BOOST_IOSTREAMS_FAILURE("bad close"));
    273274        i.handle_ = -1;
    274275        i.flags_ = 0;
    275276    }
  • libs/iostreams/src/mapped_file.cpp

    diff -r 510d5bd079ad libs/iostreams/src/mapped_file.cpp
    a b  
    2222#include <boost/iostreams/detail/ios.hpp>  // failure.
    2323#include <boost/iostreams/detail/system_failure.hpp>
    2424#include <boost/iostreams/device/mapped_file.hpp>
     25#include <boost/throw_exception.hpp>
    2526
    2627#ifdef BOOST_IOSTREAMS_WINDOWS
    2728# define WIN32_LEAN_AND_MEAN  // Exclude rarely-used stuff from Windows headers
     
    338339    using namespace std;
    339340
    340341    if (is_open())
    341         throw BOOST_IOSTREAMS_FAILURE("file already open");
     342        boost::throw_exception(BOOST_IOSTREAMS_FAILURE("file already open"));
    342343    if (!pimpl_)
    343344        pimpl_.reset(new impl_type);
    344345    else
  • libs/iostreams/src/zlib.cpp

    diff -r 510d5bd079ad libs/iostreams/src/zlib.cpp
    a b  
    1414// than using it (possibly importing code).
    1515#define BOOST_IOSTREAMS_SOURCE
    1616
     17#include <boost/throw_exception.hpp>
    1718#include <boost/iostreams/detail/config/dyn_link.hpp>
    1819#include <boost/iostreams/filter/zlib.hpp>
    1920#include "zlib.h"   // Jean-loup Gailly's and Mark Adler's "zlib.h" header.
     
    7879    //case Z_BUF_ERROR:
    7980        return;
    8081    case Z_MEM_ERROR:
    81         throw std::bad_alloc();
     82        boost::throw_exception(std::bad_alloc());
    8283    default:
    83         throw zlib_error(error);
     84        boost::throw_exception(zlib_error(error));
    8485        ;
    8586    }
    8687}