1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_FDATABASEMETADATARESULTSET_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_INC_FDATABASEMETADATARESULTSET_HXX
23 #include <sal/config.h>
27 #include <com/sun/star/sdbc/XResultSet.hpp>
28 #include <com/sun/star/sdbc/XRow.hpp>
29 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
30 #include <com/sun/star/sdbc/XCloseable.hpp>
31 #include <com/sun/star/sdbc/XColumnLocate.hpp>
32 #include <com/sun/star/util/XCancellable.hpp>
33 #include <com/sun/star/lang/XInitialization.hpp>
34 #include <com/sun/star/lang/XServiceInfo.hpp>
35 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
36 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
37 #include <com/sun/star/sdbc/XRowUpdate.hpp>
38 #include <cppuhelper/compbase.hxx>
39 #include <cppuhelper/basemutex.hxx>
40 #include <comphelper/proparrhlp.hxx>
41 #include <connectivity/CommonTools.hxx>
42 #include <comphelper/propertycontainer.hxx>
43 #include <connectivity/FValue.hxx>
44 #include <connectivity/dbtoolsdllapi.hxx>
45 #include <salhelper/simplereferenceobject.hxx>
47 namespace connectivity
49 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XResultSet
,
51 css::sdbc::XResultSetMetaDataSupplier
,
52 css::util::XCancellable
,
53 css::sdbc::XWarningsSupplier
,
54 css::sdbc::XCloseable
,
55 css::lang::XInitialization
,
56 css::lang::XServiceInfo
,
57 css::sdbc::XColumnLocate
> ODatabaseMetaDataResultSet_BASE
;
59 // typedef ORefVector<ORowSetValue> ORow;
60 // typedef ORefVector<ORow> ORows;
62 class OOO_DLLPUBLIC_DBTOOLS ODatabaseMetaDataResultSet
:
63 public cppu::BaseMutex
,
64 public ODatabaseMetaDataResultSet_BASE
,
65 public ::comphelper::OPropertyContainer
,
66 public ::comphelper::OPropertyArrayUsageHelper
<ODatabaseMetaDataResultSet
>
70 typedef std::vector
<ORowSetValueDecoratorRef
> ORow
;
71 typedef std::vector
<ORow
> ORows
;
73 enum MetaDataResultSetType
75 /// describes a result set as expected by XDatabaseMetaData::getCatalogs
77 /// describes a result set as expected by XDatabaseMetaData::getSchemas
79 /// describes a result set as expected by XDatabaseMetaData::getColumnPrivileges
80 eColumnPrivileges
= 2,
81 /// describes a result set as expected by XDatabaseMetaData::getColumns
83 /// describes a result set as expected by XDatabaseMetaData::getTables
85 /// describes a result set as expected by XDatabaseMetaData::getTableTypes
87 /// describes a result set as expected by XDatabaseMetaData::getProcedureColumns
88 eProcedureColumns
= 6,
89 /// describes a result set as expected by XDatabaseMetaData::getProcedures
91 /// describes a result set as expected by XDatabaseMetaData::getExportedKeys
93 /// describes a result set as expected by XDatabaseMetaData::getImportedKeys
95 /// describes a result set as expected by XDatabaseMetaData::getPrimaryKeys
97 /// describes a result set as expected by XDatabaseMetaData::getIndexInfo
99 /// describes a result set as expected by XDatabaseMetaData::getTablePrivileges
100 eTablePrivileges
= 12,
101 /// describes a result set as expected by XDatabaseMetaData::getCrossReference
102 eCrossReference
= 13,
103 /// describes a result set as expected by XDatabaseMetaData::getTypeInfo
105 /// describes a result set as expected by XDatabaseMetaData::getBestRowIdentifier
106 eBestRowIdentifier
= 15,
107 /// describes a result set as expected by XDatabaseMetaData::getVersionColumns
108 eVersionColumns
= 16,
109 /// describes a result set as expected by XDatabaseMetaData::getUDTs
114 ORowSetValue m_aEmptyValue
;
115 css::uno::WeakReferenceHelper m_aStatement
;
116 css::uno::Reference
< css::sdbc::XResultSetMetaData
> m_xMetaData
;
119 sal_Int32 m_nFetchSize
;
120 sal_Int32 m_nResultSetType
;
121 sal_Int32 m_nFetchDirection
;
122 sal_Int32 m_nResultSetConcurrency
;
125 /// @throws css::sdbc::SQLException
126 void checkIndex(sal_Int32 columnIndex
);
127 void setType(MetaDataResultSetType _eType
);
131 ORows::iterator m_aRowsIter
;
135 virtual const ORowSetValue
& getValue(sal_Int32 columnIndex
);
137 // OPropertyArrayUsageHelper
138 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper( ) const override
;
139 // OPropertySetHelper
140 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
142 virtual ~ODatabaseMetaDataResultSet() override
;
145 virtual void SAL_CALL
acquire() throw() override
;
146 virtual void SAL_CALL
release() throw() override
;
148 /// default construction
149 ODatabaseMetaDataResultSet();
150 /// construction of a pre-defined result set type
151 ODatabaseMetaDataResultSet( MetaDataResultSetType _eType
);
153 void setRows(const ORows
& _rRows
);
157 /// @throws css::uno::RuntimeException
158 static OUString
getImplementationName_Static( );
159 /// @throws css::uno::RuntimeException
160 static css::uno::Sequence
< OUString
> getSupportedServiceNames_Static( );
163 virtual OUString SAL_CALL
getImplementationName( ) override
;
164 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
165 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
166 // ::cppu::OComponentHelper
167 virtual void SAL_CALL
disposing() override
;
169 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& rType
) override
;
171 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
173 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
175 virtual sal_Bool SAL_CALL
next( ) override
;
176 virtual sal_Bool SAL_CALL
isBeforeFirst( ) override
;
177 virtual sal_Bool SAL_CALL
isAfterLast( ) override
;
178 virtual sal_Bool SAL_CALL
isFirst( ) override
;
179 virtual sal_Bool SAL_CALL
isLast( ) override
;
180 virtual void SAL_CALL
beforeFirst( ) override
;
181 virtual void SAL_CALL
afterLast( ) override
;
182 virtual sal_Bool SAL_CALL
first( ) override
;
183 virtual sal_Bool SAL_CALL
last( ) override
;
184 virtual sal_Int32 SAL_CALL
getRow( ) override
;
185 virtual sal_Bool SAL_CALL
absolute( sal_Int32 row
) override
;
186 virtual sal_Bool SAL_CALL
relative( sal_Int32 rows
) override
;
187 virtual sal_Bool SAL_CALL
previous( ) override
;
188 virtual void SAL_CALL
refreshRow( ) override
;
189 virtual sal_Bool SAL_CALL
rowUpdated( ) override
;
190 virtual sal_Bool SAL_CALL
rowInserted( ) override
;
191 virtual sal_Bool SAL_CALL
rowDeleted( ) override
;
192 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getStatement( ) override
;
194 virtual sal_Bool SAL_CALL
wasNull( ) override
;
195 virtual OUString SAL_CALL
getString( sal_Int32 columnIndex
) override
;
196 virtual sal_Bool SAL_CALL
getBoolean( sal_Int32 columnIndex
) override
;
197 virtual sal_Int8 SAL_CALL
getByte( sal_Int32 columnIndex
) override
;
198 virtual sal_Int16 SAL_CALL
getShort( sal_Int32 columnIndex
) override
;
199 virtual sal_Int32 SAL_CALL
getInt( sal_Int32 columnIndex
) override
;
200 virtual sal_Int64 SAL_CALL
getLong( sal_Int32 columnIndex
) override
;
201 virtual float SAL_CALL
getFloat( sal_Int32 columnIndex
) override
;
202 virtual double SAL_CALL
getDouble( sal_Int32 columnIndex
) override
;
203 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getBytes( sal_Int32 columnIndex
) override
;
204 virtual css::util::Date SAL_CALL
getDate( sal_Int32 columnIndex
) override
;
205 virtual css::util::Time SAL_CALL
getTime( sal_Int32 columnIndex
) override
;
206 virtual css::util::DateTime SAL_CALL
getTimestamp( sal_Int32 columnIndex
) override
;
207 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getBinaryStream( sal_Int32 columnIndex
) override
;
208 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getCharacterStream( sal_Int32 columnIndex
) override
;
209 virtual css::uno::Any SAL_CALL
getObject( sal_Int32 columnIndex
, const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
;
210 virtual css::uno::Reference
< css::sdbc::XRef
> SAL_CALL
getRef( sal_Int32 columnIndex
) override
;
211 virtual css::uno::Reference
< css::sdbc::XBlob
> SAL_CALL
getBlob( sal_Int32 columnIndex
) override
;
212 virtual css::uno::Reference
< css::sdbc::XClob
> SAL_CALL
getClob( sal_Int32 columnIndex
) override
;
213 virtual css::uno::Reference
< css::sdbc::XArray
> SAL_CALL
getArray( sal_Int32 columnIndex
) override
;
214 // XResultSetMetaDataSupplier
215 virtual css::uno::Reference
< css::sdbc::XResultSetMetaData
> SAL_CALL
getMetaData( ) override
;
217 virtual void SAL_CALL
cancel( ) override
;
219 virtual void SAL_CALL
close( ) override
;
221 virtual css::uno::Any SAL_CALL
getWarnings( ) override
;
222 virtual void SAL_CALL
clearWarnings( ) override
;
224 virtual sal_Int32 SAL_CALL
findColumn( const OUString
& columnName
) override
;
227 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
229 void setCatalogsMap();
230 void setSchemasMap();
231 void setColumnPrivilegesMap();
232 void setColumnsMap();
234 void setTableTypes();
235 void setProcedureColumnsMap();
236 void setProceduresMap();
237 void setExportedKeysMap();
238 void setImportedKeysMap();
239 void setPrimaryKeysMap();
240 void setIndexInfoMap();
241 void setTablePrivilegesMap();
242 void setCrossReferenceMap();
243 void setTypeInfoMap();
244 void setBestRowIdentifierMap();
245 void setVersionColumnsMap();
248 // some methods to get already defined ORowSetValues
249 // this increase the reuse of ORowSetValues
250 /// return an empty ORowSetValueDecorator
251 static ORowSetValueDecoratorRef
const & getEmptyValue();
252 /// return an ORowSetValueDecorator with 0 as value
253 static ORowSetValueDecoratorRef
const & get0Value();
254 /// return an ORowSetValueDecorator with 1 as value
255 static ORowSetValueDecoratorRef
const & get1Value();
256 /// return an ORowSetValueDecorator with ColumnSearch::BASIC as value
257 static ORowSetValueDecoratorRef
const & getBasicValue();
258 /// return an ORowSetValueDecorator with string SELECT as value
259 static ORowSetValueDecoratorRef
const & getSelectValue();
260 /// return an ORowSetValueDecorator with string INSERT as value
261 static ORowSetValueDecoratorRef
const & getInsertValue();
262 /// return an ORowSetValueDecorator with string DELETE as value
263 static ORowSetValueDecoratorRef
const & getDeleteValue();
264 /// return an ORowSetValueDecorator with string UPDATE as value
265 static ORowSetValueDecoratorRef
const & getUpdateValue();
266 /// return an ORowSetValueDecorator with string CREATE as value
267 static ORowSetValueDecoratorRef
const & getCreateValue();
268 /// return an ORowSetValueDecorator with string READ as value
269 static ORowSetValueDecoratorRef
const & getReadValue();
270 /// return an ORowSetValueDecorator with string ALTER as value
271 static ORowSetValueDecoratorRef
const & getAlterValue();
272 /// return an ORowSetValueDecorator with string DROP as value
273 static ORowSetValueDecoratorRef
const & getDropValue();
274 /// return an ORowSetValueDecorator with string ' as value
275 static ORowSetValueDecoratorRef
const & getQuoteValue();
279 #endif // INCLUDED_CONNECTIVITY_SOURCE_INC_FDATABASEMETADATARESULTSET_HXX
281 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */