Branch libreoffice-5-0-4
[LibreOffice.git] / include / connectivity / dbmetadata.hxx
blob148763d9dfe5fc6ec945f86cee1e1a59c35286bf
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_DBMETADATA_HXX
21 #define INCLUDED_CONNECTIVITY_DBMETADATA_HXX
23 #include <com/sun/star/sdbc/XConnection.hpp>
24 #include <com/sun/star/uno/XComponentContext.hpp>
26 #include <memory>
27 #include <connectivity/dbtoolsdllapi.hxx>
30 namespace dbtools
35 //= DatabaseMetaData
37 struct DatabaseMetaData_Impl;
38 /** encapsulates meta data about a database/connection which cannot be obtained
39 from the usual XDatabaseMetaData result set.
41 Meta data perhaps isn't really the right term ... Some of the methods
42 in this class involved heuristics, some are just a convenient wrapper
43 around more complex ways to obtain the same information.
45 @todo
46 Once CWS dba30 is integrated, we could easily add all the meta data
47 which is part of the "Info" property of a data source.
49 class OOO_DLLPUBLIC_DBTOOLS DatabaseMetaData
51 private:
52 ::std::unique_ptr< DatabaseMetaData_Impl > m_pImpl;
54 public:
55 DatabaseMetaData();
56 /** constructs a DatabaseMetaData instance
57 @param _rxConnection
58 is the connection whose meta data you're interested in.
59 Note that some of the information provided by this class can only be obtained
60 if this connection denotes an application-level connection, i.e. supports
61 the com.sun.star.sdb.Connection service.
63 @throws ::com::sun::star::lang::IllegalArgumentException
64 if the given connection is not <NULL/>, but the XDatabaseMetaData provided by it
65 are <NULL/>
66 @throws ::com::sun::star::sdbc::SQLException
67 if obtaining the meta data from the connection throws an SQLException
68 @throws ::com::sun::star::uno::RuntimeException
69 if obtaining the meta data from the connection throws an RuntimeException
71 DatabaseMetaData(
72 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _connection );
73 DatabaseMetaData( const DatabaseMetaData& _copyFrom );
74 DatabaseMetaData& operator=( const DatabaseMetaData& _copyFrom );
76 ~DatabaseMetaData();
78 public:
79 /** determines whether or not the instances is based on a valid connection
81 As long as this method returns true<TRUE/>, you should expect all other
82 methods throwing an SQLException when called.
84 bool isConnected() const;
86 /** resets the instance so that it's based on a new connection
88 inline void reset( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _connection )
90 *this = DatabaseMetaData( _connection );
93 /// wraps XDatabaseMetaData::getIdentifierQuoteString
94 const OUString& getIdentifierQuoteString() const;
96 /// wraps XDatabaseMetaData::getCatalogSeparator
97 const OUString& getCatalogSeparator() const;
99 /** determines whether the database supports sub queries in the FROM part
100 of a SELECT clause are supported.
101 @throws ::com::sun::star::sdbc::SQLException
102 with SQLState 08003 (connection does not exist) if the instances was
103 default-constructed and does not have a connection, yet.
105 bool supportsSubqueriesInFrom() const;
107 /** checks whether the database supports primary keys
109 Since there's no dedicated API to ask a database for this, a heuristics needs to be applied.
110 First, the <code>PrimaryKeySupport<code> settings of the data source is examined. If it is <TRUE/>
111 or <FALSE/>, then value is returned. If it is <NULL/>, then the database meta data are examined
112 for support of core SQL grammar, and the result is returned. The assumption is that a database/driver
113 which supports core SQL grammar usually also supports primary keys, and vice versa. At least, experience
114 shows this is true most of the time.
116 bool supportsPrimaryKeys() const;
118 /** determines whether names in the database should be restricted to SQL-92 identifiers
120 Effectively, this method checks the EnableSQL92Check property of the data source settings,
121 if present.
123 bool restrictIdentifiersToSQL92() const;
125 /** determines whether when generating SQL statements, an AS keyword should be generated
126 before a correlation name.
128 E.g., it determines whether <code>SELECT * FROM table AS correlation_name</code> or
129 <code>SELECT * FROM table correlation_name</code> is generated.
131 bool generateASBeforeCorrelationName() const;
133 /** should date time be escaped like '2001-01-01' => {D '2001-01-01' }
135 bool shouldEscapeDateTime() const;
137 /** auto increment columns should be automatically used as primary key.
139 bool isAutoIncrementPrimaryKey() const;
141 /** determines the syntax to use for boolean comparison predicates
143 @see ::com::sun::star::sdb::BooleanComparisonMode
145 sal_Int32
146 getBooleanComparisonMode() const;
148 /** determines in relations are supported.
150 * \return <TRUE/> when relations are supported, otherwise <FALSE/>
152 bool supportsRelations() const;
154 /** determines if column alias names can be used in the order by clause.
156 * \return <TRUE/> when relations are supported, otherwise <FALSE/>
158 bool supportsColumnAliasInOrderBy() const;
160 /** determines whether user administration is supported for the database
162 User administration support is controlled by the availability of the XUsersSupplier
163 interface, and it returning a non-NULL users container.
165 @param _rContext
166 the component context we operate in. Might be needed to create the
167 css.sdbc.DriverManager instance.
169 bool supportsUserAdministration( const css::uno::Reference<css::uno::XComponentContext>& _rContext ) const;
171 /** determines whether in the application UI, empty table folders (aka catalogs/schemas) should be displayed
173 bool displayEmptyTableFolders() const;
175 /** determines that threads are supported.
177 * \return <TRUE/> when threads are supported, otherwise <FALSE/>
179 bool supportsThreads() const;
183 } // namespace dbtools
186 #endif // INCLUDED_CONNECTIVITY_DBMETADATA_HXX
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */