nixd
Loading...
Searching...
No Matches
StreamProc.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <llvm/Support/raw_ostream.h>
7
8namespace nixd {
9
10struct StreamProc {
11private:
12 std::unique_ptr<util::PipedProc> Proc;
13 std::unique_ptr<llvm::raw_fd_ostream> Stream;
14
15public:
16 /// \brief Launch a streamed process with \p Action.
17 ///
18 /// The value returned by \p Action will be interpreted as process's exit
19 /// value.
20 StreamProc(const std::function<int()> &Action);
21
22 [[nodiscard]] llvm::raw_fd_ostream &stream() const {
23 assert(Stream);
24 return *Stream;
25 }
26
27 [[nodiscard]] util::PipedProc &proc() const {
28 assert(Proc);
29 return *Proc;
30 }
31
32 [[nodiscard]] std::unique_ptr<lspserver::InboundPort> mkIn() const;
33
34 [[nodiscard]] std::unique_ptr<lspserver::OutboundPort> mkOut() const;
35};
36
37} // namespace nixd
util::PipedProc & proc() const
Definition StreamProc.h:27
StreamProc(const std::function< int()> &Action)
Launch a streamed process with Action.
std::unique_ptr< lspserver::InboundPort > mkIn() const
Definition StreamProc.cpp:8
std::unique_ptr< lspserver::OutboundPort > mkOut() const
llvm::raw_fd_ostream & stream() const
Definition StreamProc.h:22