1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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 .
22 #include "Connection.hxx"
26 #include <connectivity/FValue.hxx>
27 #include <cppuhelper/compbase.hxx>
28 #include <comphelper/proparrhlp.hxx>
29 #include <comphelper/propertycontainer.hxx>
31 #include <com/sun/star/util/XCancellable.hpp>
32 #include <com/sun/star/sdbc/XCloseable.hpp>
33 #include <com/sun/star/sdbc/XColumnLocate.hpp>
34 #include <com/sun/star/sdbc/XResultSet.hpp>
35 #include <com/sun/star/sdbc/XRow.hpp>
36 #include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
38 namespace connectivity::firebird
43 typedef ::cppu::WeakComponentImplHelper
< css::sdbc::XResultSet
,
45 css::sdbc::XResultSetMetaDataSupplier
,
46 css::util::XCancellable
,
47 css::sdbc::XCloseable
,
48 css::sdbc::XColumnLocate
,
49 css::lang::XServiceInfo
> OResultSet_BASE
;
52 * This ResultSet does not deal with the management of the SQLDA
53 * it is supplied with. The owner must mange its SQLDA appropriately
54 * and ensure that the ResultSet is destroyed before disposing of the
57 class OResultSet
: public OResultSet_BASE
,
58 public ::comphelper::OPropertyContainer
,
59 public ::comphelper::OPropertyArrayUsageHelper
<OResultSet
>
62 bool m_bIsBookmarkable
;
63 sal_Int32 m_nFetchSize
;
64 sal_Int32 m_nResultSetType
;
65 sal_Int32 m_nFetchDirection
;
66 sal_Int32 m_nResultSetConcurrency
;
69 // Connection kept alive by m_xStatement
70 Connection
* m_pConnection
;
71 ::osl::Mutex
& m_rMutex
;
72 const css::uno::Reference
< css::uno::XInterface
>& m_xStatement
;
74 css::uno::Reference
< css::sdbc::XResultSetMetaData
> m_xMetaData
;
77 isc_stmt_handle m_statementHandle
;
80 // Row numbering starts with 0 for "in front of first row"
81 sal_Int32 m_currentRow
;
82 bool m_bIsAfterLastRow
;
84 const sal_Int32 m_fieldCount
;
85 ISC_STATUS_ARRAY m_statusVector
;
87 bool isNull(const sal_Int32 nColumnIndex
);
89 template <typename T
> OUString
makeNumericString(
90 const sal_Int32 nColumnIndex
);
92 template <typename T
> T
retrieveValue(const sal_Int32 nColumnIndex
,
93 const ISC_SHORT nType
);
95 template <typename T
> T
safelyRetrieveValue(
96 const sal_Int32 nColumnIndex
,
97 const ISC_SHORT nType
= 0);
99 // OIdPropertyArrayUsageHelper
100 virtual ::cppu::IPropertyArrayHelper
* createArrayHelper() const override
;
101 virtual ::cppu::IPropertyArrayHelper
& SAL_CALL
getInfoHelper() override
;
103 /// @throws css::sdbc::SQLException
104 /// @throws css::uno::RuntimeException
105 void checkColumnIndex( sal_Int32 index
);
106 /// @throws css::sdbc::SQLException
107 /// @throws css::uno::RuntimeException
108 void checkRowIndex();
110 // you can't delete objects of this type
111 virtual ~OResultSet() override
;
113 DECLARE_SERVICE_INFO();
115 OResultSet(Connection
* pConnection
,
116 ::osl::Mutex
& rMutex
,
117 const css::uno::Reference
< css::uno::XInterface
>& xStatement
,
118 isc_stmt_handle aStatementHandle
,
123 virtual css::uno::Any SAL_CALL
queryInterface(
124 const css::uno::Type
& rType
) override
;
125 virtual void SAL_CALL
acquire() noexcept override
;
126 virtual void SAL_CALL
release() noexcept override
;
128 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
130 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo( ) override
;
132 virtual sal_Bool SAL_CALL
next( ) override
;
133 virtual sal_Bool SAL_CALL
isBeforeFirst( ) override
;
134 virtual sal_Bool SAL_CALL
isAfterLast( ) override
;
135 virtual sal_Bool SAL_CALL
isFirst( ) override
;
136 virtual sal_Bool SAL_CALL
isLast( ) override
;
137 virtual void SAL_CALL
beforeFirst( ) override
;
138 virtual void SAL_CALL
afterLast( ) override
;
139 virtual sal_Bool SAL_CALL
first( ) override
;
140 virtual sal_Bool SAL_CALL
last( ) override
;
141 virtual sal_Int32 SAL_CALL
getRow( ) override
;
142 virtual sal_Bool SAL_CALL
absolute( sal_Int32 row
) override
;
143 virtual sal_Bool SAL_CALL
relative( sal_Int32 rows
) override
;
144 virtual sal_Bool SAL_CALL
previous( ) override
;
145 virtual void SAL_CALL
refreshRow( ) override
;
146 virtual sal_Bool SAL_CALL
rowUpdated( ) override
;
147 virtual sal_Bool SAL_CALL
rowInserted( ) override
;
148 virtual sal_Bool SAL_CALL
rowDeleted( ) override
;
149 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getStatement( ) override
;
151 virtual sal_Bool SAL_CALL
wasNull( ) override
;
152 virtual OUString SAL_CALL
getString( sal_Int32 columnIndex
) override
;
153 virtual sal_Bool SAL_CALL
getBoolean( sal_Int32 columnIndex
) override
;
154 virtual sal_Int8 SAL_CALL
getByte( sal_Int32 columnIndex
) override
;
155 virtual sal_Int16 SAL_CALL
getShort( sal_Int32 columnIndex
) override
;
156 virtual sal_Int32 SAL_CALL
getInt( sal_Int32 columnIndex
) override
;
157 virtual sal_Int64 SAL_CALL
getLong( sal_Int32 columnIndex
) override
;
158 virtual float SAL_CALL
getFloat( sal_Int32 columnIndex
) override
;
159 virtual double SAL_CALL
getDouble( sal_Int32 columnIndex
) override
;
160 virtual css::uno::Sequence
< sal_Int8
> SAL_CALL
getBytes( sal_Int32 columnIndex
) override
;
161 virtual css::util::Date SAL_CALL
getDate( sal_Int32 columnIndex
) override
;
162 virtual css::util::Time SAL_CALL
getTime( sal_Int32 columnIndex
) override
;
163 virtual css::util::DateTime SAL_CALL
getTimestamp( sal_Int32 columnIndex
) override
;
164 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getBinaryStream( sal_Int32 columnIndex
) override
;
165 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getCharacterStream( sal_Int32 columnIndex
) override
;
166 virtual css::uno::Any SAL_CALL
getObject( sal_Int32 columnIndex
, const css::uno::Reference
< css::container::XNameAccess
>& typeMap
) override
;
167 virtual css::uno::Reference
< css::sdbc::XRef
> SAL_CALL
getRef( sal_Int32 columnIndex
) override
;
168 virtual css::uno::Reference
< css::sdbc::XBlob
> SAL_CALL
getBlob( sal_Int32 columnIndex
) override
;
169 virtual css::uno::Reference
< css::sdbc::XClob
> SAL_CALL
getClob( sal_Int32 columnIndex
) override
;
170 virtual css::uno::Reference
< css::sdbc::XArray
> SAL_CALL
getArray( sal_Int32 columnIndex
) override
;
171 // XResultSetMetaDataSupplier
172 virtual css::uno::Reference
< css::sdbc::XResultSetMetaData
> SAL_CALL
getMetaData( ) override
;
174 virtual void SAL_CALL
cancel( ) override
;
176 virtual void SAL_CALL
close( ) override
;
180 virtual sal_Int32 SAL_CALL
findColumn(const OUString
& columnName
) override
;
184 // Specialisations have to be in the namespace and can't be within the class.
185 template <> css::util::Date
186 OResultSet::retrieveValue(
187 const sal_Int32 nColumnIndex
,
188 const ISC_SHORT nType
);
189 template <> ::connectivity::ORowSetValue
190 OResultSet::retrieveValue(
191 const sal_Int32 nColumnIndex
,
192 const ISC_SHORT nType
);
193 template <> css::util::Time
194 OResultSet::retrieveValue(
195 const sal_Int32 nColumnIndex
,
196 const ISC_SHORT nType
);
197 template <> css::util::DateTime
198 OResultSet::retrieveValue(
199 const sal_Int32 nColumnIndex
,
200 const ISC_SHORT nType
);
201 template <> ISC_QUAD
*
202 OResultSet::retrieveValue(
203 const sal_Int32 nColumnIndex
,
204 const ISC_SHORT nType
);
206 OResultSet::retrieveValue(
207 const sal_Int32 nColumnIndex
,
208 const ISC_SHORT nType
);
209 template <> ISC_QUAD
*
210 OResultSet::retrieveValue(
211 const sal_Int32 nColumnIndex
,
212 const ISC_SHORT nType
);
216 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */