{
if(arg_type==REQUIRED_ARG)
throw usage_error("--"+lng+" requires an argument");
+
++seen_count;
if(ext_seen_count)
*ext_seen_count = seen_count;
- store();
+ try
+ {
+ store();
+ }
+ catch(const exception &e)
+ {
+ throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")");
+ }
}
void GetOpt::OptBase::process(const string &arg)
{
if(arg_type==NO_ARG)
throw usage_error("--"+lng+" takes no argument");
+
++seen_count;
if(ext_seen_count)
*ext_seen_count = seen_count;
- store(arg);
+ try
+ {
+ store(arg);
+ }
+ catch(const exception &e)
+ {
+ throw usage_error("Invalid argument for --"+lng+" ("+e.what()+")");
+ }
}
} // namespace Msp
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)); }
};
bool help;