]> git.tdb.fi Git - libs/core.git/blobdiff - source/core/getopt.h
Make sure all files have the correct header
[libs/core.git] / source / core / getopt.h
index 2824a0b7c7f3b79378477853fa8874300a98eb75..7e5e25f5a1a9ee9994995cc9c77ca4355db8e8b7 100644 (file)
@@ -7,10 +7,10 @@ Distributed under the LGPL
 #ifndef MSP_CORE_GETOPT_H_
 #define MSP_CORE_GETOPT_H_
 
-#include <list>
 #include <sstream>
 #include <string>
-#include "error.h"
+#include <vector>
+#include "except.h"
 
 namespace Msp {
 
@@ -46,25 +46,6 @@ public:
                OptBase(char s, const std::string &l, ArgType a): shrt(s), lng(l), arg_type(a), seen_count(0) { }
        };
 
-       const std::list<std::string> &get_args() const { return args; }
-
-       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(); }
-       
-       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(); }
-       
-       template<typename T>
-       OptBase &add_option(const std::string &l, T &d, ArgType a)
-       { return add_option(0, l, d, a); }
-
-       std::string generate_usage(const std::string &) const;
-       std::string generate_help() const;
-       void operator()(unsigned, const char *const *);
-
-       ~GetOpt();
 private:
        template<typename T>
        class Option: public OptBase
@@ -127,8 +108,30 @@ private:
                T &data;
        };
 
-       std::list<OptBase *>   opts;
-       std::list<std::string> args;
+       std::list<OptBase *> opts;
+       std::vector<std::string> args;
+
+public:
+       ~GetOpt();
+
+       const std::vector<std::string> &get_args() const { return args; }
+
+       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(); }
+       
+       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(); }
+       
+       template<typename T>
+       OptBase &add_option(const std::string &l, T &d, ArgType a)
+       { return add_option(0, l, d, a); }
+
+       std::string generate_usage(const std::string &) const;
+       std::string generate_help() const;
+       void operator()(unsigned, const char *const *);
+private:
 
        OptBase &get_option(char);
        OptBase &get_option(const std::string &);