LCOV - code coverage report
Current view: top level - connectivity/source/drivers/postgresql - pq_array.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 32 0.0 %
Date: 2014-04-14 Functions: 0 7 0.0 %
Legend: Lines: hit not hit

          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             :  *    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 <rtl/ustrbuf.hxx>
      38             : 
      39             : #include <com/sun/star/sdbc/XArray.hpp>
      40             : #include <com/sun/star/sdbc/DataType.hpp>
      41             : 
      42             : 
      43             : #include "pq_array.hxx"
      44             : #include "pq_statics.hxx"
      45             : #include "pq_sequenceresultset.hxx"
      46             : 
      47             : 
      48             : using com::sun::star::sdbc::SQLException;
      49             : using com::sun::star::uno::Any;
      50             : 
      51             : using com::sun::star::uno::Sequence;
      52             : namespace pq_sdbc_driver
      53             : {
      54             : 
      55             : 
      56           0 : OUString Array::getBaseTypeName(  )
      57             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
      58             : {
      59           0 :     return OUString( "varchar" );
      60             : }
      61             : 
      62           0 : sal_Int32 Array::getBaseType(  )
      63             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
      64             : {
      65           0 :     return  com::sun::star::sdbc::DataType::VARCHAR;
      66             : }
      67             : 
      68           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Array::getArray(
      69             :     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /* typeMap */ )
      70             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
      71             : {
      72           0 :     return m_data;
      73             : }
      74             : 
      75           0 : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > Array::getArrayAtIndex(
      76             :     sal_Int32 index,
      77             :     sal_Int32 count,
      78             :     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /* typeMap */ )
      79             :     throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
      80             : {
      81           0 :     checkRange( index, count );
      82           0 :     return Sequence< Any > ( &m_data[index-1], count );
      83             : }
      84             : 
      85           0 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > Array::getResultSet(
      86             :     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap )
      87             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
      88             : {
      89           0 :     return getResultSetAtIndex( 0 , m_data.getLength() , typeMap );
      90             : }
      91             : 
      92           0 : ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > Array::getResultSetAtIndex(
      93             :     sal_Int32 index,
      94             :     sal_Int32 count,
      95             :     const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& /* typeMap */ )
      96             :         throw (::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException, std::exception)
      97             : {
      98           0 :     checkRange( index, count );
      99           0 :     Sequence< Sequence< Any > > ret( count );
     100             : 
     101           0 :     for( int i = 0 ; i < count ; i ++ )
     102             :     {
     103           0 :         Sequence< Any > row( 2 );
     104           0 :         row[0] <<= (sal_Int32) ( i + index );
     105           0 :         row[1] = m_data[i+index-1];
     106           0 :         ret[i] = row;
     107           0 :     }
     108             : 
     109             :     return new SequenceResultSet(
     110           0 :         m_refMutex, m_owner, getStatics().resultSetArrayColumnNames, ret, m_tc );
     111             : }
     112             : 
     113             : 
     114           0 : void Array::checkRange( sal_Int32 index, sal_Int32 count )
     115             : {
     116           0 :     if( index >= 1 && index -1 + count <= m_data.getLength() )
     117           0 :         return;
     118           0 :     OUStringBuffer buf;
     119           0 :     buf.append( "Array::getArrayAtIndex(): allowed range for index + count " );
     120           0 :     buf.append( m_data.getLength() );
     121           0 :     buf.append( ", got " );
     122           0 :     buf.append( index );
     123           0 :     buf.append( " + " );
     124           0 :     buf.append( count );
     125             : 
     126           0 :     throw SQLException( buf.makeStringAndClear() , *this, OUString(), 1, Any());
     127             : 
     128             : }
     129             : 
     130             : }
     131             : 
     132             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10