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;
};
std::string lng;
ArgType arg_type;
unsigned seen_count;
+ unsigned *ext_seen_count;
std::string help;
std::string metavar;
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; }
virtual void store() { }
virtual void store(const std::string &a)
- {
- try
- {
- data = lexical_cast<T>(a);
- }
- catch(const lexical_error &e)
- {
- throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")");
- }
- }
+ { data = lexical_cast<T>(a); }
};
template<typename T>
virtual void store() { }
virtual void store(const std::string &a)
- {
- try
- {
- data.push_back(lexical_cast<typename T::value_type>(a));
- }
- catch(const lexical_error &e)
- {
- throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")");
- }
- }
+ { data.push_back(lexical_cast<typename T::value_type>(a)); }
};
+ typedef std::list<OptBase *> OptionList;
+
bool help;
- std::list<OptBase *> opts;
+ OptionList opts;
std::vector<std::string> args;
public: