fichiers organisés
This commit is contained in:
31
d06/ex00/srcs/convert.cpp
Normal file
31
d06/ex00/srcs/convert.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include "color.h"
|
||||
|
||||
bool checkChar(std::string str);
|
||||
bool checkInt(std::string str);
|
||||
bool checkFloat(std::string str);
|
||||
bool checkDouble(std::string str);
|
||||
|
||||
bool isElse(std::string str) {
|
||||
std::cout << str << B_RED " is not valid type for this exercise" RESET "\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool (*checkFunc[])(std::string str) =
|
||||
{
|
||||
checkChar,
|
||||
checkInt,
|
||||
checkFloat,
|
||||
checkDouble,
|
||||
isElse
|
||||
};
|
||||
|
||||
void convert(std::string str) {
|
||||
|
||||
int size = sizeof(checkFunc) / sizeof(checkFunc[0]);
|
||||
|
||||
for (int it = 0; it < size; it++)
|
||||
if ((*checkFunc[it])(str))
|
||||
break;
|
||||
}
|
||||
Reference in New Issue
Block a user