9 #ifndef CPPCOMMON_SYSTEM_DLL_H
10 #define CPPCOMMON_SYSTEM_DLL_H
13 #include "system/exceptions.h"
27 #if defined(_WIN32) || defined(_WIN64)
29 #define EXPORT __declspec(dllexport)
31 #define EXPORT __declspec(dllimport)
45 #define API extern "C" EXPORT
75 explicit operator bool()
const {
return IsLoaded(); }
84 bool IsResolve(
const std::string& name)
const;
110 template <
typename T>
111 T*
Resolve(
const std::string& name)
const;
123 static std::string
prefix();
136 friend void swap(
DLL& dll1,
DLL& dll2) noexcept;
141 Impl& impl() noexcept {
return reinterpret_cast<Impl&
>(_storage); }
142 const Impl& impl() const noexcept {
return reinterpret_cast<Impl const&
>(_storage); }
144 static const size_t StorageSize = 48;
145 static const size_t StorageAlign = 8;
146 alignas(StorageAlign) std::byte _storage[StorageSize];
153 void* ResolveAddress(
const std::string& name)
const;
static std::string extension()
Get the dynamic link library extension.
DLL & operator=(const Path &path)
T * Resolve(const std::string &name) const
Resolve dynamic link library symbol by the given name.
static std::string prefix()
Get the dynamic link library prefix.
bool IsResolve(const std::string &name) const
Is dynamic link library resolve the given symbol?
bool Load()
Load dynamic link library.
void Unload()
Unload dynamic link library.
void swap(DLL &dll) noexcept
Swap two instances.
DLL()
Initialize the dynamic link library with an empty path.
const Path path() const
Get the dynamic link library path.
bool IsLoaded() const
Is dynamic link library loaded?
Dynamic link library inline implementation.
C++ Common project definitions.
Filesystem path definition.