-
Notifications
You must be signed in to change notification settings - Fork 9
/
arg.cpp
58 lines (50 loc) · 1.48 KB
/
arg.cpp
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
#include "arg.hpp"
Arg::Arg(const char *name, QVariant(*callback)(QString),
const QVariant default_, const QString help){
this->_name = name;
this->setDefault(default_);
this->setCallback(callback);
this->setHelp(help);
this->setRequired(false);
}
Arg::Arg(const char *name, QVariant(*callback)(QString), const QString help){
this->_name = name;
this->setCallback(callback);
this->setHelp(help);
this->setRequired(true);
}
Arg::Arg(const char *shortname, const char *name,
QVariant(*callback)(QString), const QVariant default_,
const QString help){
this->_name = name;
this->_shortname = shortname;
this->setDefault(default_);
this->setCallback(callback);
this->setHelp(help);
this->setRequired(false);
}
Arg::Arg(const char *shortname, const char *name,
QVariant(*callback)(QString), const QString help){
this->_name = name;
this->_shortname = shortname;
this->setCallback(callback);
this->setHelp(help);
this->setRequired(true);
}
Arg::Arg(const Arg &arg) : QObject(){
_name = arg._name;
_shortname = arg._shortname;
_callback = arg._callback;
_default = arg._default;
_help = arg._help;
_required = arg._required;
}
QVariant Arg::writableFile(QString filename){
return QVariant(filename);
}
QVariant Arg::readableFile(QString filename){
if(filename == "-" || QFileInfo(filename).isReadable()){
return QVariant(filename);
}
return QVariant();
}