X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fgetopt.cpp;h=911b673d9b1d28358966a302de44aaf6428735e3;hb=03d324e20b1062fbc9a6b60106b370c7194a6141;hp=cfc9d7a02fa99e547cc19afefecf6c32250691b3;hpb=d16185720fa344263367dbd50c61bfc8183d99a4;p=libs%2Fcore.git diff --git a/source/core/getopt.cpp b/source/core/getopt.cpp index cfc9d7a..911b673 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((*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)