LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/io/source/connector - ctr_pipe.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 21 28 75.0 %
Date: 2013-07-09 Functions: 6 8 75.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             : 
      21             : #include "connector.hxx"
      22             : 
      23             : using namespace ::osl;
      24             : using namespace ::rtl;
      25             : using namespace ::com::sun::star::uno;
      26             : using namespace ::com::sun::star::io;
      27             : using namespace ::com::sun::star::connection;
      28             : 
      29             : 
      30             : namespace stoc_connector {
      31             : 
      32          18 :     PipeConnection::PipeConnection( const OUString & sConnectionDescription ) :
      33             :         m_nStatus( 0 ),
      34          18 :         m_sDescription( sConnectionDescription )
      35             :     {
      36             :         // make it unique
      37          18 :         m_sDescription += ",uniqueValue=";
      38          36 :         m_sDescription += OUString::valueOf(
      39             :             sal::static_int_cast< sal_Int64 >(
      40             :                 reinterpret_cast< sal_IntPtr >(&m_pipe)),
      41          18 :             10 );
      42          18 :     }
      43             : 
      44          34 :     PipeConnection::~PipeConnection()
      45             :     {
      46          34 :     }
      47             : 
      48         418 :     sal_Int32 PipeConnection::read( Sequence < sal_Int8 > & aReadBytes , sal_Int32 nBytesToRead )
      49             :             throw(::com::sun::star::io::IOException,
      50             :                   ::com::sun::star::uno::RuntimeException)
      51             :     {
      52         418 :         if( ! m_nStatus )
      53             :         {
      54         418 :             if( aReadBytes.getLength() != nBytesToRead )
      55             :             {
      56         418 :                 aReadBytes.realloc( nBytesToRead );
      57             :             }
      58         835 :             return m_pipe.read( aReadBytes.getArray()  , aReadBytes.getLength() );
      59             :         }
      60             :         else {
      61           0 :             throw IOException();
      62             :         }
      63             :     }
      64             : 
      65         188 :     void PipeConnection::write( const Sequence < sal_Int8 > &seq )
      66             :             throw(::com::sun::star::io::IOException,
      67             :                   ::com::sun::star::uno::RuntimeException)
      68             :     {
      69         188 :         if( ! m_nStatus )
      70             :         {
      71         188 :             if( m_pipe.write( seq.getConstArray() , seq.getLength() ) != seq.getLength() )
      72             :             {
      73           0 :                 throw IOException();
      74             :             }
      75             :         }
      76             :         else {
      77           0 :             throw IOException();
      78             :         }
      79         188 :     }
      80             : 
      81           0 :     void PipeConnection::flush( )
      82             :             throw(::com::sun::star::io::IOException,
      83             :                   ::com::sun::star::uno::RuntimeException)
      84             :     {
      85             : 
      86           0 :     }
      87             : 
      88           1 :     void PipeConnection::close()
      89             :             throw(::com::sun::star::io::IOException,
      90             :                   ::com::sun::star::uno::RuntimeException)
      91             :     {
      92             :         // ensure that close is called only once
      93           1 :         if(1 == osl_atomic_increment( (&m_nStatus) ) )
      94             :         {
      95           1 :             m_pipe.close();
      96             :         }
      97           1 :     }
      98             : 
      99           0 :     OUString PipeConnection::getDescription()
     100             :             throw( ::com::sun::star::uno::RuntimeException)
     101             :     {
     102           0 :         return m_sDescription;
     103             :     }
     104             : 
     105             : }
     106             : 
     107             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10