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

Generated by: LCOV version 1.11