[complement-svn] SF.net SVN: complement:[1950] trunk/complement/explore
Status: Pre-Alpha
Brought to you by:
complement
From: <com...@us...> - 2008-07-25 06:34:42
|
Revision: 1950 http://complement.svn.sourceforge.net/complement/?rev=1950&view=rev Author: complement Date: 2008-07-25 06:34:37 +0000 (Fri, 25 Jul 2008) Log Message: ----------- follow C++ draft for system_error See http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2008/n2691.pdf Modified Paths: -------------- trunk/complement/explore/include/mt/mutex trunk/complement/explore/include/mt/system_error trunk/complement/explore/lib/mt/ChangeLog trunk/complement/explore/lib/mt/system_error.cc Modified: trunk/complement/explore/include/mt/mutex =================================================================== --- trunk/complement/explore/include/mt/mutex 2008-07-25 06:34:06 UTC (rev 1949) +++ trunk/complement/explore/include/mt/mutex 2008-07-25 06:34:37 UTC (rev 1950) @@ -218,7 +218,7 @@ void lock() { #ifdef __FIT_PTHREADS - std::error_catalog::value_type e = pthread_mutex_lock( &this->_M_lock ); + int /* std::error_catalog::value_type */ e = pthread_mutex_lock( &this->_M_lock ); if ( e ) { // throw std::system_error( e, native_catalog ); } Modified: trunk/complement/explore/include/mt/system_error =================================================================== --- trunk/complement/explore/include/mt/system_error 2008-07-25 06:34:06 UTC (rev 1949) +++ trunk/complement/explore/include/mt/system_error 2008-07-25 06:34:37 UTC (rev 1950) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/02/24 13:19:17 ptr> +// -*- C++ -*- Time-stamp: <08/07/20 19:12:24 ptr> /* * Copyright (c) 2007-2008 @@ -8,135 +8,475 @@ * * Based on JTC1/SC22/WG21 C++ 0x working draft; * - * This is revision 2 of <system_error>: - * http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2007/n2303.html + * http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2008/n2691.pdf */ #ifndef __SYSTEM_ERROR #define __SYSTEM_ERROR -#include <locale> +// #include <locale> #include <string> #include <stdexcept> -namespace std -{ +#ifdef STLPORT +#include <type_traits> +#else +... +#endif -struct error_catalog -{ - typedef int value_type; +#include <cerrno> - static const value_type address_family_not_supported; - static const value_type address_in_use; - static const value_type address_not_available; - static const value_type already_connected; - static const value_type argument_list_too_long; - static const value_type argument_out_of_domain; - static const value_type bad_address; - static const value_type bad_file_descriptor; - static const value_type bad_message; - static const value_type broken_pipe; - static const value_type connection_aborted; - static const value_type connection_refused; - static const value_type connection_reset; - static const value_type cross_device_link; - static const value_type destination_address_required; - static const value_type device_or_resource_busy; - static const value_type directory_not_empty; - static const value_type executable_format_error; - static const value_type file_exists; - static const value_type file_too_large; - static const value_type filename_too_long; - static const value_type function_not_supported; - static const value_type host_unreachable; - static const value_type identifier_removed; - static const value_type illegal_byte_sequence; - static const value_type inappropriate_io_control_operation; - static const value_type interrupted; - static const value_type invalid_argument; - static const value_type invalid_seek; - static const value_type io_error; - static const value_type is_a_directory; - static const value_type message_too_long; - static const value_type network_down; - static const value_type network_reset; - static const value_type network_unreachable; - static const value_type no_buffer_space; - static const value_type no_child_process; - static const value_type no_link; - static const value_type no_lock_available; - static const value_type no_message_available; - static const value_type no_message; - static const value_type no_space_on_device; - static const value_type no_stream_resources; - static const value_type no_such_device_or_address; - static const value_type no_such_device; - static const value_type no_such_file_or_directory; - static const value_type no_such_process; - static const value_type not_a_directory; - static const value_type not_a_socket; - static const value_type not_a_stream; - static const value_type not_connected; - static const value_type not_enough_memory; - static const value_type not_supported; - static const value_type operation_already_in_progress; - static const value_type operation_canceled; - static const value_type operation_in_progress; - static const value_type operation_not_permitted; - static const value_type operation_not_supported; - static const value_type owner_dead; - static const value_type permission_denied; - static const value_type protocol_error; - static const value_type protocol_not_available; - static const value_type protocol_not_supported; - static const value_type read_only_file_system; - static const value_type resource_deadlock_would_occur; - static const value_type result_out_of_range; - static const value_type state_not_recoverable; - static const value_type stream_timeout; - static const value_type text_file_busy; - static const value_type timed_out; - static const value_type too_many_files_open_in_system; - static const value_type too_many_files_open; - static const value_type too_many_links; - static const value_type too_many_synbolic_link_levels; - static const value_type try_again; - static const value_type value_too_large; - static const value_type wrong_protocol_type; +namespace std { - virtual const value_type last_value() const throw(); +class error_category; +class error_code; +class error_condition; +class system_error; - virtual bool is_valid_value(value_type) const throw(); +template <class T> +struct is_error_code_enum : + public std::tr1::false_type +{ }; - virtual const char* str(value_type) const throw(); +template <class T> +struct is_error_condition_enum : + public std::tr1::false_type +{ }; - const locale& getloc() const throw() - { return _M_loc; } +namespace posix_error { - error_catalog(const locale& __loc = locale::classic()) throw() : - _M_loc( __loc ) - { } +enum posix_errno { +#ifdef EAFNOSUPPORT + address_family_not_supported = EAFNOSUPPORT, +#else +#endif +#ifdef EADDRINUSE + address_in_use = EADDRINUSE, +#else +#endif +#ifdef EADDRNOTAVAIL + address_not_available = EADDRNOTAVAIL, +#else +#endif +#ifdef EISCONN + already_connected = EISCONN, +#else +#endif +#ifdef E2BIG + argument_list_too_long = E2BIG, +#else +#endif +#ifdef EDOM + argument_out_of_domain = EDOM, +#else +#endif +#ifdef EFAULT + bad_address = EFAULT, +#else +#endif +#ifdef EBADF + bad_file_descriptor = EBADF, +#else +#endif +#ifdef EBADMSG + bad_message = EBADMSG, +#else +#endif +#ifdef EPIPE + broken_pipe = EPIPE, +#else +#endif +#ifdef ECONNABORTED + connection_aborted = ECONNABORTED, +#else +#endif +#ifdef EALREADY + connection_already_in_progress = EALREADY, +#else +#endif +#ifdef ECONNREFUSED + connection_refused = ECONNREFUSED, +#else +#endif +#ifdef ECONNRESET + connection_reset = ECONNRESET, +#else +#endif +#ifdef EXDEV + cross_device_link = EXDEV, +#else +#endif +#ifdef EDESTADDRREQ + destination_address_required = EDESTADDRREQ, +#else +#endif +#ifdef EBUSY + device_or_resource_busy = EBUSY, +#else +#endif +#ifdef ENOTEMPTY + directory_not_empty = ENOTEMPTY, +#else +#endif +#ifdef ENOEXEC + executable_format_error = ENOEXEC, +#else +#endif +#ifdef EEXIST + file_exists = EEXIST, +#else +#endif +#ifdef EFBIG + file_too_large = EFBIG, +#else +#endif +#ifdef ENAMETOOLONG + filename_too_long = ENAMETOOLONG, +#else +#endif +#ifdef ENOSYS + function_not_supported = ENOSYS, +#else +#endif +#ifdef EHOSTUNREACH + host_unreachable = EHOSTUNREACH, +#else +#endif +#ifdef EIDRM + identifier_removed = EIDRM, +#else +#endif +#ifdef EILSEQ + illegal_byte_sequence = EILSEQ, +#else +#endif +#ifdef ENOTTY + inappropriate_io_control_operation = ENOTTY, +#else +#endif +#ifdef EINTR + interrupted = EINTR, +#else +#endif +#ifdef EINVAL + invalid_argument = EINVAL, +#else +#endif +#ifdef ESPIPE + invalid_seek = ESPIPE, +#else +#endif +#ifdef EIO + io_error = EIO, +#else +#endif +#ifdef EISDIR + is_a_directory = EISDIR, +#else +#endif +#ifdef EMSGSIZE + message_too_long = EMSGSIZE, +#else +#endif +#ifdef ENETDOWN + network_down = ENETDOWN, +#else +#endif +#ifdef ENETRESET + network_reset = ENETRESET, +#else +#endif +#ifdef ENETUNREACH + network_unreachable = ENETUNREACH, +#else +#endif +#ifdef ENOBUFS + no_buffer_space = ENOBUFS, +#else +#endif +#ifdef ECHILD + no_child_process = ECHILD, +#else +#endif +#ifdef ENOLINK + no_link = ENOLINK, +#else +#endif +#ifdef ENOLCK + no_lock_available = ENOLCK, +#else +#endif +#ifdef ENODATA + no_message_available = ENODATA, +#else +#endif +#ifdef ENOMSG + no_message = ENOMSG, +#else +#endif +#ifdef ENOPROTOOPT + no_protocol_option = ENOPROTOOPT, +#else +#endif +#ifdef ENOSPC + no_space_on_device = ENOSPC, +#else +#endif +#ifdef ENOSR + no_stream_resources = ENOSR, +#else +#endif +#ifdef ENXIO + no_such_device_or_address = ENXIO, +#else +#endif +#ifdef ENODEV + no_such_device = ENODEV, +#else +#endif +#ifdef ENOENT + no_such_file_or_directory = ENOENT, +#else +#endif +#ifdef ESRCH + no_such_process = ESRCH, +#else +#endif +#ifdef ENOTDIR + not_a_directory = ENOTDIR, +#else +#endif +#ifdef ENOTSOCK + not_a_socket = ENOTSOCK, +#else +#endif +#ifdef ENOSTR + not_a_stream = ENOSTR, +#else +#endif +#ifdef ENOTCONN + not_connected = ENOTCONN, +#else +#endif +#ifdef ENOMEM + not_enough_memory = ENOMEM, +#else +#endif +#ifdef ENOTSUP + not_supported = ENOTSUP, +#else +#endif +#ifdef EALREADY + operation_already_in_progress = EALREADY, +#else +#endif +#ifdef ECANCELED + operation_canceled = ECANCELED, +#else +#endif +#ifdef EINPROGRESS + operation_in_progress = EINPROGRESS, +#else +#endif +#ifdef EPERM + operation_not_permitted = EPERM, +#else +#endif +#ifdef EOPNOTSUPP + operation_not_supported = EOPNOTSUPP, +#else +#endif +#ifdef EOWNERDEAD + owner_dead = EOWNERDEAD, +#else +#endif +#ifdef EACCES + permission_denied = EACCES, +#else +#endif +#ifdef EPROTO + protocol_error = EPROTO, +#else +#endif +#ifdef EPROTONOSUPPORT + protocol_not_supported = EPROTONOSUPPORT, +#else +#endif +#ifdef EROFS + read_only_file_system = EROFS, +#else +#endif +#ifdef EDEADLK + resource_deadlock_would_occur = EDEADLK, +#else +#endif +#ifdef EAGAIN + resource_unavailable_try_again = EAGAIN, +#else +#endif +#ifdef ERANGE + result_out_of_range = ERANGE, +#else +#endif +#ifdef ENOTRECOVERABLE + state_not_recoverable = ENOTRECOVERABLE, +#else +#endif +#ifdef ETIME + stream_timeout = ETIME, +#else +#endif +#ifdef ETXTBSY + text_file_busy = ETXTBSY, +#else +#endif +#ifdef ETIMEDOUT + timed_out = ETIMEDOUT, +#else +#endif +#ifdef ENFILE + too_many_files_open_in_system = ENFILE, +#else +#endif +#ifdef EMFILE + too_many_files_open = EMFILE, +#else +#endif +#ifdef EMLINK + too_many_links = EMLINK, +#else +#endif +#ifdef ELOOP + too_many_synbolic_link_levels = ELOOP, +#else +#endif +#ifdef EOVERFLOW + value_too_large = EOVERFLOW, +#else +#endif +#ifdef EPROTOTYPE + wrong_protocol_type = EPROTOTYPE +#else +#endif +}; - error_catalog(const char* __name) : - _M_loc( __name ) - { } +} // namespace posix_error - virtual ~error_catalog() throw() +template <> +struct is_error_condition_enum<posix_error::posix_errno> : + public std::tr1::true_type +{ }; + +namespace posix_error { + +error_code make_error_code( posix_errno err ); +error_condition make_error_condition( posix_errno err ); + +} // namespace posix_error + +bool operator ==(const error_code& l, const error_code& r ); +bool operator ==(const error_code& l, const error_condition& r ); +bool operator ==(const error_condition& l, const error_code& r ); +bool operator ==(const error_condition& l, const error_condition& r ); + +bool operator !=(const error_code& l, const error_code& r ); +bool operator !=(const error_code& l, const error_condition& r ); +bool operator !=(const error_condition& l, const error_code& r ); +bool operator !=(const error_condition& l, const error_condition& r ); + +class error_category +{ + public: + virtual ~error_category(); + + private: + error_category( const error_category& ); + error_category& operator =( const error_category& ); + + public: + error_category() { } + virtual const char* name() const = 0; + virtual error_condition default_error_condition( int err ) const; + virtual bool equivalent( int code, const error_condition& cnd ) const; + virtual bool equivalent( const error_code& code, int cnd ) const; + virtual string message( int err ) const = 0; - bool operator ==(const error_catalog& __other) const throw(); - bool operator !=(const error_catalog& __other) const throw(); + bool operator ==( const error_category& ) const; + bool operator !=( const error_category& ) const; + bool operator <( const error_category& ) const; +}; +const error_category& get_posix_category(); +const error_category& get_system_category(); + +static const error_category& posix_category = get_posix_category(); +static const error_category& native_category = get_system_category(); + +class error_code +{ + public: + error_code(); + error_code( int val, const error_category& ); + template <class ErrorCodeEnum> + error_code( ErrorCodeEnum err, typename std::tr1::enable_if<is_error_code_enum<ErrorCodeEnum>::value,void>::type* = 0 ); + + void assign( int val, const error_category& ); + template <class ErrorCodeEnum> + typename std::tr1::enable_if<is_error_code_enum<ErrorCodeEnum>::value, error_code >::type& operator =( ErrorCodeEnum err ); + void clear(); + + int value() const; + const error_category& category() const; + error_condition default_error_condition() const; + string message() const; + operator bool() const; + private: - const locale _M_loc; + int v; + const error_category& c; }; +bool operator <( const error_code&, const error_code& ); + + +class error_condition +{ + public: + error_condition(); + error_condition( int val, const error_category& category ); + template <class ErrorConditionEnum> + error_condition( ErrorConditionEnum err, + typename std::tr1::enable_if<is_error_condition_enum<ErrorConditionEnum>::value,void>::type* = 0 ); + + void assign( int val, const error_category& category ); + template <class ErrorConditionEnum> + typename std::tr1::enable_if<is_error_condition_enum<ErrorConditionEnum>::value, error_code >::type& operator =( ErrorConditionEnum err ); + void clear(); + + int value() const; + const error_category& category() const; + string message() const; + operator bool() const; + + private: + int val_; + const error_category& cat_; +}; + +bool operator <( const error_condition&, const error_condition& ); + class system_error : - public std::runtime_error + public runtime_error { public: - system_error( const std::string& ); - system_error( error_catalog::value_type, const error_catalog& ); + system_error( error_code code, const string& what ); + system_error( error_code code ); + system_error( error_code code, const error_category& category, + const string& what ); + system_error( error_code code, const error_category& category ); + error_code& code() const throw(); + const char* what() const throw(); }; } // namespace std Modified: trunk/complement/explore/lib/mt/ChangeLog =================================================================== --- trunk/complement/explore/lib/mt/ChangeLog 2008-07-25 06:34:06 UTC (rev 1949) +++ trunk/complement/explore/lib/mt/ChangeLog 2008-07-25 06:34:37 UTC (rev 1950) @@ -1,3 +1,11 @@ +2008-07-21 Petr Ovtchenkov <pt...@is...> + + * mutex: avoid usage of error_catalog---interface in + system_error changed. + + * system_error, system_error.cc: follow + http://www.open-std.org/jtc1/sc22/WG21/docs/papers/2008/n2691.pdf + 2008-07-07 Petr Ovtchenkov <pt...@is...> * uid.cc, uid.h: convert uid to string; output uid Modified: trunk/complement/explore/lib/mt/system_error.cc =================================================================== --- trunk/complement/explore/lib/mt/system_error.cc 2008-07-25 06:34:06 UTC (rev 1949) +++ trunk/complement/explore/lib/mt/system_error.cc 2008-07-25 06:34:37 UTC (rev 1950) @@ -1,4 +1,4 @@ -// -*- C++ -*- Time-stamp: <08/02/24 13:36:56 ptr> +// -*- C++ -*- Time-stamp: <08/07/20 19:55:22 ptr> /* * Copyright (c) 2007-2008 @@ -45,15 +45,14 @@ namespace detail { -class _SysErrInit +struct _SysErrInit { - public: - typedef std::vector<char *> container_type; + typedef std::vector<const char *> container_type; _SysErrInit(); container_type _sys_err; - std::error_catalog::value_type _last_value; + container_type::size_type _last_value; }; _SysErrInit::_SysErrInit() : @@ -817,358 +816,95 @@ static _SysErrInit _syserr; +static const std::string _unknown( "Code not specified in this category" ); + +class posix_error_category : + public std::error_category +{ + public: + virtual const char* name() const; + virtual std::string message( int err ) const; + +}; + +const char* posix_error_category::name() const +{ + return "POSIX"; +} + +std::string posix_error_category::message( int err ) const +{ + // bad: allocation present, so no memory may happens... + return (err >= 0) && (err <= _syserr._last_value) && (_syserr._sys_err[err] != 0) ? std::string( _syserr._sys_err[err] ) : _unknown; +} + +class system_error_category : + public std::error_category +{ + public: + virtual const char* name() const; + virtual std::string message( int err ) const; + +}; + +const char* system_error_category::name() const +{ + return "system"; +} + +std::string system_error_category::message( int err ) const +{ + // bad: allocation present, so no memory may happens... + return (err >= 0) && (err <= _syserr._last_value) && (_syserr._sys_err[err] != 0) ? std::string( _syserr._sys_err[err] ) : _unknown; +} + +static posix_error_category _posix_error_category; +static system_error_category _system_error_category; + } // namespace detail namespace std { using namespace detail; -#ifdef EAFNOSUPPORT -const error_catalog::value_type error_catalog::address_family_not_supported = EAFNOSUPPORT; -#else -#endif -#ifdef EADDRINUSE -const error_catalog::value_type error_catalog::address_in_use = EADDRINUSE; -#else -#endif -#ifdef EADDRNOTAVAIL -const error_catalog::value_type error_catalog::address_not_available = EADDRNOTAVAIL; -#else -#endif -#ifdef EISCONN -const error_catalog::value_type error_catalog::already_connected = EISCONN; -#else -#endif -#ifdef E2BIG -const error_catalog::value_type error_catalog::argument_list_too_long = E2BIG; -#else -#endif -#ifdef EDOM -const error_catalog::value_type error_catalog::argument_out_of_domain = EDOM; -#else -#endif -#ifdef EFAULT -const error_catalog::value_type error_catalog::bad_address = EFAULT; -#else -#endif -#ifdef EBADF -const error_catalog::value_type error_catalog::bad_file_descriptor = EBADF; -#else -#endif -#ifdef EBADMSG -const error_catalog::value_type error_catalog::bad_message = EBADMSG; -#else -#endif -#ifdef EPIPE -const error_catalog::value_type error_catalog::broken_pipe = EPIPE; -#else -#endif -#ifdef ECONNABORTED -const error_catalog::value_type error_catalog::connection_aborted = ECONNABORTED; -#else -#endif -#ifdef ECONNREFUSED -const error_catalog::value_type error_catalog::connection_refused = ECONNREFUSED; -#else -#endif -#ifdef ECONNRESET -const error_catalog::value_type error_catalog::connection_reset = ECONNRESET; -#else -#endif -#ifdef EXDEV -const error_catalog::value_type error_catalog::cross_device_link = EXDEV; -#else -#endif -#ifdef EDESTADDRREQ -const error_catalog::value_type error_catalog::destination_address_required = EDESTADDRREQ; -#else -#endif -#ifdef EBUSY -const error_catalog::value_type error_catalog::device_or_resource_busy = EBUSY; -#else -#endif -#ifdef ENOTEMPTY -const error_catalog::value_type error_catalog::directory_not_empty = ENOTEMPTY; -#else -#endif -#ifdef ENOEXEC -const error_catalog::value_type error_catalog::executable_format_error = ENOEXEC; -#else -#endif -#ifdef EEXIST -const error_catalog::value_type error_catalog::file_exists = EEXIST; -#else -#endif -#ifdef EFBIG -const error_catalog::value_type error_catalog::file_too_large = EFBIG; -#else -#endif -#ifdef ENAMETOOLONG -const error_catalog::value_type error_catalog::filename_too_long = ENAMETOOLONG; -#else -#endif -#ifdef ENOSYS -const error_catalog::value_type error_catalog::function_not_supported = ENOSYS; -#else -#endif -#ifdef EHOSTUNREACH -const error_catalog::value_type error_catalog::host_unreachable = EHOSTUNREACH; -#else -#endif -#ifdef EIDRM -const error_catalog::value_type error_catalog::identifier_removed = EIDRM; -#else -#endif -#ifdef EILSEQ -const error_catalog::value_type error_catalog::illegal_byte_sequence = EILSEQ; -#else -#endif -#ifdef ENOTTY -const error_catalog::value_type error_catalog::inappropriate_io_control_operation =ENOTTY; -#else -#endif -#ifdef EINTR -const error_catalog::value_type error_catalog::interrupted = EINTR; -#else -#endif -#ifdef EINVAL -const error_catalog::value_type error_catalog::invalid_argument = EINVAL; -#else -#endif -#ifdef ESPIPE -const error_catalog::value_type error_catalog::invalid_seek = ESPIPE; -#else -#endif -#ifdef EIO -const error_catalog::value_type error_catalog::io_error = EIO; -#else -#endif -#ifdef EISDIR -const error_catalog::value_type error_catalog::is_a_directory = EISDIR; -#else -#endif -#ifdef EMSGSIZE -const error_catalog::value_type error_catalog::message_too_long = EMSGSIZE; -#else -#endif -#ifdef ENETDOWN -const error_catalog::value_type error_catalog::network_down = ENETDOWN; -#else -#endif -#ifdef ENETRESET -const error_catalog::value_type error_catalog::network_reset = ENETRESET; -#else -#endif -#ifdef ENETUNREACH -const error_catalog::value_type error_catalog::network_unreachable = ENETUNREACH; -#else -#endif -#ifdef ENOBUFS -const error_catalog::value_type error_catalog::no_buffer_space = ENOBUFS; -#else -#endif -#ifdef ECHILD -const error_catalog::value_type error_catalog::no_child_process = ECHILD; -#else -#endif -#ifdef ENOLINK -const error_catalog::value_type error_catalog::no_link = ENOLINK; -#else -#endif -#ifdef ENOLCK -const error_catalog::value_type error_catalog::no_lock_available = ENOLCK; -#else -#endif -#ifdef ENODATA -const error_catalog::value_type error_catalog::no_message_available = ENODATA; -#else -#endif -#ifdef ENOMSG -const error_catalog::value_type error_catalog::no_message = ENOMSG; -#else -#endif -#ifdef ENOSPC -const error_catalog::value_type error_catalog::no_space_on_device = ENOSPC; -#else -#endif -#ifdef ENOSR -const error_catalog::value_type error_catalog::no_stream_resources = ENOSR; -#else -#endif -#ifdef ENXIO -const error_catalog::value_type error_catalog::no_such_device_or_address = ENXIO; -#else -#endif -#ifdef ENODEV -const error_catalog::value_type error_catalog::no_such_device = ENODEV; -#else -#endif -#ifdef ENOENT -const error_catalog::value_type error_catalog::no_such_file_or_directory = ENOENT; -#else -#endif -#ifdef ESRCH -const error_catalog::value_type error_catalog::no_such_process = ESRCH; -#else -#endif -#ifdef ENOTDIR -const error_catalog::value_type error_catalog::not_a_directory = ENOTDIR; -#else -#endif -#ifdef ENOTSOCK -const error_catalog::value_type error_catalog::not_a_socket = ENOTSOCK; -#else -#endif -#ifdef ENOSTR -const error_catalog::value_type error_catalog::not_a_stream = ENOSTR; -#else -#endif -#ifdef ENOTCONN -const error_catalog::value_type error_catalog::not_connected = ENOTCONN; -#else -#endif -#ifdef ENOMEM -const error_catalog::value_type error_catalog::not_enough_memory = ENOMEM; -#else -#endif -#ifdef ENOTSUP -const error_catalog::value_type error_catalog::not_supported = ENOTSUP; -#else -#endif -#ifdef EALREADY -const error_catalog::value_type error_catalog::operation_already_in_progress = EALREADY; -#else -#endif -#ifdef ECANCELED -const error_catalog::value_type error_catalog::operation_canceled = ECANCELED; -#else -#endif -#ifdef EINPROGRESS -const error_catalog::value_type error_catalog::operation_in_progress = EINPROGRESS; -#else -#endif -#ifdef EPERM -const error_catalog::value_type error_catalog::operation_not_permitted = EPERM; -#else -#endif -#ifdef EOPNOTSUPP -const error_catalog::value_type error_catalog::operation_not_supported = EOPNOTSUPP; -#else -#endif -#ifdef EOWNERDEAD -const error_catalog::value_type error_catalog::owner_dead = EOWNERDEAD; -#else -#endif -#ifdef EACCES -const error_catalog::value_type error_catalog::permission_denied = EACCES; -#else -#endif -#ifdef EPROTO -const error_catalog::value_type error_catalog::protocol_error = EPROTO; -#else -#endif -#ifdef ENOPROTOOPT -const error_catalog::value_type error_catalog::protocol_not_available = ENOPROTOOPT; -#else -#endif -#ifdef EPROTONOSUPPORT -const error_catalog::value_type error_catalog::protocol_not_supported = EPROTONOSUPPORT; -#else -#endif -#ifdef EROFS -const error_catalog::value_type error_catalog::read_only_file_system = EROFS; -#else -#endif -#ifdef EDEADLK -const error_catalog::value_type error_catalog::resource_deadlock_would_occur = EDEADLK; -#else -#endif -#ifdef ERANGE -const error_catalog::value_type error_catalog::result_out_of_range = ERANGE; -#else -#endif -#ifdef ENOTRECOVERABLE -const error_catalog::value_type error_catalog::state_not_recoverable = ENOTRECOVERABLE; -#else -#endif -#ifdef ETIME -const error_catalog::value_type error_catalog::stream_timeout = ETIME; -#else -#endif -#ifdef ETXTBSY -const error_catalog::value_type error_catalog::text_file_busy = ETXTBSY; -#else -#endif -#ifdef ETIMEDOUT -const error_catalog::value_type error_catalog::timed_out = ETIMEDOUT; -#else -#endif -#ifdef ENFILE -const error_catalog::value_type error_catalog::too_many_files_open_in_system = ENFILE; -#else -#endif -#ifdef EMFILE -const error_catalog::value_type error_catalog::too_many_files_open = EMFILE; -#else -#endif -#ifdef EMLINK -const error_catalog::value_type error_catalog::too_many_links = EMLINK; -#else -#endif -#ifdef ELOOP -const error_catalog::value_type error_catalog::too_many_synbolic_link_levels = ELOOP; -#else -#endif -#ifdef EAGAIN -const error_catalog::value_type error_catalog::try_again = EAGAIN; -#else -#endif -#ifdef EOVERFLOW -const error_catalog::value_type error_catalog::value_too_large = EOVERFLOW; -#else -#endif -#ifdef EPROTOTYPE -const error_catalog::value_type error_catalog::wrong_protocol_type = EPROTOTYPE; -#else -#endif - -const error_catalog::value_type error_catalog::last_value() const throw() +error_condition error_category::default_error_condition( int err ) const { - return _syserr._last_value; + return error_condition( err, *this ); } -bool error_catalog::is_valid_value( error_catalog::value_type v ) const throw() +bool error_category::equivalent( int code, const error_condition& cnd ) const { - return (v >= 0) && (v <= _syserr._last_value) && (_syserr._sys_err[v] != 0); + return default_error_condition( code ) == cnd; } -const char* error_catalog::str( error_catalog::value_type v ) const throw() +bool error_category::equivalent( const error_code& code, int cnd ) const { - if ( (v < 0) || (v > _syserr._last_value) ) { - return 0; - } + return (*this == code.category()) && (code.value() == cnd); +} - return _syserr._sys_err[v]; +bool error_category::operator ==( const error_category& cat ) const +{ + return this == &cat; } -bool error_catalog::operator ==(const error_catalog& __other) const throw() +bool error_category::operator !=( const error_category& cat ) const { - return (_M_loc == __other.getloc()) && (typeid(*this) == typeid(__other)); + return this != &cat; } -bool error_catalog::operator !=(const error_catalog& __other) const throw() +bool error_category::operator <( const error_category& cat ) const { - return (_M_loc != __other.getloc()) || (typeid(*this) != typeid(__other)); + return this < &cat; } -system_error::system_error( const std::string& s ) : - std::runtime_error( s ) +const error_category& get_posix_category() { + return detail::_posix_error_category; } -system_error::system_error( error_catalog::value_type _v, const error_catalog& _c ) : - std::runtime_error( _c.str( _v ) ) +const error_category& get_system_category() { + return detail::_system_error_category; } } // namespace std This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |