Kaydet (Commit) 66dd3427 authored tarafından Noel Grandin's avatar Noel Grandin

convert ODBC3SQL constants to scoped enum

Change-Id: I61d2b76a32be23d238b1f50a6a76975d64d1878c
üst f2bd8b5e
......@@ -90,7 +90,7 @@ void SAL_CALL OConnection::release() throw()
relase_ChildImpl();
}
oslGenericFunction OConnection::getOdbcFunction(sal_Int32 _nIndex) const
oslGenericFunction OConnection::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
{
OSL_ENSURE(m_pDriver,"OConnection::getOdbcFunction: m_pDriver is null!");
return m_pDriver->getOdbcFunction(_nIndex);
......
......@@ -391,7 +391,7 @@ void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_
rDataLen = _nDataLen;
SQLRETURN nRetcode;
nRetcode = (*reinterpret_cast<T3SQLBindParameter>(m_pConnection->getOdbcFunction(ODBC3SQLBindParameter)))(
nRetcode = (*reinterpret_cast<T3SQLBindParameter>(m_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindParameter)))(
m_aStatementHandle,
// checkParameterIndex guarantees this is safe
static_cast<SQLUSMALLINT>(parameterIndex),
......
......@@ -154,7 +154,7 @@ OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) :
// We use SQLFetchScroll unconditionally in several places
// the *only* difference this makes is whether ::next() uses SQLFetchScroll or SQLFetch
// so this test seems pointless
if ( getOdbcFunction(ODBC3SQLGetFunctions) )
if ( getOdbcFunction(ODBC3SQLFunctionId::GetFunctions) )
{
SQLUSMALLINT nSupported = 0;
m_bUseFetchScroll = ( N3SQLGetFunctions(m_aConnectionHandle,SQL_API_SQLFETCHSCROLL,&nSupported) == SQL_SUCCESS && nSupported == 1 );
......@@ -847,7 +847,7 @@ void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException, st
&nRealLen
);
bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLFunctionId::BulkOperations ) );
if ( bPositionByBookmark )
{
nRet = N3SQLBulkOperations( m_aStatementHandle, SQL_ADD );
......@@ -914,7 +914,7 @@ void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException, st
try
{
bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLFunctionId::BulkOperations ) );
if ( bPositionByBookmark )
{
getBookmark();
......
......@@ -83,7 +83,7 @@ SQLLEN OResultSetMetaData::getNumColAttrib(OConnection* _pConnection
,sal_Int32 _ident) throw(SQLException, RuntimeException)
{
SQLLEN nValue=0;
OTools::ThrowException(_pConnection,(*reinterpret_cast<T3SQLColAttribute>(_pConnection->getOdbcFunction(ODBC3SQLColAttribute)))(_aStatementHandle,
OTools::ThrowException(_pConnection,(*reinterpret_cast<T3SQLColAttribute>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::ColAttribute)))(_aStatementHandle,
(SQLUSMALLINT)_column,
(SQLUSMALLINT)_ident,
NULL,
......
......@@ -139,7 +139,7 @@ void OTools::getValue( OConnection* _pConnection,
OSL_ENSURE(static_cast<size_t>(_nSize) >= properSize, "memory region is too small");
SQLLEN pcbValue = SQL_NULL_DATA;
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLGetData)))(_aStatementHandle,
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))(_aStatementHandle,
(SQLUSMALLINT)columnIndex,
_nType,
_pValue,
......@@ -175,7 +175,7 @@ void OTools::bindValue( OConnection* _pConnection,
if (columnIndex != 0 && !_pValue)
{
*pLen = SQL_NULL_DATA;
nRetcode = (*reinterpret_cast<T3SQLBindCol>(_pConnection->getOdbcFunction(ODBC3SQLBindCol)))(_aStatementHandle,
nRetcode = (*reinterpret_cast<T3SQLBindCol>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindCol)))(_aStatementHandle,
(SQLUSMALLINT)columnIndex,
fCType,
_pData,
......@@ -276,7 +276,7 @@ void OTools::bindValue( OConnection* _pConnection,
{
}
nRetcode = (*reinterpret_cast<T3SQLBindCol>(_pConnection->getOdbcFunction(ODBC3SQLBindCol)))(_aStatementHandle,
nRetcode = (*reinterpret_cast<T3SQLBindCol>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::BindCol)))(_aStatementHandle,
(SQLUSMALLINT)columnIndex,
fCType,
_pData,
......@@ -329,7 +329,7 @@ void OTools::ThrowException(const OConnection* _pConnection,
// statements of this connection [what in this case will probably be the same, but the Reference
// Manual isn't totally clear in this...].
// corresponding for hdbc.
SQLRETURN n = (*reinterpret_cast<T3SQLGetDiagRec>(_pConnection->getOdbcFunction(ODBC3SQLGetDiagRec)))(_nHandleType,_pContext,1,
SQLRETURN n = (*reinterpret_cast<T3SQLGetDiagRec>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetDiagRec)))(_nHandleType,_pContext,1,
szSqlState,
&pfNativeError,
szErrorMessage,sizeof szErrorMessage - 1,&pcbErrorMsg);
......@@ -367,7 +367,7 @@ Sequence<sal_Int8> OTools::getBytesValue(const OConnection* _pConnection,
while (pcbValue == SQL_NO_TOTAL || pcbValue > nMaxLen)
{
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLGetData)))(
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))(
_aStatementHandle,
(SQLUSMALLINT)columnIndex,
_fSqlType,
......@@ -427,7 +427,7 @@ OUString OTools::getStringValue(OConnection* _pConnection,
while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxSize) )
{
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLGetData)))(
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))(
_aStatementHandle,
(SQLUSMALLINT)columnIndex,
SQL_C_WCHAR,
......@@ -471,7 +471,7 @@ OUString OTools::getStringValue(OConnection* _pConnection,
while ((pcbValue == SQL_NO_TOTAL ) || (pcbValue >= nMaxLen) )
{
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLGetData)))(
(*reinterpret_cast<T3SQLGetData>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetData)))(
_aStatementHandle,
(SQLUSMALLINT)columnIndex,
SQL_C_CHAR,
......@@ -519,7 +519,7 @@ void OTools::GetInfo(OConnection* _pConnection,
char aValue[512];
SQLSMALLINT nValueLen=0;
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLGetInfo)))(_aConnectionHandle,_nInfo,aValue,(sizeof aValue)-1,&nValueLen),
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,aValue,(sizeof aValue)-1,&nValueLen),
_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
_rValue = OUString(aValue,nValueLen,_nTextEncoding);
......@@ -534,7 +534,7 @@ void OTools::GetInfo(OConnection* _pConnection,
SQLSMALLINT nValueLen;
_rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLGetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
}
......@@ -547,7 +547,7 @@ void OTools::GetInfo(OConnection* _pConnection,
SQLSMALLINT nValueLen;
_rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLGetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
}
......@@ -560,7 +560,7 @@ void OTools::GetInfo(OConnection* _pConnection,
SQLSMALLINT nValueLen;
_rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLGetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
}
......@@ -572,7 +572,7 @@ void OTools::GetInfo(OConnection* _pConnection,
{
SQLSMALLINT nValueLen;
OTools::ThrowException(_pConnection,
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLGetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
(*reinterpret_cast<T3SQLGetInfo>(_pConnection->getOdbcFunction(ODBC3SQLFunctionId::GetInfo)))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
_aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
}
......
......@@ -27,6 +27,7 @@
#include <connectivity/CommonTools.hxx>
#include "TConnection.hxx"
#include "OTypeInfo.hxx"
#include "OTools.hxx"
#include <cppuhelper/weakref.hxx>
#include "AutoRetrievingBase.hxx"
#include <osl/module.h>
......@@ -83,7 +84,7 @@ namespace connectivity
OConnection* cloneConnection(); // creates a new connection
public:
oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const;
oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const;
SQLRETURN Construct( const OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver);
......
......@@ -61,7 +61,7 @@ namespace connectivity
public:
inline OConnection* getOwnConnection() const { return m_pConnection; }
inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
inline oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
{
return m_pConnection->getOdbcFunction(_nIndex);
}
......
......@@ -122,7 +122,7 @@ namespace connectivity
ODatabaseMetaDataResultSet(OConnection* _pConnection);
inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
inline oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
{
return m_pConnection->getOdbcFunction(_nIndex);
}
......
......@@ -28,6 +28,7 @@
#include "odbc/odbcbasedllapi.hxx"
#include <connectivity/CommonTools.hxx>
#include <osl/module.h>
#include "OTools.hxx"
namespace connectivity
{
......@@ -54,7 +55,7 @@ namespace connectivity
ODBCDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
// only possibility to get the odbc functions
virtual oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const = 0;
virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const = 0;
// OComponentHelper
virtual void SAL_CALL disposing() SAL_OVERRIDE;
// XInterface
......
......@@ -221,7 +221,7 @@ namespace connectivity
void construct();
inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
inline oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
{
return m_pStatement->getOdbcFunction(_nIndex);
}
......
......@@ -80,7 +80,7 @@ namespace connectivity
,sal_Int32 column)
throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
inline oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
{
return m_pConnection->getOdbcFunction(_nIndex);
}
......
......@@ -152,7 +152,7 @@ namespace connectivity
OStatement_Base(OConnection* _pConnection );
using OStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
inline oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const
inline oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
{
return m_pConnection->getOdbcFunction(_nIndex);
}
......
......@@ -30,60 +30,63 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/textenc.h>
#define ODBC3SQLAllocHandle 1
#define ODBC3SQLConnect 2
#define ODBC3SQLDriverConnect 3
#define ODBC3SQLBrowseConnect 4
#define ODBC3SQLDataSources 5
#define ODBC3SQLDrivers 6
#define ODBC3SQLGetInfo 7
#define ODBC3SQLGetFunctions 8
#define ODBC3SQLGetTypeInfo 9
#define ODBC3SQLSetConnectAttr 10
#define ODBC3SQLGetConnectAttr 11
#define ODBC3SQLSetEnvAttr 12
#define ODBC3SQLGetEnvAttr 13
#define ODBC3SQLSetStmtAttr 14
#define ODBC3SQLGetStmtAttr 15
#define ODBC3SQLPrepare 16
#define ODBC3SQLBindParameter 17
#define ODBC3SQLSetCursorName 18
#define ODBC3SQLExecute 19
#define ODBC3SQLExecDirect 20
#define ODBC3SQLDescribeParam 21
#define ODBC3SQLNumParams 22
#define ODBC3SQLParamData 23
#define ODBC3SQLPutData 24
#define ODBC3SQLRowCount 25
#define ODBC3SQLNumResultCols 26
#define ODBC3SQLDescribeCol 27
#define ODBC3SQLColAttribute 28
#define ODBC3SQLBindCol 29
#define ODBC3SQLFetch 30
#define ODBC3SQLFetchScroll 31
#define ODBC3SQLGetData 32
#define ODBC3SQLSetPos 33
#define ODBC3SQLBulkOperations 34
#define ODBC3SQLMoreResults 35
#define ODBC3SQLGetDiagRec 36
#define ODBC3SQLColumnPrivileges 37
#define ODBC3SQLColumns 38
#define ODBC3SQLForeignKeys 39
#define ODBC3SQLPrimaryKeys 40
#define ODBC3SQLProcedureColumns 41
#define ODBC3SQLProcedures 42
#define ODBC3SQLSpecialColumns 43
#define ODBC3SQLStatistics 44
#define ODBC3SQLTablePrivileges 45
#define ODBC3SQLTables 46
#define ODBC3SQLFreeStmt 47
#define ODBC3SQLCloseCursor 48
#define ODBC3SQLCancel 49
#define ODBC3SQLEndTran 50
#define ODBC3SQLDisconnect 51
#define ODBC3SQLFreeHandle 52
#define ODBC3SQLGetCursorName 53
#define ODBC3SQLNativeSql 54
enum class ODBC3SQLFunctionId
{
AllocHandle = 1,
Connect = 2,
DriverConnect = 3,
BrowseConnect = 4,
DataSources = 5,
Drivers = 6,
GetInfo = 7,
GetFunctions = 8,
GetTypeInfo = 9,
SetConnectAttr = 10,
GetConnectAttr = 11,
SetEnvAttr = 12,
GetEnvAttr = 13,
SetStmtAttr = 14,
GetStmtAttr = 15,
Prepare = 16,
BindParameter = 17,
SetCursorName = 18,
Execute = 19,
ExecDirect = 20,
DescribeParam = 21,
NumParams = 22,
ParamData = 23,
PutData = 24,
RowCount = 25,
NumResultCols = 26,
DescribeCol = 27,
ColAttribute = 28,
BindCol = 29,
Fetch = 30,
FetchScroll = 31,
GetData = 32,
SetPos = 33,
BulkOperations = 34,
MoreResults = 35,
GetDiagRec = 36,
ColumnPrivileges = 37,
Columns = 38,
ForeignKeys = 39,
PrimaryKeys = 40,
ProcedureColumns = 41,
Procedures = 42,
SpecialColumns = 43,
Statistics = 44,
TablePrivileges = 45,
Tables = 46,
FreeStmt = 47,
CloseCursor = 48,
Cancel = 49,
EndTran = 50,
Disconnect = 51,
FreeHandle = 52,
GetCursorName = 53,
NativeSql = 54,
};
namespace connectivity
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment