13 #ifndef __STOUT_WINDOWS_DYNAMICLIBRARY_HPP__ 14 #define __STOUT_WINDOWS_DYNAMICLIBRARY_HPP__ 41 if (handle_ !=
nullptr) {
49 if (handle_ !=
nullptr) {
50 return Error(
"Library already opened");
53 handle_ = ::LoadLibraryW(wide_stringify(path).data());
55 if (handle_ ==
nullptr) {
56 return WindowsError(
"Could not load library '" + path +
"'");
66 if (handle_ ==
nullptr) {
67 return Error(
"Could not close library; handle was already `nullptr`");
70 if (!::FreeLibrary(handle_)) {
72 "Could not close library '" + (path_.
isSome() ? path_.
get() :
""));
83 if (handle_ ==
nullptr) {
85 "Could not get symbol '" + name +
"'; library handle was `nullptr`");
88 void* symbol = ::GetProcAddress(handle_, name.c_str());
90 if (symbol ==
nullptr) {
92 "Error looking up symbol '" + name +
"' in '" +
104 #endif // __STOUT_WINDOWS_DYNAMICLIBRARY_HPP__
Try< Nothing > open(const std::string &path)
Definition: dynamiclibrary.hpp:46
Definition: nothing.hpp:16
Definition: errorbase.hpp:36
Definition: error.hpp:108
Try< void * > loadSymbol(const std::string &name)
Definition: dynamiclibrary.hpp:81
bool isSome() const
Definition: option.hpp:116
const T & get() const &
Definition: option.hpp:119
DynamicLibrary is a very simple wrapper around the programming interface to the dynamic linking loade...
Definition: dynamiclibrary.hpp:29
DynamicLibrary()
Definition: dynamiclibrary.hpp:31
Try< Nothing > close()
Definition: dynamiclibrary.hpp:62
virtual ~DynamicLibrary()
Definition: dynamiclibrary.hpp:39
constexpr const char * name
Definition: shell.hpp:41