view src/util.h @ 252:4d2b37a0acf2

Move SQL table creation from schema array to util-module.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 08 May 2018 15:00:17 +0300
parents 43a5e09bb832
children eadffc38ab43
line wrap: on
line source

//
// Syntilista - debt list/management database program
// Programmed and designed by Matti Hämäläinen <ccr@tnsp.org>
// (C) Copyright 2017-2018 Tecnic Software productions (TNSP)
//
// Distributed under 3-clause BSD style license, refer to
// included file "COPYING" for exact terms.
//
#ifndef SL_UTIL_H
#define SL_UTIL_H


#define SQL_MAX_SCHEMA_INSERTS 16


//
// SQL schema / table definitions
//
typedef struct
{
    QString name;
    QString schema;
} SLSQLSchemaDef;


//
// Various helper utility functions
//
double slMoneyStrToValue(const QString &str);
QString slMoneyValueToStr(double val);
QString slMoneyValueToStrSign(double val);

QString slCleanupStr(const QString &str);

const QDateTime slDateTimeToLocal(const QDateTime &val);
const QString slDateTimeToStr(const QDateTime &val);

void slLog(const QString &mtype, const QString &msg);
int slErrorMsg(const QString &title, const QString &msg);

bool slCheckAndReportSQLError(const QString where, const QSqlError &err, bool report = false);
bool slConditionallyCreateSQLTables(QSqlDatabase &db, const SLSQLSchemaDef *schema, const int nschema);


#endif // SL_UTIL_H