upload codebase

Signed-off-by: Double Sine <xiao_ai_yu@live.cn>
This commit is contained in:
Double Sine
2022-02-14 15:47:41 +08:00
commit 9017721a5c
43 changed files with 4615 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
#pragma once
#include "../exception.hpp"
namespace nkg::exceptions {
class index_exception : public ::nkg::exception {
public:
index_exception(std::string_view file, int line, std::string_view message) noexcept :
::nkg::exception(file, line, message) {}
};
}

View File

@@ -0,0 +1,12 @@
#pragma once
#include "../exception.hpp"
namespace nkg::exceptions {
class key_exception : public ::nkg::exception {
public:
key_exception(std::string_view file, int line, std::string_view message) noexcept :
::nkg::exception(file, line, message) {}
};
}

View File

@@ -0,0 +1,12 @@
#pragma once
#include "../exception.hpp"
namespace nkg::exceptions {
class operation_canceled_exception : public ::nkg::exception {
public:
operation_canceled_exception(std::string_view file, int line, std::string_view message) noexcept :
::nkg::exception(file, line, message) {}
};
}

View File

@@ -0,0 +1,36 @@
#pragma once
#include <errno.h>
#include <string.h>
#include "../exception.hpp"
namespace nkg::exceptions {
class unix_exception : public ::nkg::exception {
public:
using error_code_t = decltype(errno);
private:
error_code_t m_error_code;
std::string m_error_string;
public:
unix_exception(std::string_view file, int line, error_code_t unix_errno, std::string_view message) noexcept :
::nkg::exception(file, line, message), m_error_code(unix_errno), m_error_string(strerror(unix_errno)) {}
[[nodiscard]]
virtual bool error_code_exists() const noexcept override {
return true;
}
[[nodiscard]]
virtual intptr_t error_code() const noexcept override {
return m_error_code;
}
[[nodiscard]]
virtual const std::string& error_string() const noexcept override {
return m_error_string;
}
};
}