diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-30 15:15:00 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-30 15:15:00 +0300 |
commit | 003ce4b2567b85b5a129c78fcf75cd73c455d557 (patch) | |
tree | cf5d747239fa81415fca81bb63feb3dcdc9693c4 /src/utils/xmlutils.cpp | |
parent | fadafe160a52f47d9eeca88517562964a85499c2 (diff) | |
download | manaplus-003ce4b2567b85b5a129c78fcf75cd73c455d557.tar.gz manaplus-003ce4b2567b85b5a129c78fcf75cd73c455d557.tar.bz2 manaplus-003ce4b2567b85b5a129c78fcf75cd73c455d557.tar.xz manaplus-003ce4b2567b85b5a129c78fcf75cd73c455d557.zip |
Add support for includes in xml utils functions.
Diffstat (limited to 'src/utils/xmlutils.cpp')
-rw-r--r-- | src/utils/xmlutils.cpp | 59 |
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); + } + } } } } |