#include #include #include #include "JLang/JFileStream.hh" #include "JLang/JNullStream.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JANG::JFileSream and JLANG::JNullStream classes. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; bool use_cin; bool use_cout; int debug; try { JParser<> zap("Example program to test file streaming."); zap['c'] = make_field(use_cin); zap['C'] = make_field(use_cout); zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JFileInputStream is(STDIN_FILENO); JFileOutputStream os(STDOUT_FILENO); istream in (use_cin ? cin .rdbuf() : is.rdbuf()); ostream out(use_cout ? cout.rdbuf() : os.rdbuf()); for ( ; ; ) { string buffer; out << "> " << flush; getline(in,buffer); if (buffer != "") { cout << "out -> <" << flush; out << buffer << flush; cout << ">" << endl; cout << "null -> <" << flush; null << buffer << flush; cout << ">" << endl; } else { break; } } }