blob: 0688327ebe071bd69963b2a1b396ae13af452ae9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/* Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>
*
* schroot is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* schroot is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*********************************************************************/
#ifndef SCHROOT_BASE_OPTIONS_H
#define SCHROOT_BASE_OPTIONS_H
#include <sbuild/sbuild-session.h>
#include <sbuild/sbuild-types.h>
#include <schroot-base/schroot-base-option-action.h>
#include <string>
#ifdef HAVE_TR1_MEMORY
#include <tr1/memory>
#elif HAVE_BOOST_SHARED_PTR_HPP
#include <boost/shared_ptr.hpp>
namespace std { namespace tr1 { using boost::shared_ptr; } }
#else
#error A shared_ptr implementation is not available
#endif
#include <boost/program_options.hpp>
namespace schroot_base
{
/**
* Basic schroot command-line options. This is specialised by the
* frontends to suit their particular command-line options and
* behaviour. This class implements the functionality common to all
* options parsing classes.
*/
class options
{
public:
/// A shared_ptr to an options object.
typedef std::tr1::shared_ptr<options> ptr;
typedef option_action::action_type action_type;
/// The constructor.
options ();
/// The destructor.
virtual ~options ();
/**
* Parse the command-line options.
*
* @param argc the number of arguments
* @param argv argument vector
*/
void
parse (int argc,
char *argv[]);
/// Display program help.
static const action_type ACTION_HELP;
/// Display program version.
static const action_type ACTION_VERSION;
/// Action list.
option_action action;
/// Quiet messages.
bool quiet;
/// Verbose messages.
bool verbose;
/**
* Get the visible options group. This options group contains all
* the options visible to the user.
*
* @returns the options_description.
*/
boost::program_options::options_description const&
get_visible_options() const;
protected:
/**
* Add options to option groups.
*/
virtual void
add_options ();
/**
* Add option groups to container groups.
*/
virtual void
add_option_groups ();
/**
* Check options after parsing.
*/
virtual void
check_options ();
/**
* Check actions after parsing.
*/
virtual void
check_actions ();
/// General options group.
boost::program_options::options_description general;
/// Hidden options group.
boost::program_options::options_description hidden;
/// Positional options group.
boost::program_options::positional_options_description positional;
/// Visible options container (used for --help).
boost::program_options::options_description visible;
/// Global options container (used for parsing).
boost::program_options::options_description global;
/// Variables map, filled during parsing.
boost::program_options::variables_map vm;
private:
/// Debug level string.
std::string debug_level;
};
}
#endif /* SCHROOT_BASE_OPTIONS_H */
/*
* Local Variables:
* mode:C++
* End:
*/
|