Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/core/StarDynamicLib.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-06-20 14:33:09 +1000
commit6352e8e3196f78388b6c771073f9e03eaa612673 (patch)
treee23772f79a7fbc41bc9108951e9e136857484bf4 /source/core/StarDynamicLib.hpp
parent6741a057e5639280d85d0f88ba26f000baa58f61 (diff)
everything everywhere
all at once
Diffstat (limited to 'source/core/StarDynamicLib.hpp')
-rw-r--r--source/core/StarDynamicLib.hpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/core/StarDynamicLib.hpp b/source/core/StarDynamicLib.hpp
new file mode 100644
index 0000000..c479d8b
--- /dev/null
+++ b/source/core/StarDynamicLib.hpp
@@ -0,0 +1,38 @@
+#ifndef STAR_PLATFORM_HPP
+#define STAR_PLATFORM_HPP
+
+#include "StarString.hpp"
+
+namespace Star {
+
+STAR_CLASS(DynamicLib);
+
+class DynamicLib {
+public:
+ // Returns the library extension normally used on the current platform
+ // including the '.', e.g. '.dll', '.so', '.dylib'
+ static String libraryExtension();
+
+ // Load a dll from the given filename. If the library is found and
+ // succesfully loaded, returns a handle to the library, otherwise nullptr.
+ static DynamicLibUPtr loadLibrary(String const& fileName);
+
+ // Load a dll from the given name, minus extension.
+ static DynamicLibUPtr loadLibraryBase(String const& baseName);
+
+ // Should return handle to currently running executable. Will always
+ // succeed.
+ static DynamicLibUPtr currentExecutable();
+
+ virtual ~DynamicLib() = default;
+
+ virtual void* funcPtr(char const* name) = 0;
+};
+
+inline DynamicLibUPtr DynamicLib::loadLibraryBase(String const& baseName) {
+ return loadLibrary(baseName + libraryExtension());
+}
+
+}
+
+#endif