16
16
// / State of a child process pipe
17
17
class proc_pipe
18
18
{
19
- public:
20
- proc_pipe () = default ;
21
-
22
19
protected:
20
+ proc_pipe () = default ;
23
21
HANDLE hProcess = 0 ; // /< WIN32 process handle
24
22
HANDLE hThread = 0 ; // /< WIN32 thread handle
25
23
FILE *file_ = nullptr ; // /< C file handle for I/O (not both)
@@ -32,10 +30,8 @@ class proc_pipe
32
30
// / State of a child process pipe
33
31
class proc_pipe
34
32
{
35
- public:
36
- proc_pipe () = default ;
37
-
38
33
protected:
34
+ proc_pipe () = default ;
39
35
pid_t pid = 0 ; // /< POSIX process identifier
40
36
FILE *file_ = nullptr ; // /< C file handle for input or output (not both)
41
37
};
@@ -48,18 +44,22 @@ class proc_pipe
48
44
class common_pipe : public proc_pipe
49
45
{
50
46
public:
51
- common_pipe () : proc_pipe{} {}
52
- virtual ~common_pipe () noexcept {
53
- if (opened ())
54
- close ();
55
- }
56
47
FILE *file () const { return file_; }
57
48
int close (int *exit_code = nullptr );
58
49
bool opened () const { return file_ != nullptr ; }
59
50
bool exceptions () const { return exceptions_; }
60
51
void exceptions (bool exc) { exceptions_ = exc; }
61
52
62
53
protected:
54
+ common_pipe () = default ;
55
+ common_pipe (const common_pipe&) = delete ;
56
+ common_pipe& operator =(const common_pipe&) = delete ;
57
+ common_pipe (common_pipe&&) noexcept = default ;
58
+ common_pipe& operator =(common_pipe&&) noexcept = default ;
59
+ ~common_pipe () noexcept {
60
+ if (opened ())
61
+ close ();
62
+ }
63
63
bool exceptions_ = false ;
64
64
int error (int err, const std::string& what) const ;
65
65
int open (const std::string &command, char mode);
@@ -69,7 +69,7 @@ class common_pipe : public proc_pipe
69
69
class ipipe : public common_pipe
70
70
{
71
71
public:
72
- ipipe () : common_pipe{} {}
72
+ ipipe ();
73
73
int open (const std::string &cmd) { return common_pipe::open (cmd, ' r' ); }
74
74
int read (std::string &data);
75
75
};
@@ -78,7 +78,7 @@ class ipipe : public common_pipe
78
78
class opipe : public common_pipe
79
79
{
80
80
public:
81
- opipe () : common_pipe{} {}
81
+ opipe ();
82
82
int open (const std::string &cmd) { return common_pipe::open (cmd, ' w' ); }
83
83
int write (std::string_view data);
84
84
int flush (std::string_view data = {});
0 commit comments