initial upload

This commit is contained in:
2026-02-26 12:09:40 -06:00
parent 102beb1f6f
commit 8f208f436c
16 changed files with 1183 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
#pragma once
#include <ckitty/memory/primitives.hpp>
#include <sstream>
#include <iomanip>
namespace ckitty {
struct error {
i32 code;
std::string message;
error(i32 code = 0, const std::string& msg = "")
: code(code), message(msg) {
}
operator bool() const {
return code;
}
operator std::string() const {
std::ostringstream oss;
oss << "[" << std::hex << std::showbase << std::uppercase << std::setw(2) << std::setfill('0') << code << "] ";
oss << (message.empty() ? "(no info)" : message);
return oss.str();
}
error& operator+=(const error& err) {
auto err1 = (*this) + err;
code = err1.code;
message = err1.message;
return *this;
}
error operator+(const error& err) const {
// If this error has no code (no error), return the other error
if (code == 0) {
return err;
}
// If the other error has no code, return this error
if (err.code == 0) {
return *this;
}
// Both errors have codes, combine them
error result = *this;
// Combine messages
if (!result.message.empty()) {
result.message += "\n ";
}
// add next error to the message
result.message += err.operator std::string();
return result;
}
};
}