12 #ifndef __PTPMGMT_OPT_H
13 #define __PTPMGMT_OPT_H
20 #ifdef __PTPMGMT_HAVE_GETOPT_H
24 __PTPMGMT_NAMESPACE_BEGIN
51 size_t m_max_arg_name = 0;
52 std::vector<option> m_long_opts_list;
54 size_t m_last_strings = 0;
55 std::map<int, std::string> m_opts;
56 std::string m_net_opts, m_all_opts, m_all_short_opts, m_with_opts, m_msg;
57 char m_net_select = 0;
58 int m_argc = 0, m_end_optind = 0;
59 bool m_useDef =
false;
64 std::string m_start, m_end;
66 helpStore(
const char *s,
const char *e =
nullptr): m_start(s) {
70 helpStore &addStart(
const std::string &s) {m_start += s;
return *
this;}
71 helpStore &addStart(
const char s) {m_start += s;
return *
this;}
72 helpStore &addEnd(
const std::string &e) {m_end += e;
return *
this;}
73 std::string get(
size_t length)
const;
76 std::vector<helpStore> helpVec;
77 bool helpUpdate =
false;
112 const std::string &
get_msg()
const {
return m_msg; }
148 bool have(
char opt)
const {
return m_opts.count(opt) > 0; }
155 const std::string &
val(
char opt)
const;
163 {
return have(opt) ? m_opts.at(opt).c_str() :
""; }
171 {
return have(opt) ? atoi(m_opts.at(opt).c_str()) : 0; }
182 bool have_more()
const {
return m_end_optind < m_argc; }
191 __PTPMGMT_DEPRECATED(
int procces_next()
const,
return process_next())
195 __PTPMGMT_NAMESPACE_END
Buffer for send, receive, build, and parse.
C interface to command line options parsing class.
Hold and process options.
Definition: opt.h:47
int val_i(char opt) const
Definition: opt.h:170
bool insert(const Pmc_option &opt)
const char * val_c(char opt) const
Definition: opt.h:162
char get_net_transport() const
Definition: opt.h:177
const char * get_msg_c() const
Definition: opt.h:117
loop_val parse_options(int argc, char *const argv[])
const std::string & get_msg() const
Definition: opt.h:112
Options(bool useDef=true)
bool have(char opt) const
Definition: opt.h:148
loop_val
Definition: opt.h:81
@ OPT_DONE
Definition: opt.h:85
@ OPT_HELP
Definition: opt.h:84
@ OPT_MSG
Definition: opt.h:83
@ OPT_ERR
Definition: opt.h:82
int process_next() const
Definition: opt.h:187
const std::string & val(char opt) const
bool have_more() const
Definition: opt.h:182
Structre to add new option.
Definition: opt.h:29
std::string arg_help
Definition: opt.h:39
std::string help_msg
Definition: opt.h:38
std::string def_val
Definition: opt.h:40
char short_name
Definition: opt.h:34
bool have_arg
Definition: opt.h:36
std::string long_name
Definition: opt.h:35
bool long_only
Definition: opt.h:37