Update ooo320-m1
[ooovba.git] / sal / inc / osl / pipe.hxx
blob1ba307b53d05c9095a1da363bd1df05ee96b1475
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: pipe.hxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _OSL_PIPE_HXX_
31 #define _OSL_PIPE_HXX_
33 #include <osl/pipe_decl.hxx>
35 namespace osl
37 //______________________________________________________________________________
38 inline Pipe::Pipe()
39 : m_handle( 0 )
42 //______________________________________________________________________________
43 inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
44 : m_handle( osl_createPipe( strName.pData, Options , 0 ) )
47 //______________________________________________________________________________
48 inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
49 : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
52 //______________________________________________________________________________
53 inline Pipe::Pipe(const Pipe& pipe )
54 : m_handle( pipe.m_handle )
56 if( m_handle )
57 osl_acquirePipe( m_handle );
60 //______________________________________________________________________________
61 inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire )
62 : m_handle ( pipe )
65 //______________________________________________________________________________
66 inline Pipe::Pipe(oslPipe pipe)
67 : m_handle( pipe )
69 if( m_handle )
70 osl_acquirePipe( m_handle );
73 //______________________________________________________________________________
74 inline Pipe::~Pipe()
76 if( m_handle )
77 osl_releasePipe( m_handle );
80 //______________________________________________________________________________
81 inline sal_Bool Pipe::create( const ::rtl::OUString & strName,
82 oslPipeOptions Options, const Security &rSec )
84 *this = Pipe( strName, Options, rSec );
85 return is();
88 //______________________________________________________________________________
89 inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
91 *this = Pipe( strName, Options );
92 return is();
94 //______________________________________________________________________________
95 inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
97 *this = pipe.getHandle();
98 return *this;
101 //______________________________________________________________________________
102 inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
104 if( pipe )
105 osl_acquirePipe( pipe );
106 if( m_handle )
107 osl_releasePipe( m_handle );
108 m_handle = pipe;
109 return *this;
112 //______________________________________________________________________________
113 inline sal_Bool SAL_CALL Pipe::is() const
115 return m_handle != 0;
118 //______________________________________________________________________________
119 inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
121 return m_handle == rPipe.m_handle;
124 //______________________________________________________________________________
125 inline void SAL_CALL Pipe::close()
127 osl_closePipe( m_handle );
130 //______________________________________________________________________________
131 inline void SAL_CALL Pipe::clear()
133 if( m_handle )
135 osl_releasePipe( m_handle );
136 m_handle = 0;
140 //______________________________________________________________________________
141 inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
143 Connection = StreamPipe( osl_acceptPipe( m_handle ), SAL_NO_ACQUIRE);
144 if( Connection.is() )
145 return osl_Pipe_E_None;
146 else
147 return getError();
150 //______________________________________________________________________________
151 inline oslPipeError SAL_CALL Pipe::getError() const
153 return osl_getLastPipeError( 0 );
156 //______________________________________________________________________________
157 inline oslPipe SAL_CALL Pipe::getHandle() const
159 return m_handle;
162 //______________________________________________________________________________
163 inline StreamPipe::StreamPipe(){}
165 //______________________________________________________________________________
166 inline StreamPipe::StreamPipe(oslPipe hPipe)
167 : Pipe( hPipe )
171 //______________________________________________________________________________
172 inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
173 : Pipe( strName, Options , rSec )
176 //______________________________________________________________________________
177 inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
178 : Pipe( strName, Options )
181 //______________________________________________________________________________
182 inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
183 : Pipe( aPipe )
185 //______________________________________________________________________________
186 inline StreamPipe::StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire )
187 : Pipe( pipe , noacquire )
190 //______________________________________________________________________________
191 inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
193 return osl_readPipe( m_handle, pBuffer, n );
196 //______________________________________________________________________________
197 inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
199 return osl_writePipe( m_handle, pBuffer , n );
202 //______________________________________________________________________________
203 inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
205 return osl_receivePipe( m_handle, pBuffer , BytesToRead );
208 //______________________________________________________________________________
209 inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
211 return osl_sendPipe( m_handle, pBuffer , BytesToSend );
215 #endif