#include "dumpTask.h" #include "rowSet.h" #include "xmlObjectLoader.h" #include #include #include ElementLoaderImpl dumptaskLoader("dumptask"); DumpTask::DumpTask(const xmlpp::Element * p) : SourceObject(p), Task(p) { } DumpTask::~DumpTask() { } void DumpTask::loadComplete(const CommonObjects *) { } class Printer : public boost::static_visitor<> { public: void operator()(const long long int & i) const { fprintf(stderr, "%lld", i); } void operator()(const long int & i) const { fprintf(stderr, "%ld", i); } void operator()(const int & i) const { fprintf(stderr, "%d", i); } void operator()(const short int & i) const { fprintf(stderr, "%hd", i); } void operator()(const long long unsigned int & i) const { fprintf(stderr, "%llu", i); } void operator()(const long unsigned int & i) const { fprintf(stderr, "%lu", i); } void operator()(const unsigned int & i) const { fprintf(stderr, "%u", i); } void operator()(const short unsigned int & i) const { fprintf(stderr, "%hu", i); } void operator()(const float & i) const { fprintf(stderr, "%g", i); } void operator()(const double & i) const { fprintf(stderr, "%g", i); } void operator()(const Glib::ustring & i) const { fprintf(stderr, "'%.*s'", i.length(), i.c_str()); } void operator()(const boost::shared_ptr & i) const { fprintf(stderr, "'%.*s'", i->length(), i->c_str()); } void operator()(const boost::posix_time::ptime & i) const { fprintf(stderr, "[%s]", boost::posix_time::to_iso_extended_string(i).c_str()); } void operator()(const boost::shared_ptr & i) const { fprintf(stderr, "[%s]", boost::posix_time::to_iso_extended_string(*i).c_str()); } }; void DumpTask::execute() const { const RowSet::RowValuesStack::value_type & r = *++RowSet::Stack().rbegin(); unsigned int cols = r->columnCount(); Printer printer; for (unsigned int c = 0; c < cols; c += 1) { if (c > 0) { fprintf(stderr, ", "); } fprintf(stderr, "%s = ", r->getColumnName(c).c_str()); if (!r->isNull(c)) { boost::apply_visitor(printer, r->getCurrentValue(c)); } } fprintf(stderr, "\n"); }