#include <pstream.h>
Inheritance diagram for redi::basic_pstreambuf< CharT, Traits >:
Public Types | |
typedef CharT | char_type |
typedef Traits | traits_type |
typedef traits_type::int_type | int_type |
typedef traits_type::off_type | off_type |
typedef traits_type::pos_type | pos_type |
typedef int | fd_t |
Type used for file descriptors. | |
Public Member Functions | |
basic_pstreambuf () | |
Default constructor. | |
basic_pstreambuf (const std::string &command, pmode mode) | |
Constructor that initialises the buffer with command. | |
basic_pstreambuf (const std::string &file, const std::vector< std::string > &argv, pmode mode) | |
Constructor that initialises the buffer with file and argv.. | |
~basic_pstreambuf () | |
Destructor. | |
basic_pstreambuf * | open (const std::string &command, pmode mode) |
Initialise the stream buffer with command. | |
basic_pstreambuf * | open (const std::string &file, const std::vector< std::string > &argv, pmode mode) |
Initialise the stream buffer with file and argv. | |
basic_pstreambuf * | close () |
Close the stream buffer and wait for the process to exit. | |
basic_pstreambuf * | kill (int signal=SIGTERM) |
Send a signal to the process. | |
void | peof () |
Close the pipe connected to the process' stdin. | |
bool | read_err (bool readerr=true) |
Change active input source. | |
bool | is_open () const |
Report whether the stream buffer has been initialised. | |
bool | exited () |
Report whether the process has exited. | |
int | status () const |
Return the exit status of the process. | |
int | error () const |
Return the error number for the most recent failed operation. | |
Protected Types | |
enum | buf_read_src { rsrc_out = 0, rsrc_err = 1 } |
Enumerated type to indicate whether stdout or stderr is to be read. | |
Protected Member Functions | |
int_type | overflow (int_type c) |
Transfer characters to the pipe when character buffer overflows. | |
int_type | underflow () |
Transfer characters from the pipe when the character buffer is empty. | |
int_type | pbackfail (int_type c=traits_type::eof()) |
Make a character available to be returned by the next extraction. | |
int | sync () |
Write any buffered characters to the stream. | |
std::streamsize | xsputn (const char_type *s, std::streamsize n) |
bool | write (char_type c) |
Insert a character into the pipe. | |
bool | read (char_type &c) |
Extract a character from the pipe. | |
std::streamsize | write (char_type *s, std::streamsize n) |
Insert a sequence of characters into the pipe. | |
std::streamsize | read (char_type *s, std::streamsize n) |
Extract a sequence of characters from the pipe. | |
pid_t | fork (pmode mode) |
Initialise pipes and fork process. | |
int | wait (bool nohang=false) |
Wait for the child process to exit. | |
fd_t & | wpipe () |
Return the file descriptor for the output pipe;. | |
fd_t & | rpipe () |
Return the file descriptor for the active input pipe. | |
fd_t & | rpipe (buf_read_src which) |
Return the file descriptor for the specified input pipe. | |
void | create_buffers (pmode mode) |
void | destroy_buffers (pmode mode) |
bool | empty_buffer () |
Writes buffered characters to the process' stdin pipe.. | |
bool | fill_buffer () |
char_type * | rbuffer () |
Return the active input buffer. | |
buf_read_src | switch_read_buffer (buf_read_src) |
Provides underlying streambuf functionality for the PStreams classes.
|
Default constructor. Creates an uninitialised stream buffer. |
|
Constructor that initialises the buffer with command. Initialises the stream buffer by calling open() with the supplied arguments.
|
|
Constructor that initialises the buffer with file and argv.. Initialises the stream buffer by calling open() with the supplied arguments.
|
|
Destructor. Closes the stream by calling close().
|
|
Close the stream buffer and wait for the process to exit.
Closes all pipes and waits for the associated process to finish. If an error occurs the error code will be set to one of the possible errors for
|
|
Writes buffered characters to the process' stdin pipe..
|
|
Return the error number for the most recent failed operation. return The error code of the most recently failed operation, or zero. |
|
Report whether the process has exited. return True if the associated process has exited, false otherwise. see basic_pstreambuf<C,T>::close() |
|
|
|
Initialise pipes and fork process.
Creates pipes as specified by mode and calls
If an error occurs the error code will be set to one of the possile errors for
|
|
Report whether the stream buffer has been initialised.
|
|
Send a signal to the process. Sends the specified signal to the process. A signal can be used to terminate a child process that would not exit otherwise.
If an error occurs the error code will be set to one of the possible errors for
|
|
Initialise the stream buffer with file and argv. Starts a new process by executing file with the arguments in argv and opens pipes to the process with the specified mode. By convention argv[0] should be the file name of the file being executed. Will duplicate the actions of the shell in searching for an executable file if the specified file name does not contain a slash (/) character.
|
|
Initialise the stream buffer with command. Starts a new process by passing command to the shell and opens pipes to the process with the specified mode. There is no way to tell whether the shell command succeeded, this function will always succeed unless resource limits (such as memory usage, or number of processes or open files) are exceeded.
|
|
Transfer characters to the pipe when character buffer overflows. Called when the internal character buffer is not present or is full, to transfer the buffer contents to the pipe. For unbuffered streams this is called for every insertion.
|
|
Make a character available to be returned by the next extraction.
Attempts to make c available as the next character to be read by
|
|
Close the pipe connected to the process' stdin.
closes the output pipe, causing the child process to receive the End Of File indicator on subsequent reads from its
|
|
Return the active input buffer.
|
|
Extract a sequence of characters from the pipe. Reads up to n characters from the pipe to the buffer s. This currently only works for fixed width character encodings where each character uses sizeof(char_type) bytes.
|
|
Extract a character from the pipe. Attempts to extract a character from the pipe and store it in c. Used by underflow().
|
|
Change active input source.
Toggle the stream used for reading. If readerr is
|
|
Return the file descriptor for the specified input pipe.
|
|
Return the file descriptor for the active input pipe.
|
|
Return the exit status of the process. return The exit status of the child process, or -1 if close() has not yet been called to wait for the child to exit. see basic_pstreambuf<C,T>::close() |
|
Transfer characters from the pipe when the character buffer is empty. Called when the internal character buffer is is empty, to re-fill it from the pipe.
|
|
Wait for the child process to exit. Suspends execution and waits for the associated process to exit, or until a signal is delivered whose action is to terminate the current process or to call a signal handling function. If the process has already exited wait() returns immediately.
|
|
Return the file descriptor for the output pipe;.
|
|
Insert a sequence of characters into the pipe. Writes up to n characters to the pipe from the buffer s. This currently only works for fixed width character encodings where each character uses sizeof(char_type) bytes.
|
|
Insert a character into the pipe. Attempts to insert c into the pipe. Used by overflow().
|