From 434eaf0ce051840c3ec160b497d3cbaaebdc6fcb Mon Sep 17 00:00:00 2001 From: Quentin Snow Date: Sun, 22 Jan 2023 17:21:31 -0600 Subject: [PATCH] Added documentation for non private functions. --- src/database.h | 40 ++++++++++++++++++++++++++++++++ src/optHandlers/mainOptHandler.h | 13 +++++++++++ src/utilities.h | 7 ++++++ 3 files changed, 60 insertions(+) diff --git a/src/database.h b/src/database.h index 218b26b..36e26f0 100644 --- a/src/database.h +++ b/src/database.h @@ -11,12 +11,52 @@ class Database { public: + /** + * @brief Checks if an account exists in the database + * + * @param account The name of the account to check for + * @param db The database connection to use + * + * @return True if the account exists, false otherwise + * + * @throws std::runtime_error If the database query fails + */ static bool doesAccountExist(const std::string &account, sqlite3 *db); + /** + * @brief Deletes an account from the database + * + * @param account The name of the account to delete + * @param db The database connection to use + * + * @return True if the account was successfully deleted, false otherwise + * + * @throws std::runtime_error If the database query fails + */ static bool deleteAccount(const std::string &account, sqlite3 *db); + /** + * @brief Retrieves the cached value of an account from the database + * + * @param account The name of the account to retrieve the value of + * @param db The database connection to use + * + * @return The cached value of the account + * + * @throws std::runtime_error If the database query fails or the account doesn't exist + */ static double getValue(const std::string &account, sqlite3 *db); + /** + * @brief Caches the value of an account by calculating the sum of all payments and earnings + * + * @param accountId The ID of the account to cache the value of + * @param db The database connection to use + * + * @return The cached value of the account + * + * @throws std::runtime_error If the database query fails + */ static double cacheAccountValue(long long accountId, sqlite3 *db); }; diff --git a/src/optHandlers/mainOptHandler.h b/src/optHandlers/mainOptHandler.h index 0b7984b..59fd451 100644 --- a/src/optHandlers/mainOptHandler.h +++ b/src/optHandlers/mainOptHandler.h @@ -12,8 +12,21 @@ #include "operation.h" namespace Budget::OptHandlers { + /** + * @class MainOptHandler + * @brief Handles command line options for the main menu of the budget application + * + * The MainOptHandler class handles command line options passed to the budget application. It uses the getopt_long function + * to parse the options and perform the corresponding actions. + */ class MainOptHandler { public: + /** + * @brief Constructor for MainOptHandler + * + * @param argv Vector of arguments passed to the application + * @param pSqlite3 The database connection to use + */ explicit MainOptHandler(const std::vector &argv, sqlite3 *pSqlite3); void help(); diff --git a/src/utilities.h b/src/utilities.h index 14ad667..57c2e09 100644 --- a/src/utilities.h +++ b/src/utilities.h @@ -10,6 +10,13 @@ class Utilities { public: + /** + * @brief Asks the user to confirm an action with a yes or no question + * + * @param question The question to ask the user + * + * @return True if the user confirms the action, false otherwise + */ static bool confirm(const std::string &question); };