Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / connectivity / source / inc / odbc / ODatabaseMetaDataResultSet.hxx
blob64d548a76b945ffe5b1a39fe72481a4043ccefa0
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 #ifndef INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODATABASEMETADATARESULTSET_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODATABASEMETADATARESULTSET_HXX
23 #include <com/sun/star/sdbc/ResultSetType.hpp>
24 #include <com/sun/star/sdbc/FetchDirection.hpp>
25 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
26 #include <com/sun/star/sdbc/XResultSet.hpp>
27 #include <com/sun/star/sdbc/XRow.hpp>
28 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
29 #include <com/sun/star/sdbc/XCloseable.hpp>
30 #include <com/sun/star/sdbc/XColumnLocate.hpp>
31 #include <com/sun/star/util/XCancellable.hpp>
32 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
34 #include <com/sun/star/sdbc/XRowUpdate.hpp>
35 #include <cppuhelper/compbase.hxx>
36 #include <cppuhelper/basemutex.hxx>
37 #include <comphelper/proparrhlp.hxx>
38 #include <odbc/OStatement.hxx>
39 #include <odbc/ODatabaseMetaData.hxx>
40 #include <odbc/odbcbasedllapi.hxx>
41 #include <memory>
43 namespace connectivity
45 namespace odbc
48 ** java_sql_ResultSet
50 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XResultSet,
51 css::sdbc::XRow,
52 css::sdbc::XResultSetMetaDataSupplier,
53 css::util::XCancellable,
54 css::sdbc::XWarningsSupplier,
55 css::sdbc::XCloseable,
56 css::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE;
58 class OOO_DLLPUBLIC_ODBCBASE ODatabaseMetaDataResultSet :
59 public cppu::BaseMutex,
60 public ODatabaseMetaDataResultSet_BASE,
61 public ::cppu::OPropertySetHelper,
62 public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet>
64 std::vector< sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 every time
66 std::map<sal_Int32, ::std::map<sal_Int32,sal_Int32> >
67 m_aValueRange;
69 std::map<sal_Int32,SWORD> m_aODBCColumnTypes;
71 SQLHANDLE m_aStatementHandle; // ... until freed
72 css::uno::WeakReferenceHelper m_aStatement;
73 css::uno::Reference< css::sdbc::XResultSetMetaData>
74 m_xMetaData;
75 std::unique_ptr<SQLUSMALLINT[]> m_pRowStatusArray;
76 rtl::Reference<OConnection> m_pConnection;
77 rtl_TextEncoding m_nTextEncoding;
78 sal_Int32 m_nRowPos;
79 sal_Int32 m_nDriverColumnCount; // column count of the driver which can sometimes be less than the metadata count
80 SQLRETURN m_nCurrentFetchState;
81 bool m_bWasNull;
82 bool m_bEOF; // after last record
84 // set the columncount of the driver
85 void checkColumnCount();
86 static sal_Int32 getFetchDirection() { return css::sdbc::FetchDirection::FORWARD; }
87 /// @throws css::sdbc::SQLException
88 /// @throws css::uno::RuntimeException
89 static sal_Int32 getFetchSize();
90 /// @throws css::sdbc::SQLException
91 /// @throws css::uno::RuntimeException
92 static OUString getCursorName();
93 SWORD impl_getColumnType_nothrow(sal_Int32 columnIndex);
95 sal_Int32 mapColumn (sal_Int32 column);
97 protected:
99 // OPropertyArrayUsageHelper
100 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
101 // OPropertySetHelper
102 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
104 virtual sal_Bool SAL_CALL convertFastPropertyValue(
105 css::uno::Any & rConvertedValue,
106 css::uno::Any & rOldValue,
107 sal_Int32 nHandle,
108 const css::uno::Any& rValue ) override;
109 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
110 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
111 virtual ~ODatabaseMetaDataResultSet() override;
112 template < typename T, SQLSMALLINT sqlTypeId > T getInteger ( sal_Int32 columnIndex );
114 public:
115 // A ctor needed for returning the object
116 ODatabaseMetaDataResultSet(OConnection* _pConnection);
119 oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
121 return m_pConnection->getOdbcFunction(_nIndex);
123 // ::cppu::OComponentHelper
124 virtual void SAL_CALL disposing() override;
125 // XInterface
126 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
127 virtual void SAL_CALL acquire() throw() override;
128 virtual void SAL_CALL release() throw() override;
129 //XTypeProvider
130 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
131 // XPropertySet
132 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
133 css::uno::Reference< css::uno::XInterface > operator *()
135 return css::uno::Reference< css::uno::XInterface >(*static_cast<ODatabaseMetaDataResultSet_BASE*>(this));
137 // XResultSet
138 virtual sal_Bool SAL_CALL next( ) override;
139 virtual sal_Bool SAL_CALL isBeforeFirst( ) override;
140 virtual sal_Bool SAL_CALL isAfterLast( ) override;
141 virtual sal_Bool SAL_CALL isFirst( ) override;
142 virtual sal_Bool SAL_CALL isLast( ) override;
143 virtual void SAL_CALL beforeFirst( ) override;
144 virtual void SAL_CALL afterLast( ) override;
145 virtual sal_Bool SAL_CALL first( ) override;
146 virtual sal_Bool SAL_CALL last( ) override;
147 virtual sal_Int32 SAL_CALL getRow( ) override;
148 virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) override;
149 virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) override;
150 virtual sal_Bool SAL_CALL previous( ) override;
151 virtual void SAL_CALL refreshRow( ) override;
152 virtual sal_Bool SAL_CALL rowUpdated( ) override;
153 virtual sal_Bool SAL_CALL rowInserted( ) override;
154 virtual sal_Bool SAL_CALL rowDeleted( ) override;
155 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) override;
156 // XRow
157 virtual sal_Bool SAL_CALL wasNull( ) override;
158 virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override;
159 virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override;
160 virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override;
161 virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override;
162 virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override;
163 virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override;
164 virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override;
165 virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override;
166 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override;
167 virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override;
168 virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override;
169 virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override;
170 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override;
171 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override;
172 virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
173 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override;
174 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override;
175 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override;
176 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override;
177 // XResultSetMetaDataSupplier
178 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
179 // XCancellable
180 virtual void SAL_CALL cancel( ) override;
181 // XCloseable
182 virtual void SAL_CALL close( ) override;
183 // XWarningsSupplier
184 virtual css::uno::Any SAL_CALL getWarnings( ) override;
185 virtual void SAL_CALL clearWarnings( ) override;
186 // XColumnLocate
187 virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) override;
189 /// @throws css::sdbc::SQLException
190 /// @throws css::uno::RuntimeException
191 void openTablesTypes( );
192 /// @throws css::sdbc::SQLException
193 /// @throws css::uno::RuntimeException
194 void openTypeInfo();
195 /// @throws css::sdbc::SQLException
196 /// @throws css::uno::RuntimeException
197 void openCatalogs();
198 /// @throws css::sdbc::SQLException
199 /// @throws css::uno::RuntimeException
200 void openSchemas();
201 /// @throws css::sdbc::SQLException
202 /// @throws css::uno::RuntimeException
203 void openTables(const css::uno::Any& catalog, const OUString& schemaPattern,
204 const OUString& tableNamePattern, const css::uno::Sequence< OUString >& types );
205 /// @throws css::sdbc::SQLException
206 /// @throws css::uno::RuntimeException
207 void openColumnPrivileges( const css::uno::Any& catalog, const OUString& schema,
208 const OUString& table, const OUString& columnNamePattern );
209 /// @throws css::sdbc::SQLException
210 /// @throws css::uno::RuntimeException
211 void openColumns( const css::uno::Any& catalog, const OUString& schemaPattern,
212 const OUString& tableNamePattern, const OUString& columnNamePattern );
213 /// @throws css::sdbc::SQLException
214 /// @throws css::uno::RuntimeException
215 void openProcedureColumns( const css::uno::Any& catalog, const OUString& schemaPattern,
216 const OUString& procedureNamePattern,const OUString& columnNamePattern );
217 /// @throws css::sdbc::SQLException
218 /// @throws css::uno::RuntimeException
219 void openProcedures( const css::uno::Any& catalog, const OUString& schemaPattern,
220 const OUString& procedureNamePattern);
221 /// @throws css::sdbc::SQLException
222 /// @throws css::uno::RuntimeException
223 void openVersionColumns(const css::uno::Any& catalog, const OUString& schema,
224 const OUString& table);
225 /// @throws css::sdbc::SQLException
226 /// @throws css::uno::RuntimeException
227 void openBestRowIdentifier( const css::uno::Any& catalog, const OUString& schema,
228 const OUString& table,sal_Int32 scope, bool nullable );
229 /// @throws css::sdbc::SQLException
230 /// @throws css::uno::RuntimeException
231 void openForeignKeys( const css::uno::Any& catalog, const OUString* schema,const OUString* table,
232 const css::uno::Any& catalog2, const OUString* schema2,const OUString* table2);
233 /// @throws css::sdbc::SQLException
234 /// @throws css::uno::RuntimeException
235 void openExportedKeys(const css::uno::Any& catalog, const OUString& schema,const OUString& table);
236 /// @throws css::sdbc::SQLException
237 /// @throws css::uno::RuntimeException
238 void openImportedKeys(const css::uno::Any& catalog, const OUString& schema,const OUString& table);
239 /// @throws css::sdbc::SQLException
240 /// @throws css::uno::RuntimeException
241 void openPrimaryKeys(const css::uno::Any& catalog, const OUString& schema,const OUString& table);
242 /// @throws css::sdbc::SQLException
243 /// @throws css::uno::RuntimeException
244 void openTablePrivileges(const css::uno::Any& catalog, const OUString& schemaPattern,
245 const OUString& tableNamePattern);
246 /// @throws css::sdbc::SQLException
247 /// @throws css::uno::RuntimeException
248 void openSpecialColumns(bool _bRowVer,const css::uno::Any& catalog, const OUString& schema,
249 const OUString& table,sal_Int32 scope, bool nullable );
250 /// @throws css::sdbc::SQLException
251 /// @throws css::uno::RuntimeException
252 void openIndexInfo( const css::uno::Any& catalog, const OUString& schema,
253 const OUString& table,bool unique,bool approximate );
255 protected:
256 using OPropertySetHelper::getFastPropertyValue;
261 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_ODBC_ODATABASEMETADATARESULTSET_HXX
263 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */