summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-02-14 18:57:18 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-02-14 21:36:32 (GMT)
commitcb05f5a908e20006c954ce38755c2e422ecc2388 (patch)
treea793551a5fe279a57d4330119560e8542f745484 /Swiften/Serializer/XML
parentcad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff)
downloadswift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.zip
swift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2
Removed Swift::String.
Diffstat (limited to 'Swiften/Serializer/XML')
-rw-r--r--Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp10
-rw-r--r--Swiften/Serializer/XML/XMLElement.cpp26
-rw-r--r--Swiften/Serializer/XML/XMLElement.h12
-rw-r--r--Swiften/Serializer/XML/XMLNode.h4
-rw-r--r--Swiften/Serializer/XML/XMLRawTextNode.h6
-rw-r--r--Swiften/Serializer/XML/XMLTextNode.h16
6 files changed, 37 insertions, 37 deletions
diff --git a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp b/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
index bfd91d1..8c68f97 100644
--- a/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
+++ b/Swiften/Serializer/XML/UnitTest/XMLElementTest.cpp
@@ -34,8 +34,8 @@ class XMLElementTest : public CppUnit::TestFixture
bazElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode("Bli")));
testling.addNode(bazElement);
- String result = testling.serialize();
- String expectedResult =
+ std::string result = testling.serialize();
+ std::string expectedResult =
"<foo myatt=\"myval\" xmlns=\"http://example.com\">"
"<bar>Blo</bar>"
"<baz>Bli</baz>"
@@ -47,21 +47,21 @@ class XMLElementTest : public CppUnit::TestFixture
void testSerialize_NoChildren() {
XMLElement testling("foo", "http://example.com");
- CPPUNIT_ASSERT_EQUAL(String("<foo xmlns=\"http://example.com\"/>"), testling.serialize());
+ CPPUNIT_ASSERT_EQUAL(std::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());
+ CPPUNIT_ASSERT_EQUAL(std::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_ASSERT_EQUAL(std::string("<foo myatt=\"\"/>"), testling.serialize());
}
};
diff --git a/Swiften/Serializer/XML/XMLElement.cpp b/Swiften/Serializer/XML/XMLElement.cpp
index 289ce31..6c90e0d 100644
--- a/Swiften/Serializer/XML/XMLElement.cpp
+++ b/Swiften/Serializer/XML/XMLElement.cpp
@@ -11,19 +11,19 @@
namespace Swift {
-XMLElement::XMLElement(const String& tag, const String& xmlns, const String& text) : tag_(tag) {
- if (!xmlns.isEmpty()) {
+XMLElement::XMLElement(const std::string& tag, const std::string& xmlns, const std::string& text) : tag_(tag) {
+ if (!xmlns.empty()) {
setAttribute("xmlns", xmlns);
}
- if (!text.isEmpty()) {
+ if (!text.empty()) {
addNode(XMLTextNode::ref(new XMLTextNode(text)));
}
}
-String XMLElement::serialize() {
- String result;
+std::string XMLElement::serialize() {
+ std::string result;
result += "<" + tag_;
- typedef std::pair<String,String> Pair;
+ typedef std::pair<std::string,std::string> Pair;
foreach(const Pair& p, attributes_) {
result += " " + p.first + "=\"" + p.second + "\"";
}
@@ -41,13 +41,13 @@ String XMLElement::serialize() {
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;");
+void XMLElement::setAttribute(const std::string& attribute, const std::string& value) {
+ std::string escapedValue(value);
+ String::replaceAll(escapedValue, '&', "&amp;");
+ String::replaceAll(escapedValue, '<', "&lt;");
+ String::replaceAll(escapedValue, '>', "&gt;");
+ String::replaceAll(escapedValue, '\'', "&apos;");
+ String::replaceAll(escapedValue, '"', "&quot;");
attributes_[attribute] = escapedValue;
}
diff --git a/Swiften/Serializer/XML/XMLElement.h b/Swiften/Serializer/XML/XMLElement.h
index b350344..65af7ae 100644
--- a/Swiften/Serializer/XML/XMLElement.h
+++ b/Swiften/Serializer/XML/XMLElement.h
@@ -10,7 +10,7 @@
#include <vector>
#include <map>
-#include "Swiften/Base/String.h"
+#include <string>
#include "Swiften/Serializer/XML/XMLNode.h"
@@ -19,16 +19,16 @@ namespace Swift {
public:
typedef boost::shared_ptr<XMLElement> ref;
- XMLElement(const String& tag, const String& xmlns = "", const String& text = "");
+ XMLElement(const std::string& tag, const std::string& xmlns = "", const std::string& text = "");
- void setAttribute(const String& attribute, const String& value);
+ void setAttribute(const std::string& attribute, const std::string& value);
void addNode(boost::shared_ptr<XMLNode> node);
- virtual String serialize();
+ virtual std::string serialize();
private:
- String tag_;
- std::map<String, String> attributes_;
+ std::string tag_;
+ std::map<std::string, std::string> attributes_;
std::vector< boost::shared_ptr<XMLNode> > childNodes_;
};
}
diff --git a/Swiften/Serializer/XML/XMLNode.h b/Swiften/Serializer/XML/XMLNode.h
index 6b75aa9..5261888 100644
--- a/Swiften/Serializer/XML/XMLNode.h
+++ b/Swiften/Serializer/XML/XMLNode.h
@@ -7,14 +7,14 @@
#ifndef SWIFTEN_XMLNode_H
#define SWIFTEN_XMLNode_H
-#include "Swiften/Base/String.h"
+#include <string>
namespace Swift {
class XMLNode {
public:
virtual ~XMLNode();
- virtual String serialize() = 0;
+ virtual std::string serialize() = 0;
};
}
diff --git a/Swiften/Serializer/XML/XMLRawTextNode.h b/Swiften/Serializer/XML/XMLRawTextNode.h
index 1f9f8ec..9fa8c40 100644
--- a/Swiften/Serializer/XML/XMLRawTextNode.h
+++ b/Swiften/Serializer/XML/XMLRawTextNode.h
@@ -12,15 +12,15 @@
namespace Swift {
class XMLRawTextNode : public XMLNode {
public:
- XMLRawTextNode(const String& text) : text_(text) {
+ XMLRawTextNode(const std::string& text) : text_(text) {
}
- String serialize() {
+ std::string serialize() {
return text_;
}
private:
- String text_;
+ std::string text_;
};
}
diff --git a/Swiften/Serializer/XML/XMLTextNode.h b/Swiften/Serializer/XML/XMLTextNode.h
index dae4d58..4d55f76 100644
--- a/Swiften/Serializer/XML/XMLTextNode.h
+++ b/Swiften/Serializer/XML/XMLTextNode.h
@@ -7,28 +7,28 @@
#pragma once
#include "Swiften/Serializer/XML/XMLNode.h"
-
+#include <Swiften/Base/String.h>
namespace Swift {
class XMLTextNode : public XMLNode {
public:
typedef boost::shared_ptr<XMLTextNode> ref;
- XMLTextNode(const String& text) : text_(text) {
- text_.replaceAll('&', "&amp;"); // Should come first
- text_.replaceAll('<', "&lt;");
- text_.replaceAll('>', "&gt;");
+ XMLTextNode(const std::string& text) : text_(text) {
+ String::replaceAll(text_, '&', "&amp;"); // Should come first
+ String::replaceAll(text_, '<', "&lt;");
+ String::replaceAll(text_, '>', "&gt;");
}
- String serialize() {
+ std::string serialize() {
return text_;
}
- static ref create(const String& text) {
+ static ref create(const std::string& text) {
return ref(new XMLTextNode(text));
}
private:
- String text_;
+ std::string text_;
};
}