annotate src/util.h @ 255:55581d90c55d

Change API for slCheckAndReportSQLError().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 10 Oct 2018 13:21:51 +0300
parents eadffc38ab43
children df3f902588af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
246
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 //
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 // Syntilista - debt list/management database program
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 // Programmed and designed by Matti Hämäläinen <ccr@tnsp.org>
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 // (C) Copyright 2017-2018 Tecnic Software productions (TNSP)
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 //
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 // Distributed under 3-clause BSD style license, refer to
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 // included file "COPYING" for exact terms.
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 //
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #ifndef SL_UTIL_H
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 #define SL_UTIL_H
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11
252
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
12
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
13 #define SQL_MAX_SCHEMA_INSERTS 16
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
14
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
15
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
16 //
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
17 // SQL schema / table definitions
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
18 //
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
19 typedef struct
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
20 {
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
21 QString name;
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
22 QString schema;
253
eadffc38ab43 Add support for initial INSERT statements for database creation in schema array.
Matti Hamalainen <ccr@tnsp.org>
parents: 252
diff changeset
23 QString inserts[SQL_MAX_SCHEMA_INSERTS];
252
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
24 } SLSQLSchemaDef;
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
25
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
26
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
27 //
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
28 // Various helper utility functions
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
29 //
246
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 double slMoneyStrToValue(const QString &str);
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 QString slMoneyValueToStr(double val);
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 QString slMoneyValueToStrSign(double val);
252
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
33
246
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 QString slCleanupStr(const QString &str);
252
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
35
246
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 const QDateTime slDateTimeToLocal(const QDateTime &val);
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 const QString slDateTimeToStr(const QDateTime &val);
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 void slLog(const QString &mtype, const QString &msg);
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 int slErrorMsg(const QString &title, const QString &msg);
252
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
41
255
55581d90c55d Change API for slCheckAndReportSQLError().
Matti Hamalainen <ccr@tnsp.org>
parents: 253
diff changeset
42 bool slCheckAndReportSQLError(const QSqlQuery &query, const QString where, bool report = false);
252
4d2b37a0acf2 Move SQL table creation from schema array to util-module.
Matti Hamalainen <ccr@tnsp.org>
parents: 246
diff changeset
43 bool slConditionallyCreateSQLTables(QSqlDatabase &db, const SLSQLSchemaDef *schema, const int nschema);
246
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45
43a5e09bb832 Split some utility functions to util.{h,cpp}
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 #endif // SL_UTIL_H