#include #include #include "JLang/JCategory.hh" #include "Jeep/JProperties.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace JPP; /** * Test data structure. */ struct JABC { /** * Constructor. * * \param a a * \param b b * \param c c */ JABC(const double a, const double b, const double c) { this->a = a; this->b = b; this->c = c; } double a; double b; double c; /** * Get properties of this class. * * \param object test data * \param equation equation parameters */ template static JProperties getProperties(typename JCategory::reference_type object, const JEquationParameters& equation = JEquationParameters("=", "\n;", "./", "#"), const int debug = 0) { JProperties properties(equation, debug); properties.insert(gmake_property(object.a)); properties.insert(gmake_property(object.b)); properties.insert(gmake_property(object.c)); return properties; } }; } /** * \file * Example program to test JPROPERTIES::JProperties class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int debug; try { JParser<> zap; zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } double a = 1.0; double b = 2.0; double c = 3.0; JABC test(a, b, c); getProperties(test).getValue("a") *= a; getProperties(test).setValue("b", 111.0); getProperties(test).getValue("c") += c; ASSERT(test.a == a*a); ASSERT(test.b == 111.0); ASSERT(test.c == 2*c); return 0; }