X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fgetopt.cpp;h=498977569e2179ee203de59f0e1624b536031f70;hp=8fd13a0c0593bc28dab3f276597b8de8a2cf6dd7;hb=1f262a37bf2c0531f7474df3cdb60d608bfdbba1;hpb=c76bd823b81d723d8cd4531631a4b18544f1981a diff --git a/source/core/getopt.cpp b/source/core/getopt.cpp index 8fd13a0..4989775 100644 --- a/source/core/getopt.cpp +++ b/source/core/getopt.cpp @@ -66,7 +66,7 @@ string GetOpt::generate_help() const for(list::const_iterator i=opts.begin(); (!any_short && i!=opts.end()); ++i) any_short=(*i)->get_short(); - unsigned maxw=0; + string::size_type maxw=0; list switches; for(list::const_iterator i=opts.begin(); i!=opts.end(); ++i) { @@ -247,4 +247,22 @@ GetOpt::OptBase &GetOpt::OptBase::set_help(const string &h, const string &m) return *this; } +void GetOpt::OptBase::process() +{ + if(arg_type==REQUIRED_ARG) + throw UsageError("--"+lng+" requires an argument"); + ++seen_count; + + store(); +} + +void GetOpt::OptBase::process(const string &arg) +{ + if(arg_type==NO_ARG) + throw UsageError("--"+lng+" takes no argument"); + ++seen_count; + + store(arg); +} + } // namespace Msp