diff options
Diffstat (limited to 'src/lib/netlist/plib/poptions.h')
-rw-r--r-- | src/lib/netlist/plib/poptions.h | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/lib/netlist/plib/poptions.h b/src/lib/netlist/plib/poptions.h index 984db395e2f..1665738ebe4 100644 --- a/src/lib/netlist/plib/poptions.h +++ b/src/lib/netlist/plib/poptions.h @@ -15,22 +15,24 @@ #include "pstring.h" #include "plists.h" +PLIB_NAMESPACE_START() + /*************************************************************************** Options ***************************************************************************/ -class poptions; +class options; -class poption +class option { public: - poption() + option() : m_short(""), m_long(""), m_help(""), m_has_argument(false) {} - poption(pstring ashort, pstring along, pstring help, bool has_argument, poptions *parent = nullptr); + option(pstring ashort, pstring along, pstring help, bool has_argument, options *parent = nullptr); - virtual ~poption() + virtual ~option() { } @@ -45,11 +47,11 @@ public: private: }; -class poption_str : public poption +class option_str : public option { public: - poption_str(pstring ashort, pstring along, pstring defval, pstring help, poptions *parent = nullptr) - : poption(ashort, along, help, true, parent), m_val(defval) + option_str(pstring ashort, pstring along, pstring defval, pstring help, options *parent = nullptr) + : option(ashort, along, help, true, parent), m_val(defval) {} virtual int parse(pstring argument) override { m_val = argument; return 0; } @@ -59,11 +61,11 @@ private: pstring m_val; }; -class poption_str_limit : public poption +class option_str_limit : public option { public: - poption_str_limit(pstring ashort, pstring along, pstring defval, pstring limit, pstring help, poptions *parent = nullptr) - : poption(ashort, along, help, true, parent), m_val(defval), m_limit(limit, ":") + option_str_limit(pstring ashort, pstring along, pstring defval, pstring limit, pstring help, options *parent = nullptr) + : option(ashort, along, help, true, parent), m_val(defval), m_limit(limit, ":") {} virtual int parse(pstring argument) override @@ -83,11 +85,11 @@ private: pstring_vector_t m_limit; }; -class poption_bool : public poption +class option_bool : public option { public: - poption_bool(pstring ashort, pstring along, pstring help, poptions *parent = nullptr) - : poption(ashort, along, help, false, parent), m_val(false) + option_bool(pstring ashort, pstring along, pstring help, options *parent = nullptr) + : option(ashort, along, help, false, parent), m_val(false) {} virtual int parse(ATTR_UNUSED pstring argument) override { m_val = true; return 0; } @@ -97,11 +99,11 @@ private: bool m_val; }; -class poption_double : public poption +class option_double : public option { public: - poption_double(pstring ashort, pstring along, double defval, pstring help, poptions *parent = nullptr) - : poption(ashort, along, help, true, parent), m_val(defval) + option_double(pstring ashort, pstring along, double defval, pstring help, options *parent = nullptr) + : option(ashort, along, help, true, parent), m_val(defval) {} virtual int parse(pstring argument) override @@ -116,13 +118,13 @@ private: double m_val; }; -class poptions +class options { public: - poptions() {} + options() {} - poptions(poption *o[]) + options(option *o[]) { int i=0; while (o[i] != nullptr) @@ -132,12 +134,12 @@ public: } } - ~poptions() + ~options() { m_opts.clear(); } - void register_option(poption *opt) + void register_option(option *opt) { m_opts.push_back(opt); } @@ -149,7 +151,7 @@ public: for (int i=1; i<argc; ) { pstring arg(argv[i]); - poption *opt = nullptr; + option *opt = nullptr; if (arg.startsWith("--")) { @@ -182,7 +184,7 @@ public: for (std::size_t i=0; i<m_opts.size(); i++ ) { - poption *opt = m_opts[i]; + option *opt = m_opts[i]; pstring line = ""; if (opt->m_short != "") line += " -" + opt->m_short; @@ -203,7 +205,7 @@ public: private: - poption *getopt_short(pstring arg) + option *getopt_short(pstring arg) { for (std::size_t i=0; i < m_opts.size(); i++) { @@ -212,7 +214,7 @@ private: } return nullptr; } - poption *getopt_long(pstring arg) + option *getopt_long(pstring arg) { for (std::size_t i=0; i < m_opts.size(); i++) { @@ -222,16 +224,17 @@ private: return nullptr; } - pvector_t<poption *> m_opts; + pvector_t<option *> m_opts; pstring m_app; }; -poption::poption(pstring ashort, pstring along, pstring help, bool has_argument, poptions *parent) +option::option(pstring ashort, pstring along, pstring help, bool has_argument, options *parent) : m_short(ashort), m_long(along), m_help(help), m_has_argument(has_argument) { if (parent != nullptr) parent->register_option(this); } +PLIB_NAMESPACE_END() #endif /* POPTIONS_H_ */ |