// -------------------------------------------------------------------------- // #include "tdm_reaper.hpp" // -------------------------------------------------------------------------- // tdm_reaper::tdm_reaper() { } tdm_reaper::tdm_reaper(std::string tdmfile, std::string tdxfile, bool showlog): tdmfile_(tdmfile), tdxfile_(tdxfile) { // start processing tdm data model this->process_tdm(showlog); } void tdm_reaper::submit_files(std::string tdmfile, std::string tdxfile, bool showlog) { // save files tdmfile_ = tdmfile; tdxfile_ = tdxfile; // start processing tdm data model this->process_tdm(showlog); } void tdm_reaper::process_tdm(bool showlog) { // check both tdm, tdx files std::filesystem::path ptdm(tdmfile_), ptdx(tdxfile_); if ( !std::filesystem::exists(ptdm) ) { throw std::runtime_error(std::string("*.tdm file ") + tdmfile_ + " does not exist!"); } if ( !std::filesystem::exists(ptdx) ) { throw std::runtime_error(std::string("*.tdx file ") + tdxfile_ + " does not exist!"); } // set up xml-parser and load tdm-file try { xml_result_ = xml_doc_.load_file(tdmfile_.c_str()); if ( showlog ) { std::cout<<"\nloading "<process_include(showlog); this->process_root(showlog); } void tdm_reaper::process_include(bool showlog) { // get XML node pugi::xml_node tdmincl = xml_doc_.child("usi:tdm").child("usi:include"); // check endianness std::string endianness(tdmincl.child("file").attribute("byteOrder").value()); endianness_ = endianness.compare("littleEndian") == 0 ? true : false; // check referenced .tdx file std::string urltdx(tdmincl.child("file").attribute("url").value()); // obtain machine's endianness int num = 1; machine_endianness_ = ( *(char*)&num == 1 ); if ( machine_endianness_ != endianness_ ) throw std::runtime_error("endianness mismatch"); if ( showlog ) { std::cout<<"\n"; std::cout<<"endianness: "<<(endianness_?"little":"big")<<"\n" <<"machine endianness: "<<(machine_endianness_?"little":"big")<<"\n" <<"url: "<(tdxblock.id_,tdxblock)); if ( showlog ) std::cout<str()); // std::cout<str(0)<<"\n"; if ( showlog ) std::cout<