xref: /AOO41X/main/mysqlc/source/mysqlc_resultset.hxx (revision 079eb5772d0a9e49bbf5c2cd738fc5b5d43e5181)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 #ifndef MYSQLC_SRESULTSET_HXX
23 #define MYSQLC_SRESULTSET_HXX
24 
25 #include "mysqlc_preparedstatement.hxx"
26 #include "mysqlc_statement.hxx"
27 #include "mysqlc_subcomponent.hxx"
28 
29 #include <com/sun/star/sdbc/XCloseable.hpp>
30 #include <com/sun/star/sdbc/XColumnLocate.hpp>
31 #include <com/sun/star/sdbc/XResultSet.hpp>
32 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
33 #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
34 #include <com/sun/star/sdbc/XRow.hpp>
35 #include <com/sun/star/sdbc/XRowUpdate.hpp>
36 #include <com/sun/star/sdbc/XWarningsSupplier.hpp>
37 #include <com/sun/star/sdbcx/XDeleteRows.hpp>
38 #include <com/sun/star/sdbcx/XRowLocate.hpp>
39 #include <com/sun/star/util/XCancellable.hpp>
40 
41 #include <cppuhelper/compbase12.hxx>
42 
43 
44 namespace connectivity
45 {
46     namespace mysqlc
47     {
48         using ::rtl::OUString;
49         using ::com::sun::star::sdbc::SQLException;
50         using ::com::sun::star::uno::RuntimeException;
51         using ::com::sun::star::uno::Any;
52         typedef ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > my_XInputStreamRef;
53         typedef my_XNameAccessRef my_XNameAccessRef;
54 
55         /*
56         **  OResultSet
57         */
58         typedef ::cppu::WeakComponentImplHelper12<  ::com::sun::star::sdbc::XResultSet,
59                                                     ::com::sun::star::sdbc::XRow,
60                                                     ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
61                                                     ::com::sun::star::util::XCancellable,
62                                                     ::com::sun::star::sdbc::XWarningsSupplier,
63                                                     ::com::sun::star::sdbc::XResultSetUpdate,
64                                                     ::com::sun::star::sdbc::XRowUpdate,
65                                                     ::com::sun::star::sdbcx::XRowLocate,
66                                                     ::com::sun::star::sdbcx::XDeleteRows,
67                                                     ::com::sun::star::sdbc::XCloseable,
68                                                     ::com::sun::star::sdbc::XColumnLocate,
69                                                     ::com::sun::star::lang::XServiceInfo> OResultSet_BASE;
70 
71         class OResultSet :  public  OBase_Mutex,
72                             public  OResultSet_BASE,
73                             public  ::cppu::OPropertySetHelper,
74                             public  OPropertyArrayUsageHelper<OResultSet>
75         {
76         protected:
77             ::com::sun::star::uno::WeakReferenceHelper  m_aStatement;
78             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
79             sql::ResultSet      *m_result;
80             unsigned int        fieldCount;
81             rtl_TextEncoding    m_encoding;
82             // OPropertyArrayUsageHelper
83             ::cppu::IPropertyArrayHelper* createArrayHelper() const;
84             // OPropertySetHelper
85             ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
86 
87             sal_Bool SAL_CALL convertFastPropertyValue(Any & rConvertedValue, Any & rOldValue, sal_Int32 nHandle, const Any& rValue)
88                         throw (::com::sun::star::lang::IllegalArgumentException);
89 
90             void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle, const Any& rValue)
91                         throw (::com::sun::star::uno::Exception);
92 
93             void SAL_CALL getFastPropertyValue(Any& rValue, sal_Int32 nHandle) const;
94 
95             // you can't delete objects of this type
96             virtual ~OResultSet();
97 
98         public:
99             DECLARE_SERVICE_INFO();
100 
101             OResultSet( OCommonStatement* pStmt, sql::ResultSet *result, rtl_TextEncoding _encoding );
102 
operator *()103             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
104             {
105                 return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this);
106             }
107 
108             // ::cppu::OComponentHelper
109             void SAL_CALL disposing();
110 
111             // XInterface
112             Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type & rType)
113                                                                         throw(RuntimeException);
114 
115             void SAL_CALL acquire()                                     throw();
116 
117             void SAL_CALL release()                                     throw();
118 
119             //XTypeProvider
120             ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
121                                                                         throw(RuntimeException);
122 
123             // XPropertySet
124             ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
125                                                                         throw(RuntimeException);
126 
127             // XResultSet
128             sal_Bool SAL_CALL next()                                    throw(SQLException, RuntimeException);
129 
130             sal_Bool SAL_CALL isBeforeFirst()                           throw(SQLException, RuntimeException);
131 
132             sal_Bool SAL_CALL isAfterLast()                             throw(SQLException, RuntimeException);
133 
134             sal_Bool SAL_CALL isFirst()                                 throw(SQLException, RuntimeException);
135 
136             sal_Bool SAL_CALL isLast()                                  throw(SQLException, RuntimeException);
137 
138             void SAL_CALL beforeFirst()                                 throw(SQLException, RuntimeException);
139 
140             void SAL_CALL afterLast()                                   throw(SQLException, RuntimeException);
141 
142             sal_Bool SAL_CALL first()                                   throw(SQLException, RuntimeException);
143 
144             sal_Bool SAL_CALL last()                                    throw(SQLException, RuntimeException);
145 
146             sal_Int32 SAL_CALL getRow()                                 throw(SQLException, RuntimeException);
147 
148             sal_Bool SAL_CALL absolute(sal_Int32 row)                   throw(SQLException, RuntimeException);
149 
150             sal_Bool SAL_CALL relative(sal_Int32 rows)                  throw(SQLException, RuntimeException);
151 
152             sal_Bool SAL_CALL previous()                                throw(SQLException, RuntimeException);
153 
154             void SAL_CALL refreshRow()                                  throw(SQLException, RuntimeException);
155 
156             sal_Bool SAL_CALL rowUpdated()                              throw(SQLException, RuntimeException);
157 
158             sal_Bool SAL_CALL rowInserted()                             throw(SQLException, RuntimeException);
159 
160             sal_Bool SAL_CALL rowDeleted()                              throw(SQLException, RuntimeException);
161 
162             ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement()
163                                                                         throw(SQLException, RuntimeException);
164             // XRow
165             sal_Bool SAL_CALL wasNull() throw(SQLException, RuntimeException);
166 
167             OUString SAL_CALL getString(sal_Int32 column)       throw(SQLException, RuntimeException);
168 
169             sal_Bool SAL_CALL getBoolean(sal_Int32 column)              throw(SQLException, RuntimeException);
170 
171             sal_Int8 SAL_CALL getByte(sal_Int32 column)                 throw(SQLException, RuntimeException);
172 
173             sal_Int16 SAL_CALL getShort(sal_Int32 column)               throw(SQLException, RuntimeException);
174 
175             sal_Int32 SAL_CALL getInt(sal_Int32 column)                 throw(SQLException, RuntimeException);
176 
177             sal_Int64 SAL_CALL getLong(sal_Int32 column)                throw(SQLException, RuntimeException);
178 
179             float SAL_CALL getFloat(sal_Int32 column)                   throw(SQLException, RuntimeException);
180 
181             double SAL_CALL getDouble(sal_Int32 column)                 throw(SQLException, RuntimeException);
182 
183             ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes(sal_Int32 column)
184                                                                         throw(SQLException, RuntimeException);
185 
186             ::com::sun::star::util::Date SAL_CALL getDate(sal_Int32 column)
187                                                                         throw(SQLException, RuntimeException);
188 
189             ::com::sun::star::util::Time SAL_CALL getTime(sal_Int32 column)
190                                                                         throw(SQLException, RuntimeException);
191 
192             ::com::sun::star::util::DateTime SAL_CALL getTimestamp(sal_Int32 column)
193                                                                         throw(SQLException, RuntimeException);
194 
195             my_XInputStreamRef SAL_CALL getBinaryStream(sal_Int32 column)
196                                                                         throw(SQLException, RuntimeException);
197 
198             my_XInputStreamRef SAL_CALL getCharacterStream(sal_Int32 column)
199                                                                         throw(SQLException, RuntimeException);
200 
201             Any SAL_CALL getObject(sal_Int32 column, const my_XNameAccessRef& typeMap)
202                                                                         throw(SQLException, RuntimeException);
203 
204             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef(sal_Int32 column)
205                                                                         throw(SQLException, RuntimeException);
206 
207             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob(sal_Int32 column)
208                                                                         throw(SQLException, RuntimeException);
209 
210             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob(sal_Int32 column)
211                                                                         throw(SQLException, RuntimeException);
212 
213             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray(sal_Int32 column)
214                                                                         throw(SQLException, RuntimeException);
215 
216             // XResultSetMetaDataSupplier
217             ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData()
218                                                                         throw(SQLException, RuntimeException);
219 
220             // XCancellable
221             void SAL_CALL cancel()                                      throw(RuntimeException);
222 
223             // XCloseable
224             void SAL_CALL close()                                       throw(SQLException, RuntimeException);
225 
226             // XWarningsSupplier
227             Any SAL_CALL getWarnings()                                  throw(SQLException, RuntimeException);
228 
229             void SAL_CALL clearWarnings()                               throw(SQLException, RuntimeException);
230 
231             // XResultSetUpdate
232             void SAL_CALL insertRow()                                   throw(SQLException, RuntimeException);
233 
234             void SAL_CALL updateRow()                                   throw(SQLException, RuntimeException);
235 
236             void SAL_CALL deleteRow()                                   throw(SQLException, RuntimeException);
237 
238             void SAL_CALL cancelRowUpdates()                            throw(SQLException, RuntimeException);
239 
240             void SAL_CALL moveToInsertRow()                             throw(SQLException, RuntimeException);
241 
242             void SAL_CALL moveToCurrentRow()                            throw(SQLException, RuntimeException);
243 
244             // XRowUpdate
245             void SAL_CALL updateNull(sal_Int32 column)                  throw(SQLException, RuntimeException);
246 
247             void SAL_CALL updateBoolean(sal_Int32 column, sal_Bool x)   throw(SQLException, RuntimeException);
248 
249             void SAL_CALL updateByte(sal_Int32 column, sal_Int8 x)      throw(SQLException, RuntimeException);
250 
251             void SAL_CALL updateShort(sal_Int32 column, sal_Int16 x)    throw(SQLException, RuntimeException);
252 
253             void SAL_CALL updateInt(sal_Int32 column, sal_Int32 x)      throw(SQLException, RuntimeException);
254 
255             void SAL_CALL updateLong(sal_Int32 column, sal_Int64 x)     throw(SQLException, RuntimeException);
256 
257             void SAL_CALL updateFloat(sal_Int32 column, float x)        throw(SQLException, RuntimeException);
258 
259             void SAL_CALL updateDouble(sal_Int32 column, double x)      throw(SQLException, RuntimeException);
260 
261             void SAL_CALL updateString(sal_Int32 column, const OUString& x)
262                                                                         throw(SQLException, RuntimeException);
263 
264             void SAL_CALL updateBytes(sal_Int32 column, const ::com::sun::star::uno::Sequence< sal_Int8 >& x)
265                                                                         throw(SQLException, RuntimeException);
266 
267             void SAL_CALL updateDate(sal_Int32 column, const ::com::sun::star::util::Date& x)
268                                                                         throw(SQLException, RuntimeException);
269 
270             void SAL_CALL updateTime(sal_Int32 column, const ::com::sun::star::util::Time& x)
271                                                                         throw(SQLException, RuntimeException);
272 
273             void SAL_CALL updateTimestamp(sal_Int32 column, const ::com::sun::star::util::DateTime& x)
274                                                                         throw(SQLException, RuntimeException);
275 
276             void SAL_CALL updateBinaryStream(sal_Int32 column, const my_XInputStreamRef& x, sal_Int32 length)
277                                                                         throw(SQLException, RuntimeException);
278 
279             void SAL_CALL updateCharacterStream(sal_Int32 column, const my_XInputStreamRef& x, sal_Int32 length)
280                                                                         throw(SQLException, RuntimeException);
281 
282             void SAL_CALL updateObject(sal_Int32 column, const Any& x)
283                                                                         throw(SQLException, RuntimeException);
284 
285             void SAL_CALL updateNumericObject(sal_Int32 column, const Any& x, sal_Int32 scale)
286                                                                         throw(SQLException, RuntimeException);
287 
288             // XColumnLocate
289             sal_Int32 SAL_CALL findColumn(const OUString& columnName)
290                                                                         throw(SQLException, RuntimeException);
291 
292             // XRowLocate
293             Any SAL_CALL getBookmark()                                  throw(SQLException, RuntimeException);
294 
295             sal_Bool SAL_CALL moveToBookmark(const Any& bookmark)
296                                                                         throw(SQLException, RuntimeException);
297 
298             sal_Bool SAL_CALL moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows)
299                                                                         throw(SQLException, RuntimeException);
300 
301             sal_Int32 SAL_CALL compareBookmarks(const Any& first, const Any& second)
302                                                                         throw(SQLException, RuntimeException);
303 
304             sal_Bool SAL_CALL hasOrderedBookmarks()                     throw(SQLException, RuntimeException);
305 
306             sal_Int32 SAL_CALL hashBookmark(const Any& bookmark)
307                                                                         throw(SQLException, RuntimeException);
308 
309             // XDeleteRows
310             ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows(const ::com::sun::star::uno::Sequence< Any >& rows)
311                                                                         throw(SQLException, RuntimeException);
312 
313             void checkColumnIndex(sal_Int32 index) throw(SQLException, RuntimeException);
314 
315         private:
316             using ::cppu::OPropertySetHelper::getFastPropertyValue;
317         };
318     } /* mysqlc */
319 } /* connectivity */
320 #endif // CONNECTIVITY_SRESULTSET_HXX
321 
322 /*
323  * Local variables:
324  * tab-width: 4
325  * c-basic-offset: 4
326  * End:
327  * vim600: noet sw=4 ts=4 fdm=marker
328  * vim<600: noet sw=4 ts=4
329  */
330