Skip to content

Engine → Core → dynamic_library.h

dynamic_library

Syntax

class CONJURE_API dynamic_library

Constructors

AccessSignatureDescription
publicdynamic_library();
publicdynamic_library( dynamic_library &&other) noexcept;

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~dynamic_library();

Variables

AccessNameTypeDefaultDescription
privatemHandlevoid *nullptr
privatemPathstd::filesystem::path{}

Functions

Public

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

[[nodiscard]] static std::string_view extension() noexcept;

The platform's library extension including the dot: ".dll", ".so" or ".dylib".

is_loaded

[[nodiscard]] bool is_loaded() const noexcept;

True while a library is loaded.

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

[[nodiscard]] const std::filesystem::path &path() const noexcept;

The path given to load(), empty when nothing is loaded.

prefix

[[nodiscard]] static std::string_view prefix() noexcept;

The platform's library prefix: "" on Windows, "lib" elsewhere.

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

template <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

void unload() noexcept;

Unloads the library now. Safe to call when nothing is loaded.

Operator Overloads

Public

operator=

dynamic_library &operator=(
    dynamic_library &&other) noexcept;