mlpack  3.1.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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.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
65 
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
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
string(REGEX REPLACE".*#define MLPACK_VERSION_MINOR ([0-9]+).*""\\1"MLPACK_VERSION_MINOR"${VERSION_HPP_CONTENTS}") string(REGEX REPLACE".* "\\1" MLPACK_VERSION_PATCH "$
Definition: CMakeLists.txt:35