UDK 3.2.7 C/C++ API Reference

osl/pipe.hxx

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 #ifndef _OSL_PIPE_HXX_
00020 #define _OSL_PIPE_HXX_
00021 
00022 #include <osl/pipe_decl.hxx>
00023 
00024 namespace osl
00025 {
00026     //______________________________________________________________________________
00027     inline Pipe::Pipe()
00028         : m_handle( 0 )
00029     {}
00030 
00031     //______________________________________________________________________________
00032     inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
00033         : m_handle( osl_createPipe( strName.pData, Options , 0 ) )
00034     {}
00035 
00036     //______________________________________________________________________________
00037     inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
00038         : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
00039     {}
00040 
00041     //______________________________________________________________________________
00042     inline Pipe::Pipe(const Pipe& pipe )
00043         : m_handle( pipe.m_handle )
00044     {
00045         if( m_handle )
00046             osl_acquirePipe( m_handle );
00047     }
00048 
00049     //______________________________________________________________________________
00050     inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire )
00051         : m_handle ( pipe )
00052     {}
00053 
00054     //______________________________________________________________________________
00055     inline Pipe::Pipe(oslPipe pipe)
00056         : m_handle( pipe )
00057     {
00058         if( m_handle )
00059             osl_acquirePipe( m_handle );
00060     }
00061 
00062     //______________________________________________________________________________
00063     inline Pipe::~Pipe()
00064     {
00065         if( m_handle )
00066             osl_releasePipe( m_handle );
00067     }
00068 
00069     //______________________________________________________________________________
00070     inline sal_Bool Pipe::create( const ::rtl::OUString & strName,
00071                                   oslPipeOptions Options, const Security &rSec )
00072     {
00073         *this = Pipe( strName, Options, rSec );
00074         return is();
00075     }
00076 
00077     //______________________________________________________________________________
00078     inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options  )
00079     {
00080         *this = Pipe( strName, Options );
00081         return is();
00082     }
00083     //______________________________________________________________________________
00084     inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
00085     {
00086         *this = pipe.getHandle();
00087         return *this;
00088     }
00089 
00090     //______________________________________________________________________________
00091     inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
00092     {
00093         if( pipe )
00094             osl_acquirePipe( pipe );
00095         if( m_handle )
00096             osl_releasePipe( m_handle );
00097         m_handle = pipe;
00098         return *this;
00099     }
00100 
00101     //______________________________________________________________________________
00102     inline sal_Bool SAL_CALL Pipe::is() const
00103     {
00104         return m_handle != 0;
00105     }
00106 
00107     //______________________________________________________________________________
00108     inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
00109     {
00110         return m_handle == rPipe.m_handle;
00111     }
00112 
00113     //______________________________________________________________________________
00114     inline void SAL_CALL Pipe::close()
00115     {
00116         osl_closePipe( m_handle );
00117     }
00118 
00119     //______________________________________________________________________________
00120     inline void SAL_CALL Pipe::clear()
00121     {
00122         if( m_handle )
00123         {
00124             osl_releasePipe( m_handle );
00125             m_handle = 0;
00126         }
00127     }
00128 
00129     //______________________________________________________________________________
00130     inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
00131     {
00132         Connection = StreamPipe( osl_acceptPipe( m_handle ), SAL_NO_ACQUIRE);
00133         if( Connection.is() )
00134             return osl_Pipe_E_None;
00135         else
00136             return getError();
00137     }
00138 
00139     //______________________________________________________________________________
00140     inline oslPipeError SAL_CALL Pipe::getError() const
00141     {
00142         return osl_getLastPipeError( 0 );
00143     }
00144 
00145     //______________________________________________________________________________
00146     inline oslPipe SAL_CALL Pipe::getHandle() const
00147     {
00148         return m_handle;
00149     }
00150 
00151     //______________________________________________________________________________
00152     inline StreamPipe::StreamPipe(){}
00153 
00154     //______________________________________________________________________________
00155     inline StreamPipe::StreamPipe(oslPipe hPipe)
00156         : Pipe( hPipe )
00157     {
00158     }
00159 
00160     //______________________________________________________________________________
00161     inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
00162         : Pipe( strName, Options , rSec )
00163     {}
00164 
00165     //______________________________________________________________________________
00166     inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options  )
00167         : Pipe( strName, Options )
00168     {}
00169 
00170     //______________________________________________________________________________
00171     inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
00172         : Pipe( aPipe )
00173     {}
00174     //______________________________________________________________________________
00175     inline StreamPipe::StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire )
00176         : Pipe( pipe , noacquire )
00177     {}
00178 
00179     //______________________________________________________________________________
00180     inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
00181     {
00182         return osl_readPipe( m_handle, pBuffer, n );
00183     }
00184 
00185     //______________________________________________________________________________
00186     inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
00187     {
00188         return osl_writePipe( m_handle, pBuffer , n );
00189     }
00190 
00191     //______________________________________________________________________________
00192     inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
00193     {
00194         return osl_receivePipe( m_handle, pBuffer , BytesToRead );
00195     }
00196 
00197     //______________________________________________________________________________
00198     inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
00199     {
00200         return osl_sendPipe( m_handle, pBuffer , BytesToSend );
00201     }
00202 
00203 }
00204 #endif
00205 
00206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines