Usermode/libc++ - system_error and vector implementation
[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 }
18 system_error::system_error(::std::error_code ec, const ::std::string& what_arg):
19         m_error_code(ec)
20 {
21         m_what_str += " - ";
22         m_what_str += what_arg;
23 }
24 system_error::system_error(::std::error_code ec, const char* what_arg):
25         m_error_code(ec)
26 {
27         m_what_str += " - ";
28         m_what_str += what_arg;
29 }
30 system_error::system_error(int ev, const ::std::error_category& ecat):
31         m_error_code(ev, ecat)
32 {
33 }
34 system_error::system_error(int ev, const ::std::error_category& ecat, const ::std::string& what_arg):
35         m_error_code(ev, ecat)
36 {
37         m_what_str += " - ";
38         m_what_str += what_arg;
39 }
40 system_error::system_error(int ev, const ::std::error_category& ecat, const char* what_arg):
41         m_error_code(ev, ecat)
42 {
43         m_what_str += " - ";
44         m_what_str += what_arg;
45 }
46
47 system_error::~system_error() noexcept
48 {
49 }
50
51 const char* system_error::what() const noexcept
52 {
53         return m_what_str.c_str();
54 }
55
56
57 bool error_category::equivalent(const error_code& code, int valcond) const noexcept {
58         return *this == code.category() && code.value() == valcond;
59 }
60
61
62 class class_generic_category:
63         public error_category
64 {
65 public:
66         class_generic_category() {
67         }
68         ~class_generic_category() noexcept {
69         }
70         const char *name() const noexcept {
71                 return "generic";
72         }
73         ::std::string message(int val) const {
74                 return ::std::string( ::strerror(val) );
75         }
76 } g_generic_category;
77
78 const ::std::error_category& generic_category() noexcept
79 {
80         return g_generic_category;
81 }
82
83
84 class class_system_category:
85         public error_category
86 {
87 public:
88         class_system_category() {
89         }
90         ~class_system_category() noexcept {
91         }
92         const char *name() const noexcept {
93                 return "system";
94         }
95         ::std::string message(int val) const {
96                 return ::std::string( ::strerror(val) );
97         }
98 } g_system_category;
99
100 const ::std::error_category& system_category() noexcept
101 {
102         return g_system_category;
103 }
104
105 };      // namespace std
106

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