Go to the documentation of this file.
13 #ifndef MLPACK_CORE_BINDINGS_CLI_CLI_OPTION_HPP
14 #define MLPACK_CORE_BINDINGS_CLI_CLI_OPTION_HPP
68 const std::string& identifier,
69 const std::string& description,
70 const std::string& alias,
71 const std::string& cppName,
72 const bool required =
false,
73 const bool input =
true,
74 const bool noTranspose =
false,
75 const std::string& =
"")
80 data.
desc = description;
81 data.
name = identifier;
83 data.
alias = alias[0];
93 if (std::is_same<
typename std::remove_pointer<N>::type,
95 std::remove_pointer<N>::type>::type>::value)
97 data.
value = boost::any(defaultValue);
102 data.
value = boost::any(std::tuple<N, decltype(tmp)>(defaultValue, tmp));
105 const std::string tname = data.
tname;
107 typename std::remove_pointer<N>::type>(identifier);
108 std::string progOptId = (alias[0] !=
'\0') ? boostName +
","
109 + std::string(1, alias[0]) : boostName;
112 const std::map<std::string, util::ParamData>& parameters =
114 if (parameters.count(boostName) > 0)
119 #define BASH_RED "\033[0;31m"
120 #define BASH_CLEAR "\033[0m"
123 #define BASH_CLEAR ""
133 outstr <<
"Parameter --" << boostName <<
" (" << data.
alias <<
") "
134 <<
"is defined multiple times with the same identifiers."
146 &GetPrintableParam<N>;
153 &MapParameterName<N>;
156 &GetPrintableParamName<N>;
158 &GetPrintableParamValue<N>;
160 &GetAllocatedMemory<N>;
162 &DeleteAllocatedMemory<N>;
static CLI & GetSingleton()
Retrieve the singleton.
std::string documentation
Documentation for what the program does.
std::string MapParameterName(const std::string &identifier, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>>::type *=0)
If needed, map the parameter name to the name that is used by boost::program_options.
ProgramDoc(const std::string &programName, const std::string &documentation)
Construct a ProgramDoc object.
std::string cppType
The true name of the type, as it would be written in C++.
boost::any value
The actual value that is held.
bool persistent
If this should be preserved across different settings (i.e.
static void Add(util::ParamData &&d)
Adds a parameter to the hierarchy; use the PARAM_*() macros instead of this (i.e.
A static object whose constructor registers program documentation with the CLI class.
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.
bool input
True if this option is an input option (otherwise, it is output).
This structure holds all of the information about a single parameter, including its value (which is s...
std::string desc
Description of this parameter, if any.
FunctionMapType functionMap
bool wasPassed
True if the option was passed to the program.
std::string name
Name of this parameter.
#define TYPENAME(x)
The TYPENAME macro is used internally to convert a type into a string.
std::string programName
The name of the program.
static std::map< std::string, util::ParamData > & Parameters()
Return a modifiable list of parameters that CLI knows about.
A static object whose constructor registers a parameter with the CLI class.
bool required
True if this option is required.
bool loaded
If this is an input parameter that needs extra loading, this indicates whether or not it has been loa...
char alias
Alias for this parameter.
std::string tname
Type information of this parameter.
Allows us to output to an ostream with a prefix at the beginning of each line, in the same way we wou...
Utility struct to return the type that boost::program_options should accept for a given input type.
bool noTranspose
True if this is a matrix that should not be transposed.