bump product version to 7.2.5.1
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_connection.hxx
blobc75be472465439242e0b9dfe3eb6a8aea5353d27
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 #pragma once
22 #include <memory>
23 #include "mysqlc_subcomponent.hxx"
24 #include "mysqlc_types.hxx"
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/lang/DisposedException.hpp>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/lang/XUnoTunnel.hpp>
30 #include <com/sun/star/sdbc/ColumnSearch.hpp>
31 #include <com/sun/star/sdbc/ColumnValue.hpp>
32 #include <com/sun/star/sdbc/DataType.hpp>
33 #include <com/sun/star/sdbc/SQLWarning.hpp>
34 #include <com/sun/star/sdbc/XConnection.hpp>
35 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
36 #include <com/sun/star/util/XStringSubstitution.hpp>
38 #include <cppuhelper/compbase3.hxx>
39 #include <cppuhelper/weakref.hxx>
40 #include <rtl/string.hxx>
41 #include <rtl/ref.hxx>
43 #include <mysql.h>
45 #include <map>
47 namespace sql
49 class SQLException;
52 namespace connectivity
54 class OMetaConnection;
55 class ODatabaseMetaData;
57 namespace mysqlc
59 using ::com::sun::star::sdbc::SQLException;
60 using ::com::sun::star::sdbc::SQLWarning;
61 using ::com::sun::star::uno::RuntimeException;
63 typedef ::cppu::WeakComponentImplHelper3<css::sdbc::XConnection, css::sdbc::XWarningsSupplier,
64 css::lang::XServiceInfo>
65 OMetaConnection_BASE;
67 struct ConnectionSettings
69 rtl_TextEncoding encoding;
70 OUString connectionURL;
71 bool readOnly;
72 ConnectionSettings()
73 : encoding(RTL_TEXTENCODING_DONTKNOW)
74 , readOnly(false)
79 class MysqlCDriver;
81 typedef OMetaConnection_BASE OConnection_BASE;
83 typedef std::vector<css::uno::WeakReferenceHelper> OWeakRefArray;
85 class OConnection final : public OBase_Mutex, public OConnection_BASE
87 private:
88 MYSQL m_mysql;
89 ConnectionSettings m_settings;
90 css::uno::Reference<css::container::XNameAccess> m_typeMap;
91 css::uno::Reference<css::util::XStringSubstitution> m_xParameterSubstitution;
93 // Data attributes
95 css::uno::WeakReference<css::sdbc::XDatabaseMetaData> m_xMetaData;
97 OWeakRefArray m_aStatements; // vector containing a list
98 // of all the Statement objects
99 // for this Connection
101 rtl::Reference<MysqlCDriver> m_xDriver; // Pointer to the owning driver object
102 public:
103 MYSQL* getMysqlConnection() { return &m_mysql; }
105 /// @throws SQLException
106 /// @throws RuntimeException
107 sal_Int32 getMysqlVersion();
109 /// @throws SQLException
110 void construct(const OUString& url, const css::uno::Sequence<css::beans::PropertyValue>& info);
112 OConnection(MysqlCDriver& _rDriver);
113 virtual ~OConnection() override;
115 rtl_TextEncoding getConnectionEncoding() const { return m_settings.encoding; }
117 // OComponentHelper
118 virtual void SAL_CALL disposing() override;
120 // XServiceInfo
121 virtual OUString SAL_CALL getImplementationName() override;
123 virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
125 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
127 // XConnection
128 css::uno::Reference<css::sdbc::XStatement> SAL_CALL createStatement() override;
130 css::uno::Reference<css::sdbc::XPreparedStatement>
131 SAL_CALL prepareStatement(const OUString& sql) override;
133 css::uno::Reference<css::sdbc::XPreparedStatement>
134 SAL_CALL prepareCall(const OUString& sql) override;
136 OUString SAL_CALL nativeSQL(const OUString& sql) override;
138 void SAL_CALL setAutoCommit(sal_Bool autoCommit) override;
140 sal_Bool SAL_CALL getAutoCommit() override;
142 void SAL_CALL commit() override;
144 void SAL_CALL rollback() override;
146 sal_Bool SAL_CALL isClosed() override;
148 css::uno::Reference<css::sdbc::XDatabaseMetaData> SAL_CALL getMetaData() override;
150 void SAL_CALL setReadOnly(sal_Bool readOnly) override;
152 sal_Bool SAL_CALL isReadOnly() override;
154 void SAL_CALL setCatalog(const OUString& catalog) override;
156 OUString SAL_CALL getCatalog() override;
158 void SAL_CALL setTransactionIsolation(sal_Int32 level) override;
160 sal_Int32 SAL_CALL getTransactionIsolation() override;
162 css::uno::Reference<css::container::XNameAccess> SAL_CALL getTypeMap() override;
164 void SAL_CALL
165 setTypeMap(const css::uno::Reference<css::container::XNameAccess>& typeMap) override;
166 // XCloseable
167 void SAL_CALL close() override;
168 // XWarningsSupplier
169 css::uno::Any SAL_CALL getWarnings() override;
170 void SAL_CALL clearWarnings() override;
172 // TODO: Not used
173 //sal_Int32 sdbcColumnType(OUString typeName);
174 const ConnectionSettings& getConnectionSettings() const { return m_settings; }
175 OUString transFormPreparedStatement(const OUString& _sSQL);
177 const MysqlCDriver& getDriver() const { return *m_xDriver; }
179 }; /* OConnection */
180 // TODO: Not used.
181 //inline OUString getPattern(OUString p) { return (p.getLength()) ? p : ASC2OU("%"); }
182 } /* mysqlc */
183 } /* connectivity */
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */