diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-20 00:34:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-20 00:34:20 +0300 |
commit | 899d3b925ccb249de881bbc957f6e4ddc754cbbd (patch) | |
tree | 4c35a6f21d909f9bc07ed091f0c8e3cb5f700105 /src/utils/xml/libxml.cpp | |
parent | 1049de4c76ac6fc85c9f7f2bd35fb62ca787aa4c (diff) | |
download | manaverse-899d3b925ccb249de881bbc957f6e4ddc754cbbd.tar.gz manaverse-899d3b925ccb249de881bbc957f6e4ddc754cbbd.tar.bz2 manaverse-899d3b925ccb249de881bbc957f6e4ddc754cbbd.tar.xz manaverse-899d3b925ccb249de881bbc957f6e4ddc754cbbd.zip |
Add function for read float and double number from xml.
Diffstat (limited to 'src/utils/xml/libxml.cpp')
-rw-r--r-- | src/utils/xml/libxml.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/utils/xml/libxml.cpp b/src/utils/xml/libxml.cpp index 90204fb49..251f994d5 100644 --- a/src/utils/xml/libxml.cpp +++ b/src/utils/xml/libxml.cpp @@ -205,9 +205,25 @@ namespace XML return ret; } - double getFloatProperty(XmlNodeConstPtr node, - const char *const name, - double def) + float getFloatProperty(XmlNodeConstPtr node, + const char *const name, + float def) + { + float &ret = def; + + xmlChar *const prop = XmlGetProp(node, name); + if (prop != nullptr) + { + ret = atof(reinterpret_cast<char*>(prop)); + xmlFree(prop); + } + + return ret; + } + + double getDoubleProperty(XmlNodeConstPtr node, + const char *const name, + double def) { double &ret = def; |