diff --git a/options.cpp b/options.cpp index d36e4dd2..879f03f4 100644 --- a/options.cpp +++ b/options.cpp @@ -22,6 +22,11 @@ #include "config.h" +#include "debug.hpp" +#include "types.hpp" +#include "types/casts.hpp" + +#include #include #include #include @@ -29,7 +34,6 @@ #include #include #include -#include #include @@ -292,21 +296,20 @@ helpoption::execute (void) { * Command line processing options */ -processor::processor () -{ add_option (new helpoption (this)); } - - -processor::~processor () { - for (auto i: m_options) - delete i; +processor::processor () { + add_option (make_unique (this)); } +processor::~processor () +{ ; } + + void processor::print_usage (void) { cout << "Usage: " << m_command << " [options]" << endl; - for (const auto i: m_options) + for (const auto &i: m_options) cout << '\t' << *i << endl; } @@ -437,7 +440,7 @@ processor::parse_args (int argc, const char ** argv) { // Must make sure each option has a chance to reset state (clear flags, // etc) between parses - for (auto i: m_options) + for (auto &i: m_options) i->reset (); const unsigned int FIRST_ARGUMENT = 1; @@ -468,62 +471,76 @@ processor::parse_args (int argc, const char ** argv) { exit (EXIT_FAILURE); } - for (auto i: m_options) + for (auto &i: m_options) i->finish (); } void -processor::add_option (option *opt) { +processor::add_option (std::unique_ptr