+ typedef std::list<OptionImpl *> OptionList;
+ typedef std::list<ArgumentImpl *> ArgumentList;
+
+ bool help;
+ OptionList opts;
+ ArgumentList args;
+ std::vector<std::string> args_raw;
+
+public:
+ GetOpt();
+ ~GetOpt();
+
+ /** Returns any non-option arguments encountered during processing.
+ Deprecated; use add_argument instead. */
+ DEPRECATED const std::vector<std::string> &get_args() const { return args_raw; }
+
+ /** Adds an option with both short and long forms. Processing depends on
+ the type of the destination variable and whether an argument is taken or
+ not. With an argument, the value is lexical_cast to the appropriate type
+ and stored in the destination. Without an argument, a bool will be set to
+ true and an unsigned will be incremented; any other type will be ignored. */
+ template<typename T>
+ Option &add_option(char s, const std::string &l, T &d, ArgType a = NO_ARG)
+ { return add_option(s, l, SimpleStore<T>(d), a); }
+
+ /** Adds an option with both short and long forms. The option may be
+ specified multiple times, and the argument from each occurrence is stored in
+ the list. The argument type must be REQUIRED_ARG. */
+ template<typename T>
+ Option &add_option(char s, const std::string &l, std::vector<T> &d, ArgType a = REQUIRED_ARG)
+ { return add_option(s, l, ListStore<std::vector<T> >(d), a); }
+
+ /** Adds an option with both short and long forms. The option may be
+ specified multiple times, and the argument from each occurrence is stored in
+ the list. The argument type must be REQUIRED_ARG. */
+ template<typename T>
+ Option &add_option(char s, const std::string &l, std::list<T> &d, ArgType a = REQUIRED_ARG)
+ { return add_option(s, l, ListStore<std::list<T> >(d), a); }
+
+ /** Adds an option with only a long form. */
+ template<typename T>
+ Option &add_option(const std::string &l, T &d, ArgType a)
+ { return add_option(0, l, d, a); }
+
+ /** Adds a positional argument. The value will be lexical_cast to the
+ appropriate type and stored in the destination. */
+ template<typename T>
+ Argument &add_argument(const std::string &n, T &d, ArgType a = REQUIRED_ARG)
+ { return add_argument(n, SimpleStore<T>(d), a); }
+
+ /** Adds a positional argument list. If the list is declared as required,
+ at least one element must be given; an optional list may be empty. Only one
+ list may be added, and optional fixed arguments can't be used with it. */
+ template<typename T>
+ Argument &add_argument(const std::string &n, std::vector<T> &d, ArgType a = REQUIRED_ARG)
+ { return add_argument(n, ListStore<std::vector<T> >(d), a); }
+
+ /** Adds a positional argument list. If the list is declared as required,
+ at least one element must be given; an optional list may be empty. Only one
+ list may be added, and optional fixed arguments can't be used with it. */
+ template<typename T>
+ Argument &add_argument(const std::string &n, std::list<T> &d, ArgType a = REQUIRED_ARG)
+ { return add_argument(n, ListStore<std::list<T> >(d), a); }
+
+private:
+ OptionImpl &add_option(char, const std::string &, const Store &, ArgType);
+ ArgumentImpl &add_argument(const std::string &, const Store &, ArgType);
+
+ OptionImpl &get_option(char);
+ OptionImpl &get_option(const std::string &);