32 lines
978 B
C++
32 lines
978 B
C++
#pragma once
|
|
|
|
#include <filesystem>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace izo {
|
|
|
|
class DynamicLibrary {
|
|
public:
|
|
DynamicLibrary() noexcept = default;
|
|
~DynamicLibrary();
|
|
DynamicLibrary(DynamicLibrary&& other) noexcept;
|
|
DynamicLibrary& operator=(DynamicLibrary&& other) noexcept;
|
|
DynamicLibrary(const DynamicLibrary&) = delete;
|
|
DynamicLibrary& operator=(const DynamicLibrary&) = delete;
|
|
|
|
explicit operator bool() const noexcept { return handle_ != nullptr; }
|
|
void* Symbol(std::string_view name, std::string* errorMessage = nullptr) const;
|
|
void Reset() noexcept;
|
|
|
|
private:
|
|
friend DynamicLibrary LoadDynamicLibrary(const std::filesystem::path&, std::string*);
|
|
explicit DynamicLibrary(void* handle) noexcept : handle_(handle) {}
|
|
void* handle_ = nullptr;
|
|
};
|
|
|
|
DynamicLibrary LoadDynamicLibrary(const std::filesystem::path& path,
|
|
std::string* errorMessage = nullptr);
|
|
|
|
} // namespace izo
|