bump product version to 5.0.4.1
[LibreOffice.git] / mysqlc / source / mysqlc_connection.hxx
blobaeb968693f7ee5f75811af8b7bb062f4cb183ca4
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 "mysqlc_subcomponent.hxx"
24 #include "mysqlc_types.hxx"
26 #include <boost/shared_ptr.hpp>
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 <cppconn/driver.h>
41 #include <cppuhelper/compbase3.hxx>
42 #include <cppuhelper/weakref.hxx>
43 #include <rtl/string.hxx>
45 #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::SQLWarning;
61 using ::com::sun::star::sdbc::SQLException;
62 using ::com::sun::star::uno::RuntimeException;
63 typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > my_XStatementRef;
64 typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > my_XPreparedStatementRef;
65 typedef ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > my_XNameAccessRef;
66 typedef ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > my_XDatabaseMetaDataRef;
68 typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection,
69 ::com::sun::star::sdbc::XWarningsSupplier,
70 ::com::sun::star::lang::XServiceInfo
71 > OMetaConnection_BASE;
72 struct ConnectionSettings
74 rtl_TextEncoding encoding;
75 std::unique_ptr<sql::Connection> cppConnection;
76 rtl::OUString schema;
77 rtl::OUString quoteIdentifier;
78 rtl::OUString connectionURL;
79 bool readOnly;
82 class MysqlCDriver;
84 typedef OMetaConnection_BASE OConnection_BASE;
86 typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
88 class OConnection : public OBase_Mutex,
89 public OConnection_BASE,
90 public connectivity::mysqlc::OSubComponent<OConnection, OConnection_BASE>
92 friend class connectivity::mysqlc::OSubComponent<OConnection, OConnection_BASE>;
94 private:
95 ConnectionSettings m_settings;
97 private:
98 ::com::sun::star::uno::Reference< com::sun::star::container::XNameAccess > m_typeMap;
99 ::com::sun::star::uno::Reference< com::sun::star::util::XStringSubstitution > m_xParameterSubstitution;
100 protected:
103 // Data attributes
105 ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
107 OWeakRefArray m_aStatements; // vector containing a list
108 // of all the Statement objects
109 // for this Connection
111 SQLWarning m_aLastWarning; // Last SQLWarning generated by an operation
112 rtl::OUString m_aURL; // URL of connection
113 rtl::OUString m_sUser; // the user name
114 MysqlCDriver& m_rDriver; // Pointer to the owning driver object
115 sql::Driver* cppDriver;
117 bool m_bClosed;
118 bool m_bUseCatalog; // should we use the catalog on filebased databases
119 bool m_bUseOldDateFormat;
121 public:
122 rtl::OUString getMysqlVariable(const char *varname)
123 throw(SQLException, RuntimeException);
125 sal_Int32 getMysqlVersion()
126 throw(SQLException, RuntimeException);
128 virtual void construct(const rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info)
129 throw(SQLException);
131 OConnection(MysqlCDriver& _rDriver, sql::Driver * cppDriver);
132 virtual ~OConnection();
134 rtl_TextEncoding getConnectionEncoding() { return m_settings.encoding; }
137 // OComponentHelper
138 virtual void SAL_CALL disposing() SAL_OVERRIDE;
140 // XInterface
141 virtual void SAL_CALL release() throw() SAL_OVERRIDE;
143 // XServiceInfo
144 virtual rtl::OUString SAL_CALL getImplementationName()
145 throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
147 virtual sal_Bool SAL_CALL supportsService(
148 rtl::OUString const & ServiceName) throw (css::uno::RuntimeException, std::exception)
149 SAL_OVERRIDE;
151 virtual css::uno::Sequence<rtl::OUString> SAL_CALL
152 getSupportedServiceNames() throw (css::uno::RuntimeException, std::exception)
153 SAL_OVERRIDE;
155 // XConnection
156 my_XStatementRef SAL_CALL createStatement()
157 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
159 my_XPreparedStatementRef SAL_CALL prepareStatement(const rtl::OUString& sql)
160 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
162 my_XPreparedStatementRef SAL_CALL prepareCall(const rtl::OUString& sql)
163 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
165 rtl::OUString SAL_CALL nativeSQL(const rtl::OUString& sql)
166 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
168 void SAL_CALL setAutoCommit(sal_Bool autoCommit)
169 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
171 sal_Bool SAL_CALL getAutoCommit()
172 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
174 void SAL_CALL commit()
175 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
177 void SAL_CALL rollback()
178 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
180 sal_Bool SAL_CALL isClosed()
181 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
183 my_XDatabaseMetaDataRef SAL_CALL getMetaData()
184 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
186 void SAL_CALL setReadOnly(sal_Bool readOnly)
187 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
189 sal_Bool SAL_CALL isReadOnly()
190 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
192 void SAL_CALL setCatalog(const rtl::OUString& catalog)
193 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
195 rtl::OUString SAL_CALL getCatalog()
196 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
198 void SAL_CALL setTransactionIsolation(sal_Int32 level)
199 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
201 sal_Int32 SAL_CALL getTransactionIsolation()
202 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
204 my_XNameAccessRef SAL_CALL getTypeMap()
205 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
207 void SAL_CALL setTypeMap(const my_XNameAccessRef& typeMap)
208 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
209 // XCloseable
210 void SAL_CALL close()
211 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
212 // XWarningsSupplier
213 ::com::sun::star::uno::Any SAL_CALL getWarnings()
214 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
215 void SAL_CALL clearWarnings()
216 throw(SQLException, RuntimeException, std::exception) SAL_OVERRIDE;
218 // TODO: Not used
219 //sal_Int32 sdbcColumnType(rtl::OUString typeName);
220 inline const ConnectionSettings& getConnectionSettings() const { return m_settings; }
221 rtl::OUString transFormPreparedStatement(const rtl::OUString& _sSQL);
223 // should we use the catalog on filebased databases
224 inline bool isCatalogUsed() const { return m_bUseCatalog; }
225 inline rtl::OUString getUserName() const { return m_sUser; }
226 inline const MysqlCDriver& getDriver() const { return m_rDriver;}
227 inline rtl_TextEncoding getTextEncoding() const { return m_settings.encoding; }
229 }; /* OConnection */
230 // TODO: Not used.
231 //inline rtl::OUString getPattern(rtl::OUString p) { return (p.getLength()) ? p : ASC2OU("%"); }
232 } /* mysqlc */
233 } /* connectivity */
234 #endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_CONNECTION_HXX
237 * Local variables:
238 * tab-width: 4
239 * c-basic-offset: 4
240 * End:
241 * vim600: noet sw=4 ts=4 fdm=marker
242 * vim<600: noet sw=4 ts=4
245 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */