|
From: <cn...@us...> - 2008-12-30 21:25:25
|
Revision: 108
http://hgengine.svn.sourceforge.net/hgengine/?rev=108&view=rev
Author: cnlohr
Date: 2008-12-30 21:25:22 +0000 (Tue, 30 Dec 2008)
Log Message:
-----------
clean up the XML parser and switch to MString
Modified Paths:
--------------
Mercury2/src/XMLParser.cpp
Mercury2/src/XMLParser.h
Modified: Mercury2/src/XMLParser.cpp
===================================================================
--- Mercury2/src/XMLParser.cpp 2008-12-30 21:25:06 UTC (rev 107)
+++ Mercury2/src/XMLParser.cpp 2008-12-30 21:25:22 UTC (rev 108)
@@ -1,4 +1,7 @@
#include <XMLParser.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
//#include <SMOException.h>
XMLNode::XMLNode(xmlNode* node, xmlDoc* doc)
@@ -39,34 +42,34 @@
return XMLNode();
}
-std::string XMLNode::Name() const
+MString XMLNode::Name() const
{
- return std::string((const char*)m_node->name); //XXX fix utf8
+ return MString((const char*)m_node->name); //XXX fix utf8
}
-std::string XMLNode::Content() const
+MString XMLNode::Content() const
{
- string data;
+ MString data;
// xmlChar* d = xmlNodeListGetString(m_doc, m_node->xmlChildrenNode, 1);
xmlChar* d = xmlNodeGetContent(m_node);
if (d)
{
- data = string((const char*)d);
+ data = MString((const char*)d);
xmlFree(d);
}
return data;
}
-std::string XMLNode::Attribute(const std::string& tag) const
+MString XMLNode::Attribute(const MString& tag) const
{
- string data;
+ MString data;
xmlChar* d = xmlGetProp(m_node, (const xmlChar*)tag.c_str());
if (d)
{
- data = string((const char*)d);
+ data = MString((const char*)d);
xmlFree(d);
}
return data;
@@ -88,7 +91,7 @@
if (m_doc) xmlFreeDoc(m_doc);
}
-XMLDocument* XMLDocument::Load(const std::string& file)
+XMLDocument* XMLDocument::Load(const MString& file)
{
XMLDocument* xmldoc = new XMLDocument();
@@ -98,7 +101,7 @@
return xmldoc;
}
-void XMLDocument::LoadFromString(const std::string& xml)
+void XMLDocument::LoadFromString(const MString& xml)
{
xmlInitParser(); //XXX WTF am I supposed to do with this
m_doc = xmlReadMemory(xml.c_str(), xml.length(), "noname.xml", NULL, 0);
Modified: Mercury2/src/XMLParser.h
===================================================================
--- Mercury2/src/XMLParser.h 2008-12-30 21:25:06 UTC (rev 107)
+++ Mercury2/src/XMLParser.h 2008-12-30 21:25:22 UTC (rev 108)
@@ -1,11 +1,13 @@
#ifndef XMLPARSER_H
#define XMLPARSER_H
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <string>
#include <MAutoPtr.h>
+struct _xmlNode;
+typedef struct _xmlNode xmlNode;
+struct _xmlDoc;
+typedef struct _xmlDoc xmlDoc;
+
class XMLElement
{
public:
@@ -23,9 +25,9 @@
XMLNode PreviousNode() const;
XMLNode Child() const;
- std::string Name() const;
- std::string Content() const;
- std::string Attribute(const std::string& tag) const;
+ MString Name() const;
+ MString Content() const;
+ MString Attribute(const MString & tag) const;
inline bool IsValid() const { return m_node!=NULL; }
@@ -40,8 +42,8 @@
XMLDocument();
virtual ~XMLDocument();
- static XMLDocument* Load(const std::string& file);
- void LoadFromString(const std::string& xml);
+ static XMLDocument* Load(const MString& file);
+ void LoadFromString(const MString& xml);
XMLNode GetRootNode();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|