Branch data 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 : : * Version: MPL 1.1 / GPLv3+ / LGPLv2.1+
32 : : *
33 : : * The contents of this file are subject to the Mozilla Public License Version
34 : : * 1.1 (the "License"); you may not use this file except in compliance with
35 : : * the License or as specified alternatively below. You may obtain a copy of
36 : : * the License at http://www.mozilla.org/MPL/
37 : : *
38 : : * Software distributed under the License is distributed on an "AS IS" basis,
39 : : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
40 : : * for the specific language governing rights and limitations under the
41 : : * License.
42 : : *
43 : : * Major Contributor(s):
44 : : * [ Copyright (C) 2011 Lionel Elie Mamane <lionel@mamane.lu> ]
45 : : *
46 : : * All Rights Reserved.
47 : : *
48 : : * For minor contributions see the git repository.
49 : : *
50 : : * Alternatively, the contents of this file may be used under the terms of
51 : : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
52 : : * the GNU Lesser General Public License Version 2.1 or later (the "LGPLv2.1+"),
53 : : * in which case the provisions of the GPLv3+ or the LGPLv2.1+ are applicable
54 : : * instead of those above.
55 : : *
56 : : ************************************************************************/
57 : :
58 : : #ifndef _PG_BASERESULTSET_HXX_
59 : : #define _PG_BASERESULTSET_HXX_
60 : :
61 : : #include <cppuhelper/propshlp.hxx>
62 : : #include <cppuhelper/component.hxx>
63 : :
64 : : #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
65 : : #include <com/sun/star/sdbc/XRow.hpp>
66 : : #include <com/sun/star/sdbc/XCloseable.hpp>
67 : : #include <com/sun/star/sdbc/XColumnLocate.hpp>
68 : : #include "pq_connection.hxx"
69 : :
70 : : namespace pq_sdbc_driver
71 : : {
72 : :
73 : : static const sal_Int32 BASERESULTSET_CURSOR_NAME = 0;
74 : : static const sal_Int32 BASERESULTSET_ESCAPE_PROCESSING = 1;
75 : : static const sal_Int32 BASERESULTSET_FETCH_DIRECTION = 2;
76 : : static const sal_Int32 BASERESULTSET_FETCH_SIZE = 3;
77 : : static const sal_Int32 BASERESULTSET_IS_BOOKMARKABLE = 4;
78 : : static const sal_Int32 BASERESULTSET_RESULT_SET_CONCURRENCY = 5;
79 : : static const sal_Int32 BASERESULTSET_RESULT_SET_TYPE = 6;
80 : :
81 : : #define BASERESULTSET_SIZE 7
82 : :
83 : : class BaseResultSet : public cppu::OComponentHelper,
84 : : public cppu::OPropertySetHelper,
85 : : public com::sun::star::sdbc::XCloseable,
86 : : public com::sun::star::sdbc::XResultSetMetaDataSupplier,
87 : : public com::sun::star::sdbc::XResultSet,
88 : : public com::sun::star::sdbc::XRow,
89 : : public com::sun::star::sdbc::XColumnLocate
90 : : {
91 : : protected:
92 : : com::sun::star::uno::Any m_props[BASERESULTSET_SIZE];
93 : : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_owner;
94 : : com::sun::star::uno::Reference< com::sun::star::script::XTypeConverter > m_tc;
95 : : ::rtl::Reference< RefCountedMutex > m_refMutex;
96 : : sal_Int32 m_row;
97 : : sal_Int32 m_rowCount;
98 : : sal_Int32 m_fieldCount;
99 : : sal_Bool m_wasNull;
100 : :
101 : : public:
102 : : inline cppu::OBroadcastHelper & getRBHelper() { return OComponentHelper::rBHelper;}
103 : :
104 : : protected:
105 : : /** mutex should be locked before called
106 : : */
107 : : virtual void checkClosed()
108 : : throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException ) = 0;
109 : : virtual void checkColumnIndex( sal_Int32 index )
110 : : throw ( com::sun::star::sdbc::SQLException, com::sun::star::uno::RuntimeException );
111 : : virtual void checkRowIndex( sal_Bool mustBeOnValidRow );
112 : :
113 : : virtual ::com::sun::star::uno::Any getValue( sal_Int32 columnIndex ) = 0;
114 : : com::sun::star::uno::Any convertTo(
115 : : const ::com::sun::star::uno::Any &str, const com::sun::star::uno::Type &type );
116 : :
117 : : protected:
118 : : BaseResultSet(
119 : : const ::rtl::Reference< RefCountedMutex > & mutex,
120 : : const com::sun::star::uno::Reference< com::sun::star::uno::XInterface > &owner,
121 : : sal_Int32 rowCount,
122 : : sal_Int32 columnCount,
123 : : const ::com::sun::star::uno::Reference< ::com::sun::star::script::XTypeConverter > &tc );
124 : : ~BaseResultSet();
125 : :
126 : : public: // XInterface
127 : 0 : virtual void SAL_CALL acquire() throw() { OComponentHelper::acquire(); }
128 : 0 : virtual void SAL_CALL release() throw() { OComponentHelper::release(); }
129 : : virtual com::sun::star::uno::Any SAL_CALL queryInterface(
130 : : const com::sun::star::uno::Type & reqType )
131 : : throw (com::sun::star::uno::RuntimeException);
132 : :
133 : : public: // XCloseable
134 : : // virtual void SAL_CALL close( )
135 : : // throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
136 : :
137 : : public: // XTypeProvider, first implemented by OPropertySetHelper
138 : : virtual com::sun::star::uno::Sequence< com::sun::star::uno::Type > SAL_CALL getTypes()
139 : : throw( com::sun::star::uno::RuntimeException );
140 : : virtual com::sun::star::uno::Sequence< sal_Int8> SAL_CALL getImplementationId()
141 : : throw( com::sun::star::uno::RuntimeException );
142 : :
143 : : public: // XResultSetMetaDataSupplier
144 : : // virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( )
145 : : // throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
146 : :
147 : : public: // XResultSet
148 : : // Methods
149 : : virtual sal_Bool SAL_CALL next( )
150 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
151 : : virtual sal_Bool SAL_CALL isBeforeFirst( )
152 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
153 : : virtual sal_Bool SAL_CALL isAfterLast( )
154 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
155 : : virtual sal_Bool SAL_CALL isFirst( )
156 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
157 : : virtual sal_Bool SAL_CALL isLast( )
158 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
159 : : virtual void SAL_CALL beforeFirst( )
160 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
161 : : virtual void SAL_CALL afterLast( )
162 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
163 : : virtual sal_Bool SAL_CALL first( )
164 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
165 : : virtual sal_Bool SAL_CALL last( )
166 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
167 : : virtual sal_Int32 SAL_CALL getRow( )
168 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
169 : : virtual sal_Bool SAL_CALL absolute( sal_Int32 row )
170 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
171 : : virtual sal_Bool SAL_CALL relative( sal_Int32 rows )
172 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
173 : : virtual sal_Bool SAL_CALL previous( )
174 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
175 : : virtual void SAL_CALL refreshRow( )
176 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
177 : : virtual sal_Bool SAL_CALL rowUpdated( )
178 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
179 : : virtual sal_Bool SAL_CALL rowInserted( )
180 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
181 : : virtual sal_Bool SAL_CALL rowDeleted( )
182 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
183 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement()
184 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
185 : :
186 : :
187 : : public: // XRow
188 : : virtual sal_Bool SAL_CALL wasNull( )
189 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
190 : : virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex )
191 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
192 : : virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex )
193 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
194 : : virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex )
195 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
196 : : virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex )
197 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
198 : : virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex )
199 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
200 : : virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex )
201 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
202 : : virtual float SAL_CALL getFloat( sal_Int32 columnIndex )
203 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
204 : : virtual double SAL_CALL getDouble( sal_Int32 columnIndex )
205 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
206 : : virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex )
207 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
208 : : virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex )
209 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
210 : : virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex )
211 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
212 : : virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex )
213 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
214 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex )
215 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
216 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex )
217 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
218 : : virtual ::com::sun::star::uno::Any SAL_CALL getObject(
219 : : sal_Int32 columnIndex,
220 : : const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
221 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
222 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex )
223 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
224 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex )
225 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
226 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex )
227 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
228 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex )
229 : : throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
230 : :
231 : : public: // XColumnLocate
232 : : // virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName )
233 : : // throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) = 0;
234 : :
235 : : public: // OPropertySetHelper
236 : : virtual cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
237 : :
238 : : virtual sal_Bool SAL_CALL convertFastPropertyValue(
239 : : ::com::sun::star::uno::Any & rConvertedValue,
240 : : ::com::sun::star::uno::Any & rOldValue,
241 : : sal_Int32 nHandle,
242 : : const ::com::sun::star::uno::Any& rValue )
243 : : throw (::com::sun::star::lang::IllegalArgumentException);
244 : :
245 : : virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
246 : : sal_Int32 nHandle,
247 : : const ::com::sun::star::uno::Any& rValue )
248 : : throw (::com::sun::star::uno::Exception);
249 : :
250 : : using ::cppu::OPropertySetHelper::getFastPropertyValue;
251 : :
252 : : void SAL_CALL getFastPropertyValue(
253 : : ::com::sun::star::uno::Any& rValue,
254 : : sal_Int32 nHandle ) const;
255 : :
256 : : // XPropertySet
257 : : ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
258 : : throw(com::sun::star::uno::RuntimeException);
259 : :
260 : : public: // OComponentHelper
261 : : virtual void SAL_CALL disposing();
262 : :
263 : :
264 : : };
265 : :
266 : : }
267 : : #endif
|