#include #include #include #include #include #include "JLang/JSTDObjectReader.hh" #include "JLang/JConversionIterator.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to test JLANG::JSTDObjectReader class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int debug; try { JParser<> zap("Example program to test object iteration using STD containers."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; typedef vector buffer_type; buffer_type buffer; for (int i = 0; i != 3; ++i) { buffer.push_back(i + 0.1); } { JSTDObjectReader in(buffer); for (int i = 0; in.hasNext(); ++i) { const double value = *in.next(); DEBUG("in " << value << endl); ASSERT(value == buffer[i]); } in.rewind(); JConversionIterator out(in); for (int i = 0; out.hasNext(); ++i) { const int value = *in.next(); DEBUG("out " << value << endl); ASSERT(value == (int) buffer[i]); } } { JSTDObjectReader in(buffer); for (int i = 0; in.hasNext(); ++i) { const double value = *in.next(); DEBUG("in " << value << endl); ASSERT(value == buffer[i]); } } return 0; }