implementace pugi xml
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include <filesystem>
|
||||
#include "plcLicence.h"
|
||||
#include "utils.h"
|
||||
#include "pugixml.hpp"
|
||||
|
||||
|
||||
#define CID_LENGTH 32
|
||||
#define CSD_LENGTH 32
|
||||
@@ -58,47 +60,20 @@ PlcLicence::PlcLicence()
|
||||
/// @param dataFileName
|
||||
void PlcLicence::processConfigFile(string &dataFileName)
|
||||
{
|
||||
std::string content;
|
||||
|
||||
#ifdef LINUX
|
||||
// dataFileName = getCompletePath(dataFileName);
|
||||
#endif
|
||||
std::ifstream inputFile(dataFileName);
|
||||
|
||||
if (inputFile.is_open())
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_file("licData.xml");
|
||||
if (result)
|
||||
{
|
||||
content.assign((std::istreambuf_iterator<char>(inputFile)), (std::istreambuf_iterator<char>()));
|
||||
inputFile.close();
|
||||
// std::cout << "File content:\n" << content << std::endl;
|
||||
this->stationName = doc.child("data").child("station").child_value();
|
||||
this->distributor = doc.child("data").child("distributor").child_value();
|
||||
;
|
||||
// cout << doc.child("data").child("plcType").attribute("t").value() << endl;
|
||||
// cout << doc.child("data").child("plcType").child_value() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Unable to open the file." << std::endl;
|
||||
}
|
||||
|
||||
string station = getXmlContentFromString(content, "station");
|
||||
string distributor = getXmlContentFromString(content, "distributor");
|
||||
|
||||
// cout << station;
|
||||
// cout << distributor;
|
||||
|
||||
this->stationName = station;
|
||||
this->distributor = distributor;
|
||||
|
||||
// char stationCh[station.length()] = {};
|
||||
// getCharsFromString(station, stationCh);
|
||||
|
||||
// char distributorCh[distributor.length()] = {};
|
||||
// getCharsFromString(distributor, distributorCh);
|
||||
|
||||
// this->stationName = stationCh;
|
||||
// this->distributor = distributorCh;
|
||||
|
||||
// this->stationName = "ceskatrebova";
|
||||
// this->distributor = "RO1";
|
||||
|
||||
// cout << this->stationName << "\n";
|
||||
// cout << this->distributor << "\n";
|
||||
}
|
||||
|
||||
PlcLicence::PlcLicence(map<string, string> &arguments)
|
||||
|
||||
12444
src/pugixml.cpp
Normal file
12444
src/pugixml.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user