Pipes are implemented in blop in a form of standard C++ streams:
ipstream inputcmd("cat somefile"); string s; while(inputcmd>>s) cerr<<s<<endl; opstream outputcmd("cat"); outputcmd<<"Hello World"<<endl;
You can use remote files:
iscpstream file1("user@remote.machine:dir1/dir2/filename"); // read remote file via scp oscpstream file2("user@remote.machine:dir1/dir2/filename"); // write a remote file via scp ihttpstream file3("http://www.machine.com/url"); // read a file downloaded from the web
void ipstream::ibufsize(int size); void opstream::obufsize(int size);
A related topic: the output of commands (pipes) can be plotted in blop with the usual plot or mplot commands: if the last letter of the filename is |, the preceding part of the filename is interpreted as a command, the output of which will be plotted.
To access remote files for read or write via scp as a c++-stream, you can use the following classes: iscpstream or oscpstream. Both have a constructor accepting a filename (which should be of the form user@machine.address.com:dir1/dir2/filename, or, alternatively, their open(const char *) member function can be used.
The iscpstream first downloads the remote file, and then opens it for reading locally. The oscpstream first opens a local temporary file for writing, and upon closing (which is also called from its destructor) it uploads it to the remote location via scp.
Similarly to iscpstream above, the ihttpstream class downloads the file via wget from the given URL (provided as the filename to the constructor or the open(const char *url) member function).
Source files: pstream.h pstream.cc