summaryrefslogtreecommitdiffstats
path: root/kexi/kexidb/driver_p.cpp
blob: 462ce608bdd45f7942bbbf22dbbb4049390d18bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* This file is part of the KDE project
    Copyright (C) 2003-2004 Jaroslaw Staniek <js@iidea.pl>
    Copyright (C) 2004 Martin Ellis <martin.ellis@kdemail.net>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#include <kdebug.h>
#include <tqdict.h>
#include <tqvaluevector.h>
#include "driver_p.h"

using namespace KexiDB;

namespace KexiDB {
	TQAsciiDict<bool>* DriverPrivate::kexiSQLDict = 0;
	
	/*! TQAsciiDict keys need to be a pointer to *something*.  Used
	    for SQL keyword dictionaries
	*/
  static bool _dummy;
}


DriverPrivate::DriverPrivate()
 : isFileDriver(false)
 , isDBOpenedAfterCreate(false)
 , features(Driver::NoFeatures)
{
	kexiSQLDict = 0;
	driverSQLDict = 0;
	adminTools = 0;

	properties["client_library_version"] = "";
	propertyCaptions["client_library_version"] =
	  i18n("Client library version");

	properties["default_server_encoding"] = "";
	propertyCaptions["default_server_encoding"] =
	  i18n("Default character encoding on server");
}

void DriverPrivate::initInternalProperties()
{
	properties["is_file_database"] = TQVariant(isFileDriver, 1);
	propertyCaptions["is_file_database"] = i18n("File-based database driver");
	if (isFileDriver) {
		properties["file_database_mimetype"] = fileDBDriverMimeType;
		propertyCaptions["file_database_mimetype"] = i18n("File-based database's MIME type");
	}

#if 0
	TQString str;
	if (features & Driver::SingleTransactions)
		str = i18n("Single transactions");
	else if (features & Driver::MultipleTransactions)
		str = i18n("Multiple transactions");
	else if (features & Driver::NestedTransactions)
		str = i18n("Nested transactions");
	else if (features & Driver::IgnoreTransactions)
		str = i18n("Ignored");
	else
		str = i18n("None");
#endif
//	properties["transaction_support"] = features & Driver::TransactionsMask;
//	propertyCaptions["transaction_support"] = i18n("Transaction support");
	properties["transaction_single"] = TQVariant(features & Driver::SingleTransactions, 1);
	propertyCaptions["transaction_single"] = i18n("Single transactions support");
	properties["transaction_multiple"] = TQVariant(features & Driver::MultipleTransactions, 1);
	propertyCaptions["transaction_multiple"] = i18n("Multiple transactions support");
	properties["transaction_nested"] = TQVariant(features & Driver::NestedTransactions, 1);
	propertyCaptions["transaction_nested"] = i18n("Nested transactions support");

	properties["kexidb_driver_version"] =
	  TQString("%1.%2").arg(version().major).arg(version().minor);
	propertyCaptions["kexidb_driver_version"] =
	  i18n("KexiDB driver version");
}

DriverPrivate::~DriverPrivate()
{
	delete driverSQLDict;
	delete adminTools;
}


void DriverPrivate::initKexiKeywords() {
	// TQAsciiDict constructor args:
	//   size (preferable prime)
	//   case sensitive flag (false)
	//   copy strings (false)
	if(!kexiSQLDict) {
		kexiSQLDict = new TQAsciiDict<bool>(79, false, false);
		initKeywords(kexiSQLKeywords, *kexiSQLDict);
	}
}

void DriverPrivate::initDriverKeywords(const char* keywords[], int hashSize) {
	driverSQLDict = new TQAsciiDict<bool>(hashSize, false, false);
	initKeywords(keywords, *driverSQLDict);
}

void DriverPrivate::initKeywords(const char* keywords[], 
    TQAsciiDict<bool>& dict) {
	for(int i = 0; keywords[i] != 0; i++) {
		dict.insert(keywords[i], &_dummy);
	}
}

AdminTools::Private::Private()
{
}

AdminTools::Private::~Private()
{
}