Ticket #6442: system_header_only_boost.patch

File system_header_only_boost.patch, 34.1 KB (added by viboes, 11 years ago)

header part

  • api_config.hpp

     
    3333//    Standalone MinGW and all other known Windows compilers do predefine _WIN32
    3434//    Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too.
    3535
    36 # if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) )
     36# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
    3737#   define BOOST_SYSTEM_WINDOWS_API
    3838# else
    3939#   define BOOST_SYSTEM_POSIX_API
    4040# endif
    4141
    42 //# if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__CYGWIN__))
    4342# if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin
    4443#   define BOOST_WINDOWS_API
    4544# else
  • config.hpp

     
    1111#define BOOST_SYSTEM_CONFIG_HPP
    1212
    1313#include <boost/config.hpp>
    14 
    15 #if defined(BOOST_SYSTEM_SOURCE) && !defined(BOOST_USE_WINDOWS_H)
    16 #define BOOST_USE_WINDOWS_H
    17 #endif
    18 
    1914#include <boost/system/api_config.hpp>  // for BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API
    2015
    2116#ifdef BOOST_SYSTEM_INLINED
  • cygwin_error.hpp

     
    77
    88//  See library home page at http://www.boost.org/libs/system
    99
    10 #ifndef BOOST_SYSTEM_CYGWIN_ERROR_HPP
    11 #define BOOST_SYSTEM_CYGWIN_ERROR_HPP
     10#ifndef BOOST_CYGWIN_ERROR_HPP
     11#define BOOST_CYGWIN_ERROR_HPP
    1212
    1313//  This header is effectively empty for compiles on operating systems where
    1414//  it is not applicable.
     
    5353
    5454#endif  // __CYGWIN__
    5555
    56 #endif  // BOOST_SYSTEM_CYGWIN_ERROR_HPP
     56#endif  // BOOST_CYGWIN_ERROR_HPP
  • detail/inlined/error_code.hpp

     
     1//  error_code support implementation file  ----------------------------------//
     2
     3//  Copyright Beman Dawes 2002, 2006
     4
     5//  Distributed under the Boost Software License, Version 1.0. (See accompanying
     6//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     7
     8//  See library home page at http://www.boost.org/libs/system
     9
     10//----------------------------------------------------------------------------//
     11
     12#ifndef BOOST_SYSTEM_DETAIL_INLINED_ERROR_CODE_HPP
     13#define BOOST_SYSTEM_DETAIL_INLINED_ERROR_CODE_HPP
     14
     15#include <boost/config/warning_disable.hpp>
     16
     17#include <boost/system/config.hpp>
     18#ifndef BOOST_SYSTEM_INLINED
     19#include <boost/system/error_code.hpp>
     20#endif
     21#include <boost/cerrno.hpp>
     22#include <vector>
     23#include <cstdlib>
     24#include <cassert>
     25
     26//using namespace boost::system;
     27//using namespace boost::system::errc;
     28
     29#include <cstring> // for strerror/strerror_r
     30
     31# if defined( BOOST_SYSTEM_WINDOWS_API )
     32#   include <boost/detail/win/error_handling.hpp>
     33#   include "local_free_on_destruction.hpp"
     34#   ifndef ERROR_INCORRECT_SIZE
     35#     define ERROR_INCORRECT_SIZE ERROR_BAD_ARGUMENTS
     36#   endif
     37# endif
     38
     39//----------------------------------------------------------------------------//
     40
     41namespace boost
     42{
     43namespace system
     44{
     45namespace system_detail
     46{
     47#if defined(__PGI)
     48  using boost::system::errc::invalid_argument;
     49#endif
     50  //  standard error categories  ---------------------------------------------//
     51
     52  class generic_error_category : public error_category
     53  {
     54  public:
     55    generic_error_category(){}
     56    BOOST_SYSTEM_INLINE const char *   name() const;
     57    BOOST_SYSTEM_INLINE std::string    message( int ev ) const;
     58  };
     59
     60  class system_error_category : public error_category
     61  {
     62  public:
     63    system_error_category(){}
     64    BOOST_SYSTEM_INLINE const char *        name() const;
     65    BOOST_SYSTEM_INLINE std::string         message( int ev ) const;
     66    BOOST_SYSTEM_INLINE error_condition     default_error_condition( int ev ) const;
     67  };
     68
     69  //  generic_error_category implementation  ---------------------------------//
     70
     71  const char * generic_error_category::name() const
     72  {
     73    return "generic";
     74  }
     75
     76  std::string generic_error_category::message( int ev ) const
     77  {
     78    static std::string unknown_err( "Unknown error" );
     79  // strerror_r is preferred because it is always thread safe,
     80  // however, we fallback to strerror in certain cases because:
     81  //   -- Windows doesn't provide strerror_r.
     82  //   -- HP and Sun do provide strerror_r on newer systems, but there is
     83  //      no way to tell if is available at runtime and in any case their
     84  //      versions of strerror are thread safe anyhow.
     85  //   -- Linux only sometimes provides strerror_r.
     86  //   -- Tru64 provides strerror_r only when compiled -pthread.
     87  //   -- VMS doesn't provide strerror_r, but on this platform, strerror is
     88  //      thread safe.
     89  # if defined(BOOST_SYSTEM_WINDOWS_API) || defined(__hpux) || defined(__sun)\
     90     || (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\
     91     || (defined(__osf__) && !defined(_REENTRANT))\
     92     || (defined(__INTEGRITY))\
     93     || (defined(__vms))\
     94     || (defined(__QNXNTO__))
     95      const char * c_str = std::strerror( ev );
     96      return  c_str
     97        ? std::string( c_str )
     98        : unknown_err;
     99  # else  // use strerror_r
     100      char buf[64];
     101      char * bp = buf;
     102      std::size_t sz = sizeof(buf);
     103  #  if defined(__CYGWIN__) || defined(__USE_GNU)
     104      // Oddball version of strerror_r
     105      const char * c_str = strerror_r( ev, bp, sz );
     106      return  c_str
     107        ? std::string( c_str )
     108        : unknown_err;
     109  #  else
     110      // POSIX version of strerror_r
     111      int result;
     112      for (;;)
     113      {
     114        // strerror_r returns 0 on success, otherwise ERANGE if buffer too small,
     115        // invalid_argument if ev not a valid error number
     116  #  if defined (__sgi)
     117        const char * c_str = strerror( ev );
     118        result = 0;
     119      return  c_str
     120        ? std::string( c_str )
     121        : unknown_err;
     122  #  else
     123        result = strerror_r( ev, bp, sz );
     124  #  endif
     125        if (result == 0 )
     126          break;
     127        else
     128        {
     129  #  if defined(__linux)
     130          // Linux strerror_r returns -1 on error, with error number in errno
     131          result = errno;
     132  #  endif
     133          if ( result !=  ERANGE ) break;
     134          if ( sz > sizeof(buf) ) std::free( bp );
     135          sz *= 2;
     136          if ( (bp = static_cast<char*>(std::malloc( sz ))) == 0 )
     137            return std::string( "ENOMEM" );
     138        }
     139      }
     140      std::string msg;
     141      try
     142      {
     143        msg = ( ( result == invalid_argument ) ? "Unknown error" : bp );
     144      }
     145
     146#   ifndef BOOST_NO_EXCEPTIONS
     147      // See ticket #2098
     148      catch(...)
     149      {
     150        // just eat the exception
     151      }
     152#   endif
     153
     154      if ( sz > sizeof(buf) ) std::free( bp );
     155      sz = 0;
     156      return msg;
     157  #  endif   // else POSIX version of strerror_r
     158  # endif  // else use strerror_r
     159  }
     160  //  system_error_category implementation  --------------------------------//
     161
     162  const char * system_error_category::name() const
     163  {
     164    return "system";
     165  }
     166
     167  error_condition system_error_category::default_error_condition( int ev ) const
     168  {
     169    switch ( ev )
     170    {
     171    case 0: return make_error_condition( errc::success );
     172# if defined(BOOST_SYSTEM_POSIX_API)
     173    // POSIX-like O/S -> posix_errno decode table  ---------------------------//
     174    case E2BIG: return make_error_condition( errc::argument_list_too_long );
     175    case EACCES: return make_error_condition( errc::permission_denied );
     176    case EADDRINUSE: return make_error_condition( errc::address_in_use );
     177    case EADDRNOTAVAIL: return make_error_condition( errc::address_not_available );
     178    case EAFNOSUPPORT: return make_error_condition( errc::address_family_not_supported );
     179    case EAGAIN: return make_error_condition( errc::resource_unavailable_try_again );
     180#   if EALREADY != EBUSY  //  EALREADY and EBUSY are the same on QNX Neutrino
     181    case EALREADY: return make_error_condition( errc::connection_already_in_progress );
     182#   endif
     183    case EBADF: return make_error_condition( errc::bad_file_descriptor );
     184    case EBADMSG: return make_error_condition( errc::bad_message );
     185    case EBUSY: return make_error_condition( errc::device_or_resource_busy );
     186    case ECANCELED: return make_error_condition( errc::operation_canceled );
     187    case ECHILD: return make_error_condition( errc::no_child_process );
     188    case ECONNABORTED: return make_error_condition( errc::connection_aborted );
     189    case ECONNREFUSED: return make_error_condition( errc::connection_refused );
     190    case ECONNRESET: return make_error_condition( errc::connection_reset );
     191    case EDEADLK: return make_error_condition( errc::resource_deadlock_would_occur );
     192    case EDESTADDRREQ: return make_error_condition( errc::destination_address_required );
     193    case EDOM: return make_error_condition( errc::argument_out_of_domain );
     194    case EEXIST: return make_error_condition( errc::file_exists );
     195    case EFAULT: return make_error_condition( errc::bad_address );
     196    case EFBIG: return make_error_condition( errc::file_too_large );
     197    case EHOSTUNREACH: return make_error_condition( errc::host_unreachable );
     198    case EIDRM: return make_error_condition( errc::identifier_removed );
     199    case EILSEQ: return make_error_condition( errc::illegal_byte_sequence );
     200    case EINPROGRESS: return make_error_condition( errc::operation_in_progress );
     201    case EINTR: return make_error_condition( errc::interrupted );
     202    case EINVAL: return make_error_condition( errc::invalid_argument );
     203    case EIO: return make_error_condition( errc::io_error );
     204    case EISCONN: return make_error_condition( errc::already_connected );
     205    case EISDIR: return make_error_condition( errc::is_a_directory );
     206    case ELOOP: return make_error_condition( errc::too_many_symbolic_link_levels );
     207    case EMFILE: return make_error_condition( errc::too_many_files_open );
     208    case EMLINK: return make_error_condition( errc::too_many_links );
     209    case EMSGSIZE: return make_error_condition( errc::message_size );
     210    case ENAMETOOLONG: return make_error_condition( errc::filename_too_long );
     211    case ENETDOWN: return make_error_condition( errc::network_down );
     212    case ENETRESET: return make_error_condition( errc::network_reset );
     213    case ENETUNREACH: return make_error_condition( errc::network_unreachable );
     214    case ENFILE: return make_error_condition( errc::too_many_files_open_in_system );
     215    case ENOBUFS: return make_error_condition( errc::no_buffer_space );
     216    case ENODATA: return make_error_condition( errc::no_message_available );
     217    case ENODEV: return make_error_condition( errc::no_such_device );
     218    case ENOENT: return make_error_condition( errc::no_such_file_or_directory );
     219    case ENOEXEC: return make_error_condition( errc::executable_format_error );
     220    case ENOLCK: return make_error_condition( errc::no_lock_available );
     221    case ENOLINK: return make_error_condition( errc::no_link );
     222    case ENOMEM: return make_error_condition( errc::not_enough_memory );
     223    case ENOMSG: return make_error_condition( errc::no_message );
     224    case ENOPROTOOPT: return make_error_condition( errc::no_protocol_option );
     225    case ENOSPC: return make_error_condition( errc::no_space_on_device );
     226    case ENOSR: return make_error_condition( errc::no_stream_resources );
     227    case ENOSTR: return make_error_condition( errc::not_a_stream );
     228    case ENOSYS: return make_error_condition( errc::function_not_supported );
     229    case ENOTCONN: return make_error_condition( errc::not_connected );
     230    case ENOTDIR: return make_error_condition( errc::not_a_directory );
     231  # if ENOTEMPTY != EEXIST // AIX treats ENOTEMPTY and EEXIST as the same value
     232    case ENOTEMPTY: return make_error_condition( errc::directory_not_empty );
     233  # endif // ENOTEMPTY != EEXIST
     234  # if ENOTRECOVERABLE != ECONNRESET // the same on some Broadcom chips
     235    case ENOTRECOVERABLE: return make_error_condition( errc::state_not_recoverable );
     236  # endif // ENOTRECOVERABLE != ECONNRESET
     237    case ENOTSOCK: return make_error_condition( errc::not_a_socket );
     238    case ENOTSUP: return make_error_condition( errc::not_supported );
     239    case ENOTTY: return make_error_condition( errc::inappropriate_io_control_operation );
     240    case ENXIO: return make_error_condition( errc::no_such_device_or_address );
     241  # if EOPNOTSUPP != ENOTSUP
     242    case EOPNOTSUPP: return make_error_condition( errc::operation_not_supported );
     243  # endif // EOPNOTSUPP != ENOTSUP
     244    case EOVERFLOW: return make_error_condition( errc::value_too_large );
     245  # if EOWNERDEAD != ECONNABORTED // the same on some Broadcom chips
     246    case EOWNERDEAD: return make_error_condition( errc::owner_dead );
     247  # endif // EOWNERDEAD != ECONNABORTED
     248    case EPERM: return make_error_condition( errc::operation_not_permitted );
     249    case EPIPE: return make_error_condition( errc::broken_pipe );
     250    case EPROTO: return make_error_condition( errc::protocol_error );
     251    case EPROTONOSUPPORT: return make_error_condition( errc::protocol_not_supported );
     252    case EPROTOTYPE: return make_error_condition( errc::wrong_protocol_type );
     253    case ERANGE: return make_error_condition( errc::result_out_of_range );
     254    case EROFS: return make_error_condition( errc::read_only_file_system );
     255    case ESPIPE: return make_error_condition( errc::invalid_seek );
     256    case ESRCH: return make_error_condition( errc::no_such_process );
     257    case ETIME: return make_error_condition( errc::stream_timeout );
     258    case ETIMEDOUT: return make_error_condition( errc::timed_out );
     259    case ETXTBSY: return make_error_condition( errc::text_file_busy );
     260  # if EAGAIN != EWOULDBLOCK
     261    case EWOULDBLOCK: return make_error_condition( errc::operation_would_block );
     262  # endif // EAGAIN != EWOULDBLOCK
     263    case EXDEV: return make_error_condition( errc::cross_device_link );
     264  #else
     265    // Windows system -> posix_errno decode table  ---------------------------//
     266    // see WinError.h comments for descriptions of errors
     267    case ERROR_ACCESS_DENIED: return make_error_condition( errc::permission_denied );
     268    case ERROR_ALREADY_EXISTS: return make_error_condition( errc::file_exists );
     269    case ERROR_BAD_UNIT: return make_error_condition( errc::no_such_device );
     270    case ERROR_BUFFER_OVERFLOW: return make_error_condition( errc::filename_too_long );
     271    case ERROR_BUSY: return make_error_condition( errc::device_or_resource_busy );
     272    case ERROR_BUSY_DRIVE: return make_error_condition( errc::device_or_resource_busy );
     273    case ERROR_CANNOT_MAKE: return make_error_condition( errc::permission_denied );
     274    case ERROR_CANTOPEN: return make_error_condition( errc::io_error );
     275    case ERROR_CANTREAD: return make_error_condition( errc::io_error );
     276    case ERROR_CANTWRITE: return make_error_condition( errc::io_error );
     277    case ERROR_CURRENT_DIRECTORY: return make_error_condition( errc::permission_denied );
     278    case ERROR_DEV_NOT_EXIST: return make_error_condition( errc::no_such_device );
     279    case ERROR_DEVICE_IN_USE: return make_error_condition( errc::device_or_resource_busy );
     280    case ERROR_DIR_NOT_EMPTY: return make_error_condition( errc::directory_not_empty );
     281    case ERROR_DIRECTORY: return make_error_condition( errc::invalid_argument ); // WinError.h: "The directory name is invalid"
     282    case ERROR_DISK_FULL: return make_error_condition( errc::no_space_on_device );
     283    case ERROR_FILE_EXISTS: return make_error_condition( errc::file_exists );
     284    case ERROR_FILE_NOT_FOUND: return make_error_condition( errc::no_such_file_or_directory );
     285    case ERROR_HANDLE_DISK_FULL: return make_error_condition( errc::no_space_on_device );
     286    case ERROR_INVALID_ACCESS: return make_error_condition( errc::permission_denied );
     287    case ERROR_INVALID_DRIVE: return make_error_condition( errc::no_such_device );
     288    case ERROR_INVALID_FUNCTION: return make_error_condition( errc::function_not_supported );
     289    case ERROR_INVALID_HANDLE: return make_error_condition( errc::invalid_argument );
     290    case ERROR_INVALID_NAME: return make_error_condition( errc::invalid_argument );
     291    case ERROR_LOCK_VIOLATION: return make_error_condition( errc::no_lock_available );
     292    case ERROR_LOCKED: return make_error_condition( errc::no_lock_available );
     293    case ERROR_NEGATIVE_SEEK: return make_error_condition( errc::invalid_argument );
     294    case ERROR_NOACCESS: return make_error_condition( errc::permission_denied );
     295    case ERROR_NOT_ENOUGH_MEMORY: return make_error_condition( errc::not_enough_memory );
     296    case ERROR_NOT_READY: return make_error_condition( errc::resource_unavailable_try_again );
     297    case ERROR_NOT_SAME_DEVICE: return make_error_condition( errc::cross_device_link );
     298    case ERROR_OPEN_FAILED: return make_error_condition( errc::io_error );
     299    case ERROR_OPEN_FILES: return make_error_condition( errc::device_or_resource_busy );
     300    case ERROR_OPERATION_ABORTED: return make_error_condition( errc::operation_canceled );
     301    case ERROR_OUTOFMEMORY: return make_error_condition( errc::not_enough_memory );
     302    case ERROR_PATH_NOT_FOUND: return make_error_condition( errc::no_such_file_or_directory );
     303    case ERROR_READ_FAULT: return make_error_condition( errc::io_error );
     304    case ERROR_RETRY: return make_error_condition( errc::resource_unavailable_try_again );
     305    case ERROR_SEEK: return make_error_condition( errc::io_error );
     306    case ERROR_SHARING_VIOLATION: return make_error_condition( errc::permission_denied );
     307    case ERROR_TOO_MANY_OPEN_FILES: return make_error_condition( errc::too_many_files_open );
     308    case ERROR_WRITE_FAULT: return make_error_condition( errc::io_error );
     309    case ERROR_WRITE_PROTECT: return make_error_condition( errc::permission_denied );
     310    case WSAEACCES: return make_error_condition( errc::permission_denied );
     311    case WSAEADDRINUSE: return make_error_condition( errc::address_in_use );
     312    case WSAEADDRNOTAVAIL: return make_error_condition( errc::address_not_available );
     313    case WSAEAFNOSUPPORT: return make_error_condition( errc::address_family_not_supported );
     314    case WSAEALREADY: return make_error_condition( errc::connection_already_in_progress );
     315    case WSAEBADF: return make_error_condition( errc::bad_file_descriptor );
     316    case WSAECONNABORTED: return make_error_condition( errc::connection_aborted );
     317    case WSAECONNREFUSED: return make_error_condition( errc::connection_refused );
     318    case WSAECONNRESET: return make_error_condition( errc::connection_reset );
     319    case WSAEDESTADDRREQ: return make_error_condition( errc::destination_address_required );
     320    case WSAEFAULT: return make_error_condition( errc::bad_address );
     321    case WSAEHOSTUNREACH: return make_error_condition( errc::host_unreachable );
     322    case WSAEINPROGRESS: return make_error_condition( errc::operation_in_progress );
     323    case WSAEINTR: return make_error_condition( errc::interrupted );
     324    case WSAEINVAL: return make_error_condition( errc::invalid_argument );
     325    case WSAEISCONN: return make_error_condition( errc::already_connected );
     326    case WSAEMFILE: return make_error_condition( errc::too_many_files_open );
     327    case WSAEMSGSIZE: return make_error_condition( errc::message_size );
     328    case WSAENAMETOOLONG: return make_error_condition( errc::filename_too_long );
     329    case WSAENETDOWN: return make_error_condition( errc::network_down );
     330    case WSAENETRESET: return make_error_condition( errc::network_reset );
     331    case WSAENETUNREACH: return make_error_condition( errc::network_unreachable );
     332    case WSAENOBUFS: return make_error_condition( errc::no_buffer_space );
     333    case WSAENOPROTOOPT: return make_error_condition( errc::no_protocol_option );
     334    case WSAENOTCONN: return make_error_condition( errc::not_connected );
     335    case WSAENOTSOCK: return make_error_condition( errc::not_a_socket );
     336    case WSAEOPNOTSUPP: return make_error_condition( errc::operation_not_supported );
     337    case WSAEPROTONOSUPPORT: return make_error_condition( errc::protocol_not_supported );
     338    case WSAEPROTOTYPE: return make_error_condition( errc::wrong_protocol_type );
     339    case WSAETIMEDOUT: return make_error_condition( errc::timed_out );
     340    case WSAEWOULDBLOCK: return make_error_condition( errc::operation_would_block );
     341  #endif
     342    default: return error_condition( ev, system_category() );
     343    }
     344  }
     345
     346# if !defined( BOOST_SYSTEM_WINDOWS_API )
     347
     348  std::string system_error_category::message( int ev ) const
     349  {
     350    return generic_category().message( ev );
     351  }
     352# else
     353
     354  std::string system_error_category::message( int ev ) const
     355  {
     356# ifndef BOOST_NO_ANSI_APIS
     357        boost::detail::win32::LPVOID_ lpMsgBuf = 0;
     358        boost::detail::win32::DWORD_ retval = boost::detail::win32::FormatMessageA(
     359                        boost::detail::win32::FORMAT_MESSAGE_ALLOCATE_BUFFER_ |
     360                        boost::detail::win32::FORMAT_MESSAGE_FROM_SYSTEM_ |
     361                        boost::detail::win32::FORMAT_MESSAGE_IGNORE_INSERTS_,
     362        NULL,
     363        ev,
     364        boost::detail::win32::MAKELANGID_(boost::detail::win32::LANG_NEUTRAL_, boost::detail::win32::SUBLANG_DEFAULT_), // Default language
     365        (boost::detail::win32::LPSTR_) &lpMsgBuf,
     366        0,
     367        NULL
     368    );
     369    detail::local_free_on_destruction lfod(lpMsgBuf);
     370    if (retval == 0)
     371        return std::string("Unknown error");
     372
     373    std::string str( static_cast<boost::detail::win32::LPCSTR_>(lpMsgBuf) );
     374# else  // WinCE workaround
     375    boost::detail::win32::LPVOID_ lpMsgBuf = 0;
     376    boost::detail::win32::DWORD retval = boost::detail::win32::FormatMessageW(
     377                boost::detail::win32::FORMAT_MESSAGE_ALLOCATE_BUFFER_ |
     378                boost::detail::win32::FORMAT_MESSAGE_FROM_SYSTEM_ |
     379                boost::detail::win32::FORMAT_MESSAGE_IGNORE_INSERTS_,
     380        NULL,
     381        ev,
     382        boost::detail::win32::MAKELANGID_(boost::detail::win32::LANG_NEUTRAL_, boost::detail::win32::SUBLANG_DEFAULT_), // Default language
     383        (boost::detail::win32::LPWSTR_) &lpMsgBuf,
     384        0,
     385        NULL
     386    );
     387    detail::local_free_on_destruction lfod(lpMsgBuf);
     388    if (retval == 0)
     389        return std::string("Unknown error");
     390
     391    int num_chars = (wcslen( static_cast<LPCWSTR>(lpMsgBuf) ) + 1) * 2;
     392    boost::detail::win32::LPSTR_ narrow_buffer = (boost::detail::win32::LPSTR_)_alloca( num_chars );
     393    if (boost::detail::win32::WideCharToMultiByte(CP_ACP, 0, static_cast<boost::detail::win32::LPCWSTR_>(lpMsgBuf), -1, narrow_buffer, num_chars, NULL, NULL) == 0)
     394        return std::string("Unknown error");
     395
     396    std::string str( narrow_buffer );
     397# endif
     398    while ( str.size()
     399      && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r') )
     400        str.erase( str.size()-1 );
     401    if ( str.size() && str[str.size()-1] == '.' )
     402      { str.erase( str.size()-1 ); }
     403    return str;
     404  }
     405# endif
     406
     407}
     408
     409# ifndef BOOST_SYSTEM_NO_DEPRECATED
     410    BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code;
     411                                         //  note that it doesn't matter if this
     412                                         //  isn't initialized before use since
     413                                         //  the only use is to take its
     414                                         //  address for comparison purposes
     415# endif
     416
     417    BOOST_SYSTEM_DECL const error_category & system_category()
     418    {
     419      static const system_detail::system_error_category  system_category_const;
     420      return system_category_const;
     421    }
     422
     423    BOOST_SYSTEM_DECL const error_category & generic_category()
     424    {
     425      static const system_detail::generic_error_category generic_category_const;
     426      return generic_category_const;
     427    }
     428
     429  } // namespace system
     430} // namespace boost
     431#endif // BOOST_SYSTEM_DETAIL_INLINED_ERROR_CODE_HPP
  • detail/inlined/local_free_on_destruction.hpp

    Property changes on: detail\inlined\error_code.hpp
    ___________________________________________________________________
    Added: svn:mime-type
       + text/plain
    Added: svn:keywords
       + Id
    Added: svn:eol-style
       + native
    
     
     1//  local_free_on_exit.hpp  ------------------------------------------------------------//
     2
     3//  Copyright (c) 2003-2010 Christopher M. Kohlhoff (chris at kohlhoff dot com)
     4//  Copyright (c) 2010 Beman Dawes
     5
     6//  Distributed under the Boost Software License, Version 1.0.
     7//  See http://www.boost.org/LICENSE_1_0.txt
     8
     9//  This is derived from boost/asio/detail/local_free_on_block_exit.hpp to avoid
     10//  a dependency on asio. Thanks to Chris Kohlhoff for pointing it out.
     11
     12#ifndef BOOST_SYSTEM_DETAIL_INLINED_LOCAL_FREE_ON_DESTRUCTION_HPP
     13#define BOOST_SYSTEM_DETAIL_INLINED_LOCAL_FREE_ON_DESTRUCTION_HPP
     14
     15#include <boost/detail/win/LocalFree.hpp>
     16
     17namespace boost {
     18namespace system {
     19namespace detail {
     20
     21class local_free_on_destruction
     22{
     23public:
     24  explicit local_free_on_destruction(void* p)
     25    : p_(p) {}
     26
     27  ~local_free_on_destruction()
     28  {
     29    boost::detail::win32::LocalFree(p_);
     30  }
     31
     32private:
     33  void* p_;
     34  local_free_on_destruction(const local_free_on_destruction&);  // = deleted
     35  local_free_on_destruction& operator=(const local_free_on_destruction&);  // = deleted
     36};
     37
     38} // namespace detail
     39} // namespace system
     40} // namespace boost
     41
     42#endif  // BOOST_SYSTEM_DETAIL_INLINED_LOCAL_FREE_ON_DESTRUCTION_HPP
  • error_code.hpp

    Property changes on: detail\inlined\local_free_on_destruction.hpp
    ___________________________________________________________________
    Added: svn:mime-type
       + text/plain
    Added: svn:keywords
       + Id
    Added: svn:eol-style
       + native
    
     
    2121#include <string>
    2222#include <stdexcept>
    2323#include <functional>
     24#include <assert.h>
    2425
    2526// TODO: undef these macros if not already defined
    26 #include <boost/cerrno.hpp> 
     27#include <boost/cerrno.hpp>
    2728
    28 #if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
    29 #  error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
     29#if !defined(BOOST_SYSTEM_POSIX_API) && !defined(BOOST_SYSTEM_WINDOWS_API)
     30#  error BOOST_SYSTEM_POSIX_API or BOOST_SYSTEM_WINDOWS_API must be defined
    3031#endif
    3132
     33# ifdef BOOST_ERROR_CODE_HEADER_ONLY
     34#  ifndef BOOST_SYSTEM_INLINED
     35#   define BOOST_SYSTEM_INLINED
     36#  endif
     37# endif
     38
     39#ifndef BOOST_SYSTEM_INLINED
    3240#include <boost/config/abi_prefix.hpp> // must be the last #include
     41#endif
    3342
    3443namespace boost
    3544{
     
    187196      virtual const char *     name() const = 0;
    188197      virtual std::string      message( int ev ) const = 0;
    189198      virtual error_condition  default_error_condition( int ev ) const;
    190       virtual bool             equivalent( int code, 
     199      virtual bool             equivalent( int code,
    191200                                           const error_condition & condition ) const;
    192201      virtual bool             equivalent( const error_code & code,
    193202                                           int condition ) const;
     
    202211
    203212    //  predefined error categories  -----------------------------------------//
    204213
    205     BOOST_SYSTEM_DECL const error_category &  system_category();
    206     BOOST_SYSTEM_DECL const error_category &  generic_category();
     214    BOOST_SYSTEM_DECL BOOST_SYSTEM_INLINE const error_category &  system_category();
     215    BOOST_SYSTEM_DECL BOOST_SYSTEM_INLINE const error_category &  generic_category();
    207216
    208217    //  deprecated synonyms --------------------------------------------------//
    209218
     
    238247      // modifiers:
    239248
    240249      void assign( int val, const error_category & cat )
    241       { 
     250      {
    242251        m_val = val;
    243252        m_cat = &cat;
    244253      }
    245                                              
     254
    246255      template<typename ErrorConditionEnum>
    247256        typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type &
    248257          operator=( ErrorConditionEnum val )
    249       { 
     258      {
    250259        *this = make_error_condition(val);
    251260        return *this;
    252261      }
     
    266275      static void unspecified_bool_true() {}
    267276
    268277      operator unspecified_bool_type() const  // true if error
    269       { 
     278      {
    270279        return m_val == 0 ? 0 : unspecified_bool_true;
    271280      }
    272281
     
    282291                                     const error_condition & rhs )
    283292      {
    284293        return lhs.m_cat == rhs.m_cat && lhs.m_val == rhs.m_val;
    285       }                 
     294      }
    286295
    287296      inline friend bool operator<( const error_condition & lhs,
    288297                                    const error_condition & rhs )
     
    324333
    325334      // modifiers:
    326335      void assign( int val, const error_category & cat )
    327       { 
     336      {
    328337        m_val = val;
    329338        m_cat = &cat;
    330339      }
    331                                              
     340
    332341      template<typename ErrorCodeEnum>
    333342        typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type &
    334343          operator=( ErrorCodeEnum val )
    335       { 
     344      {
    336345        *this = make_error_code(val);
    337346        return *this;
    338347      }
     
    353362      static void unspecified_bool_true() {}
    354363
    355364      operator unspecified_bool_type() const  // true if error
    356       { 
     365      {
    357366        return m_val == 0 ? 0 : unspecified_bool_true;
    358367      }
    359368
     
    379388        return lhs.m_cat < rhs.m_cat
    380389          || (lhs.m_cat == rhs.m_cat && lhs.m_val < rhs.m_val);
    381390      }
    382                  
     391
    383392      private:
    384393      int                     m_val;
    385394      const error_category *  m_cat;
     
    397406
    398407  }  // namespace system
    399408
    400   namespace detail { inline system::error_code * throws() { return 0; } }
     409  namespace detail {
     410      inline system::error_code * throws() { return 0; }
     411  }
    401412    //  Misuse of the error_code object is turned into a noisy failure by
    402413    //  poisoning the reference. This particular implementation doesn't
    403414    //  produce warnings or errors from popular compilers, is very efficient
     
    405416    //  from order of initialization problems. In practice, it also seems
    406417    //  cause user function error handling implementation errors to be detected
    407418    //  very early in the development cycle.
    408 
    409419  inline system::error_code & throws()
    410420    { return *detail::throws(); }
    411421
     
    431441      return code.category().equivalent( code.value(), condition )
    432442        || condition.category().equivalent( code, condition.value() );
    433443    }
    434                
     444
    435445    inline bool operator!=( const error_code & lhs,
    436446                            const error_condition & rhs )
    437447    {
    438448      return !(lhs == rhs);
    439449    }
    440                
     450
    441451    inline bool operator==( const error_condition & condition,
    442452                            const error_code & code )
    443453    {
    444454      return condition.category().equivalent( code, condition.value() )
    445455        || code.category().equivalent( code.value(), condition );
    446456    }
    447                
     457
    448458    inline bool operator!=( const error_condition & lhs,
    449459                            const error_code & rhs )
    450460    {
    451461      return !(lhs == rhs);
    452462    }
    453                  
     463
    454464    // TODO: both of these may move elsewhere, but the LWG hasn't spoken yet.
    455465
    456466    template <class charT, class traits>
     
    483493    //  error_category default implementation  -------------------------------//
    484494
    485495    inline error_condition error_category::default_error_condition( int ev ) const
    486     { 
     496    {
    487497      return error_condition( ev, *this );
    488498    }
    489499
     
    502512  } // namespace system
    503513} // namespace boost
    504514
     515//#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
     516//
     517
     518#ifndef BOOST_SYSTEM_INLINED
    505519#include <boost/config/abi_suffix.hpp> // pops abi_prefix.hpp pragmas
     520#else
     521#include <boost/system/detail/inlined/error_code.hpp>
     522#endif
    506523
    507 # ifdef BOOST_ERROR_CODE_HEADER_ONLY
    508 #   include <boost/../libs/system/src/error_code.cpp>
    509 # endif
    510524
    511525#endif // BOOST_ERROR_CODE_HPP
    512526
  • linux_error.hpp

     
    2727
    2828    //  User code should use the portable "posix" enums for POSIX errors; this
    2929    //  allows such code to be portable to non-POSIX systems. For the non-POSIX
    30     //  errno values that POSIX-based systems typically provide in addition to 
     30    //  errno values that POSIX-based systems typically provide in addition to
    3131    //  POSIX values, use the system specific enums below.
    3232
    3333    namespace linux_error
     
    103103    }
    104104
    105105  }  // namespace system
    106 }  // namespace boost 
     106}  // namespace boost
    107107
    108108#endif  // Linux
    109109
  • system_error.hpp

     
    2121
    2222    class BOOST_SYMBOL_VISIBLE system_error : public std::runtime_error
    2323    // BOOST_SYMBOL_VISIBLE is needed by GCC to ensure system_error thrown from a shared
    24     // library can be caught. See svn.boost.org/trac/boost/ticket/3697 
     24    // library can be caught. See svn.boost.org/trac/boost/ticket/3697
    2525    {
    2626    public:
    2727      system_error( error_code ec )
     
    4747      virtual ~system_error() throw() {}
    4848
    4949      const error_code &  code() const throw() { return m_error_code; }
    50       const char *        what() const throw();
     50      inline const char *        what() const throw();
    5151
    5252    private:
    5353      error_code           m_error_code;
     
    5656
    5757    //  implementation  ------------------------------------------------------//
    5858
    59     inline const char * system_error::what() const throw()
     59    const char * system_error::what() const throw()
    6060    // see http://www.boost.org/more/error_handling.html for lazy build rationale
    6161    {
    6262      if ( m_what.empty() )
  • windows_error.hpp

     
    1515
    1616#include <boost/system/config.hpp>
    1717
    18 #ifdef BOOST_WINDOWS_API
     18#ifdef BOOST_SYSTEM_WINDOWS_API
    1919
    2020#include <boost/system/error_code.hpp>
    2121#include <winerror.h>
     
    113113  }  // namespace system
    114114}  // namespace boost
    115115
    116 #endif  // BOOST_WINDOWS_API
     116#endif  // BOOST_SYSTEM_WINDOWS_API
    117117
    118118#endif  // BOOST_WINDOWS_ERROR_HPP