nss: upgrade to release 3.73
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_connection.hxx
blob283b1d964d4b9bf47c35b6905b80353db2d511b6
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_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
21 #define INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
23 #include <memory>
24 #include "mysqlc_subcomponent.hxx"
25 #include "mysqlc_types.hxx"
27 #include <com/sun/star/beans/PropertyValue.hpp>
28 #include <com/sun/star/lang/DisposedException.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <com/sun/star/sdbc/ColumnSearch.hpp>
32 #include <com/sun/star/sdbc/ColumnValue.hpp>
33 #include <com/sun/star/sdbc/DataType.hpp>
34 #include <com/sun/star/sdbc/SQLWarning.hpp>
35 #include <com/sun/star/sdbc/XConnection.hpp>
36 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
37 #include <com/sun/star/util/XStringSubstitution.hpp>
39 #include <cppuhelper/compbase3.hxx>
40 #include <cppuhelper/weakref.hxx>
41 #include <rtl/string.hxx>
42 #include <rtl/ref.hxx>
44 #include <mysql.h>
46 #include <map>
48 namespace sql
50 class SQLException;
53 namespace connectivity
55 class OMetaConnection;
56 class ODatabaseMetaData;
58 namespace mysqlc
60 using ::com::sun::star::sdbc::SQLException;
61 using ::com::sun::star::sdbc::SQLWarning;
62 using ::com::sun::star::uno::RuntimeException;
64 typedef ::cppu::WeakComponentImplHelper3<css::sdbc::XConnection, css::sdbc::XWarningsSupplier,
65 css::lang::XServiceInfo>
66 OMetaConnection_BASE;
68 struct ConnectionSettings
70 rtl_TextEncoding encoding;
71 OUString connectionURL;
72 bool readOnly;
73 ConnectionSettings()
74 : encoding(RTL_TEXTENCODING_DONTKNOW)
75 , readOnly(false)
80 class MysqlCDriver;
82 typedef OMetaConnection_BASE OConnection_BASE;
84 typedef std::vector<css::uno::WeakReferenceHelper> OWeakRefArray;
86 class OConnection final : public OBase_Mutex, public OConnection_BASE
88 private:
89 MYSQL m_mysql;
90 ConnectionSettings m_settings;
91 css::uno::Reference<css::container::XNameAccess> m_typeMap;
92 css::uno::Reference<css::util::XStringSubstitution> m_xParameterSubstitution;
94 // Data attributes
96 css::uno::WeakReference<css::sdbc::XDatabaseMetaData> m_xMetaData;
98 OWeakRefArray m_aStatements; // vector containing a list
99 // of all the Statement objects
100 // for this Connection
102 rtl::Reference<MysqlCDriver> m_xDriver; // Pointer to the owning driver object
103 public:
104 MYSQL* getMysqlConnection() { return &m_mysql; }
106 /// @throws SQLException
107 /// @throws RuntimeException
108 sal_Int32 getMysqlVersion();
110 /// @throws SQLException
111 void construct(const OUString& url, const css::uno::Sequence<css::beans::PropertyValue>& info);
113 OConnection(MysqlCDriver& _rDriver);
114 virtual ~OConnection() override;
116 rtl_TextEncoding getConnectionEncoding() const { return m_settings.encoding; }
118 // OComponentHelper
119 virtual void SAL_CALL disposing() override;
121 // XServiceInfo
122 virtual OUString SAL_CALL getImplementationName() override;
124 virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
126 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
128 // XConnection
129 css::uno::Reference<css::sdbc::XStatement> SAL_CALL createStatement() override;
131 css::uno::Reference<css::sdbc::XPreparedStatement>
132 SAL_CALL prepareStatement(const OUString& sql) override;
134 css::uno::Reference<css::sdbc::XPreparedStatement>
135 SAL_CALL prepareCall(const OUString& sql) override;
137 OUString SAL_CALL nativeSQL(const OUString& sql) override;
139 void SAL_CALL setAutoCommit(sal_Bool autoCommit) override;
141 sal_Bool SAL_CALL getAutoCommit() override;
143 void SAL_CALL commit() override;
145 void SAL_CALL rollback() override;
147 sal_Bool SAL_CALL isClosed() override;
149 css::uno::Reference<css::sdbc::XDatabaseMetaData> SAL_CALL getMetaData() override;
151 void SAL_CALL setReadOnly(sal_Bool readOnly) override;
153 sal_Bool SAL_CALL isReadOnly() override;
155 void SAL_CALL setCatalog(const OUString& catalog) override;
157 OUString SAL_CALL getCatalog() override;
159 void SAL_CALL setTransactionIsolation(sal_Int32 level) override;
161 sal_Int32 SAL_CALL getTransactionIsolation() override;
163 css::uno::Reference<css::container::XNameAccess> SAL_CALL getTypeMap() override;
165 void SAL_CALL
166 setTypeMap(const css::uno::Reference<css::container::XNameAccess>& typeMap) override;
167 // XCloseable
168 void SAL_CALL close() override;
169 // XWarningsSupplier
170 css::uno::Any SAL_CALL getWarnings() override;
171 void SAL_CALL clearWarnings() override;
173 // TODO: Not used
174 //sal_Int32 sdbcColumnType(OUString typeName);
175 const ConnectionSettings& getConnectionSettings() const { return m_settings; }
176 OUString transFormPreparedStatement(const OUString& _sSQL);
178 const MysqlCDriver& getDriver() const { return *m_xDriver; }
180 }; /* OConnection */
181 // TODO: Not used.
182 //inline OUString getPattern(OUString p) { return (p.getLength()) ? p : ASC2OU("%"); }
183 } /* mysqlc */
184 } /* connectivity */
185 #endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */