LibreOffice: osl/pipe.hxx Source File

LibreOffice LibreOffice 5.2 SDK C/C++ API Reference

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 )
50 osl_acquirePipe( m_handle );
51 }
52
53
54 inline Pipe::Pipe( oslPipe pipe, __sal_NoAcquire )
55 : m_handle ( pipe )
56 {}
57
58
59 inline Pipe::Pipe(oslPipe pipe)
60 : m_handle( pipe )
61 {
62 if( m_handle )
63 osl_acquirePipe( m_handle );
64 }
65
66
67 inline Pipe::~Pipe()
68 {
69 if( m_handle )
70 osl_releasePipe( m_handle );
71 }
72
73
74 inline bool Pipe::create( const ::rtl::OUString & strName,
75 oslPipeOptions Options, const Security &rSec )
76 {
77 *this = Pipe( strName, Options, rSec );
78 return is();
79 }
80
81
82 inline bool Pipe::create( const ::rtl::OUString & strName, oslPipeOptions Options )
83 {
84 *this = Pipe( strName, Options );
85 return is();
86 }
87
88 inline Pipe& SAL_CALL Pipe::operator= (const Pipe& pipe)
89 {
90 *this = pipe.getHandle();
91 return *this;
92 }
93
94
95 inline Pipe & SAL_CALL Pipe::operator=( oslPipe pipe)
96 {
97 if( pipe )
98 osl_acquirePipe( pipe );
99 if( m_handle )
100 osl_releasePipe( m_handle );
101 m_handle = pipe;
102 return *this;
103 }
104
105
106 inline bool SAL_CALL Pipe::is() const
107 {
108 return m_handle != NULL;
109 }
110
111
112 inline bool SAL_CALL Pipe::operator==( const Pipe& rPipe ) const
113 {
114 return m_handle == rPipe.m_handle;
115 }
116
117
118 inline void SAL_CALL Pipe::close()
119 {
120 osl_closePipe( m_handle );
121 }
122
123
124 inline void SAL_CALL Pipe::clear()
125 {
126 if( m_handle )
127 {
128 osl_releasePipe( m_handle );
129 m_handle = NULL;
130 }
131 }
132
133
134 inline oslPipeError SAL_CALL Pipe::accept(StreamPipe& Connection)
135 {
136 Connection = StreamPipe( osl_acceptPipe( m_handle ), SAL_NO_ACQUIRE);
137 if( Connection.is() )
138 return osl_Pipe_E_None;
139 else
140 return getError();
141 }
142
143
144 inline oslPipeError SAL_CALL Pipe::getError() const
145 {
146 return osl_getLastPipeError( NULL );
147 }
148
149
150 inline oslPipe SAL_CALL Pipe::getHandle() const
151 {
152 return m_handle;
153 }
154
155
156 inline StreamPipe::StreamPipe(){}
157
158
159 inline StreamPipe::StreamPipe(oslPipe hPipe)
160 : Pipe( hPipe )
161 {
162 }
163
164
165 inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security &rSec )
166 : Pipe( strName, Options , rSec )
167 {}
168
169
170 inline StreamPipe::StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options )
171 : Pipe( strName, Options )
172 {}
173
174
175 inline StreamPipe::StreamPipe(const StreamPipe& aPipe)
176 : Pipe( aPipe )
177 {}
178
179 inline StreamPipe::StreamPipe( oslPipe pipe, __sal_NoAcquire noacquire )
180 : Pipe( pipe , noacquire )
181 {}
182
183
184 inline sal_Int32 SAL_CALL StreamPipe::read(void* pBuffer, sal_Int32 n) const
185 {
186 return osl_readPipe( m_handle, pBuffer, n );
187 }
188
189
190 inline sal_Int32 SAL_CALL StreamPipe::write(const void* pBuffer, sal_Int32 n) const
191 {
192 return osl_writePipe( m_handle, pBuffer , n );
193 }
194
195
196 inline sal_Int32 SAL_CALL StreamPipe::recv(void* pBuffer, sal_Int32 BytesToRead) const
197 {
198 return osl_receivePipe( m_handle, pBuffer , BytesToRead );
199 }
200
201
202 inline sal_Int32 SAL_CALL StreamPipe::send(const void* pBuffer, sal_Int32 BytesToSend) const
203 {
204 return osl_sendPipe( m_handle, pBuffer , BytesToSend );
205 }
206
207 }
208 #endif
209
210 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
osl_acquirePipe
SAL_DLLPUBLIC void osl_acquirePipe(oslPipe Pipe)
increases the refcount of the pipe.
osl_Pipe_E_None
Definition: pipe.h:35
osl::Pipe::getError
oslPipeError getError() const
Delivers a constant describing the last error for the pipe system.
Definition: pipe.hxx:144
pipe_decl.hxx
osl::Pipe::create
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:74
osl::StreamPipe::StreamPipe
StreamPipe()
Creates an unattached pipe.
Definition: pipe.hxx:156
osl::Pipe::close
void close()
Closes the pipe.
Definition: pipe.hxx:118
osl::StreamPipe::recv
sal_Int32 recv(void *pBuffer, sal_Int32 BytesToRead) const
Tries to receives BytesToRead data from the connected pipe,.
Definition: pipe.hxx:196
osl::StreamPipe::write
sal_Int32 write(const void *pBuffer, sal_Int32 n) const
Writes n bytes from pBuffer to the stream.
Definition: pipe.hxx:190
osl::Pipe::m_handle
oslPipe m_handle
Definition: pipe_decl.hxx:35
osl_sendPipe
SAL_DLLPUBLIC sal_Int32 osl_sendPipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
osl_receivePipe
SAL_DLLPUBLIC sal_Int32 osl_receivePipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
osl_acceptPipe
SAL_DLLPUBLIC oslPipe osl_acceptPipe(oslPipe Pipe)
osl::Security
capsulate security information for one user.
Definition: security_decl.hxx:34
osl::Pipe::operator==
bool operator==(const Pipe &rPipe) const
Definition: pipe.hxx:112
osl::Pipe::Pipe
Pipe()
Does not create a pipe.
Definition: pipe.hxx:31
osl::Pipe::accept
oslPipeError accept(StreamPipe &Connection)
Accept connection on an existing pipe.
Definition: pipe.hxx:134
osl_closePipe
SAL_DLLPUBLIC void osl_closePipe(oslPipe)
closes the pipe, any read,write or accept actions stop immeadiatly.
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:384
osl_releasePipe
SAL_DLLPUBLIC void osl_releasePipe(oslPipe)
decreases the refcount of the pipe.
osl
Definition: conditn.hxx:32
oslPipeOptions
sal_uInt32 oslPipeOptions
Definition: pipe.h:49
osl::StreamPipe
A pipe to send or receive a stream of data.
Definition: pipe_decl.hxx:139
osl::Pipe::getHandle
oslPipe getHandle() const
Definition: pipe.hxx:150
SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition: types.h:388
config.h
osl_getLastPipeError
SAL_DLLPUBLIC oslPipeError osl_getLastPipeError(oslPipe Pipe)
osl::StreamPipe::read
sal_Int32 read(void *pBuffer, sal_Int32 n) const
Retrieves n bytes from the stream and copies them into pBuffer.
Definition: pipe.hxx:184
osl::Pipe
Represents a pipe.
Definition: pipe_decl.hxx:32
osl_writePipe
SAL_DLLPUBLIC sal_Int32 osl_writePipe(oslPipe Pipe, const void *pBuffer, sal_Int32 BufferSize)
Writes blocking onto the pipe.
osl_readPipe
SAL_DLLPUBLIC sal_Int32 osl_readPipe(oslPipe Pipe, void *pBuffer, sal_Int32 BufferSize)
Reads blocking from the pipe.
osl::Pipe::operator=
Pipe & operator=(const Pipe &pipe)
Assignment operator.
Definition: pipe.hxx:88
osl::Pipe::clear
void clear()
releases the underlying handle
Definition: pipe.hxx:124
oslPipeError
oslPipeError
Definition: pipe.h:34
osl_createPipe
SAL_DLLPUBLIC oslPipe osl_createPipe(rtl_uString *strPipeName, oslPipeOptions Options, oslSecurity Security)
oslPipe
struct oslPipeImpl * oslPipe
Definition: pipe.h:53
osl::Pipe::~Pipe
~Pipe()
Destructor.
Definition: pipe.hxx:67
osl::StreamPipe::send
sal_Int32 send(const void *pBuffer, sal_Int32 BytesToSend) const
Tries to sends BytesToSend data from the connected pipe.
Definition: pipe.hxx:202
osl::Pipe::is
bool is() const
Definition: pipe.hxx:106