| 1 | #cxx . . $ `<file>/HercStudio/IpValidator.cpp`/include "IpValidator.h"cxx . . $ `<file>/HercStudio/IpValidator.h`/ |
| 2 | #include "HerculesStudio.h"cxx . . $ `<file>/HercStudio/HerculesStudio.h`/ |
| 3 | |
| 4 | #include <QLineEdit> |
| 5 | #include <QMessageBox> |
| 6 | |
| 7 | IpValidatorcxx . . $ IpValidator#::IpValidatorcxx . . $ IpValidator#IpValidator(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget# * parent) : |
| 8 | QDialogcxx . . $ QDialog#QDialog(872e7b0c281abd8d).(parent) |
| 9 | { |
| 10 | } |
| 11 | |
| 12 | bool IpValidatorcxx . . $ IpValidator#::validateIpcxx . . $ IpValidator#validateIp(8c7794b15f0d8b60).(QLineEditcxx . . $ QLineEdit# * ipLineEdit, bool allowNull, bool quite) |
| 13 | { |
| 14 | const stdcxx . . $ std/::stringcxx . . $ std/string# ip = ipLineEditcxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f).->textcxx . . $ QLineEdit#text(6ef7b6c27b00b43d).().toStdStringcxx . . $ QString#toStdString(219584694fe2b248).(); |
| 15 | bool ret = true; |
| 16 | if (allowNull && ip.comparecxx . . $ std/__cxx11/basic_string#compare(1fc9373649671084).("...") == 0) |
| 17 | return ret; |
| 18 | QStringcxx . . $ QString# qipcxx . . $ QString#QString(e1217c004a86c950). = ipcxx . . $ QString#QString(85c52e162fed56f9)..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).(); |
| 19 | int pos=0; |
| 20 | for (int i=0; i<4 && ret; i++) |
| 21 | { |
| 22 | hOutDebugcxx . . $ `HercStudio/HerculesStudio.h:49:9`!(5, "IP:" << ip << " pos:" << pos << " i=" << i << std::endl); |
| 23 | if (i>0) |
| 24 | { |
| 25 | if (qip.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).()[pos] != '.') |
| 26 | { |
| 27 | ret = false; |
| 28 | break; |
| 29 | } |
| 30 | pos++; |
| 31 | } |
| 32 | int num = 0; |
| 33 | int ppos=pos; |
| 34 | while(ip[cxx . . $ std/__cxx11/basic_string#`operator[]`(fe0a407a03ea4a2d).pos] >= '0' && ip[cxx . . $ std/__cxx11/basic_string#`operator[]`(fe0a407a03ea4a2d).pos] <= '9') |
| 35 | { |
| 36 | num = num*10 + ip[cxx . . $ std/__cxx11/basic_string#`operator[]`(fe0a407a03ea4a2d).pos] - '0'; |
| 37 | pos++; |
| 38 | } |
| 39 | if (pos == ppos || num > 255) |
| 40 | { |
| 41 | ret = false; |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | if (!ret) |
| 46 | { |
| 47 | if (!quite) |
| 48 | { |
| 49 | QStringcxx . . $ QString# msgcxx . . $ QString#QString(e1217c004a86c950). = ipcxx . . $ QString#QString(85c52e162fed56f9)..c_strcxx . . $ std/__cxx11/basic_string#c_str(1016ee5406d91ab9).(); |
| 50 | msg +=cxx . . $ QString#`operator+=`(d02845eef0c33901). " is an illegel IP address"; |
| 51 | QMessageBoxcxx . . $ QMessageBox#::warningcxx . . $ QMessageBox#warning(a9e3742e6f7b4147).(this, "Illegal IP address"cxx . . $ QString#QString(85c52e162fed56f9)., msg , QMessageBoxcxx . . $ QFlags#QFlags(9b289cee16747614).::Okcxx . . $ QMessageBox#Ok.); |
| 52 | ipLineEdit->setFocuscxx . . $ QWidget#setFocus(49f6e7a06ebc5aa8).(); |
| 53 | } |
| 54 | return false; |
| 55 | } |
| 56 | return true; |
| 57 | } |