bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / odbc / ORealDriver.cxx
blob8b76f4cf1cc67625638523dd7230ca429f743816
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "ORealDriver.hxx"
21 #include <odbc/ODriver.hxx>
22 #include <odbc/OTools.hxx>
23 #include <odbc/OFunctions.hxx>
25 namespace connectivity
27 namespace odbc
29 class ORealObdcDriver : public ODBCDriver
31 protected:
32 virtual oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const override;
33 virtual SQLHANDLE EnvironmentHandle(OUString &_rPath) override;
34 public:
35 explicit ORealObdcDriver(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {}
39 oslGenericFunction ORealObdcDriver::getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
41 oslGenericFunction pFunction = nullptr;
42 switch(_nIndex)
44 case ODBC3SQLFunctionId::AllocHandle:
45 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLAllocHandle);
46 break;
47 case ODBC3SQLFunctionId::Connect:
48 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLConnect);
49 break;
50 case ODBC3SQLFunctionId::DriverConnect:
51 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDriverConnect);
52 break;
53 case ODBC3SQLFunctionId::BrowseConnect:
54 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBrowseConnect);
55 break;
56 case ODBC3SQLFunctionId::DataSources:
57 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDataSources);
58 break;
59 case ODBC3SQLFunctionId::Drivers:
60 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDrivers);
61 break;
62 case ODBC3SQLFunctionId::GetInfo:
64 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetInfo);
65 break;
66 case ODBC3SQLFunctionId::GetFunctions:
68 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetFunctions);
69 break;
70 case ODBC3SQLFunctionId::GetTypeInfo:
72 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetTypeInfo);
73 break;
74 case ODBC3SQLFunctionId::SetConnectAttr:
76 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetConnectAttr);
77 break;
78 case ODBC3SQLFunctionId::GetConnectAttr:
80 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetConnectAttr);
81 break;
82 case ODBC3SQLFunctionId::SetEnvAttr:
84 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetEnvAttr);
85 break;
86 case ODBC3SQLFunctionId::GetEnvAttr:
88 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetEnvAttr);
89 break;
90 case ODBC3SQLFunctionId::SetStmtAttr:
92 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetStmtAttr);
93 break;
94 case ODBC3SQLFunctionId::GetStmtAttr:
96 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetStmtAttr);
97 break;
98 case ODBC3SQLFunctionId::Prepare:
100 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPrepare);
101 break;
102 case ODBC3SQLFunctionId::BindParameter:
104 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBindParameter);
105 break;
106 case ODBC3SQLFunctionId::SetCursorName:
108 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetCursorName);
109 break;
110 case ODBC3SQLFunctionId::Execute:
112 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLExecute);
113 break;
114 case ODBC3SQLFunctionId::ExecDirect:
116 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLExecDirect);
117 break;
118 case ODBC3SQLFunctionId::DescribeParam:
120 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDescribeParam);
121 break;
122 case ODBC3SQLFunctionId::NumParams:
124 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNumParams);
125 break;
126 case ODBC3SQLFunctionId::ParamData:
128 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLParamData);
129 break;
130 case ODBC3SQLFunctionId::PutData:
132 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPutData);
133 break;
134 case ODBC3SQLFunctionId::RowCount:
136 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLRowCount);
137 break;
138 case ODBC3SQLFunctionId::NumResultCols:
140 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNumResultCols);
141 break;
142 case ODBC3SQLFunctionId::DescribeCol:
144 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDescribeCol);
145 break;
146 case ODBC3SQLFunctionId::ColAttribute:
148 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColAttribute);
149 break;
150 case ODBC3SQLFunctionId::BindCol:
152 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBindCol);
153 break;
154 case ODBC3SQLFunctionId::Fetch:
156 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFetch);
157 break;
158 case ODBC3SQLFunctionId::FetchScroll:
160 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFetchScroll);
161 break;
162 case ODBC3SQLFunctionId::GetData:
164 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetData);
165 break;
166 case ODBC3SQLFunctionId::SetPos:
168 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSetPos);
169 break;
170 case ODBC3SQLFunctionId::BulkOperations:
172 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLBulkOperations);
173 break;
174 case ODBC3SQLFunctionId::MoreResults:
176 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLMoreResults);
177 break;
178 case ODBC3SQLFunctionId::GetDiagRec:
180 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetDiagRec);
181 break;
182 case ODBC3SQLFunctionId::ColumnPrivileges:
184 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColumnPrivileges);
185 break;
186 case ODBC3SQLFunctionId::Columns:
188 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLColumns);
189 break;
190 case ODBC3SQLFunctionId::ForeignKeys:
192 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLForeignKeys);
193 break;
194 case ODBC3SQLFunctionId::PrimaryKeys:
196 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLPrimaryKeys);
197 break;
198 case ODBC3SQLFunctionId::ProcedureColumns:
200 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLProcedureColumns);
201 break;
202 case ODBC3SQLFunctionId::Procedures:
204 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLProcedures);
205 break;
206 case ODBC3SQLFunctionId::SpecialColumns:
208 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLSpecialColumns);
209 break;
210 case ODBC3SQLFunctionId::Statistics:
212 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLStatistics);
213 break;
214 case ODBC3SQLFunctionId::TablePrivileges:
216 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLTablePrivileges);
217 break;
218 case ODBC3SQLFunctionId::Tables:
220 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLTables);
221 break;
222 case ODBC3SQLFunctionId::FreeStmt:
224 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFreeStmt);
225 break;
226 case ODBC3SQLFunctionId::CloseCursor:
228 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLCloseCursor);
229 break;
230 case ODBC3SQLFunctionId::Cancel:
232 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLCancel);
233 break;
234 case ODBC3SQLFunctionId::EndTran:
236 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLEndTran);
237 break;
238 case ODBC3SQLFunctionId::Disconnect:
240 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLDisconnect);
241 break;
242 case ODBC3SQLFunctionId::FreeHandle:
244 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLFreeHandle);
245 break;
246 case ODBC3SQLFunctionId::GetCursorName:
248 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLGetCursorName);
249 break;
250 case ODBC3SQLFunctionId::NativeSql:
252 pFunction = reinterpret_cast<oslGenericFunction>(pODBC3SQLNativeSql);
253 break;
254 default:
255 OSL_FAIL("Function unknown!");
257 return pFunction;
261 css::uno::Reference< css::uno::XInterface > ODBCDriver_CreateInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& _rxFactory)
263 return *(new ORealObdcDriver(_rxFactory));
266 // ODBC Environment (common for all Connections):
267 SQLHANDLE ORealObdcDriver::EnvironmentHandle(OUString &_rPath)
269 // Is (for this instance) already an Environment made?
270 if (!m_pDriverHandle)
272 SQLHANDLE h = SQL_NULL_HANDLE;
273 // allocate Environment
275 // load ODBC-DLL now:
276 if (!LoadLibrary_ODBC3(_rPath) || N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
277 return SQL_NULL_HANDLE;
279 // Save in global Structure
280 m_pDriverHandle = h;
281 N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION, reinterpret_cast<SQLPOINTER>(SQL_OV_ODBC3), SQL_IS_UINTEGER);
282 //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
285 return m_pDriverHandle;
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */