diff --git a/options.cpp b/options.cpp index a33d359d..d36e4dd2 100644 --- a/options.cpp +++ b/options.cpp @@ -22,17 +22,15 @@ #include "config.h" -#include -#include - #include +#include +#include #include #include -#include -#include - -#include -#include +#include +#include +#include +#include using namespace std; @@ -57,13 +55,16 @@ option::option (char _letter, -void option::execute (void) { +void +option::execute (void) { throw runtime_error( "Cannot provide no value for the option '" + m_longopt + "'" ); } -void option::execute (const string& data) { + +void +option::execute (const string& data) { assert(data.size() > 0); throw runtime_error( "Cannot provide a value for the option '" + m_longopt + "'" @@ -71,7 +72,8 @@ void option::execute (const string& data) { } -ostream& operator<< (ostream & os, const option& opt) { +ostream& +operator<< (ostream & os, const option& opt) { os << (opt.is_required () ? " -" : "[-" ) << opt.shortopt () << (opt.is_required () ? " \t" : "]\t") << opt.longopt () << "\t" << opt.description (); @@ -177,7 +179,6 @@ bytesoption::execute (const std::string& data) { size_t defaultvalue = *m_data; - try { bytesmodifier modifier = m_modifier; off_t cursor = data.size () - 1; @@ -231,7 +232,7 @@ bytesoption::execute (const std::string& data) { --cursor; assert (cursor >= 0); - multiplier = pow ((double)modifier_factor, (int)specified); + multiplier = std::pow (modifier_factor, (int)specified); get_arg (data.substr(0, cursor + 1), m_data); *m_data *= multiplier; } catch (...) { @@ -245,6 +246,7 @@ bytesoption::execute (const std::string& data) { m_found = true; } + /* * Internal helper options. Print help and usage. * A callback to the processor which triggers output of the help message. @@ -264,22 +266,23 @@ class helpoption : public option { helpoption (processor * _processor): option (HELP_CHARACTER, HELP_NAME, HELP_DESCRIPTION, false), m_processor (_processor) - { ; } + { ; } virtual void execute (void); virtual void execute (const std::string& data) - { option::execute (data); } + { option::execute (data); } }; const char helpoption::HELP_CHARACTER = 'h'; const char *helpoption::HELP_NAME = "help"; const char *helpoption::HELP_DESCRIPTION = -"display help and usage information"; + "display help and usage information"; -void helpoption::execute (void) { +void +helpoption::execute (void) { m_processor->print_usage (); exit (EXIT_SUCCESS); } @@ -294,17 +297,17 @@ processor::processor () processor::~processor () { - for(auto i = m_options.begin(); i != m_options.end(); i++) - delete *i; + for (auto i: m_options) + delete i; } -void processor::print_usage (void) { +void +processor::print_usage (void) { cout << "Usage: " << m_command << " [options]" << endl; - for(list