style(09): adding color in debug mode
This commit is contained in:
parent
64695b9deb
commit
f2441f2052
1 changed files with 23 additions and 21 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */
|
/* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */
|
||||||
/* Updated: 2025/04/12 18:07:03 by rparodi ### ########.fr */
|
/* Updated: 2025/04/12 18:29:34 by rparodi ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -43,45 +43,47 @@ value convertValue (enum error_code error, float value, std::string date) {
|
||||||
std::string error_code_to_string(enum error_code code) {
|
std::string error_code_to_string(enum error_code code) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case NO_ERROR:
|
case NO_ERROR:
|
||||||
return "NO_ERROR";
|
return "\033[0;35mNO_ERROR";
|
||||||
case NEGATIVE:
|
case NEGATIVE:
|
||||||
return "NEGATIVE";
|
return "\033[0;31mNEGATIVE";
|
||||||
case NO_FORMAT:
|
case NO_FORMAT:
|
||||||
return "NO_FORMAT";
|
return "\033[0;31mNO_FORMAT";
|
||||||
case NO_DATE:
|
case NO_DATE:
|
||||||
return "NO_DATE";
|
return "\033[0;31mNO_DATE";
|
||||||
case NO_LIMIT:
|
case NO_LIMIT:
|
||||||
return "NO_LIMIT";
|
return "\033[0;31mNO_LIMIT";
|
||||||
case NO_FLOAT:
|
case NO_FLOAT:
|
||||||
return "NO_FLOAT";
|
return "\033[0;31mNO_FLOAT";
|
||||||
case TOO_LARGE:
|
case TOO_LARGE:
|
||||||
return "TOO_LARGE";
|
return "\033[0;31mTOO_LARGE";
|
||||||
default:
|
default:
|
||||||
return "UNKNOWN";
|
return "UNKNOWN";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void debug_print_map(const std::map<size_t, value>& data) {
|
void debug_print_map(const std::map<size_t, value>& data) {
|
||||||
std::cout << "===== Debug: Contents of map =====" << std::endl;
|
std::cout << CLR_BLUE << "============= "<< CLR_YELLOW << "Debug: Contents of map" << CLR_BLUE << " =============" << CLR_RESET << std::endl;
|
||||||
std::cout << std::left
|
std::cout << std::left
|
||||||
<< std::setw(15) << "Key"
|
<< std::setw(15) << CLR_YELLOW << "Key" << CLR_RESET
|
||||||
<< std::setw(10) << "Value"
|
<< std::setw(10) << CLR_YELLOW << "Value" << CLR_RESET
|
||||||
<< std::setw(15) << "Date"
|
<< std::setw(15) << CLR_YELLOW << "Date" << CLR_RESET
|
||||||
<< std::setw(15) << "Reason"
|
<< std::setw(15) << CLR_YELLOW << "Reason"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
std::cout << std::string(40, '-') << std::endl;
|
std::cout << CLR_BLUE << std::string(50, '-') << CLR_RESET << std::endl;
|
||||||
|
|
||||||
for (std::map<size_t, value>::const_iterator it = data.begin(); it != data.end(); ++it) {
|
for (std::map<size_t, value>::const_iterator it = data.begin(); it != data.end(); ++it) {
|
||||||
std::cout << std::left
|
if (it->first != 1) {
|
||||||
<< std::setw(15) << it->first
|
std::cout << std::left
|
||||||
<< std::setw(10) << std::fixed << std::setprecision(2) << it->second.value
|
<< "\t" << CLR_GOLD << it->first << CLR_RESET
|
||||||
<< std::setw(15) << std::fixed << it->second.date
|
<< "\t" << CLR_GREEN << std::fixed << std::setprecision(2) << it->second.value << CLR_RESET
|
||||||
<< std::setw(15) << error_code_to_string(it->second.reason)
|
<< "\t" << CLR_CYAN << std::fixed << it->second.date << CLR_RESET
|
||||||
<< std::endl;
|
<< "\t" << error_code_to_string(it->second.reason) << CLR_RESET
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "===================================" << std::endl;
|
std::cout << CLR_BLUE << std::string(50, '=') << CLR_RESET << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string itoa_home(int i) {
|
std::string itoa_home(int i) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue