LCOV - code coverage report
Current view: top level - libreoffice/ucb/source/ucp/webdav-neon - NeonInputStream.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 44 0.0 %
Date: 2012-12-27 Functions: 0 13 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             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #include <string.h>
      30             : 
      31             : #include "NeonInputStream.hxx"
      32             : 
      33             : using namespace cppu;
      34             : using namespace com::sun::star::io;
      35             : using namespace com::sun::star::uno;
      36             : using namespace webdav_ucp;
      37             : 
      38             : // -------------------------------------------------------------------
      39             : // Constructor
      40             : // -------------------------------------------------------------------
      41           0 : NeonInputStream::NeonInputStream( void )
      42             : : mLen( 0 ),
      43           0 :   mPos( 0 )
      44             : {
      45           0 : }
      46             : 
      47             : // -------------------------------------------------------------------
      48             : // Destructor
      49             : // -------------------------------------------------------------------
      50           0 : NeonInputStream::~NeonInputStream( void )
      51             : {
      52           0 : }
      53             : 
      54             : // -------------------------------------------------------------------
      55             : // AddToStream
      56             : // Allows the caller to add some data to the "end" of the stream
      57             : // -------------------------------------------------------------------
      58           0 : void NeonInputStream::AddToStream( const char * inBuf, sal_Int32 inLen )
      59             : {
      60           0 :     mInputBuffer.realloc( sal::static_int_cast<sal_Int32>(mLen) + inLen );
      61           0 :     memcpy( mInputBuffer.getArray() + mLen, inBuf, inLen );
      62           0 :     mLen += inLen;
      63           0 : }
      64             : 
      65             : // -------------------------------------------------------------------
      66             : // queryInterface
      67             : // -------------------------------------------------------------------
      68           0 : Any NeonInputStream::queryInterface( const Type &type )
      69             :                         throw( RuntimeException )
      70             : {
      71             :     Any aRet = ::cppu::queryInterface( type,
      72             :                                        static_cast< XInputStream * >( this ),
      73           0 :                                        static_cast< XSeekable * >( this ) );
      74           0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( type );
      75             : }
      76             : 
      77             : // -------------------------------------------------------------------
      78             : // readBytes
      79             : // "Reads" the specified number of bytes from the stream
      80             : // -------------------------------------------------------------------
      81           0 : sal_Int32 SAL_CALL NeonInputStream::readBytes(
      82             :   ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
      83             :         throw( ::com::sun::star::io::NotConnectedException,
      84             :                ::com::sun::star::io::BufferSizeExceededException,
      85             :                ::com::sun::star::io::IOException,
      86             :                ::com::sun::star::uno::RuntimeException )
      87             : {
      88             :     // Work out how much we're actually going to write
      89           0 :     sal_Int32 theBytes2Read = nBytesToRead;
      90           0 :     sal_Int32 theBytesLeft  = sal::static_int_cast<sal_Int32>(mLen - mPos);
      91           0 :     if ( theBytes2Read > theBytesLeft )
      92           0 :         theBytes2Read = theBytesLeft;
      93             : 
      94             :     // Realloc buffer.
      95           0 :     aData.realloc( theBytes2Read );
      96             : 
      97             :     // Write the data
      98             :     memcpy(
      99           0 :         aData.getArray(), mInputBuffer.getConstArray() + mPos, theBytes2Read );
     100             : 
     101             :     // Update our stream position for next time
     102           0 :     mPos += theBytes2Read;
     103             : 
     104           0 :     return theBytes2Read;
     105             : }
     106             : 
     107             : // -------------------------------------------------------------------
     108             : // readSomeBytes
     109             : // -------------------------------------------------------------------
     110           0 : sal_Int32 SAL_CALL NeonInputStream::readSomeBytes(
     111             :  ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
     112             :         throw( ::com::sun::star::io::NotConnectedException,
     113             :                ::com::sun::star::io::BufferSizeExceededException,
     114             :                ::com::sun::star::io::IOException,
     115             :                ::com::sun::star::uno::RuntimeException )
     116             : {
     117             :     // Warning: What should this be doing ?
     118           0 :     return readBytes( aData, nMaxBytesToRead );
     119             : }
     120             : 
     121             : // -------------------------------------------------------------------
     122             : // skipBytes
     123             : // Moves the current stream position forward
     124             : // -------------------------------------------------------------------
     125           0 : void SAL_CALL NeonInputStream::skipBytes( sal_Int32 nBytesToSkip )
     126             :         throw( ::com::sun::star::io::NotConnectedException,
     127             :                ::com::sun::star::io::BufferSizeExceededException,
     128             :                ::com::sun::star::io::IOException,
     129             :                ::com::sun::star::uno::RuntimeException )
     130             : {
     131           0 :     mPos += nBytesToSkip;
     132           0 :     if ( mPos >= mLen )
     133           0 :         mPos = mLen;
     134           0 : }
     135             : 
     136             : // -------------------------------------------------------------------
     137             : // available
     138             : // Returns the number of unread bytes currently remaining on the stream
     139             : // -------------------------------------------------------------------
     140           0 : sal_Int32 SAL_CALL NeonInputStream::available(  )
     141             :         throw( ::com::sun::star::io::NotConnectedException,
     142             :                ::com::sun::star::io::IOException,
     143             :                ::com::sun::star::uno::RuntimeException )
     144             : {
     145           0 :     return sal::static_int_cast<sal_Int32>(mLen - mPos);
     146             : }
     147             : 
     148             : // -------------------------------------------------------------------
     149             : // closeInput
     150             : // -------------------------------------------------------------------
     151           0 : void SAL_CALL NeonInputStream::closeInput( void )
     152             :          throw( ::com::sun::star::io::NotConnectedException,
     153             :                   ::com::sun::star::io::IOException,
     154             :                   ::com::sun::star::uno::RuntimeException )
     155             : {
     156           0 : }
     157             : 
     158             : // -------------------------------------------------------------------
     159             : // seek
     160             : // -------------------------------------------------------------------
     161           0 : void SAL_CALL NeonInputStream::seek( sal_Int64 location )
     162             :         throw( ::com::sun::star::lang::IllegalArgumentException,
     163             :                ::com::sun::star::io::IOException,
     164             :                ::com::sun::star::uno::RuntimeException )
     165             : {
     166           0 :     if ( location < 0 )
     167           0 :         throw ::com::sun::star::lang::IllegalArgumentException();
     168             : 
     169           0 :     if ( location <= mLen )
     170           0 :         mPos = location;
     171             :     else
     172           0 :         throw ::com::sun::star::lang::IllegalArgumentException();
     173           0 : }
     174             : 
     175             : // -------------------------------------------------------------------
     176             : // getPosition
     177             : // -------------------------------------------------------------------
     178           0 : sal_Int64 SAL_CALL NeonInputStream::getPosition()
     179             :         throw( ::com::sun::star::io::IOException,
     180             :                ::com::sun::star::uno::RuntimeException )
     181             : {
     182           0 :     return mPos;
     183             : }
     184             : 
     185             : // -------------------------------------------------------------------
     186             : // getLength
     187             : // -------------------------------------------------------------------
     188           0 : sal_Int64 SAL_CALL NeonInputStream::getLength()
     189             :         throw( ::com::sun::star::io::IOException,
     190             :                ::com::sun::star::uno::RuntimeException )
     191             : {
     192           0 :     return mLen;
     193             : }
     194             : 
     195             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10