LibreOffice Module connectivity (master) 1
pq_array.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#include <com/sun/star/sdbc/SQLException.hpp>
38#include <com/sun/star/sdbc/DataType.hpp>
40
41
42#include "pq_array.hxx"
43#include "pq_statics.hxx"
45
46
47using com::sun::star::sdbc::SQLException;
48using com::sun::star::uno::Any;
49
52{
53
54
56{
57 return "varchar";
58}
59
61{
62 return css::sdbc::DataType::VARCHAR;
63}
64
65css::uno::Sequence< css::uno::Any > Array::getArray(
66 const css::uno::Reference< css::container::XNameAccess >& /* typeMap */ )
67{
69}
70
71css::uno::Sequence< css::uno::Any > Array::getArrayAtIndex(
72 sal_Int32 index,
73 sal_Int32 count,
74 const css::uno::Reference< css::container::XNameAccess >& /* typeMap */ )
75{
77 return Sequence< Any > ( &m_data[index-1], count );
78}
79
80css::uno::Reference< css::sdbc::XResultSet > Array::getResultSet(
81 const css::uno::Reference< css::container::XNameAccess >& typeMap )
82{
83 return getResultSetAtIndex( 0 , m_data.size() , typeMap );
84}
85
86css::uno::Reference< css::sdbc::XResultSet > Array::getResultSetAtIndex(
87 sal_Int32 index,
88 sal_Int32 count,
89 const css::uno::Reference< css::container::XNameAccess >& /* typeMap */ )
90{
92 std::vector< std::vector< Any > > ret( count );
93
94 for( int i = 0 ; i < count ; i ++ )
95 {
96 std::vector< Any > row( 2 );
97 row[0] <<= static_cast<sal_Int32>( i + index );
98 row[1] = m_data[i+index-1];
99 ret[i] = row;
100 }
101
102 return new SequenceResultSet(
103 m_xMutex, m_owner, std::vector(getStatics().resultSetArrayColumnNames), std::move(ret), m_tc );
104}
105
106
107void Array::checkRange( sal_Int32 index, sal_Int32 count )
108{
109 if( index >= 1 && index -1 + count <= static_cast<sal_Int32>(m_data.size()) )
110 return;
111 throw SQLException(
112 "Array::getArrayAtIndex(): allowed range for index + count "
113 + OUString::number( m_data.size() )
114 + ", got " + OUString::number( index )
115 + " + " + OUString::number( count ),
116 *this, OUString(), 1, Any());
117
118}
119
120}
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::script::XTypeConverter > m_tc
Definition: pq_array.hxx:52
void checkRange(sal_Int32 index, sal_Int32 count)
Definition: pq_array.cxx:107
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSet(const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: pq_array.cxx:80
virtual sal_Int32 SAL_CALL getBaseType() override
Definition: pq_array.cxx:60
virtual OUString SAL_CALL getBaseTypeName() override
Definition: pq_array.cxx:55
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getArray(const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: pq_array.cxx:65
css::uno::Reference< css::uno::XInterface > m_owner
Definition: pq_array.hxx:51
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getArrayAtIndex(sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: pq_array.cxx:71
std::vector< css::uno::Any > m_data
Definition: pq_array.hxx:50
virtual css::uno::Reference< css::sdbc::XResultSet > SAL_CALL getResultSetAtIndex(sal_Int32 index, sal_Int32 count, const css::uno::Reference< css::container::XNameAccess > &typeMap) override
Definition: pq_array.cxx:86
rtl::Reference< comphelper::RefCountedMutex > m_xMutex
Definition: pq_array.hxx:53
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
int i
index
Statics & getStatics()
Definition: pq_statics.cxx:112