]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/dll/example/mangled/import_class.cpp
1 // Copyright 2016 Klemens Morgenstern
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org
9 #include "../b2_workarounds.hpp" // contains dll_test::replace_with_full_path
13 #include <boost/dll/smart_library.hpp>
14 #include <boost/dll/import_mangled.hpp>
15 #include <boost/dll/import_class.hpp>
19 int main(int argc
, char* argv
[]) {
20 /*<-*/ b2_workarounds::argv_to_path_guard
guard(argc
, argv
); /*->*/
21 boost::dll::fs::path
lib_path(argv
[1]); // argv[1] contains path to directory with our plugin library
22 smart_library
lib(lib_path
);// smart library instance
25 auto size_f
= import_mangled
<std::size_t()>("space::my_plugin::size"); //get the size function
27 auto size
= (*size_f
)(); // get the size of the class
30 auto value
= import_mangled
<int>(lib
, "space::my_plugin::value");
33 auto cl
= import_class
<class alias
, const std::string
&>(lib
, "space::my_plugin::some_class", size
, "MyName");
36 auto name
= import_mangled
<const alias
, std::string()>(lib
, "name");
37 std::cout
<< "Name: " << (cl
->*name
)() << std::endl
;
40 auto calc
= import_mangled
<alias
, float(float, float), int(int, int)>(lib
, "calculate");
41 std::cout
<< "Calc(float): " (cl
->*calc
)(5.f
, 2.f
) << std::endl
;
42 std::cout
<< "Calc(int): " (cl
->*calc
)(5, 2) << std::endl
;
44 //[import_class_typeinfo
45 std::type_info
&ti
= cl
.get_type_info();