#include #include #include #include #include #include #include #include #include "JLang/JException.hh" #include "JLang/JEquation.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JLANG::JEquation class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; string inputFile; int debug; try { JParser<> zap("Example program to test equation parsing"); 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; const int KEY_WIDTH = 6; const int VAL_WIDTH = 30; const char SEP = '|'; const JEquationFacet facet(JEquationParameters("=", ";\n", "./", "#")); ifstream in(inputFile.c_str()); in.imbue(locale(in.getloc(), facet.clone())); cout << setw(4) << " " << ' ' << setw(KEY_WIDTH) << left << "key" << SEP << ' ' << setw(VAL_WIDTH) << left << "value" << endl; cout << setw(KEY_WIDTH + 5) << setfill('-') << left << "-" << setw(VAL_WIDTH + 0) << setfill('-') << left << "+" << setfill(' ') << endl; for (JEquation equation; in >> equation; ) { int i = 0; for ( ; facet.isDivision(equation.getSeparator()); ++i) { cout << "[" << setw(2) << right << i << "]" << ' ' << setw(KEY_WIDTH) << left << equation.getKey() << SEP << ' ' << setw(VAL_WIDTH) << left << equation.getValue() << endl; equation.setEquation(facet); } cout << "[" << setw(2) << right << i << "]" << ' ' << setw(KEY_WIDTH) << left << equation.getKey() << SEP << ' ' << setw(VAL_WIDTH) << left << equation.getValue() << endl; } in.close(); }