create .csv dump of all metainformation + readme
This commit is contained in:
@@ -115,18 +115,32 @@ void tdm_ripper::parse_structure()
|
||||
int groupcount = 0;
|
||||
for (pugi::xml_node anode: subtreedata.children())
|
||||
{
|
||||
// get meta-info contained in tdm_root element
|
||||
if ( std::string(anode.name()).compare("tdm_root") == 0 )
|
||||
{
|
||||
// preliminiary: extract some hard-coded information tags only
|
||||
root_info_.insert(std::pair<std::string,std::string>("name",anode.child_value("name")));
|
||||
root_info_.insert(std::pair<std::string,std::string>("description",anode.child_value("description")));
|
||||
root_info_.insert(std::pair<std::string,std::string>("title",anode.child_value("title")));
|
||||
root_info_.insert(std::pair<std::string,std::string>("author",anode.child_value("author")));
|
||||
}
|
||||
|
||||
if ( std::string(anode.name()).compare("tdm_channelgroup") == 0 )
|
||||
{
|
||||
groupcount++;
|
||||
|
||||
// meta-info is pressumably contained in FIRST channel-group xml tree element
|
||||
// (eventually identify by name = TESTINFOS ??? )
|
||||
if ( groupcount == 1 )
|
||||
for ( pugi::xml_node mnode: anode.child("instance_attributes").children() )
|
||||
{
|
||||
for ( pugi::xml_node mnode: anode.child("instance_attributes").children() )
|
||||
// preliminiary fix for Conti-TDM files since values are one arbitrary tree level above
|
||||
bool pretdmfix = ( std::string(mnode.child_value()).compare("") == 0 ) ? false : true;
|
||||
|
||||
if ( pretdmfix )
|
||||
{
|
||||
meta_info_.insert(std::pair<std::string,std::string>(mnode.attribute("name").value(),
|
||||
mnode.child_value("s")));
|
||||
meta_info_.insert(std::pair<std::string,std::string>(mnode.attribute("name").value(),mnode.child_value()));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta_info_.insert(std::pair<std::string,std::string>(mnode.attribute("name").value(),mnode.child_value("s")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,8 @@ class tdm_ripper
|
||||
pugi::xml_document xml_doc_;
|
||||
pugi::xml_parse_result xml_result_;
|
||||
|
||||
// .tdm-file eventually contains some meta information about measurement
|
||||
// .tdm-file eventually contains some meta information (about measurement)
|
||||
std::map<std::string,std::string> root_info_;
|
||||
std::map<std::string,std::string> meta_info_;
|
||||
|
||||
// binary data container
|
||||
@@ -320,7 +321,31 @@ public:
|
||||
// obtain any meta information about .tdm-file if available
|
||||
std::string get_meta(std::string attribute_name)
|
||||
{
|
||||
return meta_info_[attribute_name];
|
||||
// check if key "attribute_name" actually exits
|
||||
std::map<std::string,std::string>::iterator positer = meta_info_.find(attribute_name);
|
||||
bool ispresent = ( positer == meta_info_.end() ) ? false : true;
|
||||
|
||||
return ispresent ? meta_info_[attribute_name] : "key does not exist";
|
||||
}
|
||||
|
||||
// prepare meta information file including all available meta-data
|
||||
void print_meta(const char* filename, std::string sep = ",")
|
||||
{
|
||||
// open file
|
||||
std::ofstream fout(filename);
|
||||
|
||||
for ( const auto& it : root_info_ )
|
||||
{
|
||||
fout<<it.first<<sep<<it.second<<"\n";
|
||||
}
|
||||
fout<<sep<<"\n";
|
||||
for ( const auto& it : meta_info_ )
|
||||
{
|
||||
fout<<it.first<<sep<<it.second<<"\n";
|
||||
}
|
||||
|
||||
// close down file
|
||||
fout.close();
|
||||
}
|
||||
|
||||
// TODO add elements/methods to build .tdm and write .tdx files for your own data
|
||||
|
Reference in New Issue
Block a user