My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pipe.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _OSL_PIPE_HXX_
29 #define _OSL_PIPE_HXX_
30 
31 #include <osl/pipe_decl.hxx>
32 
33 namespace osl
34 {
35  //______________________________________________________________________________
36  inline Pipe::Pipe()
37  : m_handle( 0 )
38  {}
39 
40  //______________________________________________________________________________
41  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
42  : m_handle( osl_createPipe( strName.pData, Options , 0 ) )
43  {}
44 
45  //______________________________________________________________________________
46  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
47  : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
48  {}
49 
50  //______________________________________________________________________________
51  inline Pipe::Pipe(const Pipe& pipe )
52  : m_handle( pipe.m_handle )
53  {
54  if( m_handle )
56  }
57 
58  //______________________________________________________________________________
60  : m_handle ( pipe )
61  {}
62 
63  //______________________________________________________________________________
64  inline Pipe::Pipe(oslPipe pipe)
65  : m_handle( pipe )
66  {
67  if( m_handle )
69  }
70 
71  //______________________________________________________________________________
72  inline Pipe::~Pipe()
73  {
74  if( m_handle )
76  }
77 
78  //______________________________________________________________________________
79  inline sal_Bool Pipe::create( const ::rtl::OUString & strName,
80  oslPipeOptions Options, const Security &rSec )
81  {
82  *this = Pipe( strName, Options, rSec );
83  return is();
84  }
85 
86  //______________________________________________________________________________
87  inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
88  {
89  *this = Pipe( strName, Options );
90  return is();
91  }
92  //______________________________________________________________________________
93  inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
94  {
95  *this = pipe.getHandle();
96  return *this;
97  }
98 
99  //______________________________________________________________________________
100  inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
101  {
102  if( pipe )
103  osl_acquirePipe( pipe );
104  if( m_handle )
106  m_handle = pipe;
107  return *this;
108  }
109 
110  //______________________________________________________________________________
111  inline sal_Bool SAL_CALL Pipe::is() const
112  {
113  return m_handle != 0;
114  }
115 
116  //______________________________________________________________________________
117  inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
118  {
119  return m_handle == rPipe.m_handle;
120  }
121 
122  //______________________________________________________________________________
123  inline void SAL_CALL Pipe::close()
124  {
126  }
127 
128  //______________________________________________________________________________
129  inline void SAL_CALL Pipe::clear()
130  {
131  if( m_handle )
132  {
134  m_handle = 0;
135  }
136  }
137 
138  //______________________________________________________________________________
139  inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
140  {
142  if( Connection.is() )
143  return osl_Pipe_E_None;
144  else
145  return getError();
146  }
147 
148  //______________________________________________________________________________
149  inline oslPipeError SAL_CALL Pipe::getError() const
150  {
151  return osl_getLastPipeError( 0 );
152  }
153 
154  //______________________________________________________________________________
155  inline oslPipe SAL_CALL Pipe::getHandle() const
156  {
157  return m_handle;
158  }
159 
160  //______________________________________________________________________________
162 
163  //______________________________________________________________________________
165  : Pipe( hPipe )
166  {
167  }
168 
169  //______________________________________________________________________________
170  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
171  : Pipe( strName, Options , rSec )
172  {}
173 
174  //______________________________________________________________________________
175  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
176  : Pipe( strName, Options )
177  {}
178 
179  //______________________________________________________________________________
180  inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
181  : Pipe( aPipe )
182  {}
183  //______________________________________________________________________________
185  : Pipe( pipe , noacquire )
186  {}
187 
188  //______________________________________________________________________________
189  inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
190  {
191  return osl_readPipe( m_handle, pBuffer, n );
192  }
193 
194  //______________________________________________________________________________
195  inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
196  {
197  return osl_writePipe( m_handle, pBuffer , n );
198  }
199 
200  //______________________________________________________________________________
201  inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
202  {
203  return osl_receivePipe( m_handle, pBuffer , BytesToRead );
204  }
205 
206  //______________________________________________________________________________
207  inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
208  {
209  return osl_sendPipe( m_handle, pBuffer , BytesToSend );
210  }
211 
212 }
213 #endif
214 
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */