Browse Source

init session db class

CPP-GTK4
yggverse 3 months ago
parent
commit
7a04fb8920
  1. 3
      Makefile
  2. 3
      po/POTFILES.in
  3. 5
      src/lib/database.cpp
  4. 7
      src/lib/database.hpp
  5. 22
      src/lib/database/session.cpp
  6. 26
      src/lib/database/session.hpp

3
Makefile

@ -11,7 +11,8 @@ SRCS = src/main.cpp\
src/app/browser/header/menu.cpp\ src/app/browser/header/menu.cpp\
src/app/browser/header/tab.cpp\ src/app/browser/header/tab.cpp\
src/app/browser/page.cpp\ src/app/browser/page.cpp\
src/lib/database.cpp src/lib/database.cpp\
src/lib/database/session.cpp
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)

3
po/POTFILES.in

@ -8,6 +8,9 @@ src/app/browser/header/tab.cpp
src/app/browser/header/tab.hpp src/app/browser/header/tab.hpp
src/app/browser/page.cpp src/app/browser/page.cpp
src/app/browser/page.hpp src/app/browser/page.hpp
src/lib/database.cpp
src/lib/database.hpp src/lib/database.hpp
src/lib/database/session.cpp
src/lib/database/session.hpp
src/main.cpp src/main.cpp
src/main.hpp src/main.hpp

5
src/lib/database.cpp

@ -1,4 +1,5 @@
#include "database.hpp" #include "database.hpp"
#include "database/session.hpp"
using namespace lib; using namespace lib;
@ -9,4 +10,8 @@ Database::Database(
filename, filename,
&connection &connection
); );
session = new database::Session(
connection
);
} }

7
src/lib/database.hpp

@ -5,6 +5,11 @@
namespace lib namespace lib
{ {
namespace database
{
class Session;
}
class Database class Database
{ {
private: private:
@ -17,6 +22,8 @@ namespace lib
public: public:
database::Session * session;
Database( Database(
const char * filename const char * filename
); );

22
src/lib/database/session.cpp

@ -0,0 +1,22 @@
#include "session.hpp"
using namespace lib::database;
Session::Session(
sqlite3 * connection
) {
status = sqlite3_exec(
connection,
R"(
CREATE TABLE IF NOT EXISTS `session`
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`time` INTEGER NOT NULL,
`request` VARCHAR(1024)
)
)",
nullptr,
nullptr,
&error
);
}

26
src/lib/database/session.hpp

@ -0,0 +1,26 @@
#ifndef LIB_DATABASE_SESSION_H
#define LIB_DATABASE_SESSION_H
#include <sqlite3.h>
namespace lib::database
{
class Session
{
private:
int status;
char * error;
sqlite3 * connection;
public:
Session(
sqlite3 * connection
);
};
}
#endif // LIB_DATABASE_SESSION_H
Loading…
Cancel
Save