12 #ifndef MLPACK_BINDINGS_GO_PRINT_INPUT_PROCESSING_HPP 13 #define MLPACK_BINDINGS_GO_PRINT_INPUT_PROCESSING_HPP 32 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
34 const typename boost::disable_if<std::is_same<T,
35 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
37 const std::string prefix(indent,
' ');
39 std::string def =
"nil";
40 if (std::is_same<T, bool>::value)
45 std::string paramName = d.
name;
46 std::string goParamName = paramName;
47 if (!paramName.empty())
61 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 65 std::cout << prefix <<
"if param." << goParamName <<
" != ";
70 std::string value = boost::any_cast<std::string>(d.
value);
71 std::cout <<
"\"" << value <<
"\"";
75 double value = boost::any_cast<
double>(d.
value);
80 int value = boost::any_cast<
int>(d.
value);
85 bool value = boost::any_cast<
bool>(d.
value);
91 else if (GetType<T>(d) ==
"VecString" || GetType<T>(d) ==
"VecInt")
97 std::cout <<
" {" << std::endl;
98 std::cout << prefix << prefix <<
"setParam" << GetType<T>(d) <<
"(\"" 99 << d.
name <<
"\", param." << goParamName <<
")" << std::endl;
102 std::cout << prefix << prefix <<
"setPassed(\"" 103 << d.
name <<
"\")" << std::endl;
107 std::cout << prefix << prefix <<
"enableVerbose()" << std::endl;
109 std::cout << prefix <<
"}" << std::endl;
114 std::cout << prefix <<
"setParam" << GetType<T>(d) <<
"(\"" 115 << d.
name <<
"\", " << goParamName <<
")" 119 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
121 std::cout << std::endl;
131 const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
133 const std::string prefix(indent,
' ');
137 std::string paramName = d.
name;
138 std::string goParamName = paramName;
139 if (!paramName.empty())
153 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 157 std::cout << prefix <<
"if param." << goParamName
158 <<
" != nil {" << std::endl;
161 std::cout << prefix << prefix <<
"gonumToArma" << GetType<T>(d)
162 <<
"(\"" << d.
name <<
"\", param." << goParamName
166 std::cout << prefix << prefix <<
"setPassed(\"" << d.
name <<
"\")" 168 std::cout << prefix <<
"}" << std::endl;
173 std::cout << prefix <<
"gonumToArma" << GetType<T>(d)
174 <<
"(\"" << d.
name <<
"\", " << goParamName
178 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
180 std::cout << std::endl;
190 const typename boost::enable_if<std::is_same<T,
191 std::tuple<data::DatasetInfo, arma::mat>>>::type* = 0)
193 const std::string prefix(indent,
' ');
197 std::string paramName = d.
name;
198 std::string goParamName = paramName;
199 if (!paramName.empty())
213 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 217 std::cout << prefix <<
"if param." << goParamName
218 <<
" != nil {" << std::endl;
221 std::cout << prefix << prefix <<
"gonumToArmaMatWithInfo" 222 <<
"(\"" << d.
name <<
"\", param." << goParamName
226 std::cout << prefix << prefix <<
"setPassed(\"" << d.
name <<
"\")" 228 std::cout << prefix <<
"}" << std::endl;
233 std::cout << prefix <<
"gonumToArmaMatWithInfo" 234 <<
"(\"" << d.
name <<
"\", " << goParamName
238 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
240 std::cout << std::endl;
250 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
254 std::string goStrippedType, strippedType, printedType, defaultsType;
255 StripType(d.
cppType, goStrippedType, strippedType, printedType, defaultsType);
257 const std::string prefix(indent,
' ');
261 std::string paramName = d.
name;
262 std::string goParamName = paramName;
263 if (!paramName.empty())
277 std::cout << prefix <<
"// Detect if the parameter was passed; set if so." 281 std::cout << prefix <<
"if param." << goParamName <<
" != nil {" 284 std::cout << prefix << prefix <<
"set" << strippedType <<
"(\"" 285 << d.
name <<
"\", param." << goParamName <<
")" << std::endl;
288 std::cout << prefix << prefix <<
"setPassed(\"" << d.
name <<
"\")" 290 std::cout << prefix <<
"}" << std::endl;
295 std::cout << prefix <<
"set" << strippedType <<
"(\"" << goParamName
296 <<
"\", " << paramName <<
")" << std::endl;
299 std::cout << prefix <<
"setPassed(\"" << d.
name <<
"\")" << std::endl;
301 std::cout << std::endl;
320 PrintInputProcessing<typename std::remove_pointer<T>::type>(d,
std::string CamelCase(std::string s)
Given an snake_case like, e.g., "logistic_regression", return CamelCase(e.g.
boost::any value
The actual value that is held.
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...
The core includes that mlpack expects; standard C++ includes and Armadillo.
void PrintInputProcessing(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 input processing for a standard option type.
This structure holds all of the information about a single parameter, including its value (which is s...
if(BUILD_GO_BINDINGS) find_package(Go 1.11.0) if(NOT GO_FOUND) macro(add_go_binding name) endmacro() return() endif() find_package(Gonum) if(NOT GONUM_FOUND) macro(add_go_binding name) endmacro() endif() set(BINDING_SOURCES get_type.hpp get_param.hpp get_printable_param.hpp go_option.hpp mlpack/arma_util.h mlpack/arma_util.hpp mlpack/cli_util.h mlpack/cli_util.hpp print_class_defn.hpp print_cpp.cpp print_cpp.hpp print_defn_input.hpp print_defn_output.hpp print_doc.hpp print_doc_functions.hpp print_doc_functions_impl.hpp print_go.hpp print_go.cpp print_h.hpp print_h.cpp print_import_decl.hpp print_input_processing.hpp print_method_config.hpp print_method_init.hpp print_output_processing.hpp camel_case.hpp strip_type.hpp) set(CGO_SOURCES mlpack/arma_util.go mlpack/cli_util.go mlpack/doc.go) set(CAPI_SOURCES mlpack/capi/arma_util.cpp mlpack/capi/arma_util.h mlpack/capi/arma_util.hpp mlpack/capi/cli_util.cpp mlpack/capi/cli_util.h mlpack/capi/cli_util.hpp) set(UTIL_SOURCES mlpack/capi/arma_util.cpp mlpack/capi/cli_util.cpp) set(TEST_SOURCES tests/go_binding_test.go) add_custom_target(go ALL DEPENDS mlpack) add_custom_target(go_copy ALL DEPENDS mlpack) if(BUILD_TESTS) foreach(test_file $
std::string name
Name of this parameter.
bool required
True if this option is required.
std::string cppType
The true name of the type, as it would be written in C++.