Guest User

Untitled

a guest
Dec 20th, 2015
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. int Parse()
  2. {
  3.     xml_document<> detectorsOutput;
  4.  
  5.     string inputPath = projectPath + "\\vehout.xml";
  6.  
  7.     ifstream iFile(inputPath);
  8.     if (!iFile.is_open())
  9.     {
  10.         cout << "Bledna sciezka" << endl;
  11.         return -1;
  12.     }
  13.  
  14.     vector<double> values(0);
  15.  
  16.     vector<char> bufferC((istreambuf_iterator<char>(iFile)), istreambuf_iterator<char>());
  17.     bufferC.push_back('\0');
  18.     detectorsOutput.parse<0>(&bufferC[0]);
  19.     iFile.close();
  20.  
  21.  
  22.  
  23.  
  24.     xml_node<> *mainNode = detectorsOutput.first_node();
  25.  
  26.     for (xml_node<> *timestepNode = mainNode->first_node("tripinfo"); timestepNode != nullptr; timestepNode = timestepNode->next_sibling("tripinfo"))
  27.     {
  28.         double val = stod(timestepNode->first_attribute("duration")->value());
  29.         values.push_back(val);
  30.     }
  31.  
  32.     string outputPath = projectPath + "\\OutSCP.txt";
  33.     ofstream oFile(outputPath);
  34.     double functionValue = Function(values);
  35.  
  36.     oFile.open(outputPath, ios::app);
  37.     oFile << functionValue << endl;
  38.     oFile.close();
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment