build fix: no comphelper/profilezone.hxx in this branch
[LibreOffice.git] / include / ucbhelper / resultsetmetadata.hxx
blob5b397d6603f92c40ff4a55b45e468564c5d6c779
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_UCBHELPER_RESULTSETMETADATA_HXX
21 #define INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX
23 #include <vector>
24 #include <memory>
25 #include <com/sun/star/uno/Reference.hxx>
26 #include <com/sun/star/uno/Sequence.hxx>
27 #include <com/sun/star/lang/XTypeProvider.hpp>
28 #include <com/sun/star/sdbc/ColumnValue.hpp>
29 #include <com/sun/star/sdbc/XResultSetMetaData.hpp>
30 #include <cppuhelper/weak.hxx>
31 #include <ucbhelper/macros.hxx>
32 #include <ucbhelper/ucbhelperdllapi.h>
34 namespace com { namespace sun { namespace star {
35 namespace lang { class XMultiServiceFactory; }
36 namespace beans { struct Property; }
37 } } }
39 namespace ucbhelper_impl {
40 struct ResultSetMetaData_Impl;
43 namespace ucbhelper
47 /**
48 * This is a structure that holds additional meta data for one column
49 * of a resultset. The default values set in the constructor should be a
50 * good guess for many UCB use cases.
52 struct ResultSetColumnData
54 /** @see ResultSetMetaData::isCaseSensitive */
55 bool isCaseSensitive;
57 /** @see ResultSetMetaData::getColumnDisplaySize */
58 sal_Int32 columnDisplaySize;
60 /** @see ResultSetMetaData::getColumnLabel */
61 OUString columnLabel;
63 /** @see ResultSetMetaData::getSchemaName */
64 OUString schemaName;
66 /** @see ResultSetMetaData::getTableName */
67 OUString tableName;
69 /** @see ResultSetMetaData::getCatalogName */
70 OUString catalogName;
72 /** @see ResultSetMetaData::getColumnTypeName */
73 OUString columnTypeName;
75 /** @see ResultSetMetaData::getColumnServiceName */
76 OUString columnServiceName;
78 inline ResultSetColumnData();
81 // Note: Never change the initial values! Implementations using this struct
82 // may heavily depend on the behaviour of the default constructor.
84 ResultSetColumnData::ResultSetColumnData()
85 : isCaseSensitive( true ),
86 columnDisplaySize( 16 )
91 /**
92 * This is an implementation of the interface XResultSetMetaData. It can be
93 * used to implement the interface
94 * css::sdbc::XResultSetMetaDataSupplier, which is required for
95 * implementations of service com.sun.star.ucb.ContentResultSet.
97 class UCBHELPER_DLLPUBLIC ResultSetMetaData :
98 public ::cppu::OWeakObject,
99 public css::lang::XTypeProvider,
100 public css::sdbc::XResultSetMetaData
102 private:
103 std::unique_ptr<ucbhelper_impl::ResultSetMetaData_Impl> m_pImpl;
105 protected:
106 css::uno::Reference< css::uno::XComponentContext > m_xContext;
107 css::uno::Sequence< css::beans::Property > m_aProps;
109 public:
112 * Constructor. ResultSet is readonly by default.
114 * @param rxSMgr is a Servive Manager.
115 * @param rProps is a sequence of properties (partially) describing the
116 * columns of a resultset.
118 ResultSetMetaData(
119 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
120 const css::uno::Sequence< css::beans::Property >& rProps );
123 * Constructor.
125 * @param rxSMgr is a Servive Manager.
126 * @param rProps is a sequence of properties (partially) describing the
127 * columns of a resultset.
128 * @param rColumnData contains additional meta data for the columns of
129 * a resultset, which override the default values returned by the
130 * appropriate methods of this class. The length of rColumnData
131 * must be the same as length of rProps.
132 * rColumnData[ 0 ] corresponds to data in rProps[ 0 ],
133 * rColumnData[ 1 ] corresponds to data in rProps[ 1 ], ...
135 ResultSetMetaData(
136 const css::uno::Reference< css::uno::XComponentContext >& rxContext,
137 const css::uno::Sequence< css::beans::Property >& rProps,
138 const std::vector< ResultSetColumnData >& rColumnData );
141 * Destructor.
143 virtual ~ResultSetMetaData() override;
145 // XInterface
146 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type & rType )
147 throw( css::uno::RuntimeException, std::exception ) override;
148 virtual void SAL_CALL acquire()
149 throw() override;
150 virtual void SAL_CALL release()
151 throw() override;
153 // XTypeProvider
154 virtual css::uno::Sequence< sal_Int8 > SAL_CALL
155 getImplementationId()
156 throw( css::uno::RuntimeException, std::exception ) override;
157 virtual css::uno::Sequence< css::uno::Type > SAL_CALL
158 getTypes()
159 throw( css::uno::RuntimeException, std::exception ) override;
161 // XResultSetMetaData
164 * Returns the number of columns of the resultset.
166 * @return the length of the property sequence.
168 virtual sal_Int32 SAL_CALL
169 getColumnCount()
170 throw( css::sdbc::SQLException,
171 css::uno::RuntimeException, std::exception ) override;
173 * Checks whether column is automatically numbered, which makes it
174 * read-only.
176 * @param column is the number of the column for that a value shall
177 * be returned. The first column is 1, the second is 2, ...
178 * @return true, if column is automatically numbered.
180 virtual sal_Bool SAL_CALL
181 isAutoIncrement( sal_Int32 column )
182 throw( css::sdbc::SQLException,
183 css::uno::RuntimeException, std::exception ) override;
185 * Checks whether column is case sensitive.
187 * @param column is the number of the column for that a value shall
188 * be returned. The first column is 1, the second is 2, ...
189 * @return true, if column is case sensitive.
191 virtual sal_Bool SAL_CALL
192 isCaseSensitive( sal_Int32 column )
193 throw( css::sdbc::SQLException,
194 css::uno::RuntimeException, std::exception ) override;
196 * Checks whether the value stored in column can be used in a
197 * WHERE clause.
199 * @param column is the number of the column for that a value shall
200 * be returned. The first column is 1, the second is 2, ...
201 * @return true, if the column is searchable.
203 virtual sal_Bool SAL_CALL
204 isSearchable( sal_Int32 column )
205 throw( css::sdbc::SQLException,
206 css::uno::RuntimeException, std::exception ) override;
208 * Checks whether column is a cash value.
210 * @param column is the number of the column for that a value shall
211 * be returned. The first column is 1, the second is 2, ...
212 * @return true, if the column is a cash value.
214 virtual sal_Bool SAL_CALL
215 isCurrency( sal_Int32 column )
216 throw( css::sdbc::SQLException,
217 css::uno::RuntimeException, std::exception ) override;
219 * Checks whether a NULL can be stored in column.
221 * @see css::sdbc::ColumnValue
223 * @param column is the number of the column for that a value shall
224 * be returned. The first column is 1, the second is 2, ...
225 * @return css::sdbc::ColumnValue::NULLABLE, if a NULL
226 * can be stored in the column.
228 virtual sal_Int32 SAL_CALL
229 isNullable( sal_Int32 column )
230 throw( css::sdbc::SQLException,
231 css::uno::RuntimeException, std::exception ) override;
233 * Checks whether the value stored in column is a signed number.
235 * @param column is the number of the column for that a value shall
236 * be returned. The first column is 1, the second is 2, ...
237 * @return true, if the value stored in column is a signed number.
239 virtual sal_Bool SAL_CALL
240 isSigned( sal_Int32 column )
241 throw( css::sdbc::SQLException,
242 css::uno::RuntimeException, std::exception ) override;
244 * Gets the normal maximum width in characters for column.
246 * @param column is the number of the column for that a value shall
247 * be returned. The first column is 1, the second is 2, ...
248 * @return the normal maximum width in characters for column.
250 virtual sal_Int32 SAL_CALL
251 getColumnDisplaySize( sal_Int32 column )
252 throw( css::sdbc::SQLException,
253 css::uno::RuntimeException, std::exception ) override;
255 * Gets the suggested column title for column, to be used in print-
256 * outs and displays.
258 * @param column is the number of the column for that a value shall
259 * be returned. The first column is 1, the second is 2, ...
260 * @return the column label.
262 virtual OUString SAL_CALL
263 getColumnLabel( sal_Int32 column )
264 throw( css::sdbc::SQLException,
265 css::uno::RuntimeException, std::exception ) override;
267 * Gets the name of column.
269 * @param column is the number of the column for that a value shall
270 * be returned. The first column is 1, the second is 2, ...
271 * @return the name of the property that corresponds to column.
273 virtual OUString SAL_CALL
274 getColumnName( sal_Int32 column )
275 throw( css::sdbc::SQLException,
276 css::uno::RuntimeException, std::exception ) override;
278 * Gets the schema name for the table from which column of this
279 * result set was derived.
280 * Because this feature is not widely supported, the return value
281 * for many DBMSs will be an empty string.
283 * @param column is the number of the column for that a value shall
284 * be returned. The first column is 1, the second is 2, ...
285 * @return the schema name of column or an empty string.
287 virtual OUString SAL_CALL
288 getSchemaName( sal_Int32 column )
289 throw( css::sdbc::SQLException,
290 css::uno::RuntimeException, std::exception ) override;
292 * For number types, getprecision gets the number of decimal digits
293 * in column.
294 * For character types, it gets the maximum length in characters for
295 * column.
296 * For binary types, it gets the maximum length in bytes for column.
298 * @param column is the number of the column for that a value shall
299 * be returned. The first column is 1, the second is 2, ...
300 * @return the precision for the column.
302 virtual sal_Int32 SAL_CALL
303 getPrecision( sal_Int32 column )
304 throw( css::sdbc::SQLException,
305 css::uno::RuntimeException, std::exception ) override;
307 * Gets the number of digits to the right of the decimal point for
308 * values in column.
310 * @param column is the number of the column for that a value shall
311 * be returned. The first column is 1, the second is 2, ...
312 * @return the scale of the column.
314 virtual sal_Int32 SAL_CALL
315 getScale( sal_Int32 column )
316 throw( css::sdbc::SQLException,
317 css::uno::RuntimeException, std::exception ) override;
319 * Gets the name of the table from which column of this result set
320 * was derived or "" if there is none (for example, for a join).
321 * Because this feature is not widely supported, the return value
322 * for many DBMSs will be an empty string.
324 * @param column is the number of the column for that a value shall
325 * be returned. The first column is 1, the second is 2, ...
326 * @return the table name for column or an empty string.
328 virtual OUString SAL_CALL
329 getTableName( sal_Int32 column )
330 throw( css::sdbc::SQLException,
331 css::uno::RuntimeException, std::exception ) override;
332 virtual OUString SAL_CALL
334 * Gets the catalog name for the table from which column of this
335 * result set was derived.
336 * Because this feature is not widely supported, the return value
337 * for many DBMSs will be an empty string.
339 * @param column is the number of the column for that a value shall
340 * be returned. The first column is 1, the second is 2, ...
341 * @return the catalog name for column or an empty string.
343 getCatalogName( sal_Int32 column )
344 throw( css::sdbc::SQLException,
345 css::uno::RuntimeException, std::exception ) override;
347 * Gets the JDBC type for the value stored in column. ... The STRUCT
348 * and DISTINCT type codes are always returned for structured and
349 * distinct types, regardless of whether the value will be mapped
350 * according to the standard mapping or be a custom mapping.
352 * @param column is the number of the column for that a value shall
353 * be returned. The first column is 1, the second is 2, ...
354 * @return the type of the property that corresponds to column - mapped
355 * from UNO-Type to SQL-Type.
357 virtual sal_Int32 SAL_CALL
358 getColumnType( sal_Int32 column )
359 throw( css::sdbc::SQLException,
360 css::uno::RuntimeException, std::exception ) override;
362 * Gets the type name used by this particular data source for the
363 * values stored in column. If the type code for the type of value
364 * stored in column is STRUCT, DISTINCT or JAVA_OBJECT, this method
365 * returns a fully-qualified SQL type name.
367 * @param column is the number of the column for that a value shall
368 * be returned. The first column is 1, the second is 2, ...
369 * @return the column type name.
371 virtual OUString SAL_CALL
372 getColumnTypeName( sal_Int32 column )
373 throw( css::sdbc::SQLException,
374 css::uno::RuntimeException, std::exception ) override;
376 * Indicates whether a column is definitely not writable.
378 * @param column is the number of the column for that a value shall
379 * be returned. The first column is 1, the second is 2, ...
380 * @return true, if the column is definetely not writable.
382 virtual sal_Bool SAL_CALL
383 isReadOnly( sal_Int32 column )
384 throw( css::sdbc::SQLException,
385 css::uno::RuntimeException, std::exception ) override;
387 * Indicates whether it is possible for a write on the column to succeed.
389 * @param column is the number of the column for that a value shall
390 * be returned. The first column is 1, the second is 2, ...
391 * @return true, if it is possible for a write to succeed.
393 virtual sal_Bool SAL_CALL
394 isWritable( sal_Int32 column )
395 throw( css::sdbc::SQLException,
396 css::uno::RuntimeException, std::exception ) override;
398 * Indicates whether a write on the column will definitely succeed.
400 * @param column is the number of the column for that a value shall
401 * be returned. The first column is 1, the second is 2, ...
402 * @return true, if a write on the column will definetely succeed.
404 virtual sal_Bool SAL_CALL
405 isDefinitelyWritable( sal_Int32 column )
406 throw( css::sdbc::SQLException,
407 css::uno::RuntimeException, std::exception ) override;
409 * Returns the fully-qualified name of the service whose instances
410 * are manufactured if the method
411 * css::sdbc::ResultSet::getObject is called to retrieve a
412 * value from the column.
414 * @param column is the number of the column for that a value shall
415 * be returned. The first column is 1, the second is 2, ...
416 * @return the service name for column or an empty string, if no service
417 * is applicable.
419 virtual OUString SAL_CALL
420 getColumnServiceName( sal_Int32 column )
421 throw( css::sdbc::SQLException,
422 css::uno::RuntimeException, std::exception ) override;
425 } // namespace ucbhelper
427 #endif /* ! INCLUDED_UCBHELPER_RESULTSETMETADATA_HXX */
429 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */