UDK 3.2.7 C/C++ API Reference
|
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 00002 /************************************************************************* 00003 * 00004 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 00005 * 00006 * Copyright 2000, 2010 Oracle and/or its affiliates. 00007 * 00008 * OpenOffice.org - a multi-platform office productivity suite 00009 * 00010 * This file is part of OpenOffice.org. 00011 * 00012 * OpenOffice.org is free software: you can redistribute it and/or modify 00013 * it under the terms of the GNU Lesser General Public License version 3 00014 * only, as published by the Free Software Foundation. 00015 * 00016 * OpenOffice.org is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Lesser General Public License version 3 for more details 00020 * (a copy is included in the LICENSE file that accompanied this code). 00021 * 00022 * You should have received a copy of the GNU Lesser General Public License 00023 * version 3 along with OpenOffice.org. If not, see 00024 * <http://www.openoffice.org/license.html> 00025 * for a copy of the LGPLv3 License. 00026 * 00027 ************************************************************************/ 00028 #ifndef _OSL_PIPE_HXX_ 00029 #define _OSL_PIPE_HXX_ 00030 00031 #include <osl/pipe_decl.hxx> 00032 00033 namespace osl 00034 { 00035 //______________________________________________________________________________ 00036 inline Pipe::Pipe() 00037 : m_handle( 0 ) 00038 {} 00039 00040 //______________________________________________________________________________ 00041 inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options ) 00042 : m_handle( osl_createPipe( strName.pData, Options , 0 ) ) 00043 {} 00044 00045 //______________________________________________________________________________ 00046 inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity) 00047 : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) ) 00048 {} 00049 00050 //______________________________________________________________________________ 00051 inline Pipe::Pipe(const Pipe& pipe ) 00052 : m_handle( pipe.m_handle ) 00053 { 00054 if( m_handle ) 00055 osl_acquirePipe( m_handle ); 00056 } 00057 00058 //______________________________________________________________________________ 00059 inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire ) 00060 : m_handle ( pipe ) 00061 {} 00062 00063 //______________________________________________________________________________ 00064 inline Pipe::Pipe(oslPipe pipe) 00065 : m_handle( pipe ) 00066 { 00067 if( m_handle ) 00068 osl_acquirePipe( m_handle ); 00069 } 00070 00071 //______________________________________________________________________________ 00072 inline Pipe::~Pipe() 00073 { 00074 if( m_handle ) 00075 osl_releasePipe( m_handle ); 00076 } 00077 00078 //______________________________________________________________________________ 00079 inline sal_Bool Pipe::create( const ::rtl::OUString & strName, 00080 oslPipeOptions Options, const Security &rSec ) 00081 { 00082 *this = Pipe( strName, Options, rSec ); 00083 return is(); 00084 } 00085 00086 //______________________________________________________________________________ 00087 inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options ) 00088 { 00089 *this = Pipe( strName, Options ); 00090 return is(); 00091 } 00092 //______________________________________________________________________________ 00093 inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe) 00094 { 00095 *this = pipe.getHandle(); 00096 return *this; 00097 } 00098 00099 //______________________________________________________________________________ 00100 inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe) 00101 { 00102 if( pipe ) 00103 osl_acquirePipe( pipe ); 00104 if( m_handle ) 00105 osl_releasePipe( m_handle ); 00106 m_handle = pipe; 00107 return *this; 00108 } 00109 00110 //______________________________________________________________________________ 00111 inline sal_Bool SAL_CALL Pipe::is() const 00112 { 00113 return m_handle != 0; 00114 } 00115 00116 //______________________________________________________________________________ 00117 inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const 00118 { 00119 return m_handle == rPipe.m_handle; 00120 } 00121 00122 //______________________________________________________________________________ 00123 inline void SAL_CALL Pipe::close() 00124 { 00125 osl_closePipe( m_handle ); 00126 } 00127 00128 //______________________________________________________________________________ 00129 inline void SAL_CALL Pipe::clear() 00130 { 00131 if( m_handle ) 00132 { 00133 osl_releasePipe( m_handle ); 00134 m_handle = 0; 00135 } 00136 } 00137 00138 //______________________________________________________________________________ 00139 inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection) 00140 { 00141 Connection = StreamPipe( osl_acceptPipe( m_handle ), SAL_NO_ACQUIRE); 00142 if( Connection.is() ) 00143 return osl_Pipe_E_None; 00144 else 00145 return getError(); 00146 } 00147 00148 //______________________________________________________________________________ 00149 inline oslPipeError SAL_CALL Pipe::getError() const 00150 { 00151 return osl_getLastPipeError( 0 ); 00152 } 00153 00154 //______________________________________________________________________________ 00155 inline oslPipe SAL_CALL Pipe::getHandle() const 00156 { 00157 return m_handle; 00158 } 00159 00160 //______________________________________________________________________________ 00161 inline StreamPipe::StreamPipe(){} 00162 00163 //______________________________________________________________________________ 00164 inline StreamPipe::StreamPipe(oslPipe hPipe) 00165 : Pipe( hPipe ) 00166 { 00167 } 00168 00169 //______________________________________________________________________________ 00170 inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec ) 00171 : Pipe( strName, Options , rSec ) 00172 {} 00173 00174 //______________________________________________________________________________ 00175 inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options ) 00176 : Pipe( strName, Options ) 00177 {} 00178 00179 //______________________________________________________________________________ 00180 inline StreamPipe::StreamPipe(const StreamPipe& aPipe) 00181 : Pipe( aPipe ) 00182 {} 00183 //______________________________________________________________________________ 00184 inline StreamPipe::StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire ) 00185 : Pipe( pipe , noacquire ) 00186 {} 00187 00188 //______________________________________________________________________________ 00189 inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const 00190 { 00191 return osl_readPipe( m_handle, pBuffer, n ); 00192 } 00193 00194 //______________________________________________________________________________ 00195 inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const 00196 { 00197 return osl_writePipe( m_handle, pBuffer , n ); 00198 } 00199 00200 //______________________________________________________________________________ 00201 inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const 00202 { 00203 return osl_receivePipe( m_handle, pBuffer , BytesToRead ); 00204 } 00205 00206 //______________________________________________________________________________ 00207 inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const 00208 { 00209 return osl_sendPipe( m_handle, pBuffer , BytesToSend ); 00210 } 00211 00212 } 00213 #endif 00214 00215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */