UCommon
ucommon::pipestream Class Reference

Streamable pipe socket connection. More...

#include <stream.h>

Inheritance diagram for ucommon::pipestream:
Collaboration diagram for ucommon::pipestream:

Public Types

enum  access_t { RDONLY , WRONLY , RDWR }
 

Public Member Functions

void cancel (void)
 
int close (void)
 Close an active stream connection.
 
void open (const char *path, access_t access, char **args, char **env=NULL, size_t buffering=512)
 Open a stream connection to a pipe service.
 
 operator bool () const
 See if stream connection is active.
 
bool operator! () const
 See if stream is disconnected.
 
 pipestream ()
 Create an unopened pipe stream.
 
 pipestream (const char *command, access_t access, char **args, char **env=NULL, size_t size=512)
 Create child process and start pipe.
 
void terminate (void)
 Force terminate child and close.
 
virtual ~pipestream ()
 Destroy a pipe stream.
 
- Public Member Functions inherited from ucommon::StreamBuffer
bool is_open (void) const
 
 operator bool () const
 
bool operator! () const
 
int sync (void)
 Flush the stream input and output buffers, writes pending output.
 

Protected Member Functions

int overflow (int ch)
 This streambuf method is used to write the output buffer through the established pipe connection.
 
void release (void)
 Release the stream, detach/do not wait for the process.
 
int underflow (void)
 This streambuf method is used to load the input buffer through the established pipe connection.
 
- Protected Member Functions inherited from ucommon::StreamBuffer
void allocate (size_t size)
 
void release (void)
 
int uflow ()
 This streambuf method is used for doing unbuffered reads through the establish tcp socket connection when in interactive mode.
 

Protected Attributes

shell::pid_t pid
 
fsys_t rd
 
fsys_t wr
 
- Protected Attributes inherited from ucommon::StreamBuffer
size_t bufsize
 
char * gbuf
 
char * pbuf
 

Detailed Description

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.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 237 of file stream.h.

Member Enumeration Documentation

◆ access_t

enum ucommon::pipestream::access_t

Definition at line 240 of file stream.h.

Constructor & Destructor Documentation

◆ pipestream()

ucommon::pipestream::pipestream ( const char * command,
access_t access,
char ** args,
char ** env = NULL,
size_t size = 512 )

Create child process and start pipe.

Parameters
pathto execute.
accessmode of pipe stream.
argsto pass to command.
envto create in child.
sizeof buffer.

Member Function Documentation

◆ cancel()

void ucommon::pipestream::cancel ( void )
inline

Definition at line 335 of file stream.h.

◆ close()

int ucommon::pipestream::close ( void )

Close an active stream connection.

This waits for the child to terminate.

◆ open()

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.

Parameters
pathto execute.
accessmode of stream.
argsto pass to command.
envto create in child process.
bufferingsize to use.

◆ operator bool()

ucommon::pipestream::operator bool ( ) const
inline

See if stream connection is active.

Returns
true if stream is active.

Definition at line 302 of file stream.h.

◆ operator!()

bool ucommon::pipestream::operator! ( ) const
inline

See if stream is disconnected.

Returns
true if stream disconnected.

Definition at line 310 of file stream.h.

◆ overflow()

int ucommon::pipestream::overflow ( int ch)
protected

This streambuf method is used to write the output buffer through the established pipe connection.

Parameters
chchar to push through.
Returns
char pushed through.

◆ underflow()

int ucommon::pipestream::underflow ( void )
protected

This streambuf method is used to load the input buffer through the established pipe connection.

Returns
char from get buffer, EOF if not connected.

Field Documentation

◆ pid

shell::pid_t ucommon::pipestream::pid
protected

Definition at line 253 of file stream.h.

◆ rd

fsys_t ucommon::pipestream::rd
protected

Definition at line 252 of file stream.h.

◆ wr

fsys_t ucommon::pipestream::wr
protected

Definition at line 252 of file stream.h.


The documentation for this class was generated from the following file: