Usermode/libc++ - Implement map::insert and map::erase
[tpg/acess2.git] / Usermode / Libraries / libc++.so_src / system_error.cc
1 /*
2  * Acess2 C++ Library
3  * - By John Hodge (thePowersGang)
4  *
5  * system_error.cc
6  * - ::std::system_error and other helpers
7  */
8 #include <system_error>
9 #include <cerrno>
10
11 namespace std {
12
13 system_error::system_error(::std::error_code ec):
14         m_error_code(ec),
15         m_what_str( (::std::string)ec.category().name() + ":" + ec.message())
16 {
17         ::_sys::debug("system_error(%s:%s)", ec.category().name(), ec.message().c_str());
18 }
19 system_error::system_error(::std::error_code ec, const ::std::string& what_arg):
20         system_error(ec)
21 {
22         m_what_str += " - ";
23         m_what_str += what_arg;
24 }
25 system_error::system_error(::std::error_code ec, const char* what_arg):
26         system_error(ec)
27 {
28         m_what_str += " - ";
29         m_what_str += what_arg;
30 }
31 system_error::system_error(int ev, const ::std::error_category& ecat):
32         system_error( ::std::error_code(ev, ecat) )
33 {
34 }
35 system_error::system_error(int ev, const ::std::error_category& ecat, const ::std::string& what_arg):
36         system_error(ev, ecat)
37 {
38         m_what_str += " - ";
39         m_what_str += what_arg;
40 }
41 system_error::system_error(int ev, const ::std::error_category& ecat, const char* what_arg):
42         system_error(ev, ecat)
43 {
44         m_what_str += " - ";
45         m_what_str += what_arg;
46 }
47
48 system_error::~system_error() noexcept
49 {
50 }
51
52 const char* system_error::what() const noexcept
53 {
54         return m_what_str.c_str();
55 }
56
57
58 bool error_category::equivalent(const error_code& code, int valcond) const noexcept {
59         return *this == code.category() && code.value() == valcond;
60 }
61
62
63 class class_generic_category:
64         public error_category
65 {
66 public:
67         class_generic_category() {
68         }
69         ~class_generic_category() noexcept {
70         }
71         const char *name() const noexcept {
72                 return "generic";
73         }
74         ::std::string message(int val) const {
75                 return ::std::string( ::strerror(val) );
76         }
77 } g_generic_category;
78
79 const ::std::error_category& generic_category() noexcept
80 {
81         return g_generic_category;
82 }
83
84
85 class class_system_category:
86         public error_category
87 {
88 public:
89         class_system_category() {
90         }
91         ~class_system_category() noexcept {
92         }
93         const char *name() const noexcept {
94                 return "system";
95         }
96         ::std::string message(int val) const {
97                 return ::std::string( ::strerror(val) );
98         }
99 } g_system_category;
100
101 const ::std::error_category& system_category() noexcept
102 {
103         return g_system_category;
104 }
105
106 };      // namespace std
107

UCC git Repository :: git.ucc.asn.au