-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfigFileParser.cpp
More file actions
30 lines (23 loc) · 992 Bytes
/
ConfigFileParser.cpp
File metadata and controls
30 lines (23 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
#include "pugixml.hpp"
#include "ConfigFileParser.h"
/*static*/ PIL_ERROR_CODE ConfigFileParser::ParseSupportedDevices(std::string &configFile, std::vector<DeviceDescription> &configFiles) {
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file(configFile.c_str(), pugi::parse_default | pugi::parse_declaration);
if (result.status != pugi::status_ok)
return PIL_XML_PARSING_ERROR;
pugi::xml_node root = doc.document_element();
for (auto child: root.children()) {
DeviceDescription devDescription;
for (auto attrib: child.attributes()) {
std::string name = attrib.name();
std::string value = attrib.value();
if (name == "name")
devDescription.m_DeviceName = value;
if (name == "description")
devDescription.m_DeviceDescription = value;
}
configFiles.push_back(devDescription);
}
return PIL_NO_ERROR;
}