mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 18:53:28 +01:00
42 lines
708 B
C++
42 lines
708 B
C++
#include <string>
|
|
|
|
namespace utils
|
|
{
|
|
class dynamic_library
|
|
{
|
|
void *m_handle = nullptr;
|
|
|
|
public:
|
|
dynamic_library() = default;
|
|
dynamic_library(const std::string &path);
|
|
|
|
~dynamic_library();
|
|
|
|
bool load(const std::string &path);
|
|
void close();
|
|
|
|
private:
|
|
void *get_impl(const std::string &name) const;
|
|
|
|
public:
|
|
template<typename Type = void>
|
|
Type *get(const std::string &name) const
|
|
{
|
|
Type *result;
|
|
*(void **)(&result) = get_impl(name);
|
|
return result;
|
|
}
|
|
|
|
template<typename Type>
|
|
bool get(Type *&function, const std::string &name) const
|
|
{
|
|
*(void **)(&function) = get_impl(name);
|
|
|
|
return !!function;
|
|
}
|
|
|
|
bool loaded() const;
|
|
explicit operator bool() const;
|
|
};
|
|
}
|