From 899d3b925ccb249de881bbc957f6e4ddc754cbbd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 20 Aug 2017 00:34:20 +0300 Subject: Add function for read float and double number from xml. --- src/utils/xml/libxml.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/utils/xml/libxml.cpp') 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(prop)); + xmlFree(prop); + } + + return ret; + } + + double getDoubleProperty(XmlNodeConstPtr node, + const char *const name, + double def) { double &ret = def; -- cgit v1.2.3-70-g09d2