source: trunk/lib/OptionSwitch.h @ 745

Last change on this file since 745 was 705, checked in by Peter Johansson, 13 years ago

importing classes for commandline parsing from yat. This fixes #349 and #265

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1#ifndef _theplu_svndigest_option_switch_
2#define _theplu_svndigest_option_switch_
3
4// $Id: OptionSwitch.h 705 2008-11-25 23:33:26Z peter $
5
6/*
7  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
8
9  This file is part of svndigest, http://dev.thep.lu.se/svndigest
10
11  svndigest is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 3 of the License, or
14  (at your option) any later version.
15
16  svndigest is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include "Option.h"
26
27#include <string>
28
29namespace theplu {
30namespace svndigest {
31
32  class CommandLine;
33  /**
34     \brief Class for switch option
35   */
36  class OptionSwitch : public Option
37  {
38  public:
39    /**
40       \brief Constructor
41       
42       \param cmd Commandline Option is associated with
43       \param name string such as "help" for --help, "h" for -h or
44       "h,help" for having both short and long option name
45       \param desc string used in help display
46       \param def default value for switch
47    */
48    OptionSwitch(CommandLine& cmd, std::string name, 
49                 std::string desc, bool def=false); 
50
51
52    /**
53       \brief return value
54     */
55    bool value(void) const;
56
57  private:
58    /**
59     */
60    void do_parse(std::vector<std::string>::iterator&, 
61                  const std::vector<std::string>::iterator&);
62
63    /**
64       called inside do_parse and allows inherited classes to add
65       stuff to do_parse.
66     */
67    virtual void do_parse2(std::vector<std::string>::iterator, 
68                           std::vector<std::string>::iterator);
69
70    /**
71     */
72    std::string print2(void) const;
73
74    /**
75     */
76    void do_validate(void) const;
77
78  private:
79    bool def_;
80    bool switch_;
81  };
82
83}} // of namespace svndigest, and theplu
84
85#endif
Note: See TracBrowser for help on using the repository browser.