ucommon
7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
![]() ![]() |
#include <stream.h>
Public Types | |
enum | access_t { RDONLY, WRONLY, RDWR } |
Public Member Functions | |
pipestream () | |
pipestream (const char *command, access_t access, char **args, char **env=NULL, size_t size=512) | |
virtual | ~pipestream () |
operator bool () const | |
bool | operator! () const |
void | open (const char *path, access_t access, char **args, char **env=NULL, size_t buffering=512) |
int | close (void) |
void | terminate (void) |
void | cancel (void) |
![]() | |
int | sync (void) |
bool | is_open (void) const |
operator bool () const | |
bool | operator! () const |
Protected Member Functions | |
void | release (void) |
int | underflow (void) __OVERRIDE |
int | overflow (int ch) __OVERRIDE |
![]() | |
StreamBuffer () | |
int | uflow () __OVERRIDE |
void | release (void) |
void | allocate (size_t size) |
Protected Attributes | |
fsys_t | rd |
fsys_t | wr |
shell::pid_t | pid |
![]() | |
size_t | bufsize |
char * | gbuf |
char * | pbuf |
Private Member Functions | |
__LOCAL void | allocate (size_t size, access_t mode) |
__DELETE_COPY (pipestream) | |
Streamable pipe socket connection. This creates a stream between a parent and child process. As a stream class, data can be exchanged using the << and >> operators.
ucommon::pipestream::pipestream | ( | ) |
Create an unopened pipe stream.
Definition at line 405 of file stream.cpp.
ucommon::pipestream::pipestream | ( | const char * | command, |
access_t | access, | ||
char ** | args, | ||
char ** | env = NULL , |
||
size_t | size = 512 |
||
) |
Create child process and start pipe.
path | to execute. |
access | mode of pipe stream. |
args | to pass to command. |
env | to create in child. |
size | of buffer. |
Definition at line 410 of file stream.cpp.
References open().
|
virtual |
|
private |
|
private |
Definition at line 440 of file stream.cpp.
References ucommon::StreamBuffer::bufsize, ucommon::clear(), ucommon::StreamBuffer::gbuf, ucommon::StreamBuffer::pbuf, RDONLY, RDWR, and WRONLY.
Referenced by open().
int ucommon::pipestream::close | ( | void | ) |
Close an active stream connection. This waits for the child to terminate.
Definition at line 609 of file stream.cpp.
References ucommon::StreamBuffer::bufsize, pid, release(), ucommon::StreamBuffer::sync(), and ucommon::shell::wait().
Referenced by open(), overflow(), terminate(), underflow(), and ~pipestream().
void ucommon::pipestream::open | ( | const char * | path, |
access_t | access, | ||
char ** | args, | ||
char ** | env = NULL , |
||
size_t | buffering = 512 |
||
) |
Open a stream connection to a pipe service.
path | to execute. |
access | mode of stream. |
args | to pass to command. |
env | to create in child process. |
buffering | size to use. |
Definition at line 561 of file stream.cpp.
References allocate(), ucommon::fsys::assign(), close(), ucommon::fsys::inherit(), input, INVALID_HANDLE_VALUE, INVALID_PID_VALUE, ucommon::fsys::null(), output, pid, ucommon::fsys::pipe(), rd, RDONLY, RDWR, ucommon::fsys::release(), ucommon::shell::spawn(), wr, and WRONLY.
Referenced by pipestream().
|
inline |
|
inline |
|
protected |
This streambuf method is used to write the output buffer through the established pipe connection.
ch | char to push through. |
Definition at line 510 of file stream.cpp.
References ucommon::StreamBuffer::bufsize, ch, close(), EOF, IS_EOF, ucommon::StreamBuffer::pbuf, PUT, wr, and ucommon::fsys::write().
|
protected |
Release the stream, detach/do not wait for the process.
Definition at line 429 of file stream.cpp.
References ucommon::StreamBuffer::gbuf, ucommon::StreamBuffer::pbuf, rd, ucommon::StreamBuffer::release(), ucommon::fsys::release(), and wr.
Referenced by close().
void ucommon::pipestream::terminate | ( | void | ) |
Force terminate child and close.
Definition at line 421 of file stream.cpp.
References ucommon::StreamBuffer::bufsize, ucommon::shell::cancel(), close(), and pid.
|
protected |
This streambuf method is used to load the input buffer through the established pipe connection.
Definition at line 471 of file stream.cpp.
References ucommon::StreamBuffer::bufsize, ch, ucommon::clear(), close(), EOF, ucommon::StreamBuffer::gbuf, GET, rd, and ucommon::fsys::read().
|
protected |
Definition at line 253 of file stream.h.
Referenced by close(), open(), and terminate().
|
protected |
Definition at line 252 of file stream.h.
Referenced by open(), release(), and underflow().
|
protected |
Definition at line 252 of file stream.h.
Referenced by open(), overflow(), and release().