LibreOffice Module connectivity (master) 1
pq_updateableresultset.hxx
Go to the documentation of this file.
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: 200? 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#pragma once
38
41
42#include <com/sun/star/sdbc/FetchDirection.hpp>
43#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
44#include <com/sun/star/sdbc/ResultSetType.hpp>
45#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
46#include <com/sun/star/sdbc/XRowUpdate.hpp>
47#include <utility>
48
49namespace pq_sdbc_driver
50{
51
53{
55 : isTouched(false)
56 {}
57 css::uno::Any value;
59};
60
61typedef std::vector< UpdateableField > UpdateableFieldVector;
62
64 public SequenceResultSet,
65 public css::sdbc::XResultSetUpdate,
66 public css::sdbc::XRowUpdate
67{
69 OUString m_schema;
70 OUString m_table;
71 std::vector< OUString > m_primaryKey;
74
75private:
77 const ::rtl::Reference< comphelper::RefCountedMutex > & mutex,
78 const css::uno::Reference< css::uno::XInterface > &owner,
79 std::vector< OUString >&& colNames,
80 std::vector< std::vector< css::uno::Any > >&& data,
81 ConnectionSettings **ppSettings,
82 OUString schema,
83 OUString table,
84 std::vector< OUString >&& primaryKey)
85 : SequenceResultSet( mutex, owner, std::move(colNames), std::move(data), (*ppSettings)->tc ),
86 m_ppSettings( ppSettings ),
87 m_schema(std::move( schema )),
88 m_table(std::move( table )),
89 m_primaryKey( std::move(primaryKey) ),
90 m_insertRow( false )
91 {
92 // LEM TODO: this duplicates code in pq_resultset.cxx, except for different value
93 // of ResultSetConcurrency. Baaad.
94 // Why is an updatable ResultSet a sequenceresultset in the first place?
95 // This seems to imply that the whole data is fetched once and kept in memory. BAAAAD.
96 // LEM TODO: shouldn't these things be inherited from the statement or something like that?
97 // Positioned update/delete not supported, so no cursor name
98 // Fetch direction and size are cursor-specific things, so not used now.
99 // Fetch size not set
100 m_props[ BASERESULTSET_FETCH_DIRECTION ] <<= css::sdbc::FetchDirection::UNKNOWN;
101 // No escape processing for now
103 // Bookmarks not implemented for now
106 css::sdbc::ResultSetConcurrency::UPDATABLE;
108 css::sdbc::ResultSetType::SCROLL_INSENSITIVE;
109 }
110
111 OUString buildWhereClause();
112 void checkUpdate( sal_Int32 column );
113
114public:
115 static css::uno::Reference< css::sdbc::XCloseable > createFromPGResultSet(
116 const ::rtl::Reference< comphelper::RefCountedMutex > & mutex,
117 const css::uno::Reference< css::uno::XInterface > &owner,
118 ConnectionSettings **ppSettings,
119 PGresult *result,
120 const OUString &schema,
121 const OUString &table,
122 std::vector< OUString > && primaryKey );
123
124public: // XInterface
125 virtual void SAL_CALL acquire() noexcept override { SequenceResultSet::acquire(); }
126 virtual void SAL_CALL release() noexcept override { SequenceResultSet::release(); }
127 virtual css::uno::Any SAL_CALL queryInterface(
128 const css::uno::Type & reqType ) override;
129
130public: // XTypeProvider
131 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override;
132 virtual css::uno::Sequence< sal_Int8> SAL_CALL getImplementationId() override;
133
134public: // XResultSetUpdate
135 virtual void SAL_CALL insertRow( ) override;
136 virtual void SAL_CALL updateRow( ) override;
137 virtual void SAL_CALL deleteRow( ) override;
138 virtual void SAL_CALL cancelRowUpdates( ) override;
139 virtual void SAL_CALL moveToInsertRow( ) override;
140 virtual void SAL_CALL moveToCurrentRow( ) override;
141
142public: // XRowUpdate
143 virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) override;
144 virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) override;
145 virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) override;
146 virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) override;
147 virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) override;
148 virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) override;
149 virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) override;
150 virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) override;
151 virtual void SAL_CALL updateString( sal_Int32 columnIndex, const OUString& x ) override;
152 virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 >& x ) override;
153 virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const css::util::Date& x ) override;
154 virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const css::util::Time& x ) override;
155 virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const css::util::DateTime& x ) override;
156 virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override;
157 virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream >& x, sal_Int32 length ) override;
158 virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const css::uno::Any& x ) override;
159 virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const css::uno::Any& x, sal_Int32 scale ) override;
160
161public:
163 static css::uno::Sequence< css::uno::Type > getStaticTypes( bool updateable );
164
165};
166
167
168}
169
170/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL release() noexcept override
css::uno::Any m_props[BASERESULTSET_SIZE]
static css::uno::Reference< css::sdbc::XCloseable > createFromPGResultSet(const ::rtl::Reference< comphelper::RefCountedMutex > &mutex, const css::uno::Reference< css::uno::XInterface > &owner, ConnectionSettings **ppSettings, PGresult *result, const OUString &schema, const OUString &table, std::vector< OUString > &&primaryKey)
virtual void SAL_CALL updateString(sal_Int32 columnIndex, const OUString &x) override
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &reqType) override
virtual void SAL_CALL updateDouble(sal_Int32 columnIndex, double x) override
virtual void SAL_CALL updateRow() override
virtual void SAL_CALL updateNumericObject(sal_Int32 columnIndex, const css::uno::Any &x, sal_Int32 scale) override
virtual void SAL_CALL moveToCurrentRow() override
UpdateableResultSet(const ::rtl::Reference< comphelper::RefCountedMutex > &mutex, const css::uno::Reference< css::uno::XInterface > &owner, std::vector< OUString > &&colNames, std::vector< std::vector< css::uno::Any > > &&data, ConnectionSettings **ppSettings, OUString schema, OUString table, std::vector< OUString > &&primaryKey)
virtual void SAL_CALL updateByte(sal_Int32 columnIndex, sal_Int8 x) override
static css::uno::Sequence< css::uno::Type > getStaticTypes(bool updateable)
virtual void SAL_CALL updateTimestamp(sal_Int32 columnIndex, const css::util::DateTime &x) override
virtual void SAL_CALL updateCharacterStream(sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL updateObject(sal_Int32 columnIndex, const css::uno::Any &x) override
virtual void SAL_CALL deleteRow() override
virtual void SAL_CALL cancelRowUpdates() override
virtual void SAL_CALL updateDate(sal_Int32 columnIndex, const css::util::Date &x) override
virtual void SAL_CALL updateBoolean(sal_Int32 columnIndex, sal_Bool x) override
virtual void SAL_CALL updateInt(sal_Int32 columnIndex, sal_Int32 x) override
virtual void SAL_CALL insertRow() override
virtual void SAL_CALL updateLong(sal_Int32 columnIndex, sal_Int64 x) override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL updateFloat(sal_Int32 columnIndex, float x) override
virtual void SAL_CALL updateShort(sal_Int32 columnIndex, sal_Int16 x) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual void SAL_CALL moveToInsertRow() override
virtual void SAL_CALL updateBinaryStream(sal_Int32 columnIndex, const css::uno::Reference< css::io::XInputStream > &x, sal_Int32 length) override
virtual void SAL_CALL updateTime(sal_Int32 columnIndex, const css::util::Time &x) override
virtual void SAL_CALL updateNull(sal_Int32 columnIndex) override
virtual void SAL_CALL updateBytes(sal_Int32 columnIndex, const css::uno::Sequence< sal_Int8 > &x) override
@ table
const sal_Int32 BASERESULTSET_RESULT_SET_CONCURRENCY
const sal_Int32 BASERESULTSET_FETCH_DIRECTION
const sal_Int32 BASERESULTSET_IS_BOOKMARKABLE
std::vector< UpdateableField > UpdateableFieldVector
const sal_Int32 BASERESULTSET_RESULT_SET_TYPE
const sal_Int32 BASERESULTSET_ESCAPE_PROCESSING
sal_Int32 scale
Definition: pq_statics.cxx:62
std::mutex mutex
unsigned char sal_Bool
signed char sal_Int8