| | |
| | |
| | |
| |
|
| | #pragma once |
| |
|
| | #include <string> |
| |
|
| | namespace Common { |
| |
|
| | class DynamicLibrary { |
| | public: |
| | explicit DynamicLibrary(); |
| | explicit DynamicLibrary(void* handle); |
| | explicit DynamicLibrary(std::string_view name, int major = -1, int minor = -1); |
| | ~DynamicLibrary(); |
| |
|
| | |
| | [[nodiscard]] bool IsLoaded() const noexcept { |
| | return handle != nullptr; |
| | } |
| |
|
| | |
| | |
| | [[nodiscard]] bool Load(std::string_view filename); |
| |
|
| | |
| | [[nodiscard]] std::string_view GetLoadError() const { |
| | return load_error; |
| | } |
| |
|
| | |
| | template <typename T> |
| | [[nodiscard]] T GetSymbol(std::string_view name) const { |
| | return reinterpret_cast<T>(GetRawSymbol(name)); |
| | } |
| |
|
| | |
| | |
| | |
| | [[nodiscard]] static std::string GetLibraryName(std::string_view name, int major = -1, |
| | int minor = -1); |
| |
|
| | private: |
| | void* GetRawSymbol(std::string_view name) const; |
| |
|
| | void* handle; |
| | std::string load_error; |
| | }; |
| |
|
| | } |
| |
|