LCOV - code coverage report
Current view: top level - ucb/source/ucp/webdav-neon - NeonInputStream.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 44 0.0 %
Date: 2015-06-13 12:38:46 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 "NeonInputStream.hxx"
      30             : 
      31             : #include <cppuhelper/queryinterface.hxx>
      32             : 
      33             : #include <string.h>
      34             : 
      35             : using namespace cppu;
      36             : using namespace com::sun::star::io;
      37             : using namespace com::sun::star::uno;
      38             : using namespace webdav_ucp;
      39             : 
      40           0 : NeonInputStream::NeonInputStream()
      41             : : mLen( 0 ),
      42           0 :   mPos( 0 )
      43             : {
      44           0 : }
      45             : 
      46           0 : NeonInputStream::~NeonInputStream()
      47             : {
      48           0 : }
      49             : 
      50             : // Allows the caller to add some data to the "end" of the stream
      51           0 : void NeonInputStream::AddToStream( const char * inBuf, sal_Int32 inLen )
      52             : {
      53           0 :     mInputBuffer.realloc( sal::static_int_cast<sal_Int32>(mLen) + inLen );
      54           0 :     memcpy( mInputBuffer.getArray() + mLen, inBuf, inLen );
      55           0 :     mLen += inLen;
      56           0 : }
      57             : 
      58           0 : Any NeonInputStream::queryInterface( const Type &type )
      59             :                         throw( RuntimeException, std::exception )
      60             : {
      61             :     Any aRet = ::cppu::queryInterface( type,
      62             :                                        static_cast< XInputStream * >( this ),
      63           0 :                                        static_cast< XSeekable * >( this ) );
      64           0 :     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( type );
      65             : }
      66             : 
      67             : // "Reads" the specified number of bytes from the stream
      68           0 : sal_Int32 SAL_CALL NeonInputStream::readBytes(
      69             :   ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
      70             :         throw( ::com::sun::star::io::NotConnectedException,
      71             :                ::com::sun::star::io::BufferSizeExceededException,
      72             :                ::com::sun::star::io::IOException,
      73             :                ::com::sun::star::uno::RuntimeException, std::exception )
      74             : {
      75             :     // Work out how much we're actually going to write
      76           0 :     sal_Int32 theBytes2Read = nBytesToRead;
      77           0 :     sal_Int32 theBytesLeft  = sal::static_int_cast<sal_Int32>(mLen - mPos);
      78           0 :     if ( theBytes2Read > theBytesLeft )
      79           0 :         theBytes2Read = theBytesLeft;
      80             : 
      81             :     // Realloc buffer.
      82           0 :     aData.realloc( theBytes2Read );
      83             : 
      84             :     // Write the data
      85             :     memcpy(
      86           0 :         aData.getArray(), mInputBuffer.getConstArray() + mPos, theBytes2Read );
      87             : 
      88             :     // Update our stream position for next time
      89           0 :     mPos += theBytes2Read;
      90             : 
      91           0 :     return theBytes2Read;
      92             : }
      93             : 
      94           0 : sal_Int32 SAL_CALL NeonInputStream::readSomeBytes(
      95             :  ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
      96             :         throw( ::com::sun::star::io::NotConnectedException,
      97             :                ::com::sun::star::io::BufferSizeExceededException,
      98             :                ::com::sun::star::io::IOException,
      99             :                ::com::sun::star::uno::RuntimeException, std::exception )
     100             : {
     101             :     // Warning: What should this be doing ?
     102           0 :     return readBytes( aData, nMaxBytesToRead );
     103             : }
     104             : 
     105             : // Moves the current stream position forward
     106           0 : void SAL_CALL NeonInputStream::skipBytes( sal_Int32 nBytesToSkip )
     107             :         throw( ::com::sun::star::io::NotConnectedException,
     108             :                ::com::sun::star::io::BufferSizeExceededException,
     109             :                ::com::sun::star::io::IOException,
     110             :                ::com::sun::star::uno::RuntimeException, std::exception )
     111             : {
     112           0 :     mPos += nBytesToSkip;
     113           0 :     if ( mPos >= mLen )
     114           0 :         mPos = mLen;
     115           0 : }
     116             : 
     117             : // Returns the number of unread bytes currently remaining on the stream
     118           0 : sal_Int32 SAL_CALL NeonInputStream::available(  )
     119             :         throw( ::com::sun::star::io::NotConnectedException,
     120             :                ::com::sun::star::io::IOException,
     121             :                ::com::sun::star::uno::RuntimeException, std::exception )
     122             : {
     123           0 :     return sal::static_int_cast<sal_Int32>(mLen - mPos);
     124             : }
     125             : 
     126           0 : void SAL_CALL NeonInputStream::closeInput()
     127             :          throw( ::com::sun::star::io::NotConnectedException,
     128             :                   ::com::sun::star::io::IOException,
     129             :                   ::com::sun::star::uno::RuntimeException, std::exception )
     130             : {
     131           0 : }
     132             : 
     133           0 : void SAL_CALL NeonInputStream::seek( sal_Int64 location )
     134             :         throw( ::com::sun::star::lang::IllegalArgumentException,
     135             :                ::com::sun::star::io::IOException,
     136             :                ::com::sun::star::uno::RuntimeException, std::exception )
     137             : {
     138           0 :     if ( location < 0 )
     139           0 :         throw ::com::sun::star::lang::IllegalArgumentException();
     140             : 
     141           0 :     if ( location <= mLen )
     142           0 :         mPos = location;
     143             :     else
     144           0 :         throw ::com::sun::star::lang::IllegalArgumentException();
     145           0 : }
     146             : 
     147           0 : sal_Int64 SAL_CALL NeonInputStream::getPosition()
     148             :         throw( ::com::sun::star::io::IOException,
     149             :                ::com::sun::star::uno::RuntimeException, std::exception )
     150             : {
     151           0 :     return mPos;
     152             : }
     153             : 
     154           0 : sal_Int64 SAL_CALL NeonInputStream::getLength()
     155             :         throw( ::com::sun::star::io::IOException,
     156             :                ::com::sun::star::uno::RuntimeException, std::exception )
     157             : {
     158           0 :     return mLen;
     159             : }
     160             : 
     161             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11