|
|
|
|
@ -893,10 +893,38 @@ vector<int> MainWindow::find_all(string &str_ntp, string substr) {
|
|
|
|
|
return sub_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::check_num_ntp(string &str_ntp) {
|
|
|
|
|
int code_ascii = 0;
|
|
|
|
|
bool flag_is_num = false;
|
|
|
|
|
for (size_t index = 0; index < str_ntp.length(); index++) {
|
|
|
|
|
code_ascii = static_cast<int>(str_ntp[index]);
|
|
|
|
|
if (code_ascii >= 48 && code_ascii <= 57 ) {
|
|
|
|
|
flag_is_num = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return flag_is_num;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::check_string_ntp(string &str_ntp) {
|
|
|
|
|
int code_ascii = 0;
|
|
|
|
|
bool flag_is_str = false;
|
|
|
|
|
for (size_t index = 0; index < str_ntp.length(); index++) {
|
|
|
|
|
code_ascii = static_cast<int>(str_ntp[index]);
|
|
|
|
|
if ((code_ascii >= 65 && code_ascii <= 90) || (code_ascii >= 97 && code_ascii <= 122)) {
|
|
|
|
|
flag_is_str = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return flag_is_str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MainWindow::check_ntp(string &str_ntp) {
|
|
|
|
|
bool flag_is_num = this->check_num_ntp(str_ntp);
|
|
|
|
|
bool flag_is_str = this->check_string_ntp(str_ntp);
|
|
|
|
|
vector<int> sub_index = this->find_all(str_ntp, ".");
|
|
|
|
|
if (sub_index.size() == 1) {
|
|
|
|
|
int index_point = sub_index[0];
|
|
|
|
|
if (sub_index.size() != 0 && flag_is_str) {
|
|
|
|
|
int index_point = sub_index[sub_index.size()-1];
|
|
|
|
|
int len_str_ntp = str_ntp.length();
|
|
|
|
|
if (((len_str_ntp-index_point) >= 2) && (index_point > 2)) {
|
|
|
|
|
return false;
|
|
|
|
|
@ -905,7 +933,7 @@ bool MainWindow::check_ntp(string &str_ntp) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (sub_index.size() == 3) {
|
|
|
|
|
else if (sub_index.size() == 3 && (flag_is_num && flag_is_str == false)) {
|
|
|
|
|
int index_str_ntp = sub_index[0];
|
|
|
|
|
int index_str_ntp_1 = sub_index[1];
|
|
|
|
|
int index_str_ntp_2 = sub_index[2];
|
|
|
|
|
|