1 | #ifndef _theplu_svndigest_parameter_ |
---|
2 | #define _theplu_svndigest_parameter_ |
---|
3 | |
---|
4 | // $Id: Parameter.h 1060 2010-06-02 01:56:35Z peter $ |
---|
5 | |
---|
6 | /* |
---|
7 | Copyright (C) 2006, 2007, 2008 Jari Häkkinen, Peter Johansson |
---|
8 | Copyright (C) 2009, 2010 Peter Johansson |
---|
9 | |
---|
10 | This file is part of svndigest, http://dev.thep.lu.se/svndigest |
---|
11 | |
---|
12 | svndigest is free software; you can redistribute it and/or modify it |
---|
13 | under the terms of the GNU General Public License as published by |
---|
14 | the Free Software Foundation; either version 3 of the License, or |
---|
15 | (at your option) any later version. |
---|
16 | |
---|
17 | svndigest is distributed in the hope that it will be useful, but |
---|
18 | 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 svndigest. If not, see <http://www.gnu.org/licenses/>. |
---|
24 | */ |
---|
25 | |
---|
26 | #include "OptionVersion.h" |
---|
27 | |
---|
28 | #include "yat/CommandLine.h" |
---|
29 | #include "yat/OptionArg.h" |
---|
30 | #include "yat/OptionHelp.h" |
---|
31 | #include "yat/OptionSwitch.h" |
---|
32 | |
---|
33 | |
---|
34 | #include <string> |
---|
35 | |
---|
36 | namespace theplu { |
---|
37 | namespace yat { |
---|
38 | namespace utility { |
---|
39 | class OptionHelp; |
---|
40 | class OptionSwitch; |
---|
41 | }} |
---|
42 | namespace svndigest { |
---|
43 | |
---|
44 | class OptionVersion; |
---|
45 | |
---|
46 | // class for command line options. |
---|
47 | class Parameter { |
---|
48 | public: |
---|
49 | Parameter(void); |
---|
50 | virtual ~Parameter(void); |
---|
51 | void parse( int argc, char *argv[]); |
---|
52 | |
---|
53 | std::string config_file(void) const; |
---|
54 | |
---|
55 | bool force(void) const; |
---|
56 | bool generate_config(void) const ; |
---|
57 | bool ignore_cache(void) const; |
---|
58 | /// @return absolute path to root directory |
---|
59 | std::string root(void) const; |
---|
60 | bool verbose(void) const; |
---|
61 | |
---|
62 | protected: |
---|
63 | yat::utility::CommandLine cmd_; |
---|
64 | yat::utility::OptionHelp help_; |
---|
65 | |
---|
66 | // throw cmd_error if path doesn't exist |
---|
67 | void check_existence(std::string path) const; |
---|
68 | // throw cmd_error if path is not dir |
---|
69 | void check_is_dir(std::string path) const; |
---|
70 | // throw cmd_error if path is not readable |
---|
71 | void check_readable(std::string path) const; |
---|
72 | |
---|
73 | private: |
---|
74 | void analyse(void); |
---|
75 | virtual void analyse2(void)=0; |
---|
76 | void init(void); |
---|
77 | // called at end of init(void) |
---|
78 | virtual void init2(void) = 0; |
---|
79 | void set_default(void); |
---|
80 | virtual void set_default2(void)=0; |
---|
81 | |
---|
82 | yat::utility::OptionArg<std::string> config_file_; |
---|
83 | yat::utility::OptionSwitch force_; |
---|
84 | yat::utility::OptionSwitch generate_config_; |
---|
85 | yat::utility::OptionSwitch ignore_cache_; |
---|
86 | yat::utility::OptionArg<std::string> root_; |
---|
87 | yat::utility::OptionSwitch verbose_; |
---|
88 | protected: |
---|
89 | OptionVersion version_; |
---|
90 | |
---|
91 | }; |
---|
92 | |
---|
93 | }} // of namespace svndigest and namespace theplu |
---|
94 | |
---|
95 | #endif |
---|