「🏗️」 wip: work in progress, not done yet.
This commit is contained in:
87
ex00/BitcoinExchange.cpp
Normal file
87
ex00/BitcoinExchange.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "BitcoinExchange.hpp"
|
||||
|
||||
Date::Date(void)
|
||||
{
|
||||
}
|
||||
|
||||
Date::Date(const std::string str)
|
||||
{
|
||||
// check format (4 char & isdigit into dash into 2 char isdigit & < 1 && isdigit & < 2, and same for day except ahah funny cuz 30 and 31 and 28 and 29 agfjasfgfjahkfga)
|
||||
|
||||
for (std::string::iterator it = str.begin(); it < str.end(); ++it)
|
||||
{
|
||||
if (*it != '-')
|
||||
continue ;
|
||||
_value *= 10;
|
||||
_value += *it - '0';
|
||||
}
|
||||
}
|
||||
|
||||
Date::Date(const Date &other)
|
||||
{
|
||||
this->_value = other._value;
|
||||
}
|
||||
|
||||
Date &Date::operator=(const Date &other)
|
||||
{
|
||||
this->_value = other._value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Date::~Date(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool Date::operator==(const Date &other) const
|
||||
{
|
||||
return this->_value == other._value;
|
||||
}
|
||||
|
||||
bool Date::operator!=(const Date &other) const
|
||||
{
|
||||
return this->_value != other._value;
|
||||
}
|
||||
|
||||
bool Date::operator<(const Date &other) const
|
||||
{
|
||||
return this->_value < other._value;
|
||||
}
|
||||
|
||||
bool Date::operator>(const Date &other) const
|
||||
{
|
||||
return this->_value > other._value;
|
||||
}
|
||||
|
||||
bool Date::operator<=(const Date &other) const
|
||||
{
|
||||
return this->_value <= other._value;
|
||||
}
|
||||
|
||||
bool Date::operator>=(const Date &other) const
|
||||
{
|
||||
return this->_value >= other._value;
|
||||
}
|
||||
|
||||
// --------------------------------------------------- //
|
||||
|
||||
void parseData(const std::string filename)
|
||||
{
|
||||
(void) filename;
|
||||
}
|
||||
|
||||
void str(std::string input)
|
||||
{
|
||||
input = "2024-10-04 | 135.00\n2014-04-14 | 24.00\n2001-09-11 | 135.00"
|
||||
std::stringstream input_ss(input);
|
||||
std::string line;
|
||||
|
||||
while (std::getline(input_ss, line))
|
||||
{
|
||||
std::stringstream ss(input);
|
||||
std::string date_str;
|
||||
std::string value_str;
|
||||
if (!std::getline(ss, date_str, '|') || !std::getline(ss, value_str, '|'))
|
||||
throw ; //add exception ig
|
||||
this->_data.insert(std::pair{Date(date_str), std::atoi(value_str.c_str())});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user