LCOV - code coverage report
Current view: top level - xmlscript/source/xml_helper - xml_byteseq.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 39 0.0 %
Date: 2014-04-14 Functions: 0 16 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             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <string.h>
      21             : 
      22             : #include <cppuhelper/implbase1.hxx>
      23             : #include <xmlscript/xml_helper.hxx>
      24             : 
      25             : using namespace osl;
      26             : using namespace com::sun::star;
      27             : using namespace com::sun::star::uno;
      28             : 
      29             : using ::rtl::ByteSequence;
      30             : 
      31             : namespace xmlscript
      32             : {
      33             : 
      34           0 : class BSeqInputStream
      35             :     : public ::cppu::WeakImplHelper1< io::XInputStream >
      36             : {
      37             :     ByteSequence _seq;
      38             :     sal_Int32 _nPos;
      39             : 
      40             : public:
      41           0 :     inline BSeqInputStream( ByteSequence const & rSeq )
      42             :         SAL_THROW(())
      43             :         : _seq( rSeq )
      44           0 :         , _nPos( 0 )
      45           0 :         {}
      46             : 
      47             :     // XInputStream
      48             :     virtual sal_Int32 SAL_CALL readBytes(
      49             :         Sequence< sal_Int8 > & rData, sal_Int32 nBytesToRead )
      50             :         throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException, std::exception) SAL_OVERRIDE;
      51             :     virtual sal_Int32 SAL_CALL readSomeBytes(
      52             :         Sequence< sal_Int8 > & rData, sal_Int32 nMaxBytesToRead )
      53             :         throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException, std::exception) SAL_OVERRIDE;
      54             :     virtual void SAL_CALL skipBytes(
      55             :         sal_Int32 nBytesToSkip )
      56             :         throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException, std::exception) SAL_OVERRIDE;
      57             :     virtual sal_Int32 SAL_CALL available()
      58             :         throw (io::NotConnectedException, io::IOException, RuntimeException, std::exception) SAL_OVERRIDE;
      59             :     virtual void SAL_CALL closeInput()
      60             :         throw (io::NotConnectedException, io::IOException, RuntimeException, std::exception) SAL_OVERRIDE;
      61             : };
      62             : 
      63           0 : sal_Int32 BSeqInputStream::readBytes(
      64             :     Sequence< sal_Int8 > & rData, sal_Int32 nBytesToRead )
      65             :     throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException, std::exception)
      66             : {
      67           0 :     nBytesToRead = ((nBytesToRead > _seq.getLength() - _nPos)
      68           0 :                     ? _seq.getLength() - _nPos
      69           0 :                     : nBytesToRead);
      70             : 
      71           0 :     ByteSequence aBytes( _seq.getConstArray() + _nPos, nBytesToRead );
      72           0 :     rData = toUnoSequence( aBytes );
      73           0 :     _nPos += nBytesToRead;
      74           0 :     return nBytesToRead;
      75             : }
      76             : 
      77           0 : sal_Int32 BSeqInputStream::readSomeBytes(
      78             :     Sequence< sal_Int8 > & rData, sal_Int32 nMaxBytesToRead )
      79             :     throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException, std::exception)
      80             : {
      81           0 :     return readBytes( rData, nMaxBytesToRead );
      82             : }
      83             : 
      84           0 : void BSeqInputStream::skipBytes(
      85             :     sal_Int32 /*nBytesToSkip*/ )
      86             :     throw (io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException, std::exception)
      87             : {
      88           0 : }
      89             : 
      90           0 : sal_Int32 BSeqInputStream::available()
      91             :     throw (io::NotConnectedException, io::IOException, RuntimeException, std::exception)
      92             : {
      93           0 :     return (_seq.getLength() - _nPos);
      94             : }
      95             : 
      96           0 : void BSeqInputStream::closeInput()
      97             :     throw (io::NotConnectedException, io::IOException, RuntimeException, std::exception)
      98             : {
      99           0 : }
     100             : 
     101           0 : class BSeqOutputStream
     102             :     : public ::cppu::WeakImplHelper1< io::XOutputStream >
     103             : {
     104             :     ByteSequence * _seq;
     105             : 
     106             : public:
     107           0 :     inline BSeqOutputStream( ByteSequence * seq )
     108             :         SAL_THROW(())
     109           0 :         : _seq( seq )
     110           0 :         {}
     111             : 
     112             :     // XOutputStream
     113             :     virtual void SAL_CALL writeBytes(
     114             :         Sequence< sal_Int8 > const & rData )
     115             :         throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException, std::exception) SAL_OVERRIDE;
     116             :     virtual void SAL_CALL flush()
     117             :         throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException, std::exception) SAL_OVERRIDE;
     118             :     virtual void SAL_CALL closeOutput()
     119             :         throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException, std::exception) SAL_OVERRIDE;
     120             : };
     121             : 
     122           0 : void BSeqOutputStream::writeBytes( Sequence< sal_Int8 > const & rData )
     123             :     throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException, std::exception)
     124             : {
     125           0 :     sal_Int32 nPos = _seq->getLength();
     126           0 :     _seq->realloc( nPos + rData.getLength() );
     127           0 :     memcpy( (char *)_seq->getArray() + nPos,
     128           0 :                       (char const *)rData.getConstArray(),
     129           0 :                       rData.getLength() );
     130           0 : }
     131           0 : void BSeqOutputStream::flush()
     132             :     throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException, std::exception)
     133             : {
     134           0 : }
     135             : 
     136           0 : void BSeqOutputStream::closeOutput()
     137             :     throw (io::NotConnectedException, io::BufferSizeExceededException, RuntimeException, std::exception)
     138             : {
     139           0 : }
     140             : 
     141           0 : Reference< io::XInputStream > SAL_CALL createInputStream( ByteSequence const & rInData )
     142             :     SAL_THROW(())
     143             : {
     144           0 :     return new BSeqInputStream( rInData );
     145             : }
     146             : 
     147           0 : Reference< io::XOutputStream > SAL_CALL createOutputStream( ByteSequence * pOutData )
     148             :     SAL_THROW(())
     149             : {
     150           0 :     return new BSeqOutputStream( pOutData );
     151             : }
     152             : 
     153             : }
     154             : 
     155             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10