#include #include #include #include #include #include "JDB/JSupport.hh" #include "JDB/JDBincludes.hh" #include "JDB/JDBDictionary.hh" #include "JROOT/JRootStreamer.hh" #include "JROOT/JRootDictionary.hh" #include "JROOT/JROOTClassSelector.hh" #include "JROOT/JASCIIFileStreamer.hh" #include "JLang/JNullStream.hh" #include "JSupport/JFileRecorder.hh" #include "Jeep/JeepToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { /** * File copy interace. */ struct io_interface { virtual ~io_interface() {} virtual void copy(const std::string& input_file, const std::string& output_file) const = 0; }; /** * File copy implementation. */ template struct io : public io_interface { virtual void copy(const std::string& input_file, const std::string& output_file) const override { using namespace std; using namespace JPP; JASCIIFileReader in(input_file.c_str(), JDBDictionary::getInstance()); JFileRecorder out(output_file.c_str()); out.open(); for (T object; in >> object; ) { out.put(object); } in .close(); out.close(); } }; /** * Multi-copy. */ struct IO : std::map > { /** * Add data type. * * \param type data type */ template void operator()(const JLANG::JType& type) { (*this)[JPP::getClassname(T::Class_Name())] = std::make_shared< io >(); } }; } /** * \file * * Auxiliary program to convert ASCII data from data base into ROOT format. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JDBTypes_t typelist; string inputFile; string outputFile; JROOTClassSelector selector; int debug; try { JParser<> zap("Auxiliary program to convert ASCII data from data base into ROOT format."); zap['f'] = make_field(inputFile, "ASCII formatted input file."\ "\nFirst line should list data members of data structure given at option -C"); zap['o'] = make_field(outputFile); zap['C'] = make_field(selector, "name of data structure") = getROOTClassSelection(); zap['d'] = make_field(debug) = 1; zap['C'] = JPARSER::not_initialised(); zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } IO io; for_each(io); io[selector]->copy(inputFile, outputFile); }