DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::file_storage::BudgetFile Class Referencefinal

The manager for interacting with a budget file. More...

#include <BudgetFile.h>

Inheritance diagram for drn::file_storage::BudgetFile:
Collaboration diagram for drn::file_storage::BudgetFile:

Public Member Functions

 BudgetFile ()
 
 BudgetFile (const QString &fileLocation, const QString &backUpExtension=BudgetFile::defaultBackUpExtension_)
 Initialises the entire object using the supplied values.
 
const QString & backUpExtension () const
 The extension to use when backing-up a budget file.
 
void changeLocation (const ::QString &fileLocation) override
 Changes the location of the budget file to load.
 
const QString & directoryPath () const
 The absolute directory path of the budget file.
 
storage::BudgetLoadValues load () const override
 Loads the budget file from the local file-system.
 
const QString & name () const noexcept override
 The file name of the budget file.
 
void store (const accounting::GeneralLedger &gl, const budgeting::Budget &b, const foundation::TypeIndexMap< budgeting::BudgetSource, accounting::AccountNumber > &budgetCodes, const banking::BankMap &banks, const surveying::CompletedSurveys &surveys) const override
 Creates or overwrites the budget file to the local file-system. When overwriting the budget file, a back-up copy is created in the same directory.
 
- Public Member Functions inherited from drn::storage::BudgetStorage
 BudgetStorage ()=default
 
 BudgetStorage (BudgetStorage &&)=default
 
 BudgetStorage (const BudgetStorage &)=default
 
virtual ~BudgetStorage ()=default
 
BudgetStorageoperator= (BudgetStorage &&)=default
 
BudgetStorageoperator= (const BudgetStorage &)=default
 

Static Public Attributes

static const QChar defaultBackUpExtension_
 
static const QString oldBackUpExtension_
 The extension used when backing-up a back-up to a budget file.
 

Detailed Description

The manager for interacting with a budget file.

Constructor & Destructor Documentation

◆ BudgetFile() [1/2]

drn::file_storage::BudgetFile::BudgetFile ( )

◆ BudgetFile() [2/2]

drn::file_storage::BudgetFile::BudgetFile ( const QString & fileLocation,
const QString & backUpExtension = BudgetFile::defaultBackUpExtension_ )
explicit

Initialises the entire object using the supplied values.

Exceptions
ErrorWhen the supplied file location is empty.
ErrorWhen the supplied file location is not absolute.
ErrorWhen the supplied back-up extension starts with the full stop file separator ('.').
Parameters
fileLocationThe file name and absolute directory path of the budget file. The text after the last directory separator is assumed to be the name of the budget file.
backUpExtension(Optional) The extension to use when backing-up a pre-existing budget file. When this is not the default, it must not start with the full stop.
Here is the call graph for this function:

Member Function Documentation

◆ backUpExtension()

const QString & drn::file_storage::BudgetFile::backUpExtension ( ) const
nodiscard

The extension to use when backing-up a budget file.

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

◆ changeLocation()

void drn::file_storage::BudgetFile::changeLocation ( const ::QString & fileLocation)
overridevirtual

Changes the location of the budget file to load.

Exceptions
StorageErrorWhen the location is invalid.
Parameters
fileLocationThe directory path and file-name of the budget file to use.

Implements drn::storage::BudgetStorage.

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

◆ directoryPath()

const QString & drn::file_storage::BudgetFile::directoryPath ( ) const
nodiscard

The absolute directory path of the budget file.

◆ load()

storage::BudgetLoadValues drn::file_storage::BudgetFile::load ( ) const
nodiscardoverridevirtual

Loads the budget file from the local file-system.

Exceptions
StorageErrorWhen the budget file cannot be found.
Returns
The values loaded for the budget file.

Implements drn::storage::BudgetStorage.

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

◆ name()

const QString & drn::file_storage::BudgetFile::name ( ) const
nodiscardoverridevirtualnoexcept

The file name of the budget file.

Implements drn::storage::BudgetStorage.

◆ store()

void drn::file_storage::BudgetFile::store ( const accounting::GeneralLedger & gl,
const budgeting::Budget & b,
const foundation::TypeIndexMap< budgeting::BudgetSource, accounting::AccountNumber > & budgetCodes,
const banking::BankMap & banks,
const surveying::CompletedSurveys & surveys ) const
overridevirtual

Creates or overwrites the budget file to the local file-system. When overwriting the budget file, a back-up copy is created in the same directory.

Exceptions
StorageErrorWhen the budget file cannot be saved.
StorageErrorWhen the budget file cannot be backed-up prior to saving.
Parameters
[in]glThe general ledger whose contents are to be stored in the file.
[in]bThe budget whose contents are to be stored in the file.
[in]budgetCodesThe mapping between each budget item and its ledger account number.
[in]banksThe financial institutions whose contents are to be stored in the file.

Implements drn::storage::BudgetStorage.

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

Member Data Documentation

◆ defaultBackUpExtension_

const QChar drn::file_storage::BudgetFile::defaultBackUpExtension_
static

The default extension used when backing-up a budget file, on systems like KDE this will show a nice back-up icon.

◆ oldBackUpExtension_

const QString drn::file_storage::BudgetFile::oldBackUpExtension_
static

The extension used when backing-up a back-up to a budget file.