DuxReiNummariae 1.1.0-alpha.19
Simple and powerful budgeting application
Loading...
Searching...
No Matches
drn::file_storage::ExchangeRatesFile Class Referencefinal

The manager for interacting with the cached exchange rates file. This is stored under the operating systems' cache directory with the name "exchange-rates.dat". More...

#include <ExchangeRatesFile.hpp>

Inheritance diagram for drn::file_storage::ExchangeRatesFile:
Collaboration diagram for drn::file_storage::ExchangeRatesFile:

Public Member Functions

 ExchangeRatesFile (const std::optional< std::filesystem::path > &filePath=std::nullopt)
 Full initialisation constructor.
bool exists () const noexcept override
 Determines if the exchange rates file exists.
std::filesystem::path filePathName () const
 Retrieves the file path and name of the exchange rates file stored on the system.
conversion::ConversionMap load () const override
 Loads the exchange rates file.
void remove () const override
 Removes the cached exchange rate file.
void store (const conversion::ConversionMap &cm) const override
 Creates or overwrites the exchange rates file.
Public Member Functions inherited from drn::storage::ExchangeRatesStorage
 ExchangeRatesStorage ()=default
 ExchangeRatesStorage (const ExchangeRatesStorage &)=delete
 ExchangeRatesStorage (ExchangeRatesStorage &&)=default
virtual ~ExchangeRatesStorage ()=default
ExchangeRatesStorageoperator= (const ExchangeRatesStorage &)=delete
ExchangeRatesStorageoperator= (ExchangeRatesStorage &&)=default

Detailed Description

The manager for interacting with the cached exchange rates file. This is stored under the operating systems' cache directory with the name "exchange-rates.dat".

Constructor & Destructor Documentation

◆ ExchangeRatesFile()

drn::file_storage::ExchangeRatesFile::ExchangeRatesFile ( const std::optional< std::filesystem::path > & filePath = std::nullopt)
explicit

Full initialisation constructor.

Parameters
[in]filePathThe optional file path to set as the location for the exchange rates file. If omitted, a default path derived from the operating system's cache location is used.

Member Function Documentation

◆ exists()

bool drn::file_storage::ExchangeRatesFile::exists ( ) const
nodiscardoverridevirtualnoexcept

Determines if the exchange rates file exists.

Returns
True when the cached path exists and is a file, false else-wise.

Implements drn::storage::ExchangeRatesStorage.

◆ filePathName()

std::filesystem::path drn::file_storage::ExchangeRatesFile::filePathName ( ) const
nodiscard

Retrieves the file path and name of the exchange rates file stored on the system.

Returns
The full absolute path and filename of the cached exchange rates file.

◆ load()

conversion::ConversionMap drn::file_storage::ExchangeRatesFile::load ( ) const
nodiscardoverridevirtual

Loads the exchange rates file.

Exceptions
BinaryFileErrorWhen the exchange rates file is not valid.
Returns
The loaded exchange rates.

Implements drn::storage::ExchangeRatesStorage.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove()

void drn::file_storage::ExchangeRatesFile::remove ( ) const
overridevirtual

Removes the cached exchange rate file.

Implements drn::storage::ExchangeRatesStorage.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ store()

void drn::file_storage::ExchangeRatesFile::store ( const conversion::ConversionMap & cm) const
overridevirtual

Creates or overwrites the exchange rates file.

Exceptions
BinaryFileErrorWhen the exchange rates file cannot be saved.
Parameters
[in]cmThe exchange rates whose contents are to be stored in the file.

Implements drn::storage::ExchangeRatesStorage.

Here is the call graph for this function:
Here is the caller graph for this function: