summaryrefslogtreecommitdiff
path: root/src/utils/xml.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-06-28 21:59:59 +0300
committerAndrei Karas <akaras@inbox.ru>2012-06-28 21:59:59 +0300
commit503a2b302d9e13b99be4574e5d7b8821dd31504d (patch)
tree34ecba674db95cdedb9fe8f5767b0dfa22571e86 /src/utils/xml.cpp
parent6207ffb9a38c7e3718b7c4d87500ea9360d4d44f (diff)
downloadplus-503a2b302d9e13b99be4574e5d7b8821dd31504d.tar.gz
plus-503a2b302d9e13b99be4574e5d7b8821dd31504d.tar.bz2
plus-503a2b302d9e13b99be4574e5d7b8821dd31504d.tar.xz
plus-503a2b302d9e13b99be4574e5d7b8821dd31504d.zip
Add validation for some xml parameters.
Diffstat (limited to 'src/utils/xml.cpp')
-rw-r--r--src/utils/xml.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 140da72df..f7350ce92 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -122,6 +122,23 @@ namespace XML
return ret;
}
+ int getIntProperty(XmlNodePtr node, const char* name, int def, int min, int max)
+ {
+ int &ret = def;
+
+ xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ if (prop)
+ {
+ ret = atoi(reinterpret_cast<char*>(prop));
+ xmlFree(prop);
+ }
+ if (ret < min)
+ ret = min;
+ else if (ret > max)
+ ret = max;
+ return ret;
+ }
+
double getFloatProperty(XmlNodePtr node, const char* name, double def)
{
double &ret = def;