13 #ifndef MLPACK_CORE_BINDINGS_CLI_CLI_OPTION_HPP 14 #define MLPACK_CORE_BINDINGS_CLI_CLI_OPTION_HPP 69 const std::string& identifier,
70 const std::string& description,
71 const std::string& alias,
72 const std::string& cppName,
73 const bool required =
false,
74 const bool input =
true,
75 const bool noTranspose =
false,
76 const std::string& =
"")
81 data.
desc = description;
82 data.
name = identifier;
84 data.
alias = alias[0];
94 if (std::is_same<
typename std::remove_pointer<N>::type,
96 std::remove_pointer<N>::type>::type>::value)
98 data.
value = boost::any(defaultValue);
103 data.
value = boost::any(std::tuple<N, decltype(tmp)>(defaultValue, tmp));
106 const std::string tname = data.
tname;
108 typename std::remove_pointer<N>::type>(identifier);
109 std::string progOptId = (alias[0] !=
'\0') ?
110 "-" + std::string(1, alias[0]) +
",--" + cliName :
"--" + cliName;
113 const std::map<std::string, util::ParamData>& parameters =
115 if (parameters.count(cliName) > 0)
120 #define BASH_RED "\033[0;31m" 121 #define BASH_CLEAR "\033[0m" 124 #define BASH_CLEAR "" 129 BASH_RED
"[FATAL] " BASH_CLEAR,
false,
true );
134 outstr <<
"Parameter --" << cliName <<
" (" << data.
alias <<
") " 135 <<
"is defined multiple times with the same identifiers." 147 &GetPrintableParam<N>;
154 &MapParameterName<N>;
156 &GetPrintableParamName<N>;
158 &GetPrintableParamValue<N>;
160 &GetAllocatedMemory<N>;
162 &DeleteAllocatedMemory<N>;
char alias
Alias for this parameter.
Definition: param_data.hpp:63
std::string tname
Type information of this parameter.
Definition: param_data.hpp:61
static void Add(util::ParamData &&d)
Adds a parameter to the hierarchy; use the PARAM_*() macros instead of this (i.e. ...
Definition: io.cpp:36
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
bool input
True if this option is an input option (otherwise, it is output).
Definition: param_data.hpp:73
bool persistent
If this should be preserved across different settings (i.e.
Definition: param_data.hpp:79
CLIOption(const N defaultValue, const std::string &identifier, const std::string &description, const std::string &alias, const std::string &cppName, const bool required=false, const bool input=true, const bool noTranspose=false, const std::string &="")
Construct an Option object.
Definition: cli_option.hpp:68
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84
std::string desc
Description of this parameter, if any.
Definition: param_data.hpp:58
bool noTranspose
True if this is a matrix that should not be transposed.
Definition: param_data.hpp:69
static IO & GetSingleton()
Retrieve the singleton.
Definition: io.cpp:147
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
bool loaded
If this is an input parameter that needs extra loading, this indicates whether or not it has been loa...
Definition: param_data.hpp:76
#define TYPENAME(x)
The TYPENAME macro is used internally to convert a type into a string.
Definition: param_data.hpp:22
A static object whose constructor registers a parameter with the IO class.
Definition: cli_option.hpp:48
static std::map< std::string, util::ParamData > & Parameters()
Return a modifiable list of parameters that IO knows about.
Definition: io.cpp:154
boost::any value
The actual value that is held.
Definition: param_data.hpp:82
std::string MapParameterName(const std::string &identifier, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0, const typename std::enable_if<!std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>::value >::type *=0)
If needed, map the parameter name to the name that is used by CLI11.
Definition: map_parameter_name.hpp:28
Utility struct to return the type that CLI11 should accept for a given input type.
Definition: parameter_type.hpp:42
std::string name
Name of this parameter.
Definition: param_data.hpp:56
Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we wou...
Definition: prefixedoutstream.hpp:46
bool required
True if this option is required.
Definition: param_data.hpp:71
bool wasPassed
True if the option was passed to the program.
Definition: param_data.hpp:66