]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * Copyright (c) 2002 Robert Collins. | |
3 | * Copyright (c) 2003 Robert Collins. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * A copy of the GNU General Public License can be found at | |
11 | * http://www.gnu.org/ | |
12 | * | |
13 | * Written by Robert Collins <robertc@hotmail.com> | |
14 | * | |
15 | */ | |
16 | ||
17 | #ifndef _OPTIONSET_H_ | |
18 | #define _OPTIONSET_H_ | |
19 | ||
20 | #include <iosfwd> | |
21 | #include <vector> | |
22 | #include "getopt++/Option.h" | |
23 | ||
24 | typedef const std::string (*StrLookup)(unsigned int); | |
25 | ||
26 | class OptionSet | |
27 | { | |
28 | public: | |
29 | OptionSet(); | |
30 | virtual ~OptionSet(); | |
31 | virtual void Register (Option *); | |
32 | virtual bool Process (int argc, char **argv, Option *nonOptionHandler); | |
33 | virtual bool Process (std::vector<std::string> const &parms, Option *nonOptionHandler); | |
34 | virtual bool process (Option *nonOptionHandler); | |
35 | virtual void ParameterUsage (std::ostream &, StrLookup strLookup); | |
36 | virtual std::vector<Option *> const &optionsInSet() const; | |
37 | virtual std::vector<std::string> const &nonOptions() const; | |
38 | virtual std::vector<std::string> const &remainingArgv() const; | |
39 | protected: | |
40 | OptionSet (OptionSet const &); | |
41 | OptionSet &operator= (OptionSet const &); | |
42 | // force initialisation of variables | |
43 | void Init (); | |
44 | private: | |
45 | void processOne(); | |
46 | bool isOption(std::string::size_type) const; | |
47 | void doOption(std::string &option, std::string::size_type const &pos); | |
48 | bool doNoArgumentOption(std::string &option, std::string::size_type const &pos); | |
49 | void findOption(std::string &option, std::string::size_type const &pos, | |
50 | Option *&theOption, int & prefixIndex) const; | |
51 | std::vector<Option *> options; | |
52 | std::vector<std::string> argv; | |
53 | std::vector<std::string> nonoptions; | |
54 | std::vector<std::string> remainingargv; | |
55 | Option *nonOptionHandler; | |
56 | Option::Result lastResult; | |
57 | }; | |
58 | ||
59 | #endif // _OPTIONSET_H_ |