Engine → Core → dynamic_library.h
dynamic_library
| Type | Class |
| Namespace | conjure::core |
| Include File Path | engine/include/conjure/core/dynamic_library.h |
| Source File Path | engine/src/core/system/dynamic_library.cpp |
| API ↗ | Processes, libraries and images |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | dynamic_library(); | |
| public | dynamic_library(
dynamic_library &&other) noexcept; |
Important
Copy constructor and assignment has been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~dynamic_library(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mHandle | void * | nullptr | |
| private | mPath | std::filesystem::path | {} |
Functions
Public
decorate_name
decorate_name[[nodiscard]] static std::string decorate_name(
std::string_view baseName);The platform file name of a library: "conjure_foo" becomes "conjure_foo.dll", "libconjure_foo.so" or "libconjure_foo.dylib". A name that already ends in the platform extension is returned unchanged.
extension
extension[[nodiscard]] static std::string_view extension() noexcept;The platform's library extension including the dot: ".dll", ".so" or ".dylib".
is_loaded
is_loaded[[nodiscard]] bool is_loaded() const noexcept;True while a library is loaded.
load
load[[nodiscard]] static result<dynamic_library> load(
const std::filesystem::path &path);Loads a library (LoadLibraryW / dlopen with RTLD_NOW | RTLD_LOCAL). A bare file name is resolved through the operating system's library search path. Fails with INVALID_ARGUMENT for an empty path, NOT_FOUND when the file does not exist and BACKEND_FAILURE otherwise; the message carries the operating system's error text.
path
path[[nodiscard]] const std::filesystem::path &path() const noexcept;The path given to load(), empty when nothing is loaded.
prefix
prefix[[nodiscard]] static std::string_view prefix() noexcept;The platform's library prefix: "" on Windows, "lib" elsewhere.
symbol
symbol[[nodiscard]] void *symbol(
const char *name) const noexcept;Address of an exported symbol, nullptr when it does not exist or nothing is loaded.
symbol_as
symbol_astemplate <typename Fn> [[nodiscard]] Fn symbol_as(
const char *name) const noexcept;symbol() converted to a pointer type, typically a function pointer. Returns nullptr when the symbol does not exist.
unload
unloadvoid unload() noexcept;Unloads the library now. Safe to call when nothing is loaded.
Operator Overloads
Public
operator=
operator=dynamic_library &operator=(
dynamic_library &&other) noexcept;