From 6c7cb7d75957e77f85f041911a19de7006c1a624 Mon Sep 17 00:00:00 2001 From: dominikpalatynski Date: Tue, 6 Feb 2024 19:23:42 +0100 Subject: [PATCH] Create Basic DataBase. Adding CMakeLists.txt in dataBase directory --- source/CMakeLists.txt | 4 +++- source/DataBase/CMakeLists.txt | 3 +++ source/DataBase/DataBaseCommon.cpp | 10 ---------- source/DataBase/DataBaseCommon.hpp | 19 ++++++++++++------- source/DataBase/DataBaseHandler.hpp | 2 +- source/DataBase/password-manager.db | Bin 24576 -> 24576 bytes source/main.cpp | 4 ++-- 7 files changed, 21 insertions(+), 21 deletions(-) create mode 100644 source/DataBase/CMakeLists.txt delete mode 100644 source/DataBase/DataBaseCommon.cpp diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index a84e6ae..9b21497 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -2,9 +2,11 @@ project(PasswordManager) add_library(sqlite3 STATIC ../lib/sqlite3.c) -add_executable(passwordManager main.cpp PasswordManager.cpp DataBase/DataBaseHandler.cpp DataBase/DataBaseCommon.cpp) +add_executable(passwordManager main.cpp PasswordManager.cpp) target_include_directories(sqlite3 PUBLIC ../lib) target_link_libraries(passwordManager PRIVATE sqlite3) add_subdirectory(test) +add_subdirectory(dataBase) + diff --git a/source/DataBase/CMakeLists.txt b/source/DataBase/CMakeLists.txt new file mode 100644 index 0000000..e7ed2cc --- /dev/null +++ b/source/DataBase/CMakeLists.txt @@ -0,0 +1,3 @@ +project(PasswordManager) + +target_sources(passwordManager PRIVATE DataBaseHandler.cpp) diff --git a/source/DataBase/DataBaseCommon.cpp b/source/DataBase/DataBaseCommon.cpp deleted file mode 100644 index 7e69841..0000000 --- a/source/DataBase/DataBaseCommon.cpp +++ /dev/null @@ -1,10 +0,0 @@ - -#include "DataBaseCommon.hpp" - -const std::vector DataBaseCommon::passwordRecords{ - "User_Id", "Title", "Category", "Username", "Password", "Note", "Url", "Creation_Time", "Modify_Time", "Expiry_Time"}; -const std::vector DataBaseCommon::userRecords{"Username", "Password"}; - -const std::string DataBaseCommon::dataBasePath{"../../../source/DataBase/password-manager.db"}; -const std::string DataBaseCommon::users{"Users"}; -const std::string DataBaseCommon::passwords{"Passwords"}; diff --git a/source/DataBase/DataBaseCommon.hpp b/source/DataBase/DataBaseCommon.hpp index 0e9f5d0..8638264 100644 --- a/source/DataBase/DataBaseCommon.hpp +++ b/source/DataBase/DataBaseCommon.hpp @@ -1,14 +1,19 @@ #pragma once -#include #include - +#include struct DataBaseCommon { - static const std::vector userRecords; - static const std::vector passwordRecords; + static constexpr std::vector userRecordsRecords{"Username", "Password"}; + static constexpr std::vector categoriesRecords{"Category"}; + static constexpr std::vector passwordHistoryRecords{"Creation_Time", "Modify_Time", "Expiry_Time"}; + static constexpr std::vector passwordRecords{ + "User_Id", "Category_Id", "Title", "Username", "Password", "Note", "Url"}; + + static constexpr std::string dataBasePath{"../../../source/dataBase/password-manager.db"}; - static const std::string dataBasePath; - static const std::string users; - static const std::string passwords; + static constexpr std::string users{"Users"}; + static constexpr std::string passwords{"Passwords"}; + static constexpr std::string passwordHistory{"PasswordHistory"}; + static constexpr std::string categories{"Categories"}; }; diff --git a/source/DataBase/DataBaseHandler.hpp b/source/DataBase/DataBaseHandler.hpp index c524e39..2a5c697 100644 --- a/source/DataBase/DataBaseHandler.hpp +++ b/source/DataBase/DataBaseHandler.hpp @@ -33,4 +33,4 @@ class DataBaseHandler void executeQuery(const std::string &query); sqlite3 *database_; -}; +}; \ No newline at end of file diff --git a/source/DataBase/password-manager.db b/source/DataBase/password-manager.db index ec89acd55a77991d0c3db8e29e23d7bae07a2a09..6a28d51402e0b17255e8a5226ea332a0f9e83e55 100644 GIT binary patch delta 459 zcmZoTz}Rqrae}m<6axbT8xS)CF(VL5Ow=(JmtxTKujS>lU|`{S!@xh2cO%amzB0bJ zjg9}fxcDp>E5zmH8CxwkJMl3wiYX{LCzhn9=NDDRd!{IHdisU9y1NEVe#+}Sxs6}g zyU~e_U0hq6vB|n5F)1fCAhEc(JijQ#BeS>!s0EG7<{aee7~-lB;^^e#s-T1>JGqcg zZt_xI6_ya!h>*z_cqJy+^2>xZvaqs?D=IQJ27@htIwmu<7{OviH5MVEq@cmYiQWAH zyrK#LL7u*jL6HjHu8|rjsx-MYfk9y<#U0h$EvB>~JxA24AQQV{e*NLUnD{Ih_-FE2@Eqbd=KZ=^ zP{4sFmam%8UR+EY_ K6B9EtCno?;yG8#1 diff --git a/source/main.cpp b/source/main.cpp index 1d78cf9..ceebe84 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,8 +1,8 @@ #include #include "PasswordManager.h" -#include "DataBase/DataBaseHandler.hpp" -#include "DataBase/DataBaseCommon.hpp" +#include "dataBase/DataBaseHandler.hpp" +#include "dataBase/DataBaseCommon.hpp" int main() {