summaryrefslogtreecommitdiff
path: root/src/utils/xmlutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/xmlutils.cpp')
-rw-r--r--src/utils/xmlutils.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
index 232ec92b1..937695d41 100644
--- a/src/utils/xmlutils.cpp
+++ b/src/utils/xmlutils.cpp
@@ -61,3 +61,42 @@ void readXmlIntVector(const std::string &fileName,
}
}
}
+
+void readXmlStringMap(const std::string &fileName,
+ const std::string &rootName,
+ const std::string &sectionName,
+ const std::string &itemName,
+ const std::string &attributeKeyName,
+ const std::string &attributeValueName,
+ std::map<std::string, std::string> &arr)
+{
+ arr.clear();
+ XML::Document doc(fileName, UseResman_true, SkipError_false);
+ const XmlNodePtrConst rootNode = doc.rootNode();
+
+ if (!rootNode || !xmlNameEqual(rootNode, rootName.c_str()))
+ {
+ logger->log("Error while loading %s!", fileName.c_str());
+ return;
+ }
+
+ for_each_xml_child_node(sectionNode, rootNode)
+ {
+ if (!xmlNameEqual(sectionNode, sectionName.c_str()))
+ continue;
+ for_each_xml_child_node(childNode, sectionNode)
+ {
+ if (!xmlNameEqual(childNode, itemName.c_str()))
+ continue;
+
+ const std::string key = XML::getProperty(childNode,
+ attributeKeyName.c_str(), "");
+ if (key.empty())
+ continue;
+ const std::string val = XML::getProperty(childNode,
+ attributeValueName.c_str(), "");
+
+ arr[key] = val;
+ }
+ }
+}