X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fgetopt.cpp;h=766b858e8d4aa4b2212b94f51756cad0a07a964b;hp=cfc9d7a02fa99e547cc19afefecf6c32250691b3;hb=154d5f43f7a6633a4937499039fc1b1b713e0c0c;hpb=d16185720fa344263367dbd50c61bfc8183d99a4 diff --git a/source/core/getopt.cpp b/source/core/getopt.cpp index cfc9d7a..766b858 100644 --- a/source/core/getopt.cpp +++ b/source/core/getopt.cpp @@ -17,6 +17,23 @@ GetOpt::~GetOpt() delete *i; } +GetOpt::OptBase &GetOpt::add_option(OptBase *opt) +{ + for(list::iterator i=opts.begin(); i!=opts.end(); ) + { + if((opt->get_short()!=0 && (*i)->get_short()==opt->get_short()) || (*i)->get_long()==opt->get_long()) + { + delete *i; + opts.erase(i++); + } + else + ++i; + } + + opts.push_back(opt); + return *opts.back(); +} + GetOpt::OptBase &GetOpt::get_option(char s) { for(list::iterator i=opts.begin(); i!=opts.end(); ++i)