nss: upgrade to release 3.73
[LibreOffice.git] / include / osl / pipe_decl.hxx
blob7f35e1155b484c07b19b8e5849ad88290023652c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_OSL_PIPE_DECL_HXX
20 #define INCLUDED_OSL_PIPE_DECL_HXX
22 #include "osl/pipe.h"
23 #include "osl/security.hxx"
24 #include "rtl/ustring.hxx"
26 namespace osl
28 class StreamPipe;
30 /** Represents a pipe.
32 class Pipe
34 protected:
35 oslPipe m_handle;
37 public:
38 /** Does not create a pipe. Use assignment operator to
39 make this a usable pipe.
41 inline Pipe();
43 /** Creates an insecure pipe that is accessible for all users.
44 @param strName
45 @param Options
47 inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options);
49 /** Creates a secure pipe that access depends on the umask settings.
50 @param strName
51 @param Options
52 @param rSecurity
54 inline Pipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security& rSecurity);
56 /** Copy constructor.
58 inline Pipe(const Pipe& pipe);
60 #if defined LIBO_INTERNAL_ONLY
61 inline Pipe(Pipe&& other) noexcept;
62 #endif
64 /** Constructs a Pipe reference without acquiring the handle
66 inline Pipe(oslPipe pipe, __sal_NoAcquire noacquire);
68 /** Creates pipe as wrapper around the underlying oslPipe.
69 @param Pipe
71 inline Pipe(oslPipe Pipe);
73 /** Destructor. Destroys the underlying oslPipe.
75 inline ~Pipe();
77 inline bool SAL_CALL is() const;
79 /** Creates an insecure pipe that is accessible for all users
80 with the given attributes.
81 If the pipe was already created, the old one will be discarded.
82 @param strName
83 @param Options
84 @param rSec
85 @return True if socket was successfully created.
87 inline bool create(const ::rtl::OUString& strName, oslPipeOptions Options,
88 const Security& rSec);
90 /** Creates a secure that access rights depend on the umask settings
91 with the given attributes.
93 If socket was already created, the old one will be discarded.
94 @param strName
95 @param Options
96 @return True if socket was successfully created.
98 inline bool create(const ::rtl::OUString& strName, oslPipeOptions Options = osl_Pipe_OPEN);
100 /** releases the underlying handle
102 inline void SAL_CALL clear();
104 /** Assignment operator. If pipe was already created, the old one will
105 be discarded.
107 inline Pipe& SAL_CALL operator=(const Pipe& pipe);
109 #if defined LIBO_INTERNAL_ONLY
110 inline Pipe& operator=(Pipe&& other) noexcept;
111 #endif
113 /** Assignment operator. If pipe was already created, the old one will
114 be discarded.
116 inline Pipe& SAL_CALL operator=(const oslPipe pipe);
118 /** Checks if the pipe is valid.
119 @return True if the object represents a valid pipe.
121 inline bool SAL_CALL isValid() const;
123 inline bool SAL_CALL operator==(const Pipe& rPipe) const;
125 /** Closes the pipe.
127 inline void SAL_CALL close();
129 /** Accept connection on an existing pipe
131 inline oslPipeError SAL_CALL accept(StreamPipe& Connection);
133 /** Delivers a constant describing the last error for the pipe system.
134 @return ENONE if no error occurred, invalid_PipeError if
135 an unknown (unmapped) error occurred, otherwise an enum describing the
136 error.
138 inline oslPipeError SAL_CALL getError() const;
140 inline oslPipe SAL_CALL getHandle() const;
143 /** A pipe to send or receive a stream of data.
145 class StreamPipe : public Pipe
147 public:
148 /** Creates an unattached pipe. You must attach the pipe to an oslPipe
149 e.g. by using the operator=(oslPipe), before you can use the stream-
150 functionality of the object.
152 inline StreamPipe();
154 /** Creates pipe as wrapper around the underlying oslPipe.
156 @param Pipe
158 inline StreamPipe(oslPipe Pipe);
160 /** Creates a pipe.
162 @param[in] strName Pipe name
163 @param[in] Options Pipe options
165 inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options = osl_Pipe_OPEN);
167 /** Creates a pipe.
169 @param[in] strName Pipe name
170 @param[in] Options Pipe options
171 @param[in] rSec Security for the pipe
173 inline StreamPipe(const ::rtl::OUString& strName, oslPipeOptions Options, const Security& rSec);
175 /** Constructs a Pipe reference without acquiring the handle
177 inline StreamPipe(oslPipe pipe, __sal_NoAcquire noacquire);
179 /** Attaches the oslPipe to this object. If the object
180 already was attached to an oslPipe, the old one will
181 be closed and destroyed.
183 @param[in] Pipe Pipe to attach to this object
185 inline StreamPipe& SAL_CALL operator=(oslPipe Pipe);
187 /** Assignment operator
189 inline StreamPipe& SAL_CALL operator=(const Pipe& pipe);
191 /** Tries to receives BytesToRead data from the connected pipe,
193 @param[out] pBuffer Points to a buffer that will be filled with the received
194 data.
195 @param[in] BytesToRead The number of bytes to read. pBuffer must have at least
196 this size.
198 @return the number of received bytes.
200 inline sal_Int32 SAL_CALL recv(void* pBuffer, sal_Int32 BytesToRead) const;
202 /** Tries to sends BytesToSend data from the connected pipe.
204 @param[in] pBuffer Points to a buffer that contains the send-data.
205 @param[in] BytesToSend The number of bytes to send. pBuffer must have at least
206 this size.
208 @return the number of transferred bytes.
210 inline sal_Int32 SAL_CALL send(const void* pBuffer, sal_Int32 BytesToSend) const;
212 /** Retrieves n bytes from the stream and copies them into pBuffer.
213 The method avoids incomplete reads due to packet boundaries.
215 @param[in] pBuffer receives the read data.
216 @param[in] n the number of bytes to read. pBuffer must be large enough
217 to hold the n bytes!
219 @return the number of read bytes. The number will only be smaller than
220 n if an exceptional condition (e.g. connection closed) occurs.
222 inline sal_Int32 SAL_CALL read(void* pBuffer, sal_Int32 n) const;
224 /** Writes n bytes from pBuffer to the stream. The method avoids
225 incomplete writes due to packet boundaries.
227 @param[in] pBuffer contains the data to be written.
228 @param[in] n the number of bytes to write.
230 @return the number of written bytes. The number will only be smaller than
231 n if an exceptional condition (e.g. connection closed) occurs.
233 sal_Int32 SAL_CALL write(const void* pBuffer, sal_Int32 n) const;
236 #endif
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */