#include #include #include #include #include "JLang/JObject.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace JPP; typedef std::vector buffer_type; /** * Example worker class which requires static instance to be processed. */ struct __A__ : public JObject<__A__> { __A__(const int N, buffer_type& buffer) : N(N), buffer(buffer) {} void operator()() { for (int i = 0; i != N; ++i) { buffer.push_back(buffer.size()); } } int N; buffer_type& buffer; }; /** * Process object. */ inline void process(__A__& object) { object(); } } /** * \file * * Example program to test JLANG::JObject class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int debug; try { JParser<> zap("Example program to test object."); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; buffer_type buffer; process(__A__(3, buffer).getInstance()); process(getInstance(__A__(2, buffer))); //process(__A__(5, buffer)); // compiler error: invalid initialization of non-const reference (as should be) for (buffer_type::const_iterator i = buffer.begin(); i != buffer.end(); ++i) { cout << *i << endl; } }