Converted with no debug prints and only accept 'a' format for chat
This commit is contained in:
@@ -73,19 +73,13 @@ bool ScalarConverter::isChar(const std::string &literal)
|
||||
{
|
||||
char c;
|
||||
|
||||
if (literal.length() == 3)
|
||||
if (literal.length() != 3)
|
||||
return (false);
|
||||
c = literal[1];
|
||||
if (literal[0] == '\'' && literal[2] == '\''
|
||||
&& (c >= 32 && c < 127))
|
||||
{
|
||||
c = literal[1];
|
||||
if (literal[0] == '\'' && literal[2] == '\''
|
||||
&& (c >= 32 && c < 127))
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
} else if (literal.length() == 1)
|
||||
{
|
||||
c = literal[0];
|
||||
if (c >= 32 && c < 127 && !std::isdigit(c))
|
||||
return (true);
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
@@ -128,6 +122,7 @@ bool ScalarConverter::isFloat(const std::string &literal)
|
||||
|
||||
void ScalarConverter::convertFromSpecialCase(const std::string &literal)
|
||||
{
|
||||
// std::cout << "---- Converting from Special case ----" << std::endl;
|
||||
std::cout << "char: impossible" << std::endl;
|
||||
std::cout << "int: impossible" << std::endl;
|
||||
if (literal == "nanf" || literal == "+inff" || literal == "-inff")
|
||||
@@ -146,8 +141,7 @@ void ScalarConverter::convertFromChar(const std::string &literal)
|
||||
|
||||
if (literal.length() == 3)
|
||||
c = literal[1];
|
||||
else if (literal.length() == 1)
|
||||
c = literal[0];
|
||||
// std::cout << "---- Converting from Char ----" << std::endl;
|
||||
std::cout << "char: '" << c << "'" << std::endl;
|
||||
std::cout << "int: " << static_cast<int>(c) << std::endl;
|
||||
std::cout << std::fixed << std::setprecision(1);
|
||||
@@ -160,6 +154,7 @@ void ScalarConverter::convertFromInt(const std::string &literal)
|
||||
int nb;
|
||||
char *end;
|
||||
|
||||
// std::cout << "---- Converting from Int ----" << std::endl;
|
||||
nb = static_cast<int>(std::strtol(literal.c_str(), &end, 10));
|
||||
if (nb < 0 || nb > 127)
|
||||
std::cout << "char: impossible" << std::endl;
|
||||
@@ -178,6 +173,7 @@ void ScalarConverter::convertFromFloat(const std::string &literal)
|
||||
float nb;
|
||||
char *end;
|
||||
|
||||
// std::cout << "---- Converting from Float ----" << std::endl;
|
||||
nb = std::strtof(literal.c_str(), &end);
|
||||
if (nb < 0 || nb > 127)
|
||||
std::cout << "char: impossible" << std::endl;
|
||||
@@ -199,6 +195,7 @@ void ScalarConverter::convertFromDouble(const std::string &literal)
|
||||
double nb;
|
||||
char *end;
|
||||
|
||||
// std::cout << "---- Converting from Double ----" << std::endl;
|
||||
nb = std::strtod(literal.c_str(), &end);
|
||||
if (nb < 0 || nb > 127)
|
||||
std::cout << "char: impossible" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user