Browse Source

init sqlite database library

CPP-GTK4
yggverse 3 months ago
parent
commit
814b25a946
  1. 1
      .gitignore
  2. 7
      Makefile
  3. 9
      README.md
  4. 1
      po/POTFILES.in
  5. 12
      src/lib/database.cpp
  6. 26
      src/lib/database.hpp
  7. 6
      src/main.cpp

1
.gitignore vendored

@ -2,6 +2,7 @@
*.cache *.cache
*.log *.log
*.status *.status
*.sqlite3
configure configure
configure~ configure~
Makefile Makefile

7
Makefile

@ -1,7 +1,7 @@
# Define compiler and flags # Define compiler and flags
CXX = g++ CXX = g++
CXXFLAGS = `pkg-config --cflags gtkmm-4.0 glibmm-2.68` CXXFLAGS = `pkg-config --cflags gtkmm-4.0 glibmm-2.68 sqlite3`
LDFLAGS = `pkg-config --libs gtkmm-4.0 glibmm-2.68` LDFLAGS = `pkg-config --libs gtkmm-4.0 glibmm-2.68 sqlite3`
# Define target executable and source files # Define target executable and source files
TARGET = bin/Yoda TARGET = bin/Yoda
@ -10,7 +10,8 @@ SRCS = src/main.cpp\
src/app/browser/header.cpp\ src/app/browser/header.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
OBJS = $(SRCS:.cpp=.o) OBJS = $(SRCS:.cpp=.o)

9
README.md

@ -10,7 +10,10 @@ GTK 4 / C++ implementation branch
### Linux ### Linux
* `sudo apt install git libgtkmm-4.0-dev libglibmm-2.68-dev` ``` bash
sudo apt install git libgtkmm-4.0-dev libglibmm-2.68-dev libsqlite3-dev
```
* `git clone https://github.com/YGGverse/Yoda.git` * `git clone https://github.com/YGGverse/Yoda.git`
* `cd Yoda` * `cd Yoda`
* `git checkout master` * `git checkout master`
@ -38,7 +41,9 @@ GTK 4 / C++ implementation branch
### Environment ### Environment
* `pkg-config --cflags --libs gtkmm-4.0 glibmm-2.68` ``` bash
pkg-config --cflags --libs gtkmm-4.0 glibmm-2.68 sqlite3
```
### Contribution ### Contribution

1
po/POTFILES.in

@ -8,5 +8,6 @@ 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.hpp
src/main.cpp src/main.cpp
src/main.hpp src/main.hpp

12
src/lib/database.cpp

@ -0,0 +1,12 @@
#include "database.hpp"
using namespace lib;
Database::Database(
const char * filename
) {
status = sqlite3_open(
filename,
&connection
);
}

26
src/lib/database.hpp

@ -0,0 +1,26 @@
#ifndef LIB_DATABASE_H
#define LIB_DATABASE_H
#include <sqlite3.h>
namespace lib
{
class Database
{
private:
int status;
char * error;
sqlite3 * connection;
public:
Database(
const char * filename
);
};
}
#endif // LIB_DATABASE_H

6
src/main.cpp

@ -1,10 +1,16 @@
#include "main.hpp" #include "main.hpp"
#include "app/browser.hpp" #include "app/browser.hpp"
#include "lib/database.hpp"
int main( int main(
int argc, int argc,
char * argv[] char * argv[]
) { ) {
// Init profile
auto database = lib::Database(
"database.sqlite3"
);
// Init app // Init app
auto app = Gtk::Application::create( auto app = Gtk::Application::create(
"io.github.yggverse.Yoda" "io.github.yggverse.Yoda"

Loading…
Cancel
Save