bump product version to 6.3.0.0.beta1
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_statement.hxx
blob9b0d3c952763fa6bb6b6434fe5e041e0fb89c45d
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_STATEMENT_HXX
21 #define INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
23 #include "mysqlc_connection.hxx"
24 #include "mysqlc_subcomponent.hxx"
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/sdbc/SQLWarning.hpp>
28 #include <com/sun/star/sdbc/XBatchExecution.hpp>
29 #include <com/sun/star/sdbc/XCloseable.hpp>
30 #include <com/sun/star/sdbc/XMultipleResults.hpp>
31 #include <com/sun/star/sdbc/XStatement.hpp>
32 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
33 #include <com/sun/star/util/XCancellable.hpp>
35 #include <cppuhelper/compbase5.hxx>
36 #include <rtl/ref.hxx>
38 namespace connectivity
40 namespace mysqlc
42 using ::com::sun::star::sdbc::SQLException;
43 using ::com::sun::star::sdbc::SQLWarning;
44 using ::com::sun::star::uno::Any;
45 using ::com::sun::star::uno::RuntimeException;
47 typedef ::cppu::WeakComponentImplHelper5<css::sdbc::XStatement, css::sdbc::XWarningsSupplier,
48 css::util::XCancellable, css::sdbc::XCloseable,
49 css::sdbc::XMultipleResults>
50 OCommonStatement_IBase;
52 //************ Class: OCommonStatement
53 // is a base class for the normal statement and for the prepared statement
55 class OCommonStatement : public OBase_Mutex,
56 public OCommonStatement_IBase,
57 public ::cppu::OPropertySetHelper,
58 public OPropertyArrayUsageHelper<OCommonStatement>
61 private:
62 SQLWarning m_aLastWarning;
64 protected:
65 rtl::Reference<OConnection> m_xConnection; // The owning Connection object
67 css::uno::Reference<css::sdbc::XResultSet> m_xResultSet;
68 MYSQL_RES* m_pMysqlResult = nullptr;
70 // number of rows affected by an UPDATE, DELETE or INSERT statement.
71 sal_Int32 m_nAffectedRows = 0;
73 protected:
74 void disposeResultSet();
76 // OPropertyArrayUsageHelper
77 ::cppu::IPropertyArrayHelper* createArrayHelper() const override;
79 // OPropertySetHelper
80 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
81 sal_Bool SAL_CALL convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue,
82 sal_Int32 nHandle, const Any& rValue) override;
84 void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) override;
86 void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const override;
87 virtual ~OCommonStatement() override;
89 protected:
90 OCommonStatement(OConnection* _pConnection);
92 public:
93 using OCommonStatement_IBase::rBHelper;
94 using OCommonStatement_IBase::operator css::uno::Reference<css::uno::XInterface>;
96 // OComponentHelper
97 void SAL_CALL disposing() override;
99 // XInterface
100 void SAL_CALL release() throw() override;
102 void SAL_CALL acquire() throw() override;
104 // XInterface
105 Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
107 //XTypeProvider
108 css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
110 // XPropertySet
111 css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
113 // XStatement
114 css::uno::Reference<css::sdbc::XResultSet> SAL_CALL executeQuery(const OUString& sql) override;
116 sal_Int32 SAL_CALL executeUpdate(const OUString& sql) override;
118 sal_Bool SAL_CALL execute(const OUString& sql) override;
120 css::uno::Reference<css::sdbc::XConnection> SAL_CALL getConnection() override;
122 // XWarningsSupplier
123 Any SAL_CALL getWarnings() override;
125 void SAL_CALL clearWarnings() override;
127 // XCancellable
128 void SAL_CALL cancel() override;
130 // XCloseable
131 void SAL_CALL close() override;
133 // XMultipleResults
134 css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getResultSet() override;
136 sal_Int32 SAL_CALL getUpdateCount() override;
138 sal_Bool SAL_CALL getMoreResults() override;
140 // other methods
141 OConnection* getOwnConnection() const { return m_xConnection.get(); }
143 private:
144 using ::cppu::OPropertySetHelper::getFastPropertyValue;
147 class OStatement final : public OCommonStatement,
148 public css::sdbc::XBatchExecution,
149 public css::lang::XServiceInfo
152 virtual ~OStatement() override = default;
154 public:
155 // A constructor which is required for the return of the objects
156 OStatement(OConnection* _pConnection)
157 : OCommonStatement(_pConnection)
161 virtual OUString SAL_CALL getImplementationName() override;
163 virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
165 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
167 Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
169 void SAL_CALL acquire() throw() override;
170 void SAL_CALL release() throw() override;
172 // XBatchExecution
173 void SAL_CALL addBatch(const OUString& sql) override;
175 void SAL_CALL clearBatch() override;
177 css::uno::Sequence<sal_Int32> SAL_CALL executeBatch() override;
181 #endif // INCLUDED_MYSQLC_SOURCE_MYSQLC_STATEMENT_HXX
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */