2 Commits

Author SHA1 Message Date
3c2b8e7cf4 тудаже 2025-03-16 10:46:18 +05:00
394c55ae5c Попытка раскидать по библиотекам 2025-03-16 10:46:06 +05:00
15 changed files with 129 additions and 42 deletions

3
.gitmodules vendored Normal file
View File

@@ -0,0 +1,3 @@
[submodule "redkbuild"]
path = redkbuild
url = ssh://git@gitea.redkit-lab.work:57322/redkit-lab/redkbuild.git

View File

@@ -8,12 +8,14 @@ Project {
// // "guiness/qbs", // // "guiness/qbs",
// // "prerequisites/qbs", // // "prerequisites/qbs",
// // "report/qbs", // // "report/qbs",
// "redkbuild", "redkbuild",
// // "ext_libs/openssl/qbs", // // "ext_libs/openssl/qbs",
// "redkitty/lib/redkit-gen-integration/qbs", // "redkitty/lib/redkit-gen-integration/qbs",
] ]
references: [ references: [
"src/cpp-opds.qbs", "src/cpp-opds.qbs",
"src/database/database.qbs",
"src/restapi/restapi.qbs",
] ]
} }

View File

@@ -35,6 +35,7 @@ Module {
// "--include-prefix", FileInfo.cleanPath(input.filePath + "/../"), // "--include-prefix", FileInfo.cleanPath(input.filePath + "/../"),
// "--output-dir", product.Qt.core.qmDir, // "--output-dir", product.Qt.core.qmDir,
"--output-dir", FileInfo.cleanPath(input.filePath + "/../"), "--output-dir", FileInfo.cleanPath(input.filePath + "/../"),
"-I/home/uzver/qt5.15/include",
input.filePath, input.filePath,
]); ]);
cmd.description = "Generating ODB files for " + input.fileName; cmd.description = "Generating ODB files for " + input.fileName;
@@ -44,5 +45,21 @@ Module {
return [cmd]; return [cmd];
} }
} }
cpp.includePaths: [ project.sourceDirectory, product.Qt.core.qmDir ]
cpp.includePaths: [
project.sourceDirectory,
product.Qt.core.qmDir,
"/usr/include", // Общие заголовки
"/usr/include/odb" // Заголовки ODB
]
// Подключаем библиотеки ODB
cpp.libraryPaths: [
"/usr/lib" // Путь к библиотекам
]
cpp.dynamicLibraries: [
"odb",
"odb-sqlite"
]
} }

1
redkbuild Submodule

Submodule redkbuild added at 3adf92aad6

View File

@@ -15,6 +15,7 @@ Application {
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] } Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
Depends { name: "cpp" } Depends { name: "cpp" }
Depends { name: "database" }
Depends { name: "odbModule"} Depends { name: "odbModule"}
// Depends { name: "redkit_gen" } // Depends { name: "redkit_gen" }
@@ -24,35 +25,10 @@ Application {
Group { Group {
name: "cpp" name: "cpp"
files: [ files: [
"books.*",
"databasemanager.*",
"main.cpp", "main.cpp",
"restapiserver.*",
] ]
} }
Group {
name: "odb"
files: [
"author_s.h",
"book_s.h",
]
fileTags: ["odb"]
}
cpp.includePaths: [
"/usr/include", // Общие заголовки
"/usr/include/odb" // Заголовки ODB
]
// Подключаем библиотеки ODB
cpp.libraryPaths: [
"/usr/lib" // Путь к библиотекам
]
cpp.dynamicLibraries: [
"odb",
"odb-sqlite"
]
// } // }
} // Project } // Project

View File

@@ -4,6 +4,8 @@
#ifndef AUTHOR_S_H #ifndef AUTHOR_S_H
#define AUTHOR_S_H #define AUTHOR_S_H
// #include <QtCore/QObject>
#include <cstddef> // std::size_t #include <cstddef> // std::size_t
#include <memory> #include <memory>
#include <string> #include <string>
@@ -13,7 +15,7 @@
#include <odb/query.hxx> #include <odb/query.hxx>
#pragma db object #pragma db object
class Author_S class __attribute__((visibility("default"))) Author_S
{ {
public: public:
Author_S() = default; Author_S() = default;

View File

@@ -4,6 +4,8 @@
#ifndef BOOK_S_H #ifndef BOOK_S_H
#define BOOK_S_H #define BOOK_S_H
// #include <QtCore/QObject>
#include <memory> #include <memory>
#include <string> #include <string>
@@ -12,7 +14,7 @@
#include "author_s.h" #include "author_s.h"
#pragma db object #pragma db object
class Book_S class __attribute__((visibility("default"))) Book_S
{ {
public: public:
Book_S() = default; Book_S() = default;

52
src/database/database.qbs Normal file
View File

@@ -0,0 +1,52 @@
/*!
\qmltype cpp-opds
\inherits Project
\brief Описание
*/
PSLibrary {
cpp.defines: [
// You can make your code fail to compile if it uses deprecated APIs.
// In order to do so, uncomment the following line.
//"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0
"DATABASE_SQLITE"
]
consoleApplication: true
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
Depends { name: "cpp" }
Depends { name: "odbModule"}
cpp.cxxLanguageVersion: "c++20"
Group {
name: "cpp"
files: [
"books.*",
"databasemanager.*",
]
}
Group {
name: "odb"
files: [
"author_s.h",
"book_s.h",
]
fileTags: ["odb"]
}
cpp.includePaths: [
"/usr/include", // Общие заголовки
"/usr/include/odb" // Заголовки ODB
]
// Подключаем библиотеки ODB
cpp.libraryPaths: [
"/usr/lib" // Путь к библиотекам
]
cpp.dynamicLibraries: [
"odb",
"odb-sqlite"
]
}

View File

@@ -35,7 +35,7 @@ struct SelectBuilder
} }
}; };
class DatabaseManager class Q_DECL_EXPORT DatabaseManager
{ {
public: public:
static DatabaseManager& instance(); // Singleton static DatabaseManager& instance(); // Singleton

View File

@@ -1,17 +1,16 @@
#include <QCoreApplication> #include <QCoreApplication>
#include "restapiserver.h" #include <restapi/restapiserver.h>
/* Опыты с odb */ /* Опыты с odb */
#include "author_s-odb.hxx" // Должен быть здесь #include <database/author_s-odb.hxx> // Должен быть здесь
#include "author_s.h" #include <database/author_s.h>
#include <database/book_s-odb.hxx> // Должен быть здесь
#include "book_s-odb.hxx" // Должен быть здесь #include <database/book_s.h>
#include "book_s.h" #include <database/database.hxx> // create_database
#include <odb/database.hxx> #include <odb/database.hxx>
#include "database.hxx" // create_database #include <iostream>
using unidb = std::unique_ptr<odb::database>; using unidb = std::unique_ptr<odb::database>;

31
src/restapi/restapi.qbs Normal file
View File

@@ -0,0 +1,31 @@
/*!
\qmltype cpp-opds
\inherits Project
\brief Описание
*/
PSLibrary {
cpp.defines: [
// You can make your code fail to compile if it uses deprecated APIs.
// In order to do so, uncomment the following line.
//"QT_DISABLE_DEPRECATED_BEFORE=0x060000" // disables all the APIs deprecated before Qt 6.0.0
"DATABASE_SQLITE"
]
consoleApplication: true
Depends { name: "Qt"; submodules: [ "core", "sql", "network" ] }
Depends { name: "cpp" }
Depends { name: "database" }
Depends { name: "odbModule"}
// Depends { name: "redkit_gen" }
cpp.cxxLanguageVersion: "c++20"
Group {
name: "cpp"
files: [
"restapiserver.*",
]
}
} // Project

View File

@@ -5,15 +5,16 @@
#include <QJsonObject> #include <QJsonObject>
#include <QJsonValue> #include <QJsonValue>
#include "book_s-odb.hxx" #include <database/book_s.h>
#include "book_s.h"
#include "database/book_s-odb.hxx"
#include <odb/core.hxx> #include <odb/core.hxx>
#include <odb/database.hxx> #include <odb/database.hxx>
#include <odb/query.hxx> #include <odb/query.hxx>
RestApiServer::RestApiServer(odb::database& db, QObject* parent) : RestApiServer::RestApiServer(odb::database& db, QObject* parent) :
m_db(db), QTcpServer(parent) {} QTcpServer(parent), m_db(db) {}
void RestApiServer::start(quint16 port) void RestApiServer::start(quint16 port)
{ {

View File

@@ -3,10 +3,11 @@
#include <odb/database.hxx> #include <odb/database.hxx>
#include <QObject>
#include <QTcpServer> #include <QTcpServer>
#include <QTcpSocket> #include <QTcpSocket>
class RestApiServer : public QTcpServer class Q_DECL_EXPORT RestApiServer : public QTcpServer
{ {
Q_OBJECT Q_OBJECT
public: public: