first steps

This commit is contained in:
2024-03-11 12:14:28 +01:00
parent 9d4775314c
commit 3568c8ecfb
12 changed files with 239 additions and 193 deletions

View File

@@ -1,13 +1,13 @@
QT -= gui
QT+=core
TEMPLATE = lib
DEFINES += CACULATOR_C_INTERFACE_LIBRARY
DEFINES += CALCULATOR_C_INTERFACE_LIBRARY
# INCLUDEPATH+=$$_PRO_FILE_PWD_/../Utilities/
CONFIG += c++17
QMAKE_CXX=x86_64-w64-mingw32-g++
CONFIG += c++20 console
#QMAKE_CXX=C:\Qt\Tools\mingw1120_64\g++.exe
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
@@ -15,12 +15,12 @@ QMAKE_CXX=x86_64-w64-mingw32-g++
SOURCES += \
calculator_c_interface_lib.cpp \
tariff_editor.cpp
tariff_calculator.cpp
HEADERS += \
calculator_c_interface_lib.h \
calculator_c_interface_lib_global.h
tariff_editor.h
calculator_c_interface_lib_global.h \
tariff_calculator.h
# Default rules for deployment.
unix {

View File

@@ -1,18 +1,19 @@
#include "calculator_c_interface_lib.h"
#include "tariff_editor.h"
#ifdef __cplusplus
extern "C" {
#endif
bool CACULATOR_C_INTERFACE_LIB_EXPORT initTariffEditor() {
TariffEditor editor;
return true;
TariffCalculatorHandle CALCULATOR_C_INTERFACE_LIB_EXPORT NewTariffCalculator(void) {
return new TariffCalculator();
}
void CALCULATOR_C_INTERFACE_LIB_EXPORT DeleteTariffCalculator(TariffCalculatorHandle handle) {
delete handle;
}
#ifdef __cplusplus
}
#endif

View File

@@ -2,19 +2,20 @@
#define CALCULATOR_C_INTERFACE_LIB_H_INCLUDED
#include "calculator_c_interface_lib_global.h"
#include "tariff_calculator.h"
typedef TariffCalculator *TariffCalculatorHandle;
#ifdef __cplusplus
extern "C" {
#endif
bool CACULATOR_C_INTERFACE_LIB_EXPORT initTariffEditor();
TariffCalculatorHandle CALCULATOR_C_INTERFACE_LIB_EXPORT NewTariffCalculator(void);
void CALCULATOR_C_INTERFACE_LIB_EXPORT DeleteTariffCalculator(TariffCalculatorHandle handle);
#ifdef __cplusplus
}
#endif
//{
//public:
// Testlib();
//};
#endif // CALCULATOR_C_INTERFACE_LIB_H_INCLUDED

View File

@@ -3,10 +3,10 @@
#include <QtCore/qglobal.h>
#if defined(CACULATOR_C_INTERFACE_LIBRARY)
#define CACULATOR_C_INTERFACE_LIB_EXPORT Q_DECL_EXPORT
#if defined(CALCULATOR_C_INTERFACE_LIBRARY)
#define CALCULATOR_C_INTERFACE_LIB_EXPORT Q_DECL_EXPORT __stdcall
#else
#define CACULATOR_C_INTERFACE_LIB_EXPORT Q_DECL_IMPORT
#define CALCULATOR_C_INTERFACE_LIB_EXPORT Q_DECL_IMPORT __stdcall
#endif
#endif // CALCULATOR_C_INTERFACE_GLOBAL_H

View File

@@ -1,4 +1,4 @@
#include "tariff_editor.h"
#include "tariff_calculator.h"
#include <QDebug>
#include <QFile>
@@ -10,7 +10,8 @@
#include <QJsonObject>
#include <QJsonValue>
QByteArray TariffEditor::readJson(QString const &filename) {
#if 0
QByteArray TariffCalculator::readJson(QString const &filename) {
QFile f(filename);
if (f.exists()) {
if (f.open(QFile::ReadOnly | QFile::Text)) {
@@ -25,10 +26,15 @@ QByteArray TariffEditor::readJson(QString const &filename) {
return QByteArray();
}
#endif
TariffCalculator::~TariffCalculator() {
qCritical() << __func__;
}
TariffEditor::TariffEditor() {
TariffCalculator::TariffCalculator() {
qCritical() << __func__;
return;
// QByteArray ba = readJson("/opt/ptu5/opt/ATBTariffCalculator/Utilities/tariff.template.json");
//QJsonParseError pe;
@@ -41,6 +47,7 @@ TariffEditor::TariffEditor() {
//}
m_a = QJsonArray();
createJsonValue("Project", "Szeged");
createJsonValue("Version", "1.0.0");
createJsonValue("Date", "01.01.1970");
@@ -56,11 +63,14 @@ TariffEditor::TariffEditor() {
createJsonValue("DayConfigs");
createJsonValue("Days");
m_jsonDoc.setArray(m_a);
qCritical().noquote() << m_jsonDoc.toJson(QJsonDocument::JsonFormat::Indented);
}
void TariffEditor::createJsonValue(QString const &key, QString const &value) {
void TariffCalculator::createJsonValue(QString const &key, QString const &value) {
if ((key.compare("Project", Qt::CaseInsensitive) == 0)
|| (key.compare("Version", Qt::CaseInsensitive) == 0)
@@ -421,3 +431,4 @@ void TariffEditor::createJsonValue(QString const &key, QString const &value) {
#endif
}

View File

@@ -1,5 +1,5 @@
#ifndef TARIFF_EDITOR_H_INCLUDED
#define TARIFF_EDITOR_H_INCLUDED
#ifndef TARIFF_CALCULATOR_H_INCLUDED
#define TARIFF_CALCULATOR_H_INCLUDED
#include <QByteArray>
#include <QString>
@@ -7,14 +7,15 @@
#include <QJsonDocument>
#include <QJsonArray>
class TariffEditor {
class TariffCalculator {
QJsonArray m_a;
QJsonDocument m_jsonDoc;
void createJsonValue(QString const &key, QString const &value = "");
public:
explicit TariffEditor();
explicit TariffCalculator();
~TariffCalculator();
static QByteArray readJson(QString const &filename);
};
#endif // TARIFF_EDITOR_H_INCLUDED
#endif // TARIFF_CALCULATOR_H_INCLUDED