15 #ifndef CMD_LINE_OPTS_H
16 #define CMD_LINE_OPTS_H
66 Option (
char shopt_,
const string& lopt_,
type_t type_,
void* val_);
90 m_short_name (
' '), m_long_name (
""), m_type (none_t), m_val (NULL)
97 m_short_name (shopt_), m_long_name (lopt_),
98 m_type (type_), m_val (val_)
135 bool add_flag_opt (
const char c,
const string& s,
bool* f);
143 bool add_opt (
const char c,
const string& s,
string* str);
151 bool add_opt (
const char c,
const string& s,
int* i);
159 bool add_opt (
const char c,
const string& s,
unsigned int* ui);
167 bool add_opt (
const char c,
const string& s,
long* l);
175 bool add_opt (
const char c,
const string& s,
unsigned long* ul);
183 bool add_opt (
const char c,
const string& s,
double* d);
191 bool add_opt (
const char c,
const string& s,
float* f);
223 bool rm_opt (
const char c_,
const string& s_);
252 static void str_to_argv (
const string& src_,
int& argc_,
char**& argv_);
262 bool is_valid (
const char sopt_,
const string& lopt_);
280 virtual void pos_arg (
const char* arg_);
Convert argument to function with one argument.
virtual void pos_arg(const char *arg_)
Process positional argument arg_.
Class CmdLineOpts messages.
const char * get_opt_error() const
If previous call to one of member functions returned false, retrieve detailed error message...
static void free_argv(char **&argv_)
Free up memory allocated by str_to_argv() function.
bool rm_opt(const char c_, const string &s_)
Remove option for the option list.
OptionSet m_opts_set
Options set.
Option()
Private default constructor.
char m_short_name
One-letter option name.
void set_error_none()
Reset error message to an empty string.
bool add_flag_opt(const char c, const string &s, bool *f)
Add binary flag option.
Convert argument to unsinged long.
bool parse_args(const char *argv[])
Parse command line arguments based on installed options set.
Convert argument to STL string.
CmdLineOpts()
Default constructor.
string m_error
Last reported error.
Convert argument to long.
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
bool assign(Option *node_, const char *op_)
Perform value assignment to the node.
vector< Option > OptionSet
A collection of assert function wrappers.
virtual ~CmdLineOpts()
Do-nothing destructor.
void(* OPTS_FUNC_ONE)(const string &)
Convert argument to double.
static void str_to_argv(const string &src_, int &argc_, char **&argv_)
Static function.
No argument; bool value is flipped.
Option * find_option(const char *str_)
Locate option in the options set.
bool is_valid(const char sopt_, const string &lopt_)
Detect if supplied option is valid.
string m_long_name
Long option name.
void dump() const
Write options set to the log file.
Convert argument to function.
int parse_config_file(IniFile &inifile_)
Parse configuration parameters found in [options] section of the INI file.
Convert argument to float.
void dump() const
Write object state to the log file.
type_t m_type
Option type.
bool add_opt(const char c, const string &s, string *str)
Add an option with STL string argument.
void * m_val
Pointer to the option value.
Convert argument to unsigned int.
const char * type_c_str()
Return the type of the Option object.