11 #if ((XTD_OS_LINUX | XTD_OS_CYGWIN | XTD_OS_MSYS) & XTD_OS)
24 #if ((XTD_OS_WINDOWS | XTD_OS_MINGW) & XTD_OS)
25 :
public xtd::windows::exception{
26 using _super_t = xtd::windows::exception;
27 #elif ((XTD_OS_LINUX | XTD_OS_CYGWIN | XTD_OS_MSYS) & XTD_OS)
33 template <
typename _ReturnT,
typename _ExpressionT>
34 inline static _ReturnT _throw_if(
const xtd::source_location& source, _ReturnT ret, _ExpressionT exp,
const char* expstr){
36 #if ((XTD_OS_WINDOWS | XTD_OS_MINGW) & XTD_OS)
38 #elif ((XTD_OS_LINUX | XTD_OS_CYGWIN | XTD_OS_MSYS) & XTD_OS)
53 #if ((XTD_OS_WINDOWS | XTD_OS_MINGW) & XTD_OS)
54 using native_handle_type = HMODULE;
55 #elif ((XTD_OS_LINUX | XTD_OS_CYGWIN | XTD_OS_MSYS) & XTD_OS)
56 using native_handle_type =
void *;
59 using pointer = std::shared_ptr<dynamic_library>;
60 using map = std::map<xtd::filesystem::path, pointer>;
62 static inline pointer make(
const char * spath){
return pointer(
new dynamic_library(spath)); }
65 native_handle_type handle()
const{
return _Handle; }
67 template <
typename _ReturnT,
typename ... _ArgsT>
70 using function_pointer_type = _ReturnT(*)(_ArgsT...);
72 inline _ReturnT operator()(_ArgsT...oArgs)
const{
73 return _function_pointer(std::forward<_ArgsT>(oArgs)...);
78 function(
const function& src) : _function_pointer(src._function_pointer), _library(src._library){}
79 function& operator=(
const function& src){
83 _function_pointer = src._function_pointer;
84 _library = src._library;
89 function(function_pointer_type fnptr, dynamic_library::pointer oLib) : _function_pointer(fnptr), _library(oLib){}
90 function_pointer_type _function_pointer =
nullptr;
91 dynamic_library::pointer _library;
98 src._Handle =
nullptr;
104 _Handle = src._Handle;
105 src._Handle =
nullptr;
108 #if ((XTD_OS_WINDOWS | XTD_OS_MINGW) & XTD_OS)
111 FreeLibrary(_Handle);
114 #elif ((XTD_OS_LINUX | XTD_OS_CYGWIN) & XTD_OS)
122 template <
typename _ReturnT,
typename ... _ArgsT>
function <_ReturnT, _ArgsT...>
get(
const char * name){
123 using return_type =
function <_ReturnT, _ArgsT...>;
124 #if ((XTD_OS_WINDOWS | XTD_OS_MINGW) & XTD_OS)
126 #elif ((XTD_OS_LINUX | XTD_OS_CYGWIN | XTD_OS_MSYS) & XTD_OS)
129 return return_type(fnptr, shared_from_this());
134 friend class process;
136 #if ((XTD_OS_WINDOWS | XTD_OS_MINGW) & XTD_OS)
137 explicit dynamic_library(
const tchar * sPath) : _Handle(xtd::exception::
throw_if(LoadLibrary(sPath), [](HMODULE h){
return (INVALID_HANDLE_VALUE == h ||
nullptr == h); })){}
138 #elif ((XTD_OS_LINUX | XTD_OS_CYGWIN | XTD_OS_MSYS) & XTD_OS)
139 explicit dynamic_library(
const char * sPath) : _Handle(xtd::dynamic_library_exception::
throw_if(dlopen(sPath, RTLD_LAZY), [](native_handle_type h){
return nullptr == h; })){}
142 explicit dynamic_library(native_handle_type hHandle) : _Handle(hHandle){}
144 native_handle_type _Handle;
host, target and build configurations and settings Various components are purpose built for specific ...
#define throw_if(_test, _expression)
Simplifies use of exception::_throw_if.
generic and special purpose exceptions
handle necessary filesystem and path functionality until C++17 is finalized
Contains information about the location of source code Used in error reporting and logging...