IpValidator.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "IpValidator.h"
00018
00019
00020 #define IP_REGEXP "\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\
00021 "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\
00022 "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"\
00023 "\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b"
00024
00025 #define MATCH_ALL "*"
00026
00027
00028
00029 IpValidator::IpValidator(QObject *parent)
00030 : QRegExpValidator(QRegExp(IP_REGEXP), parent)
00031 {
00032 }
00033
00034
00035 QValidator::State
00036 IpValidator::validate(QString &input, int &pos) const
00037 {
00038 if (input == MATCH_ALL) {
00039 return QValidator::Acceptable;
00040 }
00041 return QRegExpValidator::validate(input, pos);
00042 }
00043
00044
00045 QValidator::State
00046 IpValidator::validate(QString &input) const
00047 {
00048 int discard = 0;
00049 return validate(input, discard);
00050 }
00051