1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Definition of QSqlDriver class
|
---|
4 | **
|
---|
5 | ** Created : 2000-11-03
|
---|
6 | **
|
---|
7 | ** Copyright (C) 2005-2007 Trolltech ASA. All rights reserved.
|
---|
8 | **
|
---|
9 | ** This file is part of the sql module of the Qt GUI Toolkit.
|
---|
10 | **
|
---|
11 | ** This file may be distributed under the terms of the Q Public License
|
---|
12 | ** as defined by Trolltech ASA of Norway and appearing in the file
|
---|
13 | ** LICENSE.QPL included in the packaging of this file.
|
---|
14 | **
|
---|
15 | ** This file may be distributed and/or modified under the terms of the
|
---|
16 | ** GNU General Public License version 2 as published by the Free Software
|
---|
17 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
18 | ** packaging of this file.
|
---|
19 | **
|
---|
20 | ** Licensees holding valid Qt Enterprise Edition licenses may use this
|
---|
21 | ** file in accordance with the Qt Commercial License Agreement provided
|
---|
22 | ** with the Software.
|
---|
23 | **
|
---|
24 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
25 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
26 | **
|
---|
27 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
28 | ** information about Qt Commercial License Agreements.
|
---|
29 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
30 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
31 | **
|
---|
32 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
33 | ** not clear to you.
|
---|
34 | **
|
---|
35 | **********************************************************************/
|
---|
36 |
|
---|
37 | #ifndef QSQLDRIVER_H
|
---|
38 | #define QSQLDRIVER_H
|
---|
39 |
|
---|
40 | #ifndef QT_H
|
---|
41 | #include "qobject.h"
|
---|
42 | #include "qptrdict.h"
|
---|
43 | #include "qstring.h"
|
---|
44 | #include "qsqlerror.h"
|
---|
45 | #include "qsqlquery.h"
|
---|
46 | #include "qsqlfield.h"
|
---|
47 | #include "qsqlindex.h"
|
---|
48 | #include "qstringlist.h"
|
---|
49 | #include "qmap.h"
|
---|
50 | #endif // QT_H
|
---|
51 |
|
---|
52 | #if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
|
---|
53 | #define QM_EXPORT_SQL
|
---|
54 | #else
|
---|
55 | #define QM_EXPORT_SQL Q_EXPORT
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | #ifndef QT_NO_SQL
|
---|
59 |
|
---|
60 | class QSqlDriverExtension;
|
---|
61 |
|
---|
62 | class QSqlDatabase;
|
---|
63 |
|
---|
64 | class QM_EXPORT_SQL QSqlDriver : public QObject
|
---|
65 | {
|
---|
66 | friend class QSqlDatabase;
|
---|
67 | Q_OBJECT
|
---|
68 | public:
|
---|
69 | enum DriverFeature { Transactions, QuerySize, BLOB, Unicode, PreparedQueries,
|
---|
70 | NamedPlaceholders, PositionalPlaceholders };
|
---|
71 |
|
---|
72 | QSqlDriver( QObject * parent=0, const char * name=0 );
|
---|
73 | ~QSqlDriver();
|
---|
74 | bool isOpen() const;
|
---|
75 | bool isOpenError() const;
|
---|
76 |
|
---|
77 | virtual bool beginTransaction();
|
---|
78 | virtual bool commitTransaction();
|
---|
79 | virtual bool rollbackTransaction();
|
---|
80 | virtual QStringList tables( const QString& tableType ) const;
|
---|
81 | virtual QSqlIndex primaryIndex( const QString& tableName ) const;
|
---|
82 | virtual QSqlRecord record( const QString& tableName ) const;
|
---|
83 | virtual QSqlRecord record( const QSqlQuery& query ) const;
|
---|
84 | virtual QSqlRecordInfo recordInfo( const QString& tablename ) const;
|
---|
85 | virtual QSqlRecordInfo recordInfo( const QSqlQuery& query ) const;
|
---|
86 | virtual QString nullText() const;
|
---|
87 | virtual QString formatValue( const QSqlField* field, bool trimStrings = FALSE ) const;
|
---|
88 | QSqlError lastError() const;
|
---|
89 |
|
---|
90 | virtual bool hasFeature( DriverFeature f ) const = 0;
|
---|
91 | virtual bool open( const QString & db,
|
---|
92 | const QString & user = QString::null,
|
---|
93 | const QString & password = QString::null,
|
---|
94 | const QString & host = QString::null,
|
---|
95 | int port = -1 ) = 0;
|
---|
96 | virtual void close() = 0;
|
---|
97 | virtual QSqlQuery createQuery() const = 0;
|
---|
98 |
|
---|
99 | // ### remove for 4.0
|
---|
100 | bool open( const QString& db,
|
---|
101 | const QString& user,
|
---|
102 | const QString& password,
|
---|
103 | const QString& host,
|
---|
104 | int port,
|
---|
105 | const QString& connOpts );
|
---|
106 | protected:
|
---|
107 | virtual void setOpen( bool o );
|
---|
108 | virtual void setOpenError( bool e );
|
---|
109 | virtual void setLastError( const QSqlError& e );
|
---|
110 | private:
|
---|
111 | // ### This class needs a d-pointer in 4.0.
|
---|
112 | int dbState;
|
---|
113 | QSqlError error;
|
---|
114 | #if defined(Q_DISABLE_COPY)
|
---|
115 | QSqlDriver( const QSqlDriver & );
|
---|
116 | QSqlDriver &operator=( const QSqlDriver & );
|
---|
117 | #endif
|
---|
118 | };
|
---|
119 |
|
---|
120 | #endif // QT_NO_SQL
|
---|
121 | #endif
|
---|