LCOV - code coverage report
Current view: top level - io/source/connector - ctr_pipe.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 21 28 75.0 %
Date: 2014-11-03 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           8 :     PipeConnection::PipeConnection( const OUString & sConnectionDescription ) :
      32             :         m_nStatus( 0 ),
      33           8 :         m_sDescription( sConnectionDescription )
      34             :     {
      35             :         // make it unique
      36           8 :         m_sDescription += ",uniqueValue=";
      37          16 :         m_sDescription += OUString::number(
      38             :             sal::static_int_cast< sal_Int64 >(
      39             :                 reinterpret_cast< sal_IntPtr >(&m_pipe)),
      40           8 :             10 );
      41           8 :     }
      42             : 
      43          16 :     PipeConnection::~PipeConnection()
      44             :     {
      45          16 :     }
      46             : 
      47         832 :     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         832 :         if( ! m_nStatus )
      52             :         {
      53         832 :             if( aReadBytes.getLength() != nBytesToRead )
      54             :             {
      55         832 :                 aReadBytes.realloc( nBytesToRead );
      56             :             }
      57        1664 :             return m_pipe.read( aReadBytes.getArray()  , aReadBytes.getLength() );
      58             :         }
      59             :         else {
      60           0 :             throw IOException();
      61             :         }
      62             :     }
      63             : 
      64         374 :     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         374 :         if( ! m_nStatus )
      69             :         {
      70         374 :             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         374 :     }
      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           4 :     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           4 :         if(1 == osl_atomic_increment( (&m_nStatus) ) )
      93             :         {
      94           4 :             m_pipe.close();
      95             :         }
      96           4 :     }
      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.10