summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-02 20:41:01 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-02 20:41:01 +0300
commit1dab21b236d76900f3ddd2be32f9590aef394c2d (patch)
tree9ff63d2bf544a440c5d8de41faa401e900898012 /src/utils
parentf4f16b2fd6c455cd38e089a97db374c5ee3ea9fd (diff)
downloadplus-1dab21b236d76900f3ddd2be32f9590aef394c2d.tar.gz
plus-1dab21b236d76900f3ddd2be32f9590aef394c2d.tar.bz2
plus-1dab21b236d76900f3ddd2be32f9590aef394c2d.tar.xz
plus-1dab21b236d76900f3ddd2be32f9590aef394c2d.zip
Remove most C casts.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/xml.cpp14
-rw-r--r--src/utils/xml.h15
2 files changed, 21 insertions, 8 deletions
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index f25d867a6..73418cc60 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -110,7 +110,7 @@ namespace XML
{
int &ret = def;
- xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = XmlGetProp(node, name);
if (prop)
{
ret = atoi(reinterpret_cast<char*>(prop));
@@ -125,7 +125,7 @@ namespace XML
{
int &ret = def;
- xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = XmlGetProp(node, name);
if (prop)
{
ret = atoi(reinterpret_cast<char*>(prop));
@@ -143,7 +143,7 @@ namespace XML
{
double &ret = def;
- xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = XmlGetProp(node, name);
if (prop)
{
ret = atof(reinterpret_cast<char*>(prop));
@@ -156,7 +156,7 @@ namespace XML
std::string getProperty(const XmlNodePtr node, const char *const name,
const std::string &def)
{
- xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
+ xmlChar *const prop = XmlGetProp(node, name);
if (prop)
{
std::string val = reinterpret_cast<char*>(prop);
@@ -180,11 +180,11 @@ namespace XML
bool getBoolProperty(const XmlNodePtr node, const char *const name,
const bool def)
{
- const xmlChar *const prop = xmlGetProp(node, BAD_CAST name);
+ const xmlChar *const prop = XmlGetProp(node, name);
- if (xmlStrEqual(prop, BAD_CAST "true" ))
+ if (XmlStrEqual(prop, "true"))
return true;
- if (xmlStrEqual(prop, BAD_CAST "false"))
+ if (XmlStrEqual(prop, "false"))
return false;
return def;
}
diff --git a/src/utils/xml.h b/src/utils/xml.h
index e72d72070..ad54f4b28 100644
--- a/src/utils/xml.h
+++ b/src/utils/xml.h
@@ -32,9 +32,22 @@
#include "localconsts.h"
#define XmlNodePtr xmlNodePtr
-#define xmlNameEqual(node, str) xmlStrEqual((node)->name, BAD_CAST (str))
+#define XmlStrEqual(str1, str2) xmlStrEqual(str1, \
+ reinterpret_cast<const xmlChar*>(str2))
+#define xmlNameEqual(node, str) xmlStrEqual((node)->name, \
+ reinterpret_cast<const xmlChar*>(str))
#define XmlTextWriterPtr xmlTextWriterPtr
#define xmlTypeEqual(node, typ) ((node)->type == (typ))
+#define XmlHasProp(node, name) xmlHasProp(node, \
+ reinterpret_cast<const xmlChar*>(name))
+#define XmlGetProp(node, name) xmlGetProp(node, \
+ reinterpret_cast<const xmlChar*>(name))
+#define XmlTextWriterStartElement(writer, name) \
+ xmlTextWriterStartElement(writer, reinterpret_cast<const xmlChar*>(name))
+#define XmlTextWriterWriteAttribute(writer, name, content) \
+ xmlTextWriterWriteAttribute(writer, \
+ reinterpret_cast<const xmlChar*>(name), \
+ reinterpret_cast<const xmlChar*>(content))
/**
* XML helper functions.