/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Harl.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: erey-bet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/04/20 17:40:42 by erey-bet #+# #+# */ /* Updated: 2023/04/20 18:38:26 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"}; int i; for (i = 0; i < 4; i++) if (all_level[i] == level) break ; switch (i) { case 0: (this->*funcs[0])(); this->complain("INFO"); break; case 1: (this->*funcs[1])(); this->complain("WARNING"); break; case 2: (this->*funcs[2])(); this->complain("ERROR"); break; case 3: (this->*funcs[3])(); break; default: return ; } }