From 97b67170277437131adf6ed4d60139c172529e4f Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Tue, 26 Mar 2019 11:13:37 +1100 Subject: (nw) Clean up the mess on master MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This effectively reverts b380514764cf857469bae61c11143a19f79a74c5 and c24473ddff715ecec2e258a6eb38960cf8c8e98e, restoring the state at 598cd5227223c3b04ca31f0dbc1981256d9ea3ff. Before pushing, please check that what you're about to push is sane. Check your local commit log and ensure there isn't anything out-of-place before pushing to mainline. When things like this happen, it wastes everyone's time. I really don't need this in a week when real work™ is busting my balls and I'm behind where I want to be with preparing for MAME release. --- src/lib/netlist/plib/poptions.cpp | 154 ++++++++++++++++++++------------------ 1 file changed, 80 insertions(+), 74 deletions(-) (limited to 'src/lib/netlist/plib/poptions.cpp') diff --git a/src/lib/netlist/plib/poptions.cpp b/src/lib/netlist/plib/poptions.cpp index 910660acb3d..4a3d32c4723 100644 --- a/src/lib/netlist/plib/poptions.cpp +++ b/src/lib/netlist/plib/poptions.cpp @@ -6,77 +6,39 @@ */ #include "poptions.h" +#include "pexception.h" +#include "ptypes.h" namespace plib { /*************************************************************************** Options ***************************************************************************/ - option_base::option_base(options &parent, pstring help) + option_base::option_base(options &parent, const pstring &help) : m_help(help) { parent.register_option(this); } - option_base::~option_base() - { - } - - option_group::~option_group() - { - } - - option_example::~option_example() - { - } - - option::option(options &parent, pstring ashort, pstring along, pstring help, bool has_argument) + option::option(options &parent, const pstring &ashort, const pstring &along, const pstring &help, bool has_argument) : option_base(parent, help), m_short(ashort), m_long(along), m_has_argument(has_argument), m_specified(false) { } - option::~option() - { - } - int option_str::parse(const pstring &argument) { m_val = argument; return 0; } - int option_str_limit::parse(const pstring &argument) - { - if (plib::container::contains(m_limit, argument)) - { - m_val = argument; - return 0; - } - else - return 1; - } - int option_bool::parse(const pstring &argument) { + unused_var(argument); m_val = true; return 0; } - int option_double::parse(const pstring &argument) - { - bool err = false; - m_val = argument.as_double(&err); - return (err ? 1 : 0); - } - - int option_long::parse(const pstring &argument) - { - bool err = false; - m_val = argument.as_long(&err); - return (err ? 1 : 0); - } - int option_vec::parse(const pstring &argument) { bool err = false; @@ -85,53 +47,88 @@ namespace plib { } options::options() + : m_other_args(nullptr) { } - options::options(option *o[]) + options::options(option **o) + : m_other_args(nullptr) { int i=0; while (o[i] != nullptr) { - m_opts.push_back(o[i]); + register_option(o[i]); i++; } } - options::~options() + void options::register_option(option_base *opt) { - m_opts.clear(); + m_opts.push_back(opt); } - void options::register_option(option_base *opt) + void options::check_consistency() { - m_opts.push_back(opt); + for (auto &opt : m_opts) + { + auto *o = dynamic_cast