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/StringCodecs
parentcad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff)
downloadswift-cb05f5a908e20006c954ce38755c2e422ecc2388.zip
swift-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2
Removed Swift::String.
Diffstat (limited to 'Swiften/StringCodecs')
-rw-r--r--Swiften/StringCodecs/Base64.cpp11
-rw-r--r--Swiften/StringCodecs/Base64.h6
-rw-r--r--Swiften/StringCodecs/Hexify.cpp10
-rw-r--r--Swiften/StringCodecs/Hexify.h8
-rw-r--r--Swiften/StringCodecs/UnitTest/Base64Test.cpp12
-rw-r--r--Swiften/StringCodecs/UnitTest/HexifyTest.cpp6
6 files changed, 28 insertions, 25 deletions
diff --git a/Swiften/StringCodecs/Base64.cpp b/Swiften/StringCodecs/Base64.cpp
index 4c28f04..795d982 100644
--- a/Swiften/StringCodecs/Base64.cpp
+++ b/Swiften/StringCodecs/Base64.cpp
@@ -5,6 +5,7 @@
*/
#include <boost/numeric/conversion/cast.hpp>
+#include <algorithm>
#include "Swiften/StringCodecs/Base64.h"
@@ -12,7 +13,7 @@ namespace Swift {
#pragma GCC diagnostic ignored "-Wold-style-cast"
-String Base64::encode(const ByteArray &s) {
+std::string Base64::encode(const ByteArray &s) {
int i;
int len = s.getSize();
char tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
@@ -45,11 +46,11 @@ String Base64::encode(const ByteArray &s) {
return p;
}
-ByteArray Base64::decode(const String& input) {
- String inputWithoutNewlines(input);
- inputWithoutNewlines.removeAll('\n');
+ByteArray Base64::decode(const std::string& input) {
+ std::string inputWithoutNewlines(input);
+ inputWithoutNewlines.erase(std::remove(inputWithoutNewlines.begin(), inputWithoutNewlines.end(), '\n'), inputWithoutNewlines.end());
- const std::string& s = inputWithoutNewlines.getUTF8String();
+ const std::string& s = inputWithoutNewlines;
ByteArray p;
// -1 specifies invalid
diff --git a/Swiften/StringCodecs/Base64.h b/Swiften/StringCodecs/Base64.h
index 38978d9..4b19a9f 100644
--- a/Swiften/StringCodecs/Base64.h
+++ b/Swiften/StringCodecs/Base64.h
@@ -8,13 +8,13 @@
#include <vector>
-#include "Swiften/Base/String.h"
+#include <string>
#include "Swiften/Base/ByteArray.h"
namespace Swift {
class Base64 {
public:
- static String encode(const ByteArray& s);
- static ByteArray decode(const String &s);
+ static std::string encode(const ByteArray& s);
+ static ByteArray decode(const std::string &s);
};
}
diff --git a/Swiften/StringCodecs/Hexify.cpp b/Swiften/StringCodecs/Hexify.cpp
index c762d9b..61732b0 100644
--- a/Swiften/StringCodecs/Hexify.cpp
+++ b/Swiften/StringCodecs/Hexify.cpp
@@ -10,25 +10,25 @@
#include <iomanip>
#include <boost/numeric/conversion/cast.hpp>
-#include "Swiften/Base/String.h"
+#include <string>
#include "Swiften/Base/ByteArray.h"
namespace Swift {
-String Hexify::hexify(unsigned char byte) {
+std::string Hexify::hexify(unsigned char byte) {
std::ostringstream result;
result << std::hex << std::setw(2) << std::setfill('0') << boost::numeric_cast<unsigned int>(byte);
- return String(result.str());
+ return std::string(result.str());
}
-String Hexify::hexify(const ByteArray& data) {
+std::string Hexify::hexify(const ByteArray& data) {
std::ostringstream result;
result << std::hex;
for (unsigned int i = 0; i < data.getSize(); ++i) {
result << std::setw(2) << std::setfill('0') << boost::numeric_cast<unsigned int>(static_cast<unsigned char>(data[i]));
}
- return String(result.str());
+ return std::string(result.str());
}
}
diff --git a/Swiften/StringCodecs/Hexify.h b/Swiften/StringCodecs/Hexify.h
index 5eaabda..f85db15 100644
--- a/Swiften/StringCodecs/Hexify.h
+++ b/Swiften/StringCodecs/Hexify.h
@@ -6,13 +6,15 @@
#pragma once
+#include <string>
+
namespace Swift {
- class String;
+
class ByteArray;
class Hexify {
public:
- static String hexify(unsigned char byte);
- static String hexify(const ByteArray& data);
+ static std::string hexify(unsigned char byte);
+ static std::string hexify(const ByteArray& data);
};
}
diff --git a/Swiften/StringCodecs/UnitTest/Base64Test.cpp b/Swiften/StringCodecs/UnitTest/Base64Test.cpp
index 2f6f0a0..b263050 100644
--- a/Swiften/StringCodecs/UnitTest/Base64Test.cpp
+++ b/Swiften/StringCodecs/UnitTest/Base64Test.cpp
@@ -24,18 +24,18 @@ class Base64Test : public CppUnit::TestFixture {
public:
void testEncode() {
- String result(Base64::encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"));
- CPPUNIT_ASSERT_EQUAL(String("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejEyMzQ1Njc4OTA="), result);
+ std::string result(Base64::encode("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"));
+ CPPUNIT_ASSERT_EQUAL(std::string("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejEyMzQ1Njc4OTA="), result);
}
void testEncode_NonAscii() {
- String result(Base64::encode(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
- CPPUNIT_ASSERT_EQUAL(String("QgayPKawpkPSDYmwT/WM94uAlu0="), result);
+ std::string result(Base64::encode(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
+ CPPUNIT_ASSERT_EQUAL(std::string("QgayPKawpkPSDYmwT/WM94uAlu0="), result);
}
void testEncode_NoData() {
- String result(Base64::encode(ByteArray()));
- CPPUNIT_ASSERT_EQUAL(String(""), result);
+ std::string result(Base64::encode(ByteArray()));
+ CPPUNIT_ASSERT_EQUAL(std::string(""), result);
}
void testDecode() {
diff --git a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp b/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
index 4ed871a..0f267bf 100644
--- a/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
+++ b/Swiften/StringCodecs/UnitTest/HexifyTest.cpp
@@ -8,7 +8,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include "Swiften/StringCodecs/Hexify.h"
-#include "Swiften/Base/String.h"
+#include <string>
#include "Swiften/Base/ByteArray.h"
using namespace Swift;
@@ -21,11 +21,11 @@ class HexifyTest : public CppUnit::TestFixture {
public:
void testHexify() {
- CPPUNIT_ASSERT_EQUAL(String("4206b23ca6b0a643d20d89b04ff58cf78b8096ed"), Hexify::hexify(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
+ CPPUNIT_ASSERT_EQUAL(std::string("4206b23ca6b0a643d20d89b04ff58cf78b8096ed"), Hexify::hexify(ByteArray("\x42\x06\xb2\x3c\xa6\xb0\xa6\x43\xd2\x0d\x89\xb0\x4f\xf5\x8c\xf7\x8b\x80\x96\xed")));
}
void testHexify_Byte() {
- CPPUNIT_ASSERT_EQUAL(String("b2"), Hexify::hexify(0xb2));
+ CPPUNIT_ASSERT_EQUAL(std::string("b2"), Hexify::hexify(0xb2));
}
};