2023-07-03 13:10:16 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
namespace orbis {
|
|
|
|
|
enum class ErrorCode : int;
|
|
|
|
|
|
|
|
|
|
class SysResult {
|
|
|
|
|
int mValue = 0;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
SysResult() = default;
|
2023-07-06 18:16:25 +02:00
|
|
|
SysResult(ErrorCode ec) : mValue(-static_cast<int>(ec)) {}
|
2023-07-03 13:10:16 +02:00
|
|
|
|
|
|
|
|
[[nodiscard]] static SysResult notAnError(ErrorCode ec) {
|
|
|
|
|
SysResult result;
|
|
|
|
|
result.mValue = static_cast<int>(ec);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] int value() const { return mValue < 0 ? -mValue : mValue; }
|
|
|
|
|
[[nodiscard]] bool isError() const { return mValue < 0; }
|
|
|
|
|
};
|
|
|
|
|
} // namespace orbis
|