PhoenixGenerator  2.2.0
Set of tools to generate code
Loading...
Searching...
No Matches
NanobindTraitInclude.cpp File Reference
+ Include dependency graph for NanobindTraitInclude.cpp:

Go to the source code of this file.

Functions

PString get_nanobind_include (const PString &type)
 

Function Documentation

◆ get_nanobind_include()

PString get_nanobind_include ( const PString & type)

Definition at line 19 of file NanobindTraitInclude.cpp.

19 {
20 static const std::map<PString, PString> type_to_header = {
21 {"std::array", "<nanobind/stl/array.h>"},
22 {"std::chrono", "<nanobind/stl/chrono.h>"},
23 {"std::complex", "<nanobind/stl/complex.h>"},
24 {"std::filesystem","<nanobind/stl/filesystem.h>"},
25 {"std::function", "<nanobind/stl/function.h>"},
26 {"std::list", "<nanobind/stl/list.h>"},
27 {"std::map", "<nanobind/stl/map.h>"},
28 {"std::optional", "<nanobind/stl/optional.h>"},
29 {"std::pair", "<nanobind/stl/pair.h>"},
30 {"std::set", "<nanobind/stl/set.h>"},
31 {"std::string", "<nanobind/stl/string.h>"},
32 {"std::string_view", "<nanobind/stl/string_view.h>"},
33 {"std::wstring", "<nanobind/stl/wstring.h>"},
34 {"std::tuple", "<nanobind/stl/tuple.h>"},
35 {"std::shared_ptr", "<nanobind/stl/shared_ptr.h>"},
36 {"std::unique_ptr", "<nanobind/stl/unique_ptr.h>"},
37 {"std::unordered_set", "<nanobind/stl/unordered_set.h>"},
38 {"std::unordered_map", "<nanobind/stl/unordered_map.h>"},
39 {"std::variant", "<nanobind/stl/variant.h>"},
40 {"std::vector", "<nanobind/stl/vector.h>"},
41 {"nb::ndarray", "<nanobind/ndarray.h>"},
42 {"Eigen::Matrix", "<nanobind/eigen/dense.h>"},
43 {"Eigen::Array", "<nanobind/eigen/dense.h>"},
44 {"Eigen::Ref", "<nanobind/eigen/dense.h>"},
45 {"Eigen::Map", "<nanobind/eigen/dense.h>"},
46 {"Eigen::SparseMatrix","<nanobind/eigen/sparse.h>"}
47 };
48
49 typedef std::map<PString, PString>::const_iterator MapIt;
50 for(MapIt it = type_to_header.begin(); it != type_to_header.end(); ++it) {
51 // Search if the type starts with the key + '<' (for templates)
52 PString key = it->first + "<";
53 if(type.substr(0, key.size()) == key) {
54 return it->second;
55 }
56 // Or if the type is exactly the key (for non-templates)
57 if(type == it->first) {
58 return it->second;
59 }
60 }
61
62 return "";
63}

Referenced by NanobindTraitInclude::headerExtraInclude().

+ Here is the caller graph for this function: