LibreOffice Module connectivity (master) 1
mysqlc_statement.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include "mysqlc_connection.hxx"
24
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>
33
35#include <rtl/ref.hxx>
36
38{
39using ::com::sun::star::sdbc::SQLWarning;
40using ::com::sun::star::uno::Any;
41using ::com::sun::star::uno::Type;
42
43typedef ::cppu::WeakComponentImplHelper3<css::sdbc::XWarningsSupplier, css::util::XCancellable,
44 css::sdbc::XCloseable>
46
47//************ Class: OCommonStatement
48// is a base class for the normal statement and for the prepared statement
49
53 public OPropertyArrayUsageHelper<OCommonStatement>
54
55{
56private:
57 SQLWarning m_aLastWarning;
58
59protected:
60 rtl::Reference<OConnection> m_xConnection; // The owning Connection object
61
62 css::uno::Reference<css::sdbc::XResultSet> m_xResultSet;
63
64 // number of rows affected by an UPDATE, DELETE or INSERT statement.
65 sal_Int32 m_nAffectedRows = 0;
66
67protected:
68 void closeResultSet();
69
70 // OPropertyArrayUsageHelper
72
73 // OPropertySetHelper
75 sal_Bool SAL_CALL convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue,
76 sal_Int32 nHandle, const Any& rValue) override;
77
78 void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) override;
79
80 void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const override;
81 virtual ~OCommonStatement() override;
82
83protected:
84 OCommonStatement(OConnection* _pConnection);
85
86public:
87 using OCommonStatement_IBase::rBHelper;
88 using OCommonStatement_IBase::operator css::uno::Reference<css::uno::XInterface>;
89
90 // OComponentHelper
91 void SAL_CALL disposing() override;
92
93 // XInterface
94 void SAL_CALL release() noexcept override;
95 void SAL_CALL acquire() noexcept override;
96 Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
97
98 //XTypeProvider
99 css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
100
101 // XPropertySet
102 css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
103
104 // XWarningsSupplier
105 Any SAL_CALL getWarnings() override;
106
107 void SAL_CALL clearWarnings() override;
108
109 // XCancellable
110 void SAL_CALL cancel() override;
111
112 // XCloseable
113 void SAL_CALL close() override;
114
115 // other methods
116 OConnection* getOwnConnection() const { return m_xConnection.get(); }
117
118private:
119 using ::cppu::OPropertySetHelper::getFastPropertyValue;
120};
121
122typedef ::cppu::ImplHelper3<css::lang::XServiceInfo, css::sdbc::XMultipleResults,
123 css::sdbc::XStatement>
125
126class OStatement final : public OCommonStatement, public OStatement_BASE
127{
128 virtual ~OStatement() override = default;
129
130 bool getResult();
131
132public:
133 // A constructor which is required for the return of the objects
134 OStatement(OConnection* _pConnection)
135 : OCommonStatement(_pConnection)
136 {
137 }
138
139 virtual OUString SAL_CALL getImplementationName() override;
140
141 virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
142
143 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
144
145 //XInterface
146 Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
147 void SAL_CALL acquire() noexcept override;
148 void SAL_CALL release() noexcept override;
149
150 //XTypeProvider
151 css::uno::Sequence<Type> SAL_CALL getTypes() override;
152
153 // XStatement
154 css::uno::Reference<css::sdbc::XResultSet> SAL_CALL executeQuery(const OUString& sql) override;
155 sal_Int32 SAL_CALL executeUpdate(const OUString& sql) override;
156 sal_Bool SAL_CALL execute(const OUString& sql) override;
157 css::uno::Reference<css::sdbc::XConnection> SAL_CALL getConnection() override;
158
159 // XMultipleResults
160 css::uno::Reference<css::sdbc::XResultSet> SAL_CALL getResultSet() override;
161 sal_Int32 SAL_CALL getUpdateCount() override;
162 sal_Bool SAL_CALL getMoreResults() override;
163
164 // XBatchExecution
165 // void SAL_CALL addBatch(const OUString& sql) override;
166
167 // void SAL_CALL clearBatch() override;
168
169 // css::uno::Sequence<sal_Int32> SAL_CALL executeBatch() override;
170};
171}
172
173/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SAL_CALL getFastPropertyValue(Any &rValue, sal_Int32 nHandle) const override
OCommonStatement(OConnection *_pConnection)
void SAL_CALL acquire() noexcept override
Any SAL_CALL queryInterface(const css::uno::Type &rType) override
rtl::Reference< OConnection > m_xConnection
css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
css::uno::Reference< css::sdbc::XResultSet > m_xResultSet
::cppu::IPropertyArrayHelper * createArrayHelper() const override
used to implement the creation of the array helper which is shared amongst all instances of the class...
void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any &rValue) override
void SAL_CALL release() noexcept override
css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
::cppu::IPropertyArrayHelper &SAL_CALL getInfoHelper() override
sal_Bool SAL_CALL convertFastPropertyValue(Any &rConvertedValue, Any &rOldValue, sal_Int32 nHandle, const Any &rValue) override
sal_Int32 SAL_CALL getUpdateCount() override
css::uno::Reference< css::sdbc::XConnection > SAL_CALL getConnection() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OStatement(OConnection *_pConnection)
void SAL_CALL release() noexcept override
Any SAL_CALL queryInterface(const css::uno::Type &rType) override
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet() override
sal_Int32 SAL_CALL executeUpdate(const OUString &sql) override
virtual OUString SAL_CALL getImplementationName() override
virtual ~OStatement() override=default
css::uno::Reference< css::sdbc::XResultSet > SAL_CALL executeQuery(const OUString &sql) override
sal_Bool SAL_CALL getMoreResults() override
sal_Bool SAL_CALL execute(const OUString &sql) override
void SAL_CALL acquire() noexcept override
virtual sal_Bool SAL_CALL supportsService(OUString const &ServiceName) override
css::uno::Sequence< Type > SAL_CALL getTypes() override
Type
::cppu::ImplHelper3< css::lang::XServiceInfo, css::sdbc::XMultipleResults, css::sdbc::XStatement > OStatement_BASE
::cppu::WeakComponentImplHelper3< css::sdbc::XWarningsSupplier, css::util::XCancellable, css::sdbc::XCloseable > OCommonStatement_IBase
unsigned char sal_Bool