Quassel IRC
Pre-Release
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
abstractcliparser.h
Go to the documentation of this file.
1
/***************************************************************************
2
* Copyright (C) 2005-2015 by the Quassel Project *
3
* devel@quassel-irc.org *
4
* *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) version 3. *
9
* *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
14
* *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19
***************************************************************************/
20
21
#ifndef ABSTRACTCLIPARSER_H
22
#define ABSTRACTCLIPARSER_H
23
24
#include <QStringList>
25
26
class
AbstractCliParser
27
{
28
public
:
29
virtual
bool
init
(
const
QStringList &arguments = QStringList()) = 0;
30
31
virtual
QString
value
(
const
QString &longName) = 0;
32
virtual
bool
isSet
(
const
QString &longName) = 0;
33
inline
void
addSwitch
(
const
QString &longName,
const
char
shortName = 0,
const
QString &help = QString())
34
{
35
addArgument
(longName,
CliParserArg
(
CliParserArg::CliArgSwitch
, shortName, help));
36
}
37
38
39
inline
void
addOption
(
const
QString &longName,
const
char
shortName = 0,
const
QString &help = QString(),
const
QString &valueName = QString(),
const
QString &def = QString())
40
{
41
addArgument
(longName,
CliParserArg
(
CliParserArg::CliArgOption
, shortName, help, valueName, def));
42
}
43
44
45
virtual
void
usage
() = 0;
46
47
virtual
~AbstractCliParser
() {};
48
49
protected
:
50
struct
CliParserArg
{
51
enum
CliArgType
{
52
CliArgInvalid
,
53
CliArgSwitch
,
54
CliArgOption
55
};
56
57
CliParserArg
(
const
CliArgType
type
=
CliArgInvalid
,
const
char
shortName
= 0,
const
QString &
help
= QString(),
const
QString &
valueName
= QString(),
const
QString
def
= QString())
58
:
type
(
type
)
59
,
shortName
(
shortName
)
60
,
help
(
help
)
61
,
valueName
(
valueName
)
62
,
def
(
def
)
63
{};
64
65
CliArgType
type
;
66
char
shortName
;
67
QString
help
;
68
QString
valueName
;
69
QString
def
;
70
QString
value
;
71
bool
boolValue
=
false
;
72
};
73
74
virtual
void
addArgument
(
const
QString &longName,
const
CliParserArg
&arg) = 0;
75
};
76
77
78
#endif
tmp
quassel
src
common
abstractcliparser.h
Generated on Wed Sep 23 2015 13:43:29 for Quassel IRC by
1.8.1.2