LibreOffice
LibreOffice 5.3 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 <sal/config.h>
23 
24 #include <cstddef>
25 
26 #include <osl/pipe_decl.hxx>
27 
28 namespace osl
29 {
30 
31  inline Pipe::Pipe()
32  : m_handle( NULL )
33  {}
34 
35 
36  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options )
37  : m_handle( osl_createPipe( strName.pData, Options , NULL ) )
38  {}
39 
40 
41  inline Pipe::Pipe(const ::rtl::OUString& strName, oslPipeOptions Options,const Security & rSecurity)
42  : m_handle( osl_createPipe( strName.pData, Options , rSecurity.getHandle() ) )
43  {}
44 
45 
46  inline Pipe::Pipe(const Pipe& pipe )
47  : m_handle( pipe.m_handle )
48  {
49  if( m_handle )
51  }
52 
53 #if defined LIBO_INTERNAL_ONLY
54  Pipe::Pipe(Pipe && other): m_handle(other.m_handle) {
55  other.m_handle = nullptr;
56  }
57 #endif
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 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 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 #if defined LIBO_INTERNAL_ONLY
100  Pipe & Pipe::operator =(Pipe && other) {
101  if (m_handle != nullptr) {
103  }
104  m_handle = other.m_handle;
105  other.m_handle = nullptr;
106  return *this;
107  }
108 #endif
109 
110  inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
111  {
112  if( pipe )
113  osl_acquirePipe( pipe );
114  if( m_handle )
116  m_handle = pipe;
117  return *this;
118  }
119 
120 
121  inline bool SAL_CALL Pipe::is() const
122  {
123  return m_handle != NULL;
124  }
125 
126 
127  inline bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
128  {
129  return m_handle == rPipe.m_handle;
130  }
131 
132 
133  inline void SAL_CALL Pipe::close()
134  {
136  }
137 
138 
139  inline void SAL_CALL Pipe::clear()
140  {
141  if( m_handle )
142  {
144  m_handle = NULL;
145  }
146  }
147 
148 
149  inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
150  {
152  if( Connection.is() )
153  return osl_Pipe_E_None;
154  else
155  return getError();
156  }
157 
158 
159  inline oslPipeError SAL_CALL Pipe::getError() const
160  {
161  return osl_getLastPipeError( NULL );
162  }
163 
164 
165  inline oslPipe SAL_CALL Pipe::getHandle() const
166  {
167  return m_handle;
168  }
169 
170 
172 
173 
175  : Pipe( hPipe )
176  {
177  }
178 
179 
180  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
181  : Pipe( strName, Options , rSec )
182  {}
183 
184 
185  inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
186  : Pipe( strName, Options )
187  {}
188 
189 
190  inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
191  : Pipe( aPipe )
192  {}
193 
195  : Pipe( pipe , noacquire )
196  {}
197 
198 
199  inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
200  {
201  return osl_readPipe( m_handle, pBuffer, n );
202  }
203 
204 
205  inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
206  {
207  return osl_writePipe( m_handle, pBuffer , n );
208  }
209 
210 
211  inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
212  {
213  return osl_receivePipe( m_handle, pBuffer , BytesToRead );
214  }
215 
216 
217  inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
218  {
219  return osl_sendPipe( m_handle, pBuffer , BytesToSend );
220  }
221 
222 }
223 #endif
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_DLLPUBLIC oslPipeError osl_getLastPipeError(oslPipe Pipe)
Pipe()
Does not create a pipe.
Definition: pipe.hxx:31
SAL_DLLPUBLIC void osl_acquirePipe(oslPipe Pipe)
increases the refcount of the pipe.
A pipe to send or receive a stream of data.
Definition: pipe_decl.hxx:147
oslPipeError
Definition: pipe.h:34
void clear()
releases the underlying handle
Definition: pipe.hxx:139
StreamPipe()
Creates an unattached pipe.
Definition: pipe.hxx:171
bool operator==(const Pipe &rPipe) const
Definition: pipe.hxx:127
sal_uInt32 oslPipeOptions
Definition: pipe.h:49
Definition: pipe.h:35
void close()
Closes the pipe.
Definition: pipe.hxx:133
SAL_DLLPUBLIC oslPipe osl_acceptPipe(oslPipe Pipe)
SAL_DLLPUBLIC oslPipe osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options, oslSecurity Security)
SAL_DLLPUBLIC sal_Int32 osl_writePipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
Writes blocking onto the pipe.
SAL_DLLPUBLIC void osl_releasePipe(oslPipe)
decreases 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:199
__sal_NoAcquire
Definition: types.h:384
bool is() const
Definition: pipe.hxx:121
~Pipe()
Destructor.
Definition: pipe.hxx:72
SAL_DLLPUBLIC sal_Int32 osl_sendPipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
oslPipe getHandle() const
Definition: pipe.hxx:165
oslPipeError accept(StreamPipe &Connection)
Accept connection on an existing pipe.
Definition: pipe.hxx:149
sal_Int32 send(const void *pBuffer, sal_Int32 BytesToSend) const
Tries to sends BytesToSend data from the connected pipe.
Definition: pipe.hxx:217
SAL_DLLPUBLIC void osl_closePipe(oslPipe)
closes the pipe, any read,write or accept actions stop immeadiatly.
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:79
SAL_DLLPUBLIC sal_Int32 osl_receivePipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
definition of a no acquire enum for ctors
Definition: types.h:388
oslPipe m_handle
Definition: pipe_decl.hxx:35
oslPipeError getError() const
Delivers a constant describing the last error for the pipe system.
Definition: pipe.hxx:159
Represents a pipe.
Definition: pipe_decl.hxx:32
Pipe & operator=(const Pipe &pipe)
Assignment operator.
Definition: pipe.hxx:93
sal_Int32 write(const void *pBuffer, sal_Int32 n) const
Writes n bytes from pBuffer to the stream.
Definition: pipe.hxx:205
SAL_DLLPUBLIC sal_Int32 osl_readPipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
Reads blocking from the pipe.
sal_Int32 recv(void *pBuffer, sal_Int32 BytesToRead) const
Tries to receives BytesToRead data from the connected pipe,.
Definition: pipe.hxx:211
capsulate security information for one user.
Definition: security_decl.hxx:34
struct oslPipeImpl * oslPipe
Definition: pipe.h:53