claw
1.9.0
Toggle main menu visibility
Loading...
Searching...
No Matches
dynamic_library_traits_win32.hpp
Go to the documentation of this file.
1
/*
2
CLAW - a C++ Library Absolutely Wonderful
3
4
CLAW is a free library without any particular aim but being useful to
5
anyone.
6
7
Copyright (C) 2005-2011 Julien Jorge
8
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Lesser General Public
11
License as published by the Free Software Foundation; either
12
version 2.1 of the License, or (at your option) any later version.
13
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
18
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
23
contact: julien.jorge@stuff-o-matic.com
24
*/
30
#ifndef __CLAW_DYNAMIC_LIBRARY_TRAITS_WIN32_HPP__
31
#define __CLAW_DYNAMIC_LIBRARY_TRAITS_WIN32_HPP__
32
33
#include <string>
34
//#include <cstdarg>
35
//#include <windef.h>
36
//#include <winbase.h>
37
#include <windows.h>
38
39
namespace
claw
40
{
45
class
dynamic_library_traits_win32
46
{
47
public
:
49
typedef
HMODULE
handle
;
50
51
public
:
57
static
handle
open
(
const
std::string& name)
58
{
59
return
LoadLibrary(name.c_str());
60
}
61
67
static
handle
auto_open
(
const
std::string& name)
68
{
69
return
LoadLibrary(name.c_str());
70
}
71
76
static
void
close
(
handle
h)
77
{
78
FreeLibrary(h);
79
}
80
86
template
<
class
T>
87
static
T
get_symbol
(
handle
h,
const
std::string& name)
88
{
89
/* HACK : ISO standard doesn't allow to cast from a pointer to an object
90
to a pointer to a function. */
91
T result;
92
*(FARPROC*)(&result) = GetProcAddress(h, name.c_str());
93
94
return
result;
95
}
96
102
static
bool
have_symbol
(
handle
h,
const
std::string& name)
103
{
104
return
GetProcAddress(h, name.c_str()) != NULL;
105
}
106
111
static
bool
valid_handle
(
handle
h)
112
{
113
return
h != NULL;
114
}
115
116
};
// class dynamic_library_traits_win32
117
118
typedef
dynamic_library_traits_win32
dynamic_library_traits
;
119
}
120
121
#endif
// __CLAW_DYNAMIC_LIBRARY_TRAITS_WIN32_HPP__
claw::dynamic_library_traits_win32
Microsoft Windows interface for using dynamic libraries.
Definition
dynamic_library_traits_win32.hpp:46
claw::dynamic_library_traits_win32::handle
HMODULE handle
Type of the system handle to the library.
Definition
dynamic_library_traits_win32.hpp:49
claw::dynamic_library_traits_win32::close
static void close(handle h)
Close a library.
Definition
dynamic_library_traits_win32.hpp:76
claw::dynamic_library_traits_win32::have_symbol
static bool have_symbol(handle h, const std::string &name)
Tell if a symbol is in the library.
Definition
dynamic_library_traits_win32.hpp:102
claw::dynamic_library_traits_win32::open
static handle open(const std::string &name)
Open a library.
Definition
dynamic_library_traits_win32.hpp:57
claw::dynamic_library_traits_win32::get_symbol
static T get_symbol(handle h, const std::string &name)
Get a symbol from a library.
Definition
dynamic_library_traits_win32.hpp:87
claw::dynamic_library_traits_win32::auto_open
static handle auto_open(const std::string &name)
Open the current program.
Definition
dynamic_library_traits_win32.hpp:67
claw::dynamic_library_traits_win32::valid_handle
static bool valid_handle(handle h)
Tell if an handle is a valid library handle.
Definition
dynamic_library_traits_win32.hpp:111
dynamic_library_traits
Common interface for platform specific methods needed for using dynamic library.
claw
This is the main namespace.
Definition
application.hpp:50
lib
dynamic_library
include
claw
dynamic_library
dynamic_library_traits_win32.hpp
Generated by
1.17.0