mlpack 3.4.2
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
15namespace mlpack {
16namespace bindings {
17namespace julia {
18
19template<typename T>
20void PrintDoc(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<typename std::remove_pointer
28 <T>::type>(d) << "`: " << d.desc;
29
30 // Print a default, if possible. Defaults aren't printed for matrix or model
31 // parameters.
32 if (!d.required)
33 {
34 if (d.cppType == "std::string" ||
35 d.cppType == "double" ||
36 d.cppType == "int" ||
37 d.cppType == "bool")
38 {
39 oss << " Default value `";
40 if (d.cppType == "std::string")
41 {
42 oss << boost::any_cast<std::string>(d.value);
43 }
44 else if (d.cppType == "double")
45 {
46 oss << boost::any_cast<double>(d.value);
47 }
48 else if (d.cppType == "int")
49 {
50 oss << boost::any_cast<int>(d.value);
51 }
52 else if (d.cppType == "bool")
53 {
54 oss << (boost::any_cast<bool>(d.value) ? "true" : "false");
55 }
56 oss << "`." << std::endl;
57 }
58 }
59}
60
61} // namespace julia
62} // namespace bindings
63} // namespace mlpack
64
65#endif
if(NOT BUILD_GO_SHLIB) macro(add_go_binding name) endmacro() return() endif() endmacro() macro(post_go_setup) if(BUILD_GO_BINDINGS) file(APPEND "$
Definition: CMakeLists.txt:3
julia
Definition: CMakeLists.txt:6
std::string GetJuliaType(util::ParamData &, const typename std::enable_if<!util::IsStdVector< T >::value >::type *=0, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!std::is_same< T, std::tuple< data::DatasetInfo, arma::mat > >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0)
void PrintDoc(util::ParamData &d, const void *, void *output)
Definition: print_doc.hpp:20
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:53
std::string desc
Description of this parameter, if any.
Definition: param_data.hpp:58
boost::any value
The actual value that is held.
Definition: param_data.hpp:82
bool required
True if this option is required.
Definition: param_data.hpp:71
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