LCOV - code coverage report
Current view: top level - connectivity/source/inc/odbc - OTools.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 22 0.0 %
Date: 2014-11-03 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OTOOLS_HXX
      20             : #define INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OTOOLS_HXX
      21             : 
      22             : #include <connectivity/odbc.hxx>
      23             : #include "odbc/odbcbasedllapi.hxx"
      24             : #include <com/sun/star/sdbc/SQLException.hpp>
      25             : #include <com/sun/star/util/Date.hpp>
      26             : #include <com/sun/star/util/Time.hpp>
      27             : #include <com/sun/star/util/DateTime.hpp>
      28             : #include <osl/thread.h>
      29             : #include <rtl/ustring.hxx>
      30             : #include <com/sun/star/uno/Sequence.hxx>
      31             : #include <rtl/textenc.h>
      32             : 
      33             : #define ODBC3SQLAllocHandle         1
      34             : #define ODBC3SQLConnect             2
      35             : #define ODBC3SQLDriverConnect       3
      36             : #define ODBC3SQLBrowseConnect       4
      37             : #define ODBC3SQLDataSources         5
      38             : #define ODBC3SQLDrivers             6
      39             : #define ODBC3SQLGetInfo             7
      40             : #define ODBC3SQLGetFunctions        8
      41             : #define ODBC3SQLGetTypeInfo         9
      42             : #define ODBC3SQLSetConnectAttr      10
      43             : #define ODBC3SQLGetConnectAttr      11
      44             : #define ODBC3SQLSetEnvAttr          12
      45             : #define ODBC3SQLGetEnvAttr          13
      46             : #define ODBC3SQLSetStmtAttr         14
      47             : #define ODBC3SQLGetStmtAttr         15
      48             : #define ODBC3SQLPrepare             16
      49             : #define ODBC3SQLBindParameter       17
      50             : #define ODBC3SQLSetCursorName       18
      51             : #define ODBC3SQLExecute             19
      52             : #define ODBC3SQLExecDirect          20
      53             : #define ODBC3SQLDescribeParam       21
      54             : #define ODBC3SQLNumParams           22
      55             : #define ODBC3SQLParamData           23
      56             : #define ODBC3SQLPutData             24
      57             : #define ODBC3SQLRowCount            25
      58             : #define ODBC3SQLNumResultCols       26
      59             : #define ODBC3SQLDescribeCol         27
      60             : #define ODBC3SQLColAttribute        28
      61             : #define ODBC3SQLBindCol             29
      62             : #define ODBC3SQLFetch               30
      63             : #define ODBC3SQLFetchScroll         31
      64             : #define ODBC3SQLGetData             32
      65             : #define ODBC3SQLSetPos              33
      66             : #define ODBC3SQLBulkOperations      34
      67             : #define ODBC3SQLMoreResults         35
      68             : #define ODBC3SQLGetDiagRec          36
      69             : #define ODBC3SQLColumnPrivileges    37
      70             : #define ODBC3SQLColumns             38
      71             : #define ODBC3SQLForeignKeys         39
      72             : #define ODBC3SQLPrimaryKeys         40
      73             : #define ODBC3SQLProcedureColumns    41
      74             : #define ODBC3SQLProcedures          42
      75             : #define ODBC3SQLSpecialColumns      43
      76             : #define ODBC3SQLStatistics          44
      77             : #define ODBC3SQLTablePrivileges     45
      78             : #define ODBC3SQLTables              46
      79             : #define ODBC3SQLFreeStmt            47
      80             : #define ODBC3SQLCloseCursor         48
      81             : #define ODBC3SQLCancel              49
      82             : #define ODBC3SQLEndTran             50
      83             : #define ODBC3SQLDisconnect          51
      84             : #define ODBC3SQLFreeHandle          52
      85             : #define ODBC3SQLGetCursorName       53
      86             : #define ODBC3SQLNativeSql           54
      87             : 
      88             : namespace connectivity
      89             : {
      90             :     namespace odbc
      91             :     {
      92             :         class OConnection;
      93             : 
      94             :         const sal_Int32 MAX_PUT_DATA_LENGTH = 2000;
      95             : 
      96             :         class OOO_DLLPUBLIC_ODBCBASE OTools
      97             :         {
      98             :         public:
      99             :             static void ThrowException( const OConnection* _pConnection,
     100             :                                         SQLRETURN _rRetCode,
     101             :                                         SQLHANDLE _pContext,
     102             :                                         SQLSMALLINT _nHandleType,
     103             :                                         const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
     104             :                                         bool _bNoFound=true,
     105             :                                         rtl_TextEncoding _nTextEncoding = RTL_TEXTENCODING_MS_1252)
     106             :                                         throw(::com::sun::star::sdbc::SQLException);
     107             : 
     108             :             static void GetInfo(OConnection* _pConnection,
     109             :                                 SQLHANDLE _aConnectionHandle,
     110             :                                 SQLUSMALLINT _nInfo,
     111             :                                 OUString &_rValue,
     112             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
     113             :                                 rtl_TextEncoding _nTextEncoding)
     114             :                                 throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     115             : 
     116             :             static void GetInfo(OConnection* _pConnection,
     117             :                                 SQLHANDLE _aConnectionHandle,
     118             :                                 SQLUSMALLINT _nInfo,
     119             :                                 sal_Int32 &_rValue,
     120             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     121             : 
     122             :             static void GetInfo(OConnection* _pConnection,
     123             :                                 SQLHANDLE _aConnectionHandle,
     124             :                                 SQLUSMALLINT _nInfo,
     125             :                                 SQLUSMALLINT &_rValue,
     126             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     127             : 
     128             :             static void GetInfo(OConnection* _pConnection,
     129             :                                 SQLHANDLE _aConnectionHandle,
     130             :                                 SQLUSMALLINT _nInfo,
     131             :                                 SQLUINTEGER &_rValue,
     132             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     133             : 
     134             :             static void GetInfo(OConnection* _pConnection,
     135             :                                 SQLHANDLE _aConnectionHandle,
     136             :                                 SQLUSMALLINT _nInfo,
     137             :                                 bool &_rValue,
     138             :                                 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     139             : 
     140             :             static sal_Int32 MapOdbcType2Jdbc(SQLSMALLINT _nType);
     141             :             static SQLSMALLINT jdbcTypeToOdbc(sal_Int32 jdbcType);
     142             : 
     143           0 :             static DATE_STRUCT DateToOdbcDate(const ::com::sun::star::util::Date& x)
     144             :             {
     145             :                 DATE_STRUCT aVal;
     146           0 :                 aVal.year   = x.Year;
     147           0 :                 aVal.month  = x.Month;
     148           0 :                 aVal.day    = x.Day;
     149           0 :                 return aVal;
     150             :             }
     151           0 :             static TIME_STRUCT TimeToOdbcTime(const ::com::sun::star::util::Time& x)
     152             :             {
     153             :                 TIME_STRUCT aVal;
     154           0 :                 aVal.hour   = x.Hours;
     155           0 :                 aVal.minute = x.Minutes;
     156           0 :                 aVal.second = x.Seconds;
     157           0 :                 return aVal;
     158             :             }
     159           0 :             static TIMESTAMP_STRUCT DateTimeToTimestamp(const ::com::sun::star::util::DateTime& x)
     160             :             {
     161             :                 TIMESTAMP_STRUCT aVal;
     162           0 :                 aVal.year       = x.Year;
     163           0 :                 aVal.month      = x.Month;
     164           0 :                 aVal.day        = x.Day;
     165           0 :                 aVal.hour       = x.Hours;
     166           0 :                 aVal.minute     = x.Minutes;
     167           0 :                 aVal.second     = x.Seconds;
     168           0 :                 aVal.fraction   = x.NanoSeconds;
     169           0 :                 return aVal;
     170             :             }
     171             :             /**
     172             :                 getBindTypes set the ODBC type for C
     173             :                 @param  _bUseWChar          true when Unicode should be used
     174             :                 @param  _bUseOldTimeDate    true when the old datetime format should be used
     175             :                 @param  _nOdbcType          the ODBC sql type
     176             :                 @param  fCType              the C type for the ODBC type
     177             :                 @param  fSqlType            the SQL type for the ODBC type
     178             :             */
     179             :             static void getBindTypes(bool _bUseWChar,
     180             :                                      bool _bUseOldTimeDate,
     181             :                                      SQLSMALLINT _nOdbcType,
     182             :                                      SQLSMALLINT& fCType,
     183             :                                      SQLSMALLINT& fSqlType);
     184             : 
     185             :             static OUString getStringValue(  OConnection* _pConnection,
     186             :                                                     SQLHANDLE _aStatementHandle,
     187             :                                                     sal_Int32 columnIndex,
     188             :                                                     SQLSMALLINT _fSqlType,
     189             :                                                     bool &_bWasNull,
     190             :                                                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
     191             :                                                     rtl_TextEncoding _nTextEncoding) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     192             : 
     193             :             static  ::com::sun::star::uno::Sequence<sal_Int8> getBytesValue(const OConnection* _pConnection,
     194             :                                                                             SQLHANDLE _aStatementHandle,
     195             :                                                                             sal_Int32 columnIndex,
     196             :                                                                             SQLSMALLINT _fSqlType,
     197             :                                                                             bool &_bWasNull,
     198             :                                                                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     199             :             static void getValue(   OConnection* _pConnection,
     200             :                                     SQLHANDLE _aStatementHandle,
     201             :                                     sal_Int32 columnIndex,
     202             :                                     SQLSMALLINT _nType,
     203             :                                     bool &_bWasNull,
     204             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
     205             :                                     void* _pValue,
     206             :                                     SQLLEN _nSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     207             : 
     208             :             static void bindValue(  OConnection* _pConnection,
     209             :                                     SQLHANDLE _aStatementHandle,
     210             :                                     sal_Int32 columnIndex,
     211             :                                     SQLSMALLINT _nType,
     212             :                                     SQLSMALLINT _nMaxLen,
     213             :                                     const void* _pValue,
     214             :                                     void*       _pData,
     215             :                                     SQLLEN *pLen,
     216             :                                     const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
     217             :                                     rtl_TextEncoding _nTextEncoding,
     218             :                                     bool _bUseOldTimeDate) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
     219             :         };
     220             : 
     221           0 :         template <class T> void getValue(   OConnection* _pConnection,
     222             :                                             SQLHANDLE _aStatementHandle,
     223             :                                             sal_Int32 columnIndex,
     224             :                                             SQLSMALLINT _nType,
     225             :                                             bool &_bWasNull,
     226             :                                             const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
     227             :                                             T& _rValue) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
     228             :         {
     229           0 :             OTools::getValue(_pConnection,_aStatementHandle,columnIndex,_nType,_bWasNull,_xInterface,&_rValue,sizeof _rValue);
     230           0 :         }
     231             : 
     232             : 
     233             : 
     234             :     }
     235             : }
     236             : #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_OTOOLS_HXX
     237             : 
     238             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10