print_method_config.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_PRINT_METHOD_CONFIG_HPP
14 #define MLPACK_BINDINGS_GO_PRINT_METHOD_CONFIG_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 #include "get_go_type.hpp"
18 #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 size_t indent,
32  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
33  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
34  const typename std::enable_if<!std::is_same<T,
35  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
36 {
37  const std::string prefix(indent, ' ');
38 
39  std::string def = "nil";
40  if (std::is_same<T, bool>::value)
41  def = "false";
42 
43  // Capitalize the first letter of parameter name so it is
44  // of exported type in Go.
45  std::string name = d.name;
46  std::string goParamName = name;
47  if (!name.empty())
48  {
49  goParamName = util::CamelCase(goParamName, false);
50  }
51 
52  // Only print param that are not required.
53  if (!d.required)
54  {
55  std::cout << prefix << goParamName << " " << GetGoType<T>(d)
56  << std::endl;
57  }
58 }
59 
63 template<typename T>
65  util::ParamData& d,
66  const size_t indent,
67  const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
68 {
69  const std::string prefix(indent, ' ');
70 
71  std::string def = "nil";
72  if (std::is_same<T, bool>::value)
73  def = "false";
74 
75  // Capitalize the first letter of parameter name so it is
76  // of exported type in Go.
77  std::string name = d.name;
78  std::string goParamName = name;
79  if (!name.empty())
80  {
81  goParamName = util::CamelCase(goParamName, false);
82  }
83 
84  // Only print param that are not required.
85  if (!d.required)
86  {
87  std::cout << prefix << goParamName << " *" << GetGoType<T>(d)
88  << std::endl;
89  }
90 }
91 
95 template<typename T>
97  util::ParamData& d,
98  const size_t indent,
99  const typename std::enable_if<std::is_same<T,
100  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
101 {
102  const std::string prefix(indent, ' ');
103 
104  std::string def = "nil";
105  if (std::is_same<T, bool>::value)
106  def = "false";
107 
108  // Capitalize the first letter of parameter name so it is
109  // of exported type in Go.
110  std::string name = d.name;
111  std::string goParamName = name;
112  if (!name.empty())
113  {
114  goParamName = util::CamelCase(goParamName, false);
115  }
116 
117  // Only print param that are not required.
118  if (!d.required)
119  {
120  std::cout << prefix << goParamName << " *" << GetGoType<T>(d)
121  << std::endl;
122  }
123 }
124 
128 template<typename T>
130  util::ParamData& d,
131  const size_t indent,
132  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
133  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
134 {
135  const std::string prefix(indent, ' ');
136 
137  std::string def = "nil";
138  if (std::is_same<T, bool>::value)
139  def = "false";
140 
141  // Capitalize the first letter of parameter name so it is
142  // of exported type in Go.
143  std::string name = d.name;
144  std::string goParamName = name;
145  if (!name.empty())
146  {
147  goParamName = util::CamelCase(goParamName, false);
148  }
149 
150  // Only print param that are not required.
151  if (!d.required)
152  {
153  std::cout << prefix << goParamName << " *" << GetGoType<T>(d)
154  << std::endl;
155  }
156 }
157 
169 template<typename T>
171  const void* input,
172  void* /* output */)
173 {
174  PrintMethodConfig<typename std::remove_pointer<T>::type>(d,
175  *((size_t*) input));
176 }
177 
178 } // namespace go
179 } // namespace bindings
180 } // namespace mlpack
181 
182 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void PrintMethodConfig(util::ParamData &d, const size_t indent, 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 param in configuration struct for a standard option type.
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
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