summaryrefslogtreecommitdiff
path: root/src/utils/xml.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2006-11-15 21:43:36 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2006-11-15 21:43:36 +0000
commit86db18d65a1c6e92b115efc3afe65f770ec93398 (patch)
tree9fedd710f689b3c9732f758330578b7b7347f391 /src/utils/xml.cpp
parent2d7084e4f07cd56021ca47dc6124ed587883acc2 (diff)
downloadmana-client-86db18d65a1c6e92b115efc3afe65f770ec93398.tar.gz
mana-client-86db18d65a1c6e92b115efc3afe65f770ec93398.tar.bz2
mana-client-86db18d65a1c6e92b115efc3afe65f770ec93398.tar.xz
mana-client-86db18d65a1c6e92b115efc3afe65f770ec93398.zip
Separated getProperty method to an XML utility namespace.
Diffstat (limited to 'src/utils/xml.cpp')
-rw-r--r--src/utils/xml.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
new file mode 100644
index 00000000..b820011d
--- /dev/null
+++ b/src/utils/xml.cpp
@@ -0,0 +1,54 @@
+/*
+ * The Mana World
+ * Copyright 2004 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * The Mana World is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * The Mana World is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with The Mana World; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * $Id: dtor.h 2822 2006-11-05 14:30:53Z b_lindeijer $
+ */
+
+#include "xml.h"
+
+namespace XML
+{
+ int
+ getProperty(xmlNodePtr node, const char* name, int def)
+ {
+ int &ret = def;
+
+ xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ if (prop) {
+ ret = atoi((char*)prop);
+ xmlFree(prop);
+ }
+
+ return ret;
+ }
+
+ std::string
+ getProperty(xmlNodePtr node, const char *name, const std::string &def)
+ {
+ xmlChar *prop = xmlGetProp(node, BAD_CAST name);
+ if (prop) {
+ std::string val = (char*)prop;
+ xmlFree(prop);
+ return val;
+ }
+
+ return def;
+ }
+}