From 5007515135c05104a6b0e5b7991de310f53ce8ce Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 6 Jan 2014 19:02:11 +0300 Subject: add support for include in units.xml. --- src/units.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/units.cpp') diff --git a/src/units.cpp b/src/units.cpp index f1ba1ba39..7593f564f 100644 --- a/src/units.cpp +++ b/src/units.cpp @@ -102,7 +102,12 @@ void Units::loadUnits() units[UNIT_CURRENCY] = ud; } - XML::Document doc(paths.getStringValue("unitsFile")); + loadXmlFile(paths.getStringValue("unitsFile")); +} + +void Units::loadXmlFile(const std::string &fileName) +{ + XML::Document doc(fileName); const XmlNodePtr root = doc.rootNode(); if (!root || !xmlNameEqual(root, "units")) @@ -114,7 +119,14 @@ void Units::loadUnits() for_each_xml_child_node(node, root) { - if (xmlNameEqual(node, "unit")) + if (xmlNameEqual(node, "include")) + { + const std::string name = XML::getProperty(node, "name", ""); + if (!name.empty()) + loadXmlFile(name); + continue; + } + else if (xmlNameEqual(node, "unit")) { UnitDescription ud; int level = 1; -- cgit v1.2.3-60-g2f50