bump product version to 6.3.0.0.beta1
[LibreOffice.git] / include / osl / pipe.hxx
blobe9cfe2e6c3f0e4b2f8bb16f17d121664d77b4762
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
24 #include <cstddef>
26 #include "osl/pipe_decl.hxx"
28 namespace osl
31 inline Pipe::Pipe()
32 : m_handle( NULL )
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 )
49 if( 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;
57 #endif
59 inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire )
60 : m_handle ( pipe )
64 inline Pipe::Pipe(oslPipe pipe)
65 : m_handle( pipe )
67 if( m_handle )
68 osl_acquirePipe( m_handle );
72 inline Pipe::~Pipe()
74 if( 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 );
83 return is();
87 inline bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
89 *this = Pipe( strName, Options );
90 return is();
93 inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
95 *this = pipe.getHandle();
96 return *this;
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;
106 return *this;
108 #endif
110 inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
112 if( pipe )
113 osl_acquirePipe( pipe );
114 if( m_handle )
115 osl_releasePipe( m_handle );
116 m_handle = pipe;
117 return *this;
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()
141 if( m_handle )
143 osl_releasePipe( m_handle );
144 m_handle = NULL;
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;
154 else
155 return getError();
159 inline oslPipeError SAL_CALL Pipe::getError() const
161 return osl_getLastPipeError( NULL );
165 inline oslPipe SAL_CALL Pipe::getHandle() const
167 return m_handle;
171 inline StreamPipe::StreamPipe(){}
174 inline StreamPipe::StreamPipe(oslPipe hPipe)
175 : Pipe( 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 );
218 #endif
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */