#include #include #include #include #include "JSystem/JProcess.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example for testing inter-process communication. * \author mdejong */ int main(int argc, char* argv[]) { using namespace std; using namespace JPP; string command; bool use_cin; bool revert; try { JParser<> zap("Example for testing inter-process communication."); zap['c'] = make_field(command); zap['C'] = make_field(use_cin); zap['r'] = make_field(revert); zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } try { JProcess process(command); if (!use_cin) { istream in(process.getInputStreamBuffer()); for (string buffer; getline(in, buffer); ) { cout << buffer << endl; } } else { ostream out(process.getOutputStreamBuffer()); istream in (process.getInputStreamBuffer()); for (string buffer; getline(cin, buffer) && buffer != ""; ) { out << buffer << endl; getline(in, buffer); if (revert) { reverse(buffer.begin(), buffer.end()); } cout << buffer << endl; } } } catch(const JException& error) { cerr << error.what() << endl; } }