10#include <system_error>
23 return std::format(
"{} (error {})", std::system_category().
message(
static_cast<int>(
code)),
code);
26static void*
OpenLibrary(
const std::filesystem::path& path)
46 return message !=
nullptr ? std::string(
message) : std::string(
"no message");
79 _handle = std::exchange(
other._handle,
nullptr);
97 if (_handle ==
nullptr)
99 return std::unexpected(
Error::NotReady(std::format(
"cannot look up {}: nothing is loaded", name)));
111void SharedLibrary::Close()
113 if (_handle ==
nullptr)
static Result< SharedLibrary > Open(const std::filesystem::path &path)
Result< void * > Symbol(const char *name) const
SharedLibrary & operator=(SharedLibrary &&other) noexcept
static std::string LastError()
static void * OpenLibrary(const std::filesystem::path &path)
static std::string ReadFile(const std::filesystem::path &path)
std::expected< T, Error > Result
static void * FindExport(void *handle, const char *name)
static void CloseLibrary(void *handle)
static Error Failed(std::string detail)
static Error NotFound(std::string detail)
static Error NotReady(std::string detail)