fichiers organisés

This commit is contained in:
hugogogo
2022-03-07 15:16:05 +01:00
parent b8bf7e45dd
commit 142687283e
8 changed files with 159 additions and 78 deletions

View File

@@ -1,8 +1,7 @@
#include <iostream>
#include <string>
#include "color.h"
#include <cctype> // isdigit()
void convert(std::string str);
// 2^24 = 16777216;
// 2^31 = 2147483648
@@ -14,79 +13,6 @@
#define MIN_INT_1 "-2147483649"
#define MAX_FLOAT_INT_PRECISION "16777216"
//Char toChar(str) {
//
//}
//bool isChar() {}
bool checkChar(std::string str) {
// char c;
//
std::cout << "in char\n";
if (str.length() != 1 || isdigit(str[0]))
return false;
//
// c = toChar(str);
// std::cout << "char"RESET" equal to : "B_CYAN << c << RESET << "\n";
// fromChar(c);
return true;
}
bool checkInt(std::string str) {
std::cout << "in int\n";
if (str.length() == 1 || !isdigit(str[0]))
return false;
return true;
}
bool checkFloat(std::string str) {
std::cout << "in int\n";
if (str.length() == 1 || !isdigit(str[0]))
return false;
return true;
}
bool (*checkFunc[])(std::string str) =
{
checkChar,
checkInt,
checkFloat
};
void convert(std::string str) {
int size = sizeof(checkFunc) / sizeof(checkFunc[0]);
// std::cout << str << " is a "B_YELLOW ;
for (int it = 0; it < size; it++)
if ((*checkFunc[it])(str))
break;
// else if (isInt(str))
// {
// i = toInt(str);
// std::cout << "int"RESET" equal to : "B_CYAN << i << RESET << "\n";
// fromInt(i);
// }
// else if (isFloat(str))
// {
// f = toFloat(str);
// std::cout << "float"RESET" equal to : "B_CYAN << f << RESET << "\n";
// fromFloat(f);
// }
// else if (isDouble(str))
// {
// d = toDouble(str);
// std::cout << "double"RESET" equal to : "B_CYAN << d << RESET << "\n";
// fromDouble(d);
// }
// else
// std::cout << B_RED"not valid type"RESET"\n";
}
int main(int ac, char **av) {
if (ac > 1)