get_go_type.hpp
Go to the documentation of this file.
1 
14 #ifndef MLPACK_BINDINGS_GO_GET_GO_TYPE_HPP
15 #define MLPACK_BINDINGS_GO_GET_GO_TYPE_HPP
16 
17 #include <mlpack/prereqs.hpp>
19 #include "strip_type.hpp"
20 
21 namespace mlpack {
22 namespace bindings {
23 namespace go {
24 
25 template<typename T>
26 inline std::string GetGoType(
27  util::ParamData& /* d */,
28  const typename std::enable_if<!util::IsStdVector<T>::value>::type* = 0,
29  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
30  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
31  const typename std::enable_if<!std::is_same<T,
32  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
33 {
34  return "unknown";
35 }
36 
37 template<>
38 inline std::string GetGoType<int>(
39  util::ParamData& /* d */,
40  const typename std::enable_if<!util::IsStdVector<int>::value>::type*,
41  const typename std::enable_if<!data::HasSerialize<int>::value>::type*,
42  const typename std::enable_if<!arma::is_arma_type<int>::value>::type*,
43  const typename std::enable_if<!std::is_same<int,
44  std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
45 {
46  return "int";
47 }
48 
49 template<>
50 inline std::string GetGoType<float>(
51  util::ParamData& /* d */,
52  const typename std::enable_if<!util::IsStdVector<float>::value>::type*,
53  const typename std::enable_if<!data::HasSerialize<float>::value>::type*,
54  const typename std::enable_if<!arma::is_arma_type<float>::value>::type*,
55  const typename std::enable_if<!std::is_same<float,
56  std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
57 {
58  return "float32";
59 }
60 
61 template<>
62 inline std::string GetGoType<double>(
63  util::ParamData& /* d */,
64  const typename std::enable_if<!util::IsStdVector<double>::value>::type*,
65  const typename std::enable_if<!data::HasSerialize<double>::value>::type*,
66  const typename std::enable_if<!arma::is_arma_type<double>::value>::type*,
67  const typename std::enable_if<!std::is_same<double,
68  std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
69 {
70  return "float64";
71 }
72 
73 template<>
74 inline std::string GetGoType<std::string>(
75  util::ParamData& /* d */,
76  const typename std::enable_if<
78  const typename std::enable_if<
80  const typename std::enable_if<
81  !arma::is_arma_type<std::string>::value>::type*,
82  const typename std::enable_if<!std::is_same<std::string,
83  std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
84 {
85  return "string";
86 }
87 
88 template<>
89 inline std::string GetGoType<bool>(
90  util::ParamData& /* d */,
91  const typename std::enable_if<!util::IsStdVector<bool>::value>::type*,
92  const typename std::enable_if<!data::HasSerialize<bool>::value>::type*,
93  const typename std::enable_if<!arma::is_arma_type<bool>::value>::type*,
94  const typename std::enable_if<!std::is_same<bool,
95  std::tuple<data::DatasetInfo, arma::mat>>::value>::type*)
96 {
97  return "bool";
98 }
99 
100 template<typename T>
101 inline std::string GetGoType(
102  util::ParamData& d,
103  const typename std::enable_if<util::IsStdVector<T>::value>::type* = 0)
104 {
105  return "[]" + GetGoType<typename T::value_type>(d);
106 }
107 
108 template<typename T>
109 inline std::string GetGoType(
110  util::ParamData& /* d */,
111  const typename std::enable_if<!std::is_same<T,
112  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0,
113  const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
114 {
115  return "mat.Dense";
116 }
117 
118 template<typename T>
119 inline std::string GetGoType(
120  util::ParamData& /* d */,
121  const typename std::enable_if<std::is_same<T,
122  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
123 {
124  return "matrixWithInfo";
125 }
126 
127 template<typename T>
128 inline std::string GetGoType(
129  util::ParamData& d,
130  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
131  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
132 {
133  std::string goStrippedType, strippedType, printedType, defaultsType;
134  StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
135  return goStrippedType;
136 }
137 
138 } // namespace go
139 } // namespace bindings
140 } // namespace mlpack
141 
142 #endif
std::string GetGoType(util::ParamData &, const typename std::enable_if<!util::IsStdVector< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *=0)
Definition: get_go_type.hpp:26
void StripType(const std::string &inputType, std::string &goStrippedType, std::string &strippedType, std::string &printedType, std::string &defaultsType)
Given an input type like, e.g., "LogisticRegression<>", return four types that can be used in Go code...
Definition: strip_type.hpp:30
Linear algebra utility functions, generally performed on matrices or vectors.
std::string GetGoType< float >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< float >::value >::type *, const typename std::enable_if<!data::HasSerialize< float >::value >::type *, const typename std::enable_if<!arma::is_arma_type< float >::value >::type *, const typename std::enable_if<!std::is_same< float, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *)
Definition: get_go_type.hpp:50
The core includes that mlpack expects; standard C++ includes and Armadillo.
go
Definition: CMakeLists.txt:7
std::string GetGoType< double >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< double >::value >::type *, const typename std::enable_if<!data::HasSerialize< double >::value >::type *, const typename std::enable_if<!arma::is_arma_type< double >::value >::type *, const typename std::enable_if<!std::is_same< double, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *)
Definition: get_go_type.hpp:62
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
Metaprogramming structure for vector detection.
std::string GetGoType< bool >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< bool >::value >::type *, const typename std::enable_if<!data::HasSerialize< bool >::value >::type *, const typename std::enable_if<!arma::is_arma_type< bool >::value >::type *, const typename std::enable_if<!std::is_same< bool, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *)
Definition: get_go_type.hpp:89
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:81
std::string GetGoType< int >(util::ParamData &, const typename std::enable_if<!util::IsStdVector< int >::value >::type *, const typename std::enable_if<!data::HasSerialize< int >::value >::type *, const typename std::enable_if<!arma::is_arma_type< int >::value >::type *, const typename std::enable_if<!std::is_same< int, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *)
Definition: get_go_type.hpp:38