From edeee5654eaeba2048603ed466fd88439686791e Mon Sep 17 00:00:00 2001 From: yggverse Date: Wed, 11 Sep 2024 01:51:34 +0300 Subject: [PATCH] enshort db members namespace --- src/app/browser/main/tab.cpp | 22 +++++++++---------- src/app/browser/main/tab.hpp | 3 ++- src/app/browser/main/tab/page.cpp | 14 ++++++------ src/app/browser/main/tab/page.hpp | 3 ++- src/app/browser/main/tab/page/navigation.cpp | 14 ++++++------ src/app/browser/main/tab/page/navigation.hpp | 3 ++- .../main/tab/page/navigation/request.cpp | 15 +++++++------ .../main/tab/page/navigation/request.hpp | 3 ++- 8 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/app/browser/main/tab.cpp b/src/app/browser/main/tab.cpp index ea8dc76d..e0d631a9 100644 --- a/src/app/browser/main/tab.cpp +++ b/src/app/browser/main/tab.cpp @@ -14,7 +14,7 @@ Tab::Tab( const Glib::RefPtr & ACTION__TAB_PAGE_NAVIGATION_UPDATE ) { // Init database - DB::APP_BROWSER_MAIN_TAB__SESSION::init( + DB::SESSION::init( this->db = db ); @@ -73,12 +73,12 @@ int Tab::restore() reinterpret_cast( sqlite3_column_text( statement, - DB::APP_BROWSER_MAIN_TAB__SESSION::LABEL_TEXT + DB::SESSION::LABEL_TEXT ) ), sqlite3_column_int( statement, - DB::APP_BROWSER_MAIN_TAB__SESSION::IS_CURRENT + DB::SESSION::IS_CURRENT ) == 1 ); @@ -95,7 +95,7 @@ int Tab::restore() void Tab::clean() // @TODO menu action? { - DB::APP_BROWSER_MAIN_TAB__SESSION::clean( + DB::SESSION::clean( db ); @@ -107,7 +107,7 @@ void Tab::save() char * error; // @TODO // Delete previous data - DB::APP_BROWSER_MAIN_TAB__SESSION::clean( + DB::SESSION::clean( db ); @@ -118,7 +118,7 @@ void Tab::save() get_tabPage( page_number )->save( - DB::APP_BROWSER_MAIN_TAB__SESSION::add( + DB::SESSION::add( db, page_number, page_number == get_current_page() ? 1 : 0, @@ -333,7 +333,7 @@ tab::Page * Tab::get_tabPage( } // Database -int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::init( +int Tab::DB::SESSION::init( sqlite3 * db ) { char * error; @@ -356,7 +356,7 @@ int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::init( ); } -int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::clean( +int Tab::DB::SESSION::clean( sqlite3 * db ) { char * error; // @TODO @@ -379,7 +379,7 @@ int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::clean( { const int APP_BROWSER_MAIN_TAB__SESSION_ID = sqlite3_column_int( statement, - DB::APP_BROWSER_MAIN_TAB__SESSION::ID + DB::SESSION::ID ); // Delete record @@ -399,7 +399,7 @@ int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::clean( // Delegate children dependencies cleanup if (EXEC_STATUS == SQLITE_OK) { - tab::Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::clean( + tab::Page::DB::SESSION::clean( db, APP_BROWSER_MAIN_TAB__SESSION_ID ); @@ -412,7 +412,7 @@ int Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::clean( ); } -sqlite3_int64 Tab::DB::APP_BROWSER_MAIN_TAB__SESSION::add( +sqlite3_int64 Tab::DB::SESSION::add( sqlite3 * db, const int & PAGE_NUMBER, const bool & IS_CURRENT, diff --git a/src/app/browser/main/tab.hpp b/src/app/browser/main/tab.hpp index 4bf09359..9cbff628 100644 --- a/src/app/browser/main/tab.hpp +++ b/src/app/browser/main/tab.hpp @@ -27,7 +27,8 @@ namespace app::browser::main */ struct DB { - struct APP_BROWSER_MAIN_TAB__SESSION + // APP_BROWSER_MAIN_TAB__* + struct SESSION { enum { diff --git a/src/app/browser/main/tab/page.cpp b/src/app/browser/main/tab/page.cpp index 8915ee7e..446a72d7 100644 --- a/src/app/browser/main/tab/page.cpp +++ b/src/app/browser/main/tab/page.cpp @@ -24,7 +24,7 @@ Page::Page( action__refresh = ACTION__REFRESH; // Init database - DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::init( + DB::SESSION::init( this->db = db ); @@ -75,7 +75,7 @@ int Page::save( ) { // Delegate save action to child components return pageNavigation->save( - DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::add( + DB::SESSION::add( db, DB__APP_BROWSER_MAIN_TAB__SESSION_ID, mime, @@ -365,7 +365,7 @@ void Page::set_navbar_request_text( } // Database model -int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::init( +int Page::DB::SESSION::init( sqlite3 * db ) { char * error; @@ -388,7 +388,7 @@ int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::init( ); } -int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::clean( +int Page::DB::SESSION::clean( sqlite3 * db, const int & DB__APP_BROWSER_MAIN_TAB__SESSION_ID ) { @@ -415,7 +415,7 @@ int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::clean( { const int APP_BROWSER_MAIN_TAB_PAGE__SESSION_ID = sqlite3_column_int( statement, - DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::ID + DB::SESSION::ID ); // Delete record @@ -435,7 +435,7 @@ int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::clean( // Delegate children dependencies cleanup if (EXEC_STATUS == SQLITE_OK) { - page::Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::clean( + page::Navigation::DB::SESSION::clean( db, APP_BROWSER_MAIN_TAB_PAGE__SESSION_ID ); @@ -448,7 +448,7 @@ int Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::clean( ); } -sqlite3_int64 Page::DB::APP_BROWSER_MAIN_TAB_PAGE__SESSION::add( +sqlite3_int64 Page::DB::SESSION::add( sqlite3 * db, const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB__SESSION_ID, const Page::MIME & MIME, diff --git a/src/app/browser/main/tab/page.hpp b/src/app/browser/main/tab/page.hpp index 8cd3847b..bf980e4b 100644 --- a/src/app/browser/main/tab/page.hpp +++ b/src/app/browser/main/tab/page.hpp @@ -42,7 +42,8 @@ namespace app::browser::main::tab */ struct DB { - struct APP_BROWSER_MAIN_TAB_PAGE__SESSION + // APP_BROWSER_MAIN_TAB_PAGE__* + struct SESSION { enum { diff --git a/src/app/browser/main/tab/page/navigation.cpp b/src/app/browser/main/tab/page/navigation.cpp index 66187c04..4ed1b6ba 100644 --- a/src/app/browser/main/tab/page/navigation.cpp +++ b/src/app/browser/main/tab/page/navigation.cpp @@ -15,7 +15,7 @@ Navigation::Navigation( const Glib::RefPtr & ACTION__NAVIGATION_UPDATE ) { // Init database - DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::init( + DB::SESSION::init( this->db = db ); @@ -112,7 +112,7 @@ int Navigation::save( const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB_PAGE__SESSION_ID ) { return navigationRequest->save( - DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::add( + DB::SESSION::add( db, DB__APP_BROWSER_MAIN_TAB_PAGE__SESSION_ID ) @@ -203,7 +203,7 @@ void Navigation::set_request_text( } // Database model -int Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::init( +int Navigation::DB::SESSION::init( sqlite3 * db ) { char * error; @@ -223,7 +223,7 @@ int Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::init( ); } -int Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::clean( +int Navigation::DB::SESSION::clean( sqlite3 * db, const int & DB__APP_BROWSER_MAIN_TAB_PAGE__SESSION_ID ) { @@ -250,7 +250,7 @@ int Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::clean( { const int APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION_ID = sqlite3_column_int( statement, - DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::ID + DB::SESSION::ID ); // Delete record @@ -270,7 +270,7 @@ int Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::clean( // Delegate children dependencies cleanup if (EXEC_STATUS == SQLITE_OK) { - navigation::Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::clean( + navigation::Request::DB::SESSION::clean( db, APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION_ID ); @@ -283,7 +283,7 @@ int Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::clean( ); } -sqlite3_int64 Navigation::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION::add( +sqlite3_int64 Navigation::DB::SESSION::add( sqlite3 * db, const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB_PAGE__SESSION_ID ) { diff --git a/src/app/browser/main/tab/page/navigation.hpp b/src/app/browser/main/tab/page/navigation.hpp index 233add5d..c67bb327 100644 --- a/src/app/browser/main/tab/page/navigation.hpp +++ b/src/app/browser/main/tab/page/navigation.hpp @@ -30,7 +30,8 @@ namespace app::browser::main::tab::page */ struct DB { - struct APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION + // APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__* + struct SESSION { enum { diff --git a/src/app/browser/main/tab/page/navigation/request.cpp b/src/app/browser/main/tab/page/navigation/request.cpp index dd416b99..a4ec4918 100644 --- a/src/app/browser/main/tab/page/navigation/request.cpp +++ b/src/app/browser/main/tab/page/navigation/request.cpp @@ -9,7 +9,7 @@ Request::Request( const Glib::RefPtr & ACTION__UPDATE ) { // Init database - DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::init( + DB::SESSION::init( this->db = db ); @@ -87,7 +87,7 @@ void Request::refresh( int Request::save( const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION_ID ) { - return DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::add( + return DB::SESSION::add( db, DB__APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION_ID, get_text() @@ -151,7 +151,7 @@ Glib::ustring Request::get_query() } // Database model -int Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::init( +int Request::DB::SESSION::init( sqlite3 * db ) { char * error; @@ -172,7 +172,7 @@ int Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::init( ); } -int Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::clean( +int Request::DB::SESSION::clean( sqlite3 * db, const int & DB__APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION_ID ) { @@ -183,7 +183,8 @@ int Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::clean( db, Glib::ustring::sprintf( R"SQL( - SELECT * FROM `app_browser_main_tab_page_navigation_request__session` WHERE `app_browser_main_tab_page_navigation__session_id` = %d + SELECT * FROM `app_browser_main_tab_page_navigation_request__session` + WHERE `app_browser_main_tab_page_navigation__session_id` = %d )SQL", DB__APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION_ID ).c_str(), @@ -199,7 +200,7 @@ int Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::clean( { const int APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION_ID = sqlite3_column_int( statement, - DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::ID + DB::SESSION::ID ); // Delete record @@ -229,7 +230,7 @@ int Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::clean( ); } -sqlite3_int64 Request::DB::APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION::add( +sqlite3_int64 Request::DB::SESSION::add( sqlite3 * db, const sqlite3_int64 & DB__APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION__SESSION_ID, const Glib::ustring & TEXT diff --git a/src/app/browser/main/tab/page/navigation/request.hpp b/src/app/browser/main/tab/page/navigation/request.hpp index 1b42e46b..ccb4d308 100644 --- a/src/app/browser/main/tab/page/navigation/request.hpp +++ b/src/app/browser/main/tab/page/navigation/request.hpp @@ -23,7 +23,8 @@ namespace app::browser::main::tab::page::navigation */ struct DB { - struct APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__SESSION + // APP_BROWSER_MAIN_TAB_PAGE_NAVIGATION_REQUEST__* + struct SESSION { enum {