Lely core libraries  2.3.4
pipe.hpp
Go to the documentation of this file.
1 
22 #ifndef LELY_IO_PIPE_HPP_
23 #define LELY_IO_PIPE_HPP_
24 
25 #ifndef __cplusplus
26 #error "include <lely/io/pipe.h> for the C interface"
27 #endif
28 
29 #include <lely/io/io.hpp>
30 #include <lely/io/pipe.h>
31 
32 #include <utility>
33 
34 namespace lely {
35 
37 class IOPipe : public IOHandle {
38  public:
39  IOPipe() = default;
40 
41  IOPipe(const IOPipe& pipe) noexcept : IOHandle(pipe) {}
42 
43  IOPipe(IOPipe&& pipe) noexcept : IOHandle(::std::forward<IOPipe>(pipe)) {}
44 
45  IOPipe&
46  operator=(const IOPipe& pipe) noexcept {
47  IOHandle::operator=(pipe);
48  return *this;
49  }
50 
51  IOPipe&
52  operator=(IOPipe&& pipe) noexcept {
53  IOHandle::operator=(::std::forward<IOPipe>(pipe));
54  return *this;
55  }
56 
57  static int
58  open(IOPipe pipe[2]) noexcept {
59  io_handle_t handle_vector[2];
60  if (io_open_pipe(handle_vector) == -1) return -1;
61  pipe[0] = IOPipe(handle_vector[0]);
62  pipe[1] = IOPipe(handle_vector[1]);
63  return 0;
64  }
65 
66  protected:
67  IOPipe(io_handle_t handle) noexcept : IOHandle(handle) {}
68 };
69 
70 } // namespace lely
71 
72 #endif // !LELY_IO_PIPE_HPP_
An I/O device handle.
Definition: io.hpp:35
A pipe I/O device handle.
Definition: pipe.hpp:37
This header file is part of the I/O library; it contains the C++ interface of the I/O device handle.
This header file is part of the I/O library; it contains the pipe declarations.
int io_open_pipe(io_handle_t handle_vector[2])
Opens a pipe.
Definition: pipe.c:54
An I/O device handle.
Definition: handle.h:33