Split out io_pipe_t, let io_buffer_t inherit it

This commit is contained in:
Cheer Xiao
2013-01-15 17:31:36 +08:00
parent e020ad0c06
commit 00b6431ad9
5 changed files with 67 additions and 62 deletions

29
io.h
View File

@@ -27,15 +27,6 @@ class io_data_t
/** FD to redirect */
int fd;
/**
Type-specific parameter for redirection
*/
union
{
/** Fds for IO_PIPE and for IO_BUFFER */
int pipe_fd[2];
} param1;
virtual void print() const;
/** Set to true if this is an input io redirection */
@@ -44,7 +35,6 @@ class io_data_t
io_data_t(io_mode_t m = IO_INVALID, int f=0) :
io_mode(m),
fd(f),
param1(),
is_input(0)
{
}
@@ -113,16 +103,31 @@ class io_file_t : public io_data_t
}
};
class io_buffer_t : public io_data_t
class io_pipe_t : public io_data_t
{
public:
int pipe_fd[2];
virtual void print() const;
io_pipe_t(int f):
io_data_t(IO_PIPE, f),
pipe_fd()
{
}
};
class io_buffer_t : public io_pipe_t
{
private:
/** buffer to save output in */
shared_ptr<std::vector<char> > out_buffer;
io_buffer_t(int f):
io_data_t(IO_BUFFER, f),
io_pipe_t(f),
out_buffer()
{
io_mode = IO_BUFFER;
}
public: