Eneboo - Documentación para desarrolladores
src/plugins/sqldrivers/sqlite/qsqlite.h
Ir a la documentación de este archivo.
00001 /***************************************************************************
00002                          qsqlite.h  -  description
00003                             -------------------
00004    begin                : lun Nov 24 2003
00005    copyright            : (C) 2003-2004 by InfoSiAL S.L.
00006    email                : mail@infosial.com
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef QSQLITE_H
00019 #define QSQLITE_H
00020 
00021 #include <qsqlresult.h>
00022 #include <qstringlist.h>
00023 #include <qregexp.h>
00024 #include <qdir.h>
00025 #include <stdlib.h>
00026 #include <qmessagebox.h>
00027 #include <FLManager.h>
00028 #include <FLTableMetaData.h>
00029 #include <FLFieldMetaData.h>
00030 #include <FLManagerModules.h>
00031 #include <FLUtil.h>
00032 #include <sqlitedataset.h>
00033 #include <FLSqlDatabase.h>
00034 #include <FLSqlDriver.h>
00035 #include <FLSqlConnections.h>
00036 #include <FLDiskCache.h>
00037 
00038 #if (QT_VERSION-0 >= 0x030000)
00039 typedef QVariant QSqlVariant;
00040 #endif
00041 
00042 using namespace dbiplus;
00043 
00044 class SqliteDriver : public FLSqlDriver
00045 {
00046   Q_OBJECT
00047 
00048 public:
00049 
00050   SqliteDriver(QObject *parent = 0, const char *name = 0);
00051   ~SqliteDriver();
00052   bool open(const QString &db, 
00053             const QString &user = QString::null,
00054             const QString &password = QString::null,
00055             const QString &host = QString::null,
00056             int port = -1);
00057   bool open(const QString &db, const QString &user, 
00058             const QString &password, const QString &host,
00059             int port, const QString &connOpts);
00060   void close();
00061   bool hasFeature(QSqlDriver::DriverFeature f) const;
00062   QSqlQuery createQuery() const;
00063   QStringList tables(const QString &user) const;
00064   QSqlRecord record(const QString &tablename) const;
00065   QSqlRecord record(const QSqlQuery &query) const;
00066   QSqlRecordInfo recordInfo(const QString &tablename) const;
00067   QSqlRecordInfo recordInfo(const QSqlQuery &query) const;
00068   QSqlIndex primaryIndex(const QString &tablename) const;
00069   bool beginTransaction();
00070   bool commitTransaction();
00071   bool rollbackTransaction();
00072   SqliteDatabase *dataBase();
00073 
00074   QString formatDatabaseName(const QString &name);
00075   bool tryConnect(const QString &db,
00076                   const QString &user = QString::null,
00077                   const QString &password = QString::null,
00078                   const QString &host = QString::null,
00079                   int port = -1);
00080   QString sqlCreateTable(FLTableMetaData *tmd);
00081   QString formatValueLike(int t, const QVariant &v, const bool upper = false);
00082   QString formatValue(int t, const QVariant &v, const bool upper = false);
00083   QVariant nextSerialVal(const QString &table, const QString &field);
00084   bool alterTable(const QString &mtd1, const QString &mtd2, const QString &key = QString::null);
00085   void Mr_Proper();
00086 
00087 private:
00088 
00089   QSqlIndex primaryIndex2(const QString &tablename) const;
00090   QSqlRecord record2(const QString &tablename) const;
00091   QSqlRecordInfo recordInfo2(const QString &tablename) const;
00092   SqliteDatabase *dataBase_;
00093 };
00094 
00095 class SqliteResult : public QSqlResult
00096 {
00097 
00098 public:
00099 
00100   SqliteResult(const QSqlDriver *d);
00101   ~SqliteResult();
00102 
00103 protected:
00104 
00105   QVariant data(int);
00106   bool reset(const QString &query);
00107   bool fetch(int);
00108   bool fetchFirst();
00109   bool fetchLast();
00110   bool isNull(int);
00111   int size();
00112   int numRowsAffected();
00113 
00114 private:
00115 
00116   QString query;
00117   const SqliteDriver *driver;
00118   Dataset *dataSet;
00119 };
00120 
00121 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'