AlterOffice
AlterOffice 3.4 SDK C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #ifndef INCLUDED_OSL_PIPE_HXX
4 #define INCLUDED_OSL_PIPE_HXX
5 
6 #include "sal/config.h"
7 
8 #include <cstddef>
9 
10 #include "osl/pipe_decl.hxx"
11 
12 namespace osl
13 {
14 
15  inline Pipe::Pipe()
16  : m_handle( NULL )
17  {}
18 
19 
20  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
21  : m_handle( osl_createPipe( strName.pData, Options , NULL ) )
22  {}
23 
24 
25  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
26  : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
27  {}
28 
29 
30  inline Pipe::Pipe(const Pipe& pipe )
31  : m_handle( pipe.m_handle )
32  {
33  if( m_handle )
35  }
36 
37 #if defined LIBO_INTERNAL_ONLY
38  Pipe::Pipe(Pipe && other) noexcept : m_handle(other.m_handle) {
39  other.m_handle = nullptr;
40  }
41 #endif
42 
44  : m_handle ( pipe )
45  {}
46 
47 
48  inline Pipe::Pipe(oslPipe pipe)
49  : m_handle( pipe )
50  {
51  if( m_handle )
53  }
54 
55 
56  inline Pipe::~Pipe()
57  {
58  if( m_handle )
60  }
61 
62 
63  inline bool Pipe::create( const ::rtl::OUString & strName,
64  oslPipeOptions Options, const Security &rSec )
65  {
66  *this = Pipe( strName, Options, rSec );
67  return is();
68  }
69 
70 
71  inline bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
72  {
73  *this = Pipe( strName, Options );
74  return is();
75  }
76 
77  inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
78  {
79  *this = pipe.getHandle();
80  return *this;
81  }
82 
83 #if defined LIBO_INTERNAL_ONLY
84  Pipe & Pipe::operator =(Pipe && other) noexcept {
85  if (m_handle != nullptr) {
87  }
88  m_handle = other.m_handle;
89  other.m_handle = nullptr;
90  return *this;
91  }
92 #endif
93 
94  inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
95  {
96  if( pipe )
97  osl_acquirePipe( pipe );
98  if( m_handle )
100  m_handle = pipe;
101  return *this;
102  }
103 
104 
105  inline bool SAL_CALL Pipe::is() const
106  {
107  return m_handle != NULL;
108  }
109 
110 
111  inline bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
112  {
113  return m_handle == rPipe.m_handle;
114  }
115 
116 
117  inline void SAL_CALL Pipe::close()
118  {
120  }
121 
122 
123  inline void SAL_CALL Pipe::clear()
124  {
125  if( m_handle )
126  {
128  m_handle = NULL;
129  }
130  }
131 
132 
133  inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
134  {
136  if( Connection.is() )
137  return osl_Pipe_E_None;
138  else
139  return getError();
140  }
141 
142 
143  inline oslPipeError SAL_CALL Pipe::getError() const
144  {
145  return osl_getLastPipeError( NULL );
146  }
147 
148 
149  inline oslPipe SAL_CALL Pipe::getHandle() const
150  {
151  return m_handle;
152  }
153 
154 
156 
157 
159  : Pipe( hPipe )
160  {
161  }
162 
163 
164  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
165  : Pipe( strName, Options , rSec )
166  {}
167 
168 
169  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
170  : Pipe( strName, Options )
171  {}
172 
174  : Pipe( pipe , noacquire )
175  {}
176 
177 
178  inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
179  {
180  return osl_readPipe( m_handle, pBuffer, n );
181  }
182 
183 
184  inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
185  {
186  return osl_writePipe( m_handle, pBuffer , n );
187  }
188 
189 
190  inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
191  {
192  return osl_receivePipe( m_handle, pBuffer , BytesToRead );
193  }
194 
195 
196  inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
197  {
198  return osl_sendPipe( m_handle, pBuffer , BytesToSend );
199  }
200 
201 }
202 #endif
203 
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
oslPipeError accept(StreamPipe &Connection)
Accept connection on an existing pipe.
Definition: pipe.hxx:133
SAL_DLLPUBLIC void osl_acquirePipe(oslPipe Pipe)
Increases the refcount of the pipe.
void clear()
releases the underlying handle
Definition: pipe.hxx:123
bool operator==(const Pipe &rPipe) const
Definition: pipe.hxx:111
oslPipe m_handle
Definition: pipe_decl.hxx:19
SAL_DLLPUBLIC sal_Int32 osl_writePipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
Writes blocking onto the pipe.
SAL_DLLPUBLIC sal_Int32 osl_readPipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
Reads blocking from the pipe.
oslPipeError getError() const
Delivers a constant describing the last error for the pipe system.
Definition: pipe.hxx:143
Represents a pipe.
Definition: pipe_decl.hxx:16
sal_Int32 read(void *pBuffer, sal_Int32 n) const
Retrieves n bytes from the stream and copies them into pBuffer.
Definition: pipe.hxx:178
__sal_NoAcquire
Definition: types.h:332
sal_Int32 write(const void *pBuffer, sal_Int32 n) const
Writes n bytes from pBuffer to the stream.
Definition: pipe.hxx:184
Definition: pipe.h:18
sal_uInt32 oslPipeOptions
Pipe creation options.
Definition: pipe.h:36
void close()
Closes the pipe.
Definition: pipe.hxx:117
SAL_DLLPUBLIC void osl_closePipe(oslPipe Pipe)
Close the pipe.
SAL_DLLPUBLIC void osl_releasePipe(oslPipe Pipe)
Decreases the refcount of the pipe.
StreamPipe()
Creates an unattached pipe.
Definition: pipe.hxx:155
Encapsulate security information for one user.
Definition: security_decl.hxx:18
Pipe()
Does not create a pipe.
Definition: pipe.hxx:15
bool is() const
Definition: pipe.hxx:105
~Pipe()
Destructor.
Definition: pipe.hxx:56
SAL_DLLPUBLIC oslPipe osl_acceptPipe(oslPipe Pipe)
definition of a no acquire enum for ctors
Definition: types.h:336
sal_Int32 send(const void *pBuffer, sal_Int32 BytesToSend) const
Tries to sends BytesToSend data from the connected pipe.
Definition: pipe.hxx:196
oslPipe getHandle() const
Definition: pipe.hxx:149
SAL_DLLPUBLIC oslPipeError osl_getLastPipeError(oslPipe Pipe)
SAL_DLLPUBLIC sal_Int32 osl_receivePipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
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:63
A pipe to send or receive a stream of data.
Definition: pipe_decl.hxx:129
sal_Int32 recv(void *pBuffer, sal_Int32 BytesToRead) const
Tries to receives BytesToRead data from the connected pipe,.
Definition: pipe.hxx:190
Pipe & operator=(const Pipe &pipe)
Assignment operator.
Definition: pipe.hxx:77
struct oslPipeImpl * oslPipe
Definition: pipe.h:40
SAL_DLLPUBLIC sal_Int32 osl_sendPipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
oslPipeError
Definition: pipe.h:17
SAL_DLLPUBLIC oslPipe osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options, oslSecurity Security)
Create or open a pipe.