summaryrefslogtreecommitdiff
path: root/src/utils/xmlutils.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-30 15:15:00 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-30 15:15:00 +0300
commit003ce4b2567b85b5a129c78fcf75cd73c455d557 (patch)
treecf5d747239fa81415fca81bb63feb3dcdc9693c4 /src/utils/xmlutils.cpp
parentfadafe160a52f47d9eeca88517562964a85499c2 (diff)
downloadmanaverse-003ce4b2567b85b5a129c78fcf75cd73c455d557.tar.gz
manaverse-003ce4b2567b85b5a129c78fcf75cd73c455d557.tar.bz2
manaverse-003ce4b2567b85b5a129c78fcf75cd73c455d557.tar.xz
manaverse-003ce4b2567b85b5a129c78fcf75cd73c455d557.zip
Add support for includes in xml utils functions.
Diffstat (limited to 'src/utils/xmlutils.cpp')
-rw-r--r--src/utils/xmlutils.cpp59
1 files changed, 39 insertions, 20 deletions
diff --git a/src/utils/xmlutils.cpp b/src/utils/xmlutils.cpp
index 937695d41..c437b0175 100644
--- a/src/utils/xmlutils.cpp
+++ b/src/utils/xmlutils.cpp
@@ -49,15 +49,24 @@ void readXmlIntVector(const std::string &fileName,
continue;
for_each_xml_child_node(childNode, sectionNode)
{
- if (!xmlNameEqual(childNode, itemName.c_str()))
- continue;
-
- const int val = XML::getProperty(childNode,
- attributeName.c_str(), -1);
- if (val == -1)
- continue;
-
- arr.push_back(val);
+ if (xmlNameEqual(childNode, itemName.c_str()))
+ {
+ const int val = XML::getProperty(childNode,
+ attributeName.c_str(), -1);
+ if (val == -1)
+ continue;
+ arr.push_back(val);
+ }
+ else if (xmlNameEqual(childNode, "include"))
+ {
+ const std::string name = XML::getProperty(
+ childNode, "name", "");
+ if (!name.empty())
+ {
+ readXmlIntVector(name, rootName, sectionName, itemName,
+ attributeName, arr);
+ }
+ }
}
}
}
@@ -86,17 +95,27 @@ void readXmlStringMap(const std::string &fileName,
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;
+ if (xmlNameEqual(childNode, itemName.c_str()))
+ {
+ 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;
+ }
+ else if (xmlNameEqual(childNode, "include"))
+ {
+ const std::string name = XML::getProperty(
+ childNode, "name", "");
+ if (!name.empty())
+ {
+ readXmlStringMap(name, rootName, sectionName, itemName,
+ attributeKeyName, attributeValueName,
+ arr);
+ }
+ }
}
}
}