// ------------------------------------------------------------------------- // #ifndef TDM_REAPER #define TDM_REAPER #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "pugixml.hpp" #include "tdm_datamodel.hpp" // -------------------------------------------------------------------------- // class tdm_reaper { // .tdm and .tdx paths/filenames std::string tdmfile_; std::string tdxfile_; // set of .csv files (encoding mode) std::vector csvfile_; // XML parser pugi::xml_document xml_doc_; pugi::xml_parse_result xml_result_; // endianness (true = little, false = big) bool endianness_, machine_endianness_; // blocks of data in .tdx file std::map tdx_blocks_; // tdm root tdm_root tdmroot_; // tdm channelgroups std::map tdmchannelgroups_; // tdm channels std::map tdmchannels_; // submatrices and local_columns std::map submatrices_; std::map localcolumns_; // binary data container std::vector tdxbuffer_; // extract list of identifiers from e.g. "#xpointer(id("usi12") id("usi13"))" std::vector extract_ids(std::string idstring) { // collect group identifiers by means of regex pattern "usi[0-9]+" std::regex regid("(usi[0-9]+)"); // declare match instance and regex iterator (to find ALL matches) std::smatch usi_match; std::sregex_iterator pos(idstring.begin(), idstring.end(), regid); std::sregex_iterator end; // iterate through all matches std::vector listofids; for ( ; pos != end; ++pos) listofids.push_back(pos->str()); return listofids; } public: // check machine's datatypes // https://en.cppreference.com/w/cpp/language/types void check_local_datatypes() { std::cout<<"\nmachine's C++ datatypes:\n"; std::cout< csvfile); // decoding tdm_reaper(); tdm_reaper(std::string tdmfile, std::string tdxfile = std::string(""), bool showlog = false); // provide (tdm,tdx) files void submit_files(std::string tdmfile, std::string tdxfile = std::string(""), bool showlog = false); // process TDM data model in tdm file void process_tdm(bool showlog); // process element void process_include(bool showlog); // extract tdm_root void process_root(bool showlog); // process/list all channels and groups void process_channelgroups(bool showlog); void process_channels(bool showlog); // process submatrices and localcolumns void process_submatrices(bool showlog); void process_localcolumns(bool showlog); // get root element tdm_root get_root() { return tdmroot_; } // get full channel(group) overview std::string get_channel_overview(format chformatter); // get block/submatrix/localcolumn overview // template // std::string get_overview(format formatter); // template // std::map get_tdm_member(block blk); std::string get_submatrix_overview(format formatter); std::string get_localcolumn_overview(format formatter); std::string get_block_overview(format formatter); // get list of channelgroup ids std::vector get_channelgroup_ids() { std::vector channelgroup_ids; for (std::map::iterator it=tdmchannelgroups_.begin(); it!=tdmchannelgroups_.end(); ++it) channelgroup_ids.push_back(it->first); return channelgroup_ids; } // get list of channel ids std::vector get_channel_ids() { std::vector channel_ids; for (std::map::iterator it=tdmchannels_.begin(); it!=tdmchannels_.end(); ++it) channel_ids.push_back(it->first); return channel_ids; } // extract channel by id template std::vector get_channel(std::string& id); // (TODO introduce template T to reference specific datatype instead of double in general) // std::vector get_channel(std::string &id); void print_channel(std::string &id, const char* filename); private: template void convert_data_to_type(std::vector &buffer, std::vector &channel); }; #endif // -------------------------------------------------------------------------- //