14 #ifndef MLPACK_BINDINGS_CLI_PRINT_DOC_FUNCTIONS_IMPL_HPP 15 #define MLPACK_BINDINGS_CLI_PRINT_DOC_FUNCTIONS_IMPL_HPP 29 return "mlpack_" + bindingName;
59 inline std::string
PrintValue(
const T& value,
bool quotes)
61 std::ostringstream oss;
74 inline std::string
PrintValue(
const std::vector<T>& value,
bool quotes)
76 std::ostringstream oss;
82 for (
size_t i = 1; i < value.size(); ++i)
83 oss <<
", " << value[i];
96 throw std::invalid_argument(
"unknown parameter " + paramName +
"!");
100 std::string defaultValue;
102 (
void*) &defaultValue);
112 return "'" + dataset +
".csv'";
120 return "'" + model +
".bin'";
129 template<
typename T,
typename... Args>
135 std::string result =
"";
144 std::ostringstream ossValue;
146 std::string rawValue = ossValue.str();
147 std::string fullValue;
149 (
void*) &rawValue, (
void*) &fullValue);
151 std::ostringstream oss;
153 oss << name <<
" " << fullValue;
160 throw std::runtime_error(
"Unknown parameter '" + paramName +
"' " +
161 "encountered while assembling documentation! Check BINDING_LONG_DESC()" 162 +
" and BINDING_EXAMPLE() declaration.");
167 result +=
" " + rest;
176 template<
typename... Args>
177 std::string
ProgramCall(
const std::string& programName, Args... args)
179 return util::HyphenateString(
"$ " +
GetBindingName(programName) +
" " +
189 std::ostringstream oss;
193 std::map<std::string, util::ParamData>& parameters =
IO::Parameters();
195 for (
auto& it : parameters)
197 if (!it.second.input || it.second.persistent)
203 it.second, NULL, (
void*) &name);
207 it.second, NULL, (
void*) &value);
212 if (!it.second.required)
216 if (it.second.cppType !=
"bool")
219 if (!it.second.required)
224 for (
auto& it : parameters)
232 it.second, NULL, (
void*) &name);
236 it.second, NULL, (
void*) &value);
241 if (it.second.cppType !=
"bool")
246 return util::HyphenateString(oss.str(), 8);
267 std::string alias =
"";
269 alias =
" (-" + std::string(1, d.
alias) +
")";
271 return "'" + output + alias +
"'";
275 throw std::runtime_error(
"Parameter '" + paramName +
"' not known! Check " 276 "BINDING_LONG_DESC() and BINDING_EXAMPLE() definition.");
char alias
Alias for this parameter.
Definition: param_data.hpp:63
std::string tname
Type information of this parameter.
Definition: param_data.hpp:61
std::string ProgramCall(const std::string &programName, Args... args)
Given a program name and arguments for it, print what its invocation would be.
Definition: print_doc_functions_impl.hpp:177
std::string GetBindingName(const std::string &bindingName)
Given the name of a binding, print its command-line name (this returns "mlpack_<bindingName>".
Definition: print_doc_functions_impl.hpp:27
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
std::string PrintValue(const T &value, bool quotes)
Given a parameter type, print the corresponding value.
Definition: print_doc_functions_impl.hpp:59
static IO & GetSingleton()
Retrieve the singleton.
Definition: io.cpp:147
std::string PrintInputOptionInfo()
Print any special information about input options.
Definition: print_doc_functions_impl.hpp:43
std::string ProcessOptions()
Base case for recursion.
Definition: print_doc_functions_impl.hpp:124
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
std::string PrintDefault(const std::string ¶mName)
Given a parameter name, print its corresponding default value.
Definition: print_doc_functions_impl.hpp:93
#define TYPENAME(x)
The TYPENAME macro is used internally to convert a type into a string.
Definition: param_data.hpp:22
std::string PrintImport(const std::string &bindingName)
Print any imports for CLI (there are none, so this returns an empty string).
Definition: print_doc_functions_impl.hpp:35
std::string PrintModel(const std::string &model)
Print a model type parameter (add .bin and return).
Definition: print_doc_functions_impl.hpp:118
static std::map< std::string, util::ParamData > & Parameters()
Return a modifiable list of parameters that IO knows about.
Definition: io.cpp:154
std::string PrintDataset(const std::string &dataset)
Print a dataset type parameter (add .csv and return).
Definition: print_doc_functions_impl.hpp:110
std::string ParamString(const std::string ¶mName)
Print what a user would type to invoke the given option name.
Definition: print_doc_functions_impl.hpp:256
std::string PrintOutputOptionInfo()
Print any special information about output options.
Definition: print_doc_functions_impl.hpp:50