#include #include #include #include #include #include "JLang/JWhiteSpacesFacet.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JLANG::JWhiteSpacesFacet class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; string ws; string inputFile; int debug; try { JParser<> zap("Example program to test white spaces handling using facet."); zap['c'] = make_field(ws) = " \t=."; zap['f'] = make_field(inputFile) = ""; zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; if (inputFile == "") { for ( ; ; ) { cout << "> " << flush; string buffer; getline(cin, buffer); if (buffer != "") { istringstream is(buffer); const locale loc(is.getloc(), new JWhiteSpacesFacet(is.getloc(), ws)); is.imbue(loc); for (string key; is >> key; ) { cout << key << endl; } } else break; } } else { ifstream in(inputFile.c_str()); in.imbue(locale(in.getloc(), new JWhiteSpacesFacet(in.getloc(), ws))); for (string key; in >> key; ) { cout << key << endl; } in.close(); } }