/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* harl.class.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bchanot +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/07/15 19:49:59 by bchanot #+# #+# */ /* Updated: 2025/07/16 13:18:36 by bchanot ### ########.fr */ /* */ /* ************************************************************************** */ #include "harl.class.hpp" void Harl::debug(void) { std::cout << "[DEBUG] I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-ketchup burger. I really do!" << std::endl; } void Harl::info(void) { std::cout << "[INFO] I cannot believe adding extra bacon costs more money. You didn’t put enough bacon in my burger! If you did, I wouldn’t be asking for more!" << std::endl; } void Harl::warning(void) { std::cout << "[WARNING] I think I deserve to have some extra bacon for free. I’ve been coming for years, whereas you started working here just last month." << std::endl; } void Harl::error(void) { std::cout << "[ERROR] This is unacceptable! I want to speak to the manager now." << std::endl; } std::array Harl::getLevels(void) { return {"DEBUG", "INFO", "WARNING", "ERROR"}; } void Harl::complain(std::string level) { void (Harl::*fn[])(void) = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error}; std::array complain = Harl::getLevels(); int i; bool print = false; i = 0; while (i < 4) { if (complain[i].compare(level) == 0 || print) { print = true; (this->*fn[i])(); } i++; } }