1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include "connector.hxx"
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
;
30 namespace stoc_connector
{
32 PipeConnection::PipeConnection( const OUString
& sConnectionDescription
) :
34 m_sDescription( sConnectionDescription
)
36 g_moduleCount
.modCnt
.acquire( &g_moduleCount
.modCnt
);
38 m_sDescription
+= ",uniqueValue=";
39 m_sDescription
+= OUString::valueOf(
40 sal::static_int_cast
< sal_Int64
>(
41 reinterpret_cast< sal_IntPtr
>(&m_pipe
)),
45 PipeConnection::~PipeConnection()
47 g_moduleCount
.modCnt
.release( &g_moduleCount
.modCnt
);
50 sal_Int32
PipeConnection::read( Sequence
< sal_Int8
> & aReadBytes
, sal_Int32 nBytesToRead
)
51 throw(::com::sun::star::io::IOException
,
52 ::com::sun::star::uno::RuntimeException
)
56 if( aReadBytes
.getLength() != nBytesToRead
)
58 aReadBytes
.realloc( nBytesToRead
);
60 return m_pipe
.read( aReadBytes
.getArray() , aReadBytes
.getLength() );
67 void PipeConnection::write( const Sequence
< sal_Int8
> &seq
)
68 throw(::com::sun::star::io::IOException
,
69 ::com::sun::star::uno::RuntimeException
)
73 if( m_pipe
.write( seq
.getConstArray() , seq
.getLength() ) != seq
.getLength() )
83 void PipeConnection::flush( )
84 throw(::com::sun::star::io::IOException
,
85 ::com::sun::star::uno::RuntimeException
)
90 void PipeConnection::close()
91 throw(::com::sun::star::io::IOException
,
92 ::com::sun::star::uno::RuntimeException
)
94 // ensure that close is called only once
95 if(1 == osl_atomic_increment( (&m_nStatus
) ) )
101 OUString
PipeConnection::getDescription()
102 throw( ::com::sun::star::uno::RuntimeException
)
104 return m_sDescription
;
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */