Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qsqlextension_p.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Definition of the QSqlExtension class
00004 **
00005 ** Created : 2002-06-03
00006 **
00007 ** Copyright (C) 2002 Trolltech AS.  All rights reserved.
00008 **
00009 ** This file is part of the sql module of the Qt GUI Toolkit.
00010 **
00011 ** This file may be distributed under the terms of the Q Public License
00012 ** as defined by Trolltech AS of Norway and appearing in the file
00013 ** LICENSE.QPL included in the packaging of this file.
00014 **
00015 ** This file may be distributed and/or modified under the terms of the
00016 ** GNU General Public License version 2 as published by the Free Software
00017 ** Foundation and appearing in the file LICENSE.GPL included in the
00018 ** packaging of this file.
00019 **
00020 ** Licensees holding valid Qt Enterprise Edition licenses may use this
00021 ** file in accordance with the Qt Commercial License Agreement provided
00022 ** with the Software.
00023 **
00024 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00025 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00026 **
00027 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00028 **   information about Qt Commercial License Agreements.
00029 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00030 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00031 **
00032 ** Contact info@trolltech.com if any conditions of this licensing are
00033 ** not clear to you.
00034 **
00035 **********************************************************************/
00036 
00037 #ifndef QSQLEXTENSION_P_H
00038 #define QSQLEXTENSION_P_H
00039 
00040 //
00041 //  W A R N I N G
00042 //  -------------
00043 //
00044 // This file is not part of the Qt API.  It exists for the convenience
00045 // of other Qt classes.  This header file may change from version to
00046 // version without notice, or even be removed.
00047 //
00048 // We mean it.
00049 //
00050 //
00051 
00052 #ifndef QT_H
00053 #include "qmap.h"
00054 #include "qvaluevector.h"
00055 #include "qstring.h"
00056 #include "qvariant.h"
00057 #include "qsql.h"
00058 #endif // QT_H
00059 
00060 #ifndef QT_NO_SQL
00061 
00062 #if !defined( QT_MODULE_SQL ) || defined( QT_LICENSE_PROFESSIONAL )
00063 #define QM_EXPORT_SQL
00064 #define QM_TEMPLATE_EXTERN_SQL
00065 #else
00066 #define QM_EXPORT_SQL Q_EXPORT
00067 #define QM_TEMPLATE_EXTERN_SQL Q_TEMPLATE_EXTERN
00068 #endif
00069 
00070 struct Param {
00071     Param( const QVariant& v = QVariant(), QSql::ParameterType t = QSql::In ): value( v ), typ( t ) {}
00072     QVariant value;
00073     QSql::ParameterType typ;
00074     Q_DUMMY_COMPARISON_OPERATOR(Param)
00075 };
00076 
00077 struct Holder {
00078     Holder( const QString& hldr = QString::null, int pos = -1 ): holderName( hldr ), holderPos( pos ) {}
00079     bool operator==( const Holder& h ) const { return h.holderPos == holderPos && h.holderName == holderName; }
00080     bool operator!=( const Holder& h ) const { return h.holderPos != holderPos || h.holderName != holderName; }
00081     QString holderName;
00082     int     holderPos;
00083 };
00084 
00085 #if defined(Q_TEMPLATEDLL)
00086 QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QMap<QString,Param>;
00087 QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QMap<int,QString>;
00088 QM_TEMPLATE_EXTERN_SQL template class QM_EXPORT_SQL QValueVector<Holder>;
00089 #endif
00090 
00091 class QM_EXPORT_SQL QSqlExtension {
00092 public:
00093     QSqlExtension();
00094     virtual ~QSqlExtension();
00095     virtual bool prepare( const QString& query );
00096     virtual bool exec();
00097     virtual void bindValue( const QString& holder, const QVariant& value, QSql::ParameterType = QSql::In );
00098     virtual void bindValue( int pos, const QVariant& value, QSql::ParameterType = QSql::In );
00099     virtual void addBindValue( const QVariant& value, QSql::ParameterType = QSql::In );
00100     virtual QVariant parameterValue( const QString& holder );
00101     virtual QVariant parameterValue( int pos );
00102     void clearValues();
00103     void clearIndex();
00104 
00105     enum BindMethod { BindByPosition, BindByName };
00106     BindMethod bindMethod();
00107     BindMethod bindm;
00108     int bindCount;
00109 
00110     QMap<int, QString> index;
00111     typedef QMap<QString, Param> ValueMap;
00112     ValueMap values;
00113 
00114     // convenience container for QSqlQuery
00115     // to map holders <-> positions
00116     typedef QValueVector<Holder> HolderVector;
00117     HolderVector holders;
00118 };
00119 
00120 class QM_EXPORT_SQL QSqlDriverExtension
00121 {
00122 public:
00123     QSqlDriverExtension();
00124     virtual ~QSqlDriverExtension();
00125     virtual bool isOpen() const = 0;
00126 };
00127 #endif
00128 #endif

Generated on Sat Nov 5 16:18:23 2005 for OPIE by  doxygen 1.4.2