41 lines
718 B
C++
41 lines
718 B
C++
#include "convert.h"
|
|
|
|
//Char toInt(str) {
|
|
//
|
|
//}
|
|
|
|
bool isInt(std::string str) {
|
|
std::string int_xtrem = MAX_INT;
|
|
|
|
if (str[0] == '-')
|
|
int_xtrem = MAX_INT_1;
|
|
if (str[0] == '+' || str[0] == '-')
|
|
str.erase(str.begin());
|
|
if (str.length() == 0 || str.length() > INT_MAX_LENGTH)
|
|
return false;
|
|
if (str.find_first_not_of("0123456789") != std::string::npos)
|
|
return false;
|
|
if (str.length() < INT_MAX_LENGTH)
|
|
return true;
|
|
if (str.compare(int_xtrem) > 0)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool checkInt(std::string str) {
|
|
|
|
// int i;
|
|
|
|
std::cout << "int\n";
|
|
|
|
if (!isInt(str))
|
|
return false;
|
|
|
|
// i = toInt(str);
|
|
// std::cout << "int"RESET" equal to : "B_CYAN << i << RESET << "\n";
|
|
// fromInt(i);
|
|
|
|
return true;
|
|
}
|