LibreOffice Module connectivity (master) 1
ODatabaseMetaDataResultSet.hxx
Go to the documentation of this file.
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
20#pragma once
21
22#include <com/sun/star/sdbc/ResultSetType.hpp>
23#include <com/sun/star/sdbc/FetchDirection.hpp>
24#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
25#include <com/sun/star/sdbc/XResultSet.hpp>
26#include <com/sun/star/sdbc/XRow.hpp>
27#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
28#include <com/sun/star/sdbc/XCloseable.hpp>
29#include <com/sun/star/sdbc/XColumnLocate.hpp>
30#include <com/sun/star/util/XCancellable.hpp>
31#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
32#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
33#include <com/sun/star/sdbc/XRowUpdate.hpp>
37#include <odbc/OStatement.hxx>
40#include <memory>
41#include <string_view>
42
43namespace connectivity::odbc
44 {
45 /*
46 ** java_sql_ResultSet
47 */
48 typedef ::cppu::WeakComponentImplHelper< css::sdbc::XResultSet,
49 css::sdbc::XRow,
50 css::sdbc::XResultSetMetaDataSupplier,
51 css::util::XCancellable,
52 css::sdbc::XWarningsSupplier,
53 css::sdbc::XCloseable,
54 css::sdbc::XColumnLocate> ODatabaseMetaDataResultSet_BASE;
55
57 public cppu::BaseMutex,
60 public ::comphelper::OPropertyArrayUsageHelper<ODatabaseMetaDataResultSet>
61 {
62 std::vector< sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 every time
63
64 std::map<sal_Int32, ::std::map<sal_Int32,sal_Int32> >
66
67 std::map<sal_Int32,SWORD> m_aODBCColumnTypes;
68
69 SQLHANDLE m_aStatementHandle; // ... until freed
70 css::uno::WeakReferenceHelper m_aStatement;
71 css::uno::Reference< css::sdbc::XResultSetMetaData>
73 std::unique_ptr<SQLUSMALLINT[]> m_pRowStatusArray;
75 rtl_TextEncoding m_nTextEncoding;
76 sal_Int32 m_nRowPos;
77 sal_Int32 m_nDriverColumnCount; // column count of the driver which can sometimes be less than the metadata count
80 bool m_bEOF; // after last record
81
82 // set the columncount of the driver
83 void checkColumnCount();
84 static sal_Int32 getFetchDirection() { return css::sdbc::FetchDirection::FORWARD; }
87 static sal_Int32 getFetchSize();
90 static OUString getCursorName();
91 SWORD impl_getColumnType_nothrow(sal_Int32 columnIndex);
92
93 sal_Int32 mapColumn (sal_Int32 column);
94
95 protected:
96
97 // OPropertyArrayUsageHelper
98 virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const override;
99 // OPropertySetHelper
100 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() override;
101
103 css::uno::Any & rConvertedValue,
104 css::uno::Any & rOldValue,
105 sal_Int32 nHandle,
106 const css::uno::Any& rValue ) override;
107 virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
108 virtual void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
109 virtual ~ODatabaseMetaDataResultSet() override;
110 template < typename T, SQLSMALLINT sqlTypeId > T getInteger ( sal_Int32 columnIndex );
111
112 public:
113 // A ctor needed for returning the object
115
116
117 oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
118 {
119 return m_pConnection->getOdbcFunction(_nIndex);
120 }
121 // ::cppu::OComponentHelper
122 virtual void SAL_CALL disposing() override;
123 // XInterface
124 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType ) override;
125 virtual void SAL_CALL acquire() noexcept override;
126 virtual void SAL_CALL release() noexcept override;
127 //XTypeProvider
128 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
129 // XPropertySet
130 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
131 css::uno::Reference< css::uno::XInterface > operator *()
132 {
133 return css::uno::Reference< css::uno::XInterface >(*static_cast<ODatabaseMetaDataResultSet_BASE*>(this));
134 }
135 // XResultSet
136 virtual sal_Bool SAL_CALL next( ) override;
137 virtual sal_Bool SAL_CALL isBeforeFirst( ) override;
138 virtual sal_Bool SAL_CALL isAfterLast( ) override;
139 virtual sal_Bool SAL_CALL isFirst( ) override;
140 virtual sal_Bool SAL_CALL isLast( ) override;
141 virtual void SAL_CALL beforeFirst( ) override;
142 virtual void SAL_CALL afterLast( ) override;
143 virtual sal_Bool SAL_CALL first( ) override;
144 virtual sal_Bool SAL_CALL last( ) override;
145 virtual sal_Int32 SAL_CALL getRow( ) override;
146 virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) override;
147 virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) override;
148 virtual sal_Bool SAL_CALL previous( ) override;
149 virtual void SAL_CALL refreshRow( ) override;
150 virtual sal_Bool SAL_CALL rowUpdated( ) override;
151 virtual sal_Bool SAL_CALL rowInserted( ) override;
152 virtual sal_Bool SAL_CALL rowDeleted( ) override;
153 virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getStatement( ) override;
154 // XRow
155 virtual sal_Bool SAL_CALL wasNull( ) override;
156 virtual OUString SAL_CALL getString( sal_Int32 columnIndex ) override;
157 virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) override;
158 virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) override;
159 virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) override;
160 virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) override;
161 virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) override;
162 virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) override;
163 virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) override;
164 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) override;
165 virtual css::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) override;
166 virtual css::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) override;
167 virtual css::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) override;
168 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) override;
169 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) override;
170 virtual css::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess >& typeMap ) override;
171 virtual css::uno::Reference< css::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) override;
172 virtual css::uno::Reference< css::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) override;
173 virtual css::uno::Reference< css::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) override;
174 virtual css::uno::Reference< css::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) override;
175 // XResultSetMetaDataSupplier
176 virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) override;
177 // XCancellable
178 virtual void SAL_CALL cancel( ) override;
179 // XCloseable
180 virtual void SAL_CALL close( ) override;
181 // XWarningsSupplier
182 virtual css::uno::Any SAL_CALL getWarnings( ) override;
183 virtual void SAL_CALL clearWarnings( ) override;
184 // XColumnLocate
185 virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName ) override;
186
189 void openTablesTypes( );
192 void openTypeInfo();
195 void openCatalogs();
198 void openSchemas();
201 void openTables(const css::uno::Any& catalog, const OUString& schemaPattern,
202 std::u16string_view tableNamePattern, const css::uno::Sequence< OUString >& types );
205 void openColumnPrivileges( const css::uno::Any& catalog, const OUString& schema,
206 std::u16string_view table, std::u16string_view columnNamePattern );
209 void openColumns( const css::uno::Any& catalog, const OUString& schemaPattern,
210 std::u16string_view tableNamePattern, std::u16string_view columnNamePattern );
213 void openProcedureColumns( const css::uno::Any& catalog, const OUString& schemaPattern,
214 std::u16string_view procedureNamePattern,std::u16string_view columnNamePattern );
217 void openProcedures( const css::uno::Any& catalog, const OUString& schemaPattern,
218 std::u16string_view procedureNamePattern);
221 void openVersionColumns(const css::uno::Any& catalog, const OUString& schema,
222 std::u16string_view table);
225 void openBestRowIdentifier( const css::uno::Any& catalog, const OUString& schema,
226 std::u16string_view table,sal_Int32 scope, bool nullable );
229 void openForeignKeys( const css::uno::Any& catalog, const OUString* schema,const OUString* table,
230 const css::uno::Any& catalog2, const OUString* schema2,const OUString* table2);
233 void openExportedKeys(const css::uno::Any& catalog, const OUString& schema,const OUString& table);
236 void openImportedKeys(const css::uno::Any& catalog, const OUString& schema,const OUString& table);
239 void openPrimaryKeys(const css::uno::Any& catalog, const OUString& schema,std::u16string_view table);
242 void openTablePrivileges(const css::uno::Any& catalog, const OUString& schemaPattern,
243 std::u16string_view tableNamePattern);
246 void openSpecialColumns(bool _bRowVer,const css::uno::Any& catalog, const OUString& schema,
247 std::u16string_view table,sal_Int32 scope, bool nullable );
250 void openIndexInfo( const css::uno::Any& catalog, const OUString& schema,
251 std::u16string_view table,bool unique,bool approximate );
252
253 protected:
255 };
256
257}
258
259/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ODBC3SQLFunctionId
Definition: OTools.hxx:33
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 nHandle) override final
virtual css::uno::Any SAL_CALL getObject(sal_Int32 columnIndex, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const css::uno::Any &rValue) override
std::map< sal_Int32, ::std::map< sal_Int32, sal_Int32 > > m_aValueRange
virtual void SAL_CALL getFastPropertyValue(css::uno::Any &rValue, sal_Int32 nHandle) const override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
oslGenericFunction getOdbcFunction(ODBC3SQLFunctionId _nIndex) const
css::uno::Reference< css::sdbc::XResultSetMetaData > m_xMetaData
virtual sal_Bool SAL_CALL convertFastPropertyValue(css::uno::Any &rConvertedValue, css::uno::Any &rOldValue, sal_Int32 nHandle, const css::uno::Any &rValue) override
bool close
B2DTuple absolute(const B2DTuple &rTup)
double getDouble(const Any &_rAny)
float getFloat(const Any &_rAny)
OUString getString(const Any &_rAny)
Type
::cppu::WeakComponentImplHelper< css::sdbc::XResultSet, css::sdbc::XRow, css::sdbc::XResultSetMetaDataSupplier, css::util::XCancellable, css::sdbc::XWarningsSupplier, css::sdbc::XCloseable, css::sdbc::XColumnLocate > ODatabaseMetaDataResultSet_BASE
constexpr OUStringLiteral first
constexpr OUStringLiteral last
#define OOO_DLLPUBLIC_ODBCBASE
const char * columnName
Definition: pq_statics.cxx:56
unsigned char sal_Bool
signed char sal_Int8