diff --git a/cpp00/ex01/sources/main.cpp b/cpp00/ex01/sources/main.cpp index 5ab7d26..1c30a73 100644 --- a/cpp00/ex01/sources/main.cpp +++ b/cpp00/ex01/sources/main.cpp @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/17 14:55:18 by rparodi #+# #+# */ -/* Updated: 2024/10/22 14:05:46 by rparodi ### ########.fr */ +/* Updated: 2025/04/12 13:03:33 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/cpp09/ex00/Makefile b/cpp09/ex00/Makefile index 34faa10..6f1de3a 100644 --- a/cpp09/ex00/Makefile +++ b/cpp09/ex00/Makefile @@ -6,7 +6,11 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # +<<<<<<< Updated upstream # Updated: 2025/04/11 15:55:49 by rparodi ### ########.fr # +======= +# Updated: 2025/04/12 12:53:27 by rparodi ### ########.fr # +>>>>>>> Stashed changes # # # **************************************************************************** # @@ -33,6 +37,17 @@ CXXFLAGS += $(DEBUG) SRC = BitcoinExchange.cpp \ main.cpp +<<<<<<< Updated upstream +======= +INC_DIR = . + +CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP + +# Flags to have the dependences (can be removed for correction) +# DEBUG = -g3 +# CPPFLAGS += $(DEBUG) + +>>>>>>> Stashed changes # Objects OBJDIRNAME = ./build OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o)) @@ -116,6 +131,7 @@ footer: @printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n' clangd: +<<<<<<< Updated upstream @echo -e \ "CompileFlags:\n" \ " Add:\n" \ @@ -123,6 +139,18 @@ clangd: " - \"-I"$(shell pwd)"/includes\"\n" \ " - \"-xc++\"\n" \ > .clangd +======= + @printf "CompileFlags:\n" > ./.clangd + @printf " Add:\n" >> ./.clangd + @printf " - \"-std=c++98 -Wall -Wextra -Werror\"\n" >> ./.clangd + @printf " - \"-I"$(shell pwd)"/includes\"\n" >> ./.clangd + @printf " - \"-xc++\"\n" >> ./.clangd + @for file in $(INC_DIR); do \ + printf " - \"-I"$(shell pwd)"/"$$file"\"" >> .clangd; \ + done + @printf "\n" >> ./.clangd + @printf '$(GREY) Now parsing settings is set in $(END)$(GREEN)./.clangd$(END)\n' +>>>>>>> Stashed changes # Phony .PHONY: all clean fclean re get_db clangd diff --git a/cpp09/ex00/main.cpp b/cpp09/ex00/main.cpp index fdeddaf..6e742c0 100644 --- a/cpp09/ex00/main.cpp +++ b/cpp09/ex00/main.cpp @@ -6,7 +6,11 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */ +<<<<<<< Updated upstream /* Updated: 2025/04/11 16:06:02 by rparodi ### ########.fr */ +======= +/* Updated: 2025/04/12 15:58:47 by rparodi ### ########.fr */ +>>>>>>> Stashed changes /* */ /* ************************************************************************** */ @@ -36,10 +40,59 @@ value convertValue (enum error_code error, float value) { return to_return; } +<<<<<<< Updated upstream bool is_valid_format_date(std::string str) { regex_t regex; +======= +std::string error_code_to_string(enum error_code code) { + switch (code) { + case NO_ERROR: return "NO_ERROR"; + case NEGATIVE: return "NEGATIVE"; + case NO_FORMAT: return "NO_FORMAT"; + case NO_LIMIT: return "NO_LIMIT"; + case TOO_LARGE: return "TOO_LARGE"; + default: return "UNKNOWN"; + } +} - int ret = regcomp(®ex, "^[0-9]{4}-[0-9]{2}-[0-9]{2}$", REG_EXTENDED); +void debug_print_map(const std::map >& data) { + std::cout << "========== Debug: Parsed Entries ==========" << std::endl; + + // En-tĂȘtes de colonnes + std::cout << std::left + << std::setw(8) << "Line" + << std::setw(15) << "Date" + << std::setw(10) << "Value" + << std::setw(15) << "Reason" + << std::endl; + + std::cout << std::string(48, '-') << std::endl; + + // Parcours de la map extĂ©rieure (par ligne) + for (size_t i = 0; i < data.size(); ++i) { + size_t line = it->first; + const std::map& inner = it[line]->second; + const value& val = inner_it->second; + + std::cout << std::left + << std::setw(8) << line + << std::setw(15) << date + << std::setw(10) << std::fixed << std::setprecision(2) << val.value + << std::setw(15) << error_code_to_string(val.reason) + << std::endl; + + } + + std::cout << "===========================================" << std::endl; +} + +>>>>>>> Stashed changes + + +bool is_valid_format_date(std::string str) { + regex_t regex; + + int ret = regcomp(®ex, "^[0-9]{4}-[0-9]-[0-9]{2}$", REG_EXTENDED); if (ret) return false; @@ -122,13 +175,26 @@ std::mapparse_input(std::string name) { std::size_t limit = tmpLine.find(" | "); if (limit == std::string::npos) { tmpError = NO_FORMAT; +<<<<<<< Updated upstream +======= + to_ret[line].insert(std::make_pair(tmpLine, convertValue(line, tmpError, tmpValue))); + continue; +>>>>>>> Stashed changes } else { tmpDate = check_date(tmpLine.substr(0, limit), &tmpError); if (tmpError == NO_ERROR) { tmpValue = check_value(tmpLine.substr(limit + 3).c_str(), &tmpError); } } +<<<<<<< Updated upstream to_ret.insert(std::pair(tmpDate, convertValue(tmpError, tmpValue))); +======= + if (tmpError != NO_ERROR) + to_ret[line].insert(std::make_pair(itoa_home(line), convertValue(line, tmpError, tmpValue))); + else + to_ret[line].insert(std::make_pair(tmpLine, convertValue(line, tmpError, tmpValue))); + line++; +>>>>>>> Stashed changes } return to_ret; }