Skip to content
Snippets Groups Projects
Commit 21503a16 authored by Andrea Zoli's avatar Andrea Zoli
Browse files

Parse compression fields from xmls.

parent 26b1ce15
No related branches found
No related tags found
No related merge requests found
......@@ -278,6 +278,9 @@ std::string XmlConfig::convert(const std::string& filename)
hfs << nbits << endl;
hfs << "[Field]" << endl;
_writeFields(header, hfs);
// query for compression algorithm / compression level
xpath_node_set compression_algorithm = header.select_nodes("field[@id=\"packetlib:compression_algorithm\"]");
xpath_node_set compression_level = header.select_nodes("field[@id=\"packetlib:compression_level\"]");
/// Write packet files
vector<string> packetFilenames;
......@@ -335,6 +338,43 @@ std::string XmlConfig::convert(const std::string& filename)
xml_node tail = packet.child("tail");
_writeFields(tail, pfs);
// if not defined in the header find in datafieldheader
int algindex = 0;
if(compression_algorithm.empty())
{
compression_algorithm = datafieldheader.select_nodes("field[@id=\"packetlib:compression_algorithm\"]");
algindex = 1;
}
// and sourcedatafield
if(compression_algorithm.empty())
{
algindex = 2;
compression_algorithm = sourcedatafield.select_nodes("@field[id=\"packetlib:compression_algorithm\"]");
}
// if not defined in the header find in datafieldheader
int lvlindex = 0;
if(compression_level.empty())
{
compression_level = datafieldheader.select_nodes("field[@id=\"packetlib:compression_level\"]");
lvlindex = 1;
}
// and sourcedatafield
if(compression_level.empty())
{
lvlindex = 2;
compression_level = sourcedatafield.select_nodes("@field[id=\"packetlib:compression_level\"]");
}
if(!compression_algorithm.empty() && !compression_level.empty())
{
pfs << "[Compression]" << endl;
pfs << _physicalIndex[compression_algorithm[0].node()] << endl;
pfs << algindex << endl;
pfs << _physicalIndex[compression_level[0].node()] << endl;
pfs << lvlindex << endl;
}
packet=packet.next_sibling();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment