print_defn_input.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_PRINT_DEFN_INPUT_HPP
14 #define MLPACK_BINDINGS_GO_PRINT_DEFN_INPUT_HPP
15 
16 #include <mlpack/prereqs.hpp>
18 #include "get_go_type.hpp"
19 #include "strip_type.hpp"
20 
21 namespace mlpack {
22 namespace bindings {
23 namespace go {
24 
28 template<typename T>
30  util::ParamData& d,
31  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
32  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
33  const typename std::enable_if<!std::is_same<T,
34  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
35 {
36  if (d.required)
37  {
38  std::string name = d.name;
39  std::cout << util::CamelCase(name, true) << " " << GetGoType<T>(d);
40  }
41 }
42 
46 template<typename T>
48  util::ParamData& d,
49  const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
50 {
51  // param_name *mat.Dense
52  if (d.required)
53  {
54  std::string name = d.name;
55  std::cout << util::CamelCase(name, true) << " *" << GetGoType<T>(d);
56  }
57 }
58 
62 template<typename T>
64  util::ParamData& d,
65  const typename std::enable_if<std::is_same<T,
66  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
67 {
68  // param_name *DataWithInfo
69  if (d.required)
70  {
71  std::string name = d.name;
72  std::cout << util::CamelCase(name, true) << " *" << GetGoType<T>(d);
73  }
74 }
75 
79 template<typename T>
81  util::ParamData& d,
82  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
83  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
84 {
85  // Get the type names we need to use.
86  std::string goStrippedType, strippedType, printedType, defaultsType;
87  StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
88 
89  // param_name *ModelName
90  if (d.required)
91  {
92  std::string name = d.name;
93  std::cout << util::CamelCase(name, true) << " *" << goStrippedType;
94  }
95 }
96 
111 template<typename T>
113  const void* /* input */,
114  void* /* output */)
115 {
116  PrintDefnInput<typename std::remove_pointer<T>::type>(d);
117 }
118 
119 } // namespace go
120 } // namespace bindings
121 } // namespace mlpack
122 
123 #endif
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.
The core includes that mlpack expects; standard C++ includes and Armadillo.
go
Definition: CMakeLists.txt:7
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
void PrintDefnInput(util::ParamData &d, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0, const typename std::enable_if<!std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>::value >::type *=0)
Print input in method definition for a regular parameter type.
std::string CamelCase(std::string s, bool lower)
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g.
Definition: camel_case.hpp:26
std::string name
Name of this parameter.
Definition: param_data.hpp:56
bool required
True if this option is required.
Definition: param_data.hpp:71
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:81