uvw  2.10.0
lib.h
1 #ifndef UVW_LIB_INCLUDE_H
2 #define UVW_LIB_INCLUDE_H
3 
4 
5 #include <memory>
6 #include <string>
7 #include <type_traits>
8 #include <uv.h>
9 #include "loop.h"
10 #include "underlying_type.hpp"
11 
12 
13 namespace uvw {
14 
15 
22 class SharedLib final: public UnderlyingType<SharedLib, uv_lib_t> {
23 public:
24  explicit SharedLib(ConstructorAccess ca, std::shared_ptr<Loop> ref, const std::string &filename) noexcept;
25 
26  ~SharedLib() noexcept;
27 
32  explicit operator bool() const noexcept;
33 
43  template<typename F>
44  F * sym(const std::string &name) {
45  static_assert(std::is_function_v<F>);
46  F *func;
47  auto err = uv_dlsym(get(), name.data(), reinterpret_cast<void**>(&func));
48  if(err) { func = nullptr; }
49  return func;
50  }
51 
56  const char * error() const noexcept;
57 
58 private:
59  bool opened;
60 };
61 
62 
63 }
64 
65 
66 #ifndef UVW_AS_LIB
67 #include "lib.cpp"
68 #endif
69 
70 
71 #endif // UVW_LIB_INCLUDE_H
The SharedLib class.
Definition: lib.h:22
F * sym(const std::string &name)
Retrieves a data pointer from a dynamic library.
Definition: lib.h:44
const char * error() const noexcept
Returns the last error message, if any.
Wrapper class for underlying types.
uvw default namespace.
Definition: async.h:10