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

Dv::Util::pstream Class Reference

A wrapper that makes a stream of popen(command,"r"). More...

#include <pstream.h>

List of all members.

Public Member Functions

 pstream (const std::string &command, const std::string &mode) throw (std::runtime_error)
 Constructor.
size_t close () throw (std::runtime_error)
 Close stream.
 ~pstream () throw (std::runtime_error)
 Destructor.
const std::string & command () const
const std::string & mode () const

Private Attributes

void * file_
const std::string command_
const std::string mode_


Detailed Description

A wrapper that makes a stream of popen(command,"r").

Definition at line 13 of file pstream.h.


Constructor & Destructor Documentation

Dv::Util::pstream::pstream const std::string &  command,
const std::string &  mode
throw (std::runtime_error)
 

Constructor.

Create an input or output stream for data produced by a command. If mode is "r" (read), reading the stream reads output from the command. If mode is "w" (write), writing the stream sends the data to the command's standard input.

Parameters:
command see popen(3)
mode read ("r") or write ("w"), see popen(3).
Exceptions:
std::runtime_error if anything goes wrong.
Warning:
E.g. for a stream opened in read mode, the default standard ouput of the command is still the standard output of the parent process.

Dv::Util::pstream::~pstream  )  throw (std::runtime_error)
 

Destructor.

Exceptions:
std::runtime_error if anything goes wrong.


Member Function Documentation

size_t Dv::Util::pstream::close  )  throw (std::runtime_error)
 

Close stream.

Wait for command to finish, then return its exit status. After a close, the stream is unusable.

Returns:
exit status of command as returned by main().
Warning:
A negative exit status gets converted to a positive number, i.e. -1 becomes 255.
Exceptions:
std::runtime_error if command did not exit normally or any other problem.

const std::string& Dv::Util::pstream::command  )  const [inline]
 

Definition at line 45 of file pstream.h.

References command_.

const std::string& Dv::Util::pstream::mode  )  const [inline]
 

Definition at line 47 of file pstream.h.

References mode_.


Member Data Documentation

void* Dv::Util::pstream::file_ [private]
 

Definition at line 49 of file pstream.h.

const std::string Dv::Util::pstream::command_ [private]
 

Definition at line 50 of file pstream.h.

Referenced by command().

const std::string Dv::Util::pstream::mode_ [private]
 

Definition at line 51 of file pstream.h.

Referenced by mode().


The documentation for this class was generated from the following file:
dvutil-0.13.15 [30 December, 2004]