diff options
-rw-r--r-- | src/units.cpp | 16 | ||||
-rw-r--r-- | src/units.h | 2 |
2 files changed, 16 insertions, 2 deletions
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; diff --git a/src/units.h b/src/units.h index 84ad177cd..18a3bd3a2 100644 --- a/src/units.h +++ b/src/units.h @@ -37,6 +37,8 @@ class Units final */ static void loadUnits(); + static void loadXmlFile(const std::string &fileName); + /** * Formats the given number in the correct currency format. */ |