// -------------------------------------------------------------------------- // #include "tdm_reaper.hpp" // -------------------------------------------------------------------------- // tdm_reaper::tdm_reaper(std::string tdmfile, std::string tdxfile, bool showlog): tdmfile_(tdmfile), tdxfile_(tdxfile) { // 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); } void tdm_reaper::process_include(bool showlog) { // get XML node pugi::xml_node tdmincl = xml_doc_.child("usi:tdm").child("usi:include"); // check endianess std::string endianness(tdmincl.child("file").attribute("byteOrder").value()); endianness_ = endianness.compare("littleEndian") == 0 ? true : false; // obtain machine's endianess int num = 1; machine_endianness_ = ( *(char*)&num == 1 ); if ( machine_endianness_ != endianness_ ) throw std::runtime_error("endianess mismatch"); if ( showlog ) { std::cout<<"\n"; std::cout<<"endianess: "<<(endianness_?"little":"big")<<"\n" <<"machine endianness: "<<(machine_endianness_?"little":"big")<<"\n\n"; } // check for existence of attributes before using // pugi::xml_attribute attr; // list block of massdata for (pugi::xml_node anode: tdmincl.child("file").children()) { // declare new block block tdxblock; if ( anode.attribute("id") ) { tdxblock.id_ = anode.attribute("id").value(); } if ( anode.attribute("byteOffset") ) { tdxblock.byte_offset_ = std::stoul(anode.attribute("byteOffset").value()); } if ( anode.attribute("length") ) { tdxblock.length_ = std::stoul(anode.attribute("length").value()); } if ( anode.attribute("blockOffset") ) { tdxblock.block_offset_ = std::stoul(anode.attribute("blockOffset").value()); } if ( anode.attribute("blockSize") ) { tdxblock.block_size_ = std::stoul(anode.attribute("blockSize").value()); } if ( anode.attribute("valueType") ) { tdxblock.value_type_ = anode.attribute("valueType").value(); } // add block to map tdx_blocks_.insert(std::pair(tdxblock.id_,tdxblock)); if ( showlog ) std::cout<