cpp/CPP01/ex05/Harl.cpp
2024-12-04 17:29:31 +01:00

42 lines
1.5 KiB
C++

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Harl.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: erey-bet <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/20 17:40:42 by erey-bet #+# #+# */
/* Updated: 2023/04/20 18:08:44 by erey-bet ### ########.fr */
/* */
/* ************************************************************************** */
#include "Harl.hpp"
Harl::Harl(void) {}
void Harl::debug(void) {
std::cout << "DEBUG" << std::endl;
}
void Harl::info(void) {
std::cout << "INFO" << std::endl;
}
void Harl::warning(void) {
std::cout << "WARNING" << std::endl;
}
void Harl::error(void) {
std::cout << "ERROR" << std::endl;
}
void Harl::complain(std::string level) {
void(Harl::*funcs[4])() = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error};
std::string all_level[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
for (int i = 0; i < 4; i++)
if (all_level[i] == level)
return (this->*funcs[i])();
std::cout << "Only 'DEBUG', 'INFO', 'WARNING', 'ERROR' was allowed" << std::endl;
}