X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2Fstlplus%2Fportability%2Fdynaload.hpp;fp=src%2Fstlplus%2Fportability%2Fdynaload.hpp;h=edfee988e2f8a60e36f0ba4695a9cbf3dd801252;hp=d35d324112497f6937255115f7902c0b3dbe52b8;hb=4f6e4488a55f7e3ba3f7485d78177f793c0eab9a;hpb=574af38ed616d1adfa5e6ce35f67cda1f707f89d diff --git a/src/stlplus/portability/dynaload.hpp b/src/stlplus/portability/dynaload.hpp index d35d324..edfee98 100644 --- a/src/stlplus/portability/dynaload.hpp +++ b/src/stlplus/portability/dynaload.hpp @@ -1,86 +1,86 @@ -#ifndef STLPLUS_DYNALOAD -#define STLPLUS_DYNALOAD -//////////////////////////////////////////////////////////////////////////////// - -// Author: Andy Rushton -// Copyright: (c) Southampton University 1999-2004 -// (c) Andy Rushton 2004-2009 -// License: BSD License, see ../docs/license.html - -// A portable interface to the dynamic loader - i.e. the system for loading -// dynamic libraries or shared libraries during the running of a program, -// rather than by linking - -//////////////////////////////////////////////////////////////////////////////// -#include "portability_fixes.hpp" -#include - -namespace stlplus -{ - - ////////////////////////////////////////////////////////////////////////////// - // dynaload class manages a dynamic loadable library and unloads it on destruction - - class dynaload - { - public: - - //////////////////////////////////////////////////////////////////////////// - // library management - - // construct the object but do not load - dynaload(void); - - // construct and load - dynaload(const std::string& library); - - // destroy and unload if loaded - ~dynaload(void); - - // load the library - return success or fail - bool load(const std::string& library); - - // unload the library if loaded - bool unload(void); - - // test whether the library is loaded - bool loaded(void) const; - - //////////////////////////////////////////////////////////////////////////// - // symbol management - - // test whether a function is exported by the library - bool present(const std::string& name); - - // get the function as a generic pointer - void* symbol(const std::string& name); - - //////////////////////////////////////////////////////////////////////////// - // error management - - // enum values to indicate type of error - enum error_t {no_error, load_error, unload_error, symbol_error}; - - // test whether there has been an error - bool error(void) const; - - // clear an error once it has been handled (or ignored) - void clear_error(void); - - // get the type of the error as indicated by the enum error_t - error_t error_type(void) const; - - // get the text of the error as provided by the OS - std::string error_text(void) const; - - //////////////////////////////////////////////////////////////////////////// - - private: - void* m_handle; - error_t m_error; - std::string m_text; - }; - -} - -#endif +#ifndef STLPLUS_DYNALOAD +#define STLPLUS_DYNALOAD +//////////////////////////////////////////////////////////////////////////////// + +// Author: Andy Rushton +// Copyright: (c) Southampton University 1999-2004 +// (c) Andy Rushton 2004 onwards +// License: BSD License, see ../docs/license.html + +// A portable interface to the dynamic loader - i.e. the system for loading +// dynamic libraries or shared libraries during the running of a program, +// rather than by linking + +//////////////////////////////////////////////////////////////////////////////// +#include "portability_fixes.hpp" +#include + +namespace stlplus +{ + + ////////////////////////////////////////////////////////////////////////////// + // dynaload class manages a dynamic loadable library and unloads it on destruction + + class dynaload + { + public: + + //////////////////////////////////////////////////////////////////////////// + // library management + + // construct the object but do not load + dynaload(void); + + // construct and load + dynaload(const std::string& library); + + // destroy and unload if loaded + ~dynaload(void); + + // load the library - return success or fail + bool load(const std::string& library); + + // unload the library if loaded + bool unload(void); + + // test whether the library is loaded + bool loaded(void) const; + + //////////////////////////////////////////////////////////////////////////// + // symbol management + + // test whether a function is exported by the library + bool present(const std::string& name); + + // get the function as a generic pointer + void* symbol(const std::string& name); + + //////////////////////////////////////////////////////////////////////////// + // error management + + // enum values to indicate type of error + enum error_t {no_error, load_error, unload_error, symbol_error}; + + // test whether there has been an error + bool error(void) const; + + // clear an error once it has been handled (or ignored) + void clear_error(void); + + // get the type of the error as indicated by the enum error_t + error_t error_type(void) const; + + // get the text of the error as provided by the OS + std::string error_text(void) const; + + //////////////////////////////////////////////////////////////////////////// + + private: + void* m_handle; + error_t m_error; + std::string m_text; + }; + +} + +#endif