winapi_common
process_io.hpp
1 // Copyright (c) 2020 Egor Tensin <Egor.Tensin@gmail.com>
2 // This file is part of the "winapi-common" project.
3 // For details, see https://github.com/egor-tensin/winapi-common.
4 // Distributed under the MIT License.
5 
6 #pragma once
7 
8 #include "handle.hpp"
9 #include "path.hpp"
10 #include "pipe.hpp"
11 
12 #include <string>
13 #include <utility>
14 
15 namespace winapi {
16 namespace process {
17 
18 struct Stream {
19  Stream(Handle&& handle) : handle{std::move(handle)} {}
20 
21  Handle handle;
22 };
23 
25 struct Stdin : Stream {
27  Stdin();
29  explicit Stdin(const std::string& file);
31  explicit Stdin(const CanonicalPath& file);
33  explicit Stdin(Pipe&);
34 };
35 
37 struct Stdout : Stream {
39  Stdout();
41  explicit Stdout(const std::string& file);
43  explicit Stdout(const CanonicalPath& file);
45  explicit Stdout(Pipe&);
46 };
47 
49 struct Stderr : Stream {
51  Stderr();
53  explicit Stderr(const std::string& file);
55  explicit Stderr(const CanonicalPath& file);
57  explicit Stderr(Pipe&);
58 };
59 
61 struct IO {
62  IO() = default;
63 
64  void close();
65 
66  Stdin std_in;
67  Stdout std_out;
68  Stderr std_err;
69 };
70 
71 } // namespace process
72 } // namespace winapi
Absolute, canonical path.
Definition: path.hpp:13
HANDLE wrapper.
Definition: handle.hpp:25
Anonymous pipe wrapper.
Definition: pipe.hpp:15
Child process IO settings.
Definition: process_io.hpp:61
Redirect child process's stderr.
Definition: process_io.hpp:49
Redirect child process's stdin.
Definition: process_io.hpp:25
Redirect child process's stdout.
Definition: process_io.hpp:37