print_doc.hpp
Go to the documentation of this file.
1 
7 #ifndef MLPACK_BINDINGS_JULIA_PRINT_DOC_HPP
8 #define MLPACK_BINDINGS_JULIA_PRINT_DOC_HPP
9 
10 namespace mlpack {
11 namespace bindings {
12 namespace julia {
13 
14 template<typename T>
15 void PrintDoc(const util::ParamData& d, const void* /* input */, void* output)
16 {
17  // "type" is a reserved keyword or function.
18  const std::string juliaName = (d.name == "type") ? "type_" : d.name;
19 
20  std::ostringstream& oss = *((std::ostringstream*) output);
21 
22  oss << "`" << juliaName << "::" << GetJuliaType<T>() << "`: " << d.desc;
23 
24  // Print a default, if possible. Defaults aren't printed for matrix or model
25  // parameters.
26  if (!d.required)
27  {
28  if (d.cppType == "std::string" ||
29  d.cppType == "double" ||
30  d.cppType == "int" ||
31  d.cppType == "bool")
32  {
33  oss << " Default value `";
34  if (d.cppType == "std::string")
35  {
36  oss << boost::any_cast<std::string>(d.value);
37  }
38  else if (d.cppType == "double")
39  {
40  oss << boost::any_cast<double>(d.value);
41  }
42  else if (d.cppType == "int")
43  {
44  oss << boost::any_cast<int>(d.value);
45  }
46  else if (d.cppType == "bool")
47  {
48  oss << (boost::any_cast<bool>(d.value) ? "true" : "false");
49  }
50  oss << "`." << std::endl;
51  }
52  }
53 }
54 
55 } // namespace julia
56 } // namespace bindings
57 } // namespace mlpack
58 
59 #endif
60 
void PrintDoc(const util::ParamData &d, const void *, void *output)
Definition: print_doc.hpp:15
boost::any value
The actual value that is held.
Definition: param_data.hpp:82
strip_type.hpp
Definition: add_to_po.hpp:21
std::string desc
Description of this parameter, if any.
Definition: param_data.hpp:58
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
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 $
Definition: CMakeLists.txt:1
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:84