Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2002-07-26 16:31:14

How about this:

  systemistream s("./hello.exe"); //execute hello.cpp put results stream
  std::string data;
  while (getline(s,data)) {
    std::cout << data << std::endl;

//! An input stream built from the result of running a shell command
/*! This class is intended to facilitate large scale integration by similar
 * to the perl "open" command by combining the concept of an input stream
 * and the common idea of a spawning a subprocess to perform a task.
 * The class takes the definition optionally tasks the the subprocess
 * execution string as the a construction argument and will automatically
 * spawn the child process. Alternatively, the child process can be created
 * later using the open method.
class systemistream : public std::basic_istream<char, std::char_traits<char> > {
  systemistream(const std::string& command="");
  void open(const std::string& command);
  void close();
  std::basic_filebuf<char, std::char_traits<char> >* buf_;


It's a bit of a hack, but it works...


Boost list run by bdawes at, gregod at, cpdaniel at, john at