@@ -51,81 +51,81 @@ class SharedLibrary
51
51
public:
52
52
enum Flags
53
53
{
54
- SHLIB_GLOBAL = 1 ,
55
54
// / On platforms that use dlopen(), use RTLD_GLOBAL. This is the default
56
55
// / if no flags are given.
57
56
// /
58
57
// / This flag is ignored on platforms that do not use dlopen().
58
+ SHLIB_GLOBAL = 1 ,
59
59
60
- SHLIB_LOCAL = 2
61
60
// / On platforms that use dlopen(), use RTLD_LOCAL instead of RTLD_GLOBAL.
62
61
// /
63
62
// / Note that if this flag is specified, RTTI (including dynamic_cast and throw) will
64
63
// / not work for types defined in the shared library with GCC and possibly other
65
64
// / compilers as well. See http://gcc.gnu.org/faq.html#dso for more information.
66
65
// /
67
66
// / This flag is ignored on platforms that do not use dlopen().
67
+ SHLIB_LOCAL = 2
68
68
};
69
69
70
- SharedLibrary ();
71
70
// / Creates a SharedLibrary object.
71
+ SharedLibrary ();
72
72
73
- SharedLibrary (const std::string& path, int flags = 0 );
74
73
// / Creates a SharedLibrary object and loads a library
75
74
// / from the given path, using the given flags.
76
75
// / See the Flags enumeration for valid values.
76
+ SharedLibrary (const std::string& path, int flags = 0 );
77
77
78
- virtual ~SharedLibrary () = default ;
79
78
// / Destroys the SharedLibrary. The actual library
80
79
// / remains loaded.
80
+ virtual ~SharedLibrary () = default ;
81
81
82
- void load (const std::string& path, int flags = 0 );
83
82
// / Loads a shared library from the given path,
84
83
// / using the given flags. See the Flags enumeration
85
84
// / for valid values.
86
85
// / Throws a LibraryAlreadyLoadedException if
87
86
// / a library has already been loaded.
88
87
// / Throws a LibraryLoadException if the library
89
88
// / cannot be loaded.
89
+ void load (const std::string& path, int flags = 0 );
90
90
91
- void unload ();
92
91
// / Unloads a shared library.
92
+ void unload ();
93
93
94
- bool isLoaded () const ;
95
94
// / Returns true iff a library has been loaded.
95
+ bool isLoaded () const ;
96
96
97
- bool hasSymbol (const std::string& name);
98
97
// / Returns true iff the loaded library contains
99
98
// / a symbol with the given name.
99
+ bool hasSymbol (const std::string& name);
100
100
101
- void * getSymbol (const std::string& name);
102
101
// / Returns the address of the symbol with
103
102
// / the given name. For functions, this
104
103
// / is the entry point of the function.
105
104
// / Throws a NotFoundException if the symbol
106
105
// / does not exist.
106
+ void * getSymbol (const std::string& name);
107
107
108
- const std::string& getPath () const ;
109
108
// / Returns the path of the library, as
110
109
// / specified in a call to load() or the
111
110
// / constructor.
111
+ const std::string& getPath () const ;
112
112
113
- static std::string prefix ();
114
113
// / Returns the platform-specific filename prefix
115
114
// / for shared libraries.
116
115
// / Most platforms would return "lib" as prefix, while
117
116
// / on Cygwin, the "cyg" prefix will be returned.
117
+ static std::string prefix ();
118
118
119
- static std::string suffix ();
120
119
// / Returns the platform-specific filename suffix
121
120
// / for shared libraries (including the period).
122
121
// / In debug mode, the suffix also includes a
123
122
// / "d" to specify the debug version of a library.
123
+ static std::string suffix ();
124
124
125
- static std::string getOSName (const std::string& name);
126
125
// / Returns the platform-specific filename
127
126
// / for shared libraries by prefixing and suffixing name
128
127
// / with prefix() and suffix()
128
+ static std::string getOSName (const std::string& name);
129
129
130
130
private:
131
131
SharedLibrary (const SharedLibrary&);
@@ -134,7 +134,7 @@ class SharedLibrary
134
134
void * findSymbol (const std::string& name);
135
135
136
136
std::string _path;
137
- void * _handle;
137
+ void * _handle = nullptr ;
138
138
std::mutex _mutex;
139
139
};
140
140
0 commit comments