00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <cstdlib>
00023
00024 #include "utils/xml.hpp"
00025
00026 namespace XML
00027 {
00028
00029 int getProperty(xmlNodePtr node, const char *name, int def)
00030 {
00031 if (xmlChar *prop = xmlGetProp(node, BAD_CAST name))
00032 {
00033 int ret = atoi((char*)prop);
00034 xmlFree(prop);
00035 return ret;
00036 }
00037 return def;
00038 }
00039
00040 double getFloatProperty(xmlNodePtr node, const char* name, double def)
00041 {
00042 double &ret = def;
00043
00044 xmlChar *prop = xmlGetProp(node, BAD_CAST name);
00045 if (prop) {
00046 ret = atof((char*)prop);
00047 xmlFree(prop);
00048 }
00049
00050 return ret;
00051 }
00052
00053 std::string getProperty(xmlNodePtr node, const char *name,
00054 const std::string &def)
00055 {
00056 if (xmlChar *prop = xmlGetProp(node, BAD_CAST name))
00057 {
00058 std::string val = (char *)prop;
00059 xmlFree(prop);
00060 return val;
00061 }
00062 return def;
00063 }
00064
00065 }