forked from wisinorden/iptvutils
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidator.cpp
More file actions
50 lines (36 loc) · 811 Bytes
/
Copy pathvalidator.cpp
File metadata and controls
50 lines (36 loc) · 811 Bytes
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
#include "validator.h"
#include <QRegExpValidator>
Validator::Validator()
{
}
bool Validator::validateIp(QLineEdit *field) {
if (isValidIp(field->text())) {
return true;
}
else {
return false;
}
}
bool Validator::isValidIp(QString ip) {
QStringList parts = ip.split('.');
if (parts.length() != 4 || parts.at(0).toInt() > 239 || parts.at(0).toInt() < 224){
return false;
}
bool ok;
for (int i = 0; i < parts.length(); i++) {
uint num = parts.at(i).toUInt(&ok);
if (!ok || num > 255)
return false;
}
return true;
}
bool Validator::validatePort(QLineEdit *field) {
bool ok;
uint port = field->text().toUShort(&ok);
if(ok) {
return true;
}
else {
return false;
}
}