]> cygwin.com Git - cygwin-apps/setup.git/blob - libgetopt++/src/BoolOption.cc
2002-04-23 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / libgetopt++ / src / BoolOption.cc
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 #include <getopt++/BoolOption.h>
17
18 BoolOption::BoolOption(bool const defaultvalue, char shortopt,
19 char const *longopt, string const &shorthelp,
20 OptionSet &owner) : _value (defaultvalue) ,
21 _ovalue (defaultvalue), _shortopt(shortopt),
22 _longopt (longopt), _shorthelp (shorthelp)
23 {
24 owner.Register (this);
25 };
26
27 BoolOption::~ BoolOption () {};
28
29 string const
30 BoolOption::shortOption () const
31 {
32 return string() + _shortopt;
33 }
34
35 struct option
36 BoolOption::longOption () const
37 {
38 struct option foo = {_longopt, no_argument, NULL, _shortopt};
39 return foo;
40 }
41
42 string const
43 BoolOption::shortHelp () const
44 {
45 return _shorthelp;
46 }
47
48 bool
49 BoolOption::Process (char const *)
50 {
51 _value = !_ovalue;
52 }
53
54 BoolOption::operator bool () const
55 {
56 return _value;
57 }
This page took 0.038373 seconds and 5 git commands to generate.