LibreOffice Module connectivity (master) 1
pq_sequenceresultset.cxx
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: 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
40
42
43#include <com/sun/star/sdbc/SQLException.hpp>
44
45using com::sun::star::sdbc::XResultSetMetaData;
46
48using com::sun::star::uno::Any;
49
50namespace pq_sdbc_driver
51{
52
54{
55 // we never close :o)
56}
57
58
59Any SequenceResultSet::getValue( sal_Int32 columnIndex )
60{
61 m_wasNull = ! m_data[m_row][columnIndex -1 ].hasValue();
62 return m_data[m_row][columnIndex -1 ];
63}
64
66 const ::rtl::Reference< comphelper::RefCountedMutex > & mutex,
67 const css::uno::Reference< css::uno::XInterface > &owner,
68 std::vector< OUString >&& colNames,
69 std::vector< std::vector< Any > >&& data,
71 const ColumnMetaDataVector *pVec) :
72 BaseResultSet( mutex, owner, data.size(), colNames.size(), tc ),
73 m_data(std::move(data) ),
74 m_columnNames( std::move(colNames) )
75{
76 if( pVec )
77 {
78 m_meta = new SequenceResultSetMetaData( std::vector(*pVec), m_columnNames.size() );
79 }
80}
81
83{
84
85}
86
88{
89 // a noop
90}
91
93{
94 if( ! m_meta.is() )
95 {
96 // Oh no, not again
97 throw css::sdbc::SQLException(
98 "pq_sequenceresultset: no meta supported ", *this,
99 // I did not find "IM001" in a specific standard,
100 // but it seems to be used by other systems (such as ODBC)
101 // and some parts of LibreOffice special-case it.
102 "IM001", 1, Any() );
103 }
104 return m_meta;
105}
106
107
109 const OUString& columnName )
110{
111 // no need to guard, as all members are readonly !
112 for( int i = 0 ;i < m_fieldCount ; i ++ )
113 {
114 if( columnName == m_columnNames[i] )
115 {
116 return i+1;
117 }
118 }
120 assert(false);
121 return 0; // Never reached
122}
123}
124
125/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SequenceResultSet(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, const css::uno::Reference< css::script::XTypeConverter > &tc, const ColumnMetaDataVector *pVec=nullptr)
std::vector< std::vector< css::uno::Any > > m_data
virtual void checkClosed() override
mutex should be locked before called
virtual void SAL_CALL close() override
virtual sal_Int32 SAL_CALL findColumn(const OUString &columnName) override
virtual css::uno::Any getValue(sal_Int32 columnIndex) override
unchecked, acquire mutex before calling
css::uno::Reference< css::sdbc::XResultSetMetaData > m_meta
virtual css::uno::Reference< css::sdbc::XResultSetMetaData > SAL_CALL getMetaData() override
size
void throwInvalidColumnException(const OUString &_rColumnName, const Reference< XInterface > &_rxContext)
int i
std::vector< ColumnMetaData > ColumnMetaDataVector
Definition: pq_statics.hxx:88
const char * columnName
Definition: pq_statics.cxx:56
std::mutex mutex