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 * This file is part of LibreOffice published API.
23 #ifndef INCLUDED_OSL_PIPE_HXX
24 #define INCLUDED_OSL_PIPE_HXX
26 #include "sal/config.h"
30 #include "osl/pipe_decl.hxx"
40 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
41 : m_handle( osl_createPipe( strName
.pData
, Options
, NULL
) )
45 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
,const Security
& rSecurity
)
46 : m_handle( osl_createPipe( strName
.pData
, Options
, rSecurity
.getHandle() ) )
50 inline Pipe::Pipe(const Pipe
& pipe
)
51 : m_handle( pipe
.m_handle
)
54 osl_acquirePipe( m_handle
);
57 #if defined LIBO_INTERNAL_ONLY
58 Pipe::Pipe(Pipe
&& other
) noexcept
: m_handle(other
.m_handle
) {
59 other
.m_handle
= nullptr;
63 inline Pipe::Pipe( oslPipe pipe
, __sal_NoAcquire
)
68 inline Pipe::Pipe(oslPipe pipe
)
72 osl_acquirePipe( m_handle
);
79 osl_releasePipe( m_handle
);
83 inline bool Pipe::create( const ::rtl::OUString
& strName
,
84 oslPipeOptions Options
, const Security
&rSec
)
86 *this = Pipe( strName
, Options
, rSec
);
91 inline bool Pipe::create( const ::rtl::OUString
& strName
, oslPipeOptions Options
)
93 *this = Pipe( strName
, Options
);
97 inline Pipe
& SAL_CALL
Pipe::operator= (const Pipe
& pipe
)
99 *this = pipe
.getHandle();
103 #if defined LIBO_INTERNAL_ONLY
104 Pipe
& Pipe::operator =(Pipe
&& other
) noexcept
{
105 if (m_handle
!= nullptr) {
106 osl_releasePipe(m_handle
);
108 m_handle
= other
.m_handle
;
109 other
.m_handle
= nullptr;
114 inline Pipe
& SAL_CALL
Pipe::operator=( oslPipe pipe
)
117 osl_acquirePipe( pipe
);
119 osl_releasePipe( m_handle
);
125 inline bool SAL_CALL
Pipe::is() const
127 return m_handle
!= NULL
;
131 inline bool SAL_CALL
Pipe::operator==( const Pipe
& rPipe
) const
133 return m_handle
== rPipe
.m_handle
;
137 inline void SAL_CALL
Pipe::close()
139 osl_closePipe( m_handle
);
143 inline void SAL_CALL
Pipe::clear()
147 osl_releasePipe( m_handle
);
153 inline oslPipeError SAL_CALL
Pipe::accept(StreamPipe
& Connection
)
155 Connection
= StreamPipe( osl_acceptPipe( m_handle
), SAL_NO_ACQUIRE
);
156 if( Connection
.is() )
157 return osl_Pipe_E_None
;
163 inline oslPipeError SAL_CALL
Pipe::getError() const
165 return osl_getLastPipeError( NULL
);
169 inline oslPipe SAL_CALL
Pipe::getHandle() const
175 inline StreamPipe::StreamPipe(){}
178 inline StreamPipe::StreamPipe(oslPipe hPipe
)
184 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
, const Security
&rSec
)
185 : Pipe( strName
, Options
, rSec
)
189 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
190 : Pipe( strName
, Options
)
193 inline StreamPipe::StreamPipe( oslPipe pipe
, __sal_NoAcquire noacquire
)
194 : Pipe( pipe
, noacquire
)
198 inline sal_Int32 SAL_CALL
StreamPipe::read(void* pBuffer
, sal_Int32 n
) const
200 return osl_readPipe( m_handle
, pBuffer
, n
);
204 inline sal_Int32 SAL_CALL
StreamPipe::write(const void* pBuffer
, sal_Int32 n
) const
206 return osl_writePipe( m_handle
, pBuffer
, n
);
210 inline sal_Int32 SAL_CALL
StreamPipe::recv(void* pBuffer
, sal_Int32 BytesToRead
) const
212 return osl_receivePipe( m_handle
, pBuffer
, BytesToRead
);
216 inline sal_Int32 SAL_CALL
StreamPipe::send(const void* pBuffer
, sal_Int32 BytesToSend
) const
218 return osl_sendPipe( m_handle
, pBuffer
, BytesToSend
);
224 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */