Eneboo - Documentación para desarrolladores
|
00001 /**************************************************************************** 00002 ** 00003 ** Definition of SQLite driver classes. 00004 ** 00005 ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. 00006 ** 00007 ** This file is part of the sql module of the Qt GUI Toolkit. 00008 ** EDITIONS: FREE, ENTERPRISE 00009 ** 00010 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00011 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00012 ** 00013 ****************************************************************************/ 00014 00015 #ifndef QSQL_SQLITE_H 00016 #define QSQL_SQLITE_H 00017 00018 #include <qsqldriver.h> 00019 #include <qsqlresult.h> 00020 #include <qsqlrecord.h> 00021 #include <qsqlindex.h> 00022 #include "../cache/qsqlcachedresult.h" 00023 00024 #if (QT_VERSION-0 >= 0x030000) 00025 typedef QVariant QSqlVariant; 00026 #endif 00027 00028 #if defined (Q_OS_WIN32) 00029 # include <qt_windows.h> 00030 #endif 00031 00032 class QSQLiteDriverPrivate; 00033 class QSQLiteResultPrivate; 00034 class QSQLiteDriver; 00035 struct sqlite; 00036 00037 class QSQLiteResult : public QtSqlCachedResult 00038 { 00039 friend class QSQLiteDriver; 00040 friend class QSQLiteResultPrivate; 00041 public: 00042 QSQLiteResult(const QSQLiteDriver* db); 00043 ~QSQLiteResult(); 00044 00045 protected: 00046 bool gotoNext(QtSqlCachedResult::RowCache* row); 00047 bool reset (const QString& query); 00048 int size(); 00049 int numRowsAffected(); 00050 00051 private: 00052 QSQLiteResultPrivate* d; 00053 }; 00054 00055 class QSQLiteDriver : public QSqlDriver 00056 { 00057 friend class QSQLiteResult; 00058 public: 00059 QSQLiteDriver(QObject *parent = 0, const char *name = 0); 00060 QSQLiteDriver(sqlite *connection, QObject *parent = 0, const char *name = 0); 00061 ~QSQLiteDriver(); 00062 bool hasFeature(DriverFeature f) const; 00063 bool open(const QString & db, 00064 const QString & user, 00065 const QString & password, 00066 const QString & host, 00067 int port, 00068 const QString & connOpts); 00069 bool open( const QString & db, 00070 const QString & user, 00071 const QString & password, 00072 const QString & host, 00073 int port ) { return open (db, user, password, host, port, QString()); } 00074 void close(); 00075 QSqlQuery createQuery() const; 00076 bool beginTransaction(); 00077 bool commitTransaction(); 00078 bool rollbackTransaction(); 00079 QStringList tables(const QString& user) const; 00080 00081 QSqlRecord record(const QString& tablename) const; 00082 QSqlRecordInfo recordInfo(const QString& tablename) const; 00083 QSqlIndex primaryIndex(const QString &table) const; 00084 QSqlRecord record(const QSqlQuery& query) const; 00085 QSqlRecordInfo recordInfo(const QSqlQuery& query) const; 00086 00087 private: 00088 QSQLiteDriverPrivate* d; 00089 }; 00090 #endif