#include <cxxtools/library.h>
Public Member Functions | |
| Library () | |
| Default Constructor which does not load a library. | |
| Library (const std::string &path) | |
| Loads a shared library. | |
| Library (const Library &other) | |
| Library & | operator= (const Library &other) |
| ~Library () | |
| The destructor unloads the shared library from memory. | |
| Library & | open (const std::string &path) |
| Loads a shared library. | |
| void | close () |
| void * | operator[] (const char *symbol) const |
| Resolves the symbol symbol from the shared library Returns the address of the symbol or 0 if it was not found. | |
| void * | resolve (const char *symbol) const |
| Resolves the symbol symbol from the shared library Returns the address of the symbol or 0 if it was not found. | |
| operator const void * () const | |
| Returns null if invalid. | |
| Symbol | getSymbol (const char *symbol) const |
| bool | operator! () const |
| Returns true if invalid. | |
| const std::string & | path () const |
| Returns the path to the shared library image. | |
Static Public Member Functions | |
| static std::string | suffix () |
| Returns the extension for shared libraries. | |
| static std::string | prefix () |
| Returns the prefix for shared libraries. | |
Protected Member Functions | |
| void | detach () |
Library shlib("MyLibrary.dll"); void* procAddr = shlib["myProcedure"]; typedef int (*MyProcType)(); MyProcType proc =(MyProcType)procAddr; int result = proc();
| Library | ( | const std::string & | path | ) | [explicit] |
If a file could not be found at the given path, the path will be extended by the platform-specific shared library extension first and then also by the shared library prefix. If still no file can be found an exception is thrown.
The library is loaded immediately.
| Library& open | ( | const std::string & | path | ) |
If a file could not be found at the given path, the path will be extended by the platform-specific shared library extension first and then also by the shared library prefix. If still no file can be found an exception is thrown. Calling this method twice might close the previously loaded library.
| static std::string suffix | ( | ) | [static] |
Returns ".so" on Linux, ".dll" on Windows.
| static std::string prefix | ( | ) | [static] |
Returns "lib" on Linux, "" on Windows