]>
Commit | Line | Data |
---|---|---|
8e3e242c RC |
1 | /* |
2 | * Copyright (c) 2002 Robert Collins. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify | |
5 | * it under the terms of the GNU General Public License as published by | |
6 | * the Free Software Foundation; either version 2 of the License, or | |
7 | * (at your option) any later version. | |
8 | * | |
9 | * A copy of the GNU General Public License can be found at | |
10 | * http://www.gnu.org/ | |
11 | * | |
12 | * Written by Robert Collins <robertc@hotmail.com> | |
13 | * | |
14 | */ | |
15 | ||
16 | #ifndef _BOOLOPTION_H_ | |
17 | #define _BOOLOPTION_H_ | |
18 | ||
7419f059 RC |
19 | #include <getopt++/Option.h> |
20 | #include <getopt++/GetOption.h> | |
8e3e242c RC |
21 | |
22 | // Each registered option must implement this class. | |
23 | class BoolOption : public Option | |
24 | { | |
25 | public: | |
8effde7a JT |
26 | enum class BoolOptionType |
27 | { | |
28 | simple, | |
29 | pairedAble, | |
30 | pairedNo, | |
31 | }; | |
32 | ||
8e3e242c | 33 | BoolOption(bool const defaultvalue, char shortopt, char const *longopt = 0, |
20f237b4 | 34 | unsigned int shorthelp = 0, |
8effde7a JT |
35 | BoolOptionType type = BoolOptionType::simple, |
36 | OptionSet &owner=GetOption::GetInstance()); | |
8e3e242c | 37 | virtual ~ BoolOption (); |
e930272e | 38 | virtual std::string const shortOption () const; |
1d644c06 | 39 | virtual std::string const longOption () const; |
8effde7a | 40 | virtual std::vector<std::string> const & longOptionPrefixes () const; |
20f237b4 | 41 | virtual unsigned int shortHelp () const; |
8effde7a | 42 | virtual Result Process (char const *, int); |
1d644c06 | 43 | virtual Argument argument () const; |
8e3e242c | 44 | operator bool () const; |
8e3e242c RC |
45 | |
46 | private: | |
47 | bool _value; | |
48 | bool _ovalue; | |
49 | char _shortopt; | |
50 | char const *_longopt; | |
20f237b4 | 51 | unsigned int _shorthelp; |
8effde7a | 52 | BoolOptionType _type; |
8e3e242c RC |
53 | }; |
54 | ||
55 | #endif // _BOOLOPTION_H_ |