print_output_processing.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_PRINT_OUTPUT_PROCESSING_HPP
14 #define MLPACK_BINDINGS_GO_PRINT_OUTPUT_PROCESSING_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 #include "get_type.hpp"
18 #include "strip_type.hpp"
19 #include "camel_case.hpp"
20 
21 namespace mlpack {
22 namespace bindings {
23 namespace go {
24 
28 template<typename T>
30  const util::ParamData& d,
31  const size_t indent,
32  const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
33  const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
34  const typename boost::disable_if<std::is_same<T,
35  std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
36 {
37  const std::string prefix(indent, ' ');
38 
46  std::string name = d.name;
47  name = CamelCase(name);
48  std::cout << prefix << name << " := getParam" << GetType<T>(d)
49  << "(\"" << d.name << "\")" << std::endl;
50 }
51 
55 template<typename T>
57  const util::ParamData& d,
58  const size_t indent,
59  const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0,
60  const typename std::enable_if<!std::is_same<T,
61  std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
62 {
63  const std::string prefix(indent, ' ');
64 
72  std::string name = d.name;
73  name = CamelCase(name);
74  std::string dname = CamelCase(name);
75  name[0] = std::tolower(name[0]);
76  std::cout << prefix << "var " << name << "Ptr mlpackArma" << std::endl;
77  std::cout << prefix << dname << " := " << name
78  << "Ptr.armaToGonum" << GetType<T>(d)
79  << "(\"" << d.name << "\")" << std::endl;
80 }
84 template<typename T>
86  const util::ParamData& d,
87  const size_t indent,
88  const typename boost::enable_if<std::is_same<T,
89  std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
90 {
91  const std::string prefix(indent, ' ');
92 
100  std::string name = d.name;
101  name = CamelCase(name);
102  std::string dname = CamelCase(name);
103  name[0] = std::tolower(name[0]);
104  std::cout << prefix << "var " << name << "Ptr mlpackArma" << std::endl;
105  std::cout << prefix << dname << " := " << name << "Ptr.armaToGonumWith"
106  << "Info(\"" << d.name << "\")" << std::endl;
107 }
108 
112 template<typename T>
114  const util::ParamData& d,
115  const size_t indent,
116  const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
117  const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
118 {
119  // Get the type names we need to use.
120  std::string goStrippedType, strippedType, printedType, defaultsType;
121  StripType(d.cppType, goStrippedType, strippedType, printedType, defaultsType);
122 
123  const std::string prefix(indent, ' ');
124 
133  std::string name = d.name;
134  name = CamelCase(name);
135  std::cout << prefix << "var " << name << " " << goStrippedType << std::endl;
136  std::cout << prefix << name << ".get" << strippedType
137  << "(\"" << d.name << "\")" << std::endl;
138 }
139 
145 template<typename T>
147  const void* /*input*/,
148  void* /* output */)
149 {
150  PrintOutputProcessing<typename std::remove_pointer<T>::type>(d, 2);
151 }
152 
153 } // namespace go
154 } // namespace bindings
155 } // namespace mlpack
156 
157 #endif
std::string CamelCase(std::string s)
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g.
Definition: camel_case.hpp:24
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
strip_type.hpp
Definition: add_to_po.hpp:21
The core includes that mlpack expects; standard C++ includes and Armadillo.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
void PrintOutputProcessing(const util::ParamData &d, const size_t indent, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< data::DatasetInfo, arma::mat >>>::type *=0)
Print output processing for a regular parameter type.
std::string name
Name of this parameter.
Definition: param_data.hpp:56
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84