modified app/src/main.cpp +3 -6
| @@ -17,16 +17,13 @@ |
| 17 | 17 | #include <limits.h> |
| 18 | 18 | |
| 19 | 19 | #include <game.hpp> |
| 20 | +#include <database.hpp> |
| 20 | 21 | |
| 21 | 22 | using namespace ftxui; |
| 22 | 23 | |
| 23 | 24 | std::vector<Game> games; |
| 24 | 25 | |
| 25 | | -std::string database_initialization_command = |
| 26 | | - "CREATE TABLE games(" |
| 27 | | - "GAME_ID INTEGER PRIMARY KEY AUTOINCREMENT, " |
| 28 | | - "GAME_NAME TEXT NOT NULL, " |
| 29 | | - "GAME_PATH TEXT NOT NULL);"; |
| 26 | +Database databaseHandler; |
| 30 | 27 | |
| 31 | 28 | std::string select_all_games_command = "SELECT * FROM games;"; |
| 32 | 29 | |
| @@ -63,7 +60,7 @@ void removeGame(sqlite3 *database, std::string name) { |
| 63 | 60 | } |
| 64 | 61 | |
| 65 | 62 | void initialize_database(sqlite3 *database) { |
| 66 | | - execute_sql_command(database, database_initialization_command); |
| 63 | + execute_sql_command(database, databaseHandler.database_initialization_command); |
| 67 | 64 | printMessage("Database Initialized"); |
| 68 | 65 | } |
| 69 | 66 | |
| @@ -17,16 +17,13 @@ |
| 17 | #include <limits.h> | 17 | #include <limits.h> |
| 18 | | 18 | |
| 19 | #include <game.hpp> | 19 | #include <game.hpp> |
| | 20 | +#include <database.hpp> |
| 20 | | 21 | |
| 21 | using namespace ftxui; | 22 | using namespace ftxui; |
| 22 | | 23 | |
| 23 | std::vector<Game> games; | 24 | std::vector<Game> games; |
| 24 | | 25 | |
| 25 | -std::string database_initialization_command = | 26 | +Database databaseHandler; |
| 26 | - "CREATE TABLE games(" | | |
| 27 | - "GAME_ID INTEGER PRIMARY KEY AUTOINCREMENT, " | | |
| 28 | - "GAME_NAME TEXT NOT NULL, " | | |
| 29 | - "GAME_PATH TEXT NOT NULL);"; | | |
| 30 | | 27 | |
| 31 | std::string select_all_games_command = "SELECT * FROM games;"; | 28 | std::string select_all_games_command = "SELECT * FROM games;"; |
| 32 | | 29 | |
| @@ -63,7 +60,7 @@ void removeGame(sqlite3 *database, std::string name) { |
| 63 | } | 60 | } |
| 64 | | 61 | |
| 65 | void initialize_database(sqlite3 *database) { | 62 | void initialize_database(sqlite3 *database) { |
| 66 | - execute_sql_command(database, database_initialization_command); | 63 | + execute_sql_command(database, databaseHandler.database_initialization_command); |
| 67 | printMessage("Database Initialized"); | 64 | printMessage("Database Initialized"); |
| 68 | } | 65 | } |
| 69 | | 66 | |