summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/ExpatParser.cpp')
m---------Swiften0
-rw-r--r--Swiften/Parser/ExpatParser.cpp70
2 files changed, 0 insertions, 70 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/Parser/ExpatParser.cpp b/Swiften/Parser/ExpatParser.cpp
deleted file mode 100644
index 6f7ff86..0000000
--- a/Swiften/Parser/ExpatParser.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include "Swiften/Parser/ExpatParser.h"
-
-#include <iostream>
-
-#include "Swiften/Base/String.h"
-#include "Swiften/Parser/XMLParserClient.h"
-
-namespace Swift {
-
-static const char NAMESPACE_SEPARATOR = '\x01';
-
-static void handleStartElement(void* client, const XML_Char* name, const XML_Char** attributes) {
- std::pair<String,String> nsTagPair = String(name).getSplittedAtFirst(NAMESPACE_SEPARATOR);
- if (nsTagPair.second == "") {
- nsTagPair.second = nsTagPair.first;
- nsTagPair.first = "";
- }
- AttributeMap attributeValues;
- const XML_Char** currentAttribute = attributes;
- while (*currentAttribute) {
- std::pair<String,String> nsAttributePair = String(*currentAttribute).getSplittedAtFirst(NAMESPACE_SEPARATOR);
- if (nsAttributePair.second == "") {
- nsAttributePair.second = nsAttributePair.first;
- nsAttributePair.first = "";
- }
- attributeValues[nsAttributePair.second] = String(*(currentAttribute+1));
- currentAttribute += 2;
- }
-
- static_cast<XMLParserClient*>(client)->handleStartElement(nsTagPair.second, nsTagPair.first, attributeValues);
-}
-
-static void handleEndElement(void* client, const XML_Char* name) {
- std::pair<String,String> nsTagPair = String(name).getSplittedAtFirst(NAMESPACE_SEPARATOR);
- if (nsTagPair.second == "") {
- nsTagPair.second = nsTagPair.first;
- nsTagPair.first = "";
- }
- static_cast<XMLParserClient*>(client)->handleEndElement(nsTagPair.second, nsTagPair.first);
-}
-
-static void handleCharacterData(void* client, const XML_Char* data, int len) {
- static_cast<XMLParserClient*>(client)->handleCharacterData(String(data, len));
-}
-
-static void handleXMLDeclaration(void*, const XML_Char*, const XML_Char*, int) {
-}
-
-
-ExpatParser::ExpatParser(XMLParserClient* client) : XMLParser(client) {
- parser_ = XML_ParserCreateNS("UTF-8", NAMESPACE_SEPARATOR);
- XML_SetUserData(parser_, client);
- XML_SetElementHandler(parser_, handleStartElement, handleEndElement);
- XML_SetCharacterDataHandler(parser_, handleCharacterData);
- XML_SetXmlDeclHandler(parser_, handleXMLDeclaration);
-}
-
-ExpatParser::~ExpatParser() {
- XML_ParserFree(parser_);
-}
-
-bool ExpatParser::parse(const String& data) {
- bool success = XML_Parse(parser_, data.getUTF8Data(), data.getUTF8Size(), false) == XML_STATUS_OK;
- /*if (!success) {
- std::cout << "ERROR: " << XML_ErrorString(XML_GetErrorCode(parser_)) << " while parsing " << data << std::endl;
- }*/
- return success;
-}
-
-}