ReXGlue SDK
Loading...
Searching...
No Matches
rex::platform::DynamicLibrary Class Reference

#include <rex/platform/dynlib.h>

Inheritance diagram for rex::platform::DynamicLibrary:
[legend]

Public Member Functions

 DynamicLibrary (DynamicLibrary &&other) noexcept
DynamicLibrary & operator= (DynamicLibrary &&other) noexcept
bool Load (const std::filesystem::path &path, SymbolResolution mode=SymbolResolution::kLazy)
bool LoadNamed (std::string_view name, SymbolResolution mode=SymbolResolution::kLazy)
bool Attach (const std::filesystem::path &path)
void Close ()
 operator bool () const
void * GetRawSymbol (const char *name) const
template<typename T>
T GetSymbol (const char *name) const
const std::string & GetLastError () const

Additional Inherited Members

Protected Member Functions inherited from rex::MoveOnly
 MoveOnly (MoveOnly &&)=default
MoveOnly & operator= (MoveOnly &&)=default
 MoveOnly (const MoveOnly &)=delete
MoveOnly & operator= (const MoveOnly &)=delete

Detailed Description

Loads a shared library and resolves symbols from it. Move only.

Member Function Documentation

◆ Attach()

bool rex::platform::DynamicLibrary::Attach ( const std::filesystem::path & path)

Opens the library only when the process has it mapped. Closes any held library.

Parameters
pathFull path or file name of the library.
Returns
True when the library was mapped. It is never loaded.

◆ Close()

void rex::platform::DynamicLibrary::Close ( )

Closes the library. Safe when nothing is loaded.

◆ GetLastError()

const std::string & rex::platform::DynamicLibrary::GetLastError ( ) const
inline

Returns the OS error text of the last failed Load, empty after a success.

◆ GetRawSymbol()

void * rex::platform::DynamicLibrary::GetRawSymbol ( const char * name) const

Returns the address of an exported symbol, or null when the library is not loaded or has no such symbol.

◆ GetSymbol()

template<typename T>
T rex::platform::DynamicLibrary::GetSymbol ( const char * name) const
inline

Typed form of GetRawSymbol.

Returns
The symbol cast to T, or null.

◆ Load()

bool rex::platform::DynamicLibrary::Load ( const std::filesystem::path & path,
SymbolResolution mode = SymbolResolution::kLazy )

Loads the library at the path, closing any held library.

Parameters
modeSymbol resolution mode. Informational on Windows.
Returns
True on success. On failure GetLastError() holds the OS text.

◆ LoadNamed()

bool rex::platform::DynamicLibrary::LoadNamed ( std::string_view name,
SymbolResolution mode = SymbolResolution::kLazy )

Loads a library target from the folder rexbase was loaded from, or else from the executable folder, adding the platform prefix and extension. Closes any held library.


The documentation for this class was generated from the following file: