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 ec89acd..6a28d51 100644 Binary files a/source/DataBase/password-manager.db and b/source/DataBase/password-manager.db differ 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() {