mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 16:31:28 +12:00
Added dynamic_library utility
This commit is contained in:
parent
b52e885cde
commit
795170635f
5 changed files with 110 additions and 1 deletions
41
Utilities/dynamic_library.h
Normal file
41
Utilities/dynamic_library.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
#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;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue