bump product version to 7.2.5.1
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_statement.hxx
blob14750309ad87941e72bfa7055b04314138647200
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 "mysqlc_connection.hxx"
23 #include "mysqlc_subcomponent.hxx"
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/sdbc/SQLWarning.hpp>
27 #include <com/sun/star/sdbc/XBatchExecution.hpp>
28 #include <com/sun/star/sdbc/XCloseable.hpp>
29 #include <com/sun/star/sdbc/XMultipleResults.hpp>
30 #include <com/sun/star/sdbc/XStatement.hpp>
31 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
32 #include <com/sun/star/util/XCancellable.hpp>
34 #include <cppuhelper/compbase3.hxx>
35 #include <rtl/ref.hxx>
37 namespace connectivity::mysqlc
39 using ::com::sun::star::sdbc::SQLException;
40 using ::com::sun::star::sdbc::SQLWarning;
41 using ::com::sun::star::uno::Any;
42 using ::com::sun::star::uno::RuntimeException;
43 using ::com::sun::star::uno::Type;
45 typedef ::cppu::WeakComponentImplHelper3<css::sdbc::XWarningsSupplier, css::util::XCancellable,
46 css::sdbc::XCloseable>
47 OCommonStatement_IBase;
49 //************ Class: OCommonStatement
50 // is a base class for the normal statement and for the prepared statement
52 class OCommonStatement : public OBase_Mutex,
53 public OCommonStatement_IBase,
54 public ::cppu::OPropertySetHelper,
55 public OPropertyArrayUsageHelper<OCommonStatement>
58 private:
59 SQLWarning m_aLastWarning;
61 protected:
62 rtl::Reference<OConnection> m_xConnection; // The owning Connection object
64 css::uno::Reference<css::sdbc::XResultSet> m_xResultSet;
66 // number of rows affected by an UPDATE, DELETE or INSERT statement.
67 sal_Int32 m_nAffectedRows = 0;
69 protected:
70 void closeResultSet();
72 // OPropertyArrayUsageHelper
73 ::cppu::IPropertyArrayHelper* createArrayHelper() const override;
75 // OPropertySetHelper
76 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
77 sal_Bool SAL_CALL convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue,
78 sal_Int32 nHandle, const Any& rValue) override;
80 void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) override;
82 void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const override;
83 virtual ~OCommonStatement() override;
85 protected:
86 OCommonStatement(OConnection* _pConnection);
88 public:
89 using OCommonStatement_IBase::rBHelper;
90 using OCommonStatement_IBase::operator css::uno::Reference<css::uno::XInterface>;
92 // OComponentHelper
93 void SAL_CALL disposing() override;
95 // XInterface
96 void SAL_CALL release() noexcept override;
97 void SAL_CALL acquire() noexcept override;
98 Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
100 //XTypeProvider
101 css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
103 // XPropertySet
104 css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
106 // XWarningsSupplier
107 Any SAL_CALL getWarnings() override;
109 void SAL_CALL clearWarnings() override;
111 // XCancellable
112 void SAL_CALL cancel() override;
114 // XCloseable
115 void SAL_CALL close() override;
117 // other methods
118 OConnection* getOwnConnection() const { return m_xConnection.get(); }
120 private:
121 using ::cppu::OPropertySetHelper::getFastPropertyValue;
124 typedef ::cppu::ImplHelper3<css::lang::XServiceInfo, css::sdbc::XMultipleResults,
125 css::sdbc::XStatement>
126 OStatement_BASE;
128 class OStatement final : public OCommonStatement, public OStatement_BASE
130 virtual ~OStatement() override = default;
132 bool getResult();
134 public:
135 // A constructor which is required for the return of the objects
136 OStatement(OConnection* _pConnection)
137 : OCommonStatement(_pConnection)
141 virtual OUString SAL_CALL getImplementationName() override;
143 virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
145 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
147 //XInterface
148 Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
149 void SAL_CALL acquire() noexcept override;
150 void SAL_CALL release() noexcept override;
152 //XTypeProvider
153 css::uno::Sequence<Type> SAL_CALL getTypes() override;
155 // XStatement
156 css::uno::Reference<css::sdbc::XResultSet> SAL_CALL executeQuery(const OUString& sql) override;
157 sal_Int32 SAL_CALL executeUpdate(const OUString& sql) override;
158 sal_Bool SAL_CALL execute(const OUString& sql) override;
159 css::uno::Reference<css::sdbc::XConnection> SAL_CALL getConnection() override;
161 // XMultipleResults
162 css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getResultSet() override;
163 sal_Int32 SAL_CALL getUpdateCount() override;
164 sal_Bool SAL_CALL getMoreResults() override;
166 // XBatchExecution
167 // void SAL_CALL addBatch(const OUString& sql) override;
169 // void SAL_CALL clearBatch() override;
171 // css::uno::Sequence<sal_Int32> SAL_CALL executeBatch() override;
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */