Eneboo - Documentación para desarrolladores
src/flbase/FLSqlDatabase.h
Ir a la documentación de este archivo.
00001 /***************************************************************************
00002                              FLSqlDatabase.h
00003                           -------------------
00004  begin                : Thu Nov 22 2005
00005  copyright            : (C) 2002-2005 by InfoSiAL S.L.
00006  email                : mail@infosial.com
00007 ***************************************************************************/
00008 /***************************************************************************
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; version 2 of the License.               *
00012  ***************************************************************************/
00013 /***************************************************************************
00014    Este  programa es software libre. Puede redistribuirlo y/o modificarlo
00015    bajo  los  términos  de  la  Licencia  Pública General de GNU   en  su
00016    versión 2, publicada  por  la  Free  Software Foundation.
00017  ***************************************************************************/
00018 
00019 #ifndef FLSQLDATABASE_H
00020 #define FLSQLDATABASE_H
00021 
00022 #include <qsqldatabase.h>
00023 #include <qsqlresult.h>
00024 
00025 class FLTableMetaData;
00026 class FLSqlCursor;
00027 class FLManager;
00028 class FLManagerModules;
00029 
00045 class FL_EXPORT FLSqlDatabase
00046 {
00047 
00048 public:
00049 
00053   enum ConnOptions {
00055     USER = 0,
00057     PASSWORD = 1,
00059     PORT = 2,
00061     HOST = 3
00062   };
00063 
00067   FLSqlDatabase();
00068 
00072   ~FLSqlDatabase();
00073 
00077   static QStringList driverAliases();
00078 
00082   static QString defaultAlias();
00083 
00088   static QString driverAliasToDriverName(const QString &alias);
00089 
00094   static QString driverNameToDriverAlias(const QString &name);
00095 
00103   static bool needConnOption(const QString &alias, const int connOption);
00104 
00111   static QString defaultPort(const QString &alias);
00112 
00120   bool loadDriver(const QString &driverName, const QString &connName = "default");
00121 
00139   bool connectDB(const QString &database, const QString &user = QString::null,
00140                  const QString &password = QString::null,
00141                  const QString &host = QString::null,
00142                  int port = -1, const QString &connName = "default");
00143 
00147   bool connectDB();
00148 
00152   void closeDB();
00153 
00160   bool createTable(FLTableMetaData *tmd);
00161 
00165   bool canRegenTables();
00166 
00181   QString formatValueLike(int t, const QVariant &v, const bool upper = false);
00182 
00197   QString formatValue(int t, const QVariant &v, const bool upper = false);
00198 
00206   QVariant nextSerialVal(const QString &table, const QString &field);
00207 
00220   int atFrom(FLSqlCursor *cur);
00221 
00225   QSqlDatabase *db() const {
00226     return db_;
00227   }
00228 
00232   QSqlDatabase *dbAux() const {
00233     return dbAux_;
00234   }
00235 
00239   QString database() const {
00240     return database_;
00241   }
00242 
00246   QString user() const {
00247     return user_;
00248   }
00249 
00253   QString password() const {
00254     return password_;
00255   }
00256 
00260   QString host() const {
00261     return host_;
00262   }
00263 
00267   int port() const {
00268     return port_;
00269   }
00270 
00274   QString driverName() const {
00275     return driverName_;
00276   }
00277 
00288   bool alterTable(const QString &mtd1, const QString &mtd2, const QString &key = QString::null);
00289 
00293   FLManager *manager();
00294 
00298   FLManagerModules *managerModules();
00299 
00303   QString connectionName() const {
00304     return connectionName_;
00305   }
00306 
00310   bool canSavePoint();
00311 
00318   bool savePoint(const QString &n);
00319 
00326   bool releaseSavePoint(const QString &n);
00327 
00334   bool rollbackSavePoint(const QString &n);
00335 
00339   bool canTransaction() const;
00340 
00344   void Mr_Proper();
00345 
00349   bool canDetectLocks() const;
00350 
00369   QStringList locksStatus();
00370 
00378   QStringList detectLocks();
00379 
00391   QStringList detectRisksLocks(const QString &table = QString::null, const QString &primaryKeyValue = QString::null);
00392 
00401   bool regenTable(const QString &n, FLTableMetaData *tmd);
00402 
00403   // Some Wrappers to QSqlDatabase
00404   bool isOpen() const;
00405   bool isOpenError() const;
00406   QStringList tables() const;
00407   QStringList tables(QSql::TableType type) const;
00408   QSqlError lastError() const;
00409   QString connectOptions() const;
00410 
00411 private:
00412 
00414   QSqlDatabase *db_;
00415 
00417   QSqlDatabase *dbAux_;
00418 
00420   QString database_;
00421 
00423   QString user_;
00424 
00426   QString password_;
00427 
00429   QString host_;
00430 
00432   int port_;
00433 
00435   QString driverName_;
00436 
00438   FLManager *manager_;
00439 
00441   FLManagerModules *managerModules_;
00442 
00444   QString connectionName_;
00445 
00447   bool lockDetection_;
00448 };
00449 
00450 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'