CPP09/ex00/inc/BitcoinExchange.hpp
2026-04-15 18:09:23 +02:00

65 lines
1.4 KiB
C++

#pragma once
#include <map>
#include <string>
#include <exception>
class BitcoinExchange
{
public:
// Constructors
BitcoinExchange() = delete;
BitcoinExchange(const std::string &data_file);
// Copy constructor and copy assignment operator
BitcoinExchange(const BitcoinExchange &other);
BitcoinExchange &operator=(const BitcoinExchange &other);
// Move constructor and move assignment operator
BitcoinExchange(BitcoinExchange &&other) noexcept;
BitcoinExchange &operator=(BitcoinExchange &&other) noexcept;
// Destructor
~BitcoinExchange();
void loadInputFile(const std::string &filename);
class FileNotFoundException : public std::exception
{
public:
virtual const char *what() const noexcept;
};
class LineFormatException : public std::exception
{
public:
virtual const char *what() const noexcept;
};
class ValueNegativeException : public std::exception
{
public:
virtual const char *what() const noexcept;
};
class ValueTooLargeException : public std::exception
{
public:
virtual const char *what() const noexcept;
};
class DateInvalidException : public std::exception
{
public:
virtual const char *what() const noexcept;
};
private:
std::map<long, float>
_data;
long getTimestamp(const std::string &date) const;
void loadDataFile(const std::string &filename);
float getRate(long timestamp) const;
float getValue(long timestamp, float amount) const;
};