1 | //===-- PipeBase.h -----------------------------------------------*- C++ |
2 | //-*-===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef LLDB_HOST_PIPEBASE_H |
11 | #define LLDB_HOST_PIPEBASE_H |
12 | |
13 | #include <chrono> |
14 | #include <string> |
15 | |
16 | #include "lldb/Utility/Status.h" |
17 | #include "llvm/ADT/SmallVector.h" |
18 | #include "llvm/ADT/StringRef.h" |
19 | |
20 | namespace lldb_private { |
21 | class PipeBase { |
22 | public: |
23 | virtual ~PipeBase(); |
24 | |
25 | virtual Status CreateNew(bool child_process_inherit) = 0; |
26 | virtual Status CreateNew(llvm::StringRef name, |
27 | bool child_process_inherit) = 0; |
28 | virtual Status CreateWithUniqueName(llvm::StringRef prefix, |
29 | bool child_process_inherit, |
30 | llvm::SmallVectorImpl<char> &name) = 0; |
31 | |
32 | virtual Status OpenAsReader(llvm::StringRef name, |
33 | bool child_process_inherit) = 0; |
34 | |
35 | Status OpenAsWriter(llvm::StringRef name, bool child_process_inherit); |
36 | virtual Status |
37 | OpenAsWriterWithTimeout(llvm::StringRef name, bool child_process_inherit, |
38 | const std::chrono::microseconds &timeout) = 0; |
39 | |
40 | virtual bool CanRead() const = 0; |
41 | virtual bool CanWrite() const = 0; |
42 | |
43 | virtual lldb::pipe_t GetReadPipe() const = 0; |
44 | virtual lldb::pipe_t GetWritePipe() const = 0; |
45 | |
46 | virtual int GetReadFileDescriptor() const = 0; |
47 | virtual int GetWriteFileDescriptor() const = 0; |
48 | virtual int ReleaseReadFileDescriptor() = 0; |
49 | virtual int ReleaseWriteFileDescriptor() = 0; |
50 | virtual void CloseReadFileDescriptor() = 0; |
51 | virtual void CloseWriteFileDescriptor() = 0; |
52 | |
53 | // Close both descriptors |
54 | virtual void Close() = 0; |
55 | |
56 | // Delete named pipe. |
57 | virtual Status Delete(llvm::StringRef name) = 0; |
58 | |
59 | virtual Status Write(const void *buf, size_t size, size_t &bytes_written) = 0; |
60 | virtual Status ReadWithTimeout(void *buf, size_t size, |
61 | const std::chrono::microseconds &timeout, |
62 | size_t &bytes_read) = 0; |
63 | Status Read(void *buf, size_t size, size_t &bytes_read); |
64 | }; |
65 | } |
66 | |
67 | #endif |
68 | |