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 /SwifTools
parentcad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff)
downloadswift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.zip
swift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2
Removed Swift::String.
Diffstat (limited to 'SwifTools')
-rw-r--r--SwifTools/Application/ApplicationPathProvider.cpp10
-rw-r--r--SwifTools/Application/ApplicationPathProvider.h12
-rw-r--r--SwifTools/Application/MacOSXApplicationPathProvider.cpp4
-rw-r--r--SwifTools/Application/MacOSXApplicationPathProvider.h2
-rw-r--r--SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp5
-rw-r--r--SwifTools/Application/UnixApplicationPathProvider.cpp16
-rw-r--r--SwifTools/Application/UnixApplicationPathProvider.h2
-rw-r--r--SwifTools/Application/WindowsApplicationPathProvider.cpp2
-rw-r--r--SwifTools/Application/WindowsApplicationPathProvider.h4
-rw-r--r--SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp2
-rw-r--r--SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h4
-rw-r--r--SwifTools/AutoUpdater/SparkleAutoUpdater.h4
-rw-r--r--SwifTools/AutoUpdater/SparkleAutoUpdater.mm4
-rw-r--r--SwifTools/Dock/Dock.h2
-rw-r--r--SwifTools/Dock/MacOSXDock.h2
-rw-r--r--SwifTools/Dock/MacOSXDock.mm4
-rw-r--r--SwifTools/Linkify.cpp12
-rw-r--r--SwifTools/Linkify.h4
-rw-r--r--SwifTools/Notifier/GNTPNotifier.cpp4
-rw-r--r--SwifTools/Notifier/GNTPNotifier.h6
-rw-r--r--SwifTools/Notifier/GrowlNotifier.cpp5
-rw-r--r--SwifTools/Notifier/GrowlNotifier.h4
-rw-r--r--SwifTools/Notifier/LoggingNotifier.h8
-rw-r--r--SwifTools/Notifier/Notifier.cpp2
-rw-r--r--SwifTools/Notifier/Notifier.h10
-rw-r--r--SwifTools/Notifier/NullNotifier.h2
-rw-r--r--SwifTools/Notifier/SnarlNotifier.cpp14
-rw-r--r--SwifTools/Notifier/SnarlNotifier.h4
-rw-r--r--SwifTools/Notifier/TogglableNotifier.h2
-rw-r--r--SwifTools/TabComplete.cpp15
-rw-r--r--SwifTools/TabComplete.h16
-rw-r--r--SwifTools/UnitTest/LinkifyTest.cpp72
-rw-r--r--SwifTools/UnitTest/TabCompleteTest.cpp56
33 files changed, 159 insertions, 156 deletions
diff --git a/SwifTools/Application/ApplicationPathProvider.cpp b/SwifTools/Application/ApplicationPathProvider.cpp
index 8457f88..e683563 100644
--- a/SwifTools/Application/ApplicationPathProvider.cpp
+++ b/SwifTools/Application/ApplicationPathProvider.cpp
@@ -13,14 +13,14 @@
namespace Swift {
-ApplicationPathProvider::ApplicationPathProvider(const String& applicationName) : applicationName(applicationName) {
+ApplicationPathProvider::ApplicationPathProvider(const std::string& applicationName) : applicationName(applicationName) {
}
ApplicationPathProvider::~ApplicationPathProvider() {
}
-boost::filesystem::path ApplicationPathProvider::getProfileDir(const String& profile) const {
- boost::filesystem::path result(getHomeDir() / profile.getUTF8String());
+boost::filesystem::path ApplicationPathProvider::getProfileDir(const std::string& profile) const {
+ boost::filesystem::path result(getHomeDir() / profile);
try {
boost::filesystem::create_directory(result);
}
@@ -30,10 +30,10 @@ boost::filesystem::path ApplicationPathProvider::getProfileDir(const String& pro
return result;
}
-boost::filesystem::path ApplicationPathProvider::getResourcePath(const String& resource) const {
+boost::filesystem::path ApplicationPathProvider::getResourcePath(const std::string& resource) const {
std::vector<boost::filesystem::path> resourcePaths = getResourceDirs();
foreach(const boost::filesystem::path& resourcePath, resourcePaths) {
- boost::filesystem::path r(resourcePath / resource.getUTF8String());
+ boost::filesystem::path r(resourcePath / resource);
if (boost::filesystem::exists(r)) {
return r;
}
diff --git a/SwifTools/Application/ApplicationPathProvider.h b/SwifTools/Application/ApplicationPathProvider.h
index 722f1ad..48a9602 100644
--- a/SwifTools/Application/ApplicationPathProvider.h
+++ b/SwifTools/Application/ApplicationPathProvider.h
@@ -9,27 +9,27 @@
#include <boost/filesystem.hpp>
#include <vector>
-#include "Swiften/Base/String.h"
+#include <string>
namespace Swift {
class ApplicationPathProvider {
public:
- ApplicationPathProvider(const String& applicationName);
+ ApplicationPathProvider(const std::string& applicationName);
virtual ~ApplicationPathProvider();
virtual boost::filesystem::path getHomeDir() const = 0;
virtual boost::filesystem::path getDataDir() const = 0;
virtual boost::filesystem::path getExecutableDir() const;
- boost::filesystem::path getProfileDir(const String& profile) const;
- boost::filesystem::path getResourcePath(const String& resource) const;
+ boost::filesystem::path getProfileDir(const std::string& profile) const;
+ boost::filesystem::path getResourcePath(const std::string& resource) const;
protected:
virtual std::vector<boost::filesystem::path> getResourceDirs() const = 0;
- const String& getApplicationName() const {
+ const std::string& getApplicationName() const {
return applicationName;
}
private:
- String applicationName;
+ std::string applicationName;
};
}
diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.cpp b/SwifTools/Application/MacOSXApplicationPathProvider.cpp
index fb6523c..0ed4d40 100644
--- a/SwifTools/Application/MacOSXApplicationPathProvider.cpp
+++ b/SwifTools/Application/MacOSXApplicationPathProvider.cpp
@@ -13,13 +13,13 @@
namespace Swift {
-MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const String& name) : ApplicationPathProvider(name) {
+MacOSXApplicationPathProvider::MacOSXApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) {
resourceDirs.push_back(getExecutableDir() / "../Resources");
resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
}
boost::filesystem::path MacOSXApplicationPathProvider::getDataDir() const {
- boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName().getUTF8String());
+ boost::filesystem::path result(getHomeDir() / "Library/Application Support" / getApplicationName());
try {
boost::filesystem::create_directory(result);
}
diff --git a/SwifTools/Application/MacOSXApplicationPathProvider.h b/SwifTools/Application/MacOSXApplicationPathProvider.h
index d2613f8..fec1944 100644
--- a/SwifTools/Application/MacOSXApplicationPathProvider.h
+++ b/SwifTools/Application/MacOSXApplicationPathProvider.h
@@ -11,7 +11,7 @@
namespace Swift {
class MacOSXApplicationPathProvider : public ApplicationPathProvider {
public:
- MacOSXApplicationPathProvider(const String& name);
+ MacOSXApplicationPathProvider(const std::string& name);
virtual boost::filesystem::path getHomeDir() const;
boost::filesystem::path getDataDir() const;
diff --git a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp
index cd171cb..a418bc2 100644
--- a/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp
+++ b/SwifTools/Application/UnitTest/ApplicationPathProviderTest.cpp
@@ -6,9 +6,10 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <string>
+#include <boost/algorithm/string.hpp>
#include "SwifTools/Application/PlatformApplicationPathProvider.h"
-#include "Swiften/Base/String.h"
using namespace Swift;
@@ -39,7 +40,7 @@ class ApplicationPathProviderTest : public CppUnit::TestFixture {
void testGetExecutableDir() {
boost::filesystem::path dir = testling_->getExecutableDir();
CPPUNIT_ASSERT(boost::filesystem::is_directory(dir));
- CPPUNIT_ASSERT(String(dir.string()).endsWith("UnitTest"));
+ CPPUNIT_ASSERT(boost::ends_with(dir.string(), "UnitTest"));
}
private:
diff --git a/SwifTools/Application/UnixApplicationPathProvider.cpp b/SwifTools/Application/UnixApplicationPathProvider.cpp
index 06fa977..2ac39ab 100644
--- a/SwifTools/Application/UnixApplicationPathProvider.cpp
+++ b/SwifTools/Application/UnixApplicationPathProvider.cpp
@@ -8,14 +8,14 @@
namespace Swift {
-UnixApplicationPathProvider::UnixApplicationPathProvider(const String& name) : ApplicationPathProvider(name) {
+UnixApplicationPathProvider::UnixApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) {
resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
char* xdgDataDirs = getenv("XDG_DATA_DIRS");
if (xdgDataDirs) {
- std::vector<String> dataDirs = String(xdgDataDirs).split(':');
+ std::vector<std::string> dataDirs = std::string(xdgDataDirs).split(':');
if (!dataDirs.empty()) {
- foreach(const String& dir, dataDirs) {
- resourceDirs.push_back(boost::filesystem::path(dir.getUTF8String()) / "swift");
+ foreach(const std::string& dir, dataDirs) {
+ resourceDirs.push_back(boost::filesystem::path(dir) / "swift");
}
return;
}
@@ -31,14 +31,14 @@ boost::filesystem::path UnixApplicationPathProvider::getHomeDir() const {
boost::filesystem::path UnixApplicationPathProvider::getDataDir() const {
char* xdgDataHome = getenv("XDG_DATA_HOME");
- String dataDir;
+ std::string dataDir;
if (xdgDataHome) {
- dataDir = String(xdgDataHome);
+ dataDir = std::string(xdgDataHome);
}
- boost::filesystem::path dataPath = (dataDir.isEmpty() ?
+ boost::filesystem::path dataPath = (dataDir.empty() ?
getHomeDir() / ".local" / "share"
- : boost::filesystem::path(dataDir.getUTF8String())) / getApplicationName().getLowerCase().getUTF8String();
+ : boost::filesystem::path(dataDir)) / getApplicationName().getLowerCase();
try {
boost::filesystem::create_directories(dataPath);
diff --git a/SwifTools/Application/UnixApplicationPathProvider.h b/SwifTools/Application/UnixApplicationPathProvider.h
index 0c2f643..e043976 100644
--- a/SwifTools/Application/UnixApplicationPathProvider.h
+++ b/SwifTools/Application/UnixApplicationPathProvider.h
@@ -17,7 +17,7 @@
namespace Swift {
class UnixApplicationPathProvider : public ApplicationPathProvider {
public:
- UnixApplicationPathProvider(const String& name);
+ UnixApplicationPathProvider(const std::string& name);
virtual boost::filesystem::path getHomeDir() const;
boost::filesystem::path getDataDir() const;
diff --git a/SwifTools/Application/WindowsApplicationPathProvider.cpp b/SwifTools/Application/WindowsApplicationPathProvider.cpp
index e19606f..d645b90 100644
--- a/SwifTools/Application/WindowsApplicationPathProvider.cpp
+++ b/SwifTools/Application/WindowsApplicationPathProvider.cpp
@@ -12,7 +12,7 @@
namespace Swift {
-WindowsApplicationPathProvider::WindowsApplicationPathProvider(const String& name) : ApplicationPathProvider(name) {
+WindowsApplicationPathProvider::WindowsApplicationPathProvider(const std::string& name) : ApplicationPathProvider(name) {
resourceDirs.push_back(getExecutableDir());
resourceDirs.push_back(getExecutableDir() / "../resources"); // Development
}
diff --git a/SwifTools/Application/WindowsApplicationPathProvider.h b/SwifTools/Application/WindowsApplicationPathProvider.h
index 26f7045..9428908 100644
--- a/SwifTools/Application/WindowsApplicationPathProvider.h
+++ b/SwifTools/Application/WindowsApplicationPathProvider.h
@@ -11,11 +11,11 @@
namespace Swift {
class WindowsApplicationPathProvider : public ApplicationPathProvider {
public:
- WindowsApplicationPathProvider(const String& name);
+ WindowsApplicationPathProvider(const std::string& name);
boost::filesystem::path getDataDir() const {
char* appDirRaw = getenv("APPDATA");
- boost::filesystem::path result(boost::filesystem::path(appDirRaw) / getApplicationName().getUTF8String());
+ boost::filesystem::path result(boost::filesystem::path(appDirRaw) / getApplicationName());
boost::filesystem::create_directory(result);
return result;
}
diff --git a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp
index adc6d2d..4dd06c7 100644
--- a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp
+++ b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.cpp
@@ -22,7 +22,7 @@ bool PlatformAutoUpdaterFactory::isSupported() const {
#endif
}
-AutoUpdater* PlatformAutoUpdaterFactory::createAutoUpdater(const String& appcastURL) {
+AutoUpdater* PlatformAutoUpdaterFactory::createAutoUpdater(const std::string& appcastURL) {
#ifdef HAVE_SPARKLE
return new SparkleAutoUpdater(appcastURL);
#else
diff --git a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h
index 11528a3..59df238 100644
--- a/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h
+++ b/SwifTools/AutoUpdater/PlatformAutoUpdaterFactory.h
@@ -4,7 +4,7 @@
* See Documentation/Licenses/GPLv3.txt for more information.
*/
-#include "Swiften/Base/String.h"
+#include <string>
namespace Swift {
class AutoUpdater;
@@ -13,6 +13,6 @@ namespace Swift {
public:
bool isSupported() const;
- AutoUpdater* createAutoUpdater(const String& appcastURL);
+ AutoUpdater* createAutoUpdater(const std::string& appcastURL);
};
}
diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.h b/SwifTools/AutoUpdater/SparkleAutoUpdater.h
index 5fddda5..fc08975 100644
--- a/SwifTools/AutoUpdater/SparkleAutoUpdater.h
+++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.h
@@ -6,13 +6,13 @@
#pragma once
-#include "Swiften/Base/String.h"
+#include <string>
#include "SwifTools/AutoUpdater/AutoUpdater.h"
namespace Swift {
class SparkleAutoUpdater : public AutoUpdater {
public:
- SparkleAutoUpdater(const String& url);
+ SparkleAutoUpdater(const std::string& url);
~SparkleAutoUpdater();
void checkForUpdates();
diff --git a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
index a8ae60a..440e178 100644
--- a/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
+++ b/SwifTools/AutoUpdater/SparkleAutoUpdater.mm
@@ -10,7 +10,7 @@ class SparkleAutoUpdater::Private {
SUUpdater* updater;
};
-SparkleAutoUpdater::SparkleAutoUpdater(const String& url) {
+SparkleAutoUpdater::SparkleAutoUpdater(const std::string& url) {
d = new Private;
d->updater = [SUUpdater sharedUpdater];
@@ -18,7 +18,7 @@ SparkleAutoUpdater::SparkleAutoUpdater(const String& url) {
[d->updater setAutomaticallyChecksForUpdates: true];
NSURL* nsurl = [NSURL URLWithString:
- [NSString stringWithUTF8String: url.getUTF8Data()]];
+ [NSString stringWithUTF8String: url.c_str()]];
[d->updater setFeedURL: nsurl];
}
diff --git a/SwifTools/Dock/Dock.h b/SwifTools/Dock/Dock.h
index 2dd312c..1bd96fb 100644
--- a/SwifTools/Dock/Dock.h
+++ b/SwifTools/Dock/Dock.h
@@ -7,7 +7,7 @@
#pragma once
namespace Swift {
- class String;
+
class Dock {
public:
diff --git a/SwifTools/Dock/MacOSXDock.h b/SwifTools/Dock/MacOSXDock.h
index 511a652..64cc737 100644
--- a/SwifTools/Dock/MacOSXDock.h
+++ b/SwifTools/Dock/MacOSXDock.h
@@ -9,7 +9,7 @@
#include "SwifTools/Dock/Dock.h"
namespace Swift {
- class String;
+
class CocoaApplication;
class MacOSXDock : public Dock {
diff --git a/SwifTools/Dock/MacOSXDock.mm b/SwifTools/Dock/MacOSXDock.mm
index 0438353..a7a3d55 100644
--- a/SwifTools/Dock/MacOSXDock.mm
+++ b/SwifTools/Dock/MacOSXDock.mm
@@ -12,8 +12,8 @@ MacOSXDock::MacOSXDock(CocoaApplication*) {
}
void MacOSXDock::setNumberOfPendingMessages(int i) {
- String label(i > 0 ? boost::lexical_cast<std::string>(i) : "");
- NSString *labelString = [[NSString alloc] initWithUTF8String: label.getUTF8Data()];
+ std::string label(i > 0 ? boost::lexical_cast<std::string>(i) : "");
+ NSString *labelString = [[NSString alloc] initWithUTF8String: label.c_str()];
[[NSApp dockTile] setBadgeLabel: labelString];
[labelString release];
[NSApp requestUserAttention: NSInformationalRequest];
diff --git a/SwifTools/Linkify.cpp b/SwifTools/Linkify.cpp
index 822536e..91c713f 100644
--- a/SwifTools/Linkify.cpp
+++ b/SwifTools/Linkify.cpp
@@ -14,18 +14,18 @@ namespace Swift {
static boost::regex linkifyRegexp("^https?://.*");
-String Linkify::linkify(const String& input) {
+std::string Linkify::linkify(const std::string& input) {
std::ostringstream result;
std::vector<char> currentURL;
bool inURL = false;
- for (size_t i = 0; i < input.getUTF8Size(); ++i) {
+ for (size_t i = 0; i < input.size(); ++i) {
char c = input[i];
if (inURL) {
if (c != ' ' && c != '\t' && c != '\n') {
currentURL.push_back(c);
}
else {
- String url(&currentURL[0], currentURL.size());
+ std::string url(&currentURL[0], currentURL.size());
result << "<a href=\"" << url << "\">" << url << "</a>";
currentURL.clear();
inURL = false;
@@ -33,7 +33,7 @@ String Linkify::linkify(const String& input) {
}
}
else {
- if (boost::regex_match(input.getSubstring(i, 8).getUTF8String(), linkifyRegexp)) {
+ if (boost::regex_match(input.substr(i, 8), linkifyRegexp)) {
currentURL.push_back(c);
inURL = true;
}
@@ -43,10 +43,10 @@ String Linkify::linkify(const String& input) {
}
}
if (currentURL.size() > 0) {
- String url(&currentURL[0], currentURL.size());
+ std::string url(&currentURL[0], currentURL.size());
result << "<a href=\"" << url << "\">" << url << "</a>";
}
- return String(result.str());
+ return std::string(result.str());
}
}
diff --git a/SwifTools/Linkify.h b/SwifTools/Linkify.h
index cb5e806..ebe232f 100644
--- a/SwifTools/Linkify.h
+++ b/SwifTools/Linkify.h
@@ -6,10 +6,10 @@
#pragma once
-#include "Swiften/Base/String.h"
+#include <string>
namespace Swift {
namespace Linkify {
- String linkify(const String&);
+ std::string linkify(const std::string&);
}
}
diff --git a/SwifTools/Notifier/GNTPNotifier.cpp b/SwifTools/Notifier/GNTPNotifier.cpp
index 924b921..9a20c33 100644
--- a/SwifTools/Notifier/GNTPNotifier.cpp
+++ b/SwifTools/Notifier/GNTPNotifier.cpp
@@ -18,7 +18,7 @@
namespace Swift {
-GNTPNotifier::GNTPNotifier(const String& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory) : name(name), icon(icon), connectionFactory(connectionFactory), initialized(false), registered(false) {
+GNTPNotifier::GNTPNotifier(const std::string& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory) : name(name), icon(icon), connectionFactory(connectionFactory), initialized(false), registered(false) {
// Registration message
std::ostringstream message;
message << "GNTP/1.0 REGISTER NONE\r\n";
@@ -51,7 +51,7 @@ void GNTPNotifier::send(const std::string& message) {
currentConnection->connect(HostAddressPort(HostAddress("127.0.0.1"), 23053));
}
-void GNTPNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()>) {
+void GNTPNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()>) {
if (registered) {
std::ostringstream message;
message << "GNTP/1.0 NOTIFY NONE\r\n";
diff --git a/SwifTools/Notifier/GNTPNotifier.h b/SwifTools/Notifier/GNTPNotifier.h
index 47b0c01..a740c27 100644
--- a/SwifTools/Notifier/GNTPNotifier.h
+++ b/SwifTools/Notifier/GNTPNotifier.h
@@ -16,10 +16,10 @@ namespace Swift {
class GNTPNotifier : public Notifier {
public:
- GNTPNotifier(const String& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory);
+ GNTPNotifier(const std::string& name, const boost::filesystem::path& icon, ConnectionFactory* connectionFactory);
~GNTPNotifier();
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
private:
void handleConnectFinished(bool error);
@@ -27,7 +27,7 @@ namespace Swift {
void send(const std::string& message);
private:
- String name;
+ std::string name;
boost::filesystem::path icon;
ConnectionFactory* connectionFactory;
bool initialized;
diff --git a/SwifTools/Notifier/GrowlNotifier.cpp b/SwifTools/Notifier/GrowlNotifier.cpp
index 8b5920f..5ecd34c 100644
--- a/SwifTools/Notifier/GrowlNotifier.cpp
+++ b/SwifTools/Notifier/GrowlNotifier.cpp
@@ -8,6 +8,7 @@
#include <cassert>
+#include "Swiften/Base/String.h"
#include "Swiften/Base/ByteArray.h"
#include "SwifTools/Notifier/GrowlNotifier.h"
#include "Swiften/Base/foreach.h"
@@ -47,7 +48,7 @@ namespace {
namespace Swift {
-GrowlNotifier::GrowlNotifier(const String& name) {
+GrowlNotifier::GrowlNotifier(const std::string& name) {
// All notifications
CFMutableArrayRef allNotifications = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
foreach(Type type, getAllTypes()) {
@@ -71,7 +72,7 @@ GrowlNotifier::GrowlNotifier(const String& name) {
Growl_SetDelegate(&delegate_);
}
-void GrowlNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picturePath, boost::function<void()> callback) {
+void GrowlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picturePath, boost::function<void()> callback) {
ByteArray picture;
picture.readFromFile(picturePath.string());
diff --git a/SwifTools/Notifier/GrowlNotifier.h b/SwifTools/Notifier/GrowlNotifier.h
index f7c4260..d4a6178 100644
--- a/SwifTools/Notifier/GrowlNotifier.h
+++ b/SwifTools/Notifier/GrowlNotifier.h
@@ -21,9 +21,9 @@ namespace Swift {
*/
class GrowlNotifier : public Notifier {
public:
- GrowlNotifier(const String& name);
+ GrowlNotifier(const std::string& name);
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
private:
Growl_Delegate delegate_;
diff --git a/SwifTools/Notifier/LoggingNotifier.h b/SwifTools/Notifier/LoggingNotifier.h
index eea07ef..18ae0e2 100644
--- a/SwifTools/Notifier/LoggingNotifier.h
+++ b/SwifTools/Notifier/LoggingNotifier.h
@@ -12,15 +12,15 @@
namespace Swift {
class LoggingNotifier : public Notifier {
public:
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
notifications.push_back(Notification(type, subject, description, picture, callback));
}
struct Notification {
- Notification(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) : type(type), subject(subject), description(description), picture(picture), callback(callback) {}
+ Notification(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) : type(type), subject(subject), description(description), picture(picture), callback(callback) {}
Type type;
- String subject;
- String description;
+ std::string subject;
+ std::string description;
boost::filesystem::path picture;
boost::function<void()> callback;
};
diff --git a/SwifTools/Notifier/Notifier.cpp b/SwifTools/Notifier/Notifier.cpp
index 2c2660e..1673400 100644
--- a/SwifTools/Notifier/Notifier.cpp
+++ b/SwifTools/Notifier/Notifier.cpp
@@ -14,7 +14,7 @@ const int Notifier::DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS = 5;
Notifier::~Notifier() {
}
-String Notifier::typeToString(Type type) {
+std::string Notifier::typeToString(Type type) {
switch (type) {
case ContactAvailable: return "Contact Becomes Available";
case ContactUnavailable: return "Contact Becomes Unavailable";
diff --git a/SwifTools/Notifier/Notifier.h b/SwifTools/Notifier/Notifier.h
index a8424bf..d6bd878 100644
--- a/SwifTools/Notifier/Notifier.h
+++ b/SwifTools/Notifier/Notifier.h
@@ -8,8 +8,8 @@
#include <boost/function.hpp>
#include <boost/filesystem/path.hpp>
-
-#include "Swiften/Base/String.h"
+#include <string>
+#include <vector>
namespace Swift {
class Notifier {
@@ -23,8 +23,8 @@ namespace Swift {
*/
virtual void showMessage(
Type type,
- const String& subject,
- const String& description,
+ const std::string& subject,
+ const std::string& description,
const boost::filesystem::path& picture,
boost::function<void()> callback) = 0;
@@ -33,7 +33,7 @@ namespace Swift {
}
protected:
- String typeToString(Type type);
+ std::string typeToString(Type type);
static std::vector<Type> getAllTypes();
static std::vector<Type> getDefaultTypes();
diff --git a/SwifTools/Notifier/NullNotifier.h b/SwifTools/Notifier/NullNotifier.h
index e97329b..24b4476 100644
--- a/SwifTools/Notifier/NullNotifier.h
+++ b/SwifTools/Notifier/NullNotifier.h
@@ -11,7 +11,7 @@
namespace Swift {
class NullNotifier : public Notifier {
public:
- virtual void showMessage(Type, const String&, const String&, const boost::filesystem::path&, boost::function<void()>) {
+ virtual void showMessage(Type, const std::string&, const std::string&, const boost::filesystem::path&, boost::function<void()>) {
}
};
}
diff --git a/SwifTools/Notifier/SnarlNotifier.cpp b/SwifTools/Notifier/SnarlNotifier.cpp
index 8d7407a..e93a539 100644
--- a/SwifTools/Notifier/SnarlNotifier.cpp
+++ b/SwifTools/Notifier/SnarlNotifier.cpp
@@ -17,11 +17,11 @@
namespace Swift {
-SnarlNotifier::SnarlNotifier(const String& name, Win32NotifierWindow* window, const boost::filesystem::path& icon) : window(window), available(false) {
+SnarlNotifier::SnarlNotifier(const std::string& name, Win32NotifierWindow* window, const boost::filesystem::path& icon) : window(window), available(false) {
window->onMessageReceived.connect(boost::bind(&SnarlNotifier::handleMessageReceived, this, _1));
- available = snarl.RegisterApp(name.getUTF8Data(), name.getUTF8Data(), icon.string().c_str(), window->getID(), SWIFT_SNARLNOTIFIER_MESSAGE_ID);
+ available = snarl.RegisterApp(name.c_str(), name.c_str(), icon.string().c_str(), window->getID(), SWIFT_SNARLNOTIFIER_MESSAGE_ID);
foreach(Notifier::Type type, getAllTypes()) {
- snarl.AddClass(typeToString(type).getUTF8Data(), typeToString(type).getUTF8Data());
+ snarl.AddClass(typeToString(type).c_str(), typeToString(type).c_str());
}
}
@@ -38,12 +38,12 @@ bool SnarlNotifier::isAvailable() const {
}
-void SnarlNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+void SnarlNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
int timeout = (type == IncomingMessage || type == SystemMessage) ? DEFAULT_MESSAGE_NOTIFICATION_TIMEOUT_SECONDS : DEFAULT_STATUS_NOTIFICATION_TIMEOUT_SECONDS;
int notificationID = snarl.EZNotify(
- typeToString(type).getUTF8Data(),
- subject.getUTF8Data(),
- description.getUTF8Data(),
+ typeToString(type).c_str(),
+ subject.c_str(),
+ description.c_str(),
timeout,
picture.string().c_str());
if (notificationID > 0) {
diff --git a/SwifTools/Notifier/SnarlNotifier.h b/SwifTools/Notifier/SnarlNotifier.h
index 9aa75f6..9e2cddf 100644
--- a/SwifTools/Notifier/SnarlNotifier.h
+++ b/SwifTools/Notifier/SnarlNotifier.h
@@ -16,10 +16,10 @@ namespace Swift {
class SnarlNotifier : public Notifier {
public:
- SnarlNotifier(const String& name, Win32NotifierWindow* window, const boost::filesystem::path& icon);
+ SnarlNotifier(const std::string& name, Win32NotifierWindow* window, const boost::filesystem::path& icon);
~SnarlNotifier();
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback);
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback);
virtual bool isAvailable() const;
private:
diff --git a/SwifTools/Notifier/TogglableNotifier.h b/SwifTools/Notifier/TogglableNotifier.h
index 1e87807..415caf6 100644
--- a/SwifTools/Notifier/TogglableNotifier.h
+++ b/SwifTools/Notifier/TogglableNotifier.h
@@ -40,7 +40,7 @@ namespace Swift {
return persistentEnabled && !temporarilyDisabled;
}
- virtual void showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
+ virtual void showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) {
if (getCurrentlyEnabled()) {
notifier->showMessage(type, subject, description, picture, callback);
}
diff --git a/SwifTools/TabComplete.cpp b/SwifTools/TabComplete.cpp
index 1e15595..b123360 100644
--- a/SwifTools/TabComplete.cpp
+++ b/SwifTools/TabComplete.cpp
@@ -7,25 +7,26 @@
#include "SwifTools/TabComplete.h"
#include <algorithm>
+#include <boost/algorithm/string.hpp>
#include "Swiften/Base/foreach.h"
namespace Swift {
-void TabComplete::addWord(const String& word) {
+void TabComplete::addWord(const std::string& word) {
words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end());
words_.insert(words_.begin(), word);
- if (word.getLowerCase().beginsWith(lastShort_)) {
+ if (boost::starts_with(boost::to_lower_copy(word), lastShort_)) {
lastCompletionCandidates_.insert(lastCompletionCandidates_.begin(), word);
}
}
-void TabComplete::removeWord(const String& word) {
+void TabComplete::removeWord(const std::string& word) {
words_.erase(std::remove(words_.begin(), words_.end(), word), words_.end());
lastCompletionCandidates_.erase(std::remove(lastCompletionCandidates_.begin(), lastCompletionCandidates_.end(), word), lastCompletionCandidates_.end());
}
-String TabComplete::completeWord(const String& word) {
+std::string TabComplete::completeWord(const std::string& word) {
if (word == lastCompletion_) {
if (lastCompletionCandidates_.size() != 0) {
size_t match = 0;
@@ -39,10 +40,10 @@ String TabComplete::completeWord(const String& word) {
lastCompletion_ = lastCompletionCandidates_[nextIndex];
}
} else {
- lastShort_ = word.getLowerCase();
+ lastShort_ = boost::to_lower_copy(word);
lastCompletionCandidates_.clear();
- foreach (String candidate, words_) {
- if (candidate.getLowerCase().beginsWith(word.getLowerCase())) {
+ foreach (std::string candidate, words_) {
+ if (boost::starts_with(boost::to_lower_copy(candidate), boost::to_lower_copy(word))) {
lastCompletionCandidates_.push_back(candidate);
}
}
diff --git a/SwifTools/TabComplete.h b/SwifTools/TabComplete.h
index 01e294f..d01174f 100644
--- a/SwifTools/TabComplete.h
+++ b/SwifTools/TabComplete.h
@@ -8,18 +8,18 @@
#include <vector>
-#include "Swiften/Base/String.h"
+#include <string>
namespace Swift {
class TabComplete {
public:
- void addWord(const String& word);
- void removeWord(const String& word);
- String completeWord(const String& word);
+ void addWord(const std::string& word);
+ void removeWord(const std::string& word);
+ std::string completeWord(const std::string& word);
private:
- std::vector<String> words_;
- String lastCompletion_;
- String lastShort_;
- std::vector<String> lastCompletionCandidates_;
+ std::vector<std::string> words_;
+ std::string lastCompletion_;
+ std::string lastShort_;
+ std::vector<std::string> lastCompletionCandidates_;
};
}
diff --git a/SwifTools/UnitTest/LinkifyTest.cpp b/SwifTools/UnitTest/LinkifyTest.cpp
index a35a686..f7e2a37 100644
--- a/SwifTools/UnitTest/LinkifyTest.cpp
+++ b/SwifTools/UnitTest/LinkifyTest.cpp
@@ -35,147 +35,147 @@ class LinkifyTest : public CppUnit::TestFixture {
public:
void testLinkify_URLWithResource() {
- String result = Linkify::linkify("http://swift.im/blog");
+ std::string result = Linkify::linkify("http://swift.im/blog");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"),
+ std::string("<a href=\"http://swift.im/blog\">http://swift.im/blog</a>"),
result);
}
void testLinkify_HTTPSURLWithResource() {
- String result = Linkify::linkify("https://swift.im/blog");
+ std::string result = Linkify::linkify("https://swift.im/blog");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"),
+ std::string("<a href=\"https://swift.im/blog\">https://swift.im/blog</a>"),
result);
}
void testLinkify_URLWithEmptyResource() {
- String result = Linkify::linkify("http://swift.im/");
+ std::string result = Linkify::linkify("http://swift.im/");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://swift.im/\">http://swift.im/</a>"),
+ std::string("<a href=\"http://swift.im/\">http://swift.im/</a>"),
result);
}
void testLinkify_BareURL() {
- String result = Linkify::linkify("http://swift.im");
+ std::string result = Linkify::linkify("http://swift.im");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://swift.im\">http://swift.im</a>"),
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>"),
result);
}
void testLinkify_URLSurroundedByWhitespace() {
- String result = Linkify::linkify("Foo http://swift.im/blog Bar");
+ std::string result = Linkify::linkify("Foo http://swift.im/blog Bar");
CPPUNIT_ASSERT_EQUAL(
- String("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"),
+ std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar"),
result);
}
void testLinkify_MultipleURLs() {
- String result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz");
+ std::string result = Linkify::linkify("Foo http://swift.im/blog Bar http://el-tramo.be/about Baz");
CPPUNIT_ASSERT_EQUAL(
- String("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> Baz"),
+ std::string("Foo <a href=\"http://swift.im/blog\">http://swift.im/blog</a> Bar <a href=\"http://el-tramo.be/about\">http://el-tramo.be/about</a> Baz"),
result);
}
void testLinkify_CamelCase() {
- String result = Linkify::linkify("http://fOo.cOm/bAz");
+ std::string result = Linkify::linkify("http://fOo.cOm/bAz");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"),
+ std::string("<a href=\"http://fOo.cOm/bAz\">http://fOo.cOm/bAz</a>"),
result);
}
void testLinkify_HierarchicalResource() {
- String result = Linkify::linkify("http://foo.com/bar/baz/");
+ std::string result = Linkify::linkify("http://foo.com/bar/baz/");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"),
+ std::string("<a href=\"http://foo.com/bar/baz/\">http://foo.com/bar/baz/</a>"),
result);
}
void testLinkify_Anchor() {
- String result = Linkify::linkify("http://foo.com/bar#baz");
+ std::string result = Linkify::linkify("http://foo.com/bar#baz");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"),
+ std::string("<a href=\"http://foo.com/bar#baz\">http://foo.com/bar#baz</a>"),
result);
}
void testLinkify_Plus() {
- String result = Linkify::linkify("http://foo.com/bar+baz");
+ std::string result = Linkify::linkify("http://foo.com/bar+baz");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"),
+ std::string("<a href=\"http://foo.com/bar+baz\">http://foo.com/bar+baz</a>"),
result);
}
void testLinkify_Tilde() {
- String result = Linkify::linkify("http://foo.com/~kev/");
+ std::string result = Linkify::linkify("http://foo.com/~kev/");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"),
+ std::string("<a href=\"http://foo.com/~kev/\">http://foo.com/~kev/</a>"),
result);
}
void testLinkify_Equal() {
- String result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0");
+ std::string result = Linkify::linkify("http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"),
+ std::string("<a href=\"http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0\">http://www.amazon.co.uk/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=xmpp+definitive+guide&x=0&y=0</a>"),
result);
}
void testLinkify_Authentication() {
- String result = Linkify::linkify("http://bob:bla@swift.im/foo/bar");
+ std::string result = Linkify::linkify("http://bob:bla@swift.im/foo/bar");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"),
+ std::string("<a href=\"http://bob:bla@swift.im/foo/bar\">http://bob:bla@swift.im/foo/bar</a>"),
result);
}
void testLinkify_At() {
- String result = Linkify::linkify("http://swift.im/foo@bar");
+ std::string result = Linkify::linkify("http://swift.im/foo@bar");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"),
+ std::string("<a href=\"http://swift.im/foo@bar\">http://swift.im/foo@bar</a>"),
result);
}
void testLinkify_Amps() {
- String result = Linkify::linkify("http://swift.im/foo&bar&baz");
+ std::string result = Linkify::linkify("http://swift.im/foo&bar&baz");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"),
+ std::string("<a href=\"http://swift.im/foo&bar&baz\">http://swift.im/foo&bar&baz</a>"),
result);
}
void testLinkify_UnicodeCharacter() {
- String result = Linkify::linkify("http://\xe2\x98\x83.net");
+ std::string result = Linkify::linkify("http://\xe2\x98\x83.net");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"),
+ std::string("<a href=\"http://\xe2\x98\x83.net\">http://\xe2\x98\x83.net</a>"),
result);
}
void testLinkify_NewLine() {
- String result = Linkify::linkify("http://swift.im\nfoo");
+ std::string result = Linkify::linkify("http://swift.im\nfoo");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://swift.im\">http://swift.im</a>\nfoo"),
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>\nfoo"),
result);
}
void testLinkify_Tab() {
- String result = Linkify::linkify("http://swift.im\tfoo");
+ std::string result = Linkify::linkify("http://swift.im\tfoo");
CPPUNIT_ASSERT_EQUAL(
- String("<a href=\"http://swift.im\">http://swift.im</a>\tfoo"),
+ std::string("<a href=\"http://swift.im\">http://swift.im</a>\tfoo"),
result);
}
};
diff --git a/SwifTools/UnitTest/TabCompleteTest.cpp b/SwifTools/UnitTest/TabCompleteTest.cpp
index b7b643f..2224839 100644
--- a/SwifTools/UnitTest/TabCompleteTest.cpp
+++ b/SwifTools/UnitTest/TabCompleteTest.cpp
@@ -31,7 +31,7 @@ public:
}
void testEmpty() {
- String blah("Blah");
+ std::string blah("Blah");
CPPUNIT_ASSERT_EQUAL(
blah,
completer_.completeWord(blah));
@@ -42,7 +42,7 @@ public:
void testNoMatch() {
completer_.addWord("Bleh");
- String blah("Blah");
+ std::string blah("Blah");
CPPUNIT_ASSERT_EQUAL(
blah,
completer_.completeWord(blah));
@@ -52,8 +52,8 @@ public:
}
void testOneMatch() {
- String short1("Bl");
- String long1("Blehling");
+ std::string short1("Bl");
+ std::string long1("Blehling");
completer_.addWord(long1);
CPPUNIT_ASSERT_EQUAL(
long1,
@@ -64,9 +64,9 @@ public:
}
void testTwoMatch() {
- String short1("Hur");
- String long1("Hurgle");
- String long2("Hurdler");
+ std::string short1("Hur");
+ std::string long1("Hurgle");
+ std::string long2("Hurdler");
completer_.addWord(long1);
completer_.addWord("Blah");
completer_.addWord(long2);
@@ -83,10 +83,10 @@ public:
}
void testChangeMatch() {
- String short1("Hur");
- String short2("Rub");
- String long1("Hurgle");
- String long2("Rubbish");
+ std::string short1("Hur");
+ std::string short2("Rub");
+ std::string long1("Hurgle");
+ std::string long2("Rubbish");
completer_.addWord(long2);
completer_.addWord("Blah");
completer_.addWord(long1);
@@ -106,9 +106,9 @@ public:
}
void testRemoveDuringComplete() {
- String short1("Kev");
- String long1("Kevin");
- String long2("Kevlar");
+ std::string short1("Kev");
+ std::string long1("Kevin");
+ std::string long2("Kevlar");
completer_.addWord(long1);
completer_.addWord("Blah");
completer_.addWord(long2);
@@ -126,10 +126,10 @@ public:
}
void testAddDuringComplete() {
- String short1("Rem");
- String long1("Remko");
- String long2("Remove");
- String long3("Remedial");
+ std::string short1("Rem");
+ std::string long1("Remko");
+ std::string long2("Remove");
+ std::string long3("Remedial");
completer_.addWord(long1);
completer_.addWord("Blah");
completer_.addWord(long2);
@@ -147,16 +147,16 @@ public:
}
void testSwiftRoomSample() {
- String t("t");
- String Anpan("Anpan");
- String cdubouloz("cdubouloz");
- String Tobias("Tobias");
- String Zash("Zash");
- String lastsky("lastsky");
- String Steve("Steve Kille");
- String Flo("Flo");
- String Test("Test");
- String test("test");
+ std::string t("t");
+ std::string Anpan("Anpan");
+ std::string cdubouloz("cdubouloz");
+ std::string Tobias("Tobias");
+ std::string Zash("Zash");
+ std::string lastsky("lastsky");
+ std::string Steve("Steve Kille");
+ std::string Flo("Flo");
+ std::string Test("Test");
+ std::string test("test");
completer_.addWord(Anpan);
completer_.addWord(cdubouloz);
completer_.addWord(Tobias);