Boost logo

Boost-Commit :

From: chris_at_[hidden]
Date: 2007-09-11 07:18:00


Author: chris_kohlhoff
Date: 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
New Revision: 39189
URL: http://svn.boost.org/trac/boost/changeset/39189

Log:
Use enum-based error code constants.

Text files modified:
   trunk/boost/asio/detail/epoll_reactor.hpp | 21
   trunk/boost/asio/detail/kqueue_reactor.hpp | 31 +
   trunk/boost/asio/detail/posix_event.hpp | 3
   trunk/boost/asio/detail/posix_mutex.hpp | 7
   trunk/boost/asio/detail/posix_thread.hpp | 3
   trunk/boost/asio/detail/posix_tss_ptr.hpp | 3
   trunk/boost/asio/detail/reactive_socket_service.hpp | 8
   trunk/boost/asio/detail/socket_ops.hpp | 9
   trunk/boost/asio/detail/win_event.hpp | 4
   trunk/boost/asio/detail/win_iocp_io_service.hpp | 14
   trunk/boost/asio/detail/win_iocp_socket_service.hpp | 52 ++-
   trunk/boost/asio/detail/win_mutex.hpp | 5
   trunk/boost/asio/detail/win_thread.hpp | 4
   trunk/boost/asio/detail/win_tss_ptr.hpp | 4
   trunk/boost/asio/detail/winsock_init.hpp | 3
   trunk/boost/asio/error.hpp | 598 +++++++++++++++------------------------
   trunk/boost/asio/impl/read_until.ipp | 18
   trunk/boost/asio/ssl/detail/openssl_operation.hpp | 4
   trunk/libs/asio/test/Jamfile | 5
   trunk/libs/asio/test/error.cpp | 4
   trunk/libs/asio/test/is_read_buffered.cpp | 16
   trunk/libs/asio/test/is_write_buffered.cpp | 16
   22 files changed, 383 insertions(+), 449 deletions(-)

Modified: trunk/boost/asio/detail/epoll_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/epoll_reactor.hpp (original)
+++ trunk/boost/asio/detail/epoll_reactor.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -158,7 +158,8 @@
       int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
       if (result != 0)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         read_op_queue_.dispatch_all_operations(descriptor, ec);
       }
     }
@@ -191,7 +192,8 @@
       int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
       if (result != 0)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         write_op_queue_.dispatch_all_operations(descriptor, ec);
       }
     }
@@ -220,7 +222,8 @@
       int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
       if (result != 0)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         except_op_queue_.dispatch_all_operations(descriptor, ec);
       }
     }
@@ -251,7 +254,8 @@
       int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
       if (result != 0)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         write_op_queue_.dispatch_all_operations(descriptor, ec);
         except_op_queue_.dispatch_all_operations(descriptor, ec);
       }
@@ -428,7 +432,8 @@
         int result = epoll_ctl(epoll_fd_, EPOLL_CTL_MOD, descriptor, &ev);
         if (result != 0)
         {
- ec = boost::system::error_code(errno, boost::system::native_ecat);
+ ec = boost::system::error_code(errno,
+ boost::asio::error::system_category);
           read_op_queue_.dispatch_all_operations(descriptor, ec);
           write_op_queue_.dispatch_all_operations(descriptor, ec);
           except_op_queue_.dispatch_all_operations(descriptor, ec);
@@ -486,8 +491,10 @@
     int fd = epoll_create(epoll_size);
     if (fd == -1)
     {
- boost::throw_exception(boost::system::system_error(
- boost::system::error_code(errno, boost::system::native_ecat),
+ boost::throw_exception(
+ boost::system::system_error(
+ boost::system::error_code(errno,
+ boost::asio::error::system_category),
             "epoll"));
     }
     return fd;

Modified: trunk/boost/asio/detail/kqueue_reactor.hpp
==============================================================================
--- trunk/boost/asio/detail/kqueue_reactor.hpp (original)
+++ trunk/boost/asio/detail/kqueue_reactor.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -151,7 +151,8 @@
       EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, 0, 0, 0);
       if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         read_op_queue_.dispatch_all_operations(descriptor, ec);
       }
     }
@@ -177,7 +178,8 @@
       EV_SET(&event, descriptor, EVFILT_WRITE, EV_ADD, 0, 0, 0);
       if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         write_op_queue_.dispatch_all_operations(descriptor, ec);
       }
     }
@@ -202,7 +204,8 @@
         EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, EV_OOBAND, 0, 0);
       if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         except_op_queue_.dispatch_all_operations(descriptor, ec);
       }
     }
@@ -225,7 +228,8 @@
       EV_SET(&event, descriptor, EVFILT_WRITE, EV_ADD, 0, 0, 0);
       if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         write_op_queue_.dispatch_all_operations(descriptor, ec);
       }
     }
@@ -239,7 +243,8 @@
         EV_SET(&event, descriptor, EVFILT_READ, EV_ADD, EV_OOBAND, 0, 0);
       if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
       {
- boost::system::error_code ec(errno, boost::system::native_ecat);
+ boost::system::error_code ec(errno,
+ boost::asio::error::system_category);
         except_op_queue_.dispatch_all_operations(descriptor, ec);
         write_op_queue_.dispatch_all_operations(descriptor, ec);
       }
@@ -393,7 +398,7 @@
         if (events[i].flags & EV_ERROR)
         {
           boost::system::error_code error(
- events[i].data, boost::system::native_ecat);
+ events[i].data, boost::asio::error::system_category);
           except_op_queue_.dispatch_all_operations(descriptor, error);
           read_op_queue_.dispatch_all_operations(descriptor, error);
         }
@@ -423,7 +428,8 @@
           EV_SET(&event, descriptor, EVFILT_READ, EV_DELETE, 0, 0, 0);
         if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
         {
- boost::system::error_code error(errno, boost::system::native_ecat);
+ boost::system::error_code error(errno,
+ boost::asio::error::system_category);
           except_op_queue_.dispatch_all_operations(descriptor, error);
           read_op_queue_.dispatch_all_operations(descriptor, error);
         }
@@ -435,7 +441,7 @@
         if (events[i].flags & EV_ERROR)
         {
           boost::system::error_code error(
- events[i].data, boost::system::native_ecat);
+ events[i].data, boost::asio::error::system_category);
           write_op_queue_.dispatch_all_operations(descriptor, error);
         }
         else
@@ -452,7 +458,8 @@
           EV_SET(&event, descriptor, EVFILT_WRITE, EV_DELETE, 0, 0, 0);
         if (::kevent(kqueue_fd_, &event, 1, 0, 0, 0) == -1)
         {
- boost::system::error_code error(errno, boost::system::native_ecat);
+ boost::system::error_code error(errno,
+ boost::asio::error::system_category);
           write_op_queue_.dispatch_all_operations(descriptor, error);
         }
       }
@@ -506,8 +513,10 @@
     int fd = kqueue();
     if (fd == -1)
     {
- boost::throw_exception(boost::system::system_error(
- boost::system::error_code(errno, boost::system::native_ecat),
+ boost::throw_exception(
+ boost::system::system_error(
+ boost::system::error_code(errno,
+ boost::asio::error::system_category),
             "kqueue"));
     }
     return fd;

Modified: trunk/boost/asio/detail/posix_event.hpp
==============================================================================
--- trunk/boost/asio/detail/posix_event.hpp (original)
+++ trunk/boost/asio/detail/posix_event.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -30,6 +30,7 @@
 #include <pthread.h>
 #include <boost/asio/detail/pop_options.hpp>
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 
 namespace boost {
@@ -48,7 +49,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "event");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/posix_mutex.hpp
==============================================================================
--- trunk/boost/asio/detail/posix_mutex.hpp (original)
+++ trunk/boost/asio/detail/posix_mutex.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -29,6 +29,7 @@
 #include <pthread.h>
 #include <boost/asio/detail/pop_options.hpp>
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 #include <boost/asio/detail/scoped_lock.hpp>
 
@@ -51,7 +52,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "mutex");
       boost::throw_exception(e);
     }
@@ -70,7 +71,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "mutex");
       boost::throw_exception(e);
     }
@@ -83,7 +84,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "mutex");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/posix_thread.hpp
==============================================================================
--- trunk/boost/asio/detail/posix_thread.hpp (original)
+++ trunk/boost/asio/detail/posix_thread.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -30,6 +30,7 @@
 #include <pthread.h>
 #include <boost/asio/detail/pop_options.hpp>
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 
 namespace boost {
@@ -53,7 +54,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "thread");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/posix_tss_ptr.hpp
==============================================================================
--- trunk/boost/asio/detail/posix_tss_ptr.hpp (original)
+++ trunk/boost/asio/detail/posix_tss_ptr.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -29,6 +29,7 @@
 #include <pthread.h>
 #include <boost/asio/detail/pop_options.hpp>
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 
 namespace boost {
@@ -47,7 +48,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "tss");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/reactive_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_service.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -158,7 +158,7 @@
 
     if (int err = reactor_.register_descriptor(sock.get()))
     {
- ec = boost::system::error_code(err, boost::system::native_ecat);
+ ec = boost::system::error_code(err, boost::asio::error::system_category);
       return ec;
     }
 
@@ -182,7 +182,7 @@
 
     if (int err = reactor_.register_descriptor(native_socket))
     {
- ec = boost::system::error_code(err, boost::system::native_ecat);
+ ec = boost::system::error_code(err, boost::asio::error::system_category);
       return ec;
     }
 
@@ -1125,7 +1125,7 @@
     bool operator()(const boost::system::error_code& result)
     {
       // Check whether the operation was successful.
- if (result != 0)
+ if (result)
       {
         io_service_.post(bind_handler(handler_, result, 0));
         return true;
@@ -1490,7 +1490,7 @@
       if (connect_error)
       {
         ec = boost::system::error_code(connect_error,
- boost::system::native_ecat);
+ boost::asio::error::system_category);
         io_service_.post(bind_handler(handler_, ec));
         return true;
       }

Modified: trunk/boost/asio/detail/socket_ops.hpp
==============================================================================
--- trunk/boost/asio/detail/socket_ops.hpp (original)
+++ trunk/boost/asio/detail/socket_ops.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -53,9 +53,10 @@
     boost::system::error_code& ec)
 {
 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
- ec = boost::system::error_code(WSAGetLastError(), boost::system::native_ecat);
+ ec = boost::system::error_code(WSAGetLastError(),
+ boost::asio::error::system_category);
 #else
- ec = boost::system::error_code(errno, boost::system::native_ecat);
+ ec = boost::system::error_code(errno, boost::asio::error::system_category);
 #endif
   return return_value;
 }
@@ -1519,10 +1520,10 @@
   default: // Possibly the non-portable EAI_SYSTEM.
 #if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
     return boost::system::error_code(
- WSAGetLastError(), boost::system::native_ecat);
+ WSAGetLastError(), boost::asio::error::system_category);
 #else
     return boost::system::error_code(
- errno, boost::system::native_ecat);
+ errno, boost::asio::error::system_category);
 #endif
   }
 }

Modified: trunk/boost/asio/detail/win_event.hpp
==============================================================================
--- trunk/boost/asio/detail/win_event.hpp (original)
+++ trunk/boost/asio/detail/win_event.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -24,6 +24,7 @@
 
 #if defined(BOOST_WINDOWS)
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 #include <boost/asio/detail/socket_types.hpp>
 
@@ -48,7 +49,8 @@
     {
       DWORD last_error = ::GetLastError();
       boost::system::system_error e(
- boost::system::error_code(last_error, boost::system::native_ecat),
+ boost::system::error_code(last_error,
+ boost::asio::error::system_category),
           "event");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/win_iocp_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_io_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_io_service.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -64,7 +64,8 @@
     {
       DWORD last_error = ::GetLastError();
       boost::system::system_error e(
- boost::system::error_code(last_error, boost::system::native_ecat),
+ boost::system::error_code(last_error,
+ boost::asio::error::system_category),
           "iocp");
       boost::throw_exception(e);
     }
@@ -174,7 +175,8 @@
       {
         DWORD last_error = ::GetLastError();
         boost::system::system_error e(
- boost::system::error_code(last_error, boost::system::native_ecat),
+ boost::system::error_code(last_error,
+ boost::asio::error::system_category),
             "pqcs");
         boost::throw_exception(e);
       }
@@ -229,7 +231,8 @@
     {
       DWORD last_error = ::GetLastError();
       boost::system::system_error e(
- boost::system::error_code(last_error, boost::system::native_ecat),
+ boost::system::error_code(last_error,
+ boost::asio::error::system_category),
           "pqcs");
       boost::throw_exception(e);
     }
@@ -248,7 +251,8 @@
     {
       DWORD last_error = ::GetLastError();
       boost::system::system_error e(
- boost::system::error_code(last_error, boost::system::native_ecat),
+ boost::system::error_code(last_error,
+ boost::asio::error::system_category),
           "pqcs");
       boost::throw_exception(e);
     }
@@ -313,7 +317,7 @@
           {
             DWORD last_error = ::GetLastError();
             ec = boost::system::error_code(last_error,
- boost::system::native_ecat);
+ boost::asio::error::system_category);
             return 0;
           }
 

Modified: trunk/boost/asio/detail/win_iocp_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_service.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -338,7 +338,8 @@
       if (!cancel_io_ex(sock_as_handle, 0))
       {
         DWORD last_error = ::GetLastError();
- ec = boost::system::error_code(last_error, boost::system::native_ecat);
+ ec = boost::system::error_code(last_error,
+ boost::asio::error::system_category);
       }
       else
       {
@@ -359,7 +360,8 @@
       if (!::CancelIo(sock_as_handle))
       {
         DWORD last_error = ::GetLastError();
- ec = boost::system::error_code(last_error, boost::system::native_ecat);
+ ec = boost::system::error_code(last_error,
+ boost::asio::error::system_category);
       }
       else
       {
@@ -665,7 +667,8 @@
         last_error = WSAECONNRESET;
       else if (last_error == ERROR_PORT_UNREACHABLE)
         last_error = WSAECONNREFUSED;
- ec = boost::system::error_code(last_error, boost::system::native_ecat);
+ ec = boost::system::error_code(last_error,
+ boost::asio::error::system_category);
       return 0;
     }
 
@@ -716,7 +719,8 @@
 #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
 
       // Map non-portable errors to their portable counterparts.
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       if (ec.value() == ERROR_NETNAME_DELETED)
       {
         if (handler_op->cancel_token_.expired())
@@ -818,7 +822,8 @@
     {
       boost::asio::io_service::work work(this->io_service());
       ptr.reset();
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
     }
     else
@@ -862,7 +867,8 @@
       DWORD last_error = ::WSAGetLastError();
       if (last_error == ERROR_PORT_UNREACHABLE)
         last_error = WSAECONNREFUSED;
- ec = boost::system::error_code(last_error, boost::system::native_ecat);
+ ec = boost::system::error_code(last_error,
+ boost::asio::error::system_category);
       return 0;
     }
 
@@ -911,7 +917,8 @@
 #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
 
       // Map non-portable errors to their portable counterparts.
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       if (ec.value() == ERROR_PORT_UNREACHABLE)
       {
         ec = boost::asio::error::connection_refused;
@@ -994,7 +1001,8 @@
     {
       boost::asio::io_service::work work(this->io_service());
       ptr.reset();
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
     }
     else
@@ -1048,7 +1056,8 @@
         last_error = WSAECONNRESET;
       else if (last_error == ERROR_PORT_UNREACHABLE)
         last_error = WSAECONNREFUSED;
- ec = boost::system::error_code(last_error, boost::system::native_ecat);
+ ec = boost::system::error_code(last_error,
+ boost::asio::error::system_category);
       return 0;
     }
     if (bytes_transferred == 0)
@@ -1106,7 +1115,8 @@
 #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
 
       // Map non-portable errors to their portable counterparts.
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       if (ec.value() == ERROR_NETNAME_DELETED)
       {
         if (handler_op->cancel_token_.expired())
@@ -1213,7 +1223,8 @@
     {
       boost::asio::io_service::work work(this->io_service());
       ptr.reset();
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
     }
     else
@@ -1259,7 +1270,8 @@
       DWORD last_error = ::WSAGetLastError();
       if (last_error == ERROR_PORT_UNREACHABLE)
         last_error = WSAECONNREFUSED;
- ec = boost::system::error_code(last_error, boost::system::native_ecat);
+ ec = boost::system::error_code(last_error,
+ boost::asio::error::system_category);
       return 0;
     }
     if (bytes_transferred == 0)
@@ -1325,7 +1337,8 @@
 #endif // defined(BOOST_ASIO_ENABLE_BUFFER_DEBUGGING)
 
       // Map non-portable errors to their portable counterparts.
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       if (ec.value() == ERROR_PORT_UNREACHABLE)
       {
         ec = boost::asio::error::connection_refused;
@@ -1419,7 +1432,8 @@
     {
       boost::asio::io_service::work work(this->io_service());
       ptr.reset();
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
     }
     else
@@ -1656,7 +1670,8 @@
       ptr.reset();
 
       // Call the handler.
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
       asio_handler_invoke_helpers::invoke(
           detail::bind_handler(handler, ec), &handler);
     }
@@ -1756,7 +1771,8 @@
       {
         boost::asio::io_service::work work(this->io_service());
         ptr.reset();
- boost::system::error_code ec(last_error, boost::system::native_ecat);
+ boost::system::error_code ec(last_error,
+ boost::asio::error::system_category);
         iocp_service_.post(bind_handler(handler, ec));
       }
     }
@@ -1832,8 +1848,8 @@
       // If connection failed then post the handler with the error code.
       if (connect_error)
       {
- ec = boost::system::error_code(
- connect_error, boost::system::native_ecat);
+ ec = boost::system::error_code(connect_error,
+ boost::asio::error::system_category);
         io_service_.post(bind_handler(handler_, ec));
         return true;
       }

Modified: trunk/boost/asio/detail/win_mutex.hpp
==============================================================================
--- trunk/boost/asio/detail/win_mutex.hpp (original)
+++ trunk/boost/asio/detail/win_mutex.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -24,6 +24,7 @@
 
 #if defined(BOOST_WINDOWS)
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 #include <boost/asio/detail/socket_types.hpp>
 #include <boost/asio/detail/scoped_lock.hpp>
@@ -49,7 +50,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "mutex");
       boost::throw_exception(e);
     }
@@ -68,7 +69,7 @@
     if (error != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(error, boost::system::native_ecat),
+ boost::system::error_code(error, boost::asio::error::system_category),
           "mutex");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/win_thread.hpp
==============================================================================
--- trunk/boost/asio/detail/win_thread.hpp (original)
+++ trunk/boost/asio/detail/win_thread.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -24,6 +24,7 @@
 
 #if defined(BOOST_WINDOWS)
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 #include <boost/asio/detail/socket_types.hpp>
 
@@ -55,7 +56,8 @@
     {
       DWORD last_error = ::GetLastError();
       boost::system::system_error e(
- boost::system::error_code(last_error, boost::system::native_ecat),
+ boost::system::error_code(last_error,
+ boost::asio::error::system_category),
           "thread");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/win_tss_ptr.hpp
==============================================================================
--- trunk/boost/asio/detail/win_tss_ptr.hpp (original)
+++ trunk/boost/asio/detail/win_tss_ptr.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -24,6 +24,7 @@
 
 #if defined(BOOST_WINDOWS)
 
+#include <boost/asio/error.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 #include <boost/asio/detail/socket_types.hpp>
 
@@ -48,7 +49,8 @@
     {
       DWORD last_error = ::GetLastError();
       boost::system::system_error e(
- boost::system::error_code(last_error, boost::system::native_ecat),
+ boost::system::error_code(last_error,
+ boost::asio::error::system_category),
           "tss");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/detail/winsock_init.hpp
==============================================================================
--- trunk/boost/asio/detail/winsock_init.hpp (original)
+++ trunk/boost/asio/detail/winsock_init.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -86,7 +86,8 @@
     if (this != &instance_ && ref_->result() != 0)
     {
       boost::system::system_error e(
- boost::system::error_code(ref_->result(), boost::system::native_ecat),
+ boost::system::error_code(ref_->result(),
+ boost::asio::error::system_category),
           "winsock");
       boost::throw_exception(e);
     }

Modified: trunk/boost/asio/error.hpp
==============================================================================
--- trunk/boost/asio/error.hpp (original)
+++ trunk/boost/asio/error.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -37,493 +37,372 @@
 /// INTERNAL ONLY.
 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
 #elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
-# define BOOST_ASIO_NATIVE_ERROR(e) \
- boost::system::error_code(e, \
- boost::system::native_ecat)
-# define BOOST_ASIO_SOCKET_ERROR(e) \
- boost::system::error_code(WSA ## e, \
- boost::system::native_ecat)
-# define BOOST_ASIO_NETDB_ERROR(e) \
- boost::system::error_code(WSA ## e, \
- boost::system::native_ecat)
-# define BOOST_ASIO_GETADDRINFO_ERROR(e) \
- boost::system::error_code(WSA ## e, \
- boost::system::native_ecat)
-# define BOOST_ASIO_MISC_ERROR(e) \
- boost::system::error_code(e, \
- boost::asio::detail::error_base<T>::misc_ecat())
+# define BOOST_ASIO_NATIVE_ERROR(e) e
+# define BOOST_ASIO_SOCKET_ERROR(e) WSA ## e
+# define BOOST_ASIO_NETDB_ERROR(e) WSA ## e
+# define BOOST_ASIO_GETADDRINFO_ERROR(e) WSA ## e
 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
 #else
-# define BOOST_ASIO_NATIVE_ERROR(e) \
- boost::system::error_code(e, \
- boost::system::native_ecat)
-# define BOOST_ASIO_SOCKET_ERROR(e) \
- boost::system::error_code(e, \
- boost::system::native_ecat)
-# define BOOST_ASIO_NETDB_ERROR(e) \
- boost::system::error_code(e, \
- boost::asio::detail::error_base<T>::netdb_ecat())
-# define BOOST_ASIO_GETADDRINFO_ERROR(e) \
- boost::system::error_code(e, \
- boost::asio::detail::error_base<T>::addrinfo_ecat())
-# define BOOST_ASIO_MISC_ERROR(e) \
- boost::system::error_code(e, \
- boost::asio::detail::error_base<T>::misc_ecat())
+# define BOOST_ASIO_NATIVE_ERROR(e) e
+# define BOOST_ASIO_SOCKET_ERROR(e) e
+# define BOOST_ASIO_NETDB_ERROR(e) e
+# define BOOST_ASIO_GETADDRINFO_ERROR(e) e
 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
 #endif
 
 namespace boost {
 namespace asio {
+namespace error {
 
-namespace detail {
-
-/// Hack to keep asio library header-file-only.
-template <typename T>
-class error_base
+enum basic_errors
 {
-public:
-#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
- static boost::system::error_category netdb_ecat();
- static int netdb_ed(const boost::system::error_code& ec);
- static std::string netdb_md(const boost::system::error_code& ec);
- static boost::system::wstring_t netdb_wmd(
- const boost::system::error_code& ec);
-
- static boost::system::error_category addrinfo_ecat();
- static int addrinfo_ed(const boost::system::error_code& ec);
- static std::string addrinfo_md(const boost::system::error_code& ec);
- static boost::system::wstring_t addrinfo_wmd(
- const boost::system::error_code& ec);
-#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
-
- static boost::system::error_category misc_ecat();
- static int misc_ed(const boost::system::error_code& ec);
- static std::string misc_md(const boost::system::error_code& ec);
- static boost::system::wstring_t misc_wmd(const boost::system::error_code& ec);
-
- static boost::system::error_category ssl_ecat();
- static int ssl_ed(const boost::system::error_code& ec);
- static std::string ssl_md(const boost::system::error_code& ec);
- static boost::system::wstring_t ssl_wmd(const boost::system::error_code& ec);
-
   /// Permission denied.
- static const boost::system::error_code access_denied;
+ access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES),
 
   /// Address family not supported by protocol.
- static const boost::system::error_code address_family_not_supported;
+ address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(EAFNOSUPPORT),
 
   /// Address already in use.
- static const boost::system::error_code address_in_use;
+ address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE),
 
   /// Transport endpoint is already connected.
- static const boost::system::error_code already_connected;
-
- /// Already open.
- static const boost::system::error_code already_open;
+ already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN),
 
   /// Operation already in progress.
- static const boost::system::error_code already_started;
+ already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY),
 
   /// A connection has been aborted.
- static const boost::system::error_code connection_aborted;
+ connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED),
 
   /// Connection refused.
- static const boost::system::error_code connection_refused;
+ connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED),
 
   /// Connection reset by peer.
- static const boost::system::error_code connection_reset;
+ connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET),
 
   /// Bad file descriptor.
- static const boost::system::error_code bad_descriptor;
-
- /// End of file or stream.
- static const boost::system::error_code eof;
+ bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF),
 
   /// Bad address.
- static const boost::system::error_code fault;
-
- /// Host not found (authoritative).
- static const boost::system::error_code host_not_found;
-
- /// Host not found (non-authoritative).
- static const boost::system::error_code host_not_found_try_again;
+ fault = BOOST_ASIO_SOCKET_ERROR(EFAULT),
 
   /// No route to host.
- static const boost::system::error_code host_unreachable;
+ host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH),
 
   /// Operation now in progress.
- static const boost::system::error_code in_progress;
+ in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS),
 
   /// Interrupted system call.
- static const boost::system::error_code interrupted;
+ interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR),
 
   /// Invalid argument.
- static const boost::system::error_code invalid_argument;
+ invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL),
 
   /// Message too long.
- static const boost::system::error_code message_size;
+ message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE),
 
   /// Network is down.
- static const boost::system::error_code network_down;
+ network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN),
 
   /// Network dropped connection on reset.
- static const boost::system::error_code network_reset;
+ network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET),
 
   /// Network is unreachable.
- static const boost::system::error_code network_unreachable;
+ network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH),
 
   /// Too many open files.
- static const boost::system::error_code no_descriptors;
+ no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE),
 
   /// No buffer space available.
- static const boost::system::error_code no_buffer_space;
-
- /// The query is valid but does not have associated address data.
- static const boost::system::error_code no_data;
+ no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS),
 
   /// Cannot allocate memory.
- static const boost::system::error_code no_memory;
+ no_memory = BOOST_ASIO_WIN_OR_POSIX(
+ BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
+ BOOST_ASIO_NATIVE_ERROR(ENOMEM)),
 
   /// Operation not permitted.
- static const boost::system::error_code no_permission;
+ no_permission = BOOST_ASIO_WIN_OR_POSIX(
+ BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
+ BOOST_ASIO_NATIVE_ERROR(EPERM)),
 
   /// Protocol not available.
- static const boost::system::error_code no_protocol_option;
-
- /// A non-recoverable error occurred.
- static const boost::system::error_code no_recovery;
+ no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT),
 
   /// Transport endpoint is not connected.
- static const boost::system::error_code not_connected;
-
- /// Element not found.
- static const boost::system::error_code not_found;
+ not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN),
 
   /// Socket operation on non-socket.
- static const boost::system::error_code not_socket;
+ not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK),
 
   /// Operation cancelled.
- static const boost::system::error_code operation_aborted;
+ operation_aborted = BOOST_ASIO_WIN_OR_POSIX(
+ BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
+ BOOST_ASIO_NATIVE_ERROR(ECANCELED)),
 
   /// Operation not supported.
- static const boost::system::error_code operation_not_supported;
-
- /// The service is not supported for the given socket type.
- static const boost::system::error_code service_not_found;
-
- /// The socket type is not supported.
- static const boost::system::error_code socket_type_not_supported;
+ operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP),
 
   /// Cannot send after transport endpoint shutdown.
- static const boost::system::error_code shut_down;
+ shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN),
 
   /// Connection timed out.
- static const boost::system::error_code timed_out;
+ timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT),
 
   /// Resource temporarily unavailable.
- static const boost::system::error_code try_again;
+ try_again = BOOST_ASIO_WIN_OR_POSIX(
+ BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY),
+ BOOST_ASIO_NATIVE_ERROR(EAGAIN)),
 
   /// The socket is marked non-blocking and the requested operation would block.
- static const boost::system::error_code would_block;
-
-private:
- error_base();
+ would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK)
 };
 
-#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
-
-template <typename T>
-boost::system::error_category error_base<T>::netdb_ecat()
+enum netdb_errors
 {
- static boost::system::error_category ecat =
- boost::system::error_code::new_category(&error_base<T>::netdb_ed,
- &error_base<T>::netdb_md, &error_base<T>::netdb_wmd);
- return ecat;
-}
+ /// Host not found (authoritative).
+ host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND),
 
-template <typename T>
-int error_base<T>::netdb_ed(const boost::system::error_code&)
-{
- return EOTHER;
-}
+ /// Host not found (non-authoritative).
+ host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN),
 
-template <typename T>
-std::string error_base<T>::netdb_md(const boost::system::error_code& ec)
-{
- if (ec == error_base<T>::host_not_found)
- return "Host not found (authoritative)";
- if (ec == error_base<T>::host_not_found_try_again)
- return "Host not found (non-authoritative), try again later";
- if (ec == error_base<T>::no_data)
- return "The query is valid, but it does not have associated data";
- if (ec == error_base<T>::no_recovery)
- return "A non-recoverable error occurred during database lookup";
- return "EINVAL";
-}
+ /// The query is valid but does not have associated address data.
+ no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA),
 
-template <typename T>
-boost::system::wstring_t error_base<T>::netdb_wmd(
- const boost::system::error_code& ec)
-{
- if (ec == error_base<T>::host_not_found)
- return L"Host not found (authoritative)";
- if (ec == error_base<T>::host_not_found_try_again)
- return L"Host not found (non-authoritative), try again later";
- if (ec == error_base<T>::no_data)
- return L"The query is valid, but it does not have associated data";
- if (ec == error_base<T>::no_recovery)
- return L"A non-recoverable error occurred during database lookup";
- return L"EINVAL";
-}
+ /// A non-recoverable error occurred.
+ no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY)
+};
 
-template <typename T>
-boost::system::error_category error_base<T>::addrinfo_ecat()
+enum addrinfo_errors
 {
- static boost::system::error_category ecat =
- boost::system::error_code::new_category(&error_base<T>::addrinfo_ed,
- &error_base<T>::addrinfo_md, &error_base<T>::addrinfo_wmd);
- return ecat;
-}
+ /// The service is not supported for the given socket type.
+ service_not_found = BOOST_ASIO_WIN_OR_POSIX(
+ BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
+ BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
 
-template <typename T>
-int error_base<T>::addrinfo_ed(const boost::system::error_code&)
-{
- return EOTHER;
-}
+ /// The socket type is not supported.
+ socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX(
+ BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
+ BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
+};
 
-template <typename T>
-std::string error_base<T>::addrinfo_md(const boost::system::error_code& ec)
+enum misc_errors
 {
- if (ec == error_base<T>::service_not_found)
- return "Service not found";
- if (ec == error_base<T>::socket_type_not_supported)
- return "Socket type not supported";
- return "EINVAL";
-}
+ /// Already open.
+ already_open = 1,
 
-template <typename T>
-boost::system::wstring_t error_base<T>::addrinfo_wmd(
- const boost::system::error_code& ec)
-{
- if (ec == error_base<T>::service_not_found)
- return L"Service not found";
- if (ec == error_base<T>::socket_type_not_supported)
- return L"Socket type not supported";
- return L"EINVAL";
-}
+ /// End of file or stream.
+ eof,
 
-#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+ /// Element not found.
+ not_found
+};
 
-template <typename T>
-boost::system::error_category error_base<T>::misc_ecat()
-{
- static boost::system::error_category ecat =
- boost::system::error_code::new_category(&error_base<T>::misc_ed,
- &error_base<T>::misc_md, &error_base<T>::misc_wmd);
- return ecat;
-}
+namespace detail {
 
-template <typename T>
-int error_base<T>::misc_ed(const boost::system::error_code&)
+inline const boost::system::error_category& get_system_category()
 {
- return EOTHER;
+ return boost::system::system_category;
 }
 
-template <typename T>
-std::string error_base<T>::misc_md(const boost::system::error_code& ec)
+#if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+
+class netdb_category : public boost::system::error_category
 {
- if (ec == error_base<T>::already_open)
- return "Already open";
- if (ec == error_base<T>::eof)
- return "End of file";
- if (ec == error_base<T>::not_found)
- return "Element not found";
- return "EINVAL";
-}
+public:
+ const char* name() const
+ {
+ return "asio.netdb";
+ }
+
+ std::string message(int value) const
+ {
+ if (value == error::host_not_found)
+ return "Host not found (authoritative)";
+ if (value == error::host_not_found_try_again)
+ return "Host not found (non-authoritative), try again later";
+ if (value == error::no_data)
+ return "The query is valid, but it does not have associated data";
+ if (value == error::no_recovery)
+ return "A non-recoverable error occurred during database lookup";
+ return "asio.netdb error";
+ }
+};
 
-template <typename T>
-boost::system::wstring_t error_base<T>::misc_wmd(
- const boost::system::error_code& ec)
+inline const boost::system::error_category& get_netdb_category()
 {
- if (ec == error_base<T>::already_open)
- return L"Already open";
- if (ec == error_base<T>::eof)
- return L"End of file";
- if (ec == error_base<T>::not_found)
- return L"Element not found";
- return L"EINVAL";
+ static netdb_category instance;
+ return instance;
 }
 
-template <typename T>
-boost::system::error_category error_base<T>::ssl_ecat()
+class addrinfo_category : public boost::system::error_category
 {
- static boost::system::error_category ecat =
- boost::system::error_code::new_category(&error_base<T>::ssl_ed,
- &error_base<T>::ssl_md, &error_base<T>::ssl_wmd);
- return ecat;
-}
+public:
+ const char* name() const
+ {
+ return "asio.addrinfo";
+ }
+
+ std::string message(int value) const
+ {
+ if (value == error::service_not_found)
+ return "Service not found";
+ if (value == error::socket_type_not_supported)
+ return "Socket type not supported";
+ return "asio.addrinfo error";
+ }
+};
 
-template <typename T>
-int error_base<T>::ssl_ed(const boost::system::error_code&)
+inline const boost::system::error_category& get_addrinfo_category()
 {
- return EOTHER;
+ static addrinfo_category instance;
+ return instance;
 }
 
-template <typename T>
-std::string error_base<T>::ssl_md(const boost::system::error_code&)
+#else // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
+
+inline const boost::system::error_category& get_netdb_category()
 {
- return "SSL error";
+ return get_system_category();
 }
 
-template <typename T>
-boost::system::wstring_t error_base<T>::ssl_wmd(
- const boost::system::error_code&)
+inline const boost::system::error_category& get_addrinfo_category()
 {
- return L"SSL error";
+ return get_system_category();
 }
 
-template <typename T> const boost::system::error_code
-error_base<T>::access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES);
-
-template <typename T> const boost::system::error_code
-error_base<T>::address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(
- EAFNOSUPPORT);
-
-template <typename T> const boost::system::error_code
-error_base<T>::address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE);
-
-template <typename T> const boost::system::error_code
-error_base<T>::already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN);
-
-template <typename T> const boost::system::error_code
-error_base<T>::already_open = BOOST_ASIO_MISC_ERROR(1);
-
-template <typename T> const boost::system::error_code
-error_base<T>::already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY);
-
-template <typename T> const boost::system::error_code
-error_base<T>::connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED);
-
-template <typename T> const boost::system::error_code
-error_base<T>::connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED);
-
-template <typename T> const boost::system::error_code
-error_base<T>::connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET);
-
-template <typename T> const boost::system::error_code
-error_base<T>::bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF);
-
-template <typename T> const boost::system::error_code
-error_base<T>::eof = BOOST_ASIO_MISC_ERROR(2);
-
-template <typename T> const boost::system::error_code
-error_base<T>::fault = BOOST_ASIO_SOCKET_ERROR(EFAULT);
-
-template <typename T> const boost::system::error_code
-error_base<T>::host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND);
-
-template <typename T> const boost::system::error_code
-error_base<T>::host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN);
-
-template <typename T> const boost::system::error_code
-error_base<T>::host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH);
-
-template <typename T> const boost::system::error_code
-error_base<T>::in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS);
-
-template <typename T> const boost::system::error_code
-error_base<T>::interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR);
-
-template <typename T> const boost::system::error_code
-error_base<T>::invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL);
-
-template <typename T> const boost::system::error_code
-error_base<T>::message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE);
-
-template <typename T> const boost::system::error_code
-error_base<T>::network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN);
+#endif // !defined(BOOST_WINDOWS) && !defined(__CYGWIN__)
 
-template <typename T> const boost::system::error_code
-error_base<T>::network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET);
+class misc_category : public boost::system::error_category
+{
+public:
+ const char* name() const
+ {
+ return "asio.misc";
+ }
+
+ std::string message(int value) const
+ {
+ if (value == error::already_open)
+ return "Already open";
+ if (value == error::eof)
+ return "End of file";
+ if (value == error::not_found)
+ return "Element not found";
+ return "asio.misc error";
+ }
+};
 
-template <typename T> const boost::system::error_code
-error_base<T>::network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH);
+inline const boost::system::error_category& get_misc_category()
+{
+ static misc_category instance;
+ return instance;
+}
 
-template <typename T> const boost::system::error_code
-error_base<T>::no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE);
+class ssl_category : public boost::system::error_category
+{
+public:
+ const char* name() const
+ {
+ return "asio.ssl";
+ }
+
+ std::string message(int value) const
+ {
+ return "asio.ssl error";
+ }
+};
 
-template <typename T> const boost::system::error_code
-error_base<T>::no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS);
+inline const boost::system::error_category& get_ssl_category()
+{
+ static ssl_category instance;
+ return instance;
+}
 
-template <typename T> const boost::system::error_code
-error_base<T>::no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA);
+} // namespace detail
 
-template <typename T> const boost::system::error_code
-error_base<T>::no_memory = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
- BOOST_ASIO_NATIVE_ERROR(ENOMEM));
+#if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
 
-template <typename T> const boost::system::error_code
-error_base<T>::no_permission = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
- BOOST_ASIO_NATIVE_ERROR(EPERM));
+static const boost::system::error_category& system_category
+ = boost::asio::error::detail::get_system_category();
+static const boost::system::error_category& netdb_category
+ = boost::asio::error::detail::get_netdb_category();
+static const boost::system::error_category& addrinfo_category
+ = boost::asio::error::detail::get_addrinfo_category();
+static const boost::system::error_category& misc_category
+ = boost::asio::error::detail::get_misc_category();
+static const boost::system::error_category& ssl_category
+ = boost::asio::error::detail::get_ssl_category();
 
-template <typename T> const boost::system::error_code
-error_base<T>::no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT);
+#else
 
-template <typename T> const boost::system::error_code
-error_base<T>::no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY);
+namespace
+{
+ const boost::system::error_category& system_category
+ = boost::asio::error::detail::get_system_category();
+ const boost::system::error_category& netdb_category
+ = boost::asio::error::detail::get_netdb_category();
+ const boost::system::error_category& addrinfo_category
+ = boost::asio::error::detail::get_addrinfo_category();
+ const boost::system::error_category& misc_category
+ = boost::asio::error::detail::get_misc_category();
+ const boost::system::error_category& ssl_category
+ = boost::asio::error::detail::get_ssl_category();
+} // namespace
 
-template <typename T> const boost::system::error_code
-error_base<T>::not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN);
+#endif
 
-template <typename T> const boost::system::error_code
-error_base<T>::not_found = BOOST_ASIO_MISC_ERROR(3);
+} // namespace error
+} // namespace asio
 
-template <typename T> const boost::system::error_code
-error_base<T>::not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK);
+namespace system {
 
-template <typename T> const boost::system::error_code
-error_base<T>::operation_aborted = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
- BOOST_ASIO_NATIVE_ERROR(ECANCELED));
+template<> struct is_error_code_enum<boost::asio::error::basic_errors>
+{
+ static const bool value = true;
+};
 
-template <typename T> const boost::system::error_code
-error_base<T>::operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP);
+template<> struct is_error_code_enum<boost::asio::error::netdb_errors>
+{
+ static const bool value = true;
+};
 
-template <typename T> const boost::system::error_code
-error_base<T>::service_not_found = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
- BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE));
+template<> struct is_error_code_enum<boost::asio::error::addrinfo_errors>
+{
+ static const bool value = true;
+};
 
-template <typename T> const boost::system::error_code
-error_base<T>::socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
- BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE));
+template<> struct is_error_code_enum<boost::asio::error::misc_errors>
+{
+ static const bool value = true;
+};
 
-template <typename T> const boost::system::error_code
-error_base<T>::shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN);
+} // namespace system
 
-template <typename T> const boost::system::error_code
-error_base<T>::timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT);
+namespace asio {
+namespace error {
 
-template <typename T> const boost::system::error_code
-error_base<T>::try_again = BOOST_ASIO_WIN_OR_POSIX(
- BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY),
- BOOST_ASIO_NATIVE_ERROR(EAGAIN));
+inline boost::system::error_code make_error_code(basic_errors e)
+{
+ return boost::system::error_code(static_cast<int>(e), system_category);
+}
 
-template <typename T> const boost::system::error_code
-error_base<T>::would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK);
+inline boost::system::error_code make_error_code(netdb_errors e)
+{
+ return boost::system::error_code(static_cast<int>(e), netdb_category);
+}
 
-} // namespace detail
+inline boost::system::error_code make_error_code(addrinfo_errors e)
+{
+ return boost::system::error_code(static_cast<int>(e), addrinfo_category);
+}
 
-/// Contains error constants.
-class error : public boost::asio::detail::error_base<error>
+inline boost::system::error_code make_error_code(misc_errors e)
 {
-private:
- error();
-};
+ return boost::system::error_code(static_cast<int>(e), misc_category);
+}
 
+} // namespace error
 } // namespace asio
 } // namespace boost
 
@@ -531,7 +410,6 @@
 #undef BOOST_ASIO_SOCKET_ERROR
 #undef BOOST_ASIO_NETDB_ERROR
 #undef BOOST_ASIO_GETADDRINFO_ERROR
-#undef BOOST_ASIO_MISC_ERROR
 #undef BOOST_ASIO_WIN_OR_POSIX
 
 

Modified: trunk/boost/asio/impl/read_until.ipp
==============================================================================
--- trunk/boost/asio/impl/read_until.ipp (original)
+++ trunk/boost/asio/impl/read_until.ipp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -312,7 +312,8 @@
       if (streambuf_.size() == streambuf_.max_size())
       {
         std::size_t bytes = 0;
- handler_(error::not_found, bytes);
+ boost::system::error_code ec(error::not_found);
+ handler_(ec, bytes);
         return;
       }
 
@@ -389,7 +390,8 @@
   // No match. Check if buffer is full.
   if (b.size() == b.max_size())
   {
- s.io_service().post(detail::bind_handler(handler, error::not_found, 0));
+ boost::system::error_code ec(error::not_found);
+ s.io_service().post(detail::bind_handler(handler, ec, 0));
     return;
   }
 
@@ -470,7 +472,8 @@
       if (streambuf_.size() == streambuf_.max_size())
       {
         std::size_t bytes = 0;
- handler_(error::not_found, bytes);
+ boost::system::error_code ec(error::not_found);
+ handler_(ec, bytes);
         return;
       }
 
@@ -560,7 +563,8 @@
   // Check if buffer is full.
   if (b.size() == b.max_size())
   {
- s.io_service().post(detail::bind_handler(handler, error::not_found, 0));
+ boost::system::error_code ec(error::not_found);
+ s.io_service().post(detail::bind_handler(handler, ec, 0));
     return;
   }
 
@@ -642,7 +646,8 @@
       if (streambuf_.size() == streambuf_.max_size())
       {
         std::size_t bytes = 0;
- handler_(error::not_found, bytes);
+ boost::system::error_code ec(error::not_found);
+ handler_(ec, bytes);
         return;
       }
 
@@ -732,7 +737,8 @@
   // Check if buffer is full.
   if (b.size() == b.max_size())
   {
- s.io_service().post(detail::bind_handler(handler, error::not_found, 0));
+ boost::system::error_code ec(error::not_found);
+ s.io_service().post(detail::bind_handler(handler, ec, 0));
     return;
   }
 

Modified: trunk/boost/asio/ssl/detail/openssl_operation.hpp
==============================================================================
--- trunk/boost/asio/ssl/detail/openssl_operation.hpp (original)
+++ trunk/boost/asio/ssl/detail/openssl_operation.hpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -175,12 +175,12 @@
       if (error_code == SSL_ERROR_SYSCALL)
       {
         return handler_(boost::system::error_code(
- sys_error_code, boost::system::native_ecat), rc);
+ sys_error_code, boost::asio::error::system_category), rc);
       }
       else
       {
         return handler_(boost::system::error_code(
- error_code, boost::asio::error::ssl_ecat()), rc);
+ error_code, boost::asio::error::ssl_category), rc);
       }
     }
 

Modified: trunk/libs/asio/test/Jamfile
==============================================================================
--- trunk/libs/asio/test/Jamfile (original)
+++ trunk/libs/asio/test/Jamfile 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -8,6 +8,7 @@
 subproject libs/asio/test ;
 
 project boost : $(BOOST_ROOT) ;
+project boost_system : $(BOOST_SYSTEM_ROOT) ;
 
 # bring in the rules for testing
 import testing ;
@@ -25,8 +26,8 @@
 
 template asio_unit_test
   : <lib>@boost/libs/thread/build/boost_thread
- <lib>@boost/libs/system/build/boost_system
- : <include>../../..
+ <lib>@boost_system/libs/system/build/boost_system
+ : <include>../../.. <include>@boost <include>@boost_system
     <define>BOOST_ALL_NO_LIB=1
     <threading>multi
     <mingw><*><find-library>ws2_32

Modified: trunk/libs/asio/test/error.cpp
==============================================================================
--- trunk/libs/asio/test/error.cpp (original)
+++ trunk/libs/asio/test/error.cpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -24,8 +24,8 @@
   boost::system::error_code error(code);
   BOOST_CHECK(code == error);
 
- BOOST_CHECK(code == 0 || error);
- BOOST_CHECK(code == 0 || !!error);
+ BOOST_CHECK(!code || error);
+ BOOST_CHECK(!code || !!error);
 
   boost::system::error_code error2(error);
   BOOST_CHECK(error == error2);

Modified: trunk/libs/asio/test/is_read_buffered.cpp
==============================================================================
--- trunk/libs/asio/test/is_read_buffered.cpp (original)
+++ trunk/libs/asio/test/is_read_buffered.cpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -29,8 +29,6 @@
 public:
   typedef boost::asio::io_service io_service_type;
 
- typedef boost::asio::error error_type;
-
   typedef test_stream lowest_layer_type;
 
   test_stream(boost::asio::io_service& io_service)
@@ -54,16 +52,17 @@
     return 0;
   }
 
- template <typename Const_Buffers, typename Error_Handler>
- size_t write(const Const_Buffers&, Error_Handler)
+ template <typename Const_Buffers>
+ size_t write(const Const_Buffers&, boost::system::error_code& ec)
   {
+ ec = boost::system::error_code();
     return 0;
   }
 
   template <typename Const_Buffers, typename Handler>
   void async_write(const Const_Buffers&, Handler handler)
   {
- boost::asio::error error;
+ boost::system::error_code error;
     io_service_.post(boost::asio::detail::bind_handler(handler, error, 0));
   }
 
@@ -73,16 +72,17 @@
     return 0;
   }
 
- template <typename Mutable_Buffers, typename Error_Handler>
- size_t read(const Mutable_Buffers&, Error_Handler error_handler)
+ template <typename Mutable_Buffers>
+ size_t read(const Mutable_Buffers&, boost::system::error_code& ec)
   {
+ ec = boost::system::error_code();
     return 0;
   }
 
   template <typename Mutable_Buffers, typename Handler>
   void async_read(const Mutable_Buffers&, Handler handler)
   {
- boost::asio::error error;
+ boost::system::error_code error;
     io_service_.post(boost::asio::detail::bind_handler(handler, error, 0));
   }
 

Modified: trunk/libs/asio/test/is_write_buffered.cpp
==============================================================================
--- trunk/libs/asio/test/is_write_buffered.cpp (original)
+++ trunk/libs/asio/test/is_write_buffered.cpp 2007-09-11 07:17:56 EDT (Tue, 11 Sep 2007)
@@ -29,8 +29,6 @@
 public:
   typedef boost::asio::io_service io_service_type;
 
- typedef boost::asio::error error_type;
-
   typedef test_stream lowest_layer_type;
 
   test_stream(boost::asio::io_service& io_service)
@@ -54,16 +52,17 @@
     return 0;
   }
 
- template <typename Const_Buffers, typename Error_Handler>
- size_t write(const Const_Buffers&, Error_Handler)
+ template <typename Const_Buffers>
+ size_t write(const Const_Buffers&, boost::system::error_code& ec)
   {
+ ec = boost::system::error_code();
     return 0;
   }
 
   template <typename Const_Buffers, typename Handler>
   void async_write(const Const_Buffers&, Handler handler)
   {
- boost::asio::error error;
+ boost::system::error_code error;
     io_service_.post(boost::asio::detail::bind_handler(handler, error, 0));
   }
 
@@ -73,16 +72,17 @@
     return 0;
   }
 
- template <typename Mutable_Buffers, typename Error_Handler>
- size_t read(const Mutable_Buffers&, Error_Handler error_handler)
+ template <typename Mutable_Buffers>
+ size_t read(const Mutable_Buffers&, boost::system::error_code& ec)
   {
+ ec = boost::system::error_code();
     return 0;
   }
 
   template <typename Mutable_Buffers, typename Handler>
   void async_read(const Mutable_Buffers&, Handler handler)
   {
- boost::asio::error error;
+ boost::system::error_code error;
     io_service_.post(boost::asio::detail::bind_handler(handler, error, 0));
   }
 


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