feat(09): back to single map
This commit is contained in:
parent
d97af9e3b6
commit
93530c269a
3 changed files with 96 additions and 2 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@
|
|||
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# 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
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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";
|
||||
}
|
||||
}
|
||||
|
||||
void debug_print_map(const std::map<size_t, std::map<std::string, value> >& 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<std::string, value>& 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]{2}-[0-9]{2}$", REG_EXTENDED);
|
||||
int ret = regcomp(®ex, "^[0-9]{4}-[0-9]-[0-9]{2}$", REG_EXTENDED);
|
||||
if (ret)
|
||||
return false;
|
||||
|
||||
|
|
@ -122,13 +175,26 @@ std::map<std::string, value>parse_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<std::string, value>(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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue