Main Page | Namespace List | Class Hierarchy | Compound List | File List | Namespace Members | Compound Members | File Members

redi::basic_rpstream< CharT, Traits > Class Template Reference

Class template for Restricted PStreams. More...

#include <rpstream.h>

Inheritance diagram for redi::basic_rpstream< CharT, Traits >:

redi::pstream_common< CharT, Traits > List of all members.

Public Member Functions

 basic_rpstream ()
 Default constructor, creates an uninitialised stream.

 basic_rpstream (const std::string &command, pmode mode=std::ios_base::in|std::ios_base::out)
 Constructor that initialises the stream by starting a process.

 basic_rpstream (const std::string &file, const std::vector< std::string > &argv, pmode mode=std::ios_base::in|std::ios_base::out)
 Constructor that initialises the stream by starting a process.

 ~basic_rpstream ()
 Destructor.

void open (const std::string &command, pmode mode=std::ios_base::in|std::ios_base::out)
 Start a process.

void open (const std::string &file, const std::vector< std::string > &argv, pmode mode=std::ios_base::in|std::ios_base::out)
 Start a process.

istream_type & out ()
 Obtain a reference to the istream that reads the process' stderr.

istream_type & err ()
 Obtain a reference to the istream that reads the process' stderr.


Detailed Description

template<typename CharT, typename Traits = std::char_traits<CharT>>
class redi::basic_rpstream< CharT, Traits >

Class template for Restricted PStreams.

Writing to an rpstream opened with pmode pstdin writes to the standard input of the command. It is not possible to read directly from an rpstream object, to use an rpstream as in istream you must call either basic_rpstream::out() or basic_rpstream::err(). This is to prevent accidental reads from the wrong input source. If the rpstream was not opened with pmode pstderr then the class cannot read the process' stderr, and basic_rpstream::err() will return an istream that reads from the process' stdout, and vice versa. Reading from an rpstream opened with pmode pstdout and/or pstderr reads the command's standard output and/or standard error. Any of the process' stdin, stdout or stderr that is not connected to the pstream (as specified by the pmode) will be the same as the process that created the pstream object, unless altered by the command itself.


Constructor & Destructor Documentation

template<typename C, typename T>
redi::basic_rpstream< C, T >::basic_rpstream  ) 
 

Default constructor, creates an uninitialised stream.

Creates an uninitialised stream.

template<typename C, typename T>
redi::basic_rpstream< C, T >::basic_rpstream const std::string &  command,
pmode  mode = std::ios_base::in|std::ios_base::out
 

Constructor that initialises the stream by starting a process.

Initialises the stream buffer by calling open() with the supplied arguments.

Parameters:
command a string containing a shell command.
mode the I/O mode to use when opening the pipe.
See also:
open()

template<typename C, typename T>
redi::basic_rpstream< C, T >::basic_rpstream const std::string &  file,
const std::vector< std::string > &  argv,
pmode  mode = std::ios_base::in|std::ios_base::out
[inline]
 

Constructor that initialises the stream by starting a process.

Initialises the stream buffer by calling open() with the supplied arguments.

Parameters:
file a string containing the pathname of a program to execute.
argv a vector of argument strings passed to the new program.
mode the I/O mode to use when opening the pipe.
See also:
open()


Member Function Documentation

template<typename C, typename T>
basic_rpstream< C, T >::istream_type & redi::basic_rpstream< C, T >::err  )  [inline]
 

Obtain a reference to the istream that reads the process' stderr.

Returns:
*this

template<typename C, typename T>
void redi::basic_rpstream< C, T >::open const std::string &  file,
const std::vector< std::string > &  argv,
pmode  mode = std::ios_base::in|std::ios_base::out
[inline, virtual]
 

Start a process.

Starts a new process by executing file with the arguments in argv and opens pipes to the process as given by mode.

Parameters:
file a string containing the pathname of a program to execute.
argv a vector of argument strings passed to the new program.
mode the I/O mode to use when opening the pipe.
See also:
basic_pstreambuf::open()

Reimplemented from redi::pstream_common< CharT, Traits >.

template<typename C, typename T>
void redi::basic_rpstream< C, T >::open const std::string &  command,
pmode  mode = std::ios_base::in|std::ios_base::out
[inline, virtual]
 

Start a process.

Starts a new process by passing command to the shell and opens a pipe to the process with the specified mode.

Parameters:
command a string containing a shell command.
mode the I/O mode to use when opening the pipe.
See also:
basic_rpstreambuf::open()

Reimplemented from redi::pstream_common< CharT, Traits >.

template<typename C, typename T>
basic_rpstream< C, T >::istream_type & redi::basic_rpstream< C, T >::out  )  [inline]
 

Obtain a reference to the istream that reads the process' stderr.

Returns:
*this


The documentation for this class was generated from the following file:
Generated on Mon Jul 5 10:39:10 2004 for PStreams by doxygen 1.3.2