LibreOffice
LibreOffice 4.2 SDK 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  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_OSL_PIPE_HXX
20 #define INCLUDED_OSL_PIPE_HXX
21 
22 #include <osl/pipe_decl.hxx>
23 
24 namespace osl
25 {
26  //______________________________________________________________________________
27  inline Pipe::Pipe()
28  : m_handle( 0 )
29  {}
30 
31  //______________________________________________________________________________
32  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
33  : m_handle( osl_createPipe( strName.pData, Options , 0 ) )
34  {}
35 
36  //______________________________________________________________________________
37  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
38  : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
39  {}
40 
41  //______________________________________________________________________________
42  inline Pipe::Pipe(const Pipe& pipe )
43  : m_handle( pipe.m_handle )
44  {
45  if( m_handle )
47  }
48 
49  //______________________________________________________________________________
51  : m_handle ( pipe )
52  {}
53 
54  //______________________________________________________________________________
55  inline Pipe::Pipe(oslPipe pipe)
56  : m_handle( pipe )
57  {
58  if( m_handle )
60  }
61 
62  //______________________________________________________________________________
63  inline Pipe::~Pipe()
64  {
65  if( m_handle )
67  }
68 
69  //______________________________________________________________________________
70  inline sal_Bool Pipe::create( const ::rtl::OUString & strName,
71  oslPipeOptions Options, const Security &rSec )
72  {
73  *this = Pipe( strName, Options, rSec );
74  return is();
75  }
76 
77  //______________________________________________________________________________
78  inline sal_Bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
79  {
80  *this = Pipe( strName, Options );
81  return is();
82  }
83  //______________________________________________________________________________
84  inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
85  {
86  *this = pipe.getHandle();
87  return *this;
88  }
89 
90  //______________________________________________________________________________
91  inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
92  {
93  if( pipe )
94  osl_acquirePipe( pipe );
95  if( m_handle )
97  m_handle = pipe;
98  return *this;
99  }
100 
101  //______________________________________________________________________________
102  inline sal_Bool SAL_CALL Pipe::is() const
103  {
104  return m_handle != 0;
105  }
106 
107  //______________________________________________________________________________
108  inline sal_Bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
109  {
110  return m_handle == rPipe.m_handle;
111  }
112 
113  //______________________________________________________________________________
114  inline void SAL_CALL Pipe::close()
115  {
117  }
118 
119  //______________________________________________________________________________
120  inline void SAL_CALL Pipe::clear()
121  {
122  if( m_handle )
123  {
125  m_handle = 0;
126  }
127  }
128 
129  //______________________________________________________________________________
130  inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
131  {
133  if( Connection.is() )
134  return osl_Pipe_E_None;
135  else
136  return getError();
137  }
138 
139  //______________________________________________________________________________
140  inline oslPipeError SAL_CALL Pipe::getError() const
141  {
142  return osl_getLastPipeError( 0 );
143  }
144 
145  //______________________________________________________________________________
146  inline oslPipe SAL_CALL Pipe::getHandle() const
147  {
148  return m_handle;
149  }
150 
151  //______________________________________________________________________________
153 
154  //______________________________________________________________________________
156  : Pipe( hPipe )
157  {
158  }
159 
160  //______________________________________________________________________________
161  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
162  : Pipe( strName, Options , rSec )
163  {}
164 
165  //______________________________________________________________________________
166  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
167  : Pipe( strName, Options )
168  {}
169 
170  //______________________________________________________________________________
171  inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
172  : Pipe( aPipe )
173  {}
174  //______________________________________________________________________________
176  : Pipe( pipe , noacquire )
177  {}
178 
179  //______________________________________________________________________________
180  inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
181  {
182  return osl_readPipe( m_handle, pBuffer, n );
183  }
184 
185  //______________________________________________________________________________
186  inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
187  {
188  return osl_writePipe( m_handle, pBuffer , n );
189  }
190 
191  //______________________________________________________________________________
192  inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
193  {
194  return osl_receivePipe( m_handle, pBuffer , BytesToRead );
195  }
196 
197  //______________________________________________________________________________
198  inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
199  {
200  return osl_sendPipe( m_handle, pBuffer , BytesToSend );
201  }
202 
203 }
204 #endif
205 
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC void osl_closePipe(oslPipe)
closes the pipe, any read,write or accept actions stop immeadiatly.
SAL_DLLPUBLIC void osl_acquirePipe(oslPipe Pipe)
increases the refcount of the pipe.
sal_Int32 read(void *pBuffer, sal_Int32 n) const
Retrieves n bytes from the stream and copies them into pBuffer.
Definition: pipe.hxx:180
SAL_DLLPUBLIC sal_Int32 osl_receivePipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
sal_uInt32 oslPipeOptions
Definition: pipe.h:49
StreamPipe()
Creates an unattached pipe.
Definition: pipe.hxx:152
SAL_DLLPUBLIC oslPipe osl_acceptPipe(oslPipe Pipe)
capsulate security information for one user.
Definition: security_decl.hxx:34
sal_Bool operator==(const Pipe &rPipe) const
Definition: pipe.hxx:108
SAL_DLLPUBLIC oslPipeError osl_getLastPipeError(oslPipe Pipe)
sal_Int32 send(const void *pBuffer, sal_Int32 BytesToSend) const
Tries to sends BytesToSend data from the connected pipe.
Definition: pipe.hxx:198
SAL_DLLPUBLIC sal_Int32 osl_writePipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
Writes blocking onto the pipe.
sal_Bool create(const ::rtl::OUString &strName, oslPipeOptions Options, const Security &rSec)
Creates an insecure pipe that is accessible for all users with the given attributes.
Definition: pipe.hxx:70
oslPipeError getError() const
Delivers a constant decribing the last error for the pipe system.
Definition: pipe.hxx:140
Pipe & operator=(const Pipe &pipe)
Assignment operator.
Definition: pipe.hxx:84
void close()
Closes the pipe.
Definition: pipe.hxx:114
oslPipeError
Definition: pipe.h:34
SAL_DLLPUBLIC sal_Int32 osl_sendPipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
Definition: pipe.h:35
sal_Bool is() const
Definition: pipe.hxx:102
definition of a no acquire enum for ctors
Definition: types.h:376
sal_Int32 write(const void *pBuffer, sal_Int32 n) const
Writes n bytes from pBuffer to the stream.
Definition: pipe.hxx:186
unsigned char sal_Bool
Definition: types.h:46
__sal_NoAcquire
Definition: types.h:372
oslPipeError accept(StreamPipe &Connection)
Accept connection on an existing pipe.
Definition: pipe.hxx:130
SAL_DLLPUBLIC sal_Int32 osl_readPipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
Reads blocking from the pipe.
struct oslPipeImpl * oslPipe
Definition: pipe.h:53
Pipe()
Does not create a pipe.
Definition: pipe.hxx:27
sal_Int32 recv(void *pBuffer, sal_Int32 BytesToRead) const
Tries to receives BytesToRead data from the connected pipe,.
Definition: pipe.hxx:192
A pipe to send or receive a stream of data.
Definition: pipe_decl.hxx:139
oslPipe m_handle
Definition: pipe_decl.hxx:35
~Pipe()
Destructor.
Definition: pipe.hxx:63
SAL_DLLPUBLIC oslPipe osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options, oslSecurity Security)
void clear()
releases the underlying handle
Definition: pipe.hxx:120
SAL_DLLPUBLIC void osl_releasePipe(oslPipe)
decreases the refcount of the pipe.
Represents a pipe.
Definition: pipe_decl.hxx:32
oslPipe getHandle() const
Definition: pipe.hxx:146