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 .
19 #ifndef INCLUDED_OSL_PIPE_HXX
20 #define INCLUDED_OSL_PIPE_HXX
22 #include "sal/config.h"
26 #include "osl/pipe_decl.hxx"
36 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
37 : m_handle( osl_createPipe( strName
.pData
, Options
, NULL
) )
41 inline Pipe::Pipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
,const Security
& rSecurity
)
42 : m_handle( osl_createPipe( strName
.pData
, Options
, rSecurity
.getHandle() ) )
46 inline Pipe::Pipe(const Pipe
& pipe
)
47 : m_handle( pipe
.m_handle
)
50 osl_acquirePipe( m_handle
);
53 #if defined LIBO_INTERNAL_ONLY
54 Pipe::Pipe(Pipe
&& other
): m_handle(other
.m_handle
) {
55 other
.m_handle
= nullptr;
59 inline Pipe::Pipe( oslPipe pipe
, __sal_NoAcquire
)
64 inline Pipe::Pipe(oslPipe pipe
)
68 osl_acquirePipe( m_handle
);
75 osl_releasePipe( m_handle
);
79 inline bool Pipe::create( const ::rtl::OUString
& strName
,
80 oslPipeOptions Options
, const Security
&rSec
)
82 *this = Pipe( strName
, Options
, rSec
);
87 inline bool Pipe::create( const ::rtl::OUString
& strName
, oslPipeOptions Options
)
89 *this = Pipe( strName
, Options
);
93 inline Pipe
& SAL_CALL
Pipe::operator= (const Pipe
& pipe
)
95 *this = pipe
.getHandle();
99 #if defined LIBO_INTERNAL_ONLY
100 Pipe
& Pipe::operator =(Pipe
&& other
) {
101 if (m_handle
!= nullptr) {
102 osl_releasePipe(m_handle
);
104 m_handle
= other
.m_handle
;
105 other
.m_handle
= nullptr;
110 inline Pipe
& SAL_CALL
Pipe::operator=( oslPipe pipe
)
113 osl_acquirePipe( pipe
);
115 osl_releasePipe( m_handle
);
121 inline bool SAL_CALL
Pipe::is() const
123 return m_handle
!= NULL
;
127 inline bool SAL_CALL
Pipe::operator==( const Pipe
& rPipe
) const
129 return m_handle
== rPipe
.m_handle
;
133 inline void SAL_CALL
Pipe::close()
135 osl_closePipe( m_handle
);
139 inline void SAL_CALL
Pipe::clear()
143 osl_releasePipe( m_handle
);
149 inline oslPipeError SAL_CALL
Pipe::accept(StreamPipe
& Connection
)
151 Connection
= StreamPipe( osl_acceptPipe( m_handle
), SAL_NO_ACQUIRE
);
152 if( Connection
.is() )
153 return osl_Pipe_E_None
;
159 inline oslPipeError SAL_CALL
Pipe::getError() const
161 return osl_getLastPipeError( NULL
);
165 inline oslPipe SAL_CALL
Pipe::getHandle() const
171 inline StreamPipe::StreamPipe(){}
174 inline StreamPipe::StreamPipe(oslPipe hPipe
)
180 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
, const Security
&rSec
)
181 : Pipe( strName
, Options
, rSec
)
185 inline StreamPipe::StreamPipe(const ::rtl::OUString
& strName
, oslPipeOptions Options
)
186 : Pipe( strName
, Options
)
189 inline StreamPipe::StreamPipe( oslPipe pipe
, __sal_NoAcquire noacquire
)
190 : Pipe( pipe
, noacquire
)
194 inline sal_Int32 SAL_CALL
StreamPipe::read(void* pBuffer
, sal_Int32 n
) const
196 return osl_readPipe( m_handle
, pBuffer
, n
);
200 inline sal_Int32 SAL_CALL
StreamPipe::write(const void* pBuffer
, sal_Int32 n
) const
202 return osl_writePipe( m_handle
, pBuffer
, n
);
206 inline sal_Int32 SAL_CALL
StreamPipe::recv(void* pBuffer
, sal_Int32 BytesToRead
) const
208 return osl_receivePipe( m_handle
, pBuffer
, BytesToRead
);
212 inline sal_Int32 SAL_CALL
StreamPipe::send(const void* pBuffer
, sal_Int32 BytesToSend
) const
214 return osl_sendPipe( m_handle
, pBuffer
, BytesToSend
);
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */