3 * - By John Hodge (thePowersGang)
6 * - ::std::system_error and other helpers
8 #include <system_error>
13 system_error::system_error(::std::error_code ec):
15 m_what_str( (::std::string)ec.category().name() + ":" + ec.message())
18 system_error::system_error(::std::error_code ec, const ::std::string& what_arg):
22 m_what_str += what_arg;
24 system_error::system_error(::std::error_code ec, const char* what_arg):
28 m_what_str += what_arg;
30 system_error::system_error(int ev, const ::std::error_category& ecat):
31 m_error_code(ev, ecat)
34 system_error::system_error(int ev, const ::std::error_category& ecat, const ::std::string& what_arg):
35 m_error_code(ev, ecat)
38 m_what_str += what_arg;
40 system_error::system_error(int ev, const ::std::error_category& ecat, const char* what_arg):
41 m_error_code(ev, ecat)
44 m_what_str += what_arg;
47 system_error::~system_error() noexcept
51 const char* system_error::what() const noexcept
53 return m_what_str.c_str();
57 bool error_category::equivalent(const error_code& code, int valcond) const noexcept {
58 return *this == code.category() && code.value() == valcond;
62 class class_generic_category:
66 class_generic_category() {
68 ~class_generic_category() noexcept {
70 const char *name() const noexcept {
73 ::std::string message(int val) const {
74 return ::std::string( ::strerror(val) );
78 const ::std::error_category& generic_category() noexcept
80 return g_generic_category;
84 class class_system_category:
88 class_system_category() {
90 ~class_system_category() noexcept {
92 const char *name() const noexcept {
95 ::std::string message(int val) const {
96 return ::std::string( ::strerror(val) );
100 const ::std::error_category& system_category() noexcept
102 return g_system_category;