~ubuntu-branches/ubuntu/quantal/config-manager/quantal

« back to all changes in this revision

Viewing changes to libgetopt/src/BoolOption.cc

  • Committer: Bazaar Package Importer
  • Author(s): Anand Kumria
  • Date: 2004-07-19 22:27:50 UTC
  • mto: (3.1.1 dapper)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20040719222750-sztqdj1aoj2r6frr
Tags: upstream-0.1p83
ImportĀ upstreamĀ versionĀ 0.1p83

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
using namespace std;
19
 
 
20
 
BoolOption::BoolOption(bool const defaultvalue, char shortopt, 
21
 
                       char const *longopt, string const &shorthelp, 
22
 
                       OptionSet &owner) : _value (defaultvalue) , 
23
 
                       _ovalue (defaultvalue), _shortopt(shortopt), 
24
 
                       _longopt (longopt), _shorthelp (shorthelp)
25
 
{
26
 
  owner.Register (this);
27
 
};
28
 
 
29
 
BoolOption::~ BoolOption () {};
30
 
 
31
 
string const 
32
 
BoolOption::shortOption () const
33
 
{
34
 
  return string() + _shortopt;
35
 
}
36
 
 
37
 
string const  
38
 
BoolOption::longOption () const
39
 
{
40
 
  return _longopt;
41
 
}
42
 
 
43
 
string const 
44
 
BoolOption::shortHelp () const
45
 
{
46
 
  return _shorthelp;
47
 
}
48
 
 
49
 
Option::Result 
50
 
BoolOption::Process (char const *)
51
 
{
52
 
  _value = !_ovalue;
53
 
  return Ok;
54
 
}
55
 
 
56
 
BoolOption::operator bool () const
57
 
{
58
 
  return _value;
59
 
}
60
 
 
61
 
Option::Argument
62
 
BoolOption::argument () const
63
 
{
64
 
    return None;
65
 
}