Home accounting
|
The main file. Contains the whole program. More...
#include <fstream>
#include <string>
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <iomanip>
Classes | |
struct | record |
The struct is used for storage of every element of record. More... | |
Macros | |
#define | ACCOUNTING_OK 0 |
#define | ACCOUNTING_IO_ERROR 1 |
Functions | |
bool | ReadLines () |
The function reads the number of non-empty lines in the input file - that means lines containing records. More... | |
bool | BaseStructure (record *budget) |
The function fulfills a table of structures based on the input. More... | |
bool | CountLines (int m, record *budget) |
The function checks if given month is present in the input file. Also, it counts number of records containing particular month. More... | |
void | MonthStructure (int m, record *budget, record *month) |
The function creates a table of structures that consists of records of particular month. Also, it counts budget. More... | |
void | WriteMonth (int month) |
Writing to .html file. More... | |
void | Sort (record *month) |
The function sorts the records of particular month by amount of money. More... | |
void | WriteByOrder (record *month) |
Writing to .html file. More... | |
void | WriteSum (string period) |
Writing to .html file. More... | |
void | Hello () |
Writing to a console. More... | |
string | Convert (int number) |
The function converts the integer value to a string type. More... | |
void | WriteBegin () |
Writing to .html file. More... | |
void | WriteEnd () |
Writing to .html file. More... | |
void | Zero (int tab[]) |
The function clears the given table. More... | |
int | main () |
The main function. Calls other functions, performing the operations. More... | |
Variables | |
int | r = 0 |
int | lines = 0 |
string | line |
ifstream | file1 |
ofstream | file2 |
string | input = "Input.csv" |
string | output = "Output.html" |
string | names [] = {"salary", "food", "household", "health", "entertainment", "clothing", "transport", "other"} |
const int | n = (sizeof(names) / sizeof(names[0])) |
int | values_month [n] |
int | values_year [n] |
int | income_month |
int | income_year |
int | expenses_month |
int | expenses_year = 0 |
The main file. Contains the whole program.
bool BaseStructure | ( | record * | budget | ) |
The function fulfills a table of structures based on the input.
The table of structures contains all records listed in the file.
string Convert | ( | int | number | ) |
The function converts the integer value to a string type.
number | The integer type to be converted. |
bool CountLines | ( | int | m, |
record * | budget | ||
) |
The function checks if given month is present in the input file. Also, it counts number of records containing particular month.
Every record of table of structures 'budget' is checked to see if the date is consistent with the checked month. If so, the variable "lines" is incremented.
m | The month to be checked. |
budget | The table of structures containing all records. |
void Hello | ( | ) |
Writing to a console.
The function writes the welcome words to the user.
int main | ( | ) |
The main function. Calls other functions, performing the operations.
The function creates a table of structures that consists of records of particular month. Also, it counts budget.
Every record of table of structures 'budget' is checked to see if the date is consistent with the checked month. If so, it is being rewritten to the table of structures 'month'. Sum of every category is counted, along with total income and expenditure values.
m | The month given. |
budget | The table of structures containing all records. |
month | The table of structures containing records of given month. |
bool ReadLines | ( | ) |
The function reads the number of non-empty lines in the input file - that means lines containing records.
void Sort | ( | record * | month | ) |
The function sorts the records of particular month by amount of money.
Sorting process is performed for all records of the month, to be later easily displayed in order, starting from the highest amount, till the smallest amount.
month | The table of structures containing records of given month. |
void WriteBegin | ( | ) |
Writing to .html file.
The function writes the beginning of the file and sets its parameters.
void WriteByOrder | ( | record * | month | ) |
Writing to .html file.
The function writes all the records, previously sorted, to the output file in a separate table.
month | The table of structures containing records of given month. |
void WriteEnd | ( | ) |
Writing to .html file.
The function closes the output file.
void WriteMonth | ( | int | month | ) |
Writing to .html file.
The function writes the name of the month that is present in the records.
month | The month to be written. |
void WriteSum | ( | string | period | ) |
Writing to .html file.
The function writes the sums of all categories, to the output file in a separate table.
period | The month given/the whole year. |
void Zero | ( | int | tab[] | ) |
The function clears the given table.
The function assigns zeros to every element of table.
tab[] | The table to be cleared. |
int expenses_year = 0 |
storing total finances of month/year
ifstream file1 |
inputing from file
ofstream file2 |
output to file
string input = "Input.csv" |
input file name
string line |
temporary storing of read lines
int lines = 0 |
rows with record of particular month
string names[] = {"salary", "food", "household", "health", "entertainment", "clothing", "transport", "other"} |
storing categories' names
string output = "Output.html" |
output file name
int r = 0 |
not-empty rows of input file
int values_month[n] |
storing months' categories' values (one by another)
int values_year[n] |
storing year's categories' values