LCOV - code coverage report
Current view: top level - package/source/zipapi - ByteChucker.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 31 44 70.5 %
Date: 2014-04-11 Functions: 7 10 70.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 <ByteChucker.hxx>
      21             : #include <PackageConstants.hxx>
      22             : #include <com/sun/star/io/XSeekable.hpp>
      23             : #include <com/sun/star/io/XOutputStream.hpp>
      24             : 
      25             : using namespace ::com::sun::star::io;
      26             : using namespace ::com::sun::star::uno;
      27             : using namespace ::com::sun::star::lang;
      28             : 
      29         482 : ByteChucker::ByteChucker(Reference<XOutputStream> xOstream)
      30             : : xStream(xOstream)
      31             : , xSeek (xOstream, UNO_QUERY )
      32             : , a1Sequence ( 1 )
      33             : , a2Sequence ( 2 )
      34             : , a4Sequence ( 4 )
      35         482 : , p1Sequence ( a1Sequence.getArray() )
      36         482 : , p2Sequence ( a2Sequence.getArray() )
      37        1446 : , p4Sequence ( a4Sequence.getArray() )
      38             : {
      39         482 : }
      40             : 
      41         482 : ByteChucker::~ByteChucker()
      42             : {
      43         482 : }
      44             : 
      45      212820 : void ByteChucker::WriteBytes( const Sequence< sal_Int8 >& aData )
      46             :     throw(NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
      47             : {
      48      212820 :     xStream->writeBytes(aData);
      49      212820 : }
      50             : 
      51        7382 : sal_Int64 ByteChucker::GetPosition(  )
      52             :         throw(IOException, RuntimeException)
      53             : {
      54        7382 :     return xSeek->getPosition();
      55             : }
      56             : 
      57           0 : ByteChucker& ByteChucker::operator << (sal_Int8 nInt8)
      58             : {
      59           0 :     p1Sequence[0] = nInt8  & 0xFF;
      60           0 :     WriteBytes( a1Sequence );
      61           0 :     return *this;
      62             : }
      63             : 
      64       92262 : ByteChucker& ByteChucker::operator << (sal_Int16 nInt16)
      65             : {
      66       92262 :     p2Sequence[0] = static_cast< sal_Int8 >((nInt16 >>  0 ) & 0xFF);
      67       92262 :     p2Sequence[1] = static_cast< sal_Int8 >((nInt16 >>  8 ) & 0xFF);
      68       92262 :     WriteBytes( a2Sequence );
      69       92262 :     return *this;
      70             : }
      71       42760 : ByteChucker& ByteChucker::operator << (sal_Int32 nInt32)
      72             : {
      73       42760 :     p4Sequence[0] = static_cast< sal_Int8 >((nInt32 >>  0 ) & 0xFF);
      74       42760 :     p4Sequence[1] = static_cast< sal_Int8 >((nInt32 >>  8 ) & 0xFF);
      75       42760 :     p4Sequence[2] = static_cast< sal_Int8 >((nInt32 >> 16 ) & 0xFF);
      76       42760 :     p4Sequence[3] = static_cast< sal_Int8 >((nInt32 >> 24 ) & 0xFF);
      77       42760 :     WriteBytes( a4Sequence );
      78       42760 :     return *this;
      79             : }
      80             : 
      81           0 : ByteChucker& ByteChucker::operator << (sal_uInt8 nuInt8)
      82             : {
      83           0 :     p1Sequence[0] = nuInt8  & 0xFF;
      84           0 :     WriteBytes( a1Sequence );
      85           0 :     return *this;
      86             : }
      87           0 : ByteChucker& ByteChucker::operator << (sal_uInt16 nuInt16)
      88             : {
      89           0 :     p2Sequence[0] = static_cast< sal_Int8 >((nuInt16 >>  0 ) & 0xFF);
      90           0 :     p2Sequence[1] = static_cast< sal_Int8 >((nuInt16 >>  8 ) & 0xFF);
      91           0 :     WriteBytes( a2Sequence );
      92           0 :     return *this;
      93             : }
      94       58726 : ByteChucker& ByteChucker::operator << (sal_uInt32 nuInt32)
      95             : {
      96       58726 :     p4Sequence[0] = static_cast < sal_Int8 > ((nuInt32 >>  0 ) & 0xFF);
      97       58726 :     p4Sequence[1] = static_cast < sal_Int8 > ((nuInt32 >>  8 ) & 0xFF);
      98       58726 :     p4Sequence[2] = static_cast < sal_Int8 > ((nuInt32 >> 16 ) & 0xFF);
      99       58726 :     p4Sequence[3] = static_cast < sal_Int8 > ((nuInt32 >> 24 ) & 0xFF);
     100       58726 :     WriteBytes( a4Sequence );
     101       58726 :     return *this;
     102             : }
     103             : 
     104             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10