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