HandleBase.hpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:3k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #ifndef ODBC_HANDLES_HandleBase_hpp
  14. #define ODBC_HANDLES_HandleBase_hpp
  15. #include <common/common.hpp>
  16. #include <common/OdbcData.hpp>
  17. #include <common/DiagArea.hpp>
  18. #include <common/AttrArea.hpp>
  19. /**
  20.  * @class HandleBase
  21.  * @brief Base class for handles
  22.  *
  23.  * Following types of handles exist:
  24.  * - HandleRoot : root node
  25.  * - HandleEnv  : environment handle (SQLHENV)
  26.  * - HandleDbc  : connection handle (SQLHDBC)
  27.  * - HandleStmt : statement handle (SQLHSTMT)
  28.  * - HandleDesc : descriptor handle (SQLHDESC)
  29.  */
  30. class HandleRoot;
  31. class HandleBase {
  32. public:
  33.     HandleBase();
  34.     virtual ~HandleBase() = 0;
  35.     virtual HandleBase* getParent() = 0;
  36.     virtual HandleRoot* getRoot() = 0;
  37.     virtual OdbcHandle odbcHandle() = 0;
  38.     void saveCtx(Ctx& ctx);
  39.     // allocate and free handles
  40.     virtual void sqlAllocHandle(Ctx& ctx, SQLSMALLINT childType, HandleBase** ppChild) = 0;
  41.     virtual void sqlFreeHandle(Ctx& ctx, SQLSMALLINT childType, HandleBase* pChild) = 0;
  42.     // get diagnostics
  43.     void sqlGetDiagField(Ctx& ctx, SQLSMALLINT recNumber, SQLSMALLINT diagIdentifier, SQLPOINTER diagInfo, SQLSMALLINT bufferLength, SQLSMALLINT* stringLength);
  44.     void sqlGetDiagRec(Ctx& ctx, SQLSMALLINT recNumber, SQLCHAR* sqlstate, SQLINTEGER* nativeError, SQLCHAR* messageText, SQLSMALLINT bufferLength, SQLSMALLINT* textLength);
  45.     void sqlError(Ctx& ctx, SQLCHAR* sqlstate, SQLINTEGER* nativeError, SQLCHAR* messageText, SQLSMALLINT bufferLength, SQLSMALLINT* textLength); // odbc2.0
  46.     // common code for attributes
  47.     void baseSetHandleAttr(Ctx& ctx, AttrArea& attrArea, SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER stringLength);
  48.     void baseGetHandleAttr(Ctx& ctx, AttrArea& attrArea, SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER bufferLength, SQLINTEGER* stringLength);
  49.     void baseSetHandleOption(Ctx& ctx, AttrArea& attrArea, SQLUSMALLINT option, SQLUINTEGER value); // odbc2.0
  50.     void baseGetHandleOption(Ctx& ctx, AttrArea& attrArea, SQLUSMALLINT option, SQLPOINTER value); // odbc2.0
  51. protected:
  52.     Ctx* m_ctx; // saved from last ODBC function
  53. };
  54. inline
  55. HandleBase::HandleBase() :
  56.     m_ctx(0)
  57. {
  58. }
  59. #endif