X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fcore%2Fgetopt.h;h=53c9ddf2f0100681099df40466e125914e5e74b3;hb=9c6c946ed658abd50be9d597cb2c722592d660ae;hp=dbc0f9cef0284e94d4f5ec66b890e94700515e4d;hpb=03d324e20b1062fbc9a6b60106b370c7194a6141;p=libs%2Fcore.git diff --git a/source/core/getopt.h b/source/core/getopt.h index dbc0f9c..53c9ddf 100644 --- a/source/core/getopt.h +++ b/source/core/getopt.h @@ -72,6 +72,8 @@ public: metavariable is used to denote the argument in the option list. */ virtual Option &set_help(const std::string &, const std::string &) = 0; + virtual Option &bind_seen_count(unsigned &) = 0; + /// Returns the number of times this option was seen on the command line. virtual unsigned get_seen_count() const = 0; }; @@ -84,6 +86,7 @@ private: std::string lng; ArgType arg_type; unsigned seen_count; + unsigned *ext_seen_count; std::string help; std::string metavar; @@ -93,6 +96,7 @@ private: virtual OptBase &set_help(const std::string &); virtual OptBase &set_help(const std::string &, const std::string &); + virtual OptBase &bind_seen_count(unsigned &); char get_short() const { return shrt; } const std::string &get_long() const { return lng; } ArgType get_arg_type() const { return arg_type; } @@ -118,16 +122,7 @@ private: virtual void store() { } virtual void store(const std::string &a) - { - try - { - data = lexical_cast(a); - } - catch(const lexical_error &e) - { - throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")"); - } - } + { data = lexical_cast(a); } }; template @@ -143,16 +138,7 @@ private: virtual void store() { } virtual void store(const std::string &a) - { - try - { - data.push_back(lexical_cast(a)); - } - catch(const lexical_error &e) - { - throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")"); - } - } + { data.push_back(lexical_cast(a)); } }; bool help;