Usermode/libc++ - system_error and vector implementation
[tpg/acess2.git] / Usermode / Libraries / libc++.so_src / system_error.cc
diff --git a/Usermode/Libraries/libc++.so_src/system_error.cc b/Usermode/Libraries/libc++.so_src/system_error.cc
new file mode 100644 (file)
index 0000000..59f25f9
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Acess2 C++ Library
+ * - By John Hodge (thePowersGang)
+ *
+ * system_error.cc
+ * - ::std::system_error and other helpers
+ */
+#include <system_error>
+#include <cerrno>
+
+namespace std {
+
+system_error::system_error(::std::error_code ec):
+       m_error_code(ec),
+       m_what_str( (::std::string)ec.category().name() + ":" + ec.message())
+{
+}
+system_error::system_error(::std::error_code ec, const ::std::string& what_arg):
+       m_error_code(ec)
+{
+       m_what_str += " - ";
+       m_what_str += what_arg;
+}
+system_error::system_error(::std::error_code ec, const char* what_arg):
+       m_error_code(ec)
+{
+       m_what_str += " - ";
+       m_what_str += what_arg;
+}
+system_error::system_error(int ev, const ::std::error_category& ecat):
+       m_error_code(ev, ecat)
+{
+}
+system_error::system_error(int ev, const ::std::error_category& ecat, const ::std::string& what_arg):
+       m_error_code(ev, ecat)
+{
+       m_what_str += " - ";
+       m_what_str += what_arg;
+}
+system_error::system_error(int ev, const ::std::error_category& ecat, const char* what_arg):
+       m_error_code(ev, ecat)
+{
+       m_what_str += " - ";
+       m_what_str += what_arg;
+}
+
+system_error::~system_error() noexcept
+{
+}
+
+const char* system_error::what() const noexcept
+{
+       return m_what_str.c_str();
+}
+
+
+bool error_category::equivalent(const error_code& code, int valcond) const noexcept {
+       return *this == code.category() && code.value() == valcond;
+}
+
+
+class class_generic_category:
+       public error_category
+{
+public:
+       class_generic_category() {
+       }
+       ~class_generic_category() noexcept {
+       }
+       const char *name() const noexcept {
+               return "generic";
+       }
+       ::std::string message(int val) const {
+               return ::std::string( ::strerror(val) );
+       }
+} g_generic_category;
+
+const ::std::error_category& generic_category() noexcept
+{
+       return g_generic_category;
+}
+
+
+class class_system_category:
+       public error_category
+{
+public:
+       class_system_category() {
+       }
+       ~class_system_category() noexcept {
+       }
+       const char *name() const noexcept {
+               return "system";
+       }
+       ::std::string message(int val) const {
+               return ::std::string( ::strerror(val) );
+       }
+} g_system_category;
+
+const ::std::error_category& system_category() noexcept
+{
+       return g_system_category;
+}
+
+};     // namespace std
+

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