Base module
SharedLibrary
Loads a shared library at runtime and resolves exported symbols.
SharedLibrary
#include <icy/sharedlibrary.h>Loads a shared library at runtime and resolves exported symbols.
Public Methods
| Return | Name | Description |
|---|---|---|
bool | open inline | Opens a shared library. The filename is in utf-8. Returns true on success and false on error. Call [SharedLibrary::error()](#error-7) to get the error message. |
void | close inline | Closes the shared library. |
bool | sym inline | Retrieves a data pointer from a dynamic library. It is legal for a symbol to map to nullptr. Returns 0 on success and -1 if the symbol was not found. |
void | setError inline | Reads the last libuv dynamic-linker error, stores it in _error, and throws a std::runtime_error with the combined prefix and error message. |
std::string | error const inline | Returns the last error message recorded by setError(). Empty if no error has occurred. |
open
inline
inline bool open(const std::string & path)Opens a shared library. The filename is in utf-8. Returns true on success and false on error. Call [SharedLibrary::error()](#error-7) to get the error message.
close
inline
inline void close()Closes the shared library.
sym
inline
inline bool sym(const char * name, void ** ptr)Retrieves a data pointer from a dynamic library. It is legal for a symbol to map to nullptr. Returns 0 on success and -1 if the symbol was not found.
setError
inline
inline void setError(const std::string & prefix)Reads the last libuv dynamic-linker error, stores it in _error, and throws a std::runtime_error with the combined prefix and error message.
Parameters
prefixHuman-readable context string prepended to the error detail.
Exceptions
std::runtime_erroralways.
error
const inline
inline std::string error() constReturns the last error message recorded by setError(). Empty if no error has occurred.
Returns
Last error string.
Protected Attributes
_lib
uv_lib_t _lib_error
std::string _error