library/win32: conform to the template query signature
This commit is contained in:
parent
eb4a3be352
commit
7e1b14fe98
@ -22,16 +22,26 @@ library::library (const std::experimental::filesystem::path &path):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
library::library (library &&rhs):
|
||||||
|
m_handle (nullptr)
|
||||||
|
{
|
||||||
|
std::swap (m_handle, rhs.m_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
library&
|
||||||
|
library::operator= (cruft::library &&rhs)
|
||||||
|
{
|
||||||
|
std::swap (m_handle, rhs.m_handle);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
library::~library ()
|
library::~library ()
|
||||||
{
|
{
|
||||||
|
if (m_handle)
|
||||||
FreeLibrary (m_handle);
|
FreeLibrary (m_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
void*
|
|
||||||
library::symbol (const char *name)
|
|
||||||
{
|
|
||||||
return reinterpret_cast<void*> (GetProcAddress (m_handle, name));
|
|
||||||
}
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#ifndef __UTIL_LIBRARY_WIN32_HPP
|
#ifndef __UTIL_LIBRARY_WIN32_HPP
|
||||||
#define __UTIL_LIBRARY_WIN32_HPP
|
#define __UTIL_LIBRARY_WIN32_HPP
|
||||||
|
|
||||||
|
#include <cruft/util/cast.hpp>
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include <experimental/filesystem>
|
#include <experimental/filesystem>
|
||||||
@ -18,9 +20,21 @@ namespace cruft {
|
|||||||
class library {
|
class library {
|
||||||
public:
|
public:
|
||||||
explicit library (const std::experimental::filesystem::path&);
|
explicit library (const std::experimental::filesystem::path&);
|
||||||
|
library (library const&) = delete;
|
||||||
|
library& operator=(library const&) = delete;
|
||||||
|
library (library&&);
|
||||||
|
library& operator= (library&&);
|
||||||
|
|
||||||
~library ();
|
~library ();
|
||||||
|
|
||||||
void* symbol (const char *name);
|
template <typename FunctionT>
|
||||||
|
FunctionT
|
||||||
|
symbol (const char *name)
|
||||||
|
{
|
||||||
|
return cast::ffs<FunctionT> (
|
||||||
|
GetProcAddress (m_handle, name)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HMODULE m_handle;
|
HMODULE m_handle;
|
||||||
|
Loading…
Reference in New Issue
Block a user