bump product version to 7.2.5.1
[LibreOffice.git] / connectivity / source / drivers / mysqlc / mysqlc_prepared_resultset.hxx
blob018595b770badf22cdfe94f79d5c83f9993d0338
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_preparedstatement.hxx"
23 #include "mysqlc_statement.hxx"
24 #include "mysqlc_subcomponent.hxx"
25 #include "mysqlc_connection.hxx"
27 #include <com/sun/star/sdbc/XCloseable.hpp>
28 #include <com/sun/star/sdbc/XColumnLocate.hpp>
29 #include <com/sun/star/sdbc/XResultSet.hpp>
30 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
31 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
32 #include <com/sun/star/sdbc/XRow.hpp>
33 #include <com/sun/star/sdbc/XRowUpdate.hpp>
34 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
35 #include <com/sun/star/sdbcx/XDeleteRows.hpp>
36 #include <com/sun/star/sdbcx/XRowLocate.hpp>
37 #include <com/sun/star/util/XCancellable.hpp>
38 #include <connectivity/FValue.hxx>
40 #include <cppuhelper/compbase12.hxx>
42 namespace connectivity::mysqlc
44 using ::com::sun::star::sdbc::SQLException;
45 using ::com::sun::star::uno::Any;
46 using ::com::sun::star::uno::RuntimeException;
48 typedef ::cppu::WeakComponentImplHelper12<
49 css::sdbc::XResultSet, css::sdbc::XRow, css::sdbc::XResultSetMetaDataSupplier,
50 css::util::XCancellable, css::sdbc::XWarningsSupplier, css::sdbc::XResultSetUpdate,
51 css::sdbc::XRowUpdate, css::sdbcx::XRowLocate, css::sdbcx::XDeleteRows, css::sdbc::XCloseable,
52 css::sdbc::XColumnLocate, css::lang::XServiceInfo>
53 OPreparedResultSet_BASE;
55 class OPreparedResultSet final : public OBase_Mutex,
56 public OPreparedResultSet_BASE,
57 public ::cppu::OPropertySetHelper,
58 public OPropertyArrayUsageHelper<OPreparedResultSet>
60 OConnection& m_rConnection;
61 css::uno::WeakReferenceHelper m_aStatement;
62 css::uno::Reference<css::sdbc::XResultSetMetaData> m_xMetaData;
64 // non-owning pointers
65 MYSQL_RES* m_pResult;
66 MYSQL_STMT* m_pStmt;
67 MYSQL_FIELD* m_aFields;
69 rtl_TextEncoding m_encoding;
70 sal_Int32 m_nCurrentRow = 0;
71 sal_Int32 m_nColumnCount;
72 sal_Int32 m_nRowCount;
74 // Use c style arrays, because we have to work with pointers
75 // on these.
76 std::unique_ptr<MYSQL_BIND[]> m_aData;
77 std::unique_ptr<BindMetaData[]> m_aMetaData;
79 bool m_bWasNull = false;
81 // OPropertyArrayUsageHelper
82 ::cppu::IPropertyArrayHelper* createArrayHelper() const override;
83 // OPropertySetHelper
84 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
86 sal_Bool SAL_CALL convertFastPropertyValue(Any& rConvertedValue, Any& rOldValue,
87 sal_Int32 nHandle, const Any& rValue) override;
89 void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue) override;
91 void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const override;
93 template <typename T> T safelyRetrieveValue(const sal_Int32 nColumnIndex);
94 template <typename T> T retrieveValue(const sal_Int32 nColumnIndex);
95 connectivity::ORowSetValue getRowSetValue(sal_Int32 nColumnIndex);
97 bool fetchResult();
99 // you can't delete objects of this type
100 virtual ~OPreparedResultSet() override = default;
102 public:
103 virtual OUString SAL_CALL getImplementationName() override;
105 virtual sal_Bool SAL_CALL supportsService(OUString const& ServiceName) override;
107 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
109 OPreparedResultSet(OConnection& rConn, OPreparedStatement* pStmt, MYSQL_STMT* pMyStmt);
111 // ::cppu::OComponentHelper
112 void SAL_CALL disposing() override;
114 // XInterface
115 Any SAL_CALL queryInterface(const css::uno::Type& rType) override;
117 void SAL_CALL acquire() noexcept override;
118 void SAL_CALL release() noexcept override;
120 //XTypeProvider
121 css::uno::Sequence<css::uno::Type> SAL_CALL getTypes() override;
123 // XPropertySet
124 css::uno::Reference<css::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() override;
126 // XResultSet
127 sal_Bool SAL_CALL next() override;
128 sal_Bool SAL_CALL isBeforeFirst() override;
129 sal_Bool SAL_CALL isAfterLast() override;
130 sal_Bool SAL_CALL isFirst() override;
131 sal_Bool SAL_CALL isLast() override;
133 void SAL_CALL beforeFirst() override;
134 void SAL_CALL afterLast() override;
136 sal_Bool SAL_CALL first() override;
137 sal_Bool SAL_CALL last() override;
139 sal_Int32 SAL_CALL getRow() override;
141 sal_Bool SAL_CALL absolute(sal_Int32 row) override;
142 sal_Bool SAL_CALL relative(sal_Int32 rows) override;
143 sal_Bool SAL_CALL previous() override;
145 void SAL_CALL refreshRow() override;
147 sal_Bool SAL_CALL rowUpdated() override;
148 sal_Bool SAL_CALL rowInserted() override;
149 sal_Bool SAL_CALL rowDeleted() override;
151 css::uno::Reference<css::uno::XInterface> SAL_CALL getStatement() override;
152 // XRow
153 sal_Bool SAL_CALL wasNull() override;
155 OUString SAL_CALL getString(sal_Int32 column) override;
157 sal_Bool SAL_CALL getBoolean(sal_Int32 column) override;
158 sal_Int8 SAL_CALL getByte(sal_Int32 column) override;
159 sal_Int16 SAL_CALL getShort(sal_Int32 column) override;
160 sal_Int32 SAL_CALL getInt(sal_Int32 column) override;
161 sal_Int64 SAL_CALL getLong(sal_Int32 column) override;
163 float SAL_CALL getFloat(sal_Int32 column) override;
164 double SAL_CALL getDouble(sal_Int32 column) override;
166 css::uno::Sequence<sal_Int8> SAL_CALL getBytes(sal_Int32 column) override;
167 css::util::Date SAL_CALL getDate(sal_Int32 column) override;
168 css::util::Time SAL_CALL getTime(sal_Int32 column) override;
169 css::util::DateTime SAL_CALL getTimestamp(sal_Int32 column) override;
171 css::uno::Reference<css::io::XInputStream> SAL_CALL getBinaryStream(sal_Int32 column) override;
172 css::uno::Reference<css::io::XInputStream>
173 SAL_CALL getCharacterStream(sal_Int32 column) override;
175 Any SAL_CALL getObject(
176 sal_Int32 column, const css::uno::Reference<css::container::XNameAccess>& typeMap) override;
178 css::uno::Reference<css::sdbc::XRef> SAL_CALL getRef(sal_Int32 column) override;
179 css::uno::Reference<css::sdbc::XBlob> SAL_CALL getBlob(sal_Int32 column) override;
180 css::uno::Reference<css::sdbc::XClob> SAL_CALL getClob(sal_Int32 column) override;
181 css::uno::Reference<css::sdbc::XArray> SAL_CALL getArray(sal_Int32 column) override;
183 // XResultSetMetaDataSupplier
184 css::uno::Reference<css::sdbc::XResultSetMetaData> SAL_CALL getMetaData() override;
186 // XCancellable
187 void SAL_CALL cancel() override;
189 // XCloseable
190 void SAL_CALL close() override;
192 // XWarningsSupplier
193 Any SAL_CALL getWarnings() override;
195 void SAL_CALL clearWarnings() override;
197 // XResultSetUpdate
198 void SAL_CALL insertRow() override;
199 void SAL_CALL updateRow() override;
200 void SAL_CALL deleteRow() override;
201 void SAL_CALL cancelRowUpdates() override;
202 void SAL_CALL moveToInsertRow() override;
203 void SAL_CALL moveToCurrentRow() override;
205 // XRowUpdate
206 void SAL_CALL updateNull(sal_Int32 column) override;
207 void SAL_CALL updateBoolean(sal_Int32 column, sal_Bool x) override;
208 void SAL_CALL updateByte(sal_Int32 column, sal_Int8 x) override;
209 void SAL_CALL updateShort(sal_Int32 column, sal_Int16 x) override;
210 void SAL_CALL updateInt(sal_Int32 column, sal_Int32 x) override;
211 void SAL_CALL updateLong(sal_Int32 column, sal_Int64 x) override;
212 void SAL_CALL updateFloat(sal_Int32 column, float x) override;
213 void SAL_CALL updateDouble(sal_Int32 column, double x) override;
214 void SAL_CALL updateString(sal_Int32 column, const OUString& x) override;
215 void SAL_CALL updateBytes(sal_Int32 column, const css::uno::Sequence<sal_Int8>& x) override;
216 void SAL_CALL updateDate(sal_Int32 column, const css::util::Date& x) override;
217 void SAL_CALL updateTime(sal_Int32 column, const css::util::Time& x) override;
218 void SAL_CALL updateTimestamp(sal_Int32 column, const css::util::DateTime& x) override;
219 void SAL_CALL updateBinaryStream(sal_Int32 column,
220 const css::uno::Reference<css::io::XInputStream>& x,
221 sal_Int32 length) override;
222 void SAL_CALL updateCharacterStream(sal_Int32 column,
223 const css::uno::Reference<css::io::XInputStream>& x,
224 sal_Int32 length) override;
225 void SAL_CALL updateObject(sal_Int32 column, const Any& x) override;
226 void SAL_CALL updateNumericObject(sal_Int32 column, const Any& x, sal_Int32 scale) override;
228 // XColumnLocate
229 sal_Int32 SAL_CALL findColumn(const OUString& columnName) override;
231 // XRowLocate
232 Any SAL_CALL getBookmark() override;
234 sal_Bool SAL_CALL moveToBookmark(const Any& bookmark) override;
235 sal_Bool SAL_CALL moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) override;
236 sal_Int32 SAL_CALL compareBookmarks(const Any& first, const Any& second) override;
237 sal_Bool SAL_CALL hasOrderedBookmarks() override;
238 sal_Int32 SAL_CALL hashBookmark(const Any& bookmark) override;
240 // XDeleteRows
241 css::uno::Sequence<sal_Int32> SAL_CALL deleteRows(const css::uno::Sequence<Any>& rows) override;
243 /// @throws SQLException
244 /// @throws RuntimeException
245 void checkColumnIndex(sal_Int32 index);
247 private:
248 using ::cppu::OPropertySetHelper::getFastPropertyValue;
251 } /* connectivity::mysqlc */
253 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */