/src/sql/drivers/odbc/qsql_odbc.h

https://bitbucket.org/ultra_iter/qt-vtl · C Header · 158 lines · 94 code · 23 blank · 41 comment · 0 complexity · fca00d6793c352f34bba7d681f16bc30 MD5 · raw file

  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
  4. ** All rights reserved.
  5. ** Contact: Nokia Corporation (qt-info@nokia.com)
  6. **
  7. ** This file is part of the QtSql module of the Qt Toolkit.
  8. **
  9. ** $QT_BEGIN_LICENSE:LGPL$
  10. ** GNU Lesser General Public License Usage
  11. ** This file may be used under the terms of the GNU Lesser General Public
  12. ** License version 2.1 as published by the Free Software Foundation and
  13. ** appearing in the file LICENSE.LGPL included in the packaging of this
  14. ** file. Please review the following information to ensure the GNU Lesser
  15. ** General Public License version 2.1 requirements will be met:
  16. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  17. **
  18. ** In addition, as a special exception, Nokia gives you certain additional
  19. ** rights. These rights are described in the Nokia Qt LGPL Exception
  20. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  21. **
  22. ** GNU General Public License Usage
  23. ** Alternatively, this file may be used under the terms of the GNU General
  24. ** Public License version 3.0 as published by the Free Software Foundation
  25. ** and appearing in the file LICENSE.GPL included in the packaging of this
  26. ** file. Please review the following information to ensure the GNU General
  27. ** Public License version 3.0 requirements will be met:
  28. ** http://www.gnu.org/copyleft/gpl.html.
  29. **
  30. ** Other Usage
  31. ** Alternatively, this file may be used in accordance with the terms and
  32. ** conditions contained in a signed written agreement between you and Nokia.
  33. **
  34. **
  35. **
  36. **
  37. **
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #ifndef QSQL_ODBC_H
  42. #define QSQL_ODBC_H
  43. #include <QtSql/qsqldriver.h>
  44. #include <QtSql/qsqlresult.h>
  45. #if defined (Q_OS_WIN32)
  46. #include <QtCore/qt_windows.h>
  47. #endif
  48. #ifdef QT_PLUGIN
  49. #define Q_EXPORT_SQLDRIVER_ODBC
  50. #else
  51. #define Q_EXPORT_SQLDRIVER_ODBC Q_SQL_EXPORT
  52. #endif
  53. #ifdef Q_OS_UNIX
  54. #define HAVE_LONG_LONG 1 // force UnixODBC NOT to fall back to a struct for BIGINTs
  55. #endif
  56. #if defined(Q_CC_BOR)
  57. // workaround for Borland to make sure that SQLBIGINT is defined
  58. # define _MSC_VER 900
  59. #endif
  60. #include <sql.h>
  61. #if defined(Q_CC_BOR)
  62. # undef _MSC_VER
  63. #endif
  64. #include <sqlext.h>
  65. QT_BEGIN_HEADER
  66. QT_BEGIN_NAMESPACE
  67. class QODBCPrivate;
  68. class QODBCDriverPrivate;
  69. class QODBCDriver;
  70. class QSqlRecordInfo;
  71. class QODBCResult : public QSqlResult
  72. {
  73. public:
  74. QODBCResult(const QODBCDriver * db, QODBCDriverPrivate* p);
  75. virtual ~QODBCResult();
  76. bool prepare(const QString& query);
  77. bool exec();
  78. QVariant handle() const;
  79. virtual void setForwardOnly(bool forward);
  80. protected:
  81. bool fetchNext();
  82. bool fetchFirst();
  83. bool fetchLast();
  84. bool fetchPrevious();
  85. bool fetch(int i);
  86. bool reset (const QString& query);
  87. QVariant data(int field);
  88. bool isNull(int field);
  89. int size();
  90. int numRowsAffected();
  91. QSqlRecord record() const;
  92. void virtual_hook(int id, void *data);
  93. bool nextResult();
  94. private:
  95. QODBCPrivate *d;
  96. };
  97. class Q_EXPORT_SQLDRIVER_ODBC QODBCDriver : public QSqlDriver
  98. {
  99. Q_OBJECT
  100. public:
  101. explicit QODBCDriver(QObject *parent=0);
  102. QODBCDriver(SQLHANDLE env, SQLHANDLE con, QObject * parent=0);
  103. virtual ~QODBCDriver();
  104. bool hasFeature(DriverFeature f) const;
  105. void close();
  106. QSqlResult *createResult() const;
  107. QStringList tables(QSql::TableType) const;
  108. QSqlRecord record(const QString& tablename) const;
  109. QSqlIndex primaryIndex(const QString& tablename) const;
  110. QVariant handle() const;
  111. QString formatValue(const QSqlField &field,
  112. bool trimStrings) const;
  113. bool open(const QString& db,
  114. const QString& user,
  115. const QString& password,
  116. const QString& host,
  117. int port,
  118. const QString& connOpts);
  119. QString escapeIdentifier(const QString &identifier, IdentifierType type) const;
  120. protected Q_SLOTS:
  121. bool isIdentifierEscapedImplementation(const QString &identifier, IdentifierType type) const;
  122. protected:
  123. bool beginTransaction();
  124. bool commitTransaction();
  125. bool rollbackTransaction();
  126. private:
  127. void init();
  128. bool endTrans();
  129. void cleanup();
  130. QODBCDriverPrivate* d;
  131. friend class QODBCPrivate;
  132. };
  133. QT_END_NAMESPACE
  134. QT_END_HEADER
  135. #endif // QSQL_ODBC_H