Eneboo - Documentación para desarrolladores
src/qt/src/sql/qsqlextension_p.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 **
00003 ** Definition of the QSqlExtension class
00004 **
00005 ** Created : 2002-06-03
00006 **
00007 ** Copyright (C) 2005-2007 Trolltech ASA.  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 ASA 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 #define Q_DEFINED_QSQLEXTENSION
00086 #include "qwinexport.h"
00087 
00088 class QM_EXPORT_SQL QSqlExtension {
00089 public:
00090     QSqlExtension();
00091     virtual ~QSqlExtension();
00092     virtual bool prepare( const QString& query );
00093     virtual bool exec();
00094     virtual void bindValue( const QString& holder, const QVariant& value, QSql::ParameterType = QSql::In );
00095     virtual void bindValue( int pos, const QVariant& value, QSql::ParameterType = QSql::In );
00096     virtual void addBindValue( const QVariant& value, QSql::ParameterType = QSql::In );
00097     virtual QVariant parameterValue( const QString& holder );
00098     virtual QVariant parameterValue( int pos );
00099     QVariant boundValue( const QString& holder ) const;
00100     QVariant boundValue( int pos ) const;
00101     QMap<QString, QVariant> boundValues() const;
00102     void clear();
00103     void clearValues();
00104     void clearIndex();
00105     void resetBindCount();
00106 
00107     enum BindMethod { BindByPosition, BindByName };
00108     BindMethod bindMethod(); // ### 4.0: make this const
00109     BindMethod bindm;
00110     int bindCount;
00111 
00112     QMap<int, QString> index;
00113     typedef QMap<QString, Param> ValueMap;
00114     ValueMap values;
00115 
00116     // convenience container for QSqlQuery
00117     // to map holders <-> positions
00118     typedef QValueVector<Holder> HolderVector;
00119     HolderVector holders;
00120 };
00121 
00122 class QM_EXPORT_SQL QSqlDriverExtension
00123 {
00124 public:
00125     QSqlDriverExtension();
00126     virtual ~QSqlDriverExtension();
00127     virtual bool isOpen() const = 0;
00128 };
00129 
00130 class QM_EXPORT_SQL QSqlOpenExtension
00131 {
00132 public:
00133     QSqlOpenExtension();
00134     virtual ~QSqlOpenExtension();
00135     virtual bool open( const QString& db,
00136                        const QString& user,
00137                        const QString& password,
00138                        const QString& host,
00139                        int port,
00140                        const QString& connOpts ) = 0;
00141 };
00142 #endif
00143 
00144 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'