print_doc.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_BINDINGS_JULIA_PRINT_DOC_HPP
13 #define MLPACK_BINDINGS_JULIA_PRINT_DOC_HPP
14 
15 namespace mlpack {
16 namespace bindings {
17 namespace julia {
18 
19 template<typename T>
20 void PrintDoc(const util::ParamData& d, const void* /* input */, void* output)
21 {
22  // "type" is a reserved keyword or function.
23  const std::string juliaName = (d.name == "type") ? "type_" : d.name;
24 
25  std::ostringstream& oss = *((std::ostringstream*) output);
26 
27  oss << "`" << juliaName << "::" << GetJuliaType<T>(d) << "`: " << d.desc;
28 
29  // Print a default, if possible. Defaults aren't printed for matrix or model
30  // parameters.
31  if (!d.required)
32  {
33  if (d.cppType == "std::string" ||
34  d.cppType == "double" ||
35  d.cppType == "int" ||
36  d.cppType == "bool")
37  {
38  oss << " Default value `";
39  if (d.cppType == "std::string")
40  {
41  oss << boost::any_cast<std::string>(d.value);
42  }
43  else if (d.cppType == "double")
44  {
45  oss << boost::any_cast<double>(d.value);
46  }
47  else if (d.cppType == "int")
48  {
49  oss << boost::any_cast<int>(d.value);
50  }
51  else if (d.cppType == "bool")
52  {
53  oss << (boost::any_cast<bool>(d.value) ? "true" : "false");
54  }
55  oss << "`." << std::endl;
56  }
57  }
58 }
59 
60 } // namespace julia
61 } // namespace bindings
62 } // namespace mlpack
63 
64 #endif
void PrintDoc(const util::ParamData &d, const void *, void *output)
Definition: print_doc.hpp:20
boost::any value
The actual value that is held.
Definition: param_data.hpp:82
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
if(NOT BUILD_GO_SHLIB) macro(add_go_binding name) endmacro() return() endif() endmacro() if(NOT BUILD_GO_BINDINGS) not_found_return("Not building Go bindings.") endif() if(BUILD_GO_BINDINGS) if(FORCE_BUILD_GO_BINDINGS) find_package(Go 1.11.0) find_package(Gonum) if(NOT GO_FOUND OR NOT GONUM_FOUND) unset(BUILD_GO_BINDINGS CACHE) message(FATAL_ERROR "Go or Gonum not found
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
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