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_);
A collection of assert function wrappers.
#define trace_with_mask(s, m)
trace_with_mask() is used to trace function call chain in C++ program.
Option * find_option(const char *str_)
Locate option in the options set.
string m_error
Last reported error.
bool parse_args(const char *argv[])
Parse command line arguments based on installed options set.
void(* OPTS_FUNC_ONE)(const string &)
void set_error_none()
Reset error message to an empty string.
virtual ~CmdLineOpts()
Do-nothing destructor.
bool add_opt(const char c, const string &s, string *str)
Add an option with STL string argument.
bool rm_opt(const char c_, const string &s_)
Remove option for the option list.
OptionSet m_opts_set
Options set.
bool add_flag_opt(const char c, const string &s, bool *f)
Add binary flag option.
bool assign(Option *node_, const char *op_)
Perform value assignment to the node.
int parse_config_file(IniFile &inifile_)
Parse configuration parameters found in [options] section of the INI file.
virtual void pos_arg(const char *arg_)
Process positional argument arg_.
static void str_to_argv(const string &src_, int &argc_, char **&argv_)
Static function.
vector< Option > OptionSet
void dump() const
Write options set to the log file.
CmdLineOpts()
Default constructor.
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 is_valid(const char sopt_, const string &lopt_)
Detect if supplied option is valid.
@ func_one_t
Convert argument to function with one argument
@ func_t
Convert argument to function
@ string_t
Convert argument to STL string
@ ulong_t
Convert argument to unsigned long
@ float_t
Convert argument to float
@ long_t
Convert argument to long
@ double_t
Convert argument to double
@ flag_t
No argument; bool value is flipped.
@ int_t
Convert argument to int
@ uint_t
Convert argument to unsigned int
type_t m_type
Option type.
string m_long_name
Long option name.
Option()
Private default constructor.
void * m_val
Pointer to the option value.
void dump() const
Write object state to the log file.
const char * type_c_str()
Return the type of the Option object.
char m_short_name
One-letter option name.
@ CMDLINEOPTS
Class CmdLineOpts messages