2018-01-19 13:42:21 +00:00
|
|
|
// Copyright 2017 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QRegExp>
|
|
|
|
#include <QValidator>
|
|
|
|
|
2018-04-18 06:06:02 +01:00
|
|
|
class Validation {
|
|
|
|
public:
|
2018-04-18 17:29:03 +01:00
|
|
|
Validation()
|
|
|
|
: room_name(room_name_regex), nickname(nickname_regex), ip(ip_regex), port(0, 65535) {}
|
|
|
|
|
|
|
|
~Validation() = default;
|
2018-04-18 06:06:02 +01:00
|
|
|
|
2018-04-18 17:29:03 +01:00
|
|
|
const QValidator* GetRoomName() const {
|
|
|
|
return &room_name;
|
|
|
|
}
|
|
|
|
const QValidator* GetNickname() const {
|
|
|
|
return &nickname;
|
|
|
|
}
|
|
|
|
const QValidator* GetIP() const {
|
|
|
|
return &ip;
|
|
|
|
}
|
|
|
|
const QValidator* GetPort() const {
|
|
|
|
return &port;
|
2018-04-18 06:06:02 +01:00
|
|
|
}
|
|
|
|
|
2018-04-18 17:29:03 +01:00
|
|
|
private:
|
2018-04-18 06:06:02 +01:00
|
|
|
/// room name can be alphanumeric and " " "_" "." and "-"
|
|
|
|
QRegExp room_name_regex = QRegExp("^[a-zA-Z0-9._- ]+$");
|
2018-04-18 17:29:03 +01:00
|
|
|
QRegExpValidator room_name;
|
2018-04-18 06:06:02 +01:00
|
|
|
|
|
|
|
/// nickname can be alphanumeric and " " "_" "." and "-"
|
|
|
|
QRegExp nickname_regex = QRegExp("^[a-zA-Z0-9._- ]+$");
|
2018-04-18 17:29:03 +01:00
|
|
|
QRegExpValidator nickname;
|
2018-04-18 06:06:02 +01:00
|
|
|
|
|
|
|
/// ipv4 address only
|
|
|
|
// TODO remove this when we support hostnames in direct connect
|
|
|
|
QRegExp ip_regex = QRegExp(
|
|
|
|
"(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|"
|
|
|
|
"2[0-4][0-9]|25[0-5])");
|
2018-04-18 17:29:03 +01:00
|
|
|
QRegExpValidator ip;
|
2018-04-18 06:06:02 +01:00
|
|
|
|
|
|
|
/// port must be between 0 and 65535
|
2018-04-18 17:29:03 +01:00
|
|
|
QIntValidator port;
|
2018-04-18 06:06:02 +01:00
|
|
|
};
|