Diffstat (limited to 'qmake/include/private/qsqlextension_p.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | qmake/include/private/qsqlextension_p.h | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/qmake/include/private/qsqlextension_p.h b/qmake/include/private/qsqlextension_p.h index 597b266..3445b47 100644 --- a/qmake/include/private/qsqlextension_p.h +++ b/qmake/include/private/qsqlextension_p.h | |||
@@ -6,96 +6,123 @@ | |||
6 | ** | 6 | ** |
7 | ** Copyright (C) 2002 Trolltech AS. All rights reserved. | 7 | ** Copyright (C) 2002 Trolltech AS. All rights reserved. |
8 | ** | 8 | ** |
9 | ** This file is part of the sql module of the Qt GUI Toolkit. | 9 | ** This file is part of the sql module of the Qt GUI Toolkit. |
10 | ** | 10 | ** |
11 | ** This file may be distributed under the terms of the Q Public License | 11 | ** This file may be distributed under the terms of the Q Public License |
12 | ** as defined by Trolltech AS of Norway and appearing in the file | 12 | ** as defined by Trolltech AS of Norway and appearing in the file |
13 | ** LICENSE.QPL included in the packaging of this file. | 13 | ** LICENSE.QPL included in the packaging of this file. |
14 | ** | 14 | ** |
15 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 17 | ** Foundation and appearing in the file LICENSE.GPL included in the |
18 | ** packaging of this file. | 18 | ** packaging of this file. |
19 | ** | 19 | ** |
20 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | 20 | ** Licensees holding valid Qt Enterprise Edition licenses may use this |
21 | ** file in accordance with the Qt Commercial License Agreement provided | 21 | ** file in accordance with the Qt Commercial License Agreement provided |
22 | ** with the Software. | 22 | ** with the Software. |
23 | ** | 23 | ** |
24 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 25 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
26 | ** | 26 | ** |
27 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 27 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
28 | ** information about Qt Commercial License Agreements. | 28 | ** information about Qt Commercial License Agreements. |
29 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 29 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
30 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 30 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
31 | ** | 31 | ** |
32 | ** Contact info@trolltech.com if any conditions of this licensing are | 32 | ** Contact info@trolltech.com if any conditions of this licensing are |
33 | ** not clear to you. | 33 | ** not clear to you. |
34 | ** | 34 | ** |
35 | **********************************************************************/ | 35 | **********************************************************************/ |
36 | 36 | ||
37 | #ifndef QSQLEXTENSION_P_H | 37 | #ifndef QSQLEXTENSION_P_H |
38 | #define QSQLEXTENSION_P_H | 38 | #define QSQLEXTENSION_P_H |
39 | 39 | ||
40 | // | 40 | // |
41 | // W A R N I N G | 41 | // W A R N I N G |
42 | // ------------- | 42 | // ------------- |
43 | // | 43 | // |
44 | // This file is not part of the Qt API. It exists for the convenience | 44 | // This file is not part of the Qt API. It exists for the convenience |
45 | // of other Qt classes. This header file may change from version to | 45 | // of other Qt classes. This header file may change from version to |
46 | // version without notice, or even be removed. | 46 | // version without notice, or even be removed. |
47 | // | 47 | // |
48 | // We mean it. | 48 | // We mean it. |
49 | // | 49 | // |
50 | // | 50 | // |
51 | 51 | ||
52 | #ifndef QT_H | 52 | #ifndef QT_H |
53 | #include "qmap.h" | 53 | #include "qmap.h" |
54 | #include "qvaluevector.h" | ||
54 | #include "qstring.h" | 55 | #include "qstring.h" |
55 | #include "qvariant.h" | 56 | #include "qvariant.h" |
57 | #include "qsql.h" | ||
56 | #endif // QT_H | 58 | #endif // QT_H |
57 | 59 | ||
58 | #ifndef QT_NO_SQL | 60 | #ifndef QT_NO_SQL |
59 | 61 | ||
60 | #if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL ) | 62 | #if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL ) |
61 | #define QM_EXPORT_SQL | 63 | #define QM_EXPORT_SQL |
64 | #define QM_TEMPLATE_EXTERN_SQL | ||
62 | #else | 65 | #else |
63 | #define QM_EXPORT_SQL Q_EXPORT | 66 | #define QM_EXPORT_SQL Q_EXPORT |
67 | #define QM_TEMPLATE_EXTERN_SQL Q_TEMPLATE_EXTERN | ||
64 | #endif | 68 | #endif |
65 | 69 | ||
70 | struct Param { | ||
71 | Param( const QVariant& v = QVariant(), QSql::ParameterType t = QSql::In ): value( v ), typ( t ) {} | ||
72 | QVariant value; | ||
73 | QSql::ParameterType typ; | ||
74 | Q_DUMMY_COMPARISON_OPERATOR(Param) | ||
75 | }; | ||
76 | |||
77 | struct Holder { | ||
78 | Holder( const QString& hldr = QString::null, int pos = -1 ): holderName( hldr ), holderPos( pos ) {} | ||
79 | bool operator==( const Holder& h ) const { return h.holderPos == holderPos && h.holderName == holderName; } | ||
80 | bool operator!=( const Holder& h ) const { return h.holderPos != holderPos || h.holderName != holderName; } | ||
81 | QString holderName; | ||
82 | int holderPos; | ||
83 | }; | ||
84 | |||
66 | #if defined(Q_TEMPLATEDLL) | 85 | #if defined(Q_TEMPLATEDLL) |
67 | Q_TEMPLATE_EXTERN template class QM_EXPORT_SQL QMap<QString,QVariant>; | 86 | QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QMap<QString,Param>; |
68 | Q_TEMPLATE_EXTERN template class QM_EXPORT_SQL QMap<int,QString>; | 87 | QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QMap<int,QString>; |
88 | QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QValueVector<Holder>; | ||
69 | #endif | 89 | #endif |
70 | 90 | ||
71 | class QM_EXPORT_SQL QSqlExtension { | 91 | class QM_EXPORT_SQL QSqlExtension { |
72 | public: | 92 | public: |
73 | QSqlExtension(); | 93 | QSqlExtension(); |
74 | virtual ~QSqlExtension(); | 94 | virtual ~QSqlExtension(); |
75 | virtual bool prepare( const QString& query ); | 95 | virtual bool prepare( const QString& query ); |
76 | virtual bool exec(); | 96 | virtual bool exec(); |
77 | virtual void bindValue( const QString& holder, const QVariant& value ); | 97 | virtual void bindValue( const QString& holder, const QVariant& value, QSql::ParameterType = QSql::In ); |
78 | virtual void bindValue( int pos, const QVariant& value ); | 98 | virtual void bindValue( int pos, const QVariant& value, QSql::ParameterType = QSql::In ); |
79 | virtual void addBindValue( const QVariant& value ); | 99 | virtual void addBindValue( const QVariant& value, QSql::ParameterType = QSql::In ); |
100 | virtual QVariant parameterValue( const QString& holder ); | ||
101 | virtual QVariant parameterValue( int pos ); | ||
80 | void clearValues(); | 102 | void clearValues(); |
81 | void clearIndex(); | 103 | void clearIndex(); |
82 | 104 | ||
83 | enum BindMethod { BindByPosition, BindByName }; | 105 | enum BindMethod { BindByPosition, BindByName }; |
84 | BindMethod bindMethod(); | 106 | BindMethod bindMethod(); |
85 | BindMethod bindm; | 107 | BindMethod bindm; |
86 | int bindCount; | 108 | int bindCount; |
87 | 109 | ||
88 | QMap<int, QString> index; | 110 | QMap<int, QString> index; |
89 | QMap<QString, QVariant> values; | 111 | typedef QMap<QString, Param> ValueMap; |
112 | ValueMap values; | ||
113 | |||
114 | // convenience container for QSqlQuery | ||
115 | // to map holders <-> positions | ||
116 | typedef QValueVector<Holder> HolderVector; | ||
117 | HolderVector holders; | ||
90 | }; | 118 | }; |
91 | 119 | ||
92 | class QM_EXPORT_SQL QSqlDriverExtension | 120 | class QM_EXPORT_SQL QSqlDriverExtension |
93 | { | 121 | { |
94 | public: | 122 | public: |
95 | QSqlDriverExtension(); | 123 | QSqlDriverExtension(); |
96 | virtual ~QSqlDriverExtension(); | 124 | virtual ~QSqlDriverExtension(); |
97 | virtual bool isOpen() const = 0; | 125 | virtual bool isOpen() const = 0; |
98 | }; | 126 | }; |
99 | |||
100 | #endif | 127 | #endif |
101 | #endif | 128 | #endif |