diff --git a/cpp09/ex00/BitcoinExchange.hpp b/cpp09/ex00/BitcoinExchange.hpp index 98c6af8..ee32272 100644 --- a/cpp09/ex00/BitcoinExchange.hpp +++ b/cpp09/ex00/BitcoinExchange.hpp @@ -6,15 +6,18 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:18:18 by rparodi #+# #+# */ -/* Updated: 2025/04/10 16:05:21 by rparodi ### ########.fr */ +/* Updated: 2025/04/11 12:36:11 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once -#include -#include #include +#include +#include +#include +#include +#include #define CLR_RESET "\033[0m" diff --git a/cpp09/ex00/Makefile b/cpp09/ex00/Makefile index b93481a..b9915fd 100644 --- a/cpp09/ex00/Makefile +++ b/cpp09/ex00/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2025/04/11 11:23:29 by rparodi ### ########.fr # +# Updated: 2025/04/11 12:35:05 by rparodi ### ########.fr # # # # **************************************************************************** # @@ -66,7 +66,6 @@ clean: # Clean (make fclean) fclean: clean @printf '$(GREY) Removing $(END)$(RED)Program$(END)\n' - @$(RM) ./data.csv @$(RM) $(NAME) @echo "" diff --git a/cpp09/ex00/main.cpp b/cpp09/ex00/main.cpp index 94d55d3..ee3c06a 100644 --- a/cpp09/ex00/main.cpp +++ b/cpp09/ex00/main.cpp @@ -6,22 +6,35 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/04/08 12:15:32 by rparodi #+# #+# */ -/* Updated: 2025/04/11 11:47:18 by rparodi ### ########.fr */ +/* Updated: 2025/04/11 12:38:36 by rparodi ### ########.fr */ /* */ /* ************************************************************************** */ #include "BitcoinExchange.hpp" +#include #include +#include #include #include +#include + std::mapparse_file(std::string name) { std::map to_ret; - std::string tmp; + std::string tmpLine; std::ifstream file(name); + size_t line = 1; - while (std::getline(file, tmp)) { - ; + while (std::getline(file, tmpLine)) { + std::size_t limit = tmpLine.find(" | "); + if (limit == std::string::npos) { + std::cerr << CLR_RED << "Limiter not found at the line " << line << CLR_RESET << std::endl; + exit(1); + } else { + std::string tmpDate = tmpLine.substr(0, limit); + float tmpValue = std::atof(tmpLine.substr(limit + 3).c_str()); + to_ret.insert(std::pair(tmpDate, tmpValue)); + } } return to_ret; }