diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-06 19:02:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-06 19:02:11 +0300 |
commit | 5007515135c05104a6b0e5b7991de310f53ce8ce (patch) | |
tree | cafecb9e445a5d1da67a47a8e1cc2de31c430e89 /src | |
parent | cc2142b0daaddbe76f4ba139c7d953f8beb0dd72 (diff) | |
download | plus-5007515135c05104a6b0e5b7991de310f53ce8ce.tar.gz plus-5007515135c05104a6b0e5b7991de310f53ce8ce.tar.bz2 plus-5007515135c05104a6b0e5b7991de310f53ce8ce.tar.xz plus-5007515135c05104a6b0e5b7991de310f53ce8ce.zip |
add support for include in units.xml.
Diffstat (limited to 'src')
-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. */ |