Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*************************************************************************
3 : *
4 : * Effective License of whole file:
5 : *
6 : * This library is free software; you can redistribute it and/or
7 : * modify it under the terms of the GNU Lesser General Public
8 : * License version 2.1, as published by the Free Software Foundation.
9 : *
10 : * This library is distributed in the hope that it will be useful,
11 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 : * Lesser General Public License for more details.
14 : *
15 : * You should have received a copy of the GNU Lesser General Public
16 : * License along with this library; if not, write to the Free Software
17 : * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 : * MA 02111-1307 USA
19 : *
20 : * Parts "Copyright by Sun Microsystems, Inc" prior to August 2011:
21 : *
22 : * The Contents of this file are made available subject to the terms of
23 : * the GNU Lesser General Public License Version 2.1
24 : *
25 : * Copyright: 2000 by Sun Microsystems, Inc.
26 : *
27 : * Contributor(s): Joerg Budischewski
28 : *
29 : * All parts contributed on or after August 2011:
30 : *
31 : * This Source Code Form is subject to the terms of the Mozilla Public
32 : * License, v. 2.0. If a copy of the MPL was not distributed with this
33 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
34 : *
35 : ************************************************************************/
36 :
37 : #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_BASERESULTSET_HXX
38 : #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_POSTGRESQL_PQ_BASERESULTSET_HXX
39 :
40 : #include <cppuhelper/propshlp.hxx>
41 : #include <cppuhelper/component.hxx>
42 :
43 : #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
44 : #include <com/sun/star/sdbc/XRow.hpp>
45 : #include <com/sun/star/sdbc/XCloseable.hpp>
46 : #include <com/sun/star/sdbc/XColumnLocate.hpp>
47 : #include "pq_connection.hxx"
48 :
49 : namespace pq_sdbc_driver
50 : {
51 :
52 : static const sal_Int32 BASERESULTSET_CURSOR_NAME = 0;
53 : static const sal_Int32 BASERESULTSET_ESCAPE_PROCESSING = 1;
54 : static const sal_Int32 BASERESULTSET_FETCH_DIRECTION = 2;
55 : static const sal_Int32 BASERESULTSET_FETCH_SIZE = 3;
56 : static const sal_Int32 BASERESULTSET_IS_BOOKMARKABLE = 4;
57 : static const sal_Int32 BASERESULTSET_RESULT_SET_CONCURRENCY = 5;
58 : static const sal_Int32 BASERESULTSET_RESULT_SET_TYPE = 6;
59 :
60 : #define BASERESULTSET_SIZE 7
61 :
62 : class BaseResultSet : public cppu::OComponentHelper,
63 : public cppu::OPropertySetHelper,
64 : public com::sun::star::sdbc::XCloseable,
65 : public com::sun::star::sdbc::XResultSetMetaDataSupplier,
66 : public com::sun::star::sdbc::XResultSet,
67 : public com::sun::star::sdbc::XRow,
68 : public com::sun::star::sdbc::XColumnLocate
69 : {
70 : protected:
71 : com::sun::star::uno::Any m_props[BASERESULTSET_SIZE];
72 : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_owner;
73 : com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > m_tc;
74 : ::rtl::Reference< RefCountedMutex > m_refMutex;
75 : sal_Int32 m_row;
76 : sal_Int32 m_rowCount;
77 : sal_Int32 m_fieldCount;
78 : bool m_wasNull;
79 :
80 : public:
81 : inline cppu::OBroadcastHelper & getRBHelper() { return OComponentHelper::rBHelper;}
82 :
83 : protected:
84 : /** mutex should be locked before called
85 : */
86 : virtual void checkClosed()
87 : throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException ) = 0;
88 : virtual void checkColumnIndex( sal_Int32 index )
89 : throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException );
90 : virtual void checkRowIndex( bool mustBeOnValidRow );
91 :
92 : virtual ::com::sun::star::uno::Any getValue( sal_Int32 columnIndex ) = 0;
93 : com::sun::star::uno::Any convertTo(
94 : const ::com::sun::star::uno::Any &str, const com::sun::star::uno::Type &type );
95 :
96 : protected:
97 : BaseResultSet(
98 : const ::rtl::Reference< RefCountedMutex > & mutex,
99 : const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
100 : sal_Int32 rowCount,
101 : sal_Int32 columnCount,
102 : const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > &tc );
103 : virtual ~BaseResultSet();
104 :
105 : public: // XInterface
106 0 : virtual void SAL_CALL acquire() throw() SAL_OVERRIDE { OComponentHelper::acquire(); }
107 0 : virtual void SAL_CALL release() throw() SAL_OVERRIDE { OComponentHelper::release(); }
108 : virtual com::sun::star::uno::Any SAL_CALL queryInterface(
109 : const com::sun::star::uno::Type & reqType )
110 : throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
111 :
112 : public: // XCloseable
113 : // virtual void SAL_CALL close( )
114 : // throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
115 :
116 : public: // XTypeProvider, first implemented by OPropertySetHelper
117 : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
118 : throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
119 : virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
120 : throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
121 :
122 : public: // XResultSetMetaDataSupplier
123 : // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
124 : // throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
125 :
126 : public: // XResultSet
127 : // Methods
128 : virtual sal_Bool SAL_CALL next( )
129 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
130 : virtual sal_Bool SAL_CALL isBeforeFirst( )
131 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
132 : virtual sal_Bool SAL_CALL isAfterLast( )
133 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
134 : virtual sal_Bool SAL_CALL isFirst( )
135 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
136 : virtual sal_Bool SAL_CALL isLast( )
137 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
138 : virtual void SAL_CALL beforeFirst( )
139 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
140 : virtual void SAL_CALL afterLast( )
141 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
142 : virtual sal_Bool SAL_CALL first( )
143 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
144 : virtual sal_Bool SAL_CALL last( )
145 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
146 : virtual sal_Int32 SAL_CALL getRow( )
147 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
148 : virtual sal_Bool SAL_CALL absolute( sal_Int32 row )
149 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
150 : virtual sal_Bool SAL_CALL relative( sal_Int32 rows )
151 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
152 : virtual sal_Bool SAL_CALL previous( )
153 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
154 : virtual void SAL_CALL refreshRow( )
155 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
156 : virtual sal_Bool SAL_CALL rowUpdated( )
157 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
158 : virtual sal_Bool SAL_CALL rowInserted( )
159 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
160 : virtual sal_Bool SAL_CALL rowDeleted( )
161 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
162 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement()
163 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
164 :
165 :
166 : public: // XRow
167 : virtual sal_Bool SAL_CALL wasNull( )
168 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
169 : virtual OUString SAL_CALL getString( sal_Int32 columnIndex )
170 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
171 : virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex )
172 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
173 : virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex )
174 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
175 : virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex )
176 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
177 : virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex )
178 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
179 : virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex )
180 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
181 : virtual float SAL_CALL getFloat( sal_Int32 columnIndex )
182 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
183 : virtual double SAL_CALL getDouble( sal_Int32 columnIndex )
184 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
185 : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex )
186 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
187 : virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex )
188 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
189 : virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex )
190 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
191 : virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex )
192 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
193 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex )
194 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
195 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex )
196 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
197 : virtual ::com::sun::star::uno::Any SAL_CALL getObject(
198 : sal_Int32 columnIndex,
199 : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
200 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
201 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex )
202 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
203 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex )
204 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
205 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex )
206 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
207 : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex )
208 : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
209 :
210 : public: // XColumnLocate
211 : // virtual sal_Int32 SAL_CALL findColumn( const OUString& columnName )
212 : // throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
213 :
214 : public: // OPropertySetHelper
215 : virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() SAL_OVERRIDE;
216 :
217 : virtual sal_Bool SAL_CALL convertFastPropertyValue(
218 : ::com::sun::star::uno::Any & rConvertedValue,
219 : ::com::sun::star::uno::Any & rOldValue,
220 : sal_Int32 nHandle,
221 : const ::com::sun::star::uno::Any& rValue )
222 : throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE;
223 :
224 : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
225 : sal_Int32 nHandle,
226 : const ::com::sun::star::uno::Any& rValue )
227 : throw (::com::sun::star::uno::Exception, std::exception) SAL_OVERRIDE;
228 :
229 : using ::cppu::OPropertySetHelper::getFastPropertyValue;
230 :
231 : void SAL_CALL getFastPropertyValue(
232 : ::com::sun::star::uno::Any& rValue,
233 : sal_Int32 nHandle ) const SAL_OVERRIDE;
234 :
235 : // XPropertySet
236 : ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
237 : throw(com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
238 :
239 : public: // OComponentHelper
240 : virtual void SAL_CALL disposing() SAL_OVERRIDE;
241 :
242 :
243 : };
244 :
245 : }
246 : #endif
247 :
248 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|