yat  0.14.5pre
Option.h
1 #ifndef _theplu_yat_utility_option_
2 #define _theplu_yat_utility_option_
3 
4 // $Id: Option.h 2384 2010-12-22 14:03:36Z peter $
5 
6 /*
7  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2009, 2010 Peter Johansson
9 
10  This file is part of the yat library, http://dev.thep.lu.se/yat
11 
12  The yat library is free software; you can redistribute it and/or
13  modify it under the terms of the GNU General Public License as
14  published by the Free Software Foundation; either version 3 of the
15  License, or (at your option) any later version.
16 
17  The yat library is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with yat. If not, see <http://www.gnu.org/licenses/>.
24 */
25 
26 #include <string>
27 #include <vector>
28 
29 namespace theplu {
30 namespace yat {
31 namespace utility {
32 
33  class CommandLine;
37  class Option
38  {
39  public:
48  Option(CommandLine& cmd, std::string name, std::string desc);
49 
53  virtual ~Option(void);
54 
58  std::string description(void) const;
59 
65  void description(const std::string& description);
66 
70  std::string long_name(void) const;
71 
75  void parse(std::vector<std::string>::iterator&,
76  const std::vector<std::string>::iterator&);
77 
83  bool present(void) const;
84 
98  std::string print(void);
99 
103  void reset(void);
104 
108  char short_name(void) const;
109 
116  void validate(void);
117 
118  protected:
122  const CommandLine& cmd(void) const;
123 
124  private:
125  virtual void do_parse(std::vector<std::string>::iterator&,
126  const std::vector<std::string>::iterator&)=0;
127 
130  virtual std::string print1(void) const;
131 
134  virtual std::string print2(void) const;
135 
138  virtual std::string print3(void) const;
139 
142  virtual std::string print4(void) const;
143 
146  virtual void do_validate(void) const=0;
147 
148 
149  const CommandLine& cmd_;
150  std::string description_;
151  std::string long_name_;
152  bool present_;
153  char short_name_;
154 
155  // copy not allowed
156  Option(const Option&);
157  Option& operator=(const Option&);
158  };
159 
160 }}} // of namespace utility, yat, and theplu
161 
162 #endif
std::string description(void) const
char short_name(void) const
void validate(void)
Validate the Option.
virtual ~Option(void)
destructor
void reset(void)
sets present to false
bool present(void) const
Get if option was found in cmd.
void parse(std::vector< std::string >::iterator &, const std::vector< std::string >::iterator &)
parsing the commandline
Class for parsing the command line.
Definition: CommandLine.h:98
const CommandLine & cmd(void) const
std::string print(void)
print help output
Option(CommandLine &cmd, std::string name, std::string desc)
Constructor.
std::string long_name(void) const
Container of variables for an option.
Definition: Option.h:37

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5