]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/getopt.h
Replace earlier options sharing the same short or long name
[libs/core.git] / source / core / getopt.h
index 56ab05123584ef83fcc51cd838802ef4a941c453..a3b7ae405ec567c4d9b0fb6a8966d89bed4fb689 100644 (file)
@@ -123,17 +123,19 @@ public:
 
        template<typename T>
        OptBase &add_option(char s, const std::string &l, T &d, ArgType a = NO_ARG)
-       { opts.push_back(new Option<T>(s, l, d, a)); return *opts.back(); }
+       { return add_option(new Option<T>(s, l, d, a)); }
        
        template<typename T>
        OptBase &add_option(char s, const std::string &l, std::list<T> &d, ArgType a = REQUIRED_ARG)
-       { opts.push_back(new ListOption<std::list<T> >(s, l, d, a)); return *opts.back(); }
+       { return add_option(new ListOption<std::list<T> >(s, l, d, a)); }
        
        template<typename T>
        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<bool>::store()     { data = true; }
-template<> inline void GetOpt::Option<unsigned>::store() { ++data; }
+template<> inline void GetOpt::Option<bool>::store()
+{ data = true; }
+
+template<> inline void GetOpt::Option<unsigned>::store()
+{ ++data; }
 
 template<> inline void GetOpt::Option<std::string>::store(const std::string &a)
 { data = a; }