summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-03-28 13:40:14 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-03-28 13:40:43 (GMT)
commitb61486fefe602e0d18fa5279021006f87b965307 (patch)
tree437585cbef1179e1ec31f79789591d5610200c29 /Swiften/Serializer/XML
parentdae28dd45e43fc6e6ef2ec4c6c65d5d736ed86f8 (diff)
downloadswift-b61486fefe602e0d18fa5279021006f87b965307.zip
swift-b61486fefe602e0d18fa5279021006f87b965307.tar.bz2
Moved Swiften to a separate module.
Diffstat (limited to 'Swiften/Serializer/XML')
m---------Swiften0
-rw-r--r--Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp62
-rw-r--r--Swiften/Serializer/XML/XMLElement.cpp49
-rw-r--r--Swiften/Serializer/XML/XMLElement.h27
-rw-r--r--Swiften/Serializer/XML/XMLNode.cpp8
-rw-r--r--Swiften/Serializer/XML/XMLNode.h15
-rw-r--r--Swiften/Serializer/XML/XMLRawTextNode.h21
-rw-r--r--Swiften/Serializer/XML/XMLTextNode.h21
8 files changed, 0 insertions, 203 deletions
diff --git a/Swiften b/Swiften
new file mode 160000
+Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c
diff --git a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp b/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
deleted file mode 100644
index 49eb109..0000000
--- a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-
-#include "Swiften/Serializer/XML/XMLElement.h"
-#include "Swiften/Serializer/XML/XMLTextNode.h"
-
-using namespace Swift;
-
-class XMLElementTest : public CppUnit::TestFixture
-{
- CPPUNIT_TEST_SUITE(XMLElementTest);
- CPPUNIT_TEST(testSerialize);
- CPPUNIT_TEST(testSerialize_NoChildren);
- CPPUNIT_TEST(testSerialize_SpecialAttributeCharacters);
- CPPUNIT_TEST(testSerialize_EmptyAttributeValue);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- XMLElementTest() {}
-
- void testSerialize() {
- XMLElement testling("foo", "http://example.com");
- testling.setAttribute("myatt", "myval");
- boost::shared_ptr<XMLElement> barElement(new XMLElement("bar"));
- barElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode("Blo")));
- testling.addNode(barElement);
- boost::shared_ptr<XMLElement> bazElement(new XMLElement("baz"));
- bazElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode("Bli")));
- testling.addNode(bazElement);
-
- String result = testling.serialize();
- String expectedResult =
- "<foo myatt=\"myval\" xmlns=\"http://example.com\">"
- "<bar>Blo</bar>"
- "<baz>Bli</baz>"
- "</foo>";
-
- CPPUNIT_ASSERT_EQUAL(expectedResult, result);
- }
-
- void testSerialize_NoChildren() {
- XMLElement testling("foo", "http://example.com");
-
- CPPUNIT_ASSERT_EQUAL(String("<foo xmlns=\"http://example.com\"/>"), testling.serialize());
- }
-
- void testSerialize_SpecialAttributeCharacters() {
- XMLElement testling("foo");
- testling.setAttribute("myatt", "<\"'&>");
-
- CPPUNIT_ASSERT_EQUAL(String("<foo myatt=\"&lt;&quot;&apos;&amp;&gt;\"/>"), testling.serialize());
- }
-
- void testSerialize_EmptyAttributeValue() {
- XMLElement testling("foo");
- testling.setAttribute("myatt", "");
-
- CPPUNIT_ASSERT_EQUAL(String("<foo myatt=\"\"/>"), testling.serialize());
- }
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(XMLElementTest);
diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp
deleted file mode 100644
index 71f4d0c..0000000
--- a/Swiften/Serializer/XML/XMLElement.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "Swiften/Serializer/XML/XMLElement.h"
-
-#include "Swiften/Base/foreach.h"
-
-namespace Swift {
-
-XMLElement::XMLElement(const String& tag, const String& xmlns) :
- tag_(tag) {
- if (!xmlns.isEmpty()) {
- setAttribute("xmlns", xmlns);
- }
-}
-
-String XMLElement::serialize() {
- String result;
- result += "<" + tag_;
- typedef std::pair<String,String> Pair;
- foreach(const Pair& p, attributes_) {
- result += " " + p.first + "=\"" + p.second + "\"";
- }
-
- if (childNodes_.size() > 0) {
- result += ">";
- foreach (boost::shared_ptr<XMLNode> node, childNodes_) {
- result += node->serialize();
- }
- result += "</" + tag_ + ">";
- }
- else {
- result += "/>";
- }
- return result;
-}
-
-void XMLElement::setAttribute(const String& attribute, const String& value) {
- String escapedValue(value);
- escapedValue.replaceAll('&', "&amp;");
- escapedValue.replaceAll('<', "&lt;");
- escapedValue.replaceAll('>', "&gt;");
- escapedValue.replaceAll('\'', "&apos;");
- escapedValue.replaceAll('"', "&quot;");
- attributes_[attribute] = escapedValue;
-}
-
-void XMLElement::addNode(boost::shared_ptr<XMLNode> node) {
- childNodes_.push_back(node);
-}
-
-}
diff --git a/Swiften/Serializer/XML/XMLElement.h b/Swiften/Serializer/XML/XMLElement.h
deleted file mode 100644
index f2eb8bf..0000000
--- a/Swiften/Serializer/XML/XMLElement.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef SWIFTEN_XMLElement_H
-#define SWIFTEN_XMLElement_H
-
-#include <boost/shared_ptr.hpp>
-#include <vector>
-#include <map>
-
-#include "Swiften/Base/String.h"
-#include "Swiften/Serializer/XML/XMLNode.h"
-
-namespace Swift {
- class XMLElement : public XMLNode {
- public:
- XMLElement(const String& tag, const String& xmlns = "");
-
- void setAttribute(const String& attribute, const String& value);
- void addNode(boost::shared_ptr<XMLNode> node);
-
- virtual String serialize();
-
- private:
- String tag_;
- std::map<String, String> attributes_;
- std::vector< boost::shared_ptr<XMLNode> > childNodes_;
- };
-}
-#endif
diff --git a/Swiften/Serializer/XML/XMLNode.cpp b/Swiften/Serializer/XML/XMLNode.cpp
deleted file mode 100644
index 1bef64a..0000000
--- a/Swiften/Serializer/XML/XMLNode.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "Swiften/Serializer/XML/XMLNode.h"
-
-namespace Swift {
-
-XMLNode::~XMLNode() {
-}
-
-}
diff --git a/Swiften/Serializer/XML/XMLNode.h b/Swiften/Serializer/XML/XMLNode.h
deleted file mode 100644
index b31c0d6..0000000
--- a/Swiften/Serializer/XML/XMLNode.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef SWIFTEN_XMLNode_H
-#define SWIFTEN_XMLNode_H
-
-#include "Swiften/Base/String.h"
-
-namespace Swift {
- class XMLNode {
- public:
- virtual ~XMLNode();
-
- virtual String serialize() = 0;
- };
-}
-
-#endif
diff --git a/Swiften/Serializer/XML/XMLRawTextNode.h b/Swiften/Serializer/XML/XMLRawTextNode.h
deleted file mode 100644
index e5800c3..0000000
--- a/Swiften/Serializer/XML/XMLRawTextNode.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef SWIFTEN_XMLRawTextNode_H
-#define SWIFTEN_XMLRawTextNode_H
-
-#include "Swiften/Serializer/XML/XMLNode.h"
-
-namespace Swift {
- class XMLRawTextNode : public XMLNode {
- public:
- XMLRawTextNode(const String& text) : text_(text) {
- }
-
- String serialize() {
- return text_;
- }
-
- private:
- String text_;
- };
-}
-
-#endif
diff --git a/Swiften/Serializer/XML/XMLTextNode.h b/Swiften/Serializer/XML/XMLTextNode.h
deleted file mode 100644
index 87dda53..0000000
--- a/Swiften/Serializer/XML/XMLTextNode.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#pragma once
-
-#include "Swiften/Serializer/XML/XMLNode.h"
-
-namespace Swift {
- class XMLTextNode : public XMLNode {
- public:
- XMLTextNode(const String& text) : text_(text) {
- text_.replaceAll('&', "&amp;"); // Should come first
- text_.replaceAll('<', "&lt;");
- text_.replaceAll('>', "&gt;");
- }
-
- String serialize() {
- return text_;
- }
-
- private:
- String text_;
- };
-}