kexi

driver_p.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
3 Copyright (C) 2004 Martin Ellis <martin.ellis@kdemail.net>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this program; see the file COPYING. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include <kdebug.h>
22#include <tqdict.h>
23#include <tqvaluevector.h>
24#include "driver_p.h"
25
26using namespace KexiDB;
27
28namespace KexiDB {
29 TQAsciiDict<bool>* DriverPrivate::kexiSQLDict = 0;
30
34 static bool _dummy;
35}
36
37
38DriverPrivate::DriverPrivate()
39 : isFileDriver(false)
40 , isDBOpenedAfterCreate(false)
41 , features(Driver::NoFeatures)
42{
43 kexiSQLDict = 0;
44 driverSQLDict = 0;
45 adminTools = 0;
46
47 properties["client_library_version"] = "";
48 propertyCaptions["client_library_version"] =
49 i18n("Client library version");
50
51 properties["default_server_encoding"] = "";
52 propertyCaptions["default_server_encoding"] =
53 i18n("Default character encoding on server");
54}
55
56void DriverPrivate::initInternalProperties()
57{
58 properties["is_file_database"] = TQVariant(isFileDriver);
59 propertyCaptions["is_file_database"] = i18n("File-based database driver");
60 if (isFileDriver) {
61 properties["file_database_mimetype"] = fileDBDriverMimeType;
62 propertyCaptions["file_database_mimetype"] = i18n("File-based database's MIME type");
63 }
64
65#if 0
66 TQString str;
67 if (features & Driver::SingleTransactions)
68 str = i18n("Single transactions");
69 else if (features & Driver::MultipleTransactions)
70 str = i18n("Multiple transactions");
71 else if (features & Driver::NestedTransactions)
72 str = i18n("Nested transactions");
73 else if (features & Driver::IgnoreTransactions)
74 str = i18n("Ignored");
75 else
76 str = i18n("None");
77#endif
78// properties["transaction_support"] = features & Driver::TransactionsMask;
79// propertyCaptions["transaction_support"] = i18n("Transaction support");
80 properties["transaction_single"] = TQVariant(features & Driver::SingleTransactions);
81 propertyCaptions["transaction_single"] = i18n("Single transactions support");
82 properties["transaction_multiple"] = TQVariant(features & Driver::MultipleTransactions);
83 propertyCaptions["transaction_multiple"] = i18n("Multiple transactions support");
84 properties["transaction_nested"] = TQVariant(features & Driver::NestedTransactions);
85 propertyCaptions["transaction_nested"] = i18n("Nested transactions support");
86
87 properties["kexidb_driver_version"] =
88 TQString("%1.%2").arg(version().major).arg(version().minor);
89 propertyCaptions["kexidb_driver_version"] =
90 i18n("KexiDB driver version");
91}
92
93DriverPrivate::~DriverPrivate()
94{
95 delete driverSQLDict;
96 delete adminTools;
97}
98
99
100void DriverPrivate::initKexiKeywords() {
101 // TQAsciiDict constructor args:
102 // size (preferable prime)
103 // case sensitive flag (false)
104 // copy strings (false)
105 if(!kexiSQLDict) {
106 kexiSQLDict = new TQAsciiDict<bool>(79, false, false);
107 initKeywords(kexiSQLKeywords, *kexiSQLDict);
108 }
109}
110
111void DriverPrivate::initDriverKeywords(const char* keywords[], int hashSize) {
112 driverSQLDict = new TQAsciiDict<bool>(hashSize, false, false);
113 initKeywords(keywords, *driverSQLDict);
114}
115
116void DriverPrivate::initKeywords(const char* keywords[],
117 TQAsciiDict<bool>& dict) {
118 for(int i = 0; keywords[i] != 0; i++) {
119 dict.insert(keywords[i], &_dummy);
120 }
121}
122
123AdminTools::Private::Private()
124{
125}
126
127AdminTools::Private::~Private()
128{
129}
Generic database abstraction.
Definition driver.h:67
@ NestedTransactions
Definition driver.h:97
@ IgnoreTransactions
Definition driver.h:111
@ SingleTransactions
single trasactions are only supported
Definition driver.h:90
@ MultipleTransactions
multiple concurrent trasactions are supported (this implies !SingleTransactions)
Definition driver.h:93
High-level database connectivity library with database backend drivers.
static bool _dummy
Definition driver_p.cpp:34
KEXI_DB_EXPORT DatabaseVersionInfo version()
Definition global.cpp:55