juk3n/fluffypublic Fork
⑂ 1e9340b
Commits
⬇ Clone ▾
git clone https://git.rickub.com/juk3n/fluffy.git
git clone ssh://git@rickub.com/juk3n/fluffy.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

created empty database class

juk3n committed 2024-07-03T14:33:58+02:00 Browse files
1e9340b parent: 27755dd
added app/include/database.hpp +15 -0
new file mode 100644
@@ -0,0 +1,15 @@
1+#pragma once
2+
3+class Database
4+{
5+private:
6+ /* data */
7+public:
8+ std::string database_initialization_command =
9+ "CREATE TABLE games("
10+ "GAME_ID INTEGER PRIMARY KEY AUTOINCREMENT, "
11+ "GAME_NAME TEXT NOT NULL, "
12+ "GAME_PATH TEXT NOT NULL);";
13+ Database(/* args */);
14+ ~Database();
15+};
new file mode 100644
@@ -0,0 +1,15 @@
1+#pragma once
2+
3+class Database
4+{
5+private:
6+ /* data */
7+public:
8+ std::string database_initialization_command =
9+ "CREATE TABLE games("
10+ "GAME_ID INTEGER PRIMARY KEY AUTOINCREMENT, "
11+ "GAME_NAME TEXT NOT NULL, "
12+ "GAME_PATH TEXT NOT NULL);";
13+ Database(/* args */);
14+ ~Database();
15+};
modified app/src/main.cpp +3 -6
@@ -17,16 +17,13 @@
1717 #include <limits.h>
1818
1919 #include <game.hpp>
20+#include <database.hpp>
2021
2122 using namespace ftxui;
2223
2324 std::vector<Game> games;
2425
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;
3027
3128 std::string select_all_games_command = "SELECT * FROM games;";
3229
@@ -63,7 +60,7 @@ void removeGame(sqlite3 *database, std::string name) {
6360 }
6461
6562 void initialize_database(sqlite3 *database) {
66- execute_sql_command(database, database_initialization_command);
63+ execute_sql_command(database, databaseHandler.database_initialization_command);
6764 printMessage("Database Initialized");
6865 }
6966
@@ -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