cxxtools::posix::CommandOutput Class Reference

cxxtools::posix::CommandOutput starts a process and the stdout of the process can be read. More...

#include <cxxtools/posix/commandoutput.h>

Public Types

typedef Exec::const_reference const_reference
typedef Exec::reference reference

Public Member Functions

 CommandOutput (const std::string &cmd, unsigned bufsize=8192)
void push_back (const std::string &arg)
void run (bool combineStderr=false)
int wait (int options=0)
IODevicein ()
void close ()

Detailed Description

cxxtools::posix::CommandOutput starts a process and the stdout of the process can be read.

The class is derived from std::istream, so all methods provided from that base class can be used to read the output.

Typical usage example:

ls.push_back("-l"); // add a parameter
ls.push_back("/bin"); // and another one
ls.run(); // start the process
// read output line by line
std::string line;
while (std::getline(ls, line))
std::cout << line << std::endl;

Member Typedef Documentation

Constructor & Destructor Documentation

cxxtools::posix::CommandOutput::CommandOutput ( const std::string &  cmd,
unsigned  bufsize = 8192 
)
inlineexplicit

Member Function Documentation

void cxxtools::posix::CommandOutput::close ( )
inline
IODevice& cxxtools::posix::CommandOutput::in ( )
inline
void cxxtools::posix::CommandOutput::push_back ( const std::string &  arg)
inline
void cxxtools::posix::CommandOutput::run ( bool  combineStderr = false)
int cxxtools::posix::CommandOutput::wait ( int  options = 0)
inline

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