X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fgetopt.h;h=a3b7ae405ec567c4d9b0fb6a8966d89bed4fb689;hp=56ab05123584ef83fcc51cd838802ef4a941c453;hb=736d15fbdee0ea47b38a4d5fcd321e86eb21b465;hpb=d16185720fa344263367dbd50c61bfc8183d99a4 diff --git a/source/core/getopt.h b/source/core/getopt.h index 56ab051..a3b7ae4 100644 --- a/source/core/getopt.h +++ b/source/core/getopt.h @@ -123,17 +123,19 @@ public: template OptBase &add_option(char s, const std::string &l, T &d, ArgType a = NO_ARG) - { opts.push_back(new Option(s, l, d, a)); return *opts.back(); } + { return add_option(new Option(s, l, d, a)); } template OptBase &add_option(char s, const std::string &l, std::list &d, ArgType a = REQUIRED_ARG) - { opts.push_back(new ListOption >(s, l, d, a)); return *opts.back(); } + { return add_option(new ListOption >(s, l, d, a)); } template OptBase &add_option(const std::string &l, T &d, ArgType a) { return add_option(0, l, d, a); } private: + OptBase &add_option(OptBase *); + OptBase &get_option(char); OptBase &get_option(const std::string &); @@ -158,8 +160,11 @@ public: std::string generate_help() const; }; -template<> inline void GetOpt::Option::store() { data = true; } -template<> inline void GetOpt::Option::store() { ++data; } +template<> inline void GetOpt::Option::store() +{ data = true; } + +template<> inline void GetOpt::Option::store() +{ ++data; } template<> inline void GetOpt::Option::store(const std::string &a) { data = a; }