#include #include #include #include "JTools/JAutoMap.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace JPP; // type definition of map typedef JAutoMap JAutoMap_t; typedef JAutoMap_t::value_type value_type; using JLANG::JType; struct JElement_t : public value_type { template JElement_t(JType); }; // specialiation of constructor of auxiliary class template<> JElement_t::JElement_t(JType) : value_type(1, "char") {} template<> JElement_t::JElement_t(JType) : value_type(2, "int") {} template<> JElement_t::JElement_t(JType) : value_type(3, "float") {} template<> JElement_t::JElement_t(JType) : value_type(4, "double") {} } namespace JTOOLS { // specialiation of member method JAutoMap_t::getAutoElement template<> template<> value_type JAutoMap_t::getAutoElement(JType ) { return value_type(1, "char"); } template<> template<> value_type JAutoMap_t::getAutoElement(JType ) { return value_type(2, "int"); } template<> template<> value_type JAutoMap_t::getAutoElement(JType ) { return value_type(3, "float"); } template<> template<> value_type JAutoMap_t::getAutoElement(JType) { return value_type(4, "double"); } } /** * \file * * Example program to test JTOOLS::JAutoMap class. * \author mdejong */ int main(int argc, char **argv) { using namespace std; int debug; try { JParser<> zap("Example program to test automatic generation of map based on data types."); zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } using namespace JPP; typedef JTypeList > > > JDataTypes_t; { JAutoMap_t zmap; zmap.insert(); cout << "First method" << endl; for (JAutoMap_t::const_iterator i = zmap.begin(); i != zmap.end(); ++i) { cout << setw(2) << i->first << ' ' << i->second << endl; } } { JAutoMap_t zmap; zmap.insert(JAutomate()); cout << "Second method" << endl; for (JAutoMap_t::const_iterator i = zmap.begin(); i != zmap.end(); ++i) { cout << setw(2) << i->first << ' ' << i->second << endl; } } }