autodoc_shared_library_core.xml 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. <?xml version="1.0" standalone="yes"?>
  2. <library-reference id="shared_library_reference"><title>Shared Library Reference</title><header name="boost/dll/alias.hpp">
  3. <para>Includes alias methods and macro. You can include this header or boost/dll/shared_library.hpp to reduce dependencies in case you do not use the refcountable functions. </para><namespace name="boost">
  4. <namespace name="dll">
  5. </namespace>
  6. </namespace>
  7. <macro name="BOOST_DLL_FORCE_ALIAS_INSTANTIATION"><description><para>Define this macro to explicitly specify translation unit in which alias must be instantiated. See section 'Limitations' for more info. You may find usage examples in source codes of almost each tutorial. Must be used in code, when <link linkend="BOOST_DLL_FORCE_NO_WEAK_EXPORTS">BOOST_DLL_FORCE_NO_WEAK_EXPORTS</link> is defined </para></description></macro>
  8. <macro name="BOOST_DLL_FORCE_NO_WEAK_EXPORTS"><description><para>Define this macro to disable exporting weak symbols and start using the <link linkend="BOOST_DLL_FORCE_ALIAS_INSTANTIATION">BOOST_DLL_FORCE_ALIAS_INSTANTIATION</link>. This may be useful for working around linker problems or to test your program for compatibility with linkers that do not support export of weak symbols. </para></description></macro>
  9. <macro name="BOOST_DLL_SELECTANY"><purpose>Macro that allows linker to select any occurrence of this symbol instead of failing with 'multiple definitions' error at linktime. </purpose><description><para>This macro does not work on Android, IBM XL C/C++ and MinGW+Windows because of linker problems with exporting weak symbols (See <ulink url="https://code.google.com/p/android/issues/detail?id=70206,">https://code.google.com/p/android/issues/detail?id=70206,</ulink> <ulink url="https://sourceware.org/bugzilla/show_bug.cgi?id=17480">https://sourceware.org/bugzilla/show_bug.cgi?id=17480</ulink>) </para></description></macro>
  10. <macro name="BOOST_DLL_SECTION" kind="functionlike"><macro-parameter name="SectionName"><description><para>Name of the section. Must be a valid C identifier without quotes not longer than 8 bytes. </para></description></macro-parameter><macro-parameter name="Permissions"><description><para>Can be "read" or "write" (without quotes!). </para></description></macro-parameter><purpose>Macro that puts symbol to a specific section. On MacOS all the sections are put into "__DATA" segment. </purpose><description><para>
  11. </para></description></macro>
  12. <macro name="BOOST_DLL_ALIAS" kind="functionlike"><macro-parameter name="FunctionOrVar"><description><para>Function or variable for which an alias must be made. </para></description></macro-parameter><macro-parameter name="AliasName"><description><para>Name of the alias. Must be a valid C identifier.</para></description></macro-parameter><purpose>Makes an alias name for exported function or variable. </purpose><description><para>This macro is useful in cases of long mangled C++ names. For example some <computeroutput>void boost::foo(std::string)</computeroutput> function name will change to something like <computeroutput>N5boostN3foosE</computeroutput> after mangling. Importing function by <computeroutput>N5boostN3foosE</computeroutput> name does not looks user friendly, especially assuming the fact that different compilers have different mangling schemes. AliasName is the name that won't be mangled and can be used as a portable import name.</para><para>Can be used in any namespace, including global. FunctionOrVar must be fully qualified, so that address of it could be taken. Multiple different aliases for a single variable/function are allowed.</para><para>Make sure that AliasNames are unique per library/executable. Functions or variables in global namespace must not have names same as AliasNames.</para><para>Same AliasName in different translation units must point to the same FunctionOrVar.</para><para>Puts all the aliases into the <emphasis role="bold">"boostdll"</emphasis> read only section of the binary. Equal to <link linkend="BOOST_DLL_ALIAS_SECTIONED">BOOST_DLL_ALIAS_SECTIONED</link>(FunctionOrVar, AliasName, boostdll).</para><para>
  13. <emphasis role="bold">Example:</emphasis> <programlisting language="c++">namespace foo {
  14. void bar(std::string&amp;);
  15. BOOST_DLL_ALIAS(foo::bar, foo_bar)
  16. }
  17. BOOST_DLL_ALIAS(foo::bar, foo_bar_another_alias_name)
  18. </programlisting></para><para><emphasis role="bold">See: <link linkend="BOOST_DLL_ALIAS_SECTIONED">BOOST_DLL_ALIAS_SECTIONED</link></emphasis> for making alias in a specific section. </para></description></macro>
  19. <macro name="BOOST_DLL_ALIAS_SECTIONED" kind="functionlike"><macro-parameter name="FunctionOrVar"><description><para>Function or variable for which an alias must be made. </para></description></macro-parameter><macro-parameter name="AliasName"><description><para>Name of the alias. Must be a valid C identifier. </para></description></macro-parameter><macro-parameter name="SectionName"><description><para>Name of the section. Must be a valid C identifier without quotes not longer than 8 bytes.</para></description></macro-parameter><purpose>Same as <link linkend="BOOST_DLL_ALIAS">BOOST_DLL_ALIAS</link> but puts alias name into the user specified section. </purpose><description><para>
  20. <emphasis role="bold">Example:</emphasis> <programlisting language="c++">namespace foo {
  21. void bar(std::string&amp;);
  22. BOOST_DLL_ALIAS_SECTIONED(foo::bar, foo_bar, sect_1) // section "sect_1" now exports "foo_bar"
  23. }
  24. </programlisting> </para></description></macro>
  25. <macro name="BOOST_DLL_AUTO_ALIAS" kind="functionlike"><macro-parameter name="FunctionOrVar"><description><para>Function or variable for which an unmangled alias must be made.</para></description></macro-parameter><purpose>Exports variable or function with unmangled alias name. </purpose><description><para>This macro is useful in cases of long mangled C++ names. For example some <computeroutput>void boost::foo(std::string)</computeroutput> function name will change to something like <computeroutput>N5boostN3foosE</computeroutput> after mangling. Importing function by <computeroutput>N5boostN3foosE</computeroutput> name does not looks user friendly, especially assuming the fact that different compilers have different mangling schemes.*</para><para>Must be used in scope where FunctionOrVar declared. FunctionOrVar must be a valid C name, which means that it must not contain <computeroutput>::</computeroutput>.</para><para>Functions or variables in global namespace must not have names same as FunctionOrVar.</para><para>Puts all the aliases into the <emphasis role="bold">"boostdll"</emphasis> read only section of the binary. Almost same as <link linkend="BOOST_DLL_ALIAS">BOOST_DLL_ALIAS</link>(FunctionOrVar, FunctionOrVar).</para><para>
  26. <emphasis role="bold">Example:</emphasis> <programlisting language="c++">namespace foo {
  27. void bar(std::string&amp;);
  28. BOOST_DLL_AUTO_ALIAS(bar)
  29. }
  30. </programlisting></para><para><emphasis role="bold">See: <link linkend="BOOST_DLL_ALIAS">BOOST_DLL_ALIAS</link></emphasis> for making an alias with different names. </para></description></macro>
  31. </header>
  32. <header name="boost/dll/config.hpp">
  33. <para>Imports filesystem, error_code, errc, system_error, make_error_code from Boost or C++17 into <computeroutput>boost::dll::fs</computeroutput> namespace. </para><namespace name="boost">
  34. <namespace name="dll">
  35. <namespace name="fs">
  36. <typedef name="path"><description><para>Alias to <computeroutput>std::filesystem::path</computeroutput> if <link linkend="BOOST_DLL_USE_STD_FS">BOOST_DLL_USE_STD_FS</link> is defined by user. Alias to <computeroutput>boost::filesystem::path</computeroutput> otherwise. </para></description><type>std::conditional_t&lt; BOOST_DLL_USE_STD_FS, std::filesystem::path, boost::filesystem::path &gt;</type></typedef>
  37. <typedef name="error_code"><description><para>Alias to <computeroutput>std::error_code</computeroutput> if <link linkend="BOOST_DLL_USE_STD_FS">BOOST_DLL_USE_STD_FS</link> is defined by user. boost::system::error_code otherwise. </para></description><type>std::conditional_t&lt; BOOST_DLL_USE_STD_FS, std::error_code, boost::system::error_code &gt;</type></typedef>
  38. <typedef name="system_error"><description><para>Alias to <computeroutput>std::system_error</computeroutput> if <link linkend="BOOST_DLL_USE_STD_FS">BOOST_DLL_USE_STD_FS</link> is defined by user. Alias to <computeroutput>boost::system::system_error</computeroutput> otherwise. </para></description><type>std::conditional_t&lt; BOOST_DLL_USE_STD_FS, std::system_error, boost::system::system_error &gt;</type></typedef>
  39. </namespace>
  40. </namespace>
  41. </namespace>
  42. <macro name="BOOST_DLL_USE_STD_FS"><purpose>Define this macro to make Boost.DLL use C++17's std::filesystem::path, std::system_error and std::error_code. </purpose></macro>
  43. </header>
  44. <header name="boost/dll/library_info.hpp">
  45. <para>Contains only the <classname alt="boost::dll::library_info">boost::dll::library_info</classname> class that is capable of extracting different information from binaries. </para><namespace name="boost">
  46. <namespace name="dll">
  47. <class name="library_info"><inherit access="private">noncopyable</inherit><purpose>Class that is capable of extracting different information from a library or binary file. Currently understands ELF, MACH-O and PE formats on all the platforms. </purpose><method-group name="public member functions">
  48. <method name="sections"><type>std::vector&lt; std::string &gt;</type><description><para>
  49. </para></description><returns><para>List of sections that exist in binary file. </para>
  50. </returns></method>
  51. <method name="symbols"><type>std::vector&lt; std::string &gt;</type><description><para>
  52. </para></description><returns><para>List of all the exportable symbols from all the sections that exist in binary file. </para>
  53. </returns></method>
  54. <method name="symbols"><type>std::vector&lt; std::string &gt;</type><parameter name="section_name"><paramtype>const char *</paramtype><description><para>Name of the section from which symbol names must be returned. </para></description></parameter><description><para>
  55. </para></description><returns><para>List of symbols from the specified section. </para>
  56. </returns></method>
  57. <method name="symbols"><type>std::vector&lt; std::string &gt;</type><parameter name="section_name"><paramtype>const std::string &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  58. </method-group>
  59. <constructor specifiers="explicit"><parameter name="library_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Path to the binary file from which the info must be extracted. </para></description></parameter><parameter name="throw_if_not_native_format"><paramtype>bool</paramtype><default>true</default><description><para>Throw an exception if this file format is not supported by OS. </para></description></parameter><description><para>Opens file with specified path and prepares for information extraction.
  60. </para></description></constructor>
  61. <destructor><description><para>
  62. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></destructor>
  63. </class>
  64. </namespace>
  65. </namespace>
  66. </header>
  67. <header name="boost/dll/runtime_symbol_info.hpp">
  68. <para>Provides methods for getting acceptable by <classname alt="boost::dll::shared_library">boost::dll::shared_library</classname> location of symbol, source line or program. </para><namespace name="boost">
  69. <namespace name="dll">
  70. <overloaded-function name="symbol_location_ptr"><signature><type>boost::dll::fs::path</type><template>
  71. <template-type-parameter name="T"/>
  72. </template><parameter name="ptr_to_symbol"><paramtype>T</paramtype><description><para>Pointer to symbol which location is to be determined. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter></signature><signature><type>boost::dll::fs::path</type><template>
  73. <template-type-parameter name="T"/>
  74. </template><parameter name="ptr_to_symbol"><paramtype>T</paramtype></parameter></signature><description><para>On success returns full path and name to the binary object that holds symbol pointed by ptr_to_symbol.</para><para>
  75. <emphasis role="bold">Examples:</emphasis> <programlisting language="c++">int main() {
  76. dll::symbol_location_ptr(std::set_terminate(0)); // returns "/some/path/libmy_terminate_handler.so"
  77. dll::symbol_location_ptr(::signal(SIGSEGV, SIG_DFL)); // returns "/some/path/libmy_symbol_handler.so"
  78. }
  79. </programlisting> </para></description><returns><para>Path to the binary object that holds symbol or empty path in case error. </para>
  80. </returns><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. Overload that does not accept <link linkend="boost.dll.fs.error_code">boost::dll::fs::error_code</link> also throws <link linkend="boost.dll.fs.system_error">boost::dll::fs::system_error</link>.</simpara></throws></overloaded-function>
  81. <overloaded-function name="symbol_location"><signature><type>boost::dll::fs::path</type><template>
  82. <template-type-parameter name="T"><purpose><para>Type of the symbol, must not be explicitly specified. </para></purpose></template-type-parameter>
  83. </template><parameter name="symbol"><paramtype>const T &amp;</paramtype><description><para>Symbol which location is to be determined. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter></signature><signature><type>boost::dll::fs::path</type><template>
  84. <template-type-parameter name="T"/>
  85. </template><parameter name="symbol"><paramtype>const T &amp;</paramtype></parameter></signature><description><para>On success returns full path and name of the binary object that holds symbol.</para><para>
  86. <emphasis role="bold">Examples:</emphasis> <programlisting language="c++">int var;
  87. void foo() {}
  88. int main() {
  89. dll::symbol_location(var); // returns program location
  90. dll::symbol_location(foo); // returns program location
  91. dll::symbol_location(std::cerr); // returns location of libstdc++: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
  92. dll::symbol_location(std::placeholders::_1); // returns location of libstdc++: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6"
  93. dll::symbol_location(std::puts); // returns location of libc: "/lib/x86_64-linux-gnu/libc.so.6"
  94. }
  95. </programlisting> </para></description><returns><para>Path to the binary object that holds symbol or empty path in case error. </para>
  96. </returns><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. Overload that does not accept <link linkend="boost.dll.fs.error_code">boost::dll::fs::error_code</link> also throws <link linkend="boost.dll.fs.system_error">boost::dll::fs::system_error</link>.</simpara></throws></overloaded-function>
  97. <overloaded-function name="this_line_location"><signature><type>boost::dll::fs::path</type><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter></signature><signature><type>boost::dll::fs::path</type></signature><description><para>On success returns full path and name of the binary object that holds the current line of code (the line in which the <computeroutput>this_line_location()</computeroutput> method was called).</para><para>
  98. </para></description><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. Overload that does not accept <link linkend="boost.dll.fs.error_code">boost::dll::fs::error_code</link> also throws <link linkend="boost.dll.fs.system_error">boost::dll::fs::system_error</link>. </simpara></throws></overloaded-function>
  99. <overloaded-function name="program_location"><signature><type>boost::dll::fs::path</type><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter></signature><signature><type>boost::dll::fs::path</type></signature><description><para>On success returns full path and name of the currently running program (the one which contains the <computeroutput>main()</computeroutput> function).</para><para>Return value can be used as a parameter for <classname alt="boost::dll::shared_library">shared_library</classname>. See Tutorial "Linking plugin into the executable" for usage example. Flag '-rdynamic' must be used when linking the plugin into the executable on Linux OS.</para><para>
  100. </para></description><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. Overload that does not accept <link linkend="boost.dll.fs.error_code">boost::dll::fs::error_code</link> also throws <link linkend="boost.dll.fs.system_error">boost::dll::fs::system_error</link>. </simpara></throws></overloaded-function>
  101. </namespace>
  102. </namespace>
  103. </header>
  104. <header name="boost/dll/shared_library.hpp">
  105. <para>Contains the <classname alt="boost::dll::shared_library">boost::dll::shared_library</classname> class, core class for all the DLL/DSO operations. </para><namespace name="boost">
  106. <namespace name="dll">
  107. <class name="shared_library"><purpose>This class can be used to load a Dynamic link libraries (DLL's) or Shared Libraries, also know as dynamic shared objects (DSO's) and get their exported symbols (functions and variables). </purpose><description><para><classname alt="boost::dll::shared_library">shared_library</classname> instances share reference count to an actual loaded DLL/DSO, so it is safe and memory efficient to have multiple instances of <classname alt="boost::dll::shared_library">shared_library</classname> referencing the same DLL/DSO even if those instances were loaded using different paths (relative + absolute) referencing the same object.</para><para>On Linux/POSIX link with library "dl". "-fvisibility=hidden" flag is also recommended for use on Linux/POSIX. </para></description><typedef name="native_handle_t"><type>platform_specific</type></typedef>
  108. <method-group name="public member functions">
  109. <method name="assign"><type><classname>shared_library</classname> &amp;</type><parameter name="lib"><paramtype>const <classname>shared_library</classname> &amp;</paramtype><description><para>A library to copy. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter><description><para>Makes *this share the same shared object as lib. If *this is loaded, then unloads it.</para><para>
  110. </para></description><postconditions><para>lib.location() == this-&gt;location(), lib == *this </para>
  111. </postconditions><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. </simpara></throws></method>
  112. <method name="assign"><type><classname>shared_library</classname> &amp;</type><parameter name="lib"><paramtype>const <classname>shared_library</classname> &amp;</paramtype><description><para>A library instance to assign from. </para></description></parameter><description><para>Makes *this share the same shared object as lib. If *this is loaded, then unloads it.</para><para>
  113. </para></description><postconditions><para>lib.location() == this-&gt;location() </para>
  114. </postconditions><throws><simpara><classname/> </simpara></throws></method>
  115. <method name="load"><type>void</type><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>Note that if some library is already loaded in this instance, load will call unload() and then load the new provided library.</para><para>
  116. </para></description><throws><simpara><classname/> </simpara></throws></method>
  117. <method name="load"><type>void</type><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>Note that if some library is already loaded in this instance, load will call unload() and then load the new provided library.</para><para>
  118. </para></description><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. </simpara></throws></method>
  119. <method name="load"><type>void</type><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  120. <method name="unload" cv="noexcept"><type>void</type><description><para>Unloads a shared library. If library was loaded multiple times by different instances, the actual DLL/DSO won't be unloaded until there is at least one instance that references the DLL/DSO.</para><para>
  121. </para></description><postconditions><para>this-&gt;is_loaded() returns false. </para>
  122. </postconditions><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  123. <method name="is_loaded" cv="const noexcept"><type>bool</type><description><para>Check if an library is loaded.</para><para>
  124. </para></description><returns><para>true if a library has been loaded. </para>
  125. </returns><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  126. <method name="operator!" cv="const noexcept"><type>bool</type><description><para>Check if an library is not loaded.</para><para>
  127. </para></description><returns><para>true if a library has not been loaded. </para>
  128. </returns><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  129. <method name="conversion-operator" cv="const noexcept" specifiers="explicit"><type>bool</type><description><para>Check if an library is loaded.</para><para>
  130. </para></description><returns><para>true if a library has been loaded. </para>
  131. </returns><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  132. <method name="has" cv="const noexcept"><type>bool</type><parameter name="symbol_name"><paramtype>const char *</paramtype><description><para>Null-terminated symbol name. Can handle std::string, char*, const char*. </para></description></parameter><description><para>Search for a given symbol on loaded library. Works for all symbols, including alias names.</para><para>
  133. </para></description><returns><para><computeroutput>true</computeroutput> if the loaded library contains a symbol with a given name. </para>
  134. </returns><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  135. <method name="has" cv="const noexcept"><type>bool</type><parameter name="symbol_name"><paramtype>const std::string &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  136. <method name="get" cv="const"><type>boost::enable_if_c&lt; boost::is_member_pointer&lt; T &gt;::value||boost::is_reference&lt; T &gt;::value, T &gt;::type</type><template>
  137. <template-type-parameter name="T"><purpose><para>Type of the symbol that we are going to import. Must be explicitly specified. </para></purpose></template-type-parameter>
  138. </template><parameter name="symbol_name"><paramtype>const std::string &amp;</paramtype><description><para>Null-terminated symbol name. Can handle std::string, char*, const char*. </para></description></parameter><description><para>Returns reference to the symbol (function or variable) with the given name from the loaded library. This call will always succeed and throw nothing if call to <computeroutput>has(const char* )</computeroutput> member function with the same symbol name returned <computeroutput>true</computeroutput>.</para><para><emphasis role="bold">Example:</emphasis> <programlisting language="c++">int&amp; i0 = lib.get&lt;int&gt;("integer_name");
  139. int&amp; i1 = *lib.get&lt;int*&gt;("integer_alias_name");
  140. </programlisting></para><para>
  141. </para></description><returns><para>Reference to the symbol. </para>
  142. </returns><throws><simpara><classname/> </simpara></throws></method>
  143. <method name="get" cv="const"><type>boost::disable_if_c&lt; boost::is_member_pointer&lt; T &gt;::value||boost::is_reference&lt; T &gt;::value, T &amp; &gt;::type</type><template>
  144. <template-type-parameter name="T"/>
  145. </template><parameter name="symbol_name"><paramtype>const std::string &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  146. <method name="get" cv="const"><type>boost::enable_if_c&lt; boost::is_member_pointer&lt; T &gt;::value||boost::is_reference&lt; T &gt;::value, T &gt;::type</type><template>
  147. <template-type-parameter name="T"/>
  148. </template><parameter name="symbol_name"><paramtype>const char *</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  149. <method name="get" cv="const"><type>boost::disable_if_c&lt; boost::is_member_pointer&lt; T &gt;::value||boost::is_reference&lt; T &gt;::value, T &amp; &gt;::type</type><template>
  150. <template-type-parameter name="T"/>
  151. </template><parameter name="symbol_name"><paramtype>const char *</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  152. <method name="get_alias" cv="const"><type>T &amp;</type><template>
  153. <template-type-parameter name="T"><purpose><para>Type of the symbol that we are going to import. Must be explicitly specified.. </para></purpose></template-type-parameter>
  154. </template><parameter name="alias_name"><paramtype>const char *</paramtype><description><para>Null-terminated alias symbol name. Can handle std::string, char*, const char*. </para></description></parameter><description><para>Returns a symbol (function or variable) from a shared library by alias name of the symbol.</para><para><emphasis role="bold">Example:</emphasis> <programlisting language="c++">int&amp; i = lib.get_alias&lt;int&gt;("integer_alias_name");
  155. </programlisting></para><para>
  156. </para></description><throws><simpara><classname/> </simpara></throws></method>
  157. <method name="get_alias" cv="const"><type>T &amp;</type><template>
  158. <template-type-parameter name="T"/>
  159. </template><parameter name="alias_name"><paramtype>const std::string &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  160. <method name="native" cv="const noexcept"><type>native_handle_t</type><description><para>Returns the native handler of the loaded library.</para><para>
  161. </para></description><returns><para>Platform-specific handle. </para>
  162. </returns></method>
  163. <method name="location" cv="const"><type>boost::dll::fs::path</type><description><para>Returns full path and name of this shared object.</para><para><emphasis role="bold">Example:</emphasis> <programlisting language="c++">shared_library lib("test_lib.dll");
  164. filesystem::path full_path = lib.location(); // C:\Windows\System32\test_lib.dll
  165. </programlisting></para><para>
  166. </para></description><returns><para>Full path to the shared library. </para>
  167. </returns><throws><simpara><classname/> </simpara></throws></method>
  168. <method name="location" cv="const"><type>boost::dll::fs::path</type><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter><description><para>Returns full path and name of shared module.</para><para><emphasis role="bold">Example:</emphasis> <programlisting language="c++">shared_library lib("test_lib.dll");
  169. filesystem::path full_path = lib.location(); // C:\Windows\System32\test_lib.dll
  170. </programlisting></para><para>
  171. </para></description><returns><para>Full path to the shared library. </para>
  172. </returns><throws><simpara><classname>std::bad_alloc.</classname> </simpara></throws></method>
  173. <method name="swap" cv="noexcept"><type>void</type><parameter name="rhs"><paramtype><classname>shared_library</classname> &amp;</paramtype><description><para>Library to swap with. </para></description></parameter><description><para>Swaps two libraries. Does not invalidate existing symbols and functions loaded from libraries.</para><para>
  174. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  175. </method-group>
  176. <constructor cv="noexcept"><description><para>Creates in anstance that does not reference any DLL/DSO.</para><para>
  177. </para></description><postconditions><para>this-&gt;is_loaded() returns false. </para>
  178. </postconditions><throws><simpara><classname>Nothing.</classname> </simpara></throws></constructor>
  179. <constructor><parameter name="lib"><paramtype>const <classname>shared_library</classname> &amp;</paramtype><description><para>A library to copy. </para></description></parameter><description><para>Copy constructor that increments the reference count of an underlying shared library. Same as calling constructor with <computeroutput>lib.location()</computeroutput> parameter.</para><para>
  180. </para></description><postconditions><para>lib == *this </para>
  181. </postconditions><throws><simpara><classname/> </simpara></throws></constructor>
  182. <constructor><parameter name="lib"><paramtype>const <classname>shared_library</classname> &amp;</paramtype><description><para>A shared library to copy. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter><description><para>Copy constructor that increments the reference count of an underlying shared library. Same as calling constructor with <computeroutput>lib.location(), ec</computeroutput> parameters.</para><para>
  183. </para></description><postconditions><para>lib == *this </para>
  184. </postconditions><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. </simpara></throws></constructor>
  185. <constructor cv="noexcept"><parameter name="lib"><paramtype><classname>shared_library</classname> &amp;&amp;</paramtype><description><para>A shared library to move from. </para></description></parameter><description><para>Move constructor. Does not invalidate existing symbols and functions loaded from lib.</para><para>
  186. </para></description><postconditions><para>lib.is_loaded() returns false, this-&gt;is_loaded() return true. </para>
  187. </postconditions><throws><simpara><classname>Nothing.</classname> </simpara></throws></constructor>
  188. <constructor specifiers="explicit"><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>
  189. </para></description><throws><simpara><classname/> </simpara></throws></constructor>
  190. <constructor><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>
  191. </para></description><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. </simpara></throws></constructor>
  192. <constructor><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></constructor>
  193. <copy-assignment><type><classname>shared_library</classname> &amp;</type><parameter name="lib"><paramtype>const <classname>shared_library</classname> &amp;</paramtype><description><para>A shared library to assign from. </para></description></parameter><description><para>Assignment operator. If this-&gt;is_loaded() then calls this-&gt;unload(). Does not invalidate existing symbols and functions loaded from lib.</para><para>
  194. </para></description><postconditions><para>lib == *this </para>
  195. </postconditions><throws><simpara><classname/> </simpara></throws></copy-assignment>
  196. <copy-assignment cv="noexcept"><type><classname>shared_library</classname> &amp;</type><parameter name="lib"><paramtype><classname>shared_library</classname> &amp;&amp;</paramtype><description><para>A library to move from. </para></description></parameter><description><para>Move assignment operator. If this-&gt;is_loaded() then calls this-&gt;unload(). Does not invalidate existing symbols and functions loaded from lib.</para><para>
  197. </para></description><postconditions><para>lib.is_loaded() returns false. </para>
  198. </postconditions><throws><simpara><classname>Nothing.</classname> </simpara></throws></copy-assignment>
  199. <destructor><description><para>Destroys the object by calling <computeroutput>unload()</computeroutput>. If library was loaded multiple times by different instances, the actual DLL/DSO won't be unloaded until there is at least one instance that references the DLL/DSO.</para><para>
  200. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></destructor>
  201. <method-group name="public static functions">
  202. <method name="suffix" specifiers="static"><type>boost::dll::fs::path</type><description><para>Returns suffix of shared module: in a call to load() or the constructor/load.</para><para>
  203. </para></description><returns><para>The suffix od shared module: ".dll" (Windows), ".so" (Unix/Linux/BSD), ".dylib" (MacOS/IOS) </para>
  204. </returns></method>
  205. <method name="decorate" specifiers="static"><type>boost::dll::fs::path</type><parameter name="sl"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>the module name and path to decorate - for instance : /usr/lib/boost</para></description></parameter><description><para>Returns the decorated path to a shared module name, i.e. with needed prefix/suffix added.</para><para><emphasis role="bold">Recommendations:</emphasis> Use <computeroutput>load</computeroutput> with <computeroutput>load_mode::append_decorations</computeroutput> instead of constructing the decorated path via <computeroutput>decorate()</computeroutput> and loading by it.</para><para>For instance, for a path like "path/to/boost" it returns :<itemizedlist>
  206. <listitem><para>path/to/libboost.so on posix platforms</para>
  207. </listitem><listitem><para>path/to/libboost.dylib on OSX</para>
  208. </listitem><listitem><para>path/to/boost.dll on Windows</para>
  209. </listitem></itemizedlist>
  210. </para><para>Method handles both relative and absolute paths.</para><para><itemizedlist>
  211. <listitem><para>Windows note: <computeroutput>decorate()</computeroutput> does not prepend "lib" to the decorated path. Use <computeroutput>load</computeroutput> with <computeroutput>load_mode::append_decorations</computeroutput> for MinGW compatibility purpose.</para>
  212. </listitem><listitem><para>Posix note: if the initial module name is already prepended with lib, only the suffix() is appended to the path</para>
  213. </listitem></itemizedlist>
  214. </para><para>
  215. </para></description><returns><para>The decorated unportable path that may not exists in the filesystem or could be wrong due to platform specifics. </para>
  216. </returns></method>
  217. </method-group>
  218. </class><function name="operator=="><type>bool</type><parameter name="lhs"><paramtype>const <classname>shared_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype>const <classname>shared_library</classname> &amp;</paramtype></parameter><purpose>Very fast equality check that compares the actual DLL/DSO objects. Throws nothing. </purpose></function>
  219. <function name="operator!="><type>bool</type><parameter name="lhs"><paramtype>const <classname>shared_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype>const <classname>shared_library</classname> &amp;</paramtype></parameter><purpose>Very fast inequality check that compares the actual DLL/DSO objects. Throws nothing. </purpose></function>
  220. <function name="operator&lt;"><type>bool</type><parameter name="lhs"><paramtype>const <classname>shared_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype>const <classname>shared_library</classname> &amp;</paramtype></parameter><purpose>Compare the actual DLL/DSO objects without any guarantee to be stable between runs. Throws nothing. </purpose></function>
  221. <function name="swap"><type>void</type><parameter name="lhs"><paramtype><classname>shared_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype><classname>shared_library</classname> &amp;</paramtype></parameter><purpose>Swaps two shared libraries. Does not invalidate symbols and functions loaded from libraries. Throws nothing. </purpose></function>
  222. </namespace>
  223. </namespace>
  224. </header>
  225. <header name="boost/dll/shared_library_load_mode.hpp">
  226. <para>Contains only the boost::dll::load_mode::type enum and operators related to it. </para><namespace name="boost">
  227. <namespace name="dll">
  228. <namespace name="load_mode">
  229. <enum name="type"><enumvalue name="default_mode"><description><para>Default open mode. See the <emphasis role="bold">Default:</emphasis> comments below to find out the flags that are enabled by default. </para></description></enumvalue><enumvalue name="dont_resolve_dll_references"><description><para><emphasis role="bold">Platforms:</emphasis> Windows</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>If this value is used, and the executable module is a DLL, the system does not call DllMain for process and thread initialization and termination. Also, the system does not load additional executable modules that are referenced by the specified module.</para><para>Note Do not use this value; it is provided only for backward compatibility. If you are planning to access only data or resources in the DLL, use LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE or LOAD_LIBRARY_AS_IMAGE_RESOURCE or both. </para></description></enumvalue><enumvalue name="load_ignore_code_authz_level"><description><para><emphasis role="bold">Platforms:</emphasis> Windows</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>If this value is used, the system does not check AppLocker rules or apply Software Restriction Policies for the DLL. </para></description></enumvalue><enumvalue name="load_with_altered_search_path"><description><para><emphasis role="bold">Platforms:</emphasis> Windows</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>If this value is used and lpFileName specifies an absolute path, the system uses the alternate file search strategy.</para><para>This value cannot be combined with any LOAD_LIBRARY_SEARCH flag. </para></description></enumvalue><enumvalue name="rtld_lazy"><description><para><emphasis role="bold">Platforms:</emphasis> POSIX</para><para><emphasis role="bold">Default:</emphasis> enabled</para><para>Relocations shall be performed at an implementation-defined time, ranging from the time of the dlopen() call until the first reference to a given symbol occurs.</para><para>Specifying RTLD_LAZY should improve performance on implementations supporting dynamic symbol binding as a process may not reference all of the functions in any given object. And, for systems supporting dynamic symbol resolution for normal process execution, this behavior mimics the normal handling of process execution. </para></description></enumvalue><enumvalue name="rtld_now"><description><para><emphasis role="bold">Platforms:</emphasis> POSIX</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>All necessary relocations shall be performed when the object is first loaded. This may waste some processing if relocations are performed for functions that are never referenced. This behavior may be useful for plugins that need to know as soon as an object is loaded that all symbols referenced during execution are available. </para></description></enumvalue><enumvalue name="rtld_global"><description><para><emphasis role="bold">Platforms:</emphasis> POSIX</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>The object's symbols shall be made available for the relocation processing of any other object. In addition, symbol lookup using dlopen(0, mode) and an associated dlsym() allows objects loaded with this mode to be searched. </para></description></enumvalue><enumvalue name="rtld_local"><description><para><emphasis role="bold">Platforms:</emphasis> POSIX</para><para><emphasis role="bold">Default:</emphasis> enabled</para><para>The object's symbols shall not be made available for the relocation processing of any other object.</para><para>This is a default Windows behavior that can not be changed. </para></description></enumvalue><enumvalue name="rtld_deepbind"><description><para><emphasis role="bold">Platforms:</emphasis> POSIX (requires glibc &gt;= 2.3.4)</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>The object will use its own symbols in preference to global symbols with the same name contained in libraries that have already been loaded. This flag is not specified in POSIX.1-2001. </para></description></enumvalue><enumvalue name="append_decorations"><description><para><emphasis role="bold">Platforms:</emphasis> Windows, POSIX</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>Append a platform specific extension and prefix to shared library filename before trying to load it. If load attempt fails, try to load with exactly specified name.</para><para><emphasis role="bold">Example:</emphasis> <programlisting language="c++">// Opens `./my_plugins/plugin1.dll` on Windows, `./my_plugins/libplugin1.so` on Linux, `./my_plugins/libplugin1.dylib` on MacOS.
  230. // If that fails, loads `./my_plugins/plugin1`
  231. boost::dll::shared_library lib("./my_plugins/plugin1", load_mode::append_decorations);
  232. </programlisting> </para></description></enumvalue><enumvalue name="search_system_folders"><description><para><emphasis role="bold">Platforms:</emphasis> Windows, POSIX</para><para><emphasis role="bold">Default:</emphasis> disabled</para><para>Allow loading from system folders if path to library contains no parent path. </para></description></enumvalue><description><para>Library load modes.</para><para>Each of system family provides own modes. Flags not supported by a particular platform will be silently ignored.</para><para>For a detailed description of platform specific options see: <ulink url="http://msdn.microsoft.com/en-us/library/windows/desktop/ms684179(v=vs.85).aspx">Windows specific options</ulink>, <ulink url="http://pubs.opengroup.org/onlinepubs/000095399/functions/dlopen.html">POSIX specific options</ulink>. </para></description></enum>
  233. <function name="operator|"><type>BOOST_CONSTEXPR type</type><parameter name="left"><paramtype>type</paramtype></parameter><parameter name="right"><paramtype>type</paramtype></parameter><purpose>Free operators for load_mode::type flag manipulation. </purpose></function>
  234. <function name="operator|="><type>BOOST_CXX14_CONSTEXPR type &amp;</type><parameter name="left"><paramtype>type &amp;</paramtype></parameter><parameter name="right"><paramtype>type</paramtype></parameter></function>
  235. <function name="operator&amp;"><type>BOOST_CONSTEXPR type</type><parameter name="left"><paramtype>type</paramtype></parameter><parameter name="right"><paramtype>type</paramtype></parameter></function>
  236. <function name="operator&amp;="><type>BOOST_CXX14_CONSTEXPR type &amp;</type><parameter name="left"><paramtype>type &amp;</paramtype></parameter><parameter name="right"><paramtype>type</paramtype></parameter></function>
  237. <function name="operator^"><type>BOOST_CONSTEXPR type</type><parameter name="left"><paramtype>type</paramtype></parameter><parameter name="right"><paramtype>type</paramtype></parameter></function>
  238. <function name="operator^="><type>BOOST_CXX14_CONSTEXPR type &amp;</type><parameter name="left"><paramtype>type &amp;</paramtype></parameter><parameter name="right"><paramtype>type</paramtype></parameter></function>
  239. <function name="operator~"><type>BOOST_CONSTEXPR type</type><parameter name="left"><paramtype>type</paramtype></parameter></function>
  240. </namespace>
  241. </namespace>
  242. </namespace>
  243. </header>
  244. <header name="boost/dll/smart_library.hpp">
  245. <para>Contains the <classname alt="boost::dll::experimental::smart_library">boost::dll::experimental::smart_library</classname> class for loading mangled symbols. </para><para><warning><para>Extremely experimental! Requires C++14! Will change in next version of Boost! boost/dll/smart_library.hpp is not included in boost/dll.hpp </para>
  246. </warning>
  247. </para><namespace name="boost">
  248. <namespace name="dll">
  249. <namespace name="experimental">
  250. <class name="smart_library"><purpose>This class is an extension of <classname alt="boost::dll::shared_library">shared_library</classname>, which allows to load C++ symbols. </purpose><description><para>This class allows type safe loading of overloaded functions, member-functions, constructors and variables. It also allows to overwrite classes so they can be loaded, while being declared with different names.</para><para><warning><para>Is still very experimental.</para>
  251. </warning>
  252. Currently known limitations:</para><para>Member functions must be defined outside of the class to be exported. That is: <programlisting language="c++">//not exported:
  253. struct BOOST_SYMBOL_EXPORT my_class { void func() {}};
  254. //exported
  255. struct BOOST_SYMBOL_EXPORT my_class { void func();};
  256. void my_class::func() {};
  257. </programlisting></para><para>With the current analysis, the first version does get exported in MSVC. MinGW also does export it, BOOST_SYMBOL_EXPORT is written before it. To allow this on windows one can use BOOST_DLL_MEMBER_EXPORT for this, so that MinGW and MSVC can provide those functions. This does however not work with gcc on linux.</para><para>Direct initialization of members. On linux the following member variable i will not be initialized when using the allocating constructor: <programlisting language="c++">struct BOOST_SYMBOL_EXPORT my_class { int i; my_class() : i(42) {} };
  258. </programlisting></para><para>This does however not happen when the value is set inside the constructor function. </para></description><typedef name="mangled_storage"><type><emphasis>unspecified</emphasis></type></typedef>
  259. <method-group name="public member functions">
  260. <method name="shared_lib" cv="const"><type>const <classname>shared_library</classname> &amp;</type><description><para>Get the underlying <classname alt="boost::dll::shared_library">shared_library</classname> </para></description></method>
  261. <method name="symbol_storage" cv="const"><type>const mangled_storage &amp;</type><description><para>Access to the mangled storage, which is created on construction.</para><para>
  262. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  263. <method name="symbol_storage"><type>mangled_storage &amp;</type><purpose>Overload, for current development. </purpose></method>
  264. <method name="load"><type>void</type><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>Note that if some library is already loaded in this instance, load will call unload() and then load the new provided library.</para><para>
  265. </para></description><throws><simpara><classname/> </simpara></throws></method>
  266. <method name="load"><type>void</type><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>Note that if some library is already loaded in this instance, load will call unload() and then load the new provided library.</para><para>
  267. </para></description><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. </simpara></throws></method>
  268. <method name="load"><type>void</type><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  269. <method name="get_variable" cv="const"><type>T &amp;</type><template>
  270. <template-type-parameter name="T"><purpose><para>Type of the variable </para></purpose></template-type-parameter>
  271. </template><parameter name="name"><paramtype>const std::string &amp;</paramtype><description><para>Name of the variable </para></description></parameter><description><para>Load a variable from the referenced library.</para><para>Unlinke shared_library::get this function will also load scoped variables, which also includes static class members.</para><para><note><para>When mangled, MSVC will also check the type.</para>
  272. </note>
  273. </para></description><returns><para>A reference to the variable of type T.</para>
  274. </returns><throws><simpara><classname/> </simpara></throws></method>
  275. <method name="get_function" cv="const"><type>Func &amp;</type><template>
  276. <template-type-parameter name="Func"><purpose><para>Type of the function, required for determining the overload </para></purpose></template-type-parameter>
  277. </template><parameter name="name"><paramtype>const std::string &amp;</paramtype><description><para>Name of the function. </para></description></parameter><description><para>Load a function from the referenced library.</para><para><emphasis role="bold">Example:</emphasis> </para><para><programlisting language="c++">smart_library lib("test_lib.so");
  278. typedef int (&amp;add_ints)(int, int);
  279. typedef double (&amp;add_doubles)(double, double);
  280. add_ints f1 = lib.get_function&lt;int(int, int)&gt; ("func_name");
  281. add_doubles f2 = lib.get_function&lt;double(double, double)&gt;("func_name");
  282. </programlisting></para><para><note><para>When mangled, MSVC will also check the return type.</para>
  283. </note>
  284. </para></description><returns><para>A reference to the function of type F.</para>
  285. </returns><throws><simpara><classname/> </simpara></throws></method>
  286. <method name="get_mem_fn" cv="const"><type><emphasis>unspecified</emphasis></type><template>
  287. <template-type-parameter name="Class"><purpose><para>The class the function is a member of. If Class is const, the function will be assumed as taking a const this-pointer. The same applies for volatile. </para></purpose></template-type-parameter>
  288. <template-type-parameter name="Func"><purpose><para>Signature of the function, required for determining the overload </para></purpose></template-type-parameter>
  289. </template><parameter name="name"><paramtype>const std::string &amp;</paramtype><description><para>Name of the function. </para></description></parameter><description><para>Load a member-function from the referenced library.</para><para><emphasis role="bold">Example</emphasis> (import class is MyClass, which is available inside the library and the host):</para><para><programlisting language="c++">smart_library lib("test_lib.so");
  290. typedef int MyClass(*func)(int);
  291. typedef int MyClass(*func_const)(int) const;
  292. add_ints f1 = lib.get_mem_fn&lt;MyClass, int(int)&gt; ("MyClass::function");
  293. add_doubles f2 = lib.get_mem_fn&lt;const MyClass, double(double)&gt;("MyClass::function");
  294. </programlisting></para><para><note><para>When mangled, MSVC will also check the return type.</para>
  295. </note>
  296. </para></description><returns><para>A pointer to the member-function with the signature provided</para>
  297. </returns><throws><simpara><classname/> </simpara></throws></method>
  298. <method name="get_constructor" cv="const"><type>constructor&lt; Signature &gt;</type><template>
  299. <template-type-parameter name="Signature"><purpose><para>Signature of the function, required for determining the overload. The return type is the class which this is the constructor of. </para></purpose></template-type-parameter>
  300. </template><description><para>Load a constructor from the referenced library.</para><para><emphasis role="bold">Example</emphasis> (import class is MyClass, which is available inside the library and the host):</para><para><programlisting language="c++">smart_library lib("test_lib.so");
  301. constructor&lt;MyClass(int) f1 = lib.get_mem_fn&lt;MyClass(int)&gt;();
  302. </programlisting></para><para>
  303. </para></description><returns><para>A constructor object.</para>
  304. </returns><throws><simpara><classname/> </simpara></throws></method>
  305. <method name="get_destructor" cv="const"><type>destructor&lt; Class &gt;</type><template>
  306. <template-type-parameter name="Class"><purpose><para>The class whose destructor shall be loaded </para></purpose></template-type-parameter>
  307. </template><description><para>Load a destructor from the referenced library.</para><para><emphasis role="bold">Example</emphasis> (import class is MyClass, which is available inside the library and the host):</para><para><programlisting language="c++">smart_library lib("test_lib.so");
  308. destructor&lt;MyClass&gt; f1 = lib.get_mem_fn&lt;MyClass&gt;();
  309. </programlisting></para><para>
  310. </para></description><returns><para>A destructor object.</para>
  311. </returns><throws><simpara><classname/> </simpara></throws></method>
  312. <method name="get_type_info" cv="const"><type>const std::type_info &amp;</type><template>
  313. <template-type-parameter name="Class"><purpose><para>The class whose typeinfo shall be loaded </para></purpose></template-type-parameter>
  314. </template><description><para>Load the typeinfo of the given type.</para><para><emphasis role="bold">Example</emphasis> (import class is MyClass, which is available inside the library and the host):</para><para><programlisting language="c++">smart_library lib("test_lib.so");
  315. std::type_info &amp;ti = lib.get_Type_info&lt;MyClass&gt;();
  316. </programlisting></para><para>
  317. </para></description><returns><para>A reference to a type_info object.</para>
  318. </returns><throws><simpara><classname/> </simpara></throws></method>
  319. <method name="add_type_alias"><type>void</type><template>
  320. <template-type-parameter name="Alias"/>
  321. </template><parameter name="name"><paramtype>const std::string &amp;</paramtype><description><para>Name of the class the alias is for.</para></description></parameter><description><para>This function can be used to add a type alias.</para><para>This is to be used, when a class shall be imported, which is not declared on the host side.</para><para>Example: <programlisting language="c++">smart_library lib("test_lib.so");
  322. lib.add_type_alias&lt;MyAlias&gt;("MyClass"); //when using MyAlias, the library will look for MyClass
  323. //get the destructor of MyClass
  324. destructor&lt;MyAlias&gt; dtor = lib.get_destructor&lt;MyAlias&gt;();
  325. </programlisting></para><para>
  326. <note><para>If the alias-type is not large enough for the imported class, it will result in undefined behaviour. </para>
  327. </note>
  328. <warning><para>The alias will only be applied for the type signature, it will not replace the token in the scoped name. </para>
  329. </warning>
  330. </para></description></method>
  331. <method name="unload" cv="noexcept"><type>void</type><description><para>Unloads a shared library. If library was loaded multiple times by different instances, the actual DLL/DSO won't be unloaded until there is at least one instance that references the DLL/DSO.</para><para>
  332. </para></description><postconditions><para>this-&gt;is_loaded() returns false. </para>
  333. </postconditions><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  334. <method name="is_loaded" cv="const noexcept"><type>bool</type><description><para>Check if an library is loaded.</para><para>
  335. </para></description><returns><para>true if a library has been loaded. </para>
  336. </returns><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  337. <method name="operator!" cv="const noexcept"><type>bool</type><description><para>Check if an library is not loaded.</para><para>
  338. </para></description><returns><para>true if a library has not been loaded. </para>
  339. </returns><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  340. <method name="conversion-operator" cv="const noexcept" specifiers="explicit"><type>bool</type><purpose>bool() const </purpose><description><para>bool() const </para></description></method>
  341. <method name="has" cv="const noexcept"><type>bool</type><parameter name="symbol_name"><paramtype>const char *</paramtype><description><para>Null-terminated symbol name. Can handle std::string, char*, const char*. </para></description></parameter><description><para>Search for a given symbol on loaded library. Works for all symbols, including alias names.</para><para>
  342. </para></description><returns><para><computeroutput>true</computeroutput> if the loaded library contains a symbol with a given name. </para>
  343. </returns><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  344. <method name="has" cv="const noexcept"><type>bool</type><parameter name="symbol_name"><paramtype>const std::string &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></method>
  345. <method name="assign"><type><classname>smart_library</classname> &amp;</type><parameter name="lib"><paramtype>const <classname>smart_library</classname> &amp;</paramtype><description><para>A library instance to assign from. </para></description></parameter><description><para>Makes *this share the same shared object as lib. If *this is loaded, then unloads it.</para><para>
  346. </para></description><postconditions><para>lib.location() == this-&gt;location() </para>
  347. </postconditions><throws><simpara><classname/> </simpara></throws></method>
  348. <method name="swap" cv="noexcept"><type>void</type><parameter name="rhs"><paramtype><classname>smart_library</classname> &amp;</paramtype><description><para>Library to swap with. </para></description></parameter><description><para>Swaps two libraries. Does not invalidate existing symbols and functions loaded from libraries.</para><para>
  349. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></method>
  350. </method-group>
  351. <constructor cv="noexcept"><description><para>Creates in anstance that does not reference any DLL/DSO.</para><para>
  352. </para></description><postconditions><para>this-&gt;is_loaded() returns false. </para>
  353. </postconditions><throws><simpara><classname>Nothing.</classname> </simpara></throws></constructor>
  354. <constructor><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>
  355. </para></description><throws><simpara><classname/> </simpara></throws></constructor>
  356. <constructor><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype><description><para>Library file name. Can handle std::string, const char*, std::wstring, const wchar_t* or <link linkend="boost.dll.fs.path">boost::dll::fs::path</link>. </para></description></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype><description><para>Variable that will be set to the result of the operation. </para></description></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype><default>load_mode::default_mode</default><description><para>A mode that will be used on library load. </para></description></parameter><description><para>Loads a library by specified path with a specified mode.</para><para>
  357. </para></description><throws><simpara><classname>std::bad_alloc</classname> in case of insufficient memory. </simpara></throws></constructor>
  358. <constructor><parameter name="lib_path"><paramtype>const boost::dll::fs::path &amp;</paramtype></parameter><parameter name="mode"><paramtype>load_mode::type</paramtype></parameter><parameter name="ec"><paramtype>boost::dll::fs::error_code &amp;</paramtype></parameter><description><para>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. </para></description></constructor>
  359. <constructor cv="noexcept"><parameter name="lib"><paramtype>const <classname>smart_library</classname> &amp;</paramtype><description><para>A <classname alt="boost::dll::experimental::smart_library">smart_library</classname> to move from.</para></description></parameter><description><para>copy a <classname alt="boost::dll::experimental::smart_library">smart_library</classname> object.</para><para>
  360. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></constructor>
  361. <constructor cv="noexcept"><parameter name="lib"><paramtype><classname>smart_library</classname> &amp;&amp;</paramtype><description><para>A <classname alt="boost::dll::experimental::smart_library">smart_library</classname> to move from.</para></description></parameter><description><para>Move a <classname alt="boost::dll::experimental::smart_library">smart_library</classname> object.</para><para>
  362. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></constructor>
  363. <constructor specifiers="explicit" cv="noexcept"><parameter name="lib"><paramtype>const <classname>shared_library</classname> &amp;</paramtype><description><para>A <classname alt="boost::dll::shared_library">shared_library</classname> to move from.</para></description></parameter><description><para>Construct from a <classname alt="boost::dll::shared_library">shared_library</classname> object.</para><para>
  364. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></constructor>
  365. <constructor specifiers="explicit" cv="noexcept"><parameter name="lib"><paramtype><classname>shared_library</classname> &amp;&amp;</paramtype><description><para>A <classname alt="boost::dll::shared_library">shared_library</classname> to move from.</para></description></parameter><description><para>Construct from a <classname alt="boost::dll::shared_library">shared_library</classname> object.</para><para>
  366. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></constructor>
  367. <destructor><description><para>Destroys the <classname alt="boost::dll::experimental::smart_library">smart_library</classname>. <computeroutput>unload()</computeroutput> is called if the DLL/DSO was loaded. If library was loaded multiple times by different instances of <classname alt="boost::dll::shared_library">shared_library</classname>, the actual DLL/DSO won't be unloaded until there is at least one instance of <classname alt="boost::dll::shared_library">shared_library</classname>.</para><para>
  368. </para></description><throws><simpara><classname>Nothing.</classname> </simpara></throws></destructor>
  369. </class><function name="operator=="><type>bool</type><parameter name="lhs"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><purpose>Very fast equality check that compares the actual DLL/DSO objects. Throws nothing. </purpose></function>
  370. <function name="operator!="><type>bool</type><parameter name="lhs"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><purpose>Very fast inequality check that compares the actual DLL/DSO objects. Throws nothing. </purpose></function>
  371. <function name="operator&lt;"><type>bool</type><parameter name="lhs"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><purpose>Compare the actual DLL/DSO objects without any guarantee to be stable between runs. Throws nothing. </purpose></function>
  372. <function name="swap"><type>void</type><parameter name="lhs"><paramtype><classname>smart_library</classname> &amp;</paramtype></parameter><parameter name="rhs"><paramtype><classname>smart_library</classname> &amp;</paramtype></parameter><purpose>Swaps two shared libraries. Does not invalidate symbols and functions loaded from libraries. Throws nothing. </purpose></function>
  373. <function name="get"><type>void</type><template>
  374. <template-type-parameter name="T"/>
  375. <template-type-parameter name="T2"/>
  376. </template><parameter name="sm"><paramtype>const <classname>smart_library</classname> &amp;</paramtype><description><para>A reference to the <classname alt="boost::dll::experimental::smart_library">smart_library</classname> </para></description></parameter><parameter name="name"><paramtype>const std::string &amp;</paramtype><description><para>The name of the entity to import </para></description></parameter><description><para>Helper functions for overloads.</para><para>Gets either a variable, function or member-function, depending on the signature.</para><para><programlisting language="c++">smart_library sm("lib.so");
  377. get&lt;int&gt;(sm, "space::value"); //import a variable
  378. get&lt;void(int)&gt;(sm, "space::func"); //import a function
  379. get&lt;some_class, void(int)&gt;(sm, "space::class_::mem_fn"); //import a member function
  380. </programlisting></para><para>
  381. </para></description></function>
  382. <function name="get"><type>T &amp;</type><template>
  383. <template-type-parameter name="T"/>
  384. </template><parameter name="sm"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><parameter name="name"><paramtype>const std::string &amp;</paramtype></parameter><parameter name=""><paramtype>typename boost::enable_if&lt; boost::is_object&lt; T &gt;, T &gt;::type *</paramtype><default>nullptr</default></parameter></function>
  385. <function name="get"><type>auto</type><template>
  386. <template-type-parameter name="T"/>
  387. </template><parameter name="sm"><paramtype>const <classname>smart_library</classname> &amp;</paramtype></parameter><parameter name="name"><paramtype>const std::string &amp;</paramtype></parameter><parameter name=""><paramtype>typename boost::enable_if&lt; boost::is_function&lt; T &gt;&gt;::type *</paramtype><default>nullptr</default></parameter></function>
  388. <function name="get"><type>auto</type><template>
  389. <template-type-parameter name="Class"/>
  390. <template-type-parameter name="Signature"/>
  391. </template><parameter name="sm"><paramtype>const <classname>smart_library</classname> &amp;</paramtype><description><para>A reference to the <classname alt="boost::dll::experimental::smart_library">smart_library</classname> </para></description></parameter><parameter name="name"><paramtype>const std::string &amp;</paramtype><description><para>The name of the entity to import </para></description></parameter><description><para>Helper functions for overloads.</para><para>Gets either a variable, function or member-function, depending on the signature.</para><para><programlisting language="c++">smart_library sm("lib.so");
  392. get&lt;int&gt;(sm, "space::value"); //import a variable
  393. get&lt;void(int)&gt;(sm, "space::func"); //import a function
  394. get&lt;some_class, void(int)&gt;(sm, "space::class_::mem_fn"); //import a member function
  395. </programlisting></para><para>
  396. </para></description></function>
  397. </namespace>
  398. </namespace>
  399. </namespace>
  400. </header>
  401. </library-reference>