From 81cf8b68eca2636574f3d0a9fa1cf0b428c163e9 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 1 Aug 2026 04:30:34 +0800 Subject: [Backend] Establish standalone build infrastructure Add the thin monorepo CMake entry point and an independently configurable backend project. Enforce the Clang/C++23 toolchain, expose Make/Ninja-neutral tests and developer checks, export an installable RCCBackend package, and introduce the first Support error abstraction. --- backend/include/rcc/Support/Error.h | 49 +++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 backend/include/rcc/Support/Error.h (limited to 'backend/include/rcc/Support/Error.h') diff --git a/backend/include/rcc/Support/Error.h b/backend/include/rcc/Support/Error.h new file mode 100644 index 0000000..3d50b46 --- /dev/null +++ b/backend/include/rcc/Support/Error.h @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef RCC_SUPPORT_ERROR_H +#define RCC_SUPPORT_ERROR_H + +#include +#include +#include +#include +#include + +namespace rcc { + +enum class ErrorCode : std::uint8_t { + InvalidArgument, + ParseError, + VerificationError, + Unsupported, + IoError, + InternalError, +}; + +[[nodiscard]] std::string_view getErrorCodeName(ErrorCode Code) noexcept; + +class Error final { +public: + Error(ErrorCode Code, std::string Message); + + [[nodiscard]] ErrorCode code() const noexcept { + return Code; + } + [[nodiscard]] std::string_view message() const noexcept { + return Message; + } + +private: + ErrorCode Code; + std::string Message; +}; + +template using Expected = std::expected; + +[[nodiscard]] inline std::unexpected makeUnexpected(ErrorCode Code, std::string Message) { + return std::unexpected(Error(Code, std::move(Message))); +} + +} // namespace rcc + +#endif // RCC_SUPPORT_ERROR_H -- cgit v1.2.3