diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-02-14 18:57:18 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-02-14 21:36:32 (GMT) |
commit | cb05f5a908e20006c954ce38755c2e422ecc2388 (patch) | |
tree | a793551a5fe279a57d4330119560e8542f745484 | |
parent | cad974b45c0fb9355e68d9728e42c9ae3dbcebc7 (diff) | |
download | swift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.zip swift-contrib-cb05f5a908e20006c954ce38755c2e422ecc2388.tar.bz2 |
Removed Swift::String.
734 files changed, 3371 insertions, 3518 deletions
diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h index 1354ebf..7533a1e 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayload.h @@ -14,14 +14,14 @@ class EchoPayload : public Payload { public: EchoPayload() {} - const String& getMessage() const { + const std::string& getMessage() const { return message; } - void setMessage(const String& message) { + void setMessage(const std::string& message) { this->message = message; } private: - String message; + std::string message; }; diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h index 3af616c..9cbb795 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadParserFactory.h @@ -16,24 +16,24 @@ class EchoPayloadParser : public GenericPayloadParser<EchoPayload> { EchoPayloadParser() : currentDepth(0) {} void handleStartElement( - const String& /* element */, const String& /* ns */, const AttributeMap&) { + const std::string& /* element */, const std::string& /* ns */, const AttributeMap&) { currentDepth++; } - void handleEndElement(const String& /* element */, const String& /* ns */) { + void handleEndElement(const std::string& /* element */, const std::string& /* ns */) { currentDepth--; if (currentDepth == 0) { getPayloadInternal()->setMessage(currentText); } } - void handleCharacterData(const String& data) { + void handleCharacterData(const std::string& data) { currentText += data; } private: int currentDepth; - String currentText; + std::string currentText; }; class EchoPayloadParserFactory : public GenericPayloadParserFactory<EchoPayloadParser> { diff --git a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h index 1b18be4..85e8e67 100644 --- a/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h +++ b/Documentation/SwiftenDevelopersGuide/Examples/EchoBot/EchoPayloadSerializer.h @@ -13,7 +13,7 @@ using namespace Swift; class EchoPayloadSerializer : public GenericPayloadSerializer<EchoPayload> { public: - String serializePayload(boost::shared_ptr<EchoPayload> payload) const { + std::string serializePayload(boost::shared_ptr<EchoPayload> payload) const { XMLElement element("echo", "http://swift.im/protocol/echo"); element.addNode(XMLTextNode::ref(new XMLTextNode(payload->getMessage()))); return element.serialize(); diff --git a/Slimber/CLI/DummyMenulet.h b/Slimber/CLI/DummyMenulet.h index e0bcb2f..56cc9ce 100644 --- a/Slimber/CLI/DummyMenulet.h +++ b/Slimber/CLI/DummyMenulet.h @@ -16,7 +16,7 @@ class DummyMenulet : public Menulet { void clear() { } - void addItem(const Swift::String&, const Swift::String&) { + void addItem(const std::string&, const std::string&) { } void addAboutItem() { @@ -31,6 +31,6 @@ class DummyMenulet : public Menulet { void addSeparator() { } - void setIcon(const Swift::String&) { + void setIcon(const std::string&) { } }; diff --git a/Slimber/Cocoa/CocoaMenulet.h b/Slimber/Cocoa/CocoaMenulet.h index 292c8b9..7f2758b 100644 --- a/Slimber/Cocoa/CocoaMenulet.h +++ b/Slimber/Cocoa/CocoaMenulet.h @@ -18,9 +18,9 @@ class CocoaMenulet : public Menulet { private: virtual void clear(); - virtual void addItem(const Swift::String& name, const Swift::String& icon); + virtual void addItem(const std::string& name, const std::string& icon); virtual void addSeparator(); - void setIcon(const Swift::String& icon); + void setIcon(const std::string& icon); virtual void addAboutItem(); virtual void addRestartItem(); virtual void addExitItem(); diff --git a/Slimber/Cocoa/CocoaMenulet.mm b/Slimber/Cocoa/CocoaMenulet.mm index 90e699f..de9e9e9 100644 --- a/Slimber/Cocoa/CocoaMenulet.mm +++ b/Slimber/Cocoa/CocoaMenulet.mm @@ -4,8 +4,6 @@ #include <boost/function.hpp> -using namespace Swift; - CocoaMenulet::CocoaMenulet() { restartAction = [[CocoaAction alloc] initWithFunction: new boost::function<void()>(boost::ref(onRestartClicked))]; @@ -25,9 +23,9 @@ CocoaMenulet::~CocoaMenulet() { [restartAction release]; } -void CocoaMenulet::setIcon(const String& icon) { +void CocoaMenulet::setIcon(const std::string& icon) { NSString* path = [[NSBundle mainBundle] pathForResource: - [NSString stringWithUTF8String: icon.getUTF8Data()] ofType:@"png"]; + [NSString stringWithUTF8String: icon.c_str()] ofType:@"png"]; NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; [statusItem setImage: image]; [image release]; @@ -39,13 +37,13 @@ void CocoaMenulet::clear() { } } -void CocoaMenulet::addItem(const Swift::String& name, const String& icon) { +void CocoaMenulet::addItem(const std::string& name, const std::string& icon) { NSMenuItem* item = [[NSMenuItem alloc] initWithTitle: - [NSString stringWithUTF8String: name.getUTF8Data()] + [NSString stringWithUTF8String: name.c_str()] action: NULL keyEquivalent: @""]; - if (!icon.isEmpty()) { + if (!icon.empty()) { NSString* path = [[NSBundle mainBundle] pathForResource: - [NSString stringWithUTF8String: icon.getUTF8Data()] ofType:@"png"]; + [NSString stringWithUTF8String: icon.c_str()] ofType:@"png"]; NSImage* image = [[NSImage alloc] initWithContentsOfFile: path]; [item setImage: [[NSImage alloc] initWithContentsOfFile: path]]; [image release]; diff --git a/Slimber/FileVCardCollection.cpp b/Slimber/FileVCardCollection.cpp index 6a8b6b1..9fab068 100644 --- a/Slimber/FileVCardCollection.cpp +++ b/Slimber/FileVCardCollection.cpp @@ -26,7 +26,7 @@ boost::shared_ptr<VCard> FileVCardCollection::getOwnVCard() const { VCardParser parser; PayloadParserTester tester(&parser); - tester.parse(String(data.getData(), data.getSize())); + tester.parse(std::string(data.getData(), data.getSize())); return boost::dynamic_pointer_cast<VCard>(parser.getPayload()); } else { diff --git a/Slimber/LinkLocalPresenceManager.cpp b/Slimber/LinkLocalPresenceManager.cpp index 465d849..edb7e91 100644 --- a/Slimber/LinkLocalPresenceManager.cpp +++ b/Slimber/LinkLocalPresenceManager.cpp @@ -70,19 +70,19 @@ RosterItemPayload LinkLocalPresenceManager::getRosterItem(const LinkLocalService return RosterItemPayload(service.getJID(), getRosterName(service), RosterItemPayload::Both); } -String LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const { +std::string LinkLocalPresenceManager::getRosterName(const LinkLocalService& service) const { LinkLocalServiceInfo info = service.getInfo(); - if (!info.getNick().isEmpty()) { + if (!info.getNick().empty()) { return info.getNick(); } - else if (!info.getFirstName().isEmpty()) { - String result = info.getFirstName(); - if (!info.getLastName().isEmpty()) { + else if (!info.getFirstName().empty()) { + std::string result = info.getFirstName(); + if (!info.getLastName().empty()) { result += " " + info.getLastName(); } return result; } - else if (!info.getLastName().isEmpty()) { + else if (!info.getLastName().empty()) { return info.getLastName(); } return ""; diff --git a/Slimber/LinkLocalPresenceManager.h b/Slimber/LinkLocalPresenceManager.h index 25069fa..26bb7ce 100644 --- a/Slimber/LinkLocalPresenceManager.h +++ b/Slimber/LinkLocalPresenceManager.h @@ -10,7 +10,7 @@ #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Elements/RosterItemPayload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -37,7 +37,7 @@ namespace Swift { void handleServiceRemoved(const LinkLocalService&); RosterItemPayload getRosterItem(const LinkLocalService& service) const; - String getRosterName(const LinkLocalService& service) const; + std::string getRosterName(const LinkLocalService& service) const; boost::shared_ptr<Presence> getPresence(const LinkLocalService& service) const; private: diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp index e6c2ab5..e39a660 100644 --- a/Slimber/MainController.cpp +++ b/Slimber/MainController.cpp @@ -86,9 +86,9 @@ void MainController::handleSelfConnected(bool b) { } void MainController::handleServicesChanged() { - std::vector<String> names; + std::vector<std::string> names; foreach(const LinkLocalService& service, linkLocalServiceBrowser->getServices()) { - String description = service.getDescription(); + std::string description = service.getDescription(); if (description != service.getName()) { description += " (" + service.getName() + ")"; } @@ -99,19 +99,19 @@ void MainController::handleServicesChanged() { void MainController::handleServerStopped(boost::optional<ServerError> error) { if (error) { - String message; + std::string message; switch (error->getType()) { case ServerError::C2SPortConflict: - message = String("Error: Port ") + boost::lexical_cast<std::string>(server->getClientToServerPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getClientToServerPort()) + std::string(" in use"); break; case ServerError::C2SError: - message = String("Local connection server error"); + message = std::string("Local connection server error"); break; case ServerError::LinkLocalPortConflict: - message = String("Error: Port ") + boost::lexical_cast<std::string>(server->getLinkLocalPort()) + String(" in use"); + message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getLinkLocalPort()) + std::string(" in use"); break; case ServerError::LinkLocalError: - message = String("External connection server error"); + message = std::string("External connection server error"); break; } menuletController->setXMPPStatus(message, MenuletController::Offline); diff --git a/Slimber/Menulet.h b/Slimber/Menulet.h index 6ecdcc5..df3c32c 100644 --- a/Slimber/Menulet.h +++ b/Slimber/Menulet.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/boost_bsignals.h" class Menulet { @@ -14,12 +14,12 @@ class Menulet { virtual ~Menulet(); virtual void clear() = 0; - virtual void addItem(const Swift::String& name, const Swift::String& icon = Swift::String()) = 0; + virtual void addItem(const std::string& name, const std::string& icon = std::string()) = 0; virtual void addAboutItem() = 0; virtual void addRestartItem() = 0; virtual void addExitItem() = 0; virtual void addSeparator() = 0; - virtual void setIcon(const Swift::String&) = 0; + virtual void setIcon(const std::string&) = 0; boost::signal<void ()> onRestartClicked; }; diff --git a/Slimber/MenuletController.cpp b/Slimber/MenuletController.cpp index 1155c81..351db21 100644 --- a/Slimber/MenuletController.cpp +++ b/Slimber/MenuletController.cpp @@ -7,13 +7,11 @@ #include "Slimber/MenuletController.h" #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include <string> #include "Slimber/Menulet.h" #include <iostream> -using namespace Swift; - MenuletController::MenuletController(Menulet* menulet) : menulet(menulet), xmppStatus(Offline) { menulet->onRestartClicked.connect(boost::ref(onRestartRequested)); @@ -23,13 +21,13 @@ MenuletController::MenuletController(Menulet* menulet) : MenuletController::~MenuletController() { } -void MenuletController::setXMPPStatus(const String& message, Status status) { +void MenuletController::setXMPPStatus(const std::string& message, Status status) { xmppStatus = status; xmppStatusMessage = message; update(); } -void MenuletController::setUserNames(const std::vector<String>& users) { +void MenuletController::setUserNames(const std::vector<std::string>& users) { linkLocalUsers = users; update(); } @@ -43,8 +41,8 @@ void MenuletController::update() { else { menulet->setIcon("UsersOnline"); menulet->addItem("Online users:"); - foreach(const String& user, linkLocalUsers) { - menulet->addItem(String(" ") + user); + foreach(const std::string& user, linkLocalUsers) { + menulet->addItem(std::string(" ") + user); } } menulet->addSeparator(); diff --git a/Slimber/MenuletController.h b/Slimber/MenuletController.h index 6b7f6fd..31b2d83 100644 --- a/Slimber/MenuletController.h +++ b/Slimber/MenuletController.h @@ -9,7 +9,7 @@ #include <vector> #include <boost/signal.hpp> -#include "Swiften/Base/String.h" +#include <string> class Menulet; @@ -23,8 +23,8 @@ class MenuletController { MenuletController(Menulet*); virtual ~MenuletController(); - void setXMPPStatus(const Swift::String& message, Status status); - void setUserNames(const std::vector<Swift::String>&); + void setXMPPStatus(const std::string& message, Status status); + void setUserNames(const std::vector<std::string>&); boost::signal<void ()> onRestartRequested; @@ -34,6 +34,6 @@ class MenuletController { private: Menulet* menulet; Status xmppStatus; - Swift::String xmppStatusMessage; - std::vector<Swift::String> linkLocalUsers; + std::string xmppStatusMessage; + std::vector<std::string> linkLocalUsers; }; diff --git a/Slimber/Qt/QtMenulet.h b/Slimber/Qt/QtMenulet.h index 08bae0c..01a9db1 100644 --- a/Slimber/Qt/QtMenulet.h +++ b/Slimber/Qt/QtMenulet.h @@ -30,8 +30,8 @@ class QtMenulet : public QObject, public Menulet { menu.clear(); } - void addItem(const Swift::String& name, const Swift::String& icon) { - menu.addAction(getIcon(icon), QString::fromUtf8(name.getUTF8Data())); + void addItem(const std::string& name, const std::string& icon) { + menu.addAction(getIcon(icon), QString::fromUtf8(name.c_str())); } void addAboutItem() { @@ -50,13 +50,13 @@ class QtMenulet : public QObject, public Menulet { menu.addSeparator(); } - void setIcon(const Swift::String& icon) { + void setIcon(const std::string& icon) { trayIcon.setIcon(getIcon(icon)); } private: - QPixmap getIcon(const Swift::String& name) { - return QPixmap(":/icons/" + QString::fromUtf8(name.getUTF8Data()) + ".png"); + QPixmap getIcon(const std::string& name) { + return QPixmap(":/icons/" + QString::fromUtf8(name.c_str()) + ".png"); } private slots: diff --git a/Slimber/Server.cpp b/Slimber/Server.cpp index b8cffb0..380ce6a 100644 --- a/Slimber/Server.cpp +++ b/Slimber/Server.cpp @@ -9,6 +9,7 @@ #include <string> #include <boost/bind.hpp> +#include "Swiften/Base/String.h" #include "Swiften/LinkLocal/LinkLocalConnector.h" #include "Swiften/Network/Connection.h" #include "Swiften/Session/SessionTracer.h" @@ -21,7 +22,7 @@ #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/VCard.h" #include "Swiften/Server/UserRegistry.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/LinkLocalServiceInfo.h" #include "Swiften/LinkLocal/OutgoingLinkLocalSession.h" #include "Swiften/LinkLocal/IncomingLinkLocalSession.h" @@ -397,19 +398,19 @@ void Server::handleLinkLocalConnectionServerStopped(boost::optional<BoostConnect LinkLocalServiceInfo Server::getLinkLocalServiceInfo(boost::shared_ptr<Presence> presence) { LinkLocalServiceInfo info; boost::shared_ptr<VCard> vcard = vCardCollection->getOwnVCard(); - if (!vcard->getFamilyName().isEmpty() || !vcard->getGivenName().isEmpty()) { + if (!vcard->getFamilyName().empty() || !vcard->getGivenName().empty()) { info.setFirstName(vcard->getGivenName()); info.setLastName(vcard->getFamilyName()); } - else if (!vcard->getFullName().isEmpty()) { - std::pair<String,String> p = vcard->getFullName().getSplittedAtFirst(' '); + else if (!vcard->getFullName().empty()) { + std::pair<std::string,std::string> p = String::getSplittedAtFirst(vcard->getFullName(), ' '); info.setFirstName(p.first); info.setLastName(p.second); } - if (!vcard->getNickname().isEmpty()) { + if (!vcard->getNickname().empty()) { info.setNick(vcard->getNickname()); } - if (!vcard->getPreferredEMailAddress().address.isEmpty()) { + if (!vcard->getPreferredEMailAddress().address.empty()) { info.setEMail(vcard->getPreferredEMailAddress().address); } info.setMessage(presence->getStatus()); diff --git a/Slimber/Server.h b/Slimber/Server.h index 039f351..98332fd 100644 --- a/Slimber/Server.h +++ b/Slimber/Server.h @@ -23,7 +23,7 @@ namespace Swift { class DNSSDServiceID; - class String; + class VCardCollection; class LinkLocalConnector; class LinkLocalServiceBrowser; @@ -87,7 +87,7 @@ namespace Swift { public: DummyUserRegistry() {} - virtual bool isValidUserPassword(const JID&, const String&) const { + virtual bool isValidUserPassword(const JID&, const std::string&) const { return true; } }; diff --git a/Slimber/ServerError.h b/Slimber/ServerError.h index ad09275..ec80f0a 100644 --- a/Slimber/ServerError.h +++ b/Slimber/ServerError.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ServerError { @@ -18,7 +18,7 @@ namespace Swift { LinkLocalError }; - ServerError(Type type, const String& message = String()) : + ServerError(Type type, const std::string& message = std::string()) : type(type), message(message) { } @@ -26,12 +26,12 @@ namespace Swift { return type; } - const String& getMessage() const { + const std::string& getMessage() const { return message; } private: Type type; - String message; + std::string message; }; } diff --git a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp index 8c6710a..47eb05c 100644 --- a/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp +++ b/Slimber/UnitTest/LinkLocalPresenceManagerTest.cpp @@ -71,7 +71,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(rosterChanges[0]->getItems().size())); boost::optional<RosterItemPayload> item = rosterChanges[0]->getItem(JID("alice@wonderland")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(presenceChanges.size())); CPPUNIT_ASSERT(StatusShow::Online == presenceChanges[0]->getShow()); @@ -101,7 +101,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(presenceChanges.size())); CPPUNIT_ASSERT(StatusShow::Away == presenceChanges[1]->getShow()); CPPUNIT_ASSERT(JID("alice@wonderland") == presenceChanges[1]->getFrom()); - CPPUNIT_ASSERT_EQUAL(String("I'm Away"), presenceChanges[1]->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("I'm Away"), presenceChanges[1]->getStatus()); } void testGetAllPresence() { @@ -131,11 +131,11 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { boost::optional<RosterItemPayload> item; item = roster->getItem(JID("alice@wonderland")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); item = roster->getItem(JID("rabbit@teaparty")); CPPUNIT_ASSERT(item); - CPPUNIT_ASSERT_EQUAL(String("Rabbit"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Rabbit"), item->getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::Both, item->getSubscription()); } @@ -145,7 +145,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "Alice", "Alice In", "Wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), item->getName()); } void testGetRoster_InfoWithFirstName() { @@ -154,7 +154,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "Alice In", ""); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice In"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In"), item->getName()); } void testGetRoster_InfoWithLastName() { @@ -163,7 +163,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "", "Wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Wonderland"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), item->getName()); } void testGetRoster_InfoWithFirstAndLastName() { @@ -172,7 +172,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland", "", "Alice In", "Wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), item->getName()); } void testGetRoster_NoInfo() { @@ -181,7 +181,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { addService("alice@wonderland"); boost::optional<RosterItemPayload> item = testling->getRoster()->getItem(JID("alice@wonderland")); - CPPUNIT_ASSERT_EQUAL(String(""), item->getName()); + CPPUNIT_ASSERT_EQUAL(std::string(""), item->getName()); } void testGetServiceForJID() { @@ -193,7 +193,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { boost::optional<LinkLocalService> service = testling->getServiceForJID(JID("rabbit@teaparty")); CPPUNIT_ASSERT(service); - CPPUNIT_ASSERT_EQUAL(String("rabbit@teaparty"), service->getID().getName()); + CPPUNIT_ASSERT_EQUAL(std::string("rabbit@teaparty"), service->getID().getName()); } void testGetServiceForJID_NoMatch() { @@ -216,7 +216,7 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { return testling; } - void addService(const String& name, const String& nickName = String(), const String& firstName = String(), const String& lastName = String()) { + void addService(const std::string& name, const std::string& nickName = std::string(), const std::string& firstName = std::string(), const std::string& lastName = std::string()) { DNSSDServiceID service(name, "local."); LinkLocalServiceInfo info; info.setFirstName(firstName); @@ -227,13 +227,13 @@ class LinkLocalPresenceManagerTest : public CppUnit::TestFixture { eventLoop->processEvents(); } - void removeService(const String& name) { + void removeService(const std::string& name) { DNSSDServiceID service(name, "local."); querier->removeService(DNSSDServiceID(name, "local.")); eventLoop->processEvents(); } - void updateServicePresence(const String& name, LinkLocalServiceInfo::Status status, const String& message) { + void updateServicePresence(const std::string& name, LinkLocalServiceInfo::Status status, const std::string& message) { DNSSDServiceID service(name, "local."); LinkLocalServiceInfo info; info.setStatus(status); diff --git a/Slimber/UnitTest/MenuletControllerTest.cpp b/Slimber/UnitTest/MenuletControllerTest.cpp index 9722125..092a886 100644 --- a/Slimber/UnitTest/MenuletControllerTest.cpp +++ b/Slimber/UnitTest/MenuletControllerTest.cpp @@ -10,8 +10,6 @@ #include "Slimber/Menulet.h" #include "Slimber/MenuletController.h" -using namespace Swift; - class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(MenuletControllerTest); CPPUNIT_TEST(testConstructor); @@ -36,14 +34,14 @@ class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size())); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Offline] "), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*About*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Restart*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Exit*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Offline] "), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]); } void testUpdate() { @@ -53,14 +51,14 @@ class MenuletControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(8, static_cast<int>(menulet->items.size())); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Online] You are connected"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*About*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Restart*"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("*Exit*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*About*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Restart*"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("*Exit*"), menulet->items[i++]); } void testSetXMPPStatus_Online() { @@ -69,9 +67,9 @@ class MenuletControllerTest : public CppUnit::TestFixture { testling.setXMPPStatus("You are connected", MenuletController::Online); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Online] You are connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Online] You are connected"), menulet->items[i++]); } @@ -81,35 +79,35 @@ class MenuletControllerTest : public CppUnit::TestFixture { testling.setXMPPStatus("You are not connected", MenuletController::Offline); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("[Offline] You are not connected"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("[Offline] You are not connected"), menulet->items[i++]); } void testSetUserNames() { MenuletController testling(menulet); - std::vector<String> users; + std::vector<std::string> users; users.push_back("Alice In Wonderland"); users.push_back("The Mad Hatter"); testling.setUserNames(users); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("Online users:"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String(" Alice In Wonderland"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String(" The Mad Hatter"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("Online users:"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string(" Alice In Wonderland"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string(" The Mad Hatter"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); } void testSetUserNames_NoUsers() { MenuletController testling(menulet); - std::vector<String> users; + std::vector<std::string> users; testling.setUserNames(users); int i = 0; - CPPUNIT_ASSERT_EQUAL(String("No online users"), menulet->items[i++]); - CPPUNIT_ASSERT_EQUAL(String("-"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("No online users"), menulet->items[i++]); + CPPUNIT_ASSERT_EQUAL(std::string("-"), menulet->items[i++]); } private: @@ -118,9 +116,9 @@ class MenuletControllerTest : public CppUnit::TestFixture { items.clear(); } - virtual void addItem(const String& name, const String& icon = String()) { - String result; - if (!icon.isEmpty()) { + virtual void addItem(const std::string& name, const std::string& icon = std::string()) { + std::string result; + if (!icon.empty()) { result += "[" + icon + "] "; } result += name; @@ -143,12 +141,12 @@ class MenuletControllerTest : public CppUnit::TestFixture { items.push_back("-"); } - virtual void setIcon(const String& i) { + virtual void setIcon(const std::string& i) { icon = i; } - std::vector<String> items; - String icon; + std::vector<std::string> items; + std::string icon; }; FakeMenulet* menulet; 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(¤tURL[0], currentURL.size()); + std::string url(¤tURL[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(¤tURL[0], currentURL.size()); + std::string url(¤tURL[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); diff --git a/Swift/Controllers/CertificateFileStorage.cpp b/Swift/Controllers/CertificateFileStorage.cpp index 65da1ec..4462556 100644 --- a/Swift/Controllers/CertificateFileStorage.cpp +++ b/Swift/Controllers/CertificateFileStorage.cpp @@ -55,7 +55,7 @@ void CertificateFileStorage::addCertificate(Certificate::ref certificate) { } boost::filesystem::path CertificateFileStorage::getCertificatePath(Certificate::ref certificate) const { - return path / Hexify::hexify(SHA1::getHash(certificate->toDER())).getUTF8String(); + return path / Hexify::hexify(SHA1::getHash(certificate->toDER())); } } diff --git a/Swift/Controllers/CertificateFileStorageFactory.h b/Swift/Controllers/CertificateFileStorageFactory.h index bcac56d..7ed8287 100644 --- a/Swift/Controllers/CertificateFileStorageFactory.h +++ b/Swift/Controllers/CertificateFileStorageFactory.h @@ -17,7 +17,7 @@ namespace Swift { CertificateFileStorageFactory(const boost::filesystem::path& basePath, CertificateFactory* certificateFactory) : basePath(basePath), certificateFactory(certificateFactory) {} virtual CertificateStorage* createCertificateStorage(const JID& profile) const { - boost::filesystem::path profilePath = basePath / profile.toString().getUTF8String(); + boost::filesystem::path profilePath = basePath / profile.toString(); return new CertificateFileStorage(profilePath / "certificates", certificateFactory); } diff --git a/Swift/Controllers/Chat/ChatController.cpp b/Swift/Controllers/Chat/ChatController.cpp index 3fffbb1..e4ad9c8 100644 --- a/Swift/Controllers/Chat/ChatController.cpp +++ b/Swift/Controllers/Chat/ChatController.cpp @@ -35,9 +35,9 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ chatStateTracker_->onChatStateChange.connect(boost::bind(&ChatWindow::setContactChatState, chatWindow_, _1)); stanzaChannel_->onStanzaAcked.connect(boost::bind(&ChatController::handleStanzaAcked, this, _1)); nickResolver_->onNickChanged.connect(boost::bind(&ChatController::handleContactNickChanged, this, _1, _2)); - String nick = nickResolver_->jidToNick(toJID_); + std::string nick = nickResolver_->jidToNick(toJID_); chatWindow_->setName(nick); - String startMessage("Starting chat with " + nick); + std::string startMessage("Starting chat with " + nick); Presence::ref theirPresence; if (isInMUC) { startMessage += " in chatroom " + contact.toBare().toString(); @@ -47,7 +47,7 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ theirPresence = contact.isBare() ? presenceOracle->getHighestPriorityPresence(contact.toBare()) : presenceOracle->getLastPresence(contact); } startMessage += ": " + StatusShow::typeToFriendlyName(theirPresence ? theirPresence->getShow() : StatusShow::None); - if (theirPresence && !theirPresence->getStatus().isEmpty()) { + if (theirPresence && !theirPresence->getStatus().empty()) { startMessage += " (" + theirPresence->getStatus() + ")"; } lastShownStatus_ = theirPresence ? theirPresence->getShow() : StatusShow::None; @@ -59,7 +59,7 @@ ChatController::ChatController(const JID& self, StanzaChannel* stanzaChannel, IQ } -void ChatController::handleContactNickChanged(const JID& jid, const String& /*oldNick*/) { +void ChatController::handleContactNickChanged(const JID& jid, const std::string& /*oldNick*/) { if (jid.toBare() == toJID_.toBare()) { chatWindow_->setName(nickResolver_->jidToNick(jid)); } @@ -108,8 +108,8 @@ void ChatController::preSendMessageRequest(boost::shared_ptr<Message> message) { chatStateNotifier_->addChatStateRequest(message); } -void ChatController::postSendMessage(const String& body, boost::shared_ptr<Stanza> sentStanza) { - String id = addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional<SecurityLabel>(), String(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); +void ChatController::postSendMessage(const std::string& body, boost::shared_ptr<Stanza> sentStanza) { + std::string id = addMessage(body, "me", true, labelsEnabled_ ? chatWindow_->getSelectedSecurityLabel() : boost::optional<SecurityLabel>(), std::string(avatarManager_->getAvatarPath(selfJID_).string()), boost::posix_time::microsec_clock::universal_time()); if (stanzaChannel_->getStreamManagementEnabled()) { chatWindow_->setAckState(id, ChatWindow::Pending); unackedStanzas_[sentStanza] = id; @@ -119,7 +119,7 @@ void ChatController::postSendMessage(const String& body, boost::shared_ptr<Stanz } void ChatController::handleStanzaAcked(boost::shared_ptr<Stanza> stanza) { - String id = unackedStanzas_[stanza]; + std::string id = unackedStanzas_[stanza]; if (id != "") { chatWindow_->setAckState(id, ChatWindow::Received); } @@ -128,7 +128,7 @@ void ChatController::handleStanzaAcked(boost::shared_ptr<Stanza> stanza) { void ChatController::setOnline(bool online) { if (!online) { - std::map<boost::shared_ptr<Stanza>, String>::iterator it = unackedStanzas_.begin(); + std::map<boost::shared_ptr<Stanza>, std::string>::iterator it = unackedStanzas_.begin(); for ( ; it != unackedStanzas_.end(); it++) { chatWindow_->setAckState(it->second, ChatWindow::Failed); } @@ -142,13 +142,13 @@ void ChatController::setOnline(bool online) { ChatControllerBase::setOnline(online); } -String ChatController::senderDisplayNameFromMessage(const JID& from) { +std::string ChatController::senderDisplayNameFromMessage(const JID& from) { return nickResolver_->jidToNick(from); } -String ChatController::getStatusChangeString(boost::shared_ptr<Presence> presence) { - String nick = senderDisplayNameFromMessage(presence->getFrom()); - String response = nick; +std::string ChatController::getStatusChangeString(boost::shared_ptr<Presence> presence) { + std::string nick = senderDisplayNameFromMessage(presence->getFrom()); + std::string response = nick; if (!presence || presence->getType() == Presence::Unavailable || presence->getType() == Presence::Error) { response += " has gone offline"; } else if (presence->getType() == Presence::Available) { @@ -161,7 +161,7 @@ String ChatController::getStatusChangeString(boost::shared_ptr<Presence> presenc response += " is now busy"; } } - if (!presence->getStatus().isEmpty()) { + if (!presence->getStatus().empty()) { response += " (" + presence->getStatus() + ")"; } return response + "."; @@ -188,7 +188,7 @@ void ChatController::handlePresenceChange(boost::shared_ptr<Presence> newPresenc chatStateTracker_->handlePresenceChange(newPresence); chatStateNotifier_->setContactIsOnline(newPresence->getType() == Presence::Available); - String newStatusChangeString = getStatusChangeString(newPresence); + std::string newStatusChangeString = getStatusChangeString(newPresence); if (newStatusChangeString != lastStatusChangeString_) { if (lastWasPresence_) { chatWindow_->replaceLastMessage(newStatusChangeString); diff --git a/Swift/Controllers/Chat/ChatController.h b/Swift/Controllers/Chat/ChatController.h index c013387..b8ac1cd 100644 --- a/Swift/Controllers/Chat/ChatController.h +++ b/Swift/Controllers/Chat/ChatController.h @@ -24,16 +24,16 @@ namespace Swift { private: void handlePresenceChange(boost::shared_ptr<Presence> newPresence); - String getStatusChangeString(boost::shared_ptr<Presence> presence); + std::string getStatusChangeString(boost::shared_ptr<Presence> presence); bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); - void postSendMessage(const String &body, boost::shared_ptr<Stanza> sentStanza); + void postSendMessage(const std::string &body, boost::shared_ptr<Stanza> sentStanza); void preHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent); void preSendMessageRequest(boost::shared_ptr<Message>); - String senderDisplayNameFromMessage(const JID& from); + std::string senderDisplayNameFromMessage(const JID& from); virtual boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message>) const; void handleStanzaAcked(boost::shared_ptr<Stanza> stanza); void dayTicked() {lastWasPresence_ = false;} - void handleContactNickChanged(const JID& jid, const String& /*oldNick*/); + void handleContactNickChanged(const JID& jid, const std::string& /*oldNick*/); private: NickResolver* nickResolver_; @@ -41,8 +41,8 @@ namespace Swift { ChatStateTracker* chatStateTracker_; bool isInMUC_; bool lastWasPresence_; - String lastStatusChangeString_; - std::map<boost::shared_ptr<Stanza>, String> unackedStanzas_; + std::string lastStatusChangeString_; + std::map<boost::shared_ptr<Stanza>, std::string> unackedStanzas_; StatusShow::Type lastShownStatus_; }; } diff --git a/Swift/Controllers/Chat/ChatControllerBase.cpp b/Swift/Controllers/Chat/ChatControllerBase.cpp index ca0916d..f70ec81 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.cpp +++ b/Swift/Controllers/Chat/ChatControllerBase.cpp @@ -11,7 +11,9 @@ #include <boost/bind.hpp> #include <boost/shared_ptr.hpp> #include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/algorithm/string.hpp> +#include "Swiften/Base/String.h" #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Elements/Delay.h" #include "Swiften/Base/foreach.h" @@ -49,7 +51,7 @@ void ChatControllerBase::createDayChangeTimer() { void ChatControllerBase::handleDayChangeTick() { dateChangeTimer_->stop(); boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); - chatWindow_->addSystemMessage("The day is now " + String(boost::posix_time::to_iso_extended_string(now)).getSubstring(0,10)); + chatWindow_->addSystemMessage("The day is now " + std::string(boost::posix_time::to_iso_extended_string(now)).substr(0,10)); dayTicked(); createDayChangeTimer(); } @@ -84,8 +86,8 @@ void ChatControllerBase::handleAllMessagesRead() { chatWindow_->setUnreadMessageCount(0); } -void ChatControllerBase::handleSendMessageRequest(const String &body) { - if (!stanzaChannel_->isAvailable() || body.isEmpty()) { +void ChatControllerBase::handleSendMessageRequest(const std::string &body) { + if (!stanzaChannel_->isAvailable() || body.empty()) { return; } boost::shared_ptr<Message> message(new Message()); @@ -130,9 +132,9 @@ void ChatControllerBase::activateChatWindow() { chatWindow_->activate(); } -String ChatControllerBase::addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) { - if (message.beginsWith("/me ")) { - return chatWindow_->addAction(message.getSplittedAtFirst(' ').second, senderName, senderIsSelf, label, avatarPath, time); +std::string ChatControllerBase::addMessage(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { + if (boost::starts_with(message, "/me ")) { + return chatWindow_->addAction(String::getSplittedAtFirst(message, ' ').second, senderName, senderIsSelf, label, avatarPath, time); } else { return chatWindow_->addMessage(message, senderName, senderIsSelf, label, avatarPath, time); } @@ -148,9 +150,9 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m unreadMessages_.push_back(messageEvent); } boost::shared_ptr<Message> message = messageEvent->getStanza(); - String body = message->getBody(); + std::string body = message->getBody(); if (message->isError()) { - String errorMessage = getErrorMessage(message->getPayload<ErrorPayload>()); + std::string errorMessage = getErrorMessage(message->getPayload<ErrorPayload>()); chatWindow_->addErrorMessage(errorMessage); } else { @@ -167,7 +169,7 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m boost::posix_time::ptime now = boost::posix_time::microsec_clock::universal_time(); std::ostringstream s; s << "The following message took " << (now - delayPayloads[i]->getStamp()).total_milliseconds() / 1000.0 << " seconds to be delivered from " << delayPayloads[i]->getFrom()->toString() << "."; - chatWindow_->addSystemMessage(String(s.str())); + chatWindow_->addSystemMessage(std::string(s.str())); } boost::shared_ptr<SecurityLabel> label = message->getPayload<SecurityLabel>(); boost::optional<SecurityLabel> maybeLabel = label ? boost::optional<SecurityLabel>(*label) : boost::optional<SecurityLabel>(); @@ -179,15 +181,15 @@ void ChatControllerBase::handleIncomingMessage(boost::shared_ptr<MessageEvent> m timeStamp = *messageTimeStamp; } - addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), maybeLabel, String(avatarManager_->getAvatarPath(from).string()), timeStamp); + addMessage(body, senderDisplayNameFromMessage(from), isIncomingMessageFromMe(message), maybeLabel, std::string(avatarManager_->getAvatarPath(from).string()), timeStamp); } chatWindow_->show(); chatWindow_->setUnreadMessageCount(unreadMessages_.size()); } -String ChatControllerBase::getErrorMessage(boost::shared_ptr<ErrorPayload> error) { - String defaultMessage = "Error sending message"; - if (!error->getText().isEmpty()) { +std::string ChatControllerBase::getErrorMessage(boost::shared_ptr<ErrorPayload> error) { + std::string defaultMessage = "Error sending message"; + if (!error->getText().empty()) { return error->getText(); } else { diff --git a/Swift/Controllers/Chat/ChatControllerBase.h b/Swift/Controllers/Chat/ChatControllerBase.h index e1e5e62..4a1f8e0 100644 --- a/Swift/Controllers/Chat/ChatControllerBase.h +++ b/Swift/Controllers/Chat/ChatControllerBase.h @@ -18,7 +18,7 @@ #include "Swiften/Network/Timer.h" #include "Swiften/Network/TimerFactory.h" #include "Swiften/Elements/Stanza.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/DiscoInfo.h" #include "Swift/Controllers/XMPPEvents/MessageEvent.h" #include "Swiften/JID/JID.h" @@ -43,7 +43,7 @@ namespace Swift { void activateChatWindow(); void setAvailableServerFeatures(boost::shared_ptr<DiscoInfo> info); void handleIncomingMessage(boost::shared_ptr<MessageEvent> message); - String addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time); + std::string addMessage(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time); virtual void setOnline(bool online); virtual void setEnabled(bool enabled); virtual void setToJID(const JID& jid) {toJID_ = jid;}; @@ -53,8 +53,8 @@ namespace Swift { /** * Pass the Message appended, and the stanza used to send it. */ - virtual void postSendMessage(const String&, boost::shared_ptr<Stanza>) {}; - virtual String senderDisplayNameFromMessage(const JID& from) = 0; + virtual void postSendMessage(const std::string&, boost::shared_ptr<Stanza>) {}; + virtual std::string senderDisplayNameFromMessage(const JID& from) = 0; virtual bool isIncomingMessageFromMe(boost::shared_ptr<Message>) = 0; virtual void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>) {}; virtual void preSendMessageRequest(boost::shared_ptr<Message>) {}; @@ -64,10 +64,10 @@ namespace Swift { private: void createDayChangeTimer(); - void handleSendMessageRequest(const String &body); + void handleSendMessageRequest(const std::string &body); void handleAllMessagesRead(); void handleSecurityLabelsCatalogResponse(boost::shared_ptr<SecurityLabelsCatalog>, ErrorPayload::ref error); - String getErrorMessage(boost::shared_ptr<ErrorPayload>); + std::string getErrorMessage(boost::shared_ptr<ErrorPayload>); void handleDayChangeTick(); protected: diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp index b7e8432..94d4b9a 100644 --- a/Swift/Controllers/Chat/ChatsManager.cpp +++ b/Swift/Controllers/Chat/ChatsManager.cpp @@ -221,7 +221,7 @@ void ChatsManager::setOnline(bool enabled) { } -void ChatsManager::handleChatRequest(const String &contact) { +void ChatsManager::handleChatRequest(const std::string &contact) { ChatController* controller = getChatControllerOrFindAnother(JID(contact)); controller->activateChatWindow(); } @@ -280,7 +280,7 @@ void ChatsManager::rebindControllerJID(const JID& from, const JID& to) { chatControllers_[to]->setToJID(to); } -void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional<String>& nickMaybe, bool autoJoin) { +void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional<std::string>& nickMaybe, bool autoJoin) { if (autoJoin) { MUCBookmark bookmark(mucJID, mucJID.getNode()); bookmark.setAutojoin(true); @@ -294,7 +294,7 @@ void ChatsManager::handleJoinMUCRequest(const JID &mucJID, const boost::optional if (it != mucControllers_.end()) { it->second->rejoin(); } else { - String nick = nickMaybe ? nickMaybe.get() : jid_.getNode(); + std::string nick = nickMaybe ? nickMaybe.get() : jid_.getNode(); MUC::ref muc = mucManager->createMUC(mucJID); MUCController* controller = new MUCController(jid_, muc, nick, stanzaChannel_, iqRouter_, chatWindowFactory_, presenceOracle_, avatarManager_, uiEventStream_, false, timerFactory_, eventController_); mucControllers_[mucJID] = controller; @@ -311,7 +311,7 @@ void ChatsManager::handleSearchMUCRequest() { void ChatsManager::handleIncomingMessage(boost::shared_ptr<Message> message) { JID jid = message->getFrom(); boost::shared_ptr<MessageEvent> event(new MessageEvent(message)); - if (!event->isReadable() && !message->getPayload<ChatState>() && message->getSubject().isEmpty()) { + if (!event->isReadable() && !message->getPayload<ChatState>() && message->getSubject().empty()) { return; } diff --git a/Swift/Controllers/Chat/ChatsManager.h b/Swift/Controllers/Chat/ChatsManager.h index 62b14d9..3740186 100644 --- a/Swift/Controllers/Chat/ChatsManager.h +++ b/Swift/Controllers/Chat/ChatsManager.h @@ -10,7 +10,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/DiscoInfo.h" #include "Swiften/Elements/Message.h" #include "Swiften/Elements/Presence.h" @@ -52,8 +52,8 @@ namespace Swift { void setServerDiscoInfo(boost::shared_ptr<DiscoInfo> info); void handleIncomingMessage(boost::shared_ptr<Message> message); private: - void handleChatRequest(const String& contact); - void handleJoinMUCRequest(const JID& muc, const boost::optional<String>& nick, bool autoJoin); + void handleChatRequest(const std::string& contact); + void handleJoinMUCRequest(const JID& muc, const boost::optional<std::string>& nick, bool autoJoin); void handleSearchMUCRequest(); void handleMUCSelectedAfterSearch(const JID&); void rebindControllerJID(const JID& from, const JID& to); diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp index 0ed2b35..765c49d 100644 --- a/Swift/Controllers/Chat/MUCController.cpp +++ b/Swift/Controllers/Chat/MUCController.cpp @@ -8,6 +8,7 @@ #include <boost/bind.hpp> #include <boost/regex.hpp> +#include <boost/algorithm/string.hpp> #include "Swiften/Network/Timer.h" #include "Swiften/Network/TimerFactory.h" @@ -38,7 +39,7 @@ namespace Swift { MUCController::MUCController ( const JID& self, MUC::ref muc, - const String &nick, + const std::string &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, @@ -119,8 +120,8 @@ void MUCController::receivedActivity() { void MUCController::handleJoinFailed(boost::shared_ptr<ErrorPayload> error) { receivedActivity(); - String errorMessage = "Unable to join this room"; - String rejoinNick; + std::string errorMessage = "Unable to join this room"; + std::string rejoinNick; if (error) { switch (error->getCondition()) { case ErrorPayload::Conflict: rejoinNick = nick_ + "_"; errorMessage += " as " + nick_ + ", retrying as " + rejoinNick; break; @@ -136,17 +137,17 @@ void MUCController::handleJoinFailed(boost::shared_ptr<ErrorPayload> error) { } errorMessage += "."; chatWindow_->addErrorMessage(errorMessage); - if (!rejoinNick.isEmpty()) { + if (!rejoinNick.empty()) { nick_ = rejoinNick; parting_ = true; rejoin(); } } -void MUCController::handleJoinComplete(const String& nick) { +void MUCController::handleJoinComplete(const std::string& nick) { receivedActivity(); joined_ = true; - String joinMessage = "You have joined room " + toJID_.toString() + " as " + nick; + std::string joinMessage = "You have joined room " + toJID_.toString() + " as " + nick; nick_ = nick; chatWindow_->addSystemMessage(joinMessage); clearPresenceQueue(); @@ -158,7 +159,7 @@ void MUCController::handleAvatarChanged(const JID& jid) { if (parting_ || !jid.equals(toJID_, JID::WithoutResource)) { return; } - String path = avatarManager_->getAvatarPath(jid).string(); + std::string path = avatarManager_->getAvatarPath(jid).string(); roster_->applyOnItems(SetAvatar(jid, path, JID::WithResource)); } @@ -184,7 +185,7 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { appendToJoinParts(joinParts_, event); roster_->addContact(jid, realJID, occupant.getNick(), roleToGroupName(occupant.getRole()), avatarManager_->getAvatarPath(jid).string()); if (joined_) { - String joinString = occupant.getNick() + " has joined the room"; + std::string joinString = occupant.getNick() + " has joined the room"; MUCOccupant::Role role = occupant.getRole(); if (role != MUCOccupant::NoRole && role != MUCOccupant::Participant) { joinString += " as a " + roleToFriendlyName(role); @@ -203,7 +204,7 @@ void MUCController::handleOccupantJoined(const MUCOccupant& occupant) { } } -void MUCController::addPresenceMessage(const String& message) { +void MUCController::addPresenceMessage(const std::string& message) { lastWasPresence_ = true; chatWindow_->addPresenceMessage(message); } @@ -213,7 +214,7 @@ void MUCController::clearPresenceQueue() { joinParts_.clear(); } -String MUCController::roleToFriendlyName(MUCOccupant::Role role) { +std::string MUCController::roleToFriendlyName(MUCOccupant::Role role) { switch (role) { case MUCOccupant::Moderator: return "moderator"; case MUCOccupant::Participant: return "participant"; @@ -223,14 +224,14 @@ String MUCController::roleToFriendlyName(MUCOccupant::Role role) { return ""; } -JID MUCController::nickToJID(const String& nick) { +JID MUCController::nickToJID(const std::string& nick) { return JID(toJID_.getNode(), toJID_.getDomain(), nick); } bool MUCController::messageTargetsMe(boost::shared_ptr<Message> message) { - String stringRegexp(".*\\b" + nick_.getLowerCase() + "\\b.*"); - boost::regex myRegexp(stringRegexp.getUTF8String()); - return boost::regex_match(message->getBody().getLowerCase().getUTF8String(), myRegexp); + std::string stringRegexp(".*\\b" + boost::to_lower_copy(nick_) + "\\b.*"); + boost::regex myRegexp(stringRegexp); + return boost::regex_match(boost::to_lower_copy(message->getBody()), myRegexp); } void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> messageEvent) { @@ -246,7 +247,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes } } if (joined_) { - String nick = message->getFrom().getResource(); + std::string nick = message->getFrom().getResource(); if (nick != nick_ && currentOccupants_.find(nick) != currentOccupants_.end()) { completer_->addWord(nick); } @@ -255,7 +256,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes receivedActivity(); joined_ = true; - if (!message->getSubject().isEmpty() && message->getBody().isEmpty()) { + if (!message->getSubject().empty() && message->getBody().empty()) { chatWindow_->addSystemMessage("The room subject is now: " + message->getSubject()); doneGettingHistory_ = true; } @@ -269,7 +270,7 @@ void MUCController::preHandleIncomingMessage(boost::shared_ptr<MessageEvent> mes } } -void MUCController::handleOccupantRoleChanged(const String& nick, const MUCOccupant& occupant, const MUCOccupant::Role& oldRole) { +void MUCController::handleOccupantRoleChanged(const std::string& nick, const MUCOccupant& occupant, const MUCOccupant::Role& oldRole) { clearPresenceQueue(); receivedActivity(); JID jid(nickToJID(nick)); @@ -282,8 +283,8 @@ void MUCController::handleOccupantRoleChanged(const String& nick, const MUCOccup chatWindow_->addSystemMessage(nick + " is now a " + roleToFriendlyName(occupant.getRole())); } -String MUCController::roleToGroupName(MUCOccupant::Role role) { - String result; +std::string MUCController::roleToGroupName(MUCOccupant::Role role) { + std::string result; switch (role) { case MUCOccupant::Moderator: result = "Moderators"; break; case MUCOccupant::Participant: result = "Participants"; break; @@ -326,13 +327,13 @@ bool MUCController::shouldUpdateJoinParts() { return lastWasPresence_; } -void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType, const String& reason) { +void MUCController::handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType, const std::string& reason) { NickJoinPart event(occupant.getNick(), Part); appendToJoinParts(joinParts_, event); currentOccupants_.erase(occupant.getNick()); completer_->removeWord(occupant.getNick()); - String partMessage = (occupant.getNick() != nick_) ? occupant.getNick() + " has left the room" : "You have left the room"; - if (!reason.isEmpty()) { + std::string partMessage = (occupant.getNick() != nick_) ? occupant.getNick() + " has left the room" : "You have left the room"; + if (!reason.empty()) { partMessage += " (" + reason + ")"; } partMessage += "."; @@ -361,7 +362,7 @@ bool MUCController::isIncomingMessageFromMe(boost::shared_ptr<Message> message) return nick_ == from.getResource(); } -String MUCController::senderDisplayNameFromMessage(const JID& from) { +std::string MUCController::senderDisplayNameFromMessage(const JID& from) { return from.getResource(); } @@ -398,8 +399,8 @@ void MUCController::appendToJoinParts(std::vector<NickJoinPart>& joinParts, cons } } -String MUCController::concatenateListOfNames(const std::vector<NickJoinPart>& joinParts) { - String result; +std::string MUCController::concatenateListOfNames(const std::vector<NickJoinPart>& joinParts) { + std::string result; for (size_t i = 0; i < joinParts.size(); i++) { if (i > 0) { if (i < joinParts.size() - 1) { @@ -414,18 +415,18 @@ String MUCController::concatenateListOfNames(const std::vector<NickJoinPart>& jo return result; } -String MUCController::generateJoinPartString(const std::vector<NickJoinPart>& joinParts) { +std::string MUCController::generateJoinPartString(const std::vector<NickJoinPart>& joinParts) { std::vector<NickJoinPart> sorted[4]; - String eventStrings[4]; + std::string eventStrings[4]; foreach (NickJoinPart event, joinParts) { sorted[event.type].push_back(event); } - String result; + std::string result; std::vector<JoinPart> populatedEvents; for (size_t i = 0; i < 4; i++) { - String eventString = concatenateListOfNames(sorted[i]); - if (!eventString.isEmpty()) { - String haveHas = sorted[i].size() > 1 ? " have" : " has"; + std::string eventString = concatenateListOfNames(sorted[i]); + if (!eventString.empty()) { + std::string haveHas = sorted[i].size() > 1 ? " have" : " has"; switch (i) { case Join: eventString += haveHas + " joined";break; case Part: eventString += haveHas + " left";break; diff --git a/Swift/Controllers/Chat/MUCController.h b/Swift/Controllers/Chat/MUCController.h index 258b730..30f7aa5 100644 --- a/Swift/Controllers/Chat/MUCController.h +++ b/Swift/Controllers/Chat/MUCController.h @@ -11,7 +11,7 @@ #include <boost/signals/connection.hpp> #include <set> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Network/Timer.h" #include "Swift/Controllers/Chat/ChatControllerBase.h" #include "Swiften/Elements/Message.h" @@ -34,44 +34,44 @@ namespace Swift { enum JoinPart {Join, Part, JoinThenPart, PartThenJoin}; struct NickJoinPart { - NickJoinPart(const String& nick, JoinPart type) : nick(nick), type(type) {}; - String nick; + NickJoinPart(const std::string& nick, JoinPart type) : nick(nick), type(type) {}; + std::string nick; JoinPart type; }; class MUCController : public ChatControllerBase { public: - MUCController(const JID& self, MUC::ref muc, const String &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, PresenceOracle* presenceOracle, AvatarManager* avatarManager, UIEventStream* events, bool useDelayForLatency, TimerFactory* timerFactory, EventController* eventController); + MUCController(const JID& self, MUC::ref muc, const std::string &nick, StanzaChannel* stanzaChannel, IQRouter* iqRouter, ChatWindowFactory* chatWindowFactory, PresenceOracle* presenceOracle, AvatarManager* avatarManager, UIEventStream* events, bool useDelayForLatency, TimerFactory* timerFactory, EventController* eventController); ~MUCController(); boost::signal<void ()> onUserLeft; virtual void setOnline(bool online); void rejoin(); static void appendToJoinParts(std::vector<NickJoinPart>& joinParts, const NickJoinPart& newEvent); - static String generateJoinPartString(const std::vector<NickJoinPart>& joinParts); - static String concatenateListOfNames(const std::vector<NickJoinPart>& joinParts); + static std::string generateJoinPartString(const std::vector<NickJoinPart>& joinParts); + static std::string concatenateListOfNames(const std::vector<NickJoinPart>& joinParts); protected: void preSendMessageRequest(boost::shared_ptr<Message> message); bool isIncomingMessageFromMe(boost::shared_ptr<Message> message); - String senderDisplayNameFromMessage(const JID& from); + std::string senderDisplayNameFromMessage(const JID& from); boost::optional<boost::posix_time::ptime> getMessageTimestamp(boost::shared_ptr<Message> message) const; void preHandleIncomingMessage(boost::shared_ptr<MessageEvent>); private: void clearPresenceQueue(); - void addPresenceMessage(const String& message); + void addPresenceMessage(const std::string& message); void handleWindowClosed(); void handleAvatarChanged(const JID& jid); void handleOccupantJoined(const MUCOccupant& occupant); - void handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType type, const String& reason); + void handleOccupantLeft(const MUCOccupant& occupant, MUC::LeavingType type, const std::string& reason); void handleOccupantPresenceChange(boost::shared_ptr<Presence> presence); - void handleOccupantRoleChanged(const String& nick, const MUCOccupant& occupant,const MUCOccupant::Role& oldRole); - void handleJoinComplete(const String& nick); + void handleOccupantRoleChanged(const std::string& nick, const MUCOccupant& occupant,const MUCOccupant::Role& oldRole); + void handleJoinComplete(const std::string& nick); void handleJoinFailed(boost::shared_ptr<ErrorPayload> error); void handleJoinTimeoutTick(); - String roleToGroupName(MUCOccupant::Role role); - JID nickToJID(const String& nick); - String roleToFriendlyName(MUCOccupant::Role role); + std::string roleToGroupName(MUCOccupant::Role role); + JID nickToJID(const std::string& nick); + std::string roleToFriendlyName(MUCOccupant::Role role); void receivedActivity(); bool messageTargetsMe(boost::shared_ptr<Message> message); void updateJoinParts(); @@ -82,8 +82,8 @@ namespace Swift { private: MUC::ref muc_; UIEventStream* events_; - String nick_; - String desiredNick_; + std::string nick_; + std::string desiredNick_; Roster* roster_; TabComplete* completer_; bool parting_; @@ -93,7 +93,7 @@ namespace Swift { bool doneGettingHistory_; boost::bsignals::scoped_connection avatarChangedConnection_; boost::shared_ptr<Timer> loginCheckTimer_; - std::set<String> currentOccupants_; + std::set<std::string> currentOccupants_; std::vector<NickJoinPart> joinParts_; boost::posix_time::ptime lastActivity_; }; diff --git a/Swift/Controllers/Chat/MUCSearchController.cpp b/Swift/Controllers/Chat/MUCSearchController.cpp index 2b25e2a..743aabb 100644 --- a/Swift/Controllers/Chat/MUCSearchController.cpp +++ b/Swift/Controllers/Chat/MUCSearchController.cpp @@ -13,6 +13,7 @@ #include <Swiften/Disco/GetDiscoItemsRequest.h> #include <Swiften/Base/Log.h> +#include <Swiften/Base/String.h> #include <Swift/Controllers/UIEvents/UIEventStream.h> #include <Swift/Controllers/UIInterfaces/MUCSearchWindowFactory.h> #include <Swift/Controllers/DiscoServiceWalker.h> @@ -20,7 +21,7 @@ namespace Swift { -static const String SEARCHED_SERVICES = "searchedServices"; +static const std::string SEARCHED_SERVICES = "searchedServices"; MUCSearchController::MUCSearchController(const JID& jid, MUCSearchWindowFactory* factory, IQRouter* iqRouter, SettingsProvider* settings) : jid_(jid), factory_(factory), iqRouter_(iqRouter), settings_(settings), window_(NULL), walker_(NULL) { itemsInProgress_ = 0; @@ -45,7 +46,7 @@ void MUCSearchController::openSearchWindow() { void MUCSearchController::loadSavedServices() { savedServices_.clear(); - foreach (String stringItem, settings_->getStringSetting(SEARCHED_SERVICES).split('\n')) { + foreach (std::string stringItem, String::split(settings_->getStringSetting(SEARCHED_SERVICES), '\n')) { savedServices_.push_back(JID(stringItem)); } } @@ -54,13 +55,13 @@ void MUCSearchController::addToSavedServices(const JID& jid) { savedServices_.erase(std::remove(savedServices_.begin(), savedServices_.end(), jid), savedServices_.end()); savedServices_.push_front(jid); - String collapsed; + std::string collapsed; int i = 0; foreach (JID jidItem, savedServices_) { if (i >= 15) { break; } - if (!collapsed.isEmpty()) { + if (!collapsed.empty()) { collapsed += "\n"; } collapsed += jidItem.toString(); @@ -100,7 +101,7 @@ void MUCSearchController::handleSearchService(const JID& jid) { void MUCSearchController::handleDiscoServiceFound(const JID& jid, boost::shared_ptr<DiscoInfo> info) { bool isMUC = false; - String name; + std::string name; foreach (DiscoInfo::Identity identity, info->getIdentities()) { if ((identity.getCategory() == "directory" && identity.getType() == "chatroom") diff --git a/Swift/Controllers/Chat/MUCSearchController.h b/Swift/Controllers/Chat/MUCSearchController.h index 6d3afd1..b348886 100644 --- a/Swift/Controllers/Chat/MUCSearchController.h +++ b/Swift/Controllers/Chat/MUCSearchController.h @@ -12,7 +12,7 @@ #include <boost/shared_ptr.hpp> #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swift/Controllers/UIEvents/UIEvent.h" @@ -34,13 +34,13 @@ namespace Swift { public: class MUCRoom { public: - MUCRoom(const String& node, const String& name, int occupants) : node_(node), name_(name), occupants_(occupants) {} - String getNode() {return node_;} - String getName() {return name_;} + MUCRoom(const std::string& node, const std::string& name, int occupants) : node_(node), name_(name), occupants_(occupants) {} + std::string getNode() {return node_;} + std::string getName() {return name_;} int getOccupantCount() {return occupants_;} private: - String node_; - String name_; + std::string node_; + std::string name_; int occupants_; }; @@ -50,7 +50,7 @@ namespace Swift { complete_ = complete; } - void setName(const String& name) { + void setName(const std::string& name) { name_ = name; } @@ -66,11 +66,11 @@ namespace Swift { return jid_; } - String getName() const { + std::string getName() const { return name_; } - void setError(const String& errorText) {error_ = true; errorText_ = errorText;} + void setError(const std::string& errorText) {error_ = true; errorText_ = errorText;} void clearRooms() {rooms_.clear();} @@ -78,12 +78,12 @@ namespace Swift { std::vector<MUCRoom> getRooms() const {return rooms_;} private: - String name_; + std::string name_; JID jid_; std::vector<MUCRoom> rooms_; bool complete_; bool error_; - String errorText_; + std::string errorText_; }; class MUCSearchController { diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp index 4d6ca08..40f7445 100644 --- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp @@ -43,7 +43,7 @@ using namespace Swift; class DummyCapsProvider : public CapsProvider { - DiscoInfo::ref getCaps(const String&) const {return DiscoInfo::ref(new DiscoInfo());} + DiscoInfo::ref getCaps(const std::string&) const {return DiscoInfo::ref(new DiscoInfo());} }; class ChatsManagerTest : public CppUnit::TestFixture { @@ -119,7 +119,7 @@ public: boost::shared_ptr<Message> message(new Message()); message->setFrom(messageJID); - String body("This is a legible message. >HEH@)oeueu"); + std::string body("This is a legible message. >HEH@)oeueu"); message->setBody(body); manager_->handleIncomingMessage(message); CPPUNIT_ASSERT_EQUAL(body, window->lastMessageBody_); @@ -133,7 +133,7 @@ public: boost::shared_ptr<Message> message1(new Message()); message1->setFrom(messageJID1); - String body1("This is a legible message. >HEH@)oeueu"); + std::string body1("This is a legible message. >HEH@)oeueu"); message1->setBody(body1); manager_->handleIncomingMessage(message1); CPPUNIT_ASSERT_EQUAL(body1, window1->lastMessageBody_); @@ -145,14 +145,14 @@ public: boost::shared_ptr<Message> message2(new Message()); message2->setFrom(messageJID2); - String body2("This is a legible message. .cmaulm.chul"); + std::string body2("This is a legible message. .cmaulm.chul"); message2->setBody(body2); manager_->handleIncomingMessage(message2); CPPUNIT_ASSERT_EQUAL(body2, window1->lastMessageBody_); } void testFirstOpenWindowOutgoing() { - String messageJIDString("testling@test.com"); + std::string messageJIDString("testling@test.com"); ChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString), uiEventStream_).Return(window); @@ -162,8 +162,8 @@ public: void testFirstOpenWindowBareToFull() { - String bareJIDString("testling@test.com"); - String fullJIDString("testling@test.com/resource1"); + std::string bareJIDString("testling@test.com"); + std::string fullJIDString("testling@test.com/resource1"); MockChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(bareJIDString), uiEventStream_).Return(window); @@ -171,19 +171,19 @@ public: boost::shared_ptr<Message> message(new Message()); message->setFrom(JID(fullJIDString)); - String body("This is a legible message. mjuga3089gm8G(*>M)@*("); + std::string body("This is a legible message. mjuga3089gm8G(*>M)@*("); message->setBody(body); manager_->handleIncomingMessage(message); CPPUNIT_ASSERT_EQUAL(body, window->lastMessageBody_); } void testSecondWindow() { - String messageJIDString1("testling1@test.com"); + std::string messageJIDString1("testling1@test.com"); ChatWindow* window1 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1); uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString1)))); - String messageJIDString2("testling2@test.com"); + std::string messageJIDString2("testling2@test.com"); ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString2), uiEventStream_).Return(window2); @@ -197,9 +197,9 @@ public: Rebind it. */ void testUnbindRebind() { - String bareJIDString("testling@test.com"); - String fullJIDString1("testling@test.com/resource1"); - String fullJIDString2("testling@test.com/resource2"); + std::string bareJIDString("testling@test.com"); + std::string fullJIDString1("testling@test.com/resource1"); + std::string fullJIDString2("testling@test.com/resource2"); MockChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(bareJIDString), uiEventStream_).Return(window); @@ -207,7 +207,7 @@ public: boost::shared_ptr<Message> message1(new Message()); message1->setFrom(JID(fullJIDString1)); - String messageBody1("This is a legible message."); + std::string messageBody1("This is a legible message."); message1->setBody(messageBody1); manager_->handleIncomingMessage(message1); CPPUNIT_ASSERT_EQUAL(messageBody1, window->lastMessageBody_); @@ -221,7 +221,7 @@ public: boost::shared_ptr<Message> message2(new Message()); message2->setFrom(JID(fullJIDString2)); - String messageBody2("This is another legible message."); + std::string messageBody2("This is another legible message."); message2->setBody(messageBody2); manager_->handleIncomingMessage(message2); CPPUNIT_ASSERT_EQUAL(messageBody2, window->lastMessageBody_); @@ -234,21 +234,21 @@ public: JID muc("testling@test.com"); ChatWindow* mucWindow = new MockChatWindow(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(muc, uiEventStream_).Return(mucWindow); - uiEventStream_->send(boost::shared_ptr<JoinMUCUIEvent>(new JoinMUCUIEvent(muc, String("nick")))); + uiEventStream_->send(boost::shared_ptr<JoinMUCUIEvent>(new JoinMUCUIEvent(muc, std::string("nick")))); - String messageJIDString1("testling@test.com/1"); + std::string messageJIDString1("testling@test.com/1"); ChatWindow* window1 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1), uiEventStream_).Return(window1); uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString1)))); - String messageJIDString2("testling@test.com/2"); + std::string messageJIDString2("testling@test.com/2"); ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString2), uiEventStream_).Return(window2); uiEventStream_->send(boost::shared_ptr<UIEvent>(new RequestChatUIEvent(JID(messageJIDString2)))); - String messageJIDString3("testling@test.com/3"); + std::string messageJIDString3("testling@test.com/3"); ChatWindow* window3 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>(); mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString3), uiEventStream_).Return(window3); @@ -308,14 +308,14 @@ public: boost::shared_ptr<Message> message3(new Message()); message3->setFrom(messageJID3); - String body3("This is a legible message3."); + std::string body3("This is a legible message3."); message3->setBody(body3); manager_->handleIncomingMessage(message3); CPPUNIT_ASSERT_EQUAL(body3, window1->lastMessageBody_); boost::shared_ptr<Message> message2b(new Message()); message2b->setFrom(messageJID2); - String body2b("This is a legible message2b."); + std::string body2b("This is a legible message2b."); message2b->setBody(body2b); manager_->handleIncomingMessage(message2b); CPPUNIT_ASSERT_EQUAL(body2b, window1->lastMessageBody_); diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index 62f0ccd..7c7a8b9 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -6,6 +6,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> +#include <boost/algorithm/string.hpp> #include "3rdParty/hippomocks.h" #include "Swift/Controllers/XMPPEvents/EventController.h" @@ -112,7 +113,7 @@ public: message = Message::ref(new Message()); message->setFrom(JID(muc_->getJID().toString() + "/other2")); - message->setBody("Hi " + nick_.getLowerCase() + "."); + message->setBody("Hi " + boost::to_lower_copy(nick_) + "."); message->setType(Message::Groupchat); controller_->handleIncomingMessage(MessageEvent::ref(new MessageEvent(message))); CPPUNIT_ASSERT_EQUAL((size_t)4, eventController_->getEvents().size()); @@ -126,7 +127,7 @@ public: message = Message::ref(new Message()); message->setFrom(JID(muc_->getJID().toString() + "/other2")); - message->setBody("Hi " + nick_.getLowerCase() + "ie."); + message->setBody("Hi " + boost::to_lower_copy(nick_) + "ie."); message->setType(Message::Groupchat); controller_->handleIncomingMessage(MessageEvent::ref(new MessageEvent(message))); CPPUNIT_ASSERT_EQUAL((size_t)4, eventController_->getEvents().size()); @@ -199,31 +200,31 @@ public: void testJoinPartStringContructionSimple() { std::vector<NickJoinPart> list; list.push_back(NickJoinPart("Kev", Join)); - CPPUNIT_ASSERT_EQUAL(String("Kev has joined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Remko", Part)); - CPPUNIT_ASSERT_EQUAL(String("Kev has joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev has joined and Remko has left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Bert", Join)); - CPPUNIT_ASSERT_EQUAL(String("Kev and Bert have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev and Bert have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Ernie", Join)); - CPPUNIT_ASSERT_EQUAL(String("Kev, Bert and Ernie have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev, Bert and Ernie have joined and Remko has left the room."), MUCController::generateJoinPartString(list)); } void testJoinPartStringContructionMixed() { std::vector<NickJoinPart> list; list.push_back(NickJoinPart("Kev", JoinThenPart)); - CPPUNIT_ASSERT_EQUAL(String("Kev joined then left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev joined then left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Remko", Part)); - CPPUNIT_ASSERT_EQUAL(String("Remko has left and Kev joined then left the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left and Kev joined then left the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Bert", PartThenJoin)); - CPPUNIT_ASSERT_EQUAL(String("Remko has left, Kev joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left, Kev joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); list.push_back(NickJoinPart("Ernie", JoinThenPart)); - CPPUNIT_ASSERT_EQUAL(String("Remko has left, Kev and Ernie joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); + CPPUNIT_ASSERT_EQUAL(std::string("Remko has left, Kev and Ernie joined then left and Bert left then rejoined the room."), MUCController::generateJoinPartString(list)); } private: JID self_; MUC::ref muc_; - String nick_; + std::string nick_; StanzaChannel* stanzaChannel_; IQChannel* iqChannel_; IQRouter* iqRouter_; diff --git a/Swift/Controllers/Chat/UserSearchController.cpp b/Swift/Controllers/Chat/UserSearchController.cpp index 7473849..37059c2 100644 --- a/Swift/Controllers/Chat/UserSearchController.cpp +++ b/Swift/Controllers/Chat/UserSearchController.cpp @@ -92,7 +92,7 @@ void UserSearchController::handleDiscoServiceFound(const JID& jid, boost::shared isUserDirectory = true; } } - std::vector<String> features = info->getFeatures(); + std::vector<std::string> features = info->getFeatures(); supports55 = std::find(features.begin(), features.end(), DiscoInfo::JabberSearchFeature) != features.end(); if (/*isUserDirectory && */supports55) { //FIXME: once M-Link correctly advertises directoryness. /* Abort further searches.*/ @@ -125,7 +125,7 @@ void UserSearchController::handleSearchResponse(boost::shared_ptr<SearchPayload> std::vector<UserSearchResult> results; foreach (SearchPayload::Item item, resultsPayload->getItems()) { JID jid(item.jid); - std::map<String, String> fields; + std::map<std::string, std::string> fields; fields["first"] = item.first; fields["last"] = item.last; fields["nick"] = item.nick; diff --git a/Swift/Controllers/Chat/UserSearchController.h b/Swift/Controllers/Chat/UserSearchController.h index 9b81020..69795fb 100644 --- a/Swift/Controllers/Chat/UserSearchController.h +++ b/Swift/Controllers/Chat/UserSearchController.h @@ -12,7 +12,7 @@ #include <Swiften/Base/boost_bsignals.h> #include <Swiften/Elements/SearchPayload.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/DiscoItems.h> @@ -28,12 +28,12 @@ namespace Swift { class UserSearchResult { public: - UserSearchResult(const JID& jid, const std::map<String, String>& fields) : jid_(jid), fields_(fields) {} + UserSearchResult(const JID& jid, const std::map<std::string, std::string>& fields) : jid_(jid), fields_(fields) {} const JID& getJID() const {return jid_;} - const std::map<String, String>& getFields() const {return fields_;} + const std::map<std::string, std::string>& getFields() const {return fields_;} private: JID jid_; - std::map<String, String> fields_; + std::map<std::string, std::string> fields_; }; class UserSearchController { diff --git a/Swift/Controllers/ContactEditController.cpp b/Swift/Controllers/ContactEditController.cpp index de99895..b4729a8 100644 --- a/Swift/Controllers/ContactEditController.cpp +++ b/Swift/Controllers/ContactEditController.cpp @@ -60,13 +60,13 @@ void ContactEditController::handleRemoveContactRequest() { contactEditWindow->hide(); } -void ContactEditController::handleChangeContactRequest(const String& name, const std::set<String>& newGroups) { - std::vector<String> oldGroupsVector = currentContact->getGroups(); - std::set<String> oldGroups(oldGroupsVector.begin(), oldGroupsVector.end()); +void ContactEditController::handleChangeContactRequest(const std::string& name, const std::set<std::string>& newGroups) { + std::vector<std::string> oldGroupsVector = currentContact->getGroups(); + std::set<std::string> oldGroups(oldGroupsVector.begin(), oldGroupsVector.end()); if (oldGroups != newGroups || currentContact->getName() != name) { XMPPRosterItem newContact(*currentContact); newContact.setName(name); - newContact.setGroups(std::vector<String>(newGroups.begin(), newGroups.end())); + newContact.setGroups(std::vector<std::string>(newGroups.begin(), newGroups.end())); rosterController->updateItem(newContact); } contactEditWindow->hide(); diff --git a/Swift/Controllers/ContactEditController.h b/Swift/Controllers/ContactEditController.h index b5c8101..1947944 100644 --- a/Swift/Controllers/ContactEditController.h +++ b/Swift/Controllers/ContactEditController.h @@ -11,7 +11,7 @@ #include <boost/optional.hpp> #include <Swiften/JID/JID.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swift/Controllers/UIEvents/UIEvent.h> #include <Swiften/Roster/XMPPRosterItem.h> @@ -30,7 +30,7 @@ namespace Swift { private: void handleRemoveContactRequest(); - void handleChangeContactRequest(const String& name, const std::set<String>& groups); + void handleChangeContactRequest(const std::string& name, const std::set<std::string>& groups); private: void handleUIEvent(UIEvent::ref event); diff --git a/Swift/Controllers/DiscoServiceWalker.cpp b/Swift/Controllers/DiscoServiceWalker.cpp index 15d2aaa..ce29927 100644 --- a/Swift/Controllers/DiscoServiceWalker.cpp +++ b/Swift/Controllers/DiscoServiceWalker.cpp @@ -110,7 +110,7 @@ void DiscoServiceWalker::handleDiscoItemsResponse(boost::shared_ptr<DiscoItems> return; } foreach (DiscoItems::Item item, items->getItems()) { - if (item.getNode().isEmpty()) { + if (item.getNode().empty()) { /* Don't look at noded items. It's possible that this will exclude some services, * but I've never seen one in the wild, and it's an easy fix for not looping. */ diff --git a/Swift/Controllers/DiscoServiceWalker.h b/Swift/Controllers/DiscoServiceWalker.h index 00e2436..7982bbc 100644 --- a/Swift/Controllers/DiscoServiceWalker.h +++ b/Swift/Controllers/DiscoServiceWalker.h @@ -11,7 +11,7 @@ #include <boost/shared_ptr.hpp> #include <Swiften/Base/boost_bsignals.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/DiscoInfo.h> #include <Swiften/Elements/DiscoItems.h> diff --git a/Swift/Controllers/EventNotifier.cpp b/Swift/Controllers/EventNotifier.cpp index 343abd9..405fa77 100644 --- a/Swift/Controllers/EventNotifier.cpp +++ b/Swift/Controllers/EventNotifier.cpp @@ -31,8 +31,8 @@ EventNotifier::~EventNotifier() { void EventNotifier::handleEventAdded(boost::shared_ptr<StanzaEvent> event) { if (boost::shared_ptr<MessageEvent> messageEvent = boost::dynamic_pointer_cast<MessageEvent>(event)) { JID jid = messageEvent->getStanza()->getFrom(); - String title = nickResolver->jidToNick(jid); - if (!messageEvent->getStanza()->isError() && !messageEvent->getStanza()->getBody().isEmpty()) { + std::string title = nickResolver->jidToNick(jid); + if (!messageEvent->getStanza()->isError() && !messageEvent->getStanza()->getBody().empty()) { JID activationJID = jid; if (messageEvent->getStanza()->getType() == Message::Groupchat) { activationJID = jid.toBare(); @@ -42,8 +42,8 @@ void EventNotifier::handleEventAdded(boost::shared_ptr<StanzaEvent> event) { } else if(boost::shared_ptr<SubscriptionRequestEvent> subscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event)) { JID jid = subscriptionEvent->getJID(); - String title = ""; - String message = nickResolver->jidToNick(jid) + " wants to add you to his/her roster"; + std::string title = ""; + std::string message = nickResolver->jidToNick(jid) + " wants to add you to his/her roster"; notifier->showMessage(Notifier::SystemMessage, title, message, boost::filesystem::path(), boost::function<void()>()); } else if(boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event)) { diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 31a1d5a..1257845 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -41,7 +41,7 @@ #include "SwifTools/Dock/Dock.h" #include "SwifTools/Notifier/TogglableNotifier.h" #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Client/Client.h" #include "Swiften/Presence/PresenceSender.h" #include "Swiften/Elements/ChatState.h" @@ -66,10 +66,10 @@ namespace Swift { -static const String CLIENT_NAME = "Swift"; -static const String CLIENT_NODE = "http://swift.im"; +static const std::string CLIENT_NAME = "Swift"; +static const std::string CLIENT_NODE = "http://swift.im"; -static const String SHOW_NOTIFICATIONS = "showNotifications"; +static const std::string SHOW_NOTIFICATIONS = "showNotifications"; MainController::MainController( EventLoop* eventLoop, @@ -119,15 +119,15 @@ MainController::MainController( loginWindow_ = uiFactory_->createLoginWindow(uiEventStream_); soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings, uiEventStream_); - String selectedLoginJID = settings_->getStringSetting("lastLoginJID"); + std::string selectedLoginJID = settings_->getStringSetting("lastLoginJID"); bool loginAutomatically = settings_->getBoolSetting("loginAutomatically", false); - String cachedPassword; - String cachedCertificate; - foreach (String profile, settings->getAvailableProfiles()) { + std::string cachedPassword; + std::string cachedCertificate; + foreach (std::string profile, settings->getAvailableProfiles()) { ProfileSettingsProvider profileSettings(profile, settings); - String password = profileSettings.getStringSetting("pass"); - String certificate = profileSettings.getStringSetting("certificate"); - String jid = profileSettings.getStringSetting("jid"); + std::string password = profileSettings.getStringSetting("pass"); + std::string certificate = profileSettings.getStringSetting("certificate"); + std::string jid = profileSettings.getStringSetting("jid"); loginWindow_->addAvailableAccount(jid, password, certificate); if (jid == selectedLoginJID) { cachedPassword = password; @@ -292,7 +292,7 @@ void MainController::reconnectAfterError() { performLoginFromCachedCredentials(); } -void MainController::handleChangeStatusRequest(StatusShow::Type show, const String &statusText) { +void MainController::handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText) { boost::shared_ptr<Presence> presence(new Presence()); if (show == StatusShow::None) { // Note: this is misleading, None doesn't mean unavailable on the wire. @@ -323,7 +323,7 @@ void MainController::sendPresence(boost::shared_ptr<Presence> presence) { notifier_->setTemporarilyDisabled(presence->getShow() == StatusShow::DND); // Add information and send - if (!vCardPhotoHash_.isEmpty()) { + if (!vCardPhotoHash_.empty()) { presence->updatePayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate(vCardPhotoHash_))); } client_->getPresenceSender()->sendPresence(presence); @@ -352,7 +352,7 @@ void MainController::handleInputIdleChanged(bool idle) { } } -void MainController::handleLoginRequest(const String &username, const String &password, const String& certificateFile, bool remember, bool loginAutomatically) { +void MainController::handleLoginRequest(const std::string &username, const std::string &password, const std::string& certificateFile, bool remember, bool loginAutomatically) { loginWindow_->setMessage(""); loginWindow_->setIsLoggingIn(true); profileSettings_ = new ProfileSettingsProvider(username, settings_); @@ -368,7 +368,7 @@ void MainController::handleLoginRequest(const String &username, const String &pa performLoginFromCachedCredentials(); } -void MainController::handlePurgeSavedLoginRequest(const String& username) { +void MainController::handlePurgeSavedLoginRequest(const std::string& username) { settings_->removeProfile(username); loginWindow_->removeAvailableAccount(username); } @@ -404,7 +404,7 @@ void MainController::performLoginFromCachedCredentials() { presenceNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1)); eventNotifier_ = new EventNotifier(eventController_, notifier_, client_->getAvatarManager(), client_->getNickResolver()); eventNotifier_->onNotificationActivated.connect(boost::bind(&MainController::handleNotificationClicked, this, _1)); - if (!certificateFile_.isEmpty()) { + if (!certificateFile_.empty()) { client_->setCertificate(certificateFile_); } boost::shared_ptr<Presence> presence(new Presence()); @@ -429,8 +429,8 @@ void MainController::handleDisconnected(const boost::optional<ClientError>& erro loginWindow_->quit(); } else if (error) { - String message; - String certificateErrorMessage; + std::string message; + std::string certificateErrorMessage; switch(error->getType()) { case ClientError::UnknownError: message = "Unknown Error"; break; case ClientError::DomainNameResolveError: message = "Unable to find server"; break; @@ -464,7 +464,7 @@ void MainController::handleDisconnected(const boost::optional<ClientError>& erro } bool forceReconnectAfterCertificateTrust = false; - if (!certificateErrorMessage.isEmpty()) { + if (!certificateErrorMessage.empty()) { Certificate::ref certificate = certificateTrustChecker_->getLastCertificate(); if (loginWindow_->askUserToTrustCertificatePermanently(certificateErrorMessage, certificate)) { certificateStorage_->addCertificate(certificate); diff --git a/Swift/Controllers/MainController.h b/Swift/Controllers/MainController.h index 07bf661..f402f8f 100644 --- a/Swift/Controllers/MainController.h +++ b/Swift/Controllers/MainController.h @@ -13,7 +13,7 @@ #include "Swiften/Network/Timer.h" #include "SwifTools/Idle/PlatformIdleQuerier.h" #include "SwifTools/Idle/ActualIdleDetector.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Client/ClientError.h" #include "Swiften/JID/JID.h" #include "Swiften/Elements/DiscoInfo.h" @@ -83,16 +83,16 @@ namespace Swift { private: void resetClient(); void handleConnected(); - void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember, bool loginAutomatically); + void handleLoginRequest(const std::string& username, const std::string& password, const std::string& certificateFile, bool remember, bool loginAutomatically); void handleCancelLoginRequest(); void handleQuitRequest(); - void handleChangeStatusRequest(StatusShow::Type show, const String &statusText); + void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText); void handleDisconnected(const boost::optional<ClientError>& error); void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, ErrorPayload::ref); void handleEventQueueLengthChange(int count); void handleVCardReceived(const JID& j, VCard::ref vCard); void handleUIEvent(boost::shared_ptr<UIEvent> event); - void handlePurgeSavedLoginRequest(const String& username); + void handlePurgeSavedLoginRequest(const std::string& username); void sendPresence(boost::shared_ptr<Presence> presence); void handleInputIdleChanged(bool); void logout(); @@ -139,9 +139,9 @@ namespace Swift { JID boundJID_; SystemTrayController* systemTrayController_; SoundEventController* soundEventController_; - String vCardPhotoHash_; - String password_; - String certificateFile_; + std::string vCardPhotoHash_; + std::string password_; + std::string certificateFile_; boost::shared_ptr<ErrorEvent> lastDisconnectError_; bool useDelayForLatency_; UserSearchController* userSearchControllerChat_; diff --git a/Swift/Controllers/PresenceNotifier.cpp b/Swift/Controllers/PresenceNotifier.cpp index de6b2c9..3d5d71e 100644 --- a/Swift/Controllers/PresenceNotifier.cpp +++ b/Swift/Controllers/PresenceNotifier.cpp @@ -85,9 +85,9 @@ void PresenceNotifier::handleStanzaChannelAvailableChanged(bool available) { } void PresenceNotifier::showNotification(const JID& jid, Notifier::Type type) { - String name = nickResolver->jidToNick(jid); - String title = name + " (" + getStatusType(jid) + ")"; - String message = getStatusMessage(jid); + std::string name = nickResolver->jidToNick(jid); + std::string title = name + " (" + getStatusType(jid) + ")"; + std::string message = getStatusMessage(jid); notifier->showMessage(type, title, message, avatarManager->getAvatarPath(jid), boost::bind(&PresenceNotifier::handleNotificationActivated, this, jid)); } @@ -95,7 +95,7 @@ void PresenceNotifier::handleNotificationActivated(JID jid) { onNotificationActivated(jid); } -String PresenceNotifier::getStatusType(const JID& jid) const { +std::string PresenceNotifier::getStatusType(const JID& jid) const { Presence::ref presence = presenceOracle->getLastPresence(jid); if (presence) { return StatusShow::typeToFriendlyName(presence->getShow()); @@ -105,13 +105,13 @@ String PresenceNotifier::getStatusType(const JID& jid) const { } } -String PresenceNotifier::getStatusMessage(const JID& jid) const { +std::string PresenceNotifier::getStatusMessage(const JID& jid) const { Presence::ref presence = presenceOracle->getLastPresence(jid); if (presence) { return presence->getStatus(); } else { - return String(); + return std::string(); } } diff --git a/Swift/Controllers/PresenceNotifier.h b/Swift/Controllers/PresenceNotifier.h index 9b2d9de..0d187bd 100644 --- a/Swift/Controllers/PresenceNotifier.h +++ b/Swift/Controllers/PresenceNotifier.h @@ -37,8 +37,8 @@ namespace Swift { void handleStanzaChannelAvailableChanged(bool); void handleNotificationActivated(JID jid); void handleTimerTick(); - String getStatusType(const JID&) const; - String getStatusMessage(const JID&) const; + std::string getStatusType(const JID&) const; + std::string getStatusMessage(const JID&) const; private: void showNotification(const JID& jid, Notifier::Type type); diff --git a/Swift/Controllers/PreviousStatusStore.cpp b/Swift/Controllers/PreviousStatusStore.cpp index 271658f..947cdc7 100644 --- a/Swift/Controllers/PreviousStatusStore.cpp +++ b/Swift/Controllers/PreviousStatusStore.cpp @@ -18,25 +18,25 @@ PreviousStatusStore::~PreviousStatusStore() { } -void PreviousStatusStore::addStatus(StatusShow::Type status, const String& message) { +void PreviousStatusStore::addStatus(StatusShow::Type status, const std::string& message) { //FIXME: remove old entries store_.push_back(TypeStringPair(status, message)); } -std::vector<TypeStringPair> PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const String& message) { +std::vector<TypeStringPair> PreviousStatusStore::exactMatchSuggestions(StatusShow::Type status, const std::string& message) { std::vector<TypeStringPair> suggestions; suggestions.push_back(TypeStringPair(status, message)); return suggestions; } -std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const String& message) { +std::vector<TypeStringPair> PreviousStatusStore::getSuggestions(const std::string& message) { std::vector<TypeStringPair> suggestions; foreach (TypeStringPair status, store_) { if (status.second == message) { suggestions.clear(); suggestions.push_back(status); break; - } else if (status.second.contains(message)) { + } else if (status.second.find(message) != std::string::npos) { suggestions.push_back(status); } } diff --git a/Swift/Controllers/PreviousStatusStore.h b/Swift/Controllers/PreviousStatusStore.h index 66c49e4..6403123 100644 --- a/Swift/Controllers/PreviousStatusStore.h +++ b/Swift/Controllers/PreviousStatusStore.h @@ -9,20 +9,20 @@ #include <utility> /* std::pair */ #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/StatusShow.h" namespace Swift { - typedef std::pair<StatusShow::Type, String> TypeStringPair; + typedef std::pair<StatusShow::Type, std::string> TypeStringPair; class PreviousStatusStore { public: PreviousStatusStore(); ~PreviousStatusStore(); - void addStatus(StatusShow::Type status, const String& message); - std::vector<TypeStringPair> getSuggestions(const String& message); + void addStatus(StatusShow::Type status, const std::string& message); + std::vector<TypeStringPair> getSuggestions(const std::string& message); private: - std::vector<TypeStringPair> exactMatchSuggestions(StatusShow::Type status, const String& message); + std::vector<TypeStringPair> exactMatchSuggestions(StatusShow::Type status, const std::string& message); std::vector<TypeStringPair> store_; }; } diff --git a/Swift/Controllers/ProfileSettingsProvider.h b/Swift/Controllers/ProfileSettingsProvider.h index defe6ca..74bcd12 100644 --- a/Swift/Controllers/ProfileSettingsProvider.h +++ b/Swift/Controllers/ProfileSettingsProvider.h @@ -12,10 +12,10 @@ namespace Swift { class ProfileSettingsProvider { public: - ProfileSettingsProvider(const String& profile, SettingsProvider* provider) : profile_(profile) { + ProfileSettingsProvider(const std::string& profile, SettingsProvider* provider) : profile_(profile) { provider_ = provider; bool found = false; - foreach (String existingProfile, provider->getAvailableProfiles()) { + foreach (std::string existingProfile, provider->getAvailableProfiles()) { if (existingProfile == profile) { found = true; } @@ -25,15 +25,15 @@ class ProfileSettingsProvider { } }; virtual ~ProfileSettingsProvider() {}; - virtual String getStringSetting(const String &settingPath) {return provider_->getStringSetting(profileSettingPath(settingPath));}; - virtual void storeString(const String &settingPath, const String &settingValue) {provider_->storeString(profileSettingPath(settingPath), settingValue);}; - virtual int getIntSetting(const String& settingPath, int defaultValue) {return provider_->getIntSetting(settingPath, defaultValue);} - virtual void storeInt(const String& settingPath, int settingValue) {provider_->storeInt(settingPath, settingValue);} + virtual std::string getStringSetting(const std::string &settingPath) {return provider_->getStringSetting(profileSettingPath(settingPath));}; + virtual void storeString(const std::string &settingPath, const std::string &settingValue) {provider_->storeString(profileSettingPath(settingPath), settingValue);}; + virtual int getIntSetting(const std::string& settingPath, int defaultValue) {return provider_->getIntSetting(settingPath, defaultValue);} + virtual void storeInt(const std::string& settingPath, int settingValue) {provider_->storeInt(settingPath, settingValue);} private: - String profileSettingPath(const String &settingPath) {return profile_ + ":" + settingPath;}; + std::string profileSettingPath(const std::string &settingPath) {return profile_ + ":" + settingPath;}; SettingsProvider* provider_; - String profile_; + std::string profile_; }; } diff --git a/Swift/Controllers/Roster/ContactRosterItem.cpp b/Swift/Controllers/Roster/ContactRosterItem.cpp index df0eb7b..c6064d6 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.cpp +++ b/Swift/Controllers/Roster/ContactRosterItem.cpp @@ -10,7 +10,7 @@ namespace Swift { -ContactRosterItem::ContactRosterItem(const JID& jid, const JID& displayJID, const String& name, GroupRosterItem* parent) : RosterItem(name, parent), jid_(jid), displayJID_(displayJID) { +ContactRosterItem::ContactRosterItem(const JID& jid, const JID& displayJID, const std::string& name, GroupRosterItem* parent) : RosterItem(name, parent), jid_(jid), displayJID_(displayJID) { } ContactRosterItem::~ContactRosterItem() { @@ -33,15 +33,15 @@ StatusShow::Type ContactRosterItem::getSimplifiedStatusShow() const { return StatusShow::None; } -String ContactRosterItem::getStatusText() const { +std::string ContactRosterItem::getStatusText() const { return shownPresence_ ? shownPresence_->getStatus() : ""; } -void ContactRosterItem::setAvatarPath(const String& path) { +void ContactRosterItem::setAvatarPath(const std::string& path) { avatarPath_ = path; onDataChanged(); } -const String& ContactRosterItem::getAvatarPath() const { +const std::string& ContactRosterItem::getAvatarPath() const { return avatarPath_; } @@ -58,7 +58,7 @@ const JID& ContactRosterItem::getDisplayJID() const { } -typedef std::pair<String, boost::shared_ptr<Presence> > StringPresencePair; +typedef std::pair<std::string, boost::shared_ptr<Presence> > StringPresencePair; void ContactRosterItem::calculateShownPresence() { shownPresence_ = offlinePresence_; @@ -76,12 +76,12 @@ void ContactRosterItem::clearPresence() { onDataChanged(); } -void ContactRosterItem::applyPresence(const String& resource, boost::shared_ptr<Presence> presence) { +void ContactRosterItem::applyPresence(const std::string& resource, boost::shared_ptr<Presence> presence) { if (offlinePresence_) { offlinePresence_ = boost::shared_ptr<Presence>(); } if (presence->getType() == Presence::Unavailable) { - if (resource.isEmpty()) { + if (resource.empty()) { /* Unavailable from the bare JID means all resources are offline.*/ presences_.clear(); } else { @@ -99,15 +99,15 @@ void ContactRosterItem::applyPresence(const String& resource, boost::shared_ptr< onDataChanged(); } -const std::vector<String> ContactRosterItem::getGroups() const { +const std::vector<std::string> ContactRosterItem::getGroups() const { return groups_; } /** Only used so a contact can know about the groups it's in*/ -void ContactRosterItem::addGroup(const String& group) { +void ContactRosterItem::addGroup(const std::string& group) { groups_.push_back(group); } -void ContactRosterItem::removeGroup(const String& group) { +void ContactRosterItem::removeGroup(const std::string& group) { groups_.erase(std::remove(groups_.begin(), groups_.end(), group), groups_.end()); } diff --git a/Swift/Controllers/Roster/ContactRosterItem.h b/Swift/Controllers/Roster/ContactRosterItem.h index ca9d727..ae8d5b0 100644 --- a/Swift/Controllers/Roster/ContactRosterItem.h +++ b/Swift/Controllers/Roster/ContactRosterItem.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swift/Controllers/Roster/RosterItem.h" #include "Swiften/Elements/StatusShow.h" @@ -22,32 +22,32 @@ namespace Swift { class GroupRosterItem; class ContactRosterItem : public RosterItem { public: - ContactRosterItem(const JID& jid, const JID& displayJID, const String& name, GroupRosterItem* parent); + ContactRosterItem(const JID& jid, const JID& displayJID, const std::string& name, GroupRosterItem* parent); virtual ~ContactRosterItem(); StatusShow::Type getStatusShow() const; StatusShow::Type getSimplifiedStatusShow() const; - String getStatusText() const; - void setAvatarPath(const String& path); - const String& getAvatarPath() const; + std::string getStatusText() const; + void setAvatarPath(const std::string& path); + const std::string& getAvatarPath() const; const JID& getJID() const; void setDisplayJID(const JID& jid); const JID& getDisplayJID() const; - void applyPresence(const String& resource, boost::shared_ptr<Presence> presence); + void applyPresence(const std::string& resource, boost::shared_ptr<Presence> presence); void clearPresence(); void calculateShownPresence(); - const std::vector<String> getGroups() const; + const std::vector<std::string> getGroups() const; /** Only used so a contact can know about the groups it's in*/ - void addGroup(const String& group); - void removeGroup(const String& group); + void addGroup(const std::string& group); + void removeGroup(const std::string& group); private: JID jid_; JID displayJID_; - String avatarPath_; - std::map<String, boost::shared_ptr<Presence> > presences_; + std::string avatarPath_; + std::map<std::string, boost::shared_ptr<Presence> > presences_; boost::shared_ptr<Presence> offlinePresence_; boost::shared_ptr<Presence> shownPresence_; - std::vector<String> groups_; + std::vector<std::string> groups_; }; } diff --git a/Swift/Controllers/Roster/GroupRosterItem.cpp b/Swift/Controllers/Roster/GroupRosterItem.cpp index 7d0cf85..f0a377a 100644 --- a/Swift/Controllers/Roster/GroupRosterItem.cpp +++ b/Swift/Controllers/Roster/GroupRosterItem.cpp @@ -12,7 +12,7 @@ namespace Swift { -GroupRosterItem::GroupRosterItem(const String& name, GroupRosterItem* parent, bool sortByStatus) : RosterItem(name, parent), sortByStatus_(sortByStatus) { +GroupRosterItem::GroupRosterItem(const std::string& name, GroupRosterItem* parent, bool sortByStatus) : RosterItem(name, parent), sortByStatus_(sortByStatus) { expanded_ = true; } @@ -110,7 +110,7 @@ ContactRosterItem* GroupRosterItem::removeChild(const JID& jid) { return removed; } -GroupRosterItem* GroupRosterItem::removeGroupChild(const String& groupName) { +GroupRosterItem* GroupRosterItem::removeGroupChild(const std::string& groupName) { std::vector<RosterItem*>::iterator it = children_.begin(); GroupRosterItem* removed = NULL; while (it != children_.end()) { diff --git a/Swift/Controllers/Roster/GroupRosterItem.h b/Swift/Controllers/Roster/GroupRosterItem.h index ff5e798..57fa9fa 100644 --- a/Swift/Controllers/Roster/GroupRosterItem.h +++ b/Swift/Controllers/Roster/GroupRosterItem.h @@ -7,7 +7,7 @@ #pragma once #include "Swift/Controllers/Roster/RosterItem.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swift/Controllers/Roster/ContactRosterItem.h" #include <vector> @@ -16,13 +16,13 @@ namespace Swift { class GroupRosterItem : public RosterItem { public: - GroupRosterItem(const String& name, GroupRosterItem* parent, bool sortByStatus); + GroupRosterItem(const std::string& name, GroupRosterItem* parent, bool sortByStatus); virtual ~GroupRosterItem(); const std::vector<RosterItem*>& getChildren() const; const std::vector<RosterItem*>& getDisplayedChildren() const; void addChild(RosterItem* item); ContactRosterItem* removeChild(const JID& jid); - GroupRosterItem* removeGroupChild(const String& group); + GroupRosterItem* removeGroupChild(const std::string& group); void removeAll(); void setDisplayed(RosterItem* item, bool displayed); boost::signal<void ()> onChildrenChanged; @@ -35,7 +35,7 @@ class GroupRosterItem : public RosterItem { void handleChildrenChanged(GroupRosterItem* group); void handleDataChanged(RosterItem* item); bool sortDisplayed(); - String name_; + std::string name_; bool expanded_; std::vector<RosterItem*> children_; std::vector<RosterItem*> displayedChildren_; diff --git a/Swift/Controllers/Roster/Roster.cpp b/Swift/Controllers/Roster/Roster.cpp index 9edcaaf..4e34105 100644 --- a/Swift/Controllers/Roster/Roster.cpp +++ b/Swift/Controllers/Roster/Roster.cpp @@ -7,7 +7,7 @@ #include "Swift/Controllers/Roster/Roster.h" #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swift/Controllers/Roster/ContactRosterItem.h" #include "Swift/Controllers/Roster/RosterItem.h" @@ -46,7 +46,7 @@ GroupRosterItem* Roster::getRoot() { return root_; } -GroupRosterItem* Roster::getGroup(const String& groupName) { +GroupRosterItem* Roster::getGroup(const std::string& groupName) { foreach (RosterItem *item, root_->getChildren()) { GroupRosterItem *group = dynamic_cast<GroupRosterItem*>(item); if (group && group->getDisplayName() == groupName) { @@ -60,7 +60,7 @@ GroupRosterItem* Roster::getGroup(const String& groupName) { return group; } -void Roster::removeGroup(const String& group) { +void Roster::removeGroup(const std::string& group) { root_->removeGroupChild(group); } @@ -72,13 +72,13 @@ void Roster::handleChildrenChanged(GroupRosterItem* item) { onChildrenChanged(item); } -void Roster::addContact(const JID& jid, const JID& displayJID, const String& name, const String& groupName, const String& avatarPath) { +void Roster::addContact(const JID& jid, const JID& displayJID, const std::string& name, const std::string& groupName, const std::string& avatarPath) { GroupRosterItem* group(getGroup(groupName)); ContactRosterItem *item = new ContactRosterItem(jid, displayJID, name, group); item->setAvatarPath(avatarPath); group->addChild(item); if (itemMap_[fullJIDMapping_ ? jid : jid.toBare()].size() > 0) { - foreach (String existingGroup, itemMap_[fullJIDMapping_ ? jid : jid.toBare()][0]->getGroups()) { + foreach (std::string existingGroup, itemMap_[fullJIDMapping_ ? jid : jid.toBare()][0]->getGroups()) { item->addGroup(existingGroup); } } @@ -114,7 +114,7 @@ void Roster::removeContact(const JID& jid) { root_->removeChild(jid); } -void Roster::removeContactFromGroup(const JID& jid, const String& groupName) { +void Roster::removeContactFromGroup(const JID& jid, const std::string& groupName) { std::vector<RosterItem*> children = root_->getChildren(); std::vector<RosterItem*>::iterator it = children.begin(); while (it != children.end()) { diff --git a/Swift/Controllers/Roster/Roster.h b/Swift/Controllers/Roster/Roster.h index 5589f97..53161a8 100644 --- a/Swift/Controllers/Roster/Roster.h +++ b/Swift/Controllers/Roster/Roster.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swift/Controllers/Roster/RosterItemOperation.h" #include "Swift/Controllers/Roster/RosterFilter.h" @@ -27,10 +27,10 @@ class Roster { Roster(bool sortByStatus = true, bool fullJIDMapping = false); ~Roster(); - void addContact(const JID& jid, const JID& displayJID, const String& name, const String& group, const String& avatarPath); + void addContact(const JID& jid, const JID& displayJID, const std::string& name, const std::string& group, const std::string& avatarPath); void removeContact(const JID& jid); - void removeContactFromGroup(const JID& jid, const String& group); - void removeGroup(const String& group); + void removeContactFromGroup(const JID& jid, const std::string& group); + void removeGroup(const std::string& group); void removeAll(); void applyOnItems(const RosterItemOperation& operation); void applyOnAllItems(const RosterItemOperation& operation); @@ -42,7 +42,7 @@ class Roster { boost::signal<void (GroupRosterItem*)> onChildrenChanged; boost::signal<void (GroupRosterItem*)> onGroupAdded; boost::signal<void (RosterItem*)> onDataChanged; - GroupRosterItem* getGroup(const String& groupName); + GroupRosterItem* getGroup(const std::string& groupName); private: void handleDataChanged(RosterItem* item); void handleChildrenChanged(GroupRosterItem* item); diff --git a/Swift/Controllers/Roster/RosterController.cpp b/Swift/Controllers/Roster/RosterController.cpp index 758d4f2..e03a8d4 100644 --- a/Swift/Controllers/Roster/RosterController.cpp +++ b/Swift/Controllers/Roster/RosterController.cpp @@ -9,6 +9,7 @@ #include <boost/bind.hpp> #include <boost/smart_ptr/make_shared.hpp> +#include "Swiften/JID/JID.h" #include "Swiften/Base/foreach.h" #include "Swift/Controllers/UIInterfaces/MainWindow.h" #include "Swift/Controllers/UIInterfaces/MainWindowFactory.h" @@ -39,7 +40,7 @@ namespace Swift { -static const String SHOW_OFFLINE = "showOffline"; +static const std::string SHOW_OFFLINE = "showOffline"; /** * The controller does not gain ownership of these parameters. @@ -107,15 +108,15 @@ void RosterController::handleShowOfflineToggled(bool state) { } } -void RosterController::handleChangeStatusRequest(StatusShow::Type show, const String &statusText) { +void RosterController::handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText) { onChangeStatusRequest(show, statusText); } void RosterController::handleOnJIDAdded(const JID& jid) { - std::vector<String> groups = xmppRoster_->getGroupsForJID(jid); - String name = nickResolver_->jidToNick(jid); + std::vector<std::string> groups = xmppRoster_->getGroupsForJID(jid); + std::string name = nickResolver_->jidToNick(jid); if (!groups.empty()) { - foreach(const String& group, groups) { + foreach(const std::string& group, groups) { roster_->addContact(jid, jid, name, group, avatarManager_->getAvatarPath(jid).string()); } } @@ -139,26 +140,26 @@ void RosterController::handleOnJIDRemoved(const JID& jid) { roster_->removeContact(jid); } -void RosterController::handleOnJIDUpdated(const JID& jid, const String& oldName, const std::vector<String> passedOldGroups) { +void RosterController::handleOnJIDUpdated(const JID& jid, const std::string& oldName, const std::vector<std::string> passedOldGroups) { if (oldName != xmppRoster_->getNameForJID(jid)) { roster_->applyOnItems(SetName(nickResolver_->jidToNick(jid), jid)); } - std::vector<String> groups = xmppRoster_->getGroupsForJID(jid); - std::vector<String> oldGroups = passedOldGroups; - String name = nickResolver_->jidToNick(jid); - String contactsGroup = "Contacts"; + std::vector<std::string> groups = xmppRoster_->getGroupsForJID(jid); + std::vector<std::string> oldGroups = passedOldGroups; + std::string name = nickResolver_->jidToNick(jid); + std::string contactsGroup = "Contacts"; if (oldGroups.empty()) { oldGroups.push_back(contactsGroup); } if (groups.empty()) { groups.push_back(contactsGroup); } - foreach(const String& group, groups) { + foreach(const std::string& group, groups) { if (std::find(oldGroups.begin(), oldGroups.end(), group) == oldGroups.end()) { roster_->addContact(jid, jid, name, group, avatarManager_->getAvatarPath(jid).string()); } } - foreach(const String& group, oldGroups) { + foreach(const std::string& group, oldGroups) { if (std::find(groups.begin(), groups.end(), group) == groups.end()) { roster_->removeContactFromGroup(jid, group); if (roster_->getGroup(group)->getChildren().size() == 0) { @@ -205,14 +206,14 @@ void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) { } else if (boost::shared_ptr<RenameGroupUIEvent> renameGroupEvent = boost::dynamic_pointer_cast<RenameGroupUIEvent>(event)) { std::vector<XMPPRosterItem> items = xmppRoster_->getItems(); - String group = renameGroupEvent->getGroup(); + std::string group = renameGroupEvent->getGroup(); // FIXME: We should handle contacts groups specially to avoid clashes if (group == "Contacts") { group = ""; } foreach(XMPPRosterItem& item, items) { - std::vector<String> groups = item.getGroups(); - if ( (group.isEmpty() && groups.empty()) || std::find(groups.begin(), groups.end(), group) != groups.end()) { + std::vector<std::string> groups = item.getGroups(); + if ( (group.empty() && groups.empty()) || std::find(groups.begin(), groups.end(), group) != groups.end()) { groups.erase(std::remove(groups.begin(), groups.end(), group), groups.end()); if (std::find(groups.begin(), groups.end(), renameGroupEvent->getNewName()) == groups.end()) { groups.push_back(renameGroupEvent->getNewName()); @@ -224,7 +225,7 @@ void RosterController::handleUIEvent(boost::shared_ptr<UIEvent> event) { } } -void RosterController::setContactGroups(const JID& jid, const std::vector<String>& groups) { +void RosterController::setContactGroups(const JID& jid, const std::vector<std::string>& groups) { updateItem(XMPPRosterItem(jid, xmppRoster_->getNameForJID(jid), groups, xmppRoster_->getSubscriptionStateForJID(jid))); } @@ -244,8 +245,8 @@ void RosterController::handleRosterSetError(ErrorPayload::ref error, boost::shar if (!error) { return; } - String text = "Server " + myJID_.getDomain() + " rejected roster change to item '" + rosterPayload->getItems()[0].getJID() + "'"; - if (!error->getText().isEmpty()) { + std::string text = "Server " + myJID_.getDomain() + " rejected roster change to item '" + rosterPayload->getItems()[0].getJID().toString() + "'"; + if (!error->getText().empty()) { text += ": " + error->getText(); } boost::shared_ptr<ErrorEvent> errorEvent(new ErrorEvent(JID(myJID_.getDomain()), text)); @@ -259,7 +260,7 @@ void RosterController::handleIncomingPresence(Presence::ref newPresence) { roster_->applyOnItems(SetPresence(newPresence)); } -void RosterController::handleSubscriptionRequest(const JID& jid, const String& message) { +void RosterController::handleSubscriptionRequest(const JID& jid, const std::string& message) { if (xmppRoster_->containsJID(jid) && (xmppRoster_->getSubscriptionStateForJID(jid) == RosterItemPayload::To || xmppRoster_->getSubscriptionStateForJID(jid) == RosterItemPayload::Both)) { subscriptionManager_->confirmSubscription(jid); return; @@ -283,7 +284,7 @@ void RosterController::handleSubscriptionRequestDeclined(SubscriptionRequestEven } void RosterController::handleAvatarChanged(const JID& jid) { - String path = avatarManager_->getAvatarPath(jid).string(); + std::string path = avatarManager_->getAvatarPath(jid).string(); roster_->applyOnItems(SetAvatar(jid, path)); if (jid.equals(myJID_, JID::WithoutResource)) { mainWindow_->setMyAvatarPath(path); @@ -294,7 +295,7 @@ boost::optional<XMPPRosterItem> RosterController::getItem(const JID& jid) const return xmppRoster_->getItem(jid); } -std::set<String> RosterController::getGroups() const { +std::set<std::string> RosterController::getGroups() const { return xmppRoster_->getGroups(); } diff --git a/Swift/Controllers/Roster/RosterController.h b/Swift/Controllers/Roster/RosterController.h index b0641c3..f224180 100644 --- a/Swift/Controllers/Roster/RosterController.h +++ b/Swift/Controllers/Roster/RosterController.h @@ -7,7 +7,7 @@ #pragma once #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/ErrorPayload.h" #include "Swiften/Elements/RosterPayload.h" @@ -42,27 +42,27 @@ namespace Swift { ~RosterController(); void showRosterWindow(); MainWindow* getWindow() {return mainWindow_;}; - boost::signal<void (StatusShow::Type, const String&)> onChangeStatusRequest; + boost::signal<void (StatusShow::Type, const std::string&)> onChangeStatusRequest; boost::signal<void ()> onSignOutRequest; void handleAvatarChanged(const JID& jid); void setEnabled(bool enabled); boost::optional<XMPPRosterItem> getItem(const JID&) const; - std::set<String> getGroups() const; + std::set<std::string> getGroups() const; - void setContactGroups(const JID& jid, const std::vector<String>& groups); + void setContactGroups(const JID& jid, const std::vector<std::string>& groups); void updateItem(const XMPPRosterItem&); private: void handleOnJIDAdded(const JID &jid); void handleRosterCleared(); void handleOnJIDRemoved(const JID &jid); - void handleOnJIDUpdated(const JID &jid, const String& oldName, const std::vector<String> oldGroups); + void handleOnJIDUpdated(const JID &jid, const std::string& oldName, const std::vector<std::string> oldGroups); void handleStartChatRequest(const JID& contact); - void handleChangeStatusRequest(StatusShow::Type show, const String &statusText); + void handleChangeStatusRequest(StatusShow::Type show, const std::string &statusText); void handleShowOfflineToggled(bool state); void handleIncomingPresence(boost::shared_ptr<Presence> newPresence); - void handleSubscriptionRequest(const JID& jid, const String& message); + void handleSubscriptionRequest(const JID& jid, const std::string& message); void handleSubscriptionRequestAccepted(SubscriptionRequestEvent* event); void handleSubscriptionRequestDeclined(SubscriptionRequestEvent* event); void handleUIEvent(boost::shared_ptr<UIEvent> event); diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp index 64baac9..c1045ee 100644 --- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp +++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.cpp @@ -9,6 +9,7 @@ #include <boost/bind.hpp> #include <vector> +#include "Swiften/Base/String.h" #include "Swift/Controllers/Roster/GroupRosterItem.h" namespace Swift { @@ -29,7 +30,7 @@ void RosterGroupExpandinessPersister::handleGroupAdded(GroupRosterItem* group) { void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* group, bool expanded) { if (expanded) { - String displayName = group->getDisplayName(); + std::string displayName = group->getDisplayName(); //collapsed_.erase(std::remove(collapsed_.begin(), collapsed_.end(), displayName), collapsed_.end()); collapsed_.erase(displayName); } else { @@ -39,9 +40,9 @@ void RosterGroupExpandinessPersister::handleExpandedChanged(GroupRosterItem* gro } void RosterGroupExpandinessPersister::save() { - String setting; - foreach (const String& group, collapsed_) { - if (!setting.isEmpty()) { + std::string setting; + foreach (const std::string& group, collapsed_) { + if (!setting.empty()) { setting += "\n"; } setting += group; @@ -50,11 +51,11 @@ void RosterGroupExpandinessPersister::save() { } void RosterGroupExpandinessPersister::load() { - String saved = settings_->getStringSetting(SettingPath); - std::vector<String> collapsed = saved.split('\n'); + std::string saved = settings_->getStringSetting(SettingPath); + std::vector<std::string> collapsed = String::split(saved, '\n'); collapsed_.insert(collapsed.begin(), collapsed.end()); } -const String RosterGroupExpandinessPersister::SettingPath = "GroupExpandiness"; +const std::string RosterGroupExpandinessPersister::SettingPath = "GroupExpandiness"; } diff --git a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h index f73afa8..63affe4 100644 --- a/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h +++ b/Swift/Controllers/Roster/RosterGroupExpandinessPersister.h @@ -19,9 +19,9 @@ namespace Swift { void handleGroupAdded(GroupRosterItem* group); void load(); void save(); - std::set<String> collapsed_; + std::set<std::string> collapsed_; Roster* roster_; SettingsProvider* settings_; - static const String SettingPath; + static const std::string SettingPath; }; } diff --git a/Swift/Controllers/Roster/RosterItem.cpp b/Swift/Controllers/Roster/RosterItem.cpp index 61c5aea..3f130bb 100644 --- a/Swift/Controllers/Roster/RosterItem.cpp +++ b/Swift/Controllers/Roster/RosterItem.cpp @@ -6,11 +6,13 @@ #include "Swift/Controllers/Roster/RosterItem.h" +#include <boost/algorithm/string.hpp> + #include "Swift/Controllers/Roster/GroupRosterItem.h" namespace Swift { -RosterItem::RosterItem(const String& name, GroupRosterItem* parent) : name_(name), sortableDisplayName_(name_.getLowerCase()), parent_(parent) { +RosterItem::RosterItem(const std::string& name, GroupRosterItem* parent) : name_(name), sortableDisplayName_(boost::to_lower_copy(name_)), parent_(parent) { /* The following would be good, but because of C++'s inheritance not working in constructors, it's not going to work. */ //if (parent) { // parent_->addChild(this); @@ -25,17 +27,17 @@ GroupRosterItem* RosterItem::getParent() const { return parent_; } -void RosterItem::setDisplayName(const String& name) { +void RosterItem::setDisplayName(const std::string& name) { name_ = name; - sortableDisplayName_ = name_.getLowerCase(); + sortableDisplayName_ = boost::to_lower_copy(name_); onDataChanged(); } -String RosterItem::getDisplayName() const { +std::string RosterItem::getDisplayName() const { return name_; } -String RosterItem::getSortableDisplayName() const { +std::string RosterItem::getSortableDisplayName() const { return sortableDisplayName_; } diff --git a/Swift/Controllers/Roster/RosterItem.h b/Swift/Controllers/Roster/RosterItem.h index 35dbe73..ed8cb16 100644 --- a/Swift/Controllers/Roster/RosterItem.h +++ b/Swift/Controllers/Roster/RosterItem.h @@ -9,22 +9,22 @@ #include "Swiften/Base/boost_bsignals.h" #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class GroupRosterItem; class RosterItem { public: - RosterItem(const String& name, GroupRosterItem* parent); + RosterItem(const std::string& name, GroupRosterItem* parent); virtual ~RosterItem(); boost::signal<void ()> onDataChanged; GroupRosterItem* getParent() const; - void setDisplayName(const String& name); - String getDisplayName() const; - String getSortableDisplayName() const; + void setDisplayName(const std::string& name); + std::string getDisplayName() const; + std::string getSortableDisplayName() const; private: - String name_; - String sortableDisplayName_; + std::string name_; + std::string sortableDisplayName_; GroupRosterItem* parent_; }; diff --git a/Swift/Controllers/Roster/SetAvatar.h b/Swift/Controllers/Roster/SetAvatar.h index 2b9cfa8..241b741 100644 --- a/Swift/Controllers/Roster/SetAvatar.h +++ b/Swift/Controllers/Roster/SetAvatar.h @@ -17,7 +17,7 @@ class RosterItem; class SetAvatar : public RosterItemOperation { public: - SetAvatar(const JID& jid, const String& path, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), jid_(jid), path_(path), compareType_(compareType) { + SetAvatar(const JID& jid, const std::string& path, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), jid_(jid), path_(path), compareType_(compareType) { } virtual void operator() (RosterItem* item) const { @@ -29,7 +29,7 @@ class SetAvatar : public RosterItemOperation { private: JID jid_; - String path_; + std::string path_; JID::CompareType compareType_; }; diff --git a/Swift/Controllers/Roster/SetName.h b/Swift/Controllers/Roster/SetName.h index 4d75392..aefb0dc 100644 --- a/Swift/Controllers/Roster/SetName.h +++ b/Swift/Controllers/Roster/SetName.h @@ -16,7 +16,7 @@ class RosterItem; class SetName : public RosterItemOperation { public: - SetName(const String& name, const JID& jid, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), name_(name), jid_(jid), compareType_(compareType) { + SetName(const std::string& name, const JID& jid, JID::CompareType compareType = JID::WithoutResource) : RosterItemOperation(true, jid), name_(name), jid_(jid), compareType_(compareType) { } virtual void operator() (RosterItem* item) const { @@ -27,7 +27,7 @@ class SetName : public RosterItemOperation { } private: - String name_; + std::string name_; JID jid_; JID::CompareType compareType_; }; diff --git a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp index 466a528..16f2745 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterControllerTest.cpp @@ -91,12 +91,12 @@ class RosterControllerTest : public CppUnit::TestFixture { return dynamic_cast<GroupRosterItem*>(CHILDREN[i]); } - JID withResource(const JID& jid, const String& resource) { + JID withResource(const JID& jid, const std::string& resource) { return JID(jid.toBare().toString() + "/" + resource); } void testPresence() { - std::vector<String> groups; + std::vector<std::string> groups; groups.push_back("testGroup1"); groups.push_back("testGroup2"); JID from("test@testdomain.com"); @@ -116,7 +116,7 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testHighestPresence() { - std::vector<String> groups; + std::vector<std::string> groups; groups.push_back("testGroup1"); JID from("test@testdomain.com"); xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both); @@ -136,7 +136,7 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testNotHighestPresence() { - std::vector<String> groups; + std::vector<std::string> groups; groups.push_back("testGroup1"); JID from("test@testdomain.com"); xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both); @@ -156,7 +156,7 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testUnavailablePresence() { - std::vector<String> groups; + std::vector<std::string> groups; groups.push_back("testGroup1"); JID from("test@testdomain.com"); xmppRoster_->addContact(from, "name", groups, RosterItemPayload::Both); @@ -198,17 +198,17 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testAdd() { - std::vector<String> groups; + std::vector<std::string> groups; groups.push_back("testGroup1"); groups.push_back("testGroup2"); xmppRoster_->addContact(JID("test@testdomain.com/bob"), "name", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(CHILDREN.size())); - //CPPUNIT_ASSERT_EQUAL(String("Bob"), xmppRoster_->getNameForJID(JID("foo@bar.com"))); + //CPPUNIT_ASSERT_EQUAL(std::string("Bob"), xmppRoster_->getNameForJID(JID("foo@bar.com"))); }; void testAddSubscription() { - std::vector<String> groups; + std::vector<std::string> groups; JID jid("test@testdomain.com"); xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::None); @@ -225,24 +225,24 @@ class RosterControllerTest : public CppUnit::TestFixture { }; void testReceiveRename() { - std::vector<String> groups; + std::vector<std::string> groups; JID jid("test@testdomain.com"); xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("name"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("name"), groupChild(0)->getChildren()[0]->getDisplayName()); xmppRoster_->addContact(jid, "NewName", groups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("NewName"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), groupChild(0)->getChildren()[0]->getDisplayName()); }; void testReceiveRegroup() { - std::vector<String> oldGroups; - std::vector<String> newGroups; + std::vector<std::string> oldGroups; + std::vector<std::string> newGroups; newGroups.push_back("A Group"); - std::vector<String> newestGroups; + std::vector<std::string> newestGroups; newestGroups.push_back("Best Group"); JID jid("test@testdomain.com"); xmppRoster_->addContact(jid, "", oldGroups, RosterItemPayload::Both); @@ -254,19 +254,19 @@ class RosterControllerTest : public CppUnit::TestFixture { xmppRoster_->addContact(jid, "new name", newGroups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("A Group"), groupChild(0)->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("A Group"), groupChild(0)->getDisplayName()); xmppRoster_->addContact(jid, "new name", newestGroups, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(CHILDREN.size())); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(groupChild(0)->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Best Group"), groupChild(0)->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("new name"), groupChild(0)->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Best Group"), groupChild(0)->getDisplayName()); }; void testSendRename() { JID jid("testling@wonderland.lit"); - std::vector<String> groups; + std::vector<std::string> groups; groups.push_back("Friends"); groups.push_back("Enemies"); xmppRoster_->addContact(jid, "Bob", groups, RosterItemPayload::From); @@ -278,17 +278,17 @@ class RosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payload->getItems().size()); RosterItemPayload item = payload->getItems()[0]; CPPUNIT_ASSERT_EQUAL(jid, item.getJID()); - CPPUNIT_ASSERT_EQUAL(String("Robert"), item.getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Robert"), item.getName()); CPPUNIT_ASSERT_EQUAL(groups.size(), item.getGroups().size()); assertVectorsEqual(groups, item.getGroups(), __LINE__); } - void assertVectorsEqual(const std::vector<String>& v1, const std::vector<String>& v2, int line) { - foreach (const String& entry, v1) { + void assertVectorsEqual(const std::vector<std::string>& v1, const std::vector<std::string>& v2, int line) { + foreach (const std::string& entry, v1) { if (std::find(v2.begin(), v2.end(), entry) == v2.end()) { std::stringstream stream; - stream << "Couldn't find " << entry.getUTF8String() << " in v2 (line " << line << ")"; + stream << "Couldn't find " << entry << " in v2 (line " << line << ")"; CPPUNIT_FAIL(stream.str()); } } diff --git a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp index 754f3e1..cbef787 100644 --- a/Swift/Controllers/Roster/UnitTest/RosterTest.cpp +++ b/Swift/Controllers/Roster/UnitTest/RosterTest.cpp @@ -41,17 +41,17 @@ class RosterTest : public CppUnit::TestFixture { roster_->addContact(jid3_, JID(), "Cookie", "group1", ""); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(roster_->getRoot()->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("group1"), roster_->getRoot()->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("group2"), roster_->getRoot()->getChildren()[1]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Ernie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[1])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("group1"), roster_->getRoot()->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("group2"), roster_->getRoot()->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Ernie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[1])->getChildren()[0]->getDisplayName()); } void testRemoveContact() { roster_->addContact(jid1_, jid1_, "Bert", "group1", ""); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); roster_->removeContact(jid1_); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size())); @@ -60,11 +60,11 @@ class RosterTest : public CppUnit::TestFixture { void testRemoveSecondContact() { roster_->addContact(jid1_, jid1_, "Bert", "group1", ""); roster_->addContact(jid2_, jid2_, "Cookie", "group1", ""); - CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid2_); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); } void testRemoveSecondContactSameBare() { @@ -72,11 +72,11 @@ class RosterTest : public CppUnit::TestFixture { JID jid4b("a@b/d"); roster_->addContact(jid4a, JID(), "Bert", "group1", ""); roster_->addContact(jid4b, JID(), "Cookie", "group1", ""); - CPPUNIT_ASSERT_EQUAL(String("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Cookie"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName()); roster_->removeContact(jid4b); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren().size())); - CPPUNIT_ASSERT_EQUAL(String("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), static_cast<GroupRosterItem*>(roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName()); } void testApplyPresenceLikeMUC() { @@ -105,9 +105,9 @@ class RosterTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(children.size())); /* Check order */ - CPPUNIT_ASSERT_EQUAL(String("Ernie"), children[0]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Bert"), children[1]->getDisplayName()); - CPPUNIT_ASSERT_EQUAL(String("Bird"), children[2]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Ernie"), children[0]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bert"), children[1]->getDisplayName()); + CPPUNIT_ASSERT_EQUAL(std::string("Bird"), children[2]->getDisplayName()); presence = boost::shared_ptr<Presence>(new Presence()); presence->setFrom(jid4c); diff --git a/Swift/Controllers/Settings/DummySettingsProvider.h b/Swift/Controllers/Settings/DummySettingsProvider.h index 631b68d..90e1921 100644 --- a/Swift/Controllers/Settings/DummySettingsProvider.h +++ b/Swift/Controllers/Settings/DummySettingsProvider.h @@ -13,15 +13,15 @@ namespace Swift { class DummySettingsProvider : public SettingsProvider { public: virtual ~DummySettingsProvider() {} - virtual String getStringSetting(const String&) {return "";} - virtual void storeString(const String &, const String &) {} - virtual bool getBoolSetting(const String &, bool ) {return true;} - virtual void storeBool(const String &, bool ) {} - virtual int getIntSetting(const String &, int ) {return 0;} - virtual void storeInt(const String &, int ) {} - virtual std::vector<String> getAvailableProfiles() {return std::vector<String>();} - virtual void createProfile(const String& ) {} - virtual void removeProfile(const String& ) {} + virtual std::string getStringSetting(const std::string&) {return "";} + virtual void storeString(const std::string &, const std::string &) {} + virtual bool getBoolSetting(const std::string &, bool ) {return true;} + virtual void storeBool(const std::string &, bool ) {} + virtual int getIntSetting(const std::string &, int ) {return 0;} + virtual void storeInt(const std::string &, int ) {} + virtual std::vector<std::string> getAvailableProfiles() {return std::vector<std::string>();} + virtual void createProfile(const std::string& ) {} + virtual void removeProfile(const std::string& ) {} }; } diff --git a/Swift/Controllers/Settings/SettingsProvider.h b/Swift/Controllers/Settings/SettingsProvider.h index a2cdad4..a5ff4eb 100644 --- a/Swift/Controllers/Settings/SettingsProvider.h +++ b/Swift/Controllers/Settings/SettingsProvider.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_SettingsProvider_H #define SWIFTEN_SettingsProvider_H -#include "Swiften/Base/String.h" +#include <string> #include <vector> @@ -16,15 +16,15 @@ namespace Swift { class SettingsProvider { public: virtual ~SettingsProvider() {} - virtual String getStringSetting(const String &settingPath) = 0; - virtual void storeString(const String &settingPath, const String &settingValue) = 0; - virtual bool getBoolSetting(const String &settingPath, bool defaultValue) = 0; - virtual void storeBool(const String &settingPath, bool settingValue) = 0; - virtual int getIntSetting(const String &settingPath, int defaultValue) = 0; - virtual void storeInt(const String &settingPath, int settingValue) = 0; - virtual std::vector<String> getAvailableProfiles() = 0; - virtual void createProfile(const String& profile) = 0; - virtual void removeProfile(const String& profile) = 0; + virtual std::string getStringSetting(const std::string &settingPath) = 0; + virtual void storeString(const std::string &settingPath, const std::string &settingValue) = 0; + virtual bool getBoolSetting(const std::string &settingPath, bool defaultValue) = 0; + virtual void storeBool(const std::string &settingPath, bool settingValue) = 0; + virtual int getIntSetting(const std::string &settingPath, int defaultValue) = 0; + virtual void storeInt(const std::string &settingPath, int settingValue) = 0; + virtual std::vector<std::string> getAvailableProfiles() = 0; + virtual void createProfile(const std::string& profile) = 0; + virtual void removeProfile(const std::string& profile) = 0; }; } diff --git a/Swift/Controllers/UIEvents/AddContactUIEvent.h b/Swift/Controllers/UIEvents/AddContactUIEvent.h index 1c5e54b..b2bf5ce 100644 --- a/Swift/Controllers/UIEvents/AddContactUIEvent.h +++ b/Swift/Controllers/UIEvents/AddContactUIEvent.h @@ -6,18 +6,18 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swift/Controllers/UIEvents/UIEvent.h" namespace Swift { class AddContactUIEvent : public UIEvent { public: - AddContactUIEvent(const JID& jid, const String& name) : jid_(jid), name_(name) {}; - String getName() {return name_;}; + AddContactUIEvent(const JID& jid, const std::string& name) : jid_(jid), name_(name) {}; + std::string getName() {return name_;}; JID getJID() {return jid_;}; private: JID jid_; - String name_; + std::string name_; }; } diff --git a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h index 2a2cd96..c7f8be6 100644 --- a/Swift/Controllers/UIEvents/JoinMUCUIEvent.h +++ b/Swift/Controllers/UIEvents/JoinMUCUIEvent.h @@ -8,7 +8,7 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swift/Controllers/UIEvents/UIEvent.h" @@ -16,11 +16,11 @@ namespace Swift { class JoinMUCUIEvent : public UIEvent { public: typedef boost::shared_ptr<JoinMUCUIEvent> ref; - JoinMUCUIEvent(const JID& jid, const boost::optional<String>& nick = boost::optional<String>()) : jid_(jid), nick_(nick) {}; - boost::optional<String> getNick() {return nick_;}; + JoinMUCUIEvent(const JID& jid, const boost::optional<std::string>& nick = boost::optional<std::string>()) : jid_(jid), nick_(nick) {}; + boost::optional<std::string> getNick() {return nick_;}; JID getJID() {return jid_;}; private: JID jid_; - boost::optional<String> nick_; + boost::optional<std::string> nick_; }; } diff --git a/Swift/Controllers/UIEvents/RenameGroupUIEvent.h b/Swift/Controllers/UIEvents/RenameGroupUIEvent.h index 1825d77..9773b9e 100644 --- a/Swift/Controllers/UIEvents/RenameGroupUIEvent.h +++ b/Swift/Controllers/UIEvents/RenameGroupUIEvent.h @@ -7,24 +7,24 @@ #pragma once #include <Swift/Controllers/UIEvents/UIEvent.h> -#include <Swiften/Base/String.h> +#include <string> namespace Swift { class RenameGroupUIEvent : public UIEvent { public: - RenameGroupUIEvent(const String& group, const String& newName) : group(group), newName(newName) { + RenameGroupUIEvent(const std::string& group, const std::string& newName) : group(group), newName(newName) { } - const String& getGroup() const { + const std::string& getGroup() const { return group; } - const String& getNewName() const { + const std::string& getNewName() const { return newName; } private: - String group; - String newName; + std::string group; + std::string newName; }; } diff --git a/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h b/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h index 4b550e6..f3542fe 100644 --- a/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h +++ b/Swift/Controllers/UIEvents/RenameRosterItemUIEvent.h @@ -14,13 +14,13 @@ namespace Swift { class RenameRosterItemUIEvent : public UIEvent { public: - RenameRosterItemUIEvent(const JID& jid, const String& newName) : jid_(jid), newName_(newName) {} + RenameRosterItemUIEvent(const JID& jid, const std::string& newName) : jid_(jid), newName_(newName) {} const JID& getJID() const {return jid_;} - const String& getNewName() const {return newName_;} + const std::string& getNewName() const {return newName_;} private: JID jid_; - String newName_; + std::string newName_; }; } diff --git a/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h b/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h index 1415140..dd2ff6c 100644 --- a/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h +++ b/Swift/Controllers/UIEvents/RequestJoinMUCUIEvent.h @@ -9,7 +9,7 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swift/Controllers/UIEvents/UIEvent.h> namespace Swift { diff --git a/Swift/Controllers/UIInterfaces/ChatWindow.h b/Swift/Controllers/UIInterfaces/ChatWindow.h index a07f90b..b90ae46 100644 --- a/Swift/Controllers/UIInterfaces/ChatWindow.h +++ b/Swift/Controllers/UIInterfaces/ChatWindow.h @@ -13,7 +13,7 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/SecurityLabel.h" #include "Swiften/Elements/ChatState.h" @@ -32,17 +32,17 @@ namespace Swift { /** Add message to window. * @return id of added message (for acks). */ - virtual String addMessage(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) = 0; + virtual std::string addMessage(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time) = 0; /** Adds action to window. * @return id of added message (for acks); */ - virtual String addAction(const String& message, const String& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) = 0; - virtual void addSystemMessage(const String& message) = 0; - virtual void addPresenceMessage(const String& message) = 0; - virtual void addErrorMessage(const String& message) = 0; + virtual std::string addAction(const std::string& message, const std::string& senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time) = 0; + virtual void addSystemMessage(const std::string& message) = 0; + virtual void addPresenceMessage(const std::string& message) = 0; + virtual void addErrorMessage(const std::string& message) = 0; virtual void setContactChatState(ChatState::ChatStateType state) = 0; - virtual void setName(const String& name) = 0; + virtual void setName(const std::string& name) = 0; virtual void show() = 0; virtual void activate() = 0; virtual void setAvailableSecurityLabels(const std::vector<SecurityLabel>& labels) = 0; @@ -55,13 +55,13 @@ namespace Swift { virtual void setInputEnabled(bool enabled) = 0; virtual void setRosterModel(Roster* model) = 0; virtual void setTabComplete(TabComplete* completer) = 0; - virtual void replaceLastMessage(const String& message) = 0; - virtual void setAckState(const String& id, AckState state) = 0; + virtual void replaceLastMessage(const std::string& message) = 0; + virtual void setAckState(const std::string& id, AckState state) = 0; virtual void flash() = 0; boost::signal<void ()> onClosed; boost::signal<void ()> onAllMessagesRead; - boost::signal<void (const String&)> onSendMessageRequest; + boost::signal<void (const std::string&)> onSendMessageRequest; boost::signal<void ()> onUserTyping; boost::signal<void ()> onUserCancelsTyping; }; diff --git a/Swift/Controllers/UIInterfaces/ContactEditWindow.h b/Swift/Controllers/UIInterfaces/ContactEditWindow.h index fe552c2..2445456 100644 --- a/Swift/Controllers/UIInterfaces/ContactEditWindow.h +++ b/Swift/Controllers/UIInterfaces/ContactEditWindow.h @@ -11,7 +11,7 @@ #include <set> #include <vector> -#include <Swiften/Base/String.h> +#include <string> namespace Swift { class JID; @@ -22,12 +22,12 @@ namespace Swift { virtual void setEnabled(bool b) = 0; - virtual void setContact(const JID& jid, const String& name, const std::vector<String>& groups, const std::set<String>& allGroups) = 0; + virtual void setContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, const std::set<std::string>& allGroups) = 0; virtual void show() = 0; virtual void hide() = 0; boost::signal<void ()> onRemoveContactRequest; - boost::signal<void (const String& /* name */, const std::set<String>& /* groups */)> onChangeContactRequest; + boost::signal<void (const std::string& /* name */, const std::set<std::string>& /* groups */)> onChangeContactRequest; }; } diff --git a/Swift/Controllers/UIInterfaces/JoinMUCWindow.h b/Swift/Controllers/UIInterfaces/JoinMUCWindow.h index 8cf712c..2e3d43c 100644 --- a/Swift/Controllers/UIInterfaces/JoinMUCWindow.h +++ b/Swift/Controllers/UIInterfaces/JoinMUCWindow.h @@ -8,7 +8,7 @@ #include <vector> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/Base/boost_bsignals.h> #include <Swiften/JID/JID.h> @@ -17,11 +17,11 @@ namespace Swift { public: virtual ~JoinMUCWindow() {}; - virtual void setNick(const String& nick) = 0; - virtual void setMUC(const String& nick) = 0; + virtual void setNick(const std::string& nick) = 0; + virtual void setMUC(const std::string& nick) = 0; virtual void show() = 0; - boost::signal<void (const JID& /* muc */, const String& /* nick */, bool /* autoJoin */)> onJoinMUC; + boost::signal<void (const JID& /* muc */, const std::string& /* nick */, bool /* autoJoin */)> onJoinMUC; boost::signal<void ()> onSearchMUC; }; } diff --git a/Swift/Controllers/UIInterfaces/LoginWindow.h b/Swift/Controllers/UIInterfaces/LoginWindow.h index fc28424..61fcaa1 100644 --- a/Swift/Controllers/UIInterfaces/LoginWindow.h +++ b/Swift/Controllers/UIInterfaces/LoginWindow.h @@ -9,7 +9,7 @@ #include "Swiften/Base/boost_bsignals.h" #include <boost/shared_ptr.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/TLS/Certificate.h> namespace Swift { @@ -17,21 +17,21 @@ namespace Swift { class LoginWindow { public: virtual ~LoginWindow() {}; - virtual void selectUser(const String&) = 0; + virtual void selectUser(const std::string&) = 0; virtual void morphInto(MainWindow *mainWindow) = 0; virtual void loggedOut() = 0; - virtual void setMessage(const String&) = 0; + virtual void setMessage(const std::string&) = 0; virtual void setIsLoggingIn(bool loggingIn) = 0; - virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) = 0; - virtual void removeAvailableAccount(const String& jid) = 0; - boost::signal<void (const String&, const String&, const String& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> onLoginRequest; + virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate) = 0; + virtual void removeAvailableAccount(const std::string& jid) = 0; + boost::signal<void (const std::string&, const std::string&, const std::string& /* certificateFile */, bool /* remember password*/, bool /* login automatically */)> onLoginRequest; virtual void setLoginAutomatically(bool loginAutomatically) = 0; virtual void quit() = 0; /** Blocking request whether a cert should be permanently trusted.*/ - virtual bool askUserToTrustCertificatePermanently(const String& message, Certificate::ref) = 0; + virtual bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref) = 0; boost::signal<void ()> onCancelLoginRequest; boost::signal<void ()> onQuitRequest; - boost::signal<void (const String&)> onPurgeSavedLoginRequest; + boost::signal<void (const std::string&)> onPurgeSavedLoginRequest; }; } diff --git a/Swift/Controllers/UIInterfaces/LoginWindowFactory.h b/Swift/Controllers/UIInterfaces/LoginWindowFactory.h index 81fde93..1cead2a 100644 --- a/Swift/Controllers/UIInterfaces/LoginWindowFactory.h +++ b/Swift/Controllers/UIInterfaces/LoginWindowFactory.h @@ -11,7 +11,7 @@ namespace Swift { class LoginWindow; - class String; + class UIEventStream; class LoginWindowFactory { diff --git a/Swift/Controllers/UIInterfaces/MUCSearchWindow.h b/Swift/Controllers/UIInterfaces/MUCSearchWindow.h index ded2a0a..5814b06 100644 --- a/Swift/Controllers/UIInterfaces/MUCSearchWindow.h +++ b/Swift/Controllers/UIInterfaces/MUCSearchWindow.h @@ -11,7 +11,7 @@ #include <vector> #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include <Swift/Controllers/Chat/MUCSearchController.h> diff --git a/Swift/Controllers/UIInterfaces/MainWindow.h b/Swift/Controllers/UIInterfaces/MainWindow.h index 125aae5..2fd463b 100644 --- a/Swift/Controllers/UIInterfaces/MainWindow.h +++ b/Swift/Controllers/UIInterfaces/MainWindow.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/Elements/StatusShow.h" @@ -25,16 +25,16 @@ namespace Swift { return canDelete_; } - virtual void setMyNick(const String& name) = 0; + virtual void setMyNick(const std::string& name) = 0; virtual void setMyJID(const JID& jid) = 0; - virtual void setMyAvatarPath(const String& path) = 0; - virtual void setMyStatusText(const String& status) = 0; + virtual void setMyAvatarPath(const std::string& path) = 0; + virtual void setMyStatusText(const std::string& status) = 0; virtual void setMyStatusType(StatusShow::Type type) = 0; /** Must be able to cope with NULL to clear the roster */ virtual void setRosterModel(Roster* roster) = 0; virtual void setConnecting() = 0; - boost::signal<void (StatusShow::Type, const String&)> onChangeStatusRequest; + boost::signal<void (StatusShow::Type, const std::string&)> onChangeStatusRequest; boost::signal<void ()> onSignOutRequest; private: diff --git a/Swift/Controllers/UIInterfaces/ProfileWindow.h b/Swift/Controllers/UIInterfaces/ProfileWindow.h index e9c9a63..5d5c754 100644 --- a/Swift/Controllers/UIInterfaces/ProfileWindow.h +++ b/Swift/Controllers/UIInterfaces/ProfileWindow.h @@ -20,7 +20,7 @@ namespace Swift { virtual void setEnabled(bool b) = 0; virtual void setProcessing(bool b) = 0; - virtual void setError(const String&) = 0; + virtual void setError(const std::string&) = 0; virtual void show() = 0; virtual void hide() = 0; diff --git a/Swift/Controllers/UIInterfaces/UserSearchWindow.h b/Swift/Controllers/UIInterfaces/UserSearchWindow.h index e4a665b..0bb7400 100644 --- a/Swift/Controllers/UIInterfaces/UserSearchWindow.h +++ b/Swift/Controllers/UIInterfaces/UserSearchWindow.h @@ -10,7 +10,7 @@ #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swift/Controllers/Chat/UserSearchController.h" diff --git a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h index 9061b07..3cd0947 100644 --- a/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h +++ b/Swift/Controllers/UIInterfaces/XMLConsoleWidget.h @@ -6,15 +6,15 @@ #pragma once -namespace Swift { - class String; +#include <string> +namespace Swift { class XMLConsoleWidget { public: virtual ~XMLConsoleWidget(); - virtual void handleDataRead(const String& data) = 0; - virtual void handleDataWritten(const String& data) = 0; + virtual void handleDataRead(const std::string& data) = 0; + virtual void handleDataWritten(const std::string& data) = 0; virtual void show() = 0; virtual void activate() = 0; diff --git a/Swift/Controllers/UnitTest/MockChatWindow.h b/Swift/Controllers/UnitTest/MockChatWindow.h index 03adcfe..27b9c9e 100644 --- a/Swift/Controllers/UnitTest/MockChatWindow.h +++ b/Swift/Controllers/UnitTest/MockChatWindow.h @@ -14,14 +14,14 @@ namespace Swift { MockChatWindow() {}; virtual ~MockChatWindow(); - virtual String addMessage(const String& message, const String& /*senderName*/, bool /*senderIsSelf*/, const boost::optional<SecurityLabel>& /*label*/, const String& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; - virtual String addAction(const String& message, const String& /*senderName*/, bool /*senderIsSelf*/, const boost::optional<SecurityLabel>& /*label*/, const String& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; - virtual void addSystemMessage(const String& /*message*/) {}; - virtual void addErrorMessage(const String& /*message*/) {}; - virtual void addPresenceMessage(const String& /*message*/) {}; + virtual std::string addMessage(const std::string& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, const boost::optional<SecurityLabel>& /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; + virtual std::string addAction(const std::string& message, const std::string& /*senderName*/, bool /*senderIsSelf*/, const boost::optional<SecurityLabel>& /*label*/, const std::string& /*avatarPath*/, const boost::posix_time::ptime&) {lastMessageBody_ = message; return "";}; + virtual void addSystemMessage(const std::string& /*message*/) {}; + virtual void addErrorMessage(const std::string& /*message*/) {}; + virtual void addPresenceMessage(const std::string& /*message*/) {}; virtual void setContactChatState(ChatState::ChatStateType /*state*/) {}; - virtual void setName(const String& name) {name_ = name;}; + virtual void setName(const std::string& name) {name_ = name;}; virtual void show() {}; virtual void activate() {}; virtual void setAvailableSecurityLabels(const std::vector<SecurityLabel>& labels) {labels_ = labels;}; @@ -33,16 +33,16 @@ namespace Swift { virtual void setInputEnabled(bool /*enabled*/) {}; virtual void setRosterModel(Roster* /*roster*/) {}; virtual void setTabComplete(TabComplete*) {}; - virtual void replaceLastMessage(const Swift::String&) {}; - void setAckState(const String& /*id*/, AckState /*state*/) {}; + virtual void replaceLastMessage(const std::string&) {}; + void setAckState(const std::string& /*id*/, AckState /*state*/) {}; virtual void flash() {}; boost::signal<void ()> onClosed; boost::signal<void ()> onAllMessagesRead; - boost::signal<void (const String&)> onSendMessageRequest; + boost::signal<void (const std::string&)> onSendMessageRequest; - String name_; - String lastMessageBody_; + std::string name_; + std::string lastMessageBody_; std::vector<SecurityLabel> labels_; bool labelsEnabled_; }; diff --git a/Swift/Controllers/UnitTest/MockMainWindow.h b/Swift/Controllers/UnitTest/MockMainWindow.h index 9da5490..afa5c2a 100644 --- a/Swift/Controllers/UnitTest/MockMainWindow.h +++ b/Swift/Controllers/UnitTest/MockMainWindow.h @@ -15,10 +15,10 @@ namespace Swift { MockMainWindow() : roster(NULL) {}; virtual ~MockMainWindow() {}; virtual void setRosterModel(Roster* roster) {this->roster = roster;}; - virtual void setMyNick(const String& /*name*/) {};; + virtual void setMyNick(const std::string& /*name*/) {};; virtual void setMyJID(const JID& /*jid*/) {};; - virtual void setMyAvatarPath(const String& /*path*/) {}; - virtual void setMyStatusText(const String& /*status*/) {}; + virtual void setMyAvatarPath(const std::string& /*path*/) {}; + virtual void setMyStatusText(const std::string& /*status*/) {}; virtual void setMyStatusType(StatusShow::Type /*type*/) {}; virtual void setConnecting() {}; Roster* roster; diff --git a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp index 969555c..42cfc5f 100644 --- a/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp +++ b/Swift/Controllers/UnitTest/PresenceNotifierTest.cpp @@ -165,12 +165,13 @@ class PresenceNotifierTest : public CppUnit::TestFixture { void testNotificationSubjectContainsNameForJIDInRoster() { std::auto_ptr<PresenceNotifier> testling = createNotifier(); - roster->addContact(user1.toBare(), "User 1", std::vector<String>(), RosterItemPayload::Both); + roster->addContact(user1.toBare(), "User 1", std::vector<std::string>(), RosterItemPayload::Both); sendPresence(user1, StatusShow::Online); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].subject.contains("User 1")); + std::string subject = notifier->notifications[0].subject; + CPPUNIT_ASSERT(subject.find("User 1") != std::string::npos); } void testNotificationSubjectContainsJIDForJIDNotInRoster() { @@ -179,7 +180,8 @@ class PresenceNotifierTest : public CppUnit::TestFixture { sendPresence(user1, StatusShow::Online); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].subject.contains(user1.toBare().toString())); + std::string subject = notifier->notifications[0].subject; + CPPUNIT_ASSERT(subject.find(user1.toBare().toString()) != std::string::npos); } void testNotificationSubjectContainsStatus() { @@ -188,7 +190,8 @@ class PresenceNotifierTest : public CppUnit::TestFixture { sendPresence(user1, StatusShow::Away); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].subject.contains("Away")); + std::string subject = notifier->notifications[0].subject; + CPPUNIT_ASSERT(subject.find("Away") != std::string::npos); } void testNotificationMessageContainsStatusMessage() { @@ -197,7 +200,7 @@ class PresenceNotifierTest : public CppUnit::TestFixture { sendPresence(user1, StatusShow::Away); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(notifier->notifications.size())); - CPPUNIT_ASSERT(notifier->notifications[0].description.contains("Status Message")); + CPPUNIT_ASSERT(notifier->notifications[0].description.find("Status Message") != std::string::npos); } void testReceiveFirstPresenceWithQuietPeriodDoesNotNotify() { diff --git a/Swift/Controllers/XMLConsoleController.cpp b/Swift/Controllers/XMLConsoleController.cpp index ce0b24f..a3510d1 100644 --- a/Swift/Controllers/XMLConsoleController.cpp +++ b/Swift/Controllers/XMLConsoleController.cpp @@ -30,13 +30,13 @@ void XMLConsoleController::handleUIEvent(boost::shared_ptr<UIEvent> rawEvent) { } } -void XMLConsoleController::handleDataRead(const String& data) { +void XMLConsoleController::handleDataRead(const std::string& data) { if (xmlConsoleWidget) { xmlConsoleWidget->handleDataRead(data); } } -void XMLConsoleController::handleDataWritten(const String& data) { +void XMLConsoleController::handleDataWritten(const std::string& data) { if (xmlConsoleWidget) { xmlConsoleWidget->handleDataWritten(data); } diff --git a/Swift/Controllers/XMLConsoleController.h b/Swift/Controllers/XMLConsoleController.h index 3e1d990..d12982f 100644 --- a/Swift/Controllers/XMLConsoleController.h +++ b/Swift/Controllers/XMLConsoleController.h @@ -13,7 +13,7 @@ #include "Swift/Controllers/UIEvents/UIEventStream.h" namespace Swift { - class String; + class XMLConsoleWidgetFactory; class XMLConsoleWidget; @@ -23,8 +23,8 @@ namespace Swift { ~XMLConsoleController(); public: - void handleDataRead(const String& data); - void handleDataWritten(const String& data); + void handleDataRead(const std::string& data); + void handleDataWritten(const std::string& data); private: void handleUIEvent(boost::shared_ptr<UIEvent> event); diff --git a/Swift/Controllers/XMPPEvents/ErrorEvent.h b/Swift/Controllers/XMPPEvents/ErrorEvent.h index 3f78109..cbfc471 100644 --- a/Swift/Controllers/XMPPEvents/ErrorEvent.h +++ b/Swift/Controllers/XMPPEvents/ErrorEvent.h @@ -12,20 +12,20 @@ #include <boost/shared_ptr.hpp> #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { class ErrorEvent : public StanzaEvent { public: - ErrorEvent(const JID& jid, const String& text) : jid_(jid), text_(text){}; + ErrorEvent(const JID& jid, const std::string& text) : jid_(jid), text_(text){}; virtual ~ErrorEvent(){}; const JID& getJID() const {return jid_;}; - const String& getText() const {return text_;}; + const std::string& getText() const {return text_;}; private: JID jid_; - String text_; + std::string text_; }; } diff --git a/Swift/Controllers/XMPPEvents/MessageEvent.h b/Swift/Controllers/XMPPEvents/MessageEvent.h index e02995d..d1021dc 100644 --- a/Swift/Controllers/XMPPEvents/MessageEvent.h +++ b/Swift/Controllers/XMPPEvents/MessageEvent.h @@ -25,7 +25,7 @@ namespace Swift { boost::shared_ptr<Message> getStanza() {return stanza_;} bool isReadable() { - return getStanza()->isError() || !getStanza()->getBody().isEmpty(); + return getStanza()->isError() || !getStanza()->getBody().empty(); } void read() { diff --git a/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h index 704a86c..1f7812e 100644 --- a/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h +++ b/Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h @@ -12,16 +12,16 @@ #include <boost/shared_ptr.hpp> #include "Swift/Controllers/XMPPEvents/StanzaEvent.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { class SubscriptionRequestEvent : public StanzaEvent { public: - SubscriptionRequestEvent(const JID& jid, const String& reason) : jid_(jid), reason_(reason){}; + SubscriptionRequestEvent(const JID& jid, const std::string& reason) : jid_(jid), reason_(reason){}; virtual ~SubscriptionRequestEvent(){}; const JID& getJID() const {return jid_;}; - const String& getReason() const {return reason_;}; + const std::string& getReason() const {return reason_;}; boost::signal<void()> onAccept; boost::signal<void()> onDecline; void accept() { @@ -40,7 +40,7 @@ namespace Swift { private: JID jid_; - String reason_; + std::string reason_; }; } diff --git a/Swift/QtUI/ApplicationTest/main.cpp b/Swift/QtUI/ApplicationTest/main.cpp index 4e93452..a5f3820 100644 --- a/Swift/QtUI/ApplicationTest/main.cpp +++ b/Swift/QtUI/ApplicationTest/main.cpp @@ -9,7 +9,7 @@ #include <QVBoxLayout> #include <QLineEdit> #include "../QtSwiftUtil.h" -#include "Swiften/Base/String.h" +#include <string> #include "SwifTools/Application/Platform/PlatformApplication.h" using namespace Swift; diff --git a/Swift/QtUI/EventViewer/QtEvent.cpp b/Swift/QtUI/EventViewer/QtEvent.cpp index 21d713f..f0bc276 100644 --- a/Swift/QtUI/EventViewer/QtEvent.cpp +++ b/Swift/QtUI/EventViewer/QtEvent.cpp @@ -57,8 +57,8 @@ QString QtEvent::text() { } boost::shared_ptr<SubscriptionRequestEvent> subscriptionRequestEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(event_); if (subscriptionRequestEvent) { - String reason = subscriptionRequestEvent->getReason(); - String message = subscriptionRequestEvent->getJID().toBare().toString() + " would like to add you to their roster" + (reason.isEmpty() ? "." : ", saying '" + reason + "'."); + std::string reason = subscriptionRequestEvent->getReason(); + std::string message = subscriptionRequestEvent->getJID().toBare().toString() + " would like to add you to their roster" + (reason.empty() ? "." : ", saying '" + reason + "'."); return P2QSTRING(message); } boost::shared_ptr<ErrorEvent> errorEvent = boost::dynamic_pointer_cast<ErrorEvent>(event_); diff --git a/Swift/QtUI/FreeDesktopNotifier.cpp b/Swift/QtUI/FreeDesktopNotifier.cpp index 1edf19c..037f67b 100644 --- a/Swift/QtUI/FreeDesktopNotifier.cpp +++ b/Swift/QtUI/FreeDesktopNotifier.cpp @@ -18,10 +18,10 @@ namespace Swift { -FreeDesktopNotifier::FreeDesktopNotifier(const String& name) : applicationName(name) { +FreeDesktopNotifier::FreeDesktopNotifier(const std::string& name) : applicationName(name) { } -void FreeDesktopNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()>) { +void FreeDesktopNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()>) { QDBusConnection bus = QDBusConnection::sessionBus(); if (!bus.isConnected()) { return; diff --git a/Swift/QtUI/FreeDesktopNotifier.h b/Swift/QtUI/FreeDesktopNotifier.h index 0bbf6bb..2214a1a 100644 --- a/Swift/QtUI/FreeDesktopNotifier.h +++ b/Swift/QtUI/FreeDesktopNotifier.h @@ -12,12 +12,12 @@ namespace Swift { class FreeDesktopNotifier : public Notifier { public: - FreeDesktopNotifier(const String& name); + FreeDesktopNotifier(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: - String applicationName; + std::string applicationName; QtCachedImageScaler imageScaler; }; } diff --git a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp index bdc121c..1e624b3 100644 --- a/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp +++ b/Swift/QtUI/MUCSearch/QtMUCSearchWindow.cpp @@ -185,7 +185,7 @@ MUCSearchRoomItem* QtMUCSearchWindow::getSelectedRoom() const { } } } - if (lstIndex.empty()) { + if (lstIndex.isEmpty()) { return NULL; } else { diff --git a/Swift/QtUI/NotifierTest/NotifierTest.cpp b/Swift/QtUI/NotifierTest/NotifierTest.cpp index 65641b0..e165993 100644 --- a/Swift/QtUI/NotifierTest/NotifierTest.cpp +++ b/Swift/QtUI/NotifierTest/NotifierTest.cpp @@ -7,14 +7,14 @@ #include <iostream> #include <boost/bind.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Notifier/GrowlNotifier.h" #include <QApplication> using namespace Swift; -void notificationClicked(const String& message) { +void notificationClicked(const std::string& message) { std::cout << "Notification clicked: " << message << std::endl; } diff --git a/Swift/QtUI/QtAvatarWidget.cpp b/Swift/QtUI/QtAvatarWidget.cpp index 941e20e..0879d46 100644 --- a/Swift/QtUI/QtAvatarWidget.cpp +++ b/Swift/QtUI/QtAvatarWidget.cpp @@ -42,7 +42,7 @@ QtAvatarWidget::QtAvatarWidget(QWidget* parent) : QWidget(parent) { layout->addWidget(label); } -void QtAvatarWidget::setAvatar(const ByteArray& data, const String& type) { +void QtAvatarWidget::setAvatar(const ByteArray& data, const std::string& type) { this->data = data; this->type = type; diff --git a/Swift/QtUI/QtAvatarWidget.h b/Swift/QtUI/QtAvatarWidget.h index ce4d192..8830d82 100644 --- a/Swift/QtUI/QtAvatarWidget.h +++ b/Swift/QtUI/QtAvatarWidget.h @@ -18,13 +18,13 @@ namespace Swift { public: QtAvatarWidget(QWidget* parent); - void setAvatar(const ByteArray& data, const String& type); + void setAvatar(const ByteArray& data, const std::string& type); const ByteArray& getAvatarData() const { return data; } - const String& getAvatarType() const { + const std::string& getAvatarType() const { return type; } @@ -32,7 +32,7 @@ namespace Swift { private: ByteArray data; - String type; + std::string type; QLabel* label; }; } diff --git a/Swift/QtUI/QtBookmarkDetailWindow.cpp b/Swift/QtUI/QtBookmarkDetailWindow.cpp index d83e2eb..c0f04e2 100644 --- a/Swift/QtUI/QtBookmarkDetailWindow.cpp +++ b/Swift/QtUI/QtBookmarkDetailWindow.cpp @@ -27,23 +27,23 @@ boost::optional<MUCBookmark> QtBookmarkDetailWindow::createBookmarkFromForm() { //check room //check bookmarkName JID room(Q2PSTRING(room_->text())); - if (!room.isValid() || room.getNode().isEmpty() || !room.getResource().isEmpty()) { + if (!room.isValid() || room.getNode().empty() || !room.getResource().empty()) { QMessageBox::warning(this, "Bookmark not valid", "You must specify a valid room address (e.g. myroom@chats.example.com)."); return boost::optional<MUCBookmark>(); } - String name(Q2PSTRING(name_->text())); - if (name.isEmpty()) { + std::string name(Q2PSTRING(name_->text())); + if (name.empty()) { name = room.toString(); } MUCBookmark bookmark(room, name); - String nick(Q2PSTRING(nick_->text())); - String password(Q2PSTRING(password_->text())); + std::string nick(Q2PSTRING(nick_->text())); + std::string password(Q2PSTRING(password_->text())); bookmark.setAutojoin(autojoin_->isChecked()); - if (!nick.isEmpty()) { + if (!nick.empty()) { bookmark.setNick(nick); } - if (!password.isEmpty()) { + if (!password.empty()) { bookmark.setPassword(password); } return bookmark; diff --git a/Swift/QtUI/QtChatWindow.cpp b/Swift/QtUI/QtChatWindow.cpp index 62a696e..dac9e93 100644 --- a/Swift/QtUI/QtChatWindow.cpp +++ b/Swift/QtUI/QtChatWindow.cpp @@ -233,7 +233,7 @@ QtTabbable::AlertType QtChatWindow::getWidgetAlertState() { return NoActivity; } -void QtChatWindow::setName(const String& name) { +void QtChatWindow::setName(const std::string& name) { contact_ = P2QSTRING(name); updateTitleWithUnreadCount(); } @@ -247,11 +247,11 @@ void QtChatWindow::updateTitleWithUnreadCount() { emit titleUpdated(); } -String QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { return addMessage(message, senderName, senderIsSelf, label, avatarPath, "", time); } -String QtChatWindow::addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const QString& style, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -269,8 +269,8 @@ String QtChatWindow::addMessage(const String &message, const String &senderName, htmlString += styleSpanStart + messageHTML + styleSpanEnd; bool appendToPrevious = !previousMessageWasSystem_ && !previousMessageWasPresence_ && ((senderIsSelf && previousMessageWasSelf_) || (!senderIsSelf && !previousMessageWasSelf_ && previousSenderName_ == P2QSTRING(senderName))); - QString qAvatarPath = avatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(P2QSTRING(avatarPath)).toEncoded(); - String id = id_.generateID(); + QString qAvatarPath = avatarPath.empty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(P2QSTRING(avatarPath)).toEncoded(); + std::string id = id_.generateID(); messageLog_->addMessage(boost::shared_ptr<ChatSnippet>(new MessageSnippet(htmlString, Qt::escape(P2QSTRING(senderName)), B2QDATE(time), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id)))); previousMessageWasSelf_ = senderIsSelf; @@ -284,7 +284,7 @@ void QtChatWindow::flash() { emit requestFlash(); } -void QtChatWindow::setAckState(String const& id, ChatWindow::AckState state) { +void QtChatWindow::setAckState(std::string const& id, ChatWindow::AckState state) { QString xml; switch (state) { case ChatWindow::Pending: xml = "<img src='qrc:/icons/throbber.gif' alt='This message has not been received by your server yet.'/>"; break; @@ -298,11 +298,11 @@ int QtChatWindow::getCount() { return unreadCount_; } -String QtChatWindow::addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time) { +std::string QtChatWindow::addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time) { return addMessage(" *" + message + "*", senderName, senderIsSelf, label, avatarPath, "font-style:italic ", time); } -void QtChatWindow::addErrorMessage(const String& errorMessage) { +void QtChatWindow::addErrorMessage(const std::string& errorMessage) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -316,7 +316,7 @@ void QtChatWindow::addErrorMessage(const String& errorMessage) { previousMessageWasPresence_ = false; } -void QtChatWindow::addSystemMessage(const String& message) { +void QtChatWindow::addSystemMessage(const std::string& message) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -331,7 +331,7 @@ void QtChatWindow::addSystemMessage(const String& message) { previousMessageWasPresence_ = false; } -void QtChatWindow::addPresenceMessage(const String& message) { +void QtChatWindow::addPresenceMessage(const std::string& message) { if (isWidgetSelected()) { onAllMessagesRead(); } @@ -390,7 +390,7 @@ void QtChatWindow::moveEvent(QMoveEvent*) { emit geometryChanged(); } -void QtChatWindow::replaceLastMessage(const String& message) { +void QtChatWindow::replaceLastMessage(const std::string& message) { messageLog_->replaceLastMessage(P2QSTRING(Linkify::linkify(message))); } diff --git a/Swift/QtUI/QtChatWindow.h b/Swift/QtUI/QtChatWindow.h index 20c8685..dbcfe9c 100644 --- a/Swift/QtUI/QtChatWindow.h +++ b/Swift/QtUI/QtChatWindow.h @@ -30,11 +30,11 @@ namespace Swift { public: QtChatWindow(const QString &contact, QtChatTheme* theme, UIEventStream* eventStream); ~QtChatWindow(); - String addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time); - String addAction(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const boost::posix_time::ptime& time); - void addSystemMessage(const String& message); - void addPresenceMessage(const String& message); - void addErrorMessage(const String& errorMessage); + std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time); + std::string addAction(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const boost::posix_time::ptime& time); + void addSystemMessage(const std::string& message); + void addPresenceMessage(const std::string& message); + void addErrorMessage(const std::string& errorMessage); void show(); void activate(); void setUnreadMessageCount(int count); @@ -44,15 +44,15 @@ namespace Swift { void setSecurityLabelsEnabled(bool enabled); void setSecurityLabelsError(); SecurityLabel getSelectedSecurityLabel(); - void setName(const String& name); + void setName(const std::string& name); void setInputEnabled(bool enabled); QtTabbable::AlertType getWidgetAlertState(); void setContactChatState(ChatState::ChatStateType state); void setRosterModel(Roster* roster); void setTabComplete(TabComplete* completer); int getCount(); - void replaceLastMessage(const String& message); - void setAckState(const String& id, AckState state); + void replaceLastMessage(const std::string& message); + void setAckState(const std::string& id, AckState state); void flash(); signals: @@ -75,7 +75,7 @@ namespace Swift { private: void updateTitleWithUnreadCount(); void tabComplete(); - String addMessage(const String &message, const String &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const String& avatarPath, const QString& style, const boost::posix_time::ptime& time); + std::string addMessage(const std::string &message, const std::string &senderName, bool senderIsSelf, const boost::optional<SecurityLabel>& label, const std::string& avatarPath, const QString& style, const boost::posix_time::ptime& time); int unreadCount_; bool contactIsTyping_; diff --git a/Swift/QtUI/QtContactEditWidget.cpp b/Swift/QtUI/QtContactEditWidget.cpp index 1f97a37..e8fe24a 100644 --- a/Swift/QtUI/QtContactEditWidget.cpp +++ b/Swift/QtUI/QtContactEditWidget.cpp @@ -18,7 +18,7 @@ namespace Swift { -QtContactEditWidget::QtContactEditWidget(const std::set<String>& allGroups, QWidget* parent) : QWidget(parent), groups_(NULL) { +QtContactEditWidget::QtContactEditWidget(const std::set<std::string>& allGroups, QWidget* parent) : QWidget(parent), groups_(NULL) { QBoxLayout* layout = new QVBoxLayout(this); setContentsMargins(0,0,0,0); layout->setContentsMargins(0,0,0,0); @@ -43,7 +43,7 @@ QtContactEditWidget::QtContactEditWidget(const std::set<String>& allGroups, QWid groupsArea->setWidget(groups); QVBoxLayout* scrollLayout = new QVBoxLayout(groups); - foreach (String group, allGroups) { + foreach (std::string group, allGroups) { QCheckBox* check = new QCheckBox(groups); check->setText(P2QSTRING(group)); check->setCheckState(Qt::Unchecked); @@ -63,22 +63,22 @@ QtContactEditWidget::QtContactEditWidget(const std::set<String>& allGroups, QWid scrollLayout->addItem(new QSpacerItem(20, 73, QSizePolicy::Minimum, QSizePolicy::Expanding)); } -void QtContactEditWidget::setName(const String& name) { +void QtContactEditWidget::setName(const std::string& name) { name_->setText(P2QSTRING(name)); } -String QtContactEditWidget::getName() const { +std::string QtContactEditWidget::getName() const { return Q2PSTRING(name_->text()); } -void QtContactEditWidget::setSelectedGroups(const std::vector<String>& groups) { - foreach (String group, groups) { +void QtContactEditWidget::setSelectedGroups(const std::vector<std::string>& groups) { + foreach (std::string group, groups) { checkBoxes_[group]->setCheckState(Qt::Checked); } } -std::set<String> QtContactEditWidget::getSelectedGroups() const { - std::set<String> groups; +std::set<std::string> QtContactEditWidget::getSelectedGroups() const { + std::set<std::string> groups; foreach(const CheckBoxMap::value_type& group, checkBoxes_) { if (group.second->checkState() == Qt::Checked) { groups.insert(group.first); diff --git a/Swift/QtUI/QtContactEditWidget.h b/Swift/QtUI/QtContactEditWidget.h index b855b6c..26a9968 100644 --- a/Swift/QtUI/QtContactEditWidget.h +++ b/Swift/QtUI/QtContactEditWidget.h @@ -12,7 +12,7 @@ #include <QWidget> -#include <Swiften/Base/String.h> +#include <string> class QLineEdit; class QCheckBox; @@ -22,16 +22,16 @@ namespace Swift { Q_OBJECT public: - QtContactEditWidget(const std::set<String>& allGroups, QWidget* parent); + QtContactEditWidget(const std::set<std::string>& allGroups, QWidget* parent); - void setName(const String&); - String getName() const; + void setName(const std::string&); + std::string getName() const; - void setSelectedGroups(const std::vector<String>& groups); - std::set<String> getSelectedGroups() const; + void setSelectedGroups(const std::vector<std::string>& groups); + std::set<std::string> getSelectedGroups() const; private: - typedef std::map<String, QCheckBox*> CheckBoxMap; + typedef std::map<std::string, QCheckBox*> CheckBoxMap; CheckBoxMap checkBoxes_; QLineEdit* name_; QWidget* groups_; diff --git a/Swift/QtUI/QtContactEditWindow.cpp b/Swift/QtUI/QtContactEditWindow.cpp index 0781f64..97b8f95 100644 --- a/Swift/QtUI/QtContactEditWindow.cpp +++ b/Swift/QtUI/QtContactEditWindow.cpp @@ -47,7 +47,7 @@ QtContactEditWindow::QtContactEditWindow() : contactEditWidget_(NULL) { buttonLayout->addWidget(okButton); } -void QtContactEditWindow::setContact(const JID& jid, const String& name, const std::vector<String>& groups, const std::set<String>& allGroups) { +void QtContactEditWindow::setContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, const std::set<std::string>& allGroups) { delete contactEditWidget_; jid_ = jid; jidLabel_->setText("<b>" + P2QSTRING(jid.toString()) + "</b>"); diff --git a/Swift/QtUI/QtContactEditWindow.h b/Swift/QtUI/QtContactEditWindow.h index 25ea9b7..2d283de 100644 --- a/Swift/QtUI/QtContactEditWindow.h +++ b/Swift/QtUI/QtContactEditWindow.h @@ -9,7 +9,7 @@ #include <QWidget> #include <Swift/Controllers/UIInterfaces/ContactEditWindow.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> class QLabel; @@ -24,7 +24,7 @@ namespace Swift { public: QtContactEditWindow(); - virtual void setContact(const JID& jid, const String& name, const std::vector<String>& groups, const std::set<String>& allGroups); + virtual void setContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, const std::set<std::string>& allGroups); void setEnabled(bool); void show(); diff --git a/Swift/QtUI/QtJoinMUCWindow.cpp b/Swift/QtUI/QtJoinMUCWindow.cpp index 60558ad..5ffc34d 100644 --- a/Swift/QtUI/QtJoinMUCWindow.cpp +++ b/Swift/QtUI/QtJoinMUCWindow.cpp @@ -39,12 +39,12 @@ void QtJoinMUCWindow::handleSearch() { onSearchMUC(); } -void QtJoinMUCWindow::setNick(const String& nick) { +void QtJoinMUCWindow::setNick(const std::string& nick) { ui.nickName->setText(P2QSTRING(nick)); lastSetNick = nick; } -void QtJoinMUCWindow::setMUC(const String& nick) { +void QtJoinMUCWindow::setMUC(const std::string& nick) { ui.room->setText(P2QSTRING(nick)); } diff --git a/Swift/QtUI/QtJoinMUCWindow.h b/Swift/QtUI/QtJoinMUCWindow.h index 2d12319..6e8e846 100644 --- a/Swift/QtUI/QtJoinMUCWindow.h +++ b/Swift/QtUI/QtJoinMUCWindow.h @@ -6,7 +6,7 @@ #pragma once -#include <Swiften/Base/String.h> +#include <string> #include <Swift/Controllers/UIInterfaces/JoinMUCWindow.h> #include <Swift/QtUI/ui_QtJoinMUCWindow.h> @@ -16,8 +16,8 @@ namespace Swift { public: QtJoinMUCWindow(); - virtual void setNick(const String& nick); - virtual void setMUC(const String& nick); + virtual void setNick(const std::string& nick); + virtual void setMUC(const std::string& nick); virtual void show(); @@ -27,6 +27,6 @@ namespace Swift { private: Ui::QtJoinMUCWindow ui; - String lastSetNick; + std::string lastSetNick; }; } diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index c3fdac2..aae11d1 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -215,7 +215,7 @@ void QtLoginWindow::handleUIEvent(boost::shared_ptr<UIEvent> event) { } } -void QtLoginWindow::selectUser(const String& username) { +void QtLoginWindow::selectUser(const std::string& username) { for (int i = 0; i < usernames_.count(); i++) { if (P2QSTRING(username) == usernames_[i]) { username_->setCurrentIndex(i); @@ -225,7 +225,7 @@ void QtLoginWindow::selectUser(const String& username) { } } -void QtLoginWindow::removeAvailableAccount(const String& jid) { +void QtLoginWindow::removeAvailableAccount(const std::string& jid) { QString username = P2QSTRING(jid); int index = -1; for (int i = 0; i < usernames_.count(); i++) { @@ -241,7 +241,7 @@ void QtLoginWindow::removeAvailableAccount(const String& jid) { } } -void QtLoginWindow::addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) { +void QtLoginWindow::addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate) { QString username = P2QSTRING(defaultJID); int index = -1; for (int i = 0; i < usernames_.count(); i++) { @@ -371,8 +371,8 @@ void QtLoginWindow::morphInto(MainWindow *mainWindow) { } } -void QtLoginWindow::setMessage(const String& message) { - if (!message.isEmpty()) { +void QtLoginWindow::setMessage(const std::string& message) { + if (!message.empty()) { message_->setText("<center><font color=\"red\">" + P2QSTRING(message) + "</font></center>"); } else { @@ -406,7 +406,7 @@ void QtLoginWindow::moveEvent(QMoveEvent*) { emit geometryChanged(); } -bool QtLoginWindow::askUserToTrustCertificatePermanently(const String& message, Certificate::ref certificate) { +bool QtLoginWindow::askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate) { QMessageBox dialog(this); dialog.setText("The certificate presented by the server is not valid."); diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 6987906..3f3b5f8 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -32,13 +32,13 @@ namespace Swift { void morphInto(MainWindow *mainWindow); virtual void loggedOut(); - virtual void setMessage(const String& message); - virtual void addAvailableAccount(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate); - virtual void removeAvailableAccount(const String& jid); + virtual void setMessage(const std::string& message); + virtual void addAvailableAccount(const std::string& defaultJID, const std::string& defaultPassword, const std::string& defaultCertificate); + virtual void removeAvailableAccount(const std::string& jid); virtual void setLoginAutomatically(bool loginAutomatically); virtual void setIsLoggingIn(bool loggingIn); - void selectUser(const String& user); - bool askUserToTrustCertificatePermanently(const String& message, Certificate::ref certificate); + void selectUser(const std::string& user); + bool askUserToTrustCertificatePermanently(const std::string& message, Certificate::ref certificate); void hide(); virtual void quit(); diff --git a/Swift/QtUI/QtMainWindow.cpp b/Swift/QtUI/QtMainWindow.cpp index 2fd5700..6ebd8aa 100644 --- a/Swift/QtUI/QtMainWindow.cpp +++ b/Swift/QtUI/QtMainWindow.cpp @@ -175,7 +175,7 @@ void QtMainWindow::handleShowOfflineToggled(bool state) { } } -void QtMainWindow::setMyNick(const String& nick) { +void QtMainWindow::setMyNick(const std::string& nick) { meView_->setNick(P2QSTRING(nick)); } @@ -183,11 +183,11 @@ void QtMainWindow::setMyJID(const JID& jid) { meView_->setJID(P2QSTRING(jid.toBare().toString())); } -void QtMainWindow::setMyAvatarPath(const String& path) { +void QtMainWindow::setMyAvatarPath(const std::string& path) { meView_->setAvatar(P2QSTRING(path)); } -void QtMainWindow::setMyStatusText(const String& status) { +void QtMainWindow::setMyStatusText(const std::string& status) { meView_->setStatusText(P2QSTRING(status)); } diff --git a/Swift/QtUI/QtMainWindow.h b/Swift/QtUI/QtMainWindow.h index 66b0caf..0dc9d36 100644 --- a/Swift/QtUI/QtMainWindow.h +++ b/Swift/QtUI/QtMainWindow.h @@ -37,10 +37,10 @@ namespace Swift { QtMainWindow(QtSettingsProvider*, UIEventStream* eventStream); ~QtMainWindow(); std::vector<QMenu*> getMenus() {return menus_;} - void setMyNick(const String& name); + void setMyNick(const std::string& name); void setMyJID(const JID& jid); - void setMyAvatarPath(const String& path); - void setMyStatusText(const String& status); + void setMyAvatarPath(const std::string& path); + void setMyStatusText(const std::string& status); void setMyStatusType(StatusShow::Type type); void setConnecting(); QtEventWindow* getEventWindow(); diff --git a/Swift/QtUI/QtProfileWindow.cpp b/Swift/QtUI/QtProfileWindow.cpp index 0a53f11..c4fe400 100644 --- a/Swift/QtUI/QtProfileWindow.cpp +++ b/Swift/QtUI/QtProfileWindow.cpp @@ -118,8 +118,8 @@ void QtProfileWindow::handleSave() { onVCardChangeRequest(vcard); } -void QtProfileWindow::setError(const String& error) { - if (!error.isEmpty()) { +void QtProfileWindow::setError(const std::string& error) { + if (!error.empty()) { errorLabel->setText("<font color='red'>" + P2QSTRING(error) + "</font>"); } else { diff --git a/Swift/QtUI/QtProfileWindow.h b/Swift/QtUI/QtProfileWindow.h index 1ad73e8..edb9cce 100644 --- a/Swift/QtUI/QtProfileWindow.h +++ b/Swift/QtUI/QtProfileWindow.h @@ -26,7 +26,7 @@ namespace Swift { void setVCard(Swift::VCard::ref); void setEnabled(bool); void setProcessing(bool); - virtual void setError(const String&); + virtual void setError(const std::string&); void show(); void hide(); diff --git a/Swift/QtUI/QtRosterHeader.h b/Swift/QtUI/QtRosterHeader.h index 0dc611d..3380610 100644 --- a/Swift/QtUI/QtRosterHeader.h +++ b/Swift/QtUI/QtRosterHeader.h @@ -12,7 +12,7 @@ #include <QSize> #include <QToolBar> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/StatusShow.h" #include "QtTextEdit.h" diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp index 4bddce3..4a8a868 100644 --- a/Swift/QtUI/QtSettingsProvider.cpp +++ b/Swift/QtUI/QtSettingsProvider.cpp @@ -18,35 +18,35 @@ QtSettingsProvider::~QtSettingsProvider() { } -String QtSettingsProvider::getStringSetting(const String &settingPath) { +std::string QtSettingsProvider::getStringSetting(const std::string &settingPath) { QVariant setting = settings_.value(P2QSTRING(settingPath)); return setting.isNull() ? "" : Q2PSTRING(setting.toString()); } -void QtSettingsProvider::storeString(const String &settingPath, const String &settingValue) { +void QtSettingsProvider::storeString(const std::string &settingPath, const std::string &settingValue) { settings_.setValue(P2QSTRING(settingPath), P2QSTRING(settingValue)); } -bool QtSettingsProvider::getBoolSetting(const String &settingPath, bool defaultValue) { +bool QtSettingsProvider::getBoolSetting(const std::string &settingPath, bool defaultValue) { QVariant setting = settings_.value(P2QSTRING(settingPath)); return setting.isNull() ? defaultValue : setting.toBool(); } -void QtSettingsProvider::storeBool(const String &settingPath, bool settingValue) { +void QtSettingsProvider::storeBool(const std::string &settingPath, bool settingValue) { settings_.setValue(P2QSTRING(settingPath), settingValue); } -int QtSettingsProvider::getIntSetting(const String &settingPath, int defaultValue) { +int QtSettingsProvider::getIntSetting(const std::string &settingPath, int defaultValue) { QVariant setting = settings_.value(P2QSTRING(settingPath)); return setting.isNull() ? defaultValue : setting.toInt(); } -void QtSettingsProvider::storeInt(const String &settingPath, int settingValue) { +void QtSettingsProvider::storeInt(const std::string &settingPath, int settingValue) { settings_.setValue(P2QSTRING(settingPath), settingValue); } -std::vector<String> QtSettingsProvider::getAvailableProfiles() { - std::vector<String> profiles; +std::vector<std::string> QtSettingsProvider::getAvailableProfiles() { + std::vector<std::string> profiles; QVariant profilesVariant = settings_.value("profileList"); foreach(QString profileQString, profilesVariant.toStringList()) { profiles.push_back(Q2PSTRING(profileQString)); @@ -54,13 +54,13 @@ std::vector<String> QtSettingsProvider::getAvailableProfiles() { return profiles; } -void QtSettingsProvider::createProfile(const String& profile) { +void QtSettingsProvider::createProfile(const std::string& profile) { QStringList stringList = settings_.value("profileList").toStringList(); stringList.append(P2QSTRING(profile)); settings_.setValue("profileList", stringList); } -void QtSettingsProvider::removeProfile(const String& profile) { +void QtSettingsProvider::removeProfile(const std::string& profile) { QString profileStart(P2QSTRING(profile) + ":"); foreach (QString key, settings_.allKeys()) { if (key.startsWith(profileStart)) { diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h index d1dbc5e..ca05fe1 100644 --- a/Swift/QtUI/QtSettingsProvider.h +++ b/Swift/QtUI/QtSettingsProvider.h @@ -17,15 +17,15 @@ class QtSettingsProvider : public SettingsProvider { public: QtSettingsProvider(); virtual ~QtSettingsProvider(); - virtual String getStringSetting(const String &settingPath); - virtual void storeString(const String &settingPath, const String &settingValue); - virtual bool getBoolSetting(const String &settingPath, bool defaultValue); - virtual void storeBool(const String &settingPath, bool settingValue); - virtual int getIntSetting(const String &settingPath, int defaultValue); - virtual void storeInt(const String &settingPath, int settingValue); - virtual std::vector<String> getAvailableProfiles(); - virtual void createProfile(const String& profile); - virtual void removeProfile(const String& profile); + virtual std::string getStringSetting(const std::string &settingPath); + virtual void storeString(const std::string &settingPath, const std::string &settingValue); + virtual bool getBoolSetting(const std::string &settingPath, bool defaultValue); + virtual void storeBool(const std::string &settingPath, bool settingValue); + virtual int getIntSetting(const std::string &settingPath, int defaultValue); + virtual void storeInt(const std::string &settingPath, int settingValue); + virtual std::vector<std::string> getAvailableProfiles(); + virtual void createProfile(const std::string& profile); + virtual void removeProfile(const std::string& profile); QSettings* getQSettings(); private: QSettings settings_; diff --git a/Swift/QtUI/QtSoundPlayer.cpp b/Swift/QtUI/QtSoundPlayer.cpp index b967cef..387c6f3 100644 --- a/Swift/QtUI/QtSoundPlayer.cpp +++ b/Swift/QtUI/QtSoundPlayer.cpp @@ -24,7 +24,7 @@ void QtSoundPlayer::playSound(SoundEffect sound) { } } -void QtSoundPlayer::playSound(const String& soundResource) { +void QtSoundPlayer::playSound(const std::string& soundResource) { boost::filesystem::path resourcePath = applicationPathProvider->getResourcePath(soundResource); if (boost::filesystem::exists(resourcePath)) { QSound::play(resourcePath.string().c_str()); diff --git a/Swift/QtUI/QtSoundPlayer.h b/Swift/QtUI/QtSoundPlayer.h index 21ad8bb..6945f45 100644 --- a/Swift/QtUI/QtSoundPlayer.h +++ b/Swift/QtUI/QtSoundPlayer.h @@ -12,7 +12,7 @@ namespace Swift { class ApplicationPathProvider; - class String; + class QtSoundPlayer : public QObject, public SoundPlayer { Q_OBJECT @@ -22,7 +22,7 @@ namespace Swift { void playSound(SoundEffect sound); private: - void playSound(const String& soundResource); + void playSound(const std::string& soundResource); private: ApplicationPathProvider* applicationPathProvider; diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index 1c14dee..d4c306f 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -22,7 +22,7 @@ #include "SwifTools/Application/PlatformApplicationPathProvider.h" #include "Swiften/Avatars/AvatarFileStorage.h" #include "Swiften/Disco/CapsFileStorage.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/Platform.h" #include "Swift/Controllers/FileStoragesFactory.h" #include "Swiften/Elements/Presence.h" diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index cc9eb38..978fa14 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -11,7 +11,7 @@ #include <Swiften/TLS/PlatformTLSFactories.h> #include <Swiften/Network/BoostNetworkFactories.h> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/Platform.h" #include "Swiften/EventLoop/Qt/QtEventLoop.h" #include "QtSettingsProvider.h" diff --git a/Swift/QtUI/QtSwiftUtil.h b/Swift/QtUI/QtSwiftUtil.h index 3f1ad3b..60a9f18 100644 --- a/Swift/QtUI/QtSwiftUtil.h +++ b/Swift/QtUI/QtSwiftUtil.h @@ -7,8 +7,8 @@ #ifndef SWIFT_QtSwiftUtil_H #define SWIFT_QtSwiftUtil_H -#define P2QSTRING(a) QString::fromUtf8(a.getUTF8Data()) -#define Q2PSTRING(a) Swift::String(a.toUtf8()) +#define P2QSTRING(a) QString::fromUtf8(a.c_str()) +#define Q2PSTRING(a) std::string(a.toUtf8()) #define B2QDATE(a) QDateTime::fromTime_t((a - boost::posix_time::from_time_t(0)).total_seconds()) diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp index 57e1278..42c8a8f 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.cpp +++ b/Swift/QtUI/QtXMLConsoleWidget.cpp @@ -14,7 +14,7 @@ #include <QCheckBox> #include "QtSwiftUtil.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { @@ -71,15 +71,15 @@ void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) { event->accept(); } -void QtXMLConsoleWidget::handleDataRead(const String& data) { +void QtXMLConsoleWidget::handleDataRead(const std::string& data) { appendTextIfEnabled("<!-- IN -->\n" + data + "\n", QColor(33,98,33)); } -void QtXMLConsoleWidget::handleDataWritten(const String& data) { +void QtXMLConsoleWidget::handleDataWritten(const std::string& data) { appendTextIfEnabled("<!-- OUT -->\n" + data + "\n", QColor(155,1,0)); } -void QtXMLConsoleWidget::appendTextIfEnabled(const String& data, const QColor& color) { +void QtXMLConsoleWidget::appendTextIfEnabled(const std::string& data, const QColor& color) { if (enabled->isChecked()) { QScrollBar* scrollBar = textEdit->verticalScrollBar(); bool scrollToBottom = (!scrollBar || scrollBar->value() == scrollBar->maximum()); diff --git a/Swift/QtUI/QtXMLConsoleWidget.h b/Swift/QtUI/QtXMLConsoleWidget.h index 1cfe54f..a345495 100644 --- a/Swift/QtUI/QtXMLConsoleWidget.h +++ b/Swift/QtUI/QtXMLConsoleWidget.h @@ -23,14 +23,14 @@ namespace Swift { void show(); void activate(); - virtual void handleDataRead(const String& data); - virtual void handleDataWritten(const String& data); + virtual void handleDataRead(const std::string& data); + virtual void handleDataWritten(const std::string& data); private: virtual void closeEvent(QCloseEvent* event); virtual void showEvent(QShowEvent* event); - void appendTextIfEnabled(const String& data, const QColor& color); + void appendTextIfEnabled(const std::string& data, const QColor& color); private: QTextEdit* textEdit; diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp index 97b2028..fcd8691 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp @@ -20,18 +20,18 @@ QtTreeWidgetItem::QtTreeWidgetItem(QtTreeWidgetItem* parentItem) : QObject(), te } -void QtTreeWidgetItem::setText(const String& text) { +void QtTreeWidgetItem::setText(const std::string& text) { displayName_ = P2QSTRING(text); displayNameLower_ = displayName_.toLower(); emit changed(this); } -void QtTreeWidgetItem::setStatusText(const String& text) { +void QtTreeWidgetItem::setStatusText(const std::string& text) { statusText_ = P2QSTRING(text); emit changed(this); } -void QtTreeWidgetItem::setAvatarPath(const String& path) { +void QtTreeWidgetItem::setAvatarPath(const std::string& path) { avatar_ = QIcon(P2QSTRING(path)); emit changed(this); } diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.h b/Swift/QtUI/Roster/QtTreeWidgetItem.h index c042ae0..a2d0cdd 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.h +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.h @@ -10,7 +10,7 @@ #include <QColor> #include <QVariant> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Roster/TreeWidgetFactory.h" #include "Swiften/Roster/TreeWidget.h" #include "Swiften/Roster/TreeWidgetItem.h" @@ -43,9 +43,9 @@ class QtTreeWidgetItem : public QObject, public TreeWidgetItem { QVariant data(int role); QIcon getPresenceIcon(); QtTreeWidgetItem(QtTreeWidgetItem* parentItem); - void setText(const String& text); - void setAvatarPath(const String& path); - void setStatusText(const String& text); + void setText(const std::string& text); + void setAvatarPath(const std::string& path); + void setStatusText(const std::string& text); void setStatusShow(StatusShow::Type show); void setTextColor(unsigned long color); void setBackgroundColor(unsigned long color); diff --git a/Swift/QtUI/Roster/RosterModel.cpp b/Swift/QtUI/Roster/RosterModel.cpp index 95452c8..306b76f 100644 --- a/Swift/QtUI/Roster/RosterModel.cpp +++ b/Swift/QtUI/Roster/RosterModel.cpp @@ -137,9 +137,9 @@ QString RosterModel::getToolTip(RosterItem* item) const { QIcon RosterModel::getAvatar(RosterItem* item) const { ContactRosterItem* contact = dynamic_cast<ContactRosterItem*>(item); if (!contact) return QIcon(); - String path = contact->getAvatarPath(); + std::string path = contact->getAvatarPath(); - return path.isEmpty() ? QIcon() : QIcon(P2QSTRING(path)); + return path.empty() ? QIcon() : QIcon(P2QSTRING(path)); } QString RosterModel::getStatusText(RosterItem* item) const { diff --git a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp index ad06654..c6fb004 100644 --- a/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp +++ b/Swift/QtUI/UserSearch/QtUserSearchWindow.cpp @@ -209,7 +209,7 @@ void QtUserSearchWindow::show() { // //void QtUserSearchWindow::handleOkClicked() { // JID contact = JID(Q2PSTRING(jid_->text())); -// String nick = Q2PSTRING(nickName_->text()); +// std::string nick = Q2PSTRING(nickName_->text()); // if (addToRoster_->isChecked()) { // boost::shared_ptr<UIEvent> event(new AddContactUIEvent(contact, nick)); // eventStream_->send(event); diff --git a/Swift/QtUI/UserSearch/UserSearchModel.cpp b/Swift/QtUI/UserSearch/UserSearchModel.cpp index 1187c29..aafd789 100644 --- a/Swift/QtUI/UserSearch/UserSearchModel.cpp +++ b/Swift/QtUI/UserSearch/UserSearchModel.cpp @@ -46,12 +46,12 @@ QVariant UserSearchModel::data(UserSearchResult* item, int role) { QString UserSearchModel::nameLine(UserSearchResult* item) { QString result; - const std::map<String, String> fields = item->getFields(); - std::map<String, String>::const_iterator first = fields.find("first"); + const std::map<std::string, std::string> fields = item->getFields(); + std::map<std::string, std::string>::const_iterator first = fields.find("first"); if (first != fields.end()) { result += P2QSTRING((*first).second); } - std::map<String, String>::const_iterator last = fields.find("last"); + std::map<std::string, std::string>::const_iterator last = fields.find("last"); if (last != fields.end()) { if (!result.isEmpty()) { result += " "; diff --git a/Swift/QtUI/WindowsNotifier.cpp b/Swift/QtUI/WindowsNotifier.cpp index 9646b90..49489a3 100644 --- a/Swift/QtUI/WindowsNotifier.cpp +++ b/Swift/QtUI/WindowsNotifier.cpp @@ -16,7 +16,7 @@ namespace Swift { -WindowsNotifier::WindowsNotifier(const String& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray) : tray(tray) { +WindowsNotifier::WindowsNotifier(const std::string& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray) : tray(tray) { notifierWindow = new QtWin32NotifierWindow(); snarlNotifier = new SnarlNotifier(name, notifierWindow, icon); connect(tray, SIGNAL(messageClicked()), SLOT(handleMessageClicked())); @@ -27,7 +27,7 @@ WindowsNotifier::~WindowsNotifier() { delete notifierWindow; } -void WindowsNotifier::showMessage(Type type, const String& subject, const String& description, const boost::filesystem::path& picture, boost::function<void()> callback) { +void WindowsNotifier::showMessage(Type type, const std::string& subject, const std::string& description, const boost::filesystem::path& picture, boost::function<void()> callback) { if (snarlNotifier->isAvailable()) { snarlNotifier->showMessage(type, subject, description, picture, callback); return; diff --git a/Swift/QtUI/WindowsNotifier.h b/Swift/QtUI/WindowsNotifier.h index dbf86a2..062b76f 100644 --- a/Swift/QtUI/WindowsNotifier.h +++ b/Swift/QtUI/WindowsNotifier.h @@ -19,10 +19,10 @@ namespace Swift { Q_OBJECT public: - WindowsNotifier(const String& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray); + WindowsNotifier(const std::string& name, const boost::filesystem::path& icon, QSystemTrayIcon* tray); ~WindowsNotifier(); - 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 slots: void handleMessageClicked(); diff --git a/Swift/QtUI/tmp/QtRosterContextMenu.cpp b/Swift/QtUI/tmp/QtRosterContextMenu.cpp index a59a2f7..c8375ba 100644 --- a/Swift/QtUI/tmp/QtRosterContextMenu.cpp +++ b/Swift/QtUI/tmp/QtRosterContextMenu.cpp @@ -18,7 +18,7 @@ #include "Swiften/Roster/ContactRosterItem.h" #include "Swiften/Roster/GroupRosterItem.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Roster/Roster.h" #include "Swift/Controllers/UIEvents/UIEvent.h" #include "Swift/Controllers/UIEvents/RemoveRosterItemUIEvent.h" @@ -92,8 +92,8 @@ void QtRosterContextMenu::handleRenameGroup() { bool ok; QString newName = QInputDialog::getText(NULL, "Rename group", "New name for " + P2QSTRING(item_->getDisplayName()), QLineEdit::Normal, P2QSTRING(item_->getDisplayName()), &ok); if (ok) { - std::vector<String> addedGroups; - std::vector<String> removedGroups; + std::vector<std::string> addedGroups; + std::vector<std::string> removedGroups; addedGroups.push_back(Q2PSTRING(newName)); removedGroups.push_back(group->getDisplayName()); foreach (RosterItem* child, group->getChildren()) { diff --git a/Swiften/Avatars/AvatarFileStorage.cpp b/Swiften/Avatars/AvatarFileStorage.cpp index f76adee..046ac16 100644 --- a/Swiften/Avatars/AvatarFileStorage.cpp +++ b/Swiften/Avatars/AvatarFileStorage.cpp @@ -14,11 +14,11 @@ namespace Swift { AvatarFileStorage::AvatarFileStorage(const boost::filesystem::path& path) : path_(path) { } -bool AvatarFileStorage::hasAvatar(const String& hash) const { +bool AvatarFileStorage::hasAvatar(const std::string& hash) const { return boost::filesystem::exists(getAvatarPath(hash)); } -void AvatarFileStorage::addAvatar(const String& hash, const ByteArray& avatar) { +void AvatarFileStorage::addAvatar(const std::string& hash, const ByteArray& avatar) { boost::filesystem::path avatarPath = getAvatarPath(hash); if (!boost::filesystem::exists(avatarPath.parent_path())) { try { @@ -33,11 +33,11 @@ void AvatarFileStorage::addAvatar(const String& hash, const ByteArray& avatar) { file.close(); } -boost::filesystem::path AvatarFileStorage::getAvatarPath(const String& hash) const { - return path_ / hash.getUTF8String(); +boost::filesystem::path AvatarFileStorage::getAvatarPath(const std::string& hash) const { + return path_ / hash; } -ByteArray AvatarFileStorage::getAvatar(const String& hash) const { +ByteArray AvatarFileStorage::getAvatar(const std::string& hash) const { ByteArray data; data.readFromFile(getAvatarPath(hash).string()); return data; diff --git a/Swiften/Avatars/AvatarFileStorage.h b/Swiften/Avatars/AvatarFileStorage.h index 5ade779..e803430 100644 --- a/Swiften/Avatars/AvatarFileStorage.h +++ b/Swiften/Avatars/AvatarFileStorage.h @@ -9,7 +9,7 @@ #include <map> #include <boost/filesystem.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Avatars/AvatarStorage.h" @@ -18,11 +18,11 @@ namespace Swift { public: AvatarFileStorage(const boost::filesystem::path& path); - virtual bool hasAvatar(const String& hash) const; - virtual void addAvatar(const String& hash, const ByteArray& avatar); - virtual ByteArray getAvatar(const String& hash) const; + virtual bool hasAvatar(const std::string& hash) const; + virtual void addAvatar(const std::string& hash, const ByteArray& avatar); + virtual ByteArray getAvatar(const std::string& hash) const; - virtual boost::filesystem::path getAvatarPath(const String& hash) const; + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const; private: boost::filesystem::path path_; diff --git a/Swiften/Avatars/AvatarManagerImpl.cpp b/Swiften/Avatars/AvatarManagerImpl.cpp index 9813aed..6b77f8d 100644 --- a/Swiften/Avatars/AvatarManagerImpl.cpp +++ b/Swiften/Avatars/AvatarManagerImpl.cpp @@ -33,16 +33,16 @@ AvatarManagerImpl::~AvatarManagerImpl() { } boost::filesystem::path AvatarManagerImpl::getAvatarPath(const JID& jid) const { - String hash = combinedAvatarProvider.getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = combinedAvatarProvider.getAvatarHash(jid); + if (!hash.empty()) { return avatarStorage->getAvatarPath(hash); } return boost::filesystem::path(); } ByteArray AvatarManagerImpl::getAvatar(const JID& jid) const { - String hash = combinedAvatarProvider.getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = combinedAvatarProvider.getAvatarHash(jid); + if (!hash.empty()) { return avatarStorage->getAvatar(hash); } return ByteArray(); diff --git a/Swiften/Avatars/AvatarMemoryStorage.h b/Swiften/Avatars/AvatarMemoryStorage.h index 6f1ba49..3fa770a 100644 --- a/Swiften/Avatars/AvatarMemoryStorage.h +++ b/Swiften/Avatars/AvatarMemoryStorage.h @@ -8,25 +8,25 @@ #include <map> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Avatars/AvatarStorage.h" namespace Swift { class AvatarMemoryStorage : public AvatarStorage { public: - virtual bool hasAvatar(const String& hash) const { return avatars.find(hash) != avatars.end(); } - virtual void addAvatar(const String& hash, const ByteArray& avatar) { avatars[hash] = avatar; } - virtual ByteArray getAvatar(const String& hash) const { - std::map<String, ByteArray>::const_iterator i = avatars.find(hash); + virtual bool hasAvatar(const std::string& hash) const { return avatars.find(hash) != avatars.end(); } + virtual void addAvatar(const std::string& hash, const ByteArray& avatar) { avatars[hash] = avatar; } + virtual ByteArray getAvatar(const std::string& hash) const { + std::map<std::string, ByteArray>::const_iterator i = avatars.find(hash); return i == avatars.end() ? ByteArray() : i->second; } - virtual boost::filesystem::path getAvatarPath(const String& hash) const { - return boost::filesystem::path("/avatars") / hash.getUTF8String(); + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const { + return boost::filesystem::path("/avatars") / hash; } private: - std::map<String, ByteArray> avatars; + std::map<std::string, ByteArray> avatars; }; } diff --git a/Swiften/Avatars/AvatarProvider.h b/Swiften/Avatars/AvatarProvider.h index b953ad3..0f66904 100644 --- a/Swiften/Avatars/AvatarProvider.h +++ b/Swiften/Avatars/AvatarProvider.h @@ -7,7 +7,7 @@ #pragma once #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class JID; @@ -16,7 +16,7 @@ namespace Swift { public: virtual ~AvatarProvider(); - virtual String getAvatarHash(const JID&) const = 0; + virtual std::string getAvatarHash(const JID&) const = 0; boost::signal<void (const JID&)> onAvatarChanged; }; diff --git a/Swiften/Avatars/AvatarStorage.h b/Swiften/Avatars/AvatarStorage.h index d699f40..826a648 100644 --- a/Swiften/Avatars/AvatarStorage.h +++ b/Swiften/Avatars/AvatarStorage.h @@ -9,17 +9,17 @@ #include <boost/filesystem.hpp> namespace Swift { - class String; + class ByteArray; class AvatarStorage { public: virtual ~AvatarStorage(); - virtual bool hasAvatar(const String& hash) const = 0; - virtual void addAvatar(const String& hash, const ByteArray& avatar) = 0; - virtual ByteArray getAvatar(const String& hash) const = 0; - virtual boost::filesystem::path getAvatarPath(const String& hash) const = 0; + virtual bool hasAvatar(const std::string& hash) const = 0; + virtual void addAvatar(const std::string& hash, const ByteArray& avatar) = 0; + virtual ByteArray getAvatar(const std::string& hash) const = 0; + virtual boost::filesystem::path getAvatarPath(const std::string& hash) const = 0; }; } diff --git a/Swiften/Avatars/CombinedAvatarProvider.cpp b/Swiften/Avatars/CombinedAvatarProvider.cpp index 4f0b04a..6ac31e3 100644 --- a/Swiften/Avatars/CombinedAvatarProvider.cpp +++ b/Swiften/Avatars/CombinedAvatarProvider.cpp @@ -11,14 +11,14 @@ namespace Swift { -String CombinedAvatarProvider::getAvatarHash(const JID& jid) const { +std::string CombinedAvatarProvider::getAvatarHash(const JID& jid) const { for (size_t i = 0; i < providers.size(); ++i) { - String hash = providers[i]->getAvatarHash(jid); - if (!hash.isEmpty()) { + std::string hash = providers[i]->getAvatarHash(jid); + if (!hash.empty()) { return hash; } } - return String(); + return std::string(); } void CombinedAvatarProvider::addProvider(AvatarProvider* provider) { @@ -35,11 +35,11 @@ void CombinedAvatarProvider::removeProvider(AvatarProvider* provider) { } void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) { - String hash = getAvatarHash(jid); - std::map<JID, String>::iterator i = avatars.find(jid); + std::string hash = getAvatarHash(jid); + std::map<JID, std::string>::iterator i = avatars.find(jid); if (i != avatars.end()) { if (i->second != hash) { - if (hash.isEmpty()) { + if (hash.empty()) { avatars.erase(i); } else { @@ -48,7 +48,7 @@ void CombinedAvatarProvider::handleAvatarChanged(const JID& jid) { onAvatarChanged(jid); } } - else if (!hash.isEmpty()) { + else if (!hash.empty()) { avatars.insert(std::make_pair(jid, hash)); onAvatarChanged(jid); } diff --git a/Swiften/Avatars/CombinedAvatarProvider.h b/Swiften/Avatars/CombinedAvatarProvider.h index fbd6ce7..9c83732 100644 --- a/Swiften/Avatars/CombinedAvatarProvider.h +++ b/Swiften/Avatars/CombinedAvatarProvider.h @@ -15,7 +15,7 @@ namespace Swift { class CombinedAvatarProvider : public AvatarProvider { public: - virtual String getAvatarHash(const JID&) const; + virtual std::string getAvatarHash(const JID&) const; void addProvider(AvatarProvider*); void removeProvider(AvatarProvider*); @@ -25,6 +25,6 @@ namespace Swift { private: std::vector<AvatarProvider*> providers; - std::map<JID, String> avatars; + std::map<JID, std::string> avatars; }; } diff --git a/Swiften/Avatars/DummyAvatarManager.h b/Swiften/Avatars/DummyAvatarManager.h index 12bbe42..e73c61e 100644 --- a/Swiften/Avatars/DummyAvatarManager.h +++ b/Swiften/Avatars/DummyAvatarManager.h @@ -15,7 +15,7 @@ namespace Swift { class DummyAvatarManager : public AvatarManager { public: virtual boost::filesystem::path getAvatarPath(const JID& j) const { - return boost::filesystem::path("/avatars") / j.toString().getUTF8String(); + return boost::filesystem::path("/avatars") / j.toString(); } virtual ByteArray getAvatar(const JID& jid) const { diff --git a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp index ad3a0f1..6153d29 100644 --- a/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp +++ b/Swiften/Avatars/UnitTest/CombinedAvatarProviderTest.cpp @@ -9,7 +9,7 @@ #include <boost/bind.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Avatars/CombinedAvatarProvider.h" using namespace Swift; @@ -47,7 +47,7 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { void testGetAvatarWithNoAvatarProviderReturnsEmpty() { std::auto_ptr<CombinedAvatarProvider> testling(createProvider()); - CPPUNIT_ASSERT(testling->getAvatarHash(user1).isEmpty()); + CPPUNIT_ASSERT(testling->getAvatarHash(user1).empty()); } void testGetAvatarWithSingleAvatarProvider() { @@ -168,26 +168,26 @@ class CombinedAvatarProviderTest : public CppUnit::TestFixture { private: struct DummyAvatarProvider : public AvatarProvider { - String getAvatarHash(const JID& jid) const { - std::map<JID, String>::const_iterator i = avatars.find(jid); + std::string getAvatarHash(const JID& jid) const { + std::map<JID, std::string>::const_iterator i = avatars.find(jid); if (i != avatars.end()) { return i->second; } else { - return String(); + return std::string(); } } - std::map<JID, String> avatars; + std::map<JID, std::string> avatars; }; DummyAvatarProvider* avatarProvider1; DummyAvatarProvider* avatarProvider2; JID user1; JID user2; - String avatarHash1; - String avatarHash2; - String avatarHash3; + std::string avatarHash1; + std::string avatarHash2; + std::string avatarHash3; std::vector<JID> changes; }; diff --git a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp index 8cb9ccb..be5eaea 100644 --- a/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp +++ b/Swiften/Avatars/UnitTest/VCardAvatarManagerTest.cpp @@ -62,7 +62,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { storeVCardWithPhoto(user1.toBare(), avatar1); avatarStorage->addAvatar(avatar1Hash, avatar1); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); CPPUNIT_ASSERT_EQUAL(avatar1Hash, result); } @@ -71,16 +71,16 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { std::auto_ptr<VCardAvatarManager> testling = createManager(); storeEmptyVCard(user1.toBare()); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); - CPPUNIT_ASSERT_EQUAL(String(), result); + CPPUNIT_ASSERT_EQUAL(std::string(), result); } void testGetAvatarHashUnknownAvatarKnownVCardStoresAvatar() { std::auto_ptr<VCardAvatarManager> testling = createManager(); storeVCardWithPhoto(user1.toBare(), avatar1); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); CPPUNIT_ASSERT_EQUAL(avatar1Hash, result); CPPUNIT_ASSERT(avatarStorage->hasAvatar(avatar1Hash)); @@ -90,9 +90,9 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { void testGetAvatarHashUnknownAvatarUnknownVCard() { std::auto_ptr<VCardAvatarManager> testling = createManager(); - String result = testling->getAvatarHash(user1); + std::string result = testling->getAvatarHash(user1); - CPPUNIT_ASSERT_EQUAL(String(), result); + CPPUNIT_ASSERT_EQUAL(std::string(), result); } void testVCardUpdateTriggersUpdate() { @@ -145,7 +145,7 @@ class VCardAvatarManagerTest : public CppUnit::TestFixture { VCardManager* vcardManager; VCardMemoryStorage* vcardStorage; ByteArray avatar1; - String avatar1Hash; + std::string avatar1Hash; std::vector<JID> changes; JID user1; JID user2; diff --git a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp index a928ced..cde4a45 100644 --- a/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp +++ b/Swiften/Avatars/UnitTest/VCardUpdateAvatarManagerTest.cpp @@ -113,7 +113,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { stanzaChannel->onIQReceived(createVCardResult(ByteArray())); CPPUNIT_ASSERT(!avatarStorage->hasAvatar(Hexify::hexify(SHA1::getHash(ByteArray())))); - CPPUNIT_ASSERT_EQUAL(String(), testling->getAvatarHash(JID("foo@bar.com"))); + CPPUNIT_ASSERT_EQUAL(std::string(), testling->getAvatarHash(JID("foo@bar.com"))); } void testStanzaChannelReset_ClearsHash() { @@ -128,7 +128,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); CPPUNIT_ASSERT_EQUAL(user1.toBare(), changes[0]); - CPPUNIT_ASSERT_EQUAL(String(""), testling->getAvatarHash(user1.toBare())); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling->getAvatarHash(user1.toBare())); } void testStanzaChannelReset_ReceiveHashAfterResetUpdatesHash() { @@ -154,7 +154,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { return result; } - boost::shared_ptr<Presence> createPresenceWithPhotoHash(const JID& jid, const String& hash) { + boost::shared_ptr<Presence> createPresenceWithPhotoHash(const JID& jid, const std::string& hash) { boost::shared_ptr<Presence> presence(new Presence()); presence->setFrom(jid); presence->addPayload(boost::shared_ptr<VCardUpdate>(new VCardUpdate(hash))); @@ -187,7 +187,7 @@ class VCardUpdateAvatarManagerTest : public CppUnit::TestFixture { VCardManager* vcardManager; VCardMemoryStorage* vcardStorage; ByteArray avatar1; - String avatar1Hash; + std::string avatar1Hash; std::vector<JID> changes; JID user1; JID user2; diff --git a/Swiften/Avatars/VCardAvatarManager.cpp b/Swiften/Avatars/VCardAvatarManager.cpp index 244a73e..ce732db 100644 --- a/Swiften/Avatars/VCardAvatarManager.cpp +++ b/Swiften/Avatars/VCardAvatarManager.cpp @@ -28,10 +28,10 @@ void VCardAvatarManager::handleVCardChanged(const JID& from) { onAvatarChanged(from); } -String VCardAvatarManager::getAvatarHash(const JID& jid) const { +std::string VCardAvatarManager::getAvatarHash(const JID& jid) const { VCard::ref vCard = vcardManager_->getVCard(getAvatarJID(jid)); if (vCard && !vCard->getPhoto().isEmpty()) { - String hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); + std::string hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); if (!avatarStorage_->hasAvatar(hash)) { avatarStorage_->addAvatar(hash, vCard->getPhoto()); } diff --git a/Swiften/Avatars/VCardAvatarManager.h b/Swiften/Avatars/VCardAvatarManager.h index 069f938..3f99dad 100644 --- a/Swiften/Avatars/VCardAvatarManager.h +++ b/Swiften/Avatars/VCardAvatarManager.h @@ -21,7 +21,7 @@ namespace Swift { public: VCardAvatarManager(VCardManager*, AvatarStorage*, MUCRegistry* = NULL); - String getAvatarHash(const JID&) const; + std::string getAvatarHash(const JID&) const; private: void handleVCardChanged(const JID& from); diff --git a/Swiften/Avatars/VCardUpdateAvatarManager.cpp b/Swiften/Avatars/VCardUpdateAvatarManager.cpp index 879846e..08d026b 100644 --- a/Swiften/Avatars/VCardUpdateAvatarManager.cpp +++ b/Swiften/Avatars/VCardUpdateAvatarManager.cpp @@ -52,7 +52,7 @@ void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vC setAvatarHash(from, ""); } else { - String hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); + std::string hash = Hexify::hexify(SHA1::getHash(vCard->getPhoto())); if (!avatarStorage_->hasAvatar(hash)) { avatarStorage_->addAvatar(hash, vCard->getPhoto()); } @@ -60,21 +60,21 @@ void VCardUpdateAvatarManager::handleVCardChanged(const JID& from, VCard::ref vC } } -void VCardUpdateAvatarManager::setAvatarHash(const JID& from, const String& hash) { +void VCardUpdateAvatarManager::setAvatarHash(const JID& from, const std::string& hash) { avatarHashes_[from] = hash; onAvatarChanged(from); } /* void VCardUpdateAvatarManager::setAvatar(const JID& jid, const ByteArray& avatar) { - String hash = Hexify::hexify(SHA1::getHash(avatar)); + std::string hash = Hexify::hexify(SHA1::getHash(avatar)); avatarStorage_->addAvatar(hash, avatar); setAvatarHash(getAvatarJID(jid), hash); } */ -String VCardUpdateAvatarManager::getAvatarHash(const JID& jid) const { - std::map<JID, String>::const_iterator i = avatarHashes_.find(getAvatarJID(jid)); +std::string VCardUpdateAvatarManager::getAvatarHash(const JID& jid) const { + std::map<JID, std::string>::const_iterator i = avatarHashes_.find(getAvatarJID(jid)); if (i != avatarHashes_.end()) { return i->second; } @@ -90,9 +90,9 @@ JID VCardUpdateAvatarManager::getAvatarJID(const JID& jid) const { void VCardUpdateAvatarManager::handleStanzaChannelAvailableChanged(bool available) { if (available) { - std::map<JID, String> oldAvatarHashes; + std::map<JID, std::string> oldAvatarHashes; avatarHashes_.swap(oldAvatarHashes); - for(std::map<JID, String>::const_iterator i = oldAvatarHashes.begin(); i != oldAvatarHashes.end(); ++i) { + for(std::map<JID, std::string>::const_iterator i = oldAvatarHashes.begin(); i != oldAvatarHashes.end(); ++i) { onAvatarChanged(i->first); } } diff --git a/Swiften/Avatars/VCardUpdateAvatarManager.h b/Swiften/Avatars/VCardUpdateAvatarManager.h index 8827ab7..1f03898 100644 --- a/Swiften/Avatars/VCardUpdateAvatarManager.h +++ b/Swiften/Avatars/VCardUpdateAvatarManager.h @@ -25,13 +25,13 @@ namespace Swift { public: VCardUpdateAvatarManager(VCardManager*, StanzaChannel*, AvatarStorage*, MUCRegistry* = NULL); - String getAvatarHash(const JID&) const; + std::string getAvatarHash(const JID&) const; private: void handlePresenceReceived(boost::shared_ptr<Presence>); void handleStanzaChannelAvailableChanged(bool); void handleVCardChanged(const JID& from, VCard::ref); - void setAvatarHash(const JID& from, const String& hash); + void setAvatarHash(const JID& from, const std::string& hash); JID getAvatarJID(const JID& o) const; private: @@ -39,6 +39,6 @@ namespace Swift { StanzaChannel* stanzaChannel_; AvatarStorage* avatarStorage_; MUCRegistry* mucRegistry_; - std::map<JID, String> avatarHashes_; + std::map<JID, std::string> avatarHashes_; }; } diff --git a/Swiften/Base/ByteArray.cpp b/Swiften/Base/ByteArray.cpp index 36cc19c..7701268 100644 --- a/Swiften/Base/ByteArray.cpp +++ b/Swiften/Base/ByteArray.cpp @@ -26,8 +26,8 @@ namespace Swift { static const int BUFFER_SIZE = 4096; -void ByteArray::readFromFile(const String& file) { - std::ifstream input(file.getUTF8Data(), std::ios_base::in|std::ios_base::binary); +void ByteArray::readFromFile(const std::string& file) { + std::ifstream input(file.c_str(), std::ios_base::in|std::ios_base::binary); while (input.good()) { size_t oldSize = data_.size(); data_.resize(oldSize + BUFFER_SIZE); diff --git a/Swiften/Base/ByteArray.h b/Swiften/Base/ByteArray.h index b5cbfb0..90a4907 100644 --- a/Swiften/Base/ByteArray.h +++ b/Swiften/Base/ByteArray.h @@ -10,7 +10,7 @@ #include <vector> #include <iostream> -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ByteArray @@ -20,7 +20,7 @@ namespace Swift { ByteArray() : data_() {} - ByteArray(const String& s) : data_(s.getUTF8String().begin(), s.getUTF8String().end()) {} + ByteArray(const std::string& s) : data_(s.begin(), s.end()) {} ByteArray(const char* c) { while (*c) { @@ -107,11 +107,11 @@ namespace Swift { return data_.end(); } - String toString() const { - return String(getData(), getSize()); + std::string toString() const { + return std::string(getData(), getSize()); } - void readFromFile(const String& file); + void readFromFile(const std::string& file); void clear() { data_.clear(); diff --git a/Swiften/Base/IDGenerator.cpp b/Swiften/Base/IDGenerator.cpp index b620de7..74a0f65 100644 --- a/Swiften/Base/IDGenerator.cpp +++ b/Swiften/Base/IDGenerator.cpp @@ -11,16 +11,16 @@ namespace Swift { IDGenerator::IDGenerator() { } -String IDGenerator::generateID() { +std::string IDGenerator::generateID() { bool carry = true; size_t i = 0; - while (carry && i < currentID_.getUTF8Size()) { - char c = currentID_.getUTF8String()[i]; + while (carry && i < currentID_.size()) { + char c = currentID_[i]; if (c >= 'z') { - currentID_.getUTF8String()[i] = 'a'; + currentID_[i] = 'a'; } else { - currentID_.getUTF8String()[i] = c+1; + currentID_[i] = c+1; carry = false; } ++i; diff --git a/Swiften/Base/IDGenerator.h b/Swiften/Base/IDGenerator.h index 2089658..4b6289b 100644 --- a/Swiften/Base/IDGenerator.h +++ b/Swiften/Base/IDGenerator.h @@ -7,17 +7,17 @@ #ifndef SWIFTEN_IDGenerator_H #define SWIFTEN_IDGenerator_H -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class IDGenerator { public: IDGenerator(); - String generateID(); + std::string generateID(); private: - String currentID_; + std::string currentID_; }; } diff --git a/Swiften/Base/Paths.cpp b/Swiften/Base/Paths.cpp index c1dbef2..0e69b61 100644 --- a/Swiften/Base/Paths.cpp +++ b/Swiften/Base/Paths.cpp @@ -25,7 +25,7 @@ boost::filesystem::path Paths::getExecutablePath() { uint32_t size = 4096; path.resize(size); if (_NSGetExecutablePath(path.getData(), &size) == 0) { - return boost::filesystem::path(path.toString().getUTF8Data()).parent_path(); + return boost::filesystem::path(path.toString().c_str()).parent_path(); } #elif defined(SWIFTEN_PLATFORM_LINUX) ByteArray path; @@ -33,13 +33,13 @@ boost::filesystem::path Paths::getExecutablePath() { size_t size = readlink("/proc/self/exe", path.getData(), path.getSize()); if (size > 0) { path.resize(size); - return boost::filesystem::path(path.toString().getUTF8Data()).parent_path(); + return boost::filesystem::path(path.toString().c_str()).parent_path(); } #elif defined(SWIFTEN_PLATFORM_WINDOWS) ByteArray data; data.resize(2048); GetModuleFileName(NULL, data.getData(), data.getSize()); - return boost::filesystem::path(data.toString().getUTF8Data()).parent_path(); + return boost::filesystem::path(data.toString().c_str()).parent_path(); #endif return boost::filesystem::path(); } diff --git a/Swiften/Base/SConscript b/Swiften/Base/SConscript index 9c7b8dc..ca22044 100644 --- a/Swiften/Base/SConscript +++ b/Swiften/Base/SConscript @@ -5,8 +5,8 @@ objects = swiften_env.StaticObject([ "Error.cpp", "Log.cpp", "Paths.cpp", - "IDGenerator.cpp", "String.cpp", + "IDGenerator.cpp", "sleep.cpp", ]) swiften_env.Append(SWIFTEN_OBJECTS = [objects]) diff --git a/Swiften/Base/String.cpp b/Swiften/Base/String.cpp index 460df36..7ddf614 100644 --- a/Swiften/Base/String.cpp +++ b/Swiften/Base/String.cpp @@ -7,7 +7,7 @@ #include <cassert> #include <algorithm> -#include "Swiften/Base/String.h" +#include <Swiften/Base/String.h> namespace Swift { @@ -34,11 +34,11 @@ static inline size_t sequenceLength(char firstByte) { return 1; } -std::vector<unsigned int> String::getUnicodeCodePoints() const { +std::vector<unsigned int> String::getUnicodeCodePoints(const std::string& s) { std::vector<unsigned int> result; - for (size_t i = 0; i < data_.size();) { + for (size_t i = 0; i < s.size();) { unsigned int codePoint = 0; - char firstChar = data_[i]; + char firstChar = s[i]; size_t length = sequenceLength(firstChar); // First character is special @@ -49,7 +49,7 @@ std::vector<unsigned int> String::getUnicodeCodePoints() const { codePoint = firstChar & ((1<<(firstCharBitSize+1)) - 1); for (size_t j = 1; j < length; ++j) { - codePoint = (codePoint<<6) | (data_[i+j] & 0x3F); + codePoint = (codePoint<<6) | (s[i+j] & 0x3F); } result.push_back(codePoint); i += length; @@ -58,37 +58,37 @@ std::vector<unsigned int> String::getUnicodeCodePoints() const { } -std::pair<String,String> String::getSplittedAtFirst(char c) const { +std::pair<std::string,std::string> String::getSplittedAtFirst(const std::string& s, char c) { assert((c & 0x80) == 0); - size_t firstMatch = data_.find(c); - if (firstMatch != data_.npos) { - return std::make_pair(data_.substr(0,firstMatch),data_.substr(firstMatch+1,data_.npos)); + size_t firstMatch = s.find(c); + if (firstMatch != s.npos) { + return std::make_pair(s.substr(0,firstMatch),s.substr(firstMatch+1,s.npos)); } else { - return std::make_pair(*this, ""); + return std::make_pair(s, ""); } } -void String::replaceAll(char c, const String& s) { +void String::replaceAll(std::string& src, char c, const std::string& s) { size_t lastPos = 0; size_t matchingIndex = 0; - while ((matchingIndex = data_.find(c, lastPos)) != data_.npos) { - data_.replace(matchingIndex, 1, s.data_); - lastPos = matchingIndex + s.data_.size(); + while ((matchingIndex = src.find(c, lastPos)) != src.npos) { + src.replace(matchingIndex, 1, s); + lastPos = matchingIndex + s.size(); } } -std::vector<String> String::split(char c) const { +std::vector<std::string> String::split(const std::string& s, char c) { assert((c & 0x80) == 0); - std::vector<String> result; - String accumulator; - for (size_t i = 0; i < data_.size(); ++i) { - if (data_[i] == c) { + std::vector<std::string> result; + std::string accumulator; + for (size_t i = 0; i < s.size(); ++i) { + if (s[i] == c) { result.push_back(accumulator); accumulator = ""; } else { - accumulator += data_[i]; + accumulator += s[i]; } } result.push_back(accumulator); diff --git a/Swiften/Base/String.h b/Swiften/Base/String.h index 7d2f928..192d53b 100644 --- a/Swiften/Base/String.h +++ b/Swiften/Base/String.h @@ -6,141 +6,24 @@ #pragma once -#include <boost/algorithm/string.hpp> - -#include <ostream> +#include <map> #include <string> -#include <utility> #include <vector> -#include <cassert> -#include <algorithm> #define SWIFTEN_STRING_TO_CFSTRING(a) \ - CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.getUTF8Data()), a.getUTF8Size(), kCFStringEncodingUTF8, false) + CFStringCreateWithBytes(NULL, reinterpret_cast<const UInt8*>(a.c_str()), a.size(), kCFStringEncodingUTF8, false) namespace Swift { - class ByteArray; - - class String { - friend class ByteArray; - - public: - String() {} - String(const char* data) : data_(data) {} - String(const char* data, size_t len) : data_(data, len) {} - String(const std::string& data) : data_(data) {} - - bool isEmpty() const { return data_.empty(); } - - const char* getUTF8Data() const { return data_.c_str(); } - const std::string& getUTF8String() const { return data_; } - std::string& getUTF8String() { return data_; } - size_t getUTF8Size() const { return data_.size(); } - std::vector<unsigned int> getUnicodeCodePoints() const; - - void clear() { data_.clear(); } - - /** - * Returns the part before and after 'c'. - * If the given splitter does not occur in the string, the second - * component is the empty string. - */ - std::pair<String,String> getSplittedAtFirst(char c) const; - - std::vector<String> split(char c) const; - - String getLowerCase() const { - return boost::to_lower_copy(data_); - } - - void removeAll(char c) { - data_.erase(std::remove(data_.begin(), data_.end(), c), data_.end()); - } - - void replaceAll(char c, const String& s); - - bool beginsWith(char c) const { - return data_.size() > 0 && data_[0] == c; - } - - bool beginsWith(const String& s) const { - return boost::starts_with(data_, s.data_); - } - - bool endsWith(char c) const { - return data_.size() > 0 && data_[data_.size()-1] == c; - } - - bool endsWith(const String& s) const { - return boost::ends_with(data_, s.data_); - } - - String getSubstring(size_t begin, size_t end) const { - return String(data_.substr(begin, end)); - } - - size_t find(char c) const { - assert((c & 0x80) == 0); - return data_.find(c); - } - - size_t npos() const { - return data_.npos; - } - - friend String operator+(const String& a, const String& b) { - return String(a.data_ + b.data_); + namespace String { + std::vector<unsigned int> getUnicodeCodePoints(const std::string&); + std::pair<std::string, std::string> getSplittedAtFirst(const std::string&, char c); + std::vector<std::string> split(const std::string&, char c); + void replaceAll(std::string&, char c, const std::string& s); + inline bool beginsWith(const std::string& s, char c) { + return s.size() > 0 && s[0] == c; } - - friend String operator+(const String& a, char b) { - return String(a.data_ + b); + inline bool endsWith(const std::string& s, char c) { + return s.size() > 0 && s[s.size()-1] == c; } - - String& operator+=(const String& o) { - data_ += o.data_; - return *this; - } - - String& operator+=(char c) { - data_ += c; - return *this; - } - - String& operator=(const String& o) { - data_ = o.data_; - return *this; - } - - bool contains(const String& o) { - return data_.find(o.data_) != std::string::npos; - } - - char operator[](size_t i) const { - return data_[i]; - } - - friend bool operator>(const String& a, const String& b) { - return a.data_ > b.data_; - } - - friend bool operator<(const String& a, const String& b) { - return a.data_ < b.data_; - } - - friend bool operator!=(const String& a, const String& b) { - return a.data_ != b.data_; - } - - friend bool operator==(const String& a, const String& b) { - return a.data_ == b.data_; - } - - friend std::ostream& operator<<(std::ostream& os, const String& s) { - os << s.data_; - return os; - } - - private: - std::string data_; }; } diff --git a/Swiften/Base/UnitTest/IDGeneratorTest.cpp b/Swiften/Base/UnitTest/IDGeneratorTest.cpp index 4a6b29c..4874684 100644 --- a/Swiften/Base/UnitTest/IDGeneratorTest.cpp +++ b/Swiften/Base/UnitTest/IDGeneratorTest.cpp @@ -28,13 +28,13 @@ class IDGeneratorTest : public CppUnit::TestFixture void testGenerate() { IDGenerator testling; for (unsigned int i = 0; i < 26*4; ++i) { - String id = testling.generateID(); + std::string id = testling.generateID(); CPPUNIT_ASSERT(generatedIDs_.insert(id).second); } } private: - std::set<String> generatedIDs_; + std::set<std::string> generatedIDs_; }; CPPUNIT_TEST_SUITE_REGISTRATION(IDGeneratorTest); diff --git a/Swiften/Base/UnitTest/StringTest.cpp b/Swiften/Base/UnitTest/StringTest.cpp index 161b4f1..884bbee 100644 --- a/Swiften/Base/UnitTest/StringTest.cpp +++ b/Swiften/Base/UnitTest/StringTest.cpp @@ -6,38 +6,29 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> +#include <string> -#include "Swiften/Base/String.h" +#include <Swiften/Base/String.h> using namespace Swift; -class StringTest : public CppUnit::TestFixture -{ +class StringTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(StringTest); CPPUNIT_TEST(testGetUnicodeCodePoints); CPPUNIT_TEST(testGetSplittedAtFirst); CPPUNIT_TEST(testGetSplittedAtFirst_CharacterAtEnd); CPPUNIT_TEST(testGetSplittedAtFirst_NoSuchCharacter); - CPPUNIT_TEST(testRemoveAll); - CPPUNIT_TEST(testRemoveAll_LastChar); - CPPUNIT_TEST(testRemoveAll_ConsecutiveChars); CPPUNIT_TEST(testReplaceAll); CPPUNIT_TEST(testReplaceAll_LastChar); CPPUNIT_TEST(testReplaceAll_ConsecutiveChars); CPPUNIT_TEST(testReplaceAll_MatchingReplace); - CPPUNIT_TEST(testGetLowerCase); CPPUNIT_TEST(testSplit); - CPPUNIT_TEST(testContains); - CPPUNIT_TEST(testContainsFalse); - CPPUNIT_TEST(testContainsExact); - CPPUNIT_TEST(testEndsWith); - CPPUNIT_TEST(testEndsWith_DoesNotEndWith); CPPUNIT_TEST_SUITE_END(); public: void testGetUnicodeCodePoints() { - String testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d"); - std::vector<unsigned int> points = testling.getUnicodeCodePoints(); + std::string testling("$\xc2\xa2\xe2\x82\xac\xf4\x8a\xaf\x8d"); + std::vector<unsigned int> points = String::getUnicodeCodePoints(testling); CPPUNIT_ASSERT_EQUAL(0x24U, points[0]); CPPUNIT_ASSERT_EQUAL(0xA2U, points[1]); @@ -46,120 +37,69 @@ class StringTest : public CppUnit::TestFixture } void testGetSplittedAtFirst() { - String testling("ab@cd@ef"); + std::string testling("ab@cd@ef"); - std::pair<String,String> result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT_EQUAL(String("cd@ef"), result.second); + std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT_EQUAL(std::string("cd@ef"), result.second); } void testGetSplittedAtFirst_CharacterAtEnd() { - String testling("ab@"); + std::string testling("ab@"); - std::pair<String,String> result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT(result.second.isEmpty()); + std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT(result.second.empty()); } void testGetSplittedAtFirst_NoSuchCharacter() { - String testling("ab"); + std::string testling("ab"); - std::pair<String,String> result = testling.getSplittedAtFirst('@'); - CPPUNIT_ASSERT_EQUAL(String("ab"), result.first); - CPPUNIT_ASSERT(result.second.isEmpty()); - } - - void testRemoveAll() { - String testling("ab c de"); - - testling.removeAll(' '); - - CPPUNIT_ASSERT_EQUAL(String("abcde"), testling); - } - - void testRemoveAll_LastChar() { - String testling("abcde "); - - testling.removeAll(' '); - - CPPUNIT_ASSERT_EQUAL(String("abcde"), testling); - } - - void testRemoveAll_ConsecutiveChars() { - String testling("ab cde"); - - testling.removeAll(' '); - - CPPUNIT_ASSERT_EQUAL(String("abcde"), testling); + std::pair<std::string,std::string> result = String::getSplittedAtFirst(testling, '@'); + CPPUNIT_ASSERT_EQUAL(std::string("ab"), result.first); + CPPUNIT_ASSERT(result.second.empty()); } void testReplaceAll() { - String testling("abcbd"); + std::string testling("abcbd"); - testling.replaceAll('b', "xyz"); + String::replaceAll(testling, 'b', "xyz"); - CPPUNIT_ASSERT_EQUAL(String("axyzcxyzd"), testling); + CPPUNIT_ASSERT_EQUAL(std::string("axyzcxyzd"), testling); } void testReplaceAll_LastChar() { - String testling("abc"); + std::string testling("abc"); - testling.replaceAll('c', "xyz"); + String::replaceAll(testling, 'c', "xyz"); - CPPUNIT_ASSERT_EQUAL(String("abxyz"), testling); + CPPUNIT_ASSERT_EQUAL(std::string("abxyz"), testling); } void testReplaceAll_ConsecutiveChars() { - String testling("abbc"); + std::string testling("abbc"); - testling.replaceAll('b',"xyz"); + String::replaceAll(testling, 'b',"xyz"); - CPPUNIT_ASSERT_EQUAL(String("axyzxyzc"), testling); + CPPUNIT_ASSERT_EQUAL(std::string("axyzxyzc"), testling); } void testReplaceAll_MatchingReplace() { - String testling("abc"); + std::string testling("abc"); - testling.replaceAll('b',"bbb"); + String::replaceAll(testling, 'b',"bbb"); - CPPUNIT_ASSERT_EQUAL(String("abbbc"), testling); - } - - void testGetLowerCase() { - String testling("aBcD e"); - - CPPUNIT_ASSERT_EQUAL(String("abcd e"), testling.getLowerCase()); + CPPUNIT_ASSERT_EQUAL(std::string("abbbc"), testling); } void testSplit() { - std::vector<String> result = String("abc def ghi").split(' '); + std::vector<std::string> result = String::split("abc def ghi", ' '); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(result.size())); - CPPUNIT_ASSERT_EQUAL(String("abc"), result[0]); - CPPUNIT_ASSERT_EQUAL(String("def"), result[1]); - CPPUNIT_ASSERT_EQUAL(String("ghi"), result[2]); - } - - void testContains() { - CPPUNIT_ASSERT(String("abcde").contains(String("bcd"))); + CPPUNIT_ASSERT_EQUAL(std::string("abc"), result[0]); + CPPUNIT_ASSERT_EQUAL(std::string("def"), result[1]); + CPPUNIT_ASSERT_EQUAL(std::string("ghi"), result[2]); } - - void testContainsFalse() { - CPPUNIT_ASSERT(!String("abcde").contains(String("abcdef"))); - } - - void testContainsExact() { - CPPUNIT_ASSERT(String("abcde").contains(String("abcde"))); - } - - void testEndsWith() { - CPPUNIT_ASSERT(String("abcdef").endsWith("cdef")); - } - - void testEndsWith_DoesNotEndWith() { - CPPUNIT_ASSERT(!String("abcdef").endsWith("ddef")); - } - }; CPPUNIT_TEST_SUITE_REGISTRATION(StringTest); diff --git a/Swiften/Client/Client.cpp b/Swiften/Client/Client.cpp index 168c357..904f722 100644 --- a/Swiften/Client/Client.cpp +++ b/Swiften/Client/Client.cpp @@ -28,7 +28,7 @@ namespace Swift { -Client::Client(const JID& jid, const String& password, NetworkFactories* networkFactories, Storages* storages) : CoreClient(jid, password, networkFactories), storages(storages) { +Client::Client(const JID& jid, const std::string& password, NetworkFactories* networkFactories, Storages* storages) : CoreClient(jid, password, networkFactories), storages(storages) { memoryStorages = new MemoryStorages(); softwareVersionResponder = new SoftwareVersionResponder(getIQRouter()); @@ -93,7 +93,7 @@ XMPPRoster* Client::getRoster() const { return roster; } -void Client::setSoftwareVersion(const String& name, const String& version) { +void Client::setSoftwareVersion(const std::string& name, const std::string& version) { softwareVersionResponder->setVersion(name, version); } diff --git a/Swiften/Client/Client.h b/Swiften/Client/Client.h index 4725d50..868c9c4 100644 --- a/Swiften/Client/Client.h +++ b/Swiften/Client/Client.h @@ -47,7 +47,7 @@ namespace Swift { * this is NULL, * all data will be stored in memory (and be lost on shutdown) */ - Client(const JID& jid, const String& password, NetworkFactories* networkFactories, Storages* storages = NULL); + Client(const JID& jid, const std::string& password, NetworkFactories* networkFactories, Storages* storages = NULL); ~Client(); @@ -56,7 +56,7 @@ namespace Swift { * * This will be used to respond to version queries from other entities. */ - void setSoftwareVersion(const String& name, const String& version); + void setSoftwareVersion(const std::string& name, const std::string& version); /** * Returns a representation of the roster. diff --git a/Swiften/Client/ClientSession.cpp b/Swiften/Client/ClientSession.cpp index 49334a3..98e3065 100644 --- a/Swiften/Client/ClientSession.cpp +++ b/Swiften/Client/ClientSession.cpp @@ -304,7 +304,7 @@ void ClientSession::continueSessionInitialization() { if (needResourceBind) { state = BindingResource; boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind()); - if (!localJID.getResource().isEmpty()) { + if (!localJID.getResource().empty()) { resourceBind->setResource(localJID.getResource()); } sendStanza(IQ::createRequest(IQ::Set, JID(), "session-bind", resourceBind)); @@ -331,7 +331,7 @@ bool ClientSession::checkState(State state) { return true; } -void ClientSession::sendCredentials(const String& password) { +void ClientSession::sendCredentials(const std::string& password) { assert(WaitingForCredentials); state = Authenticating; authenticator->setCredentials(localJID.getNode(), password); diff --git a/Swiften/Client/ClientSession.h b/Swiften/Client/ClientSession.h index be0f89e..e15a707 100644 --- a/Swiften/Client/ClientSession.h +++ b/Swiften/Client/ClientSession.h @@ -12,7 +12,7 @@ #include "Swiften/Base/Error.h" #include "Swiften/Session/SessionStream.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/Elements/Element.h" #include "Swiften/StreamManagement/StanzaAckRequester.h" @@ -86,7 +86,7 @@ namespace Swift { return getState() == Finished; } - void sendCredentials(const String& password); + void sendCredentials(const std::string& password); void sendStanza(boost::shared_ptr<Stanza>); void setCertificateTrustChecker(CertificateTrustChecker* checker) { diff --git a/Swiften/Client/ClientSessionStanzaChannel.cpp b/Swiften/Client/ClientSessionStanzaChannel.cpp index 996196b..6b32b3d 100644 --- a/Swiften/Client/ClientSessionStanzaChannel.cpp +++ b/Swiften/Client/ClientSessionStanzaChannel.cpp @@ -31,7 +31,7 @@ void ClientSessionStanzaChannel::sendPresence(boost::shared_ptr<Presence> presen send(presence); } -String ClientSessionStanzaChannel::getNewIQID() { +std::string ClientSessionStanzaChannel::getNewIQID() { return idGenerator.generateID(); } diff --git a/Swiften/Client/ClientSessionStanzaChannel.h b/Swiften/Client/ClientSessionStanzaChannel.h index d3fd093..8a56301 100644 --- a/Swiften/Client/ClientSessionStanzaChannel.h +++ b/Swiften/Client/ClientSessionStanzaChannel.h @@ -33,7 +33,7 @@ namespace Swift { } private: - String getNewIQID(); + std::string getNewIQID(); void send(boost::shared_ptr<Stanza> stanza); void handleSessionFinished(boost::shared_ptr<Error> error); void handleStanza(boost::shared_ptr<Stanza> stanza); diff --git a/Swiften/Client/ClientXMLTracer.h b/Swiften/Client/ClientXMLTracer.h index 43fdda3..bca2a54 100644 --- a/Swiften/Client/ClientXMLTracer.h +++ b/Swiften/Client/ClientXMLTracer.h @@ -19,7 +19,7 @@ namespace Swift { } private: - static void printData(char direction, const String& data) { + static void printData(char direction, const std::string& data) { printLine(direction); std::cerr << data << std::endl; } diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp index 2bd22c8..edb7643 100644 --- a/Swiften/Client/CoreClient.cpp +++ b/Swiften/Client/CoreClient.cpp @@ -22,7 +22,7 @@ namespace Swift { -CoreClient::CoreClient(const JID& jid, const String& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) { +CoreClient::CoreClient(const JID& jid, const std::string& password, NetworkFactories* networkFactories) : jid_(jid), password_(password), networkFactories(networkFactories), disconnectRequested_(false), certificateTrustChecker(NULL) { stanzaChannel_ = new ClientSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::bind(&CoreClient::handleMessageReceived, this, _1)); stanzaChannel_->onPresenceReceived.connect(boost::bind(&CoreClient::handlePresenceReceived, this, _1)); @@ -52,7 +52,7 @@ void CoreClient::connect() { connect(jid_.getDomain()); } -void CoreClient::connect(const String& host) { +void CoreClient::connect(const std::string& host) { SWIFT_LOG(debug) << "Connecting to host " << host << std::endl; disconnectRequested_ = false; assert(!connector_); @@ -74,7 +74,7 @@ void CoreClient::handleConnectorFinished(boost::shared_ptr<Connection> connectio assert(!sessionStream_); sessionStream_ = boost::shared_ptr<BasicSessionStream>(new BasicSessionStream(ClientStreamType, connection_, getPayloadParserFactories(), getPayloadSerializers(), tlsFactories->getTLSContextFactory(), networkFactories->getTimerFactory())); - if (!certificate_.isEmpty()) { + if (!certificate_.empty()) { sessionStream_->setTLSCertificate(PKCS12Certificate(certificate_, password_)); } sessionStream_->onDataRead.connect(boost::bind(&CoreClient::handleDataRead, this, _1)); @@ -101,7 +101,7 @@ void CoreClient::disconnect() { } } -void CoreClient::setCertificate(const String& certificate) { +void CoreClient::setCertificate(const std::string& certificate) { certificate_ = certificate; } @@ -219,11 +219,11 @@ void CoreClient::handleNeedCredentials() { session_->sendCredentials(password_); } -void CoreClient::handleDataRead(const String& data) { +void CoreClient::handleDataRead(const std::string& data) { onDataRead(data); } -void CoreClient::handleDataWritten(const String& data) { +void CoreClient::handleDataWritten(const std::string& data) { onDataWritten(data); } diff --git a/Swiften/Client/CoreClient.h b/Swiften/Client/CoreClient.h index 5ecf2c9..92cd197 100644 --- a/Swiften/Client/CoreClient.h +++ b/Swiften/Client/CoreClient.h @@ -17,7 +17,7 @@ #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/Message.h" #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Client/StanzaChannel.h" #include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" #include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" @@ -52,10 +52,10 @@ namespace Swift { * Constructs a client for the given JID with the given password. * The given eventLoop will be used to post events to. */ - CoreClient(const JID& jid, const String& password, NetworkFactories* networkFactories); + CoreClient(const JID& jid, const std::string& password, NetworkFactories* networkFactories); ~CoreClient(); - void setCertificate(const String& certificate); + void setCertificate(const std::string& certificate); /** * Connects the client to the server. @@ -70,7 +70,7 @@ namespace Swift { */ void disconnect(); - void connect(const String& host); + void connect(const std::string& host); /** * Sends a message. @@ -164,7 +164,7 @@ namespace Swift { * This signal is emitted before the XML data is parsed, * so this data is unformatted. */ - boost::signal<void (const String&)> onDataRead; + boost::signal<void (const std::string&)> onDataRead; /** * Emitted when the client sends data. @@ -172,7 +172,7 @@ namespace Swift { * This signal is emitted after the XML was serialized, and * is unformatted. */ - boost::signal<void (const String&)> onDataWritten; + boost::signal<void (const std::string&)> onDataWritten; /** * Emitted when a message is received. @@ -197,15 +197,15 @@ namespace Swift { void handleStanzaChannelAvailableChanged(bool available); void handleSessionFinished(boost::shared_ptr<Error>); void handleNeedCredentials(); - void handleDataRead(const String&); - void handleDataWritten(const String&); + void handleDataRead(const std::string&); + void handleDataWritten(const std::string&); void handlePresenceReceived(Presence::ref); void handleMessageReceived(Message::ref); void handleStanzaAcked(Stanza::ref); private: JID jid_; - String password_; + std::string password_; NetworkFactories* networkFactories; ClientSessionStanzaChannel* stanzaChannel_; IQRouter* iqRouter_; @@ -214,7 +214,7 @@ namespace Swift { boost::shared_ptr<Connection> connection_; boost::shared_ptr<BasicSessionStream> sessionStream_; boost::shared_ptr<ClientSession> session_; - String certificate_; + std::string certificate_; bool disconnectRequested_; CertificateTrustChecker* certificateTrustChecker; }; diff --git a/Swiften/Client/DummyNickManager.h b/Swiften/Client/DummyNickManager.h index b746f88..0e3ff50 100644 --- a/Swiften/Client/DummyNickManager.h +++ b/Swiften/Client/DummyNickManager.h @@ -13,11 +13,11 @@ namespace Swift { class DummyNickManager : public NickManager { public: - String getOwnNick() const { + std::string getOwnNick() const { return ""; } - void setOwnNick(const String&) { + void setOwnNick(const std::string&) { } }; } diff --git a/Swiften/Client/DummyStanzaChannel.h b/Swiften/Client/DummyStanzaChannel.h index 5784788..b9f05c3 100644 --- a/Swiften/Client/DummyStanzaChannel.h +++ b/Swiften/Client/DummyStanzaChannel.h @@ -36,7 +36,7 @@ namespace Swift { sentStanzas.push_back(presence); } - virtual String getNewIQID() { + virtual std::string getNewIQID() { return "test-id"; } diff --git a/Swiften/Client/FileStorages.cpp b/Swiften/Client/FileStorages.cpp index 9f2dda0..ad8b130 100644 --- a/Swiften/Client/FileStorages.cpp +++ b/Swiften/Client/FileStorages.cpp @@ -12,8 +12,8 @@ namespace Swift { FileStorages::FileStorages(const boost::filesystem::path& baseDir, const JID& jid) { - String profile = jid.toBare(); - vcardStorage = new VCardFileStorage(baseDir / profile.getUTF8String() / "vcards"); + std::string profile = jid.toBare(); + vcardStorage = new VCardFileStorage(baseDir / profile / "vcards"); capsStorage = new CapsFileStorage(baseDir / "caps"); avatarStorage = new AvatarFileStorage(baseDir / "avatars"); } diff --git a/Swiften/Client/NickManager.h b/Swiften/Client/NickManager.h index e918b07..288aa7b 100644 --- a/Swiften/Client/NickManager.h +++ b/Swiften/Client/NickManager.h @@ -7,16 +7,16 @@ #pragma once #include <Swiften/Base/boost_bsignals.h> -#include <Swiften/Base/String.h> +#include <string> namespace Swift { class NickManager { public: virtual ~NickManager(); - virtual String getOwnNick() const = 0; - virtual void setOwnNick(const String& nick) = 0; + virtual std::string getOwnNick() const = 0; + virtual void setOwnNick(const std::string& nick) = 0; - boost::signal<void (const String&)> onOwnNickChanged; + boost::signal<void (const std::string&)> onOwnNickChanged; }; } diff --git a/Swiften/Client/NickManagerImpl.cpp b/Swiften/Client/NickManagerImpl.cpp index fd37222..b9ebcde 100644 --- a/Swiften/Client/NickManagerImpl.cpp +++ b/Swiften/Client/NickManagerImpl.cpp @@ -22,11 +22,11 @@ NickManagerImpl::~NickManagerImpl() { vcardManager->onVCardChanged.disconnect(boost::bind(&NickManagerImpl::handleVCardReceived, this, _1, _2)); } -String NickManagerImpl::getOwnNick() const { +std::string NickManagerImpl::getOwnNick() const { return ownNick; } -void NickManagerImpl::setOwnNick(const String&) { +void NickManagerImpl::setOwnNick(const std::string&) { } void NickManagerImpl::handleVCardReceived(const JID& jid, VCard::ref vcard) { @@ -37,8 +37,8 @@ void NickManagerImpl::handleVCardReceived(const JID& jid, VCard::ref vcard) { } void NickManagerImpl::updateOwnNickFromVCard(VCard::ref vcard) { - String nick; - if (vcard && !vcard->getNickname().isEmpty()) { + std::string nick; + if (vcard && !vcard->getNickname().empty()) { nick = vcard->getNickname(); } if (ownNick != nick) { diff --git a/Swiften/Client/NickManagerImpl.h b/Swiften/Client/NickManagerImpl.h index 8796dbe..d732987 100644 --- a/Swiften/Client/NickManagerImpl.h +++ b/Swiften/Client/NickManagerImpl.h @@ -9,7 +9,7 @@ #include <Swiften/Client/NickManager.h> #include <Swiften/Elements/VCard.h> #include <Swiften/JID/JID.h> -#include <Swiften/Base/String.h> +#include <string> namespace Swift { class VCardManager; @@ -19,8 +19,8 @@ namespace Swift { NickManagerImpl(const JID& ownJID, VCardManager* vcardManager); ~NickManagerImpl(); - String getOwnNick() const; - void setOwnNick(const String& nick); + std::string getOwnNick() const; + void setOwnNick(const std::string& nick); private: void handleVCardReceived(const JID& jid, VCard::ref vCard); @@ -29,6 +29,6 @@ namespace Swift { private: JID ownJID; VCardManager* vcardManager; - String ownNick; + std::string ownNick; }; } diff --git a/Swiften/Client/NickResolver.cpp b/Swiften/Client/NickResolver.cpp index 3e1ae8e..6d5e742 100644 --- a/Swiften/Client/NickResolver.cpp +++ b/Swiften/Client/NickResolver.cpp @@ -31,28 +31,28 @@ NickResolver::NickResolver(const JID& ownJID, XMPPRoster* xmppRoster, VCardManag xmppRoster_->onJIDAdded.connect(boost::bind(&NickResolver::handleJIDAdded, this, _1)); } -void NickResolver::handleJIDUpdated(const JID& jid, const String& previousNick, const std::vector<String>& /*groups*/) { +void NickResolver::handleJIDUpdated(const JID& jid, const std::string& previousNick, const std::vector<std::string>& /*groups*/) { onNickChanged(jid, previousNick); } void NickResolver::handleJIDAdded(const JID& jid) { - String oldNick(jidToNick(jid)); + std::string oldNick(jidToNick(jid)); onNickChanged(jid, oldNick); } -String NickResolver::jidToNick(const JID& jid) { +std::string NickResolver::jidToNick(const JID& jid) { if (jid.toBare() == ownJID_) { - if (!ownNick_.isEmpty()) { + if (!ownNick_.empty()) { return ownNick_; } } - String nick; + std::string nick; if (mucRegistry_ && mucRegistry_->isMUC(jid.toBare()) ) { - return jid.getResource().isEmpty() ? jid.toBare().toString() : jid.getResource(); + return jid.getResource().empty() ? jid.toBare().toString() : jid.getResource(); } - if (xmppRoster_->containsJID(jid) && !xmppRoster_->getNameForJID(jid).isEmpty()) { + if (xmppRoster_->containsJID(jid) && !xmppRoster_->getNameForJID(jid).empty()) { return xmppRoster_->getNameForJID(jid); } @@ -63,14 +63,14 @@ void NickResolver::handleVCardReceived(const JID& jid, VCard::ref ownVCard) { if (!jid.equals(ownJID_, JID::WithoutResource)) { return; } - String initialNick = ownNick_; + std::string initialNick = ownNick_; ownNick_ = ownJID_.toString(); if (ownVCard) { - if (!ownVCard->getNickname().isEmpty()) { + if (!ownVCard->getNickname().empty()) { ownNick_ = ownVCard->getNickname(); - } else if (!ownVCard->getGivenName().isEmpty()) { + } else if (!ownVCard->getGivenName().empty()) { ownNick_ = ownVCard->getGivenName(); - } else if (!ownVCard->getFullName().isEmpty()) { + } else if (!ownVCard->getFullName().empty()) { ownNick_ = ownVCard->getFullName(); } } diff --git a/Swiften/Client/NickResolver.h b/Swiften/Client/NickResolver.h index 697409f..881362a 100644 --- a/Swiften/Client/NickResolver.h +++ b/Swiften/Client/NickResolver.h @@ -8,7 +8,7 @@ #include <boost/signals.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/Elements/VCard.h" @@ -20,18 +20,18 @@ namespace Swift { public: NickResolver(const JID& ownJID, XMPPRoster* xmppRoster, VCardManager* vcardManager, MUCRegistry* mucRegistry); - String jidToNick(const JID& jid); + std::string jidToNick(const JID& jid); - boost::signal<void (const JID&, const String& /*previousNick*/)> onNickChanged; + boost::signal<void (const JID&, const std::string& /*previousNick*/)> onNickChanged; private: void handleVCardReceived(const JID& jid, VCard::ref vCard); - void handleJIDUpdated(const JID& jid, const String& previousNick, const std::vector<String>& groups); + void handleJIDUpdated(const JID& jid, const std::string& previousNick, const std::vector<std::string>& groups); void handleJIDAdded(const JID& jid); private: JID ownJID_; - String ownNick_; + std::string ownNick_; XMPPRoster* xmppRoster_; MUCRegistry* mucRegistry_; VCardManager* vcardManager_; diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp index af8a4c3..21c0ffb 100644 --- a/Swiften/Client/UnitTest/ClientSessionTest.cpp +++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp @@ -455,7 +455,7 @@ class ClientSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(boost::dynamic_pointer_cast<StartTLSRequest>(event.element)); } - void receiveAuthRequest(const String& mech) { + void receiveAuthRequest(const std::string& mech) { Event event = popEvent(); CPPUNIT_ASSERT(event.element); boost::shared_ptr<AuthRequest> request(boost::dynamic_pointer_cast<AuthRequest>(event.element)); @@ -490,7 +490,7 @@ class ClientSessionTest : public CppUnit::TestFixture { bool tlsEncrypted; bool compressed; bool whitespacePingEnabled; - String bindID; + std::string bindID; int resetCount; std::deque<Event> receivedEvents; }; diff --git a/Swiften/Client/UnitTest/NickResolverTest.cpp b/Swiften/Client/UnitTest/NickResolverTest.cpp index 0c5c91b..bd778d4 100644 --- a/Swiften/Client/UnitTest/NickResolverTest.cpp +++ b/Swiften/Client/UnitTest/NickResolverTest.cpp @@ -58,34 +58,34 @@ class NickResolverTest : public CppUnit::TestFixture { registry_->addMUC(JID("foo@bar")); JID testJID("foo@bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("baz"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("baz"), resolver_->jidToNick(testJID)); } void testMUCNoNick() { registry_->addMUC(JID("foo@bar")); JID testJID("foo@bar"); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testNoMatch() { JID testJID("foo@bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testZeroLengthMatch() { JID testJID("foo@bar/baz"); xmppRoster_->addContact(testJID, "", groups_, RosterItemPayload::Both); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testMatch() { JID testJID("foo@bar/baz"); xmppRoster_->addContact(testJID, "Test", groups_, RosterItemPayload::Both); - CPPUNIT_ASSERT_EQUAL(String("Test"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("Test"), resolver_->jidToNick(testJID)); } void testOverwrittenMatch() { @@ -93,40 +93,40 @@ class NickResolverTest : public CppUnit::TestFixture { xmppRoster_->addContact(testJID, "FailTest", groups_, RosterItemPayload::Both); xmppRoster_->addContact(testJID, "Test", groups_, RosterItemPayload::Both); - CPPUNIT_ASSERT_EQUAL(String("Test"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("Test"), resolver_->jidToNick(testJID)); } void testRemovedMatch() { JID testJID("foo@bar/baz"); xmppRoster_->addContact(testJID, "FailTest", groups_, RosterItemPayload::Both); xmppRoster_->removeContact(testJID); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), resolver_->jidToNick(testJID)); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), resolver_->jidToNick(testJID)); } void testOwnNickFullOnly() { populateOwnVCard("", "", "Kevin Smith"); - CPPUNIT_ASSERT_EQUAL(String("Kevin Smith"), resolver_->jidToNick(ownJID_)); + CPPUNIT_ASSERT_EQUAL(std::string("Kevin Smith"), resolver_->jidToNick(ownJID_)); } void testOwnNickGivenAndFull() { populateOwnVCard("", "Kevin", "Kevin Smith"); - CPPUNIT_ASSERT_EQUAL(String("Kevin"), resolver_->jidToNick(ownJID_)); + CPPUNIT_ASSERT_EQUAL(std::string("Kevin"), resolver_->jidToNick(ownJID_)); } void testOwnNickNickEtAl() { populateOwnVCard("Kev", "Kevin", "Kevin Smith"); - CPPUNIT_ASSERT_EQUAL(String("Kev"), resolver_->jidToNick(ownJID_)); + CPPUNIT_ASSERT_EQUAL(std::string("Kev"), resolver_->jidToNick(ownJID_)); } - void populateOwnVCard(const String& nick, const String& given, const String& full) { + void populateOwnVCard(const std::string& nick, const std::string& given, const std::string& full) { VCard::ref vcard(new VCard()); - if (!nick.isEmpty()) { + if (!nick.empty()) { vcard->setNickname(nick); } - if (!given.isEmpty()) { + if (!given.empty()) { vcard->setGivenName(given); } - if (!full.isEmpty()) { + if (!full.empty()) { vcard->setFullName(full); } vCardManager_->requestVCard(ownJID_); @@ -135,7 +135,7 @@ class NickResolverTest : public CppUnit::TestFixture { } private: - std::vector<String> groups_; + std::vector<std::string> groups_; XMPPRosterImpl* xmppRoster_; VCardStorage* vCardStorage_; IQRouter* iqRouter_; diff --git a/Swiften/Component/Component.cpp b/Swiften/Component/Component.cpp index f3e2b81..fb4ba4c 100644 --- a/Swiften/Component/Component.cpp +++ b/Swiften/Component/Component.cpp @@ -10,7 +10,7 @@ namespace Swift { -Component::Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret) : CoreComponent(eventLoop, networkFactories, jid, secret) { +Component::Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret) : CoreComponent(eventLoop, networkFactories, jid, secret) { softwareVersionResponder = new SoftwareVersionResponder(getIQRouter()); softwareVersionResponder->start(); } @@ -20,7 +20,7 @@ Component::~Component() { delete softwareVersionResponder; } -void Component::setSoftwareVersion(const String& name, const String& version) { +void Component::setSoftwareVersion(const std::string& name, const std::string& version) { softwareVersionResponder->setVersion(name, version); } diff --git a/Swiften/Component/Component.h b/Swiften/Component/Component.h index 1a04272..0119db0 100644 --- a/Swiften/Component/Component.h +++ b/Swiften/Component/Component.h @@ -19,7 +19,7 @@ namespace Swift { */ class Component : public CoreComponent { public: - Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret); + Component(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret); ~Component(); /** @@ -27,7 +27,7 @@ namespace Swift { * * This will be used to respond to version queries from other entities. */ - void setSoftwareVersion(const String& name, const String& version); + void setSoftwareVersion(const std::string& name, const std::string& version); private: SoftwareVersionResponder* softwareVersionResponder; diff --git a/Swiften/Component/ComponentConnector.cpp b/Swiften/Component/ComponentConnector.cpp index e764138..2af45f6 100644 --- a/Swiften/Component/ComponentConnector.cpp +++ b/Swiften/Component/ComponentConnector.cpp @@ -16,7 +16,7 @@ namespace Swift { -ComponentConnector::ComponentConnector(const String& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0) { +ComponentConnector::ComponentConnector(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), port(port), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0) { } void ComponentConnector::setTimeoutMilliseconds(int milliseconds) { diff --git a/Swiften/Component/ComponentConnector.h b/Swiften/Component/ComponentConnector.h index a84d8ba..c5e8f80 100644 --- a/Swiften/Component/ComponentConnector.h +++ b/Swiften/Component/ComponentConnector.h @@ -13,7 +13,7 @@ #include "Swiften/Network/Connection.h" #include "Swiften/Network/Timer.h" #include "Swiften/Network/HostAddressPort.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Network/DomainNameResolveError.h" namespace Swift { @@ -26,7 +26,7 @@ namespace Swift { public: typedef boost::shared_ptr<ComponentConnector> ref; - static ComponentConnector::ref create(const String& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { + static ComponentConnector::ref create(const std::string& hostname, int port, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { return ComponentConnector::ref(new ComponentConnector(hostname, port, resolver, connectionFactory, timerFactory)); } @@ -38,7 +38,7 @@ namespace Swift { boost::signal<void (boost::shared_ptr<Connection>)> onConnectFinished; private: - ComponentConnector(const String& hostname, int port, DomainNameResolver*, ConnectionFactory*, TimerFactory*); + ComponentConnector(const std::string& hostname, int port, DomainNameResolver*, ConnectionFactory*, TimerFactory*); void handleAddressQueryResult(const std::vector<HostAddress>& address, boost::optional<DomainNameResolveError> error); void tryNextAddress(); @@ -50,7 +50,7 @@ namespace Swift { private: - String hostname; + std::string hostname; int port; DomainNameResolver* resolver; ConnectionFactory* connectionFactory; diff --git a/Swiften/Component/ComponentHandshakeGenerator.cpp b/Swiften/Component/ComponentHandshakeGenerator.cpp index 422f986..4081420 100644 --- a/Swiften/Component/ComponentHandshakeGenerator.cpp +++ b/Swiften/Component/ComponentHandshakeGenerator.cpp @@ -7,16 +7,17 @@ #include "Swiften/Component/ComponentHandshakeGenerator.h" #include "Swiften/StringCodecs/Hexify.h" #include "Swiften/StringCodecs/SHA1.h" +#include <Swiften/Base/String.h> namespace Swift { -String ComponentHandshakeGenerator::getHandshake(const String& streamID, const String& secret) { - String concatenatedString = streamID + secret; - concatenatedString.replaceAll('&', "&"); - concatenatedString.replaceAll('<', "<"); - concatenatedString.replaceAll('>', ">"); - concatenatedString.replaceAll('\'', "'"); - concatenatedString.replaceAll('"', """); +std::string ComponentHandshakeGenerator::getHandshake(const std::string& streamID, const std::string& secret) { + std::string concatenatedString = streamID + secret; + String::replaceAll(concatenatedString, '&', "&"); + String::replaceAll(concatenatedString, '<', "<"); + String::replaceAll(concatenatedString, '>', ">"); + String::replaceAll(concatenatedString, '\'', "'"); + String::replaceAll(concatenatedString, '"', """); return Hexify::hexify(SHA1::getHash(ByteArray(concatenatedString))); } diff --git a/Swiften/Component/ComponentHandshakeGenerator.h b/Swiften/Component/ComponentHandshakeGenerator.h index d71a664..4181d3c 100644 --- a/Swiften/Component/ComponentHandshakeGenerator.h +++ b/Swiften/Component/ComponentHandshakeGenerator.h @@ -6,12 +6,12 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ComponentHandshakeGenerator { public: - static String getHandshake(const String& streamID, const String& secret); + static std::string getHandshake(const std::string& streamID, const std::string& secret); }; } diff --git a/Swiften/Component/ComponentSession.cpp b/Swiften/Component/ComponentSession.cpp index c45f663..17e0dfd 100644 --- a/Swiften/Component/ComponentSession.cpp +++ b/Swiften/Component/ComponentSession.cpp @@ -15,7 +15,7 @@ namespace Swift { -ComponentSession::ComponentSession(const JID& jid, const String& secret, boost::shared_ptr<SessionStream> stream) : jid(jid), secret(secret), stream(stream), state(Initial) { +ComponentSession::ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream> stream) : jid(jid), secret(secret), stream(stream), state(Initial) { } ComponentSession::~ComponentSession() { diff --git a/Swiften/Component/ComponentSession.h b/Swiften/Component/ComponentSession.h index dbe6e27..168e618 100644 --- a/Swiften/Component/ComponentSession.h +++ b/Swiften/Component/ComponentSession.h @@ -12,7 +12,7 @@ #include "Swiften/JID/JID.h" #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Base/Error.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Element.h" #include "Swiften/Elements/Stanza.h" #include "Swiften/Session/SessionStream.h" @@ -41,7 +41,7 @@ namespace Swift { ~ComponentSession(); - static boost::shared_ptr<ComponentSession> create(const JID& jid, const String& secret, boost::shared_ptr<SessionStream> stream) { + static boost::shared_ptr<ComponentSession> create(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream> stream) { return boost::shared_ptr<ComponentSession>(new ComponentSession(jid, secret, stream)); } @@ -60,7 +60,7 @@ namespace Swift { boost::signal<void (boost::shared_ptr<Stanza>)> onStanzaReceived; private: - ComponentSession(const JID& jid, const String& secret, boost::shared_ptr<SessionStream>); + ComponentSession(const JID& jid, const std::string& secret, boost::shared_ptr<SessionStream>); void finishSession(Error::Type error); void finishSession(boost::shared_ptr<Swift::Error> error); @@ -75,7 +75,7 @@ namespace Swift { private: JID jid; - String secret; + std::string secret; boost::shared_ptr<SessionStream> stream; boost::shared_ptr<Swift::Error> error; State state; diff --git a/Swiften/Component/ComponentSessionStanzaChannel.cpp b/Swiften/Component/ComponentSessionStanzaChannel.cpp index 9f4dc2e..b9fecb2 100644 --- a/Swiften/Component/ComponentSessionStanzaChannel.cpp +++ b/Swiften/Component/ComponentSessionStanzaChannel.cpp @@ -30,7 +30,7 @@ void ComponentSessionStanzaChannel::sendPresence(boost::shared_ptr<Presence> pre send(presence); } -String ComponentSessionStanzaChannel::getNewIQID() { +std::string ComponentSessionStanzaChannel::getNewIQID() { return idGenerator.generateID(); } diff --git a/Swiften/Component/ComponentSessionStanzaChannel.h b/Swiften/Component/ComponentSessionStanzaChannel.h index 856031f..605c8dc 100644 --- a/Swiften/Component/ComponentSessionStanzaChannel.h +++ b/Swiften/Component/ComponentSessionStanzaChannel.h @@ -36,7 +36,7 @@ namespace Swift { } private: - String getNewIQID(); + std::string getNewIQID(); void send(boost::shared_ptr<Stanza> stanza); void handleSessionFinished(boost::shared_ptr<Error> error); void handleStanza(boost::shared_ptr<Stanza> stanza); diff --git a/Swiften/Component/ComponentXMLTracer.h b/Swiften/Component/ComponentXMLTracer.h index 512e69c..70a617b 100644 --- a/Swiften/Component/ComponentXMLTracer.h +++ b/Swiften/Component/ComponentXMLTracer.h @@ -19,7 +19,7 @@ namespace Swift { } private: - static void printData(char direction, const String& data) { + static void printData(char direction, const std::string& data) { printLine(direction); std::cerr << data << std::endl; } diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp index eabe62d..e79d735 100644 --- a/Swiften/Component/CoreComponent.cpp +++ b/Swiften/Component/CoreComponent.cpp @@ -19,7 +19,7 @@ namespace Swift { -CoreComponent::CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret) : eventLoop(eventLoop), networkFactories(networkFactories), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { +CoreComponent::CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret) : eventLoop(eventLoop), networkFactories(networkFactories), resolver_(eventLoop), jid_(jid), secret_(secret), disconnectRequested_(false) { stanzaChannel_ = new ComponentSessionStanzaChannel(); stanzaChannel_->onMessageReceived.connect(boost::ref(onMessageReceived)); stanzaChannel_->onPresenceReceived.connect(boost::ref(onPresenceReceived)); @@ -41,7 +41,7 @@ CoreComponent::~CoreComponent() { delete stanzaChannel_; } -void CoreComponent::connect(const String& host, int port) { +void CoreComponent::connect(const std::string& host, int port) { assert(!connector_); connector_ = ComponentConnector::create(host, port, &resolver_, networkFactories->getConnectionFactory(), networkFactories->getTimerFactory()); connector_->onConnectFinished.connect(boost::bind(&CoreComponent::handleConnectorFinished, this, _1)); @@ -138,11 +138,11 @@ void CoreComponent::handleSessionFinished(boost::shared_ptr<Error> error) { } } -void CoreComponent::handleDataRead(const String& data) { +void CoreComponent::handleDataRead(const std::string& data) { onDataRead(data); } -void CoreComponent::handleDataWritten(const String& data) { +void CoreComponent::handleDataWritten(const std::string& data) { onDataWritten(data); } diff --git a/Swiften/Component/CoreComponent.h b/Swiften/Component/CoreComponent.h index 8ebf80f..64c9071 100644 --- a/Swiften/Component/CoreComponent.h +++ b/Swiften/Component/CoreComponent.h @@ -17,7 +17,7 @@ #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/Message.h" #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" #include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" #include "Swiften/Component/ComponentSessionStanzaChannel.h" @@ -41,10 +41,10 @@ namespace Swift { */ class CoreComponent : public Entity { public: - CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const String& secret); + CoreComponent(EventLoop* eventLoop, NetworkFactories* networkFactories, const JID& jid, const std::string& secret); ~CoreComponent(); - void connect(const String& host, int port); + void connect(const std::string& host, int port); void disconnect(); void sendMessage(boost::shared_ptr<Message>); @@ -72,8 +72,8 @@ namespace Swift { public: boost::signal<void (const ComponentError&)> onError; boost::signal<void ()> onConnected; - boost::signal<void (const String&)> onDataRead; - boost::signal<void (const String&)> onDataWritten; + boost::signal<void (const std::string&)> onDataRead; + boost::signal<void (const std::string&)> onDataWritten; boost::signal<void (boost::shared_ptr<Message>)> onMessageReceived; boost::signal<void (boost::shared_ptr<Presence>) > onPresenceReceived; @@ -82,15 +82,15 @@ namespace Swift { void handleConnectorFinished(boost::shared_ptr<Connection>); void handleStanzaChannelAvailableChanged(bool available); void handleSessionFinished(boost::shared_ptr<Error>); - void handleDataRead(const String&); - void handleDataWritten(const String&); + void handleDataRead(const std::string&); + void handleDataWritten(const std::string&); private: EventLoop* eventLoop; NetworkFactories* networkFactories; PlatformDomainNameResolver resolver_; JID jid_; - String secret_; + std::string secret_; ComponentSessionStanzaChannel* stanzaChannel_; IQRouter* iqRouter_; ComponentConnector::ref connector_; diff --git a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp index bfa2cb2..052b5de 100644 --- a/Swiften/Component/UnitTest/ComponentConnectorTest.cpp +++ b/Swiften/Component/UnitTest/ComponentConnectorTest.cpp @@ -146,7 +146,7 @@ class ComponentConnectorTest : public CppUnit::TestFixture { } private: - ComponentConnector::ref createConnector(const String& hostname, int port) { + ComponentConnector::ref createConnector(const std::string& hostname, int port) { ComponentConnector::ref connector = ComponentConnector::create(hostname, port, resolver, connectionFactory, timerFactory); connector->onConnectFinished.connect(boost::bind(&ComponentConnectorTest::handleConnectorFinished, this, _1)); return connector; diff --git a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp index e72dbea..5366478 100644 --- a/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp +++ b/Swiften/Component/UnitTest/ComponentHandshakeGeneratorTest.cpp @@ -19,13 +19,13 @@ class ComponentHandshakeGeneratorTest : public CppUnit::TestFixture { public: void testGetHandshake() { - String result = ComponentHandshakeGenerator::getHandshake("myid", "mysecret"); - CPPUNIT_ASSERT_EQUAL(String("4011cd31f9b99ac089a0cd7ce297da7323fa2525"), result); + std::string result = ComponentHandshakeGenerator::getHandshake("myid", "mysecret"); + CPPUNIT_ASSERT_EQUAL(std::string("4011cd31f9b99ac089a0cd7ce297da7323fa2525"), result); } void testGetHandshake_SpecialChars() { - String result = ComponentHandshakeGenerator::getHandshake("&<", ">'\""); - CPPUNIT_ASSERT_EQUAL(String("33631b3e0aaeb2a11c4994c917919324028873fe"), result); + std::string result = ComponentHandshakeGenerator::getHandshake("&<", ">'\""); + CPPUNIT_ASSERT_EQUAL(std::string("33631b3e0aaeb2a11c4994c917919324028873fe"), result); } }; diff --git a/Swiften/Component/UnitTest/ComponentSessionTest.cpp b/Swiften/Component/UnitTest/ComponentSessionTest.cpp index 86776e8..af8962a 100644 --- a/Swiften/Component/UnitTest/ComponentSessionTest.cpp +++ b/Swiften/Component/UnitTest/ComponentSessionTest.cpp @@ -180,7 +180,7 @@ class ComponentSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(event.element); ComponentHandshake::ref handshake(boost::dynamic_pointer_cast<ComponentHandshake>(event.element)); CPPUNIT_ASSERT(handshake); - CPPUNIT_ASSERT_EQUAL(String("4c4f8a41141722c8bbfbdd92d827f7b2fc0a542b"), handshake->getData()); + CPPUNIT_ASSERT_EQUAL(std::string("4c4f8a41141722c8bbfbdd92d827f7b2fc0a542b"), handshake->getData()); } Event popEvent() { @@ -192,7 +192,7 @@ class ComponentSessionTest : public CppUnit::TestFixture { bool available; bool whitespacePingEnabled; - String bindID; + std::string bindID; int resetCount; std::deque<Event> receivedEvents; }; diff --git a/Swiften/Config/swiften-config.cpp b/Swiften/Config/swiften-config.cpp index 4f4016e..d381faa 100644 --- a/Swiften/Config/swiften-config.cpp +++ b/Swiften/Config/swiften-config.cpp @@ -10,17 +10,18 @@ #include <boost/program_options/variables_map.hpp> #include <boost/program_options.hpp> #include <boost/version.hpp> +#include <string> -#include <Swiften/Base/String.h> #include <Swiften/Base/foreach.h> #include <Swiften/Base/Platform.h> #include <Swiften/Base/Paths.h> +#include <Swiften/Base/String.h> #include "swiften-config.h" using namespace Swift; -void printFlags(const std::vector<String>& flags) { +void printFlags(const std::vector<std::string>& flags) { for (size_t i = 0; i < flags.size(); ++i) { if (i > 0) { std::cout << " "; @@ -60,11 +61,11 @@ int main(int argc, char* argv[]) { } // Read in all variables - std::vector<String> libs; + std::vector<std::string> libs; for (size_t i = 0; LIBFLAGS[i]; ++i) { libs.push_back(LIBFLAGS[i]); } - std::vector<String> cflags; + std::vector<std::string> cflags; for (size_t i = 0; CPPFLAGS[i]; ++i) { cflags.push_back(CPPFLAGS[i]); } @@ -77,8 +78,8 @@ int main(int argc, char* argv[]) { // Replace "#" variables with the correct path for(size_t i = 0; i < libs.size(); ++i) { if (inPlace) { - String lib = libs[i]; - lib.replaceAll('#', topPath.string()); + std::string lib = libs[i]; + String::replaceAll(lib, '#', topPath.string()); libs[i] = lib; } else { @@ -87,8 +88,8 @@ int main(int argc, char* argv[]) { } for(size_t i = 0; i < cflags.size(); ++i) { if (inPlace) { - String cflag = cflags[i]; - cflag.replaceAll('#', topPath.string()); + std::string cflag = cflags[i]; + String::replaceAll(cflag, '#', topPath.string()); cflags[i] = cflag; } else { diff --git a/Swiften/Disco/CapsFileStorage.cpp b/Swiften/Disco/CapsFileStorage.cpp index 107cf28..2334acf 100644 --- a/Swiften/Disco/CapsFileStorage.cpp +++ b/Swiften/Disco/CapsFileStorage.cpp @@ -21,7 +21,7 @@ namespace Swift { CapsFileStorage::CapsFileStorage(const boost::filesystem::path& path) : path(path) { } -DiscoInfo::ref CapsFileStorage::getDiscoInfo(const String& hash) const { +DiscoInfo::ref CapsFileStorage::getDiscoInfo(const std::string& hash) const { boost::filesystem::path capsPath(getCapsPath(hash)); if (boost::filesystem::exists(capsPath)) { ByteArray data; @@ -29,7 +29,7 @@ DiscoInfo::ref CapsFileStorage::getDiscoInfo(const String& hash) const { DiscoInfoParser parser; PayloadParserTester tester(&parser); - tester.parse(String(data.getData(), data.getSize())); + tester.parse(std::string(data.getData(), data.getSize())); return boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload()); } else { @@ -37,7 +37,7 @@ DiscoInfo::ref CapsFileStorage::getDiscoInfo(const String& hash) const { } } -void CapsFileStorage::setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo) { +void CapsFileStorage::setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo) { boost::filesystem::path capsPath(getCapsPath(hash)); if (!boost::filesystem::exists(capsPath.parent_path())) { try { @@ -54,8 +54,8 @@ void CapsFileStorage::setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo) file.close(); } -boost::filesystem::path CapsFileStorage::getCapsPath(const String& hash) const { - return path / (Hexify::hexify(Base64::decode(hash)) + ".xml").getUTF8String(); +boost::filesystem::path CapsFileStorage::getCapsPath(const std::string& hash) const { + return path / (Hexify::hexify(Base64::decode(hash)) + ".xml"); } } diff --git a/Swiften/Disco/CapsFileStorage.h b/Swiften/Disco/CapsFileStorage.h index ea1b1a2..5faf08b 100644 --- a/Swiften/Disco/CapsFileStorage.h +++ b/Swiften/Disco/CapsFileStorage.h @@ -9,18 +9,18 @@ #include <boost/filesystem.hpp> #include "Swiften/Disco/CapsStorage.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class CapsFileStorage : public CapsStorage { public: CapsFileStorage(const boost::filesystem::path& path); - virtual DiscoInfo::ref getDiscoInfo(const String& hash) const; - virtual void setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo); + virtual DiscoInfo::ref getDiscoInfo(const std::string& hash) const; + virtual void setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo); private: - boost::filesystem::path getCapsPath(const String& hash) const; + boost::filesystem::path getCapsPath(const std::string& hash) const; private: boost::filesystem::path path; diff --git a/Swiften/Disco/CapsInfoGenerator.cpp b/Swiften/Disco/CapsInfoGenerator.cpp index 94f2a7a..5c0e9a7 100644 --- a/Swiften/Disco/CapsInfoGenerator.cpp +++ b/Swiften/Disco/CapsInfoGenerator.cpp @@ -22,11 +22,11 @@ namespace { namespace Swift { -CapsInfoGenerator::CapsInfoGenerator(const String& node) : node_(node) { +CapsInfoGenerator::CapsInfoGenerator(const std::string& node) : node_(node) { } CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const { - String serializedCaps; + std::string serializedCaps; std::vector<DiscoInfo::Identity> identities(discoInfo.getIdentities()); std::sort(identities.begin(), identities.end()); @@ -34,9 +34,9 @@ CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const { serializedCaps += identity.getCategory() + "/" + identity.getType() + "/" + identity.getLanguage() + "/" + identity.getName() + "<"; } - std::vector<String> features(discoInfo.getFeatures()); + std::vector<std::string> features(discoInfo.getFeatures()); std::sort(features.begin(), features.end()); - foreach (const String& feature, features) { + foreach (const std::string& feature, features) { serializedCaps += feature + "<"; } @@ -49,15 +49,15 @@ CapsInfo CapsInfoGenerator::generateCapsInfo(const DiscoInfo& discoInfo) const { continue; } serializedCaps += field->getName() + "<"; - std::vector<String> values(field->getRawValues()); + std::vector<std::string> values(field->getRawValues()); std::sort(values.begin(), values.end()); - foreach(const String& value, values) { + foreach(const std::string& value, values) { serializedCaps += value + "<"; } } } - String version(Base64::encode(SHA1::getHash(serializedCaps))); + std::string version(Base64::encode(SHA1::getHash(serializedCaps))); return CapsInfo(node_, version, "sha-1"); } diff --git a/Swiften/Disco/CapsInfoGenerator.h b/Swiften/Disco/CapsInfoGenerator.h index cc32bbd..41a1d94 100644 --- a/Swiften/Disco/CapsInfoGenerator.h +++ b/Swiften/Disco/CapsInfoGenerator.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/CapsInfo.h" namespace Swift { @@ -14,11 +14,11 @@ namespace Swift { class CapsInfoGenerator { public: - CapsInfoGenerator(const String& node); + CapsInfoGenerator(const std::string& node); CapsInfo generateCapsInfo(const DiscoInfo& discoInfo) const; private: - String node_; + std::string node_; }; } diff --git a/Swiften/Disco/CapsManager.cpp b/Swiften/Disco/CapsManager.cpp index 1c785e5..63166e6 100644 --- a/Swiften/Disco/CapsManager.cpp +++ b/Swiften/Disco/CapsManager.cpp @@ -26,7 +26,7 @@ void CapsManager::handlePresenceReceived(boost::shared_ptr<Presence> presence) { if (!capsInfo || capsInfo->getHash() != "sha-1" || presence->getPayload<ErrorPayload>()) { return; } - String hash = capsInfo->getVersion(); + std::string hash = capsInfo->getVersion(); if (capsStorage->getDiscoInfo(hash)) { return; } @@ -48,16 +48,16 @@ void CapsManager::handleStanzaChannelAvailableChanged(bool available) { } } -void CapsManager::handleDiscoInfoReceived(const JID& from, const String& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) { +void CapsManager::handleDiscoInfoReceived(const JID& from, const std::string& hash, DiscoInfo::ref discoInfo, ErrorPayload::ref error) { requestedDiscoInfos.erase(hash); if (error || CapsInfoGenerator("").generateCapsInfo(*discoInfo.get()).getVersion() != hash) { if (warnOnInvalidHash && !error) { std::cerr << "Warning: Caps from " << from.toString() << " do not verify" << std::endl; } failingCaps.insert(std::make_pair(from, hash)); - std::map<String, std::set< std::pair<JID, String> > >::iterator i = fallbacks.find(hash); + std::map<std::string, std::set< std::pair<JID, std::string> > >::iterator i = fallbacks.find(hash); if (i != fallbacks.end() && !i->second.empty()) { - std::pair<JID,String> fallbackAndNode = *i->second.begin(); + std::pair<JID,std::string> fallbackAndNode = *i->second.begin(); i->second.erase(i->second.begin()); requestDiscoInfo(fallbackAndNode.first, fallbackAndNode.second, hash); } @@ -68,14 +68,14 @@ void CapsManager::handleDiscoInfoReceived(const JID& from, const String& hash, D onCapsAvailable(hash); } -void CapsManager::requestDiscoInfo(const JID& jid, const String& node, const String& hash) { +void CapsManager::requestDiscoInfo(const JID& jid, const std::string& node, const std::string& hash) { GetDiscoInfoRequest::ref request = GetDiscoInfoRequest::create(jid, node + "#" + hash, iqRouter); request->onResponse.connect(boost::bind(&CapsManager::handleDiscoInfoReceived, this, jid, hash, _1, _2)); requestedDiscoInfos.insert(hash); request->send(); } -DiscoInfo::ref CapsManager::getCaps(const String& hash) const { +DiscoInfo::ref CapsManager::getCaps(const std::string& hash) const { return capsStorage->getDiscoInfo(hash); } diff --git a/Swiften/Disco/CapsManager.h b/Swiften/Disco/CapsManager.h index 842f2be..961dae8 100644 --- a/Swiften/Disco/CapsManager.h +++ b/Swiften/Disco/CapsManager.h @@ -26,7 +26,7 @@ namespace Swift { public: CapsManager(CapsStorage*, StanzaChannel*, IQRouter*); - DiscoInfo::ref getCaps(const String&) const; + DiscoInfo::ref getCaps(const std::string&) const; // Mainly for testing purposes void setWarnOnInvalidHash(bool b) { @@ -36,15 +36,15 @@ namespace Swift { private: void handlePresenceReceived(boost::shared_ptr<Presence>); void handleStanzaChannelAvailableChanged(bool); - void handleDiscoInfoReceived(const JID&, const String& hash, DiscoInfo::ref, ErrorPayload::ref); - void requestDiscoInfo(const JID& jid, const String& node, const String& hash); + void handleDiscoInfoReceived(const JID&, const std::string& hash, DiscoInfo::ref, ErrorPayload::ref); + void requestDiscoInfo(const JID& jid, const std::string& node, const std::string& hash); private: IQRouter* iqRouter; CapsStorage* capsStorage; bool warnOnInvalidHash; - std::set<String> requestedDiscoInfos; - std::set< std::pair<JID, String> > failingCaps; - std::map<String, std::set< std::pair<JID, String> > > fallbacks; + std::set<std::string> requestedDiscoInfos; + std::set< std::pair<JID, std::string> > failingCaps; + std::map<std::string, std::set< std::pair<JID, std::string> > > fallbacks; }; } diff --git a/Swiften/Disco/CapsMemoryStorage.h b/Swiften/Disco/CapsMemoryStorage.h index 71bd5d5..1e2d7be 100644 --- a/Swiften/Disco/CapsMemoryStorage.h +++ b/Swiften/Disco/CapsMemoryStorage.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include <map> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Disco/CapsStorage.h" namespace Swift { @@ -17,7 +17,7 @@ namespace Swift { public: CapsMemoryStorage() {} - virtual DiscoInfo::ref getDiscoInfo(const String& hash) const { + virtual DiscoInfo::ref getDiscoInfo(const std::string& hash) const { CapsMap::const_iterator i = caps.find(hash); if (i != caps.end()) { return i->second; @@ -27,12 +27,12 @@ namespace Swift { } } - virtual void setDiscoInfo(const String& hash, DiscoInfo::ref discoInfo) { + virtual void setDiscoInfo(const std::string& hash, DiscoInfo::ref discoInfo) { caps[hash] = discoInfo; } private: - typedef std::map<String, DiscoInfo::ref> CapsMap; + typedef std::map<std::string, DiscoInfo::ref> CapsMap; CapsMap caps; }; } diff --git a/Swiften/Disco/CapsProvider.h b/Swiften/Disco/CapsProvider.h index 815391a..71e2741 100644 --- a/Swiften/Disco/CapsProvider.h +++ b/Swiften/Disco/CapsProvider.h @@ -11,14 +11,14 @@ #include "Swiften/Elements/CapsInfo.h" namespace Swift { - class String; + class CapsProvider { public: virtual ~CapsProvider() {} - virtual DiscoInfo::ref getCaps(const String&) const = 0; + virtual DiscoInfo::ref getCaps(const std::string&) const = 0; - boost::signal<void (const String&)> onCapsAvailable; + boost::signal<void (const std::string&)> onCapsAvailable; }; } diff --git a/Swiften/Disco/CapsStorage.h b/Swiften/Disco/CapsStorage.h index e4ff945..f0a71a3 100644 --- a/Swiften/Disco/CapsStorage.h +++ b/Swiften/Disco/CapsStorage.h @@ -11,13 +11,13 @@ #include "Swiften/Elements/DiscoInfo.h" namespace Swift { - class String; + class CapsStorage { public: virtual ~CapsStorage(); - virtual DiscoInfo::ref getDiscoInfo(const String&) const = 0; - virtual void setDiscoInfo(const String&, DiscoInfo::ref) = 0; + virtual DiscoInfo::ref getDiscoInfo(const std::string&) const = 0; + virtual void setDiscoInfo(const std::string&, DiscoInfo::ref) = 0; }; } diff --git a/Swiften/Disco/ClientDiscoManager.cpp b/Swiften/Disco/ClientDiscoManager.cpp index 6753df2..fb7cce9 100644 --- a/Swiften/Disco/ClientDiscoManager.cpp +++ b/Swiften/Disco/ClientDiscoManager.cpp @@ -24,7 +24,7 @@ ClientDiscoManager::~ClientDiscoManager() { delete discoInfoResponder; } -void ClientDiscoManager::setCapsNode(const String& node) { +void ClientDiscoManager::setCapsNode(const std::string& node) { capsNode = node; } diff --git a/Swiften/Disco/ClientDiscoManager.h b/Swiften/Disco/ClientDiscoManager.h index b997374..3771044 100644 --- a/Swiften/Disco/ClientDiscoManager.h +++ b/Swiften/Disco/ClientDiscoManager.h @@ -41,7 +41,7 @@ namespace Swift { /** * Needs to be called before calling setDiscoInfo(). */ - void setCapsNode(const String& node); + void setCapsNode(const std::string& node); /** * Sets the capabilities of the client. @@ -61,7 +61,7 @@ namespace Swift { private: PayloadAddingPresenceSender* presenceSender; DiscoInfoResponder* discoInfoResponder; - String capsNode; + std::string capsNode; CapsInfo::ref capsInfo; }; } diff --git a/Swiften/Disco/DiscoInfoResponder.cpp b/Swiften/Disco/DiscoInfoResponder.cpp index 0254ad9..7ba044e 100644 --- a/Swiften/Disco/DiscoInfoResponder.cpp +++ b/Swiften/Disco/DiscoInfoResponder.cpp @@ -22,18 +22,18 @@ void DiscoInfoResponder::setDiscoInfo(const DiscoInfo& info) { info_ = info; } -void DiscoInfoResponder::setDiscoInfo(const String& node, const DiscoInfo& info) { +void DiscoInfoResponder::setDiscoInfo(const std::string& node, const DiscoInfo& info) { DiscoInfo newInfo(info); newInfo.setNode(node); nodeInfo_[node] = newInfo; } -bool DiscoInfoResponder::handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<DiscoInfo> info) { - if (info->getNode().isEmpty()) { +bool DiscoInfoResponder::handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<DiscoInfo> info) { + if (info->getNode().empty()) { sendResponse(from, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(info_))); } else { - std::map<String,DiscoInfo>::const_iterator i = nodeInfo_.find(info->getNode()); + std::map<std::string,DiscoInfo>::const_iterator i = nodeInfo_.find(info->getNode()); if (i != nodeInfo_.end()) { sendResponse(from, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo((*i).second))); } diff --git a/Swiften/Disco/DiscoInfoResponder.h b/Swiften/Disco/DiscoInfoResponder.h index 3861ffd..f114a21 100644 --- a/Swiften/Disco/DiscoInfoResponder.h +++ b/Swiften/Disco/DiscoInfoResponder.h @@ -20,13 +20,13 @@ namespace Swift { void clearDiscoInfo(); void setDiscoInfo(const DiscoInfo& info); - void setDiscoInfo(const String& node, const DiscoInfo& info); + void setDiscoInfo(const std::string& node, const DiscoInfo& info); private: - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<DiscoInfo> payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<DiscoInfo> payload); private: DiscoInfo info_; - std::map<String, DiscoInfo> nodeInfo_; + std::map<std::string, DiscoInfo> nodeInfo_; }; } diff --git a/Swiften/Disco/EntityCapsManager.cpp b/Swiften/Disco/EntityCapsManager.cpp index 26e0594..3f2e3d7 100644 --- a/Swiften/Disco/EntityCapsManager.cpp +++ b/Swiften/Disco/EntityCapsManager.cpp @@ -26,8 +26,8 @@ void EntityCapsManager::handlePresenceReceived(boost::shared_ptr<Presence> prese if (!capsInfo || capsInfo->getHash() != "sha-1" || presence->getPayload<ErrorPayload>()) { return; } - String hash = capsInfo->getVersion(); - std::map<JID, String>::iterator i = caps.find(from); + std::string hash = capsInfo->getVersion(); + std::map<JID, std::string>::iterator i = caps.find(from); if (i == caps.end() || i->second != hash) { caps.insert(std::make_pair(from, hash)); DiscoInfo::ref disco = capsProvider->getCaps(hash); @@ -41,7 +41,7 @@ void EntityCapsManager::handlePresenceReceived(boost::shared_ptr<Presence> prese } } else { - std::map<JID, String>::iterator i = caps.find(from); + std::map<JID, std::string>::iterator i = caps.find(from); if (i != caps.end()) { caps.erase(i); onCapsChanged(from); @@ -51,17 +51,17 @@ void EntityCapsManager::handlePresenceReceived(boost::shared_ptr<Presence> prese void EntityCapsManager::handleStanzaChannelAvailableChanged(bool available) { if (available) { - std::map<JID, String> capsCopy; + std::map<JID, std::string> capsCopy; capsCopy.swap(caps); - for (std::map<JID,String>::const_iterator i = capsCopy.begin(); i != capsCopy.end(); ++i) { + for (std::map<JID,std::string>::const_iterator i = capsCopy.begin(); i != capsCopy.end(); ++i) { onCapsChanged(i->first); } } } -void EntityCapsManager::handleCapsAvailable(const String& hash) { +void EntityCapsManager::handleCapsAvailable(const std::string& hash) { // TODO: Use Boost.Bimap ? - for (std::map<JID,String>::const_iterator i = caps.begin(); i != caps.end(); ++i) { + for (std::map<JID,std::string>::const_iterator i = caps.begin(); i != caps.end(); ++i) { if (i->second == hash) { onCapsChanged(i->first); } @@ -69,7 +69,7 @@ void EntityCapsManager::handleCapsAvailable(const String& hash) { } DiscoInfo::ref EntityCapsManager::getCaps(const JID& jid) const { - std::map<JID, String>::const_iterator i = caps.find(jid); + std::map<JID, std::string>::const_iterator i = caps.find(jid); if (i != caps.end()) { return capsProvider->getCaps(i->second); } diff --git a/Swiften/Disco/EntityCapsManager.h b/Swiften/Disco/EntityCapsManager.h index f507a1d..190f876 100644 --- a/Swiften/Disco/EntityCapsManager.h +++ b/Swiften/Disco/EntityCapsManager.h @@ -36,10 +36,10 @@ namespace Swift { private: void handlePresenceReceived(boost::shared_ptr<Presence>); void handleStanzaChannelAvailableChanged(bool); - void handleCapsAvailable(const String&); + void handleCapsAvailable(const std::string&); private: CapsProvider* capsProvider; - std::map<JID, String> caps; + std::map<JID, std::string> caps; }; } diff --git a/Swiften/Disco/GetDiscoInfoRequest.h b/Swiften/Disco/GetDiscoInfoRequest.h index 2298b5c..5cec530 100644 --- a/Swiften/Disco/GetDiscoInfoRequest.h +++ b/Swiften/Disco/GetDiscoInfoRequest.h @@ -18,7 +18,7 @@ namespace Swift { return ref(new GetDiscoInfoRequest(jid, router)); } - static ref create(const JID& jid, const String& node, IQRouter* router) { + static ref create(const JID& jid, const std::string& node, IQRouter* router) { return ref(new GetDiscoInfoRequest(jid, node, router)); } @@ -27,7 +27,7 @@ namespace Swift { GenericRequest<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(new DiscoInfo()), router) { } - GetDiscoInfoRequest(const JID& jid, const String& node, IQRouter* router) : + GetDiscoInfoRequest(const JID& jid, const std::string& node, IQRouter* router) : GenericRequest<DiscoInfo>(IQ::Get, jid, boost::shared_ptr<DiscoInfo>(new DiscoInfo()), router) { getPayloadGeneric()->setNode(node); } diff --git a/Swiften/Disco/JIDDiscoInfoResponder.cpp b/Swiften/Disco/JIDDiscoInfoResponder.cpp index 311447f..1298e5a 100644 --- a/Swiften/Disco/JIDDiscoInfoResponder.cpp +++ b/Swiften/Disco/JIDDiscoInfoResponder.cpp @@ -22,21 +22,21 @@ void JIDDiscoInfoResponder::setDiscoInfo(const JID& jid, const DiscoInfo& discoI i->second.discoInfo = discoInfo; } -void JIDDiscoInfoResponder::setDiscoInfo(const JID& jid, const String& node, const DiscoInfo& discoInfo) { +void JIDDiscoInfoResponder::setDiscoInfo(const JID& jid, const std::string& node, const DiscoInfo& discoInfo) { JIDDiscoInfoMap::iterator i = info.insert(std::make_pair(jid, JIDDiscoInfo())).first; DiscoInfo newInfo(discoInfo); newInfo.setNode(node); i->second.nodeDiscoInfo[node] = newInfo; } -bool JIDDiscoInfoResponder::handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<DiscoInfo> discoInfo) { +bool JIDDiscoInfoResponder::handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<DiscoInfo> discoInfo) { JIDDiscoInfoMap::const_iterator i = info.find(to); if (i != info.end()) { - if (discoInfo->getNode().isEmpty()) { + if (discoInfo->getNode().empty()) { sendResponse(from, to, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(i->second.discoInfo))); } else { - std::map<String,DiscoInfo>::const_iterator j = i->second.nodeDiscoInfo.find(discoInfo->getNode()); + std::map<std::string,DiscoInfo>::const_iterator j = i->second.nodeDiscoInfo.find(discoInfo->getNode()); if (j != i->second.nodeDiscoInfo.end()) { sendResponse(from, to, id, boost::shared_ptr<DiscoInfo>(new DiscoInfo(j->second))); } diff --git a/Swiften/Disco/JIDDiscoInfoResponder.h b/Swiften/Disco/JIDDiscoInfoResponder.h index aac43de..d532d0f 100644 --- a/Swiften/Disco/JIDDiscoInfoResponder.h +++ b/Swiften/Disco/JIDDiscoInfoResponder.h @@ -21,15 +21,15 @@ namespace Swift { void clearDiscoInfo(const JID& jid); void setDiscoInfo(const JID& jid, const DiscoInfo& info); - void setDiscoInfo(const JID& jid, const String& node, const DiscoInfo& info); + void setDiscoInfo(const JID& jid, const std::string& node, const DiscoInfo& info); private: - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<DiscoInfo> payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<DiscoInfo> payload); private: struct JIDDiscoInfo { DiscoInfo discoInfo; - std::map<String, DiscoInfo> nodeDiscoInfo; + std::map<std::string, DiscoInfo> nodeDiscoInfo; }; typedef std::map<JID, JIDDiscoInfo> JIDDiscoInfoMap; JIDDiscoInfoMap info; diff --git a/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp b/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp index aec3a92..d4cb331 100644 --- a/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp +++ b/Swiften/Disco/UnitTest/CapsInfoGeneratorTest.cpp @@ -30,9 +30,9 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture { CapsInfoGenerator testling("http://code.google.com/p/exodus"); CapsInfo result = testling.generateCapsInfo(discoInfo); - CPPUNIT_ASSERT_EQUAL(String("http://code.google.com/p/exodus"), result.getNode()); - CPPUNIT_ASSERT_EQUAL(String("sha-1"), result.getHash()); - CPPUNIT_ASSERT_EQUAL(String("QgayPKawpkPSDYmwT/WM94uAlu0="), result.getVersion()); + CPPUNIT_ASSERT_EQUAL(std::string("http://code.google.com/p/exodus"), result.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), result.getHash()); + CPPUNIT_ASSERT_EQUAL(std::string("QgayPKawpkPSDYmwT/WM94uAlu0="), result.getVersion()); } void testGenerate_XEP0115ComplexExample() { @@ -48,7 +48,7 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture { FormField::ref field = HiddenFormField::create("urn:xmpp:dataforms:softwareinfo"); field->setName("FORM_TYPE"); extension->addField(field); - std::vector<String> ipVersions; + std::vector<std::string> ipVersions; ipVersions.push_back("ipv6"); ipVersions.push_back("ipv4"); field = ListMultiFormField::create(ipVersions); @@ -77,7 +77,7 @@ class CapsInfoGeneratorTest : public CppUnit::TestFixture { CapsInfoGenerator testling("http://psi-im.org"); CapsInfo result = testling.generateCapsInfo(discoInfo); - CPPUNIT_ASSERT_EQUAL(String("q07IKJEyjvHSyhy//CH0CxmKi8w="), result.getVersion()); + CPPUNIT_ASSERT_EQUAL(std::string("q07IKJEyjvHSyhy//CH0CxmKi8w="), result.getVersion()); } }; diff --git a/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp b/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp index 988065f..bccf0d4 100644 --- a/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp +++ b/Swiften/Disco/UnitTest/DiscoInfoResponderTest.cpp @@ -45,7 +45,7 @@ class DiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string(""), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("foo")); testling.stop(); @@ -68,7 +68,7 @@ class DiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar-node"), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("bar")); testling.stop(); diff --git a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp index 0a498cf..544bdad 100644 --- a/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp +++ b/Swiften/Disco/UnitTest/EntityCapsManagerTest.cpp @@ -159,15 +159,15 @@ class EntityCapsManagerTest : public CppUnit::TestFixture { private: struct DummyCapsProvider : public CapsProvider { - virtual DiscoInfo::ref getCaps(const String& hash) const { - std::map<String, DiscoInfo::ref>::const_iterator i = caps.find(hash); + virtual DiscoInfo::ref getCaps(const std::string& hash) const { + std::map<std::string, DiscoInfo::ref>::const_iterator i = caps.find(hash); if (i != caps.end()) { return i->second; } return DiscoInfo::ref(); } - std::map<String, DiscoInfo::ref> caps; + std::map<std::string, DiscoInfo::ref> caps; }; private: diff --git a/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp b/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp index 03a3ee8..ef61afa 100644 --- a/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp +++ b/Swiften/Disco/UnitTest/JIDDiscoInfoResponderTest.cpp @@ -46,7 +46,7 @@ class JIDDiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string(""), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("foo")); testling.stop(); @@ -69,7 +69,7 @@ class JIDDiscoInfoResponderTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>()); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar-node"), payload->getNode()); CPPUNIT_ASSERT(payload->hasFeature("bar")); testling.stop(); diff --git a/Swiften/Elements/AuthRequest.h b/Swiften/Elements/AuthRequest.h index a1aac31..ba86900 100644 --- a/Swiften/Elements/AuthRequest.h +++ b/Swiften/Elements/AuthRequest.h @@ -14,14 +14,14 @@ namespace Swift { class AuthRequest : public Element { public: - AuthRequest(const String& mechanism = "") : mechanism_(mechanism) { + AuthRequest(const std::string& mechanism = "") : mechanism_(mechanism) { } - AuthRequest(const String& mechanism, const ByteArray& message) : + AuthRequest(const std::string& mechanism, const ByteArray& message) : mechanism_(mechanism), message_(message) { } - AuthRequest(const String& mechanism, const boost::optional<ByteArray>& message) : + AuthRequest(const std::string& mechanism, const boost::optional<ByteArray>& message) : mechanism_(mechanism), message_(message) { } @@ -33,16 +33,16 @@ namespace Swift { message_ = boost::optional<ByteArray>(message); } - const String& getMechanism() const { + const std::string& getMechanism() const { return mechanism_; } - void setMechanism(const String& mechanism) { + void setMechanism(const std::string& mechanism) { mechanism_ = mechanism; } private: - String mechanism_; + std::string mechanism_; boost::optional<ByteArray> message_; }; } diff --git a/Swiften/Elements/Body.h b/Swiften/Elements/Body.h index 8262e09..2887390 100644 --- a/Swiften/Elements/Body.h +++ b/Swiften/Elements/Body.h @@ -7,25 +7,25 @@ #pragma once #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class Body : public Payload { public: typedef boost::shared_ptr<Body> ref; - Body(const String& text = "") : text_(text) { + Body(const std::string& text = "") : text_(text) { } - void setText(const String& text) { + void setText(const std::string& text) { text_ = text; } - const String& getText() const { + const std::string& getText() const { return text_; } private: - String text_; + std::string text_; }; } diff --git a/Swiften/Elements/Bytestreams.h b/Swiften/Elements/Bytestreams.h index 9d45c8a..b493375 100644 --- a/Swiften/Elements/Bytestreams.h +++ b/Swiften/Elements/Bytestreams.h @@ -11,7 +11,7 @@ #include <boost/shared_ptr.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -20,20 +20,20 @@ namespace Swift { typedef boost::shared_ptr<Bytestreams> ref; struct StreamHost { - StreamHost(const String& host = "", const JID& jid = JID(), int port = -1) : host(host), jid(jid), port(port) {} + StreamHost(const std::string& host = "", const JID& jid = JID(), int port = -1) : host(host), jid(jid), port(port) {} - String host; + std::string host; JID jid; int port; }; Bytestreams() {} - const String& getStreamID() const { + const std::string& getStreamID() const { return id; } - void setStreamID(const String& id) { + void setStreamID(const std::string& id) { this->id = id; } @@ -54,7 +54,7 @@ namespace Swift { } private: - String id; + std::string id; boost::optional<JID> usedStreamHost; std::vector<StreamHost> streamHosts; }; diff --git a/Swiften/Elements/CapsInfo.h b/Swiften/Elements/CapsInfo.h index dc3cc2e..ccad278 100644 --- a/Swiften/Elements/CapsInfo.h +++ b/Swiften/Elements/CapsInfo.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -16,7 +16,7 @@ namespace Swift { public: typedef boost::shared_ptr<CapsInfo> ref; - CapsInfo(const String& node = "", const String& version = "", const String& hash = "sha-1") : node_(node), version_(version), hash_(hash) {} + CapsInfo(const std::string& node = "", const std::string& version = "", const std::string& hash = "sha-1") : node_(node), version_(version), hash_(hash) {} bool operator==(const CapsInfo& o) const { return o.node_ == node_ && o.version_ == version_ && o.hash_ == hash_; @@ -36,24 +36,24 @@ namespace Swift { } } - const String& getNode() const { return node_; } - void setNode(const String& node) { + const std::string& getNode() const { return node_; } + void setNode(const std::string& node) { node_ = node; } - const String& getVersion() const { return version_; } - void setVersion(const String& version) { + const std::string& getVersion() const { return version_; } + void setVersion(const std::string& version) { version_ = version; } - const String& getHash() const { return hash_; } - void setHash(const String& hash) { + const std::string& getHash() const { return hash_; } + void setHash(const std::string& hash) { hash_ = hash; } private: - String node_; - String version_; - String hash_; + std::string node_; + std::string version_; + std::string hash_; }; } diff --git a/Swiften/Elements/ChatState.h b/Swiften/Elements/ChatState.h index 8dcf77c..2896877 100644 --- a/Swiften/Elements/ChatState.h +++ b/Swiften/Elements/ChatState.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { diff --git a/Swiften/Elements/Command.h b/Swiften/Elements/Command.h index 73d359f..f4059a8 100644 --- a/Swiften/Elements/Command.h +++ b/Swiften/Elements/Command.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/Form.h" @@ -26,21 +26,21 @@ namespace Swift { struct Note { enum Type {Info, Warn, Error}; - Note(String note, Type type) : note(note), type(type) {}; + Note(std::string note, Type type) : note(note), type(type) {}; - String note; + std::string note; Type type; }; public: - Command(const String& node, const String& sessionID, Status status) { constructor(node, sessionID, NoAction, status);} - Command(const String& node = "", const String& sessionID = "", Action action = Execute) { constructor(node, sessionID, action, NoStatus); } + Command(const std::string& node, const std::string& sessionID, Status status) { constructor(node, sessionID, NoAction, status);} + Command(const std::string& node = "", const std::string& sessionID = "", Action action = Execute) { constructor(node, sessionID, action, NoStatus); } - const String& getNode() const { return node_; } - void setNode(const String& node) { node_ = node; } + const std::string& getNode() const { return node_; } + void setNode(const std::string& node) { node_ = node; } - const String& getSessionID() const { return sessionID_; } - void setSessionID(const String& id) { sessionID_ = id; } + const std::string& getSessionID() const { return sessionID_; } + void setSessionID(const std::string& id) { sessionID_ = id; } Action getAction() const { return action_; } void setAction(Action action) { action_ = action; } @@ -60,7 +60,7 @@ namespace Swift { void setForm(Form::ref payload) { form_ = payload; } private: - void constructor(const String& node, const String& sessionID, Action action, Status status) { + void constructor(const std::string& node, const std::string& sessionID, Action action, Status status) { node_ = node; sessionID_ = sessionID; action_ = action; @@ -69,8 +69,8 @@ namespace Swift { } private: - String node_; - String sessionID_; + std::string node_; + std::string sessionID_; Action action_; Status status_; Action executeAction_; diff --git a/Swiften/Elements/ComponentHandshake.h b/Swiften/Elements/ComponentHandshake.h index ca18e73..6047eab 100644 --- a/Swiften/Elements/ComponentHandshake.h +++ b/Swiften/Elements/ComponentHandshake.h @@ -9,25 +9,25 @@ #include <boost/shared_ptr.hpp> #include "Swiften/Elements/Element.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ComponentHandshake : public Element { public: typedef boost::shared_ptr<ComponentHandshake> ref; - ComponentHandshake(const String& data = "") : data(data) { + ComponentHandshake(const std::string& data = "") : data(data) { } - void setData(const String& d) { + void setData(const std::string& d) { data = d; } - const String& getData() const { + const std::string& getData() const { return data; } private: - String data; + std::string data; }; } diff --git a/Swiften/Elements/CompressRequest.h b/Swiften/Elements/CompressRequest.h index b6f01e3..0eb302a 100644 --- a/Swiften/Elements/CompressRequest.h +++ b/Swiften/Elements/CompressRequest.h @@ -13,18 +13,18 @@ namespace Swift { class CompressRequest : public Element { public: - CompressRequest(const String& method = "") : method_(method) {} + CompressRequest(const std::string& method = "") : method_(method) {} - const String& getMethod() const { + const std::string& getMethod() const { return method_; } - void setMethod(const String& method) { + void setMethod(const std::string& method) { method_ = method; } private: - String method_; + std::string method_; }; } diff --git a/Swiften/Elements/DiscoInfo.cpp b/Swiften/Elements/DiscoInfo.cpp index a939d48..9c43ef4 100644 --- a/Swiften/Elements/DiscoInfo.cpp +++ b/Swiften/Elements/DiscoInfo.cpp @@ -8,9 +8,9 @@ namespace Swift { -const String DiscoInfo::ChatStatesFeature = String("http://jabber.org/protocol/chatstates"); -const String DiscoInfo::SecurityLabelsFeature = String("urn:xmpp:sec-label:0"); -const String DiscoInfo::JabberSearchFeature = String("jabber:iq:search"); +const std::string DiscoInfo::ChatStatesFeature = std::string("http://jabber.org/protocol/chatstates"); +const std::string DiscoInfo::SecurityLabelsFeature = std::string("urn:xmpp:sec-label:0"); +const std::string DiscoInfo::JabberSearchFeature = std::string("jabber:iq:search"); bool DiscoInfo::Identity::operator<(const Identity& other) const { diff --git a/Swiften/Elements/DiscoInfo.h b/Swiften/Elements/DiscoInfo.h index 41bf6bf..5101884 100644 --- a/Swiften/Elements/DiscoInfo.h +++ b/Swiften/Elements/DiscoInfo.h @@ -10,7 +10,7 @@ #include <algorithm> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Form.h" @@ -19,29 +19,29 @@ namespace Swift { public: typedef boost::shared_ptr<DiscoInfo> ref; - static const String ChatStatesFeature; - static const String SecurityLabelsFeature; - static const String JabberSearchFeature; + static const std::string ChatStatesFeature; + static const std::string SecurityLabelsFeature; + static const std::string JabberSearchFeature; const static std::string SecurityLabels; class Identity { public: - Identity(const String& name, const String& category = "client", const String& type = "pc", const String& lang = "") : name_(name), category_(category), type_(type), lang_(lang) { + Identity(const std::string& name, const std::string& category = "client", const std::string& type = "pc", const std::string& lang = "") : name_(name), category_(category), type_(type), lang_(lang) { } - const String& getCategory() const { + const std::string& getCategory() const { return category_; } - const String& getType() const { + const std::string& getType() const { return type_; } - const String& getLanguage() const { + const std::string& getLanguage() const { return lang_; } - const String& getName() const { + const std::string& getName() const { return name_; } @@ -49,20 +49,20 @@ namespace Swift { bool operator<(const Identity& other) const; private: - String name_; - String category_; - String type_; - String lang_; + std::string name_; + std::string category_; + std::string type_; + std::string lang_; }; DiscoInfo() { } - const String& getNode() const { + const std::string& getNode() const { return node_; } - void setNode(const String& node) { + void setNode(const std::string& node) { node_ = node; } @@ -74,15 +74,15 @@ namespace Swift { identities_.push_back(identity); } - const std::vector<String>& getFeatures() const { + const std::vector<std::string>& getFeatures() const { return features_; } - void addFeature(const String& feature) { + void addFeature(const std::string& feature) { features_.push_back(feature); } - bool hasFeature(const String& feature) const { + bool hasFeature(const std::string& feature) const { return std::find(features_.begin(), features_.end(), feature) != features_.end(); } @@ -95,9 +95,9 @@ namespace Swift { } private: - String node_; + std::string node_; std::vector<Identity> identities_; - std::vector<String> features_; + std::vector<std::string> features_; std::vector<Form::ref> extensions_; }; } diff --git a/Swiften/Elements/DiscoItems.h b/Swiften/Elements/DiscoItems.h index 400947a..cc5a583 100644 --- a/Swiften/Elements/DiscoItems.h +++ b/Swiften/Elements/DiscoItems.h @@ -10,7 +10,7 @@ #include <algorithm> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -18,14 +18,14 @@ namespace Swift { public: class Item { public: - Item(const String& name, const JID& jid, const String& node="") : name_(name), jid_(jid), node_(node) { + Item(const std::string& name, const JID& jid, const std::string& node="") : name_(name), jid_(jid), node_(node) { } - const String& getName() const { + const std::string& getName() const { return name_; } - const String& getNode() const { + const std::string& getNode() const { return node_; } @@ -34,19 +34,19 @@ namespace Swift { } private: - String name_; + std::string name_; JID jid_; - String node_; + std::string node_; }; DiscoItems() { } - const String& getNode() const { + const std::string& getNode() const { return node_; } - void setNode(const String& node) { + void setNode(const std::string& node) { node_ = node; } @@ -59,7 +59,7 @@ namespace Swift { } private: - String node_; + std::string node_; std::vector<Item> items_; }; } diff --git a/Swiften/Elements/ErrorPayload.h b/Swiften/Elements/ErrorPayload.h index 8f849f2..12ad574 100644 --- a/Swiften/Elements/ErrorPayload.h +++ b/Swiften/Elements/ErrorPayload.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ErrorPayload : public Payload { @@ -43,7 +43,7 @@ namespace Swift { UnexpectedRequest }; - ErrorPayload(Condition condition = UndefinedCondition, Type type = Cancel, const String& text = String()) : type_(type), condition_(condition), text_(text) { } + ErrorPayload(Condition condition = UndefinedCondition, Type type = Cancel, const std::string& text = std::string()) : type_(type), condition_(condition), text_(text) { } Type getType() const { return type_; @@ -61,17 +61,17 @@ namespace Swift { condition_ = condition; } - void setText(const String& text) { + void setText(const std::string& text) { text_ = text; } - const String& getText() const { + const std::string& getText() const { return text_; } private: Type type_; Condition condition_; - String text_; + std::string text_; }; } diff --git a/Swiften/Elements/Form.cpp b/Swiften/Elements/Form.cpp index 41014ba..03fd1a4 100644 --- a/Swiften/Elements/Form.cpp +++ b/Swiften/Elements/Form.cpp @@ -9,13 +9,13 @@ namespace Swift { -String Form::getFormType() const { +std::string Form::getFormType() const { FormField::ref field = getField("FORM_TYPE"); boost::shared_ptr<HiddenFormField> f = boost::dynamic_pointer_cast<HiddenFormField>(field); return (f ? f->getValue() : ""); } -FormField::ref Form::getField(const String& name) const { +FormField::ref Form::getField(const std::string& name) const { foreach(FormField::ref field, fields_) { if (field->getName() == name) { return field; diff --git a/Swiften/Elements/Form.h b/Swiften/Elements/Form.h index 5e8f994..1c50f0c 100644 --- a/Swiften/Elements/Form.h +++ b/Swiften/Elements/Form.h @@ -10,7 +10,7 @@ #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/FormField.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" @@ -31,23 +31,23 @@ namespace Swift { void addField(boost::shared_ptr<FormField> field) { fields_.push_back(field); } const std::vector<boost::shared_ptr<FormField> >& getFields() const { return fields_; } - void setTitle(const String& title) { title_ = title; } - const String& getTitle() { return title_; } + void setTitle(const std::string& title) { title_ = title; } + const std::string& getTitle() { return title_; } - void setInstructions(const String& instructions) { instructions_ = instructions; } - const String& getInstructions() { return instructions_; } + void setInstructions(const std::string& instructions) { instructions_ = instructions; } + const std::string& getInstructions() { return instructions_; } Type getType() { return type_; } void setType(Type type) { type_ = type; } - String getFormType() const; + std::string getFormType() const; - FormField::ref getField(const String& name) const; + FormField::ref getField(const std::string& name) const; private: std::vector<boost::shared_ptr<FormField> > fields_; - String title_; - String instructions_; + std::string title_; + std::string instructions_; Type type_; }; } diff --git a/Swiften/Elements/FormField.h b/Swiften/Elements/FormField.h index 0221dae..f455303 100644 --- a/Swiften/Elements/FormField.h +++ b/Swiften/Elements/FormField.h @@ -12,7 +12,7 @@ #include <vector> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -23,19 +23,19 @@ namespace Swift { virtual ~FormField() {} struct Option { - Option(const String& label, const String& value) : label(label), value(value) {} - String label; - String value; + Option(const std::string& label, const std::string& value) : label(label), value(value) {} + std::string label; + std::string value; }; - void setName(const String& name) { this->name = name; } - const String& getName() const { return name; } + void setName(const std::string& name) { this->name = name; } + const std::string& getName() const { return name; } - void setLabel(const String& label) { this->label = label; } - const String& getLabel() const { return label; } + void setLabel(const std::string& label) { this->label = label; } + const std::string& getLabel() const { return label; } - void setDescription(const String& description) { this->description = description; } - const String& getDescription() const { return description; } + void setDescription(const std::string& description) { this->description = description; } + const std::string& getDescription() const { return description; } void setRequired(bool required) { this->required = required; } bool getRequired() const { return required; } @@ -48,11 +48,11 @@ namespace Swift { return options; } - const std::vector<String> getRawValues() const { + const std::vector<std::string> getRawValues() const { return rawValues; } - void addRawValue(const String& value) { + void addRawValue(const std::string& value) { rawValues.push_back(value); } @@ -60,12 +60,12 @@ namespace Swift { FormField() : required(false) {} private: - String name; - String label; - String description; + std::string name; + std::string label; + std::string description; bool required; std::vector<Option> options; - std::vector<String> rawValues; + std::vector<std::string> rawValues; }; template<typename T> class GenericFormField : public FormField { @@ -102,14 +102,14 @@ namespace Swift { }; SWIFTEN_DECLARE_FORM_FIELD(Boolean, bool); - SWIFTEN_DECLARE_FORM_FIELD(Fixed, String); - SWIFTEN_DECLARE_FORM_FIELD(Hidden, String); - SWIFTEN_DECLARE_FORM_FIELD(ListSingle, String); - SWIFTEN_DECLARE_FORM_FIELD(TextMulti, String); - SWIFTEN_DECLARE_FORM_FIELD(TextPrivate, String); - SWIFTEN_DECLARE_FORM_FIELD(TextSingle, String); + SWIFTEN_DECLARE_FORM_FIELD(Fixed, std::string); + SWIFTEN_DECLARE_FORM_FIELD(Hidden, std::string); + SWIFTEN_DECLARE_FORM_FIELD(ListSingle, std::string); + SWIFTEN_DECLARE_FORM_FIELD(TextMulti, std::string); + SWIFTEN_DECLARE_FORM_FIELD(TextPrivate, std::string); + SWIFTEN_DECLARE_FORM_FIELD(TextSingle, std::string); SWIFTEN_DECLARE_FORM_FIELD(JIDSingle, JID); SWIFTEN_DECLARE_FORM_FIELD(JIDMulti, std::vector<JID>); - SWIFTEN_DECLARE_FORM_FIELD(ListMulti, std::vector<String>); - SWIFTEN_DECLARE_FORM_FIELD(Untyped, std::vector<String>); + SWIFTEN_DECLARE_FORM_FIELD(ListMulti, std::vector<std::string>); + SWIFTEN_DECLARE_FORM_FIELD(Untyped, std::vector<std::string>); } diff --git a/Swiften/Elements/IBB.h b/Swiften/Elements/IBB.h index 727755f..55f2c4f 100644 --- a/Swiften/Elements/IBB.h +++ b/Swiften/Elements/IBB.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Elements/Payload.h" @@ -27,23 +27,23 @@ namespace Swift { MessageStanza, }; - IBB(Action action = Open, const String& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) { + IBB(Action action = Open, const std::string& streamID = "") : action(action), streamID(streamID), stanzaType(IQStanza), blockSize(-1), sequenceNumber(-1) { } - static IBB::ref createIBBOpen(const String& streamID, int blockSize) { + static IBB::ref createIBBOpen(const std::string& streamID, int blockSize) { IBB::ref result(new IBB(Open, streamID)); result->setBlockSize(blockSize); return result; } - static IBB::ref createIBBData(const String& streamID, int sequenceNumber, const ByteArray& data) { + static IBB::ref createIBBData(const std::string& streamID, int sequenceNumber, const ByteArray& data) { IBB::ref result(new IBB(Data, streamID)); result->setSequenceNumber(sequenceNumber); result->setData(data); return result; } - static IBB::ref createIBBClose(const String& streamID) { + static IBB::ref createIBBClose(const std::string& streamID) { return IBB::ref(new IBB(Close, streamID)); } @@ -63,11 +63,11 @@ namespace Swift { return stanzaType; } - void setStreamID(const String& id) { + void setStreamID(const std::string& id) { streamID = id; } - const String& getStreamID() const { + const std::string& getStreamID() const { return streamID; } @@ -97,7 +97,7 @@ namespace Swift { private: Action action; - String streamID; + std::string streamID; ByteArray data; StanzaType stanzaType; int blockSize; diff --git a/Swiften/Elements/IQ.cpp b/Swiften/Elements/IQ.cpp index abf32e9..eb62ee4 100644 --- a/Swiften/Elements/IQ.cpp +++ b/Swiften/Elements/IQ.cpp @@ -9,7 +9,7 @@ namespace Swift { boost::shared_ptr<IQ> IQ::createRequest( - Type type, const JID& to, const String& id, boost::shared_ptr<Payload> payload) { + Type type, const JID& to, const std::string& id, boost::shared_ptr<Payload> payload) { boost::shared_ptr<IQ> iq(new IQ(type)); if (to.isValid()) { iq->setTo(to); @@ -21,7 +21,7 @@ boost::shared_ptr<IQ> IQ::createRequest( return iq; } -boost::shared_ptr<IQ> IQ::createResult(const JID& to, const String& id, boost::shared_ptr<Payload> payload) { +boost::shared_ptr<IQ> IQ::createResult(const JID& to, const std::string& id, boost::shared_ptr<Payload> payload) { boost::shared_ptr<IQ> iq(new IQ(Result)); iq->setTo(to); iq->setID(id); @@ -31,7 +31,7 @@ boost::shared_ptr<IQ> IQ::createResult(const JID& to, const String& id, boost::s return iq; } -boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const String& id, boost::shared_ptr<Payload> payload) { +boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const std::string& id, boost::shared_ptr<Payload> payload) { boost::shared_ptr<IQ> iq(new IQ(Result)); iq->setTo(to); iq->setFrom(from); @@ -42,7 +42,7 @@ boost::shared_ptr<IQ> IQ::createResult(const JID& to, const JID& from, const Str return iq; } -boost::shared_ptr<IQ> IQ::createError(const JID& to, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { +boost::shared_ptr<IQ> IQ::createError(const JID& to, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); iq->setTo(to); iq->setID(id); @@ -50,7 +50,7 @@ boost::shared_ptr<IQ> IQ::createError(const JID& to, const String& id, ErrorPayl return iq; } -boost::shared_ptr<IQ> IQ::createError(const JID& to, const JID& from, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { +boost::shared_ptr<IQ> IQ::createError(const JID& to, const JID& from, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); iq->setTo(to); iq->setFrom(from); diff --git a/Swiften/Elements/IQ.h b/Swiften/Elements/IQ.h index 007dda2..78a8bbd 100644 --- a/Swiften/Elements/IQ.h +++ b/Swiften/Elements/IQ.h @@ -26,26 +26,26 @@ namespace Swift { static boost::shared_ptr<IQ> createRequest( Type type, const JID& to, - const String& id, + const std::string& id, boost::shared_ptr<Payload> payload); static boost::shared_ptr<IQ> createResult( const JID& to, - const String& id, + const std::string& id, boost::shared_ptr<Payload> payload = boost::shared_ptr<Payload>()); static boost::shared_ptr<IQ> createResult( const JID& to, const JID& from, - const String& id, + const std::string& id, boost::shared_ptr<Payload> payload = boost::shared_ptr<Payload>()); static boost::shared_ptr<IQ> createError( const JID& to, - const String& id, + const std::string& id, ErrorPayload::Condition condition = ErrorPayload::BadRequest, ErrorPayload::Type type = ErrorPayload::Cancel); static boost::shared_ptr<IQ> createError( const JID& to, const JID& from, - const String& id, + const std::string& id, ErrorPayload::Condition condition = ErrorPayload::BadRequest, ErrorPayload::Type type = ErrorPayload::Cancel); diff --git a/Swiften/Elements/InBandRegistrationPayload.h b/Swiften/Elements/InBandRegistrationPayload.h index 1a293ba..e4e1e6f 100644 --- a/Swiften/Elements/InBandRegistrationPayload.h +++ b/Swiften/Elements/InBandRegistrationPayload.h @@ -11,7 +11,7 @@ #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/Form.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class InBandRegistrationPayload : public Payload { @@ -39,147 +39,147 @@ namespace Swift { remove = b; } - const boost::optional<String>& getInstructions() const { + const boost::optional<std::string>& getInstructions() const { return instructions; } - const boost::optional<String>& getUsername() const { + const boost::optional<std::string>& getUsername() const { return username; } - const boost::optional<String>& getNick() const { + const boost::optional<std::string>& getNick() const { return nick; } - const boost::optional<String>& getPassword() const { + const boost::optional<std::string>& getPassword() const { return password; } - const boost::optional<String>& getName() const { + const boost::optional<std::string>& getName() const { return name; } - const boost::optional<String>& getFirst() const { + const boost::optional<std::string>& getFirst() const { return first; } - const boost::optional<String>& getLast() const { + const boost::optional<std::string>& getLast() const { return last; } - const boost::optional<String>& getEMail() const { + const boost::optional<std::string>& getEMail() const { return email; } - const boost::optional<String>& getAddress() const { + const boost::optional<std::string>& getAddress() const { return address; } - const boost::optional<String>& getCity() const { + const boost::optional<std::string>& getCity() const { return city; } - const boost::optional<String>& getState() const { + const boost::optional<std::string>& getState() const { return state; } - const boost::optional<String>& getZip() const { + const boost::optional<std::string>& getZip() const { return zip; } - const boost::optional<String>& getPhone() const { + const boost::optional<std::string>& getPhone() const { return phone; } - const boost::optional<String>& getURL() const { + const boost::optional<std::string>& getURL() const { return url; } - const boost::optional<String>& getDate() const { + const boost::optional<std::string>& getDate() const { return date; } - const boost::optional<String>& getMisc() const { + const boost::optional<std::string>& getMisc() const { return misc; } - const boost::optional<String>& getText() const { + const boost::optional<std::string>& getText() const { return text; } - const boost::optional<String>& getKey() const { + const boost::optional<std::string>& getKey() const { return key; } - void setInstructions(const String& v) { + void setInstructions(const std::string& v) { this->instructions = v; } - void setUsername(const String& v) { + void setUsername(const std::string& v) { this->username = v; } - void setNick(const String& v) { + void setNick(const std::string& v) { this->nick = v; } - void setPassword(const String& v) { + void setPassword(const std::string& v) { this->password = v; } - void setName(const String& v) { + void setName(const std::string& v) { this->name = v; } - void setFirst(const String& v) { + void setFirst(const std::string& v) { this->first = v; } - void setLast(const String& v) { + void setLast(const std::string& v) { this->last = v; } - void setEMail(const String& v) { + void setEMail(const std::string& v) { this->email = v; } - void setAddress(const String& v) { + void setAddress(const std::string& v) { this->address = v; } - void setCity(const String& v) { + void setCity(const std::string& v) { this->city = v; } - void setState(const String& v) { + void setState(const std::string& v) { this->state = v; } - void setZip(const String& v) { + void setZip(const std::string& v) { this->zip = v; } - void setPhone(const String& v) { + void setPhone(const std::string& v) { this->phone = v; } - void setURL(const String& v) { + void setURL(const std::string& v) { this->url = v; } - void setDate(const String& v) { + void setDate(const std::string& v) { this->date = v; } - void setMisc(const String& v) { + void setMisc(const std::string& v) { this->misc = v; } - void setText(const String& v) { + void setText(const std::string& v) { this->text = v; } - void setKey(const String& v) { + void setKey(const std::string& v) { this->key = v; } @@ -187,23 +187,23 @@ namespace Swift { Form::ref form; bool registered; bool remove; - boost::optional<String> instructions; - boost::optional<String> username; - boost::optional<String> nick; - boost::optional<String> password; - boost::optional<String> name; - boost::optional<String> first; - boost::optional<String> last; - boost::optional<String> email; - boost::optional<String> address; - boost::optional<String> city; - boost::optional<String> state; - boost::optional<String> zip; - boost::optional<String> phone; - boost::optional<String> url; - boost::optional<String> date; - boost::optional<String> misc; - boost::optional<String> text; - boost::optional<String> key; + boost::optional<std::string> instructions; + boost::optional<std::string> username; + boost::optional<std::string> nick; + boost::optional<std::string> password; + boost::optional<std::string> name; + boost::optional<std::string> first; + boost::optional<std::string> last; + boost::optional<std::string> email; + boost::optional<std::string> address; + boost::optional<std::string> city; + boost::optional<std::string> state; + boost::optional<std::string> zip; + boost::optional<std::string> phone; + boost::optional<std::string> url; + boost::optional<std::string> date; + boost::optional<std::string> misc; + boost::optional<std::string> text; + boost::optional<std::string> key; }; } diff --git a/Swiften/Elements/JingleContent.h b/Swiften/Elements/JingleContent.h index bf419aa..4ae908b 100644 --- a/Swiften/Elements/JingleContent.h +++ b/Swiften/Elements/JingleContent.h @@ -9,7 +9,7 @@ #include <vector> #include <boost/optional.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/JingleDescription.h> @@ -37,7 +37,7 @@ namespace Swift { this->creator = creator; } - void setName(const String& name) { + void setName(const std::string& name) { this->name = name; } @@ -81,7 +81,7 @@ namespace Swift { private: Creator creator; - String name; + std::string name; //Senders senders; std::vector<JingleDescription::ref> descriptions; std::vector<JingleTransport::ref> transports; diff --git a/Swiften/Elements/JingleIBBTransport.h b/Swiften/Elements/JingleIBBTransport.h index ca3ecc8..faa5af3 100644 --- a/Swiften/Elements/JingleIBBTransport.h +++ b/Swiften/Elements/JingleIBBTransport.h @@ -6,7 +6,7 @@ #pragma once -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/Elements/JingleTransport.h> namespace Swift { @@ -25,11 +25,11 @@ namespace Swift { return stanzaType; } - void setSessionID(const String& id) { + void setSessionID(const std::string& id) { sessionID = id; } - const String& getSessionID() const { + const std::string& getSessionID() const { return sessionID; } @@ -42,7 +42,7 @@ namespace Swift { } private: - String sessionID; + std::string sessionID; int blockSize; StanzaType stanzaType; }; diff --git a/Swiften/Elements/JinglePayload.h b/Swiften/Elements/JinglePayload.h index 66b6d43..59d3c99 100644 --- a/Swiften/Elements/JinglePayload.h +++ b/Swiften/Elements/JinglePayload.h @@ -9,7 +9,7 @@ #include <vector> #include <boost/optional.hpp> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/Payload.h> #include <Swiften/Elements/JingleContent.h> @@ -40,9 +40,9 @@ namespace Swift { UnsupportedTransports }; - Reason(Type type, const String& text = "") : type(type), text(text) {} + Reason(Type type, const std::string& text = "") : type(type), text(text) {} Type type; - String text; + std::string text; }; enum Action { @@ -63,7 +63,7 @@ namespace Swift { TransportReplace }; - JinglePayload(Action action, const String& sessionID) : action(action), sessionID(sessionID) { + JinglePayload(Action action, const std::string& sessionID) : action(action), sessionID(sessionID) { } void setAction(Action action) { @@ -90,11 +90,11 @@ namespace Swift { return responder; } - void setSessionID(const String& id) { + void setSessionID(const std::string& id) { sessionID = id; } - const String& getSessionID() const { + const std::string& getSessionID() const { return sessionID; } @@ -118,7 +118,7 @@ namespace Swift { Action action; JID initiator; JID responder; - String sessionID; + std::string sessionID; std::vector<JingleContent::ref> contents; boost::optional<Reason> reason; }; diff --git a/Swiften/Elements/MUCOccupant.cpp b/Swiften/Elements/MUCOccupant.cpp index 0d3773e..a5d8f0e 100644 --- a/Swiften/Elements/MUCOccupant.cpp +++ b/Swiften/Elements/MUCOccupant.cpp @@ -8,7 +8,7 @@ namespace Swift { -MUCOccupant::MUCOccupant(const String &nick, Role role, Affiliation affiliation) : nick_(nick), role_(role), affiliation_(affiliation) { +MUCOccupant::MUCOccupant(const std::string &nick, Role role, Affiliation affiliation) : nick_(nick), role_(role), affiliation_(affiliation) { } MUCOccupant::~MUCOccupant() { @@ -18,7 +18,7 @@ MUCOccupant::MUCOccupant(const MUCOccupant& other) : nick_(other.getNick()), rol } -String MUCOccupant::getNick() const { +std::string MUCOccupant::getNick() const { return nick_; } @@ -34,7 +34,7 @@ void MUCOccupant::setRealJID(const JID& realJID) { realJID_ = realJID; } -void MUCOccupant::setNick(const String& nick) { +void MUCOccupant::setNick(const std::string& nick) { nick_ = nick; } diff --git a/Swiften/Elements/MUCOccupant.h b/Swiften/Elements/MUCOccupant.h index 96ac5ad..b3ae4aa 100644 --- a/Swiften/Elements/MUCOccupant.h +++ b/Swiften/Elements/MUCOccupant.h @@ -8,7 +8,7 @@ #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -19,19 +19,19 @@ namespace Swift { enum Role {Moderator, Participant, Visitor, NoRole}; enum Affiliation {Owner, Admin, Member, Outcast, NoAffiliation}; - MUCOccupant(const String &nick, Role role, Affiliation affiliation); + MUCOccupant(const std::string &nick, Role role, Affiliation affiliation); MUCOccupant(const MUCOccupant& other); ~MUCOccupant(); - String getNick() const; + std::string getNick() const; Role getRole() const; Affiliation getAffiliation() const; boost::optional<JID> getRealJID() const; void setRealJID(const JID& jid); - void setNick(const String& nick); + void setNick(const std::string& nick); private: - String nick_; + std::string nick_; Role role_; Affiliation affiliation_; boost::optional<JID> realJID_; diff --git a/Swiften/Elements/MUCPayload.h b/Swiften/Elements/MUCPayload.h index b8210e1..c372360 100644 --- a/Swiften/Elements/MUCPayload.h +++ b/Swiften/Elements/MUCPayload.h @@ -10,7 +10,7 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { diff --git a/Swiften/Elements/MUCUserPayload.h b/Swiften/Elements/MUCUserPayload.h index 2364b6c..fb6d4c4 100644 --- a/Swiften/Elements/MUCUserPayload.h +++ b/Swiften/Elements/MUCUserPayload.h @@ -8,9 +8,10 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> +#include <string> +#include <vector> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/MUCOccupant.h" @@ -22,7 +23,7 @@ namespace Swift { struct Item { Item(MUCOccupant::Affiliation affiliation = MUCOccupant::NoAffiliation, MUCOccupant::Role role = MUCOccupant::NoRole) : affiliation(affiliation), role(role) {} boost::optional<JID> realJID; - boost::optional<String> nick; + boost::optional<std::string> nick; MUCOccupant::Affiliation affiliation; MUCOccupant::Role role; }; diff --git a/Swiften/Elements/Message.h b/Swiften/Elements/Message.h index ea03299..a553eb3 100644 --- a/Swiften/Elements/Message.h +++ b/Swiften/Elements/Message.h @@ -9,7 +9,7 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Body.h" #include "Swiften/Elements/Subject.h" #include "Swiften/Elements/ErrorPayload.h" @@ -24,7 +24,7 @@ namespace Swift { Message() : type_(Chat) { } - String getSubject() const { + std::string getSubject() const { boost::shared_ptr<Subject> subject(getPayload<Subject>()); if (subject) { return subject->getText(); @@ -32,11 +32,11 @@ namespace Swift { return ""; } - void setSubject(const String& subject) { + void setSubject(const std::string& subject) { updatePayload(boost::shared_ptr<Subject>(new Subject(subject))); } - String getBody() const { + std::string getBody() const { boost::shared_ptr<Body> body(getPayload<Body>()); if (body) { return body->getText(); @@ -44,7 +44,7 @@ namespace Swift { return ""; } - void setBody(const String& body) { + void setBody(const std::string& body) { updatePayload(boost::shared_ptr<Body>(new Body(body))); } diff --git a/Swiften/Elements/Nickname.h b/Swiften/Elements/Nickname.h index 1a8d648..540f6da 100644 --- a/Swiften/Elements/Nickname.h +++ b/Swiften/Elements/Nickname.h @@ -7,23 +7,23 @@ #pragma once #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class Nickname : public Payload { public: - Nickname(const String& nickname = "") : nickname(nickname) { + Nickname(const std::string& nickname = "") : nickname(nickname) { } - void setNickname(const String& nickname) { + void setNickname(const std::string& nickname) { this->nickname = nickname; } - const String& getNickname() const { + const std::string& getNickname() const { return nickname; } private: - String nickname; + std::string nickname; }; } diff --git a/Swiften/Elements/Presence.h b/Swiften/Elements/Presence.h index 642262c..7f957ba 100644 --- a/Swiften/Elements/Presence.h +++ b/Swiften/Elements/Presence.h @@ -20,7 +20,7 @@ namespace Swift { enum Type { Available, Error, Probe, Subscribe, Subscribed, Unavailable, Unsubscribe, Unsubscribed }; Presence() : type_(Available) /*, showType_(Online)*/ {} - Presence(const String& status) : type_(Available) { + Presence(const std::string& status) : type_(Available) { setStatus(status); } @@ -28,7 +28,7 @@ namespace Swift { return ref(new Presence()); } - static ref create(const String& status) { + static ref create(const std::string& status) { return ref(new Presence(status)); } @@ -51,7 +51,7 @@ namespace Swift { updatePayload(boost::shared_ptr<StatusShow>(new StatusShow(show))); } - String getStatus() const { + std::string getStatus() const { boost::shared_ptr<Status> status(getPayload<Status>()); if (status) { return status->getText(); @@ -59,7 +59,7 @@ namespace Swift { return ""; } - void setStatus(const String& status) { + void setStatus(const std::string& status) { updatePayload(boost::shared_ptr<Status>(new Status(status))); } diff --git a/Swiften/Elements/ProtocolHeader.h b/Swiften/Elements/ProtocolHeader.h index 36ece34..841f7a0 100644 --- a/Swiften/Elements/ProtocolHeader.h +++ b/Swiften/Elements/ProtocolHeader.h @@ -6,37 +6,37 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ProtocolHeader { public: ProtocolHeader() : version("1.0") {} - const String& getTo() const { return to; } - void setTo(const String& a) { + const std::string& getTo() const { return to; } + void setTo(const std::string& a) { to = a; } - const String& getFrom() const { return from; } - void setFrom(const String& a) { + const std::string& getFrom() const { return from; } + void setFrom(const std::string& a) { from = a; } - const String& getVersion() const { return version; } - void setVersion(const String& a) { + const std::string& getVersion() const { return version; } + void setVersion(const std::string& a) { version = a; } - const String& getID() const { return id; } - void setID(const String& a) { + const std::string& getID() const { return id; } + void setID(const std::string& a) { id = a; } private: - String to; - String from; - String id; - String version; + std::string to; + std::string from; + std::string id; + std::string version; }; } diff --git a/Swiften/Elements/RawXMLPayload.h b/Swiften/Elements/RawXMLPayload.h index 0a381ac..b042b95 100644 --- a/Swiften/Elements/RawXMLPayload.h +++ b/Swiften/Elements/RawXMLPayload.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -14,15 +14,15 @@ namespace Swift { public: RawXMLPayload() {} - void setRawXML(const String& data) { + void setRawXML(const std::string& data) { rawXML_ = data; } - const String& getRawXML() const { + const std::string& getRawXML() const { return rawXML_; } private: - String rawXML_; + std::string rawXML_; }; } diff --git a/Swiften/Elements/ResourceBind.h b/Swiften/Elements/ResourceBind.h index c13ac69..3569eb3 100644 --- a/Swiften/Elements/ResourceBind.h +++ b/Swiften/Elements/ResourceBind.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_ResourceBind_H #define SWIFTEN_ResourceBind_H -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" #include "Swiften/JID/JID.h" @@ -25,17 +25,17 @@ namespace Swift { return jid_; } - void setResource(const String& resource) { + void setResource(const std::string& resource) { resource_ = resource; } - const String& getResource() const { + const std::string& getResource() const { return resource_; } private: JID jid_; - String resource_; + std::string resource_; }; } diff --git a/Swiften/Elements/RosterItemPayload.h b/Swiften/Elements/RosterItemPayload.h index 84b2887..b8a1b10 100644 --- a/Swiften/Elements/RosterItemPayload.h +++ b/Swiften/Elements/RosterItemPayload.h @@ -10,7 +10,7 @@ #include <vector> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class RosterItemPayload @@ -19,36 +19,36 @@ namespace Swift { enum Subscription { None, To, From, Both, Remove }; RosterItemPayload() : subscription_(None), ask_(false) {} - RosterItemPayload(const JID& jid, const String& name, Subscription subscription) : jid_(jid), name_(name), subscription_(subscription), ask_(false) { } + RosterItemPayload(const JID& jid, const std::string& name, Subscription subscription) : jid_(jid), name_(name), subscription_(subscription), ask_(false) { } void setJID(const JID& jid) { jid_ = jid; } const JID& getJID() const { return jid_; } - void setName(const String& name) { name_ = name; } - const String& getName() const { return name_; } + void setName(const std::string& name) { name_ = name; } + const std::string& getName() const { return name_; } void setSubscription(Subscription subscription) { subscription_ = subscription; } const Subscription& getSubscription() const { return subscription_; } - void addGroup(const String& group) { groups_.push_back(group); } - void setGroups(const std::vector<String>& groups) { groups_ = groups; } - const std::vector<String>& getGroups() const { return groups_; } + void addGroup(const std::string& group) { groups_.push_back(group); } + void setGroups(const std::vector<std::string>& groups) { groups_ = groups; } + const std::vector<std::string>& getGroups() const { return groups_; } void setSubscriptionRequested() { ask_ = true; } bool getSubscriptionRequested() const { return ask_; } - const String& getUnknownContent() const { return unknownContent_; } - void addUnknownContent(const String& c) { + const std::string& getUnknownContent() const { return unknownContent_; } + void addUnknownContent(const std::string& c) { unknownContent_ += c; } private: JID jid_; - String name_; + std::string name_; Subscription subscription_; - std::vector<String> groups_; + std::vector<std::string> groups_; bool ask_; - String unknownContent_; + std::string unknownContent_; }; } diff --git a/Swiften/Elements/SearchPayload.h b/Swiften/Elements/SearchPayload.h index 61b8547..3a484cc 100644 --- a/Swiften/Elements/SearchPayload.h +++ b/Swiften/Elements/SearchPayload.h @@ -11,7 +11,7 @@ #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/Form.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { /** @@ -22,10 +22,10 @@ namespace Swift { typedef boost::shared_ptr<SearchPayload> ref; struct Item { - String first; - String last; - String nick; - String email; + std::string first; + std::string last; + std::string nick; + std::string email; JID jid; }; @@ -34,43 +34,43 @@ namespace Swift { Form::ref getForm() const { return form; } void setForm(Form::ref f) { form = f; } - const boost::optional<String>& getInstructions() const { + const boost::optional<std::string>& getInstructions() const { return instructions; } - const boost::optional<String>& getNick() const { + const boost::optional<std::string>& getNick() const { return nick; } - const boost::optional<String>& getFirst() const { + const boost::optional<std::string>& getFirst() const { return first; } - const boost::optional<String>& getLast() const { + const boost::optional<std::string>& getLast() const { return last; } - const boost::optional<String>& getEMail() const { + const boost::optional<std::string>& getEMail() const { return email; } - void setInstructions(const String& v) { + void setInstructions(const std::string& v) { this->instructions = v; } - void setNick(const String& v) { + void setNick(const std::string& v) { this->nick = v; } - void setFirst(const String& v) { + void setFirst(const std::string& v) { this->first = v; } - void setLast(const String& v) { + void setLast(const std::string& v) { this->last = v; } - void setEMail(const String& v) { + void setEMail(const std::string& v) { this->email = v; } @@ -84,11 +84,11 @@ namespace Swift { private: Form::ref form; - boost::optional<String> instructions; - boost::optional<String> nick; - boost::optional<String> first; - boost::optional<String> last; - boost::optional<String> email; + boost::optional<std::string> instructions; + boost::optional<std::string> nick; + boost::optional<std::string> first; + boost::optional<std::string> last; + boost::optional<std::string> email; std::vector<Item> items; }; } diff --git a/Swiften/Elements/SecurityLabel.h b/Swiften/Elements/SecurityLabel.h index 978d14f..ca38e32 100644 --- a/Swiften/Elements/SecurityLabel.h +++ b/Swiften/Elements/SecurityLabel.h @@ -9,7 +9,7 @@ #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -17,46 +17,46 @@ namespace Swift { public: SecurityLabel() {} - const String& getDisplayMarking() const { return displayMarking_; } + const std::string& getDisplayMarking() const { return displayMarking_; } - void setDisplayMarking(const String& displayMarking) { + void setDisplayMarking(const std::string& displayMarking) { displayMarking_ = displayMarking; } - const String& getForegroundColor() const { + const std::string& getForegroundColor() const { return foregroundColor_; } - void setForegroundColor(const String& foregroundColor) { + void setForegroundColor(const std::string& foregroundColor) { foregroundColor_ = foregroundColor; } - const String& getBackgroundColor() const { + const std::string& getBackgroundColor() const { return backgroundColor_; } - void setBackgroundColor(const String& backgroundColor) { + void setBackgroundColor(const std::string& backgroundColor) { backgroundColor_ = backgroundColor; } - const String& getLabel() const { return label_; } + const std::string& getLabel() const { return label_; } - void setLabel(const String& label) { + void setLabel(const std::string& label) { label_ = label; } - const std::vector<String>& getEquivalentLabels() const { return equivalentLabels_; } + const std::vector<std::string>& getEquivalentLabels() const { return equivalentLabels_; } - void addEquivalentLabel(const String& label) { + void addEquivalentLabel(const std::string& label) { equivalentLabels_.push_back(label); } private: - String displayMarking_; - String foregroundColor_; - String backgroundColor_; - String label_; - std::vector<String> equivalentLabels_; + std::string displayMarking_; + std::string foregroundColor_; + std::string backgroundColor_; + std::string label_; + std::vector<std::string> equivalentLabels_; }; } diff --git a/Swiften/Elements/SecurityLabelsCatalog.h b/Swiften/Elements/SecurityLabelsCatalog.h index e0c7bcb..1c13fdf 100644 --- a/Swiften/Elements/SecurityLabelsCatalog.h +++ b/Swiften/Elements/SecurityLabelsCatalog.h @@ -10,7 +10,7 @@ #include <vector> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" #include "Swiften/Elements/SecurityLabel.h" @@ -35,26 +35,26 @@ namespace Swift { to_ = to; } - const String& getName() const { + const std::string& getName() const { return name_; } - void setName(const String& name) { + void setName(const std::string& name) { name_ = name; } - const String& getDescription() const { + const std::string& getDescription() const { return description_; } - void setDescription(const String& description) { + void setDescription(const std::string& description) { description_ = description; } private: JID to_; - String name_; - String description_; + std::string name_; + std::string description_; std::vector<SecurityLabel> labels_; }; } diff --git a/Swiften/Elements/SoftwareVersion.h b/Swiften/Elements/SoftwareVersion.h index 1a33f2c..26d49b1 100644 --- a/Swiften/Elements/SoftwareVersion.h +++ b/Swiften/Elements/SoftwareVersion.h @@ -8,45 +8,45 @@ #define SWIFTEN_SoftwareVersion_H #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class SoftwareVersion : public Payload { public: SoftwareVersion( - const String& name = "", - const String& version = "", - const String& os = "") : + const std::string& name = "", + const std::string& version = "", + const std::string& os = "") : name_(name), version_(version), os_(os) {} - const String& getName() const { + const std::string& getName() const { return name_; } - void setName(const String& name) { + void setName(const std::string& name) { name_ = name; } - const String& getVersion() const { + const std::string& getVersion() const { return version_; } - void setVersion(const String& version) { + void setVersion(const std::string& version) { version_ = version; } - const String& getOS() const { + const std::string& getOS() const { return os_; } - void setOS(const String& os) { + void setOS(const std::string& os) { os_ = os; } private: - String name_; - String version_; - String os_; + std::string name_; + std::string version_; + std::string os_; }; } diff --git a/Swiften/Elements/Stanza.h b/Swiften/Elements/Stanza.h index 0f07223..9b934e4 100644 --- a/Swiften/Elements/Stanza.h +++ b/Swiften/Elements/Stanza.h @@ -13,7 +13,7 @@ #include "Swiften/Elements/Element.h" #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/foreach.h" #include "Swiften/JID/JID.h" @@ -66,8 +66,8 @@ namespace Swift { const JID& getTo() const { return to_; } void setTo(const JID& to) { to_ = to; } - const String& getID() const { return id_; } - void setID(const String& id) { id_ = id; } + const std::string& getID() const { return id_; } + void setID(const std::string& id) { id_ = id; } boost::optional<boost::posix_time::ptime> getTimestamp() const; @@ -75,7 +75,7 @@ namespace Swift { boost::optional<boost::posix_time::ptime> getTimestampFrom(const JID& jid) const; private: - String id_; + std::string id_; JID from_; JID to_; diff --git a/Swiften/Elements/StartSession.h b/Swiften/Elements/StartSession.h index 921f1e8..0586f40 100644 --- a/Swiften/Elements/StartSession.h +++ b/Swiften/Elements/StartSession.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_StartSession_H #define SWIFTEN_StartSession_H -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { diff --git a/Swiften/Elements/Status.h b/Swiften/Elements/Status.h index e0e3951..3ef6401 100644 --- a/Swiften/Elements/Status.h +++ b/Swiften/Elements/Status.h @@ -8,24 +8,24 @@ #define SWIFTEN_Status_H #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class Status : public Payload { public: - Status(const String& text = "") : text_(text) { + Status(const std::string& text = "") : text_(text) { } - void setText(const String& text) { + void setText(const std::string& text) { text_ = text; } - const String& getText() const { + const std::string& getText() const { return text_; } private: - String text_; + std::string text_; }; } diff --git a/Swiften/Elements/StatusShow.h b/Swiften/Elements/StatusShow.h index 1bdae96..f579ace 100644 --- a/Swiften/Elements/StatusShow.h +++ b/Swiften/Elements/StatusShow.h @@ -8,7 +8,7 @@ #define SWIFTEN_StatusShow_H #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class StatusShow : public Payload { @@ -26,7 +26,7 @@ namespace Swift { return type_; } - static String typeToFriendlyName(Type type) { + static std::string typeToFriendlyName(Type type) { switch (type) { case Online: return "Available"; case FFC: return "Available"; diff --git a/Swiften/Elements/Storage.h b/Swiften/Elements/Storage.h index 447ca2e..a2f244c 100644 --- a/Swiften/Elements/Storage.h +++ b/Swiften/Elements/Storage.h @@ -9,7 +9,7 @@ #include <vector> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -18,18 +18,18 @@ namespace Swift { struct Room { Room() : autoJoin(false) {} - String name; + std::string name; JID jid; bool autoJoin; - String nick; - String password; + std::string nick; + std::string password; }; struct URL { URL() {} - String name; - String url; + std::string name; + std::string url; }; Storage() { diff --git a/Swiften/Elements/StreamError.h b/Swiften/Elements/StreamError.h index 4311055..0d0551c 100644 --- a/Swiften/Elements/StreamError.h +++ b/Swiften/Elements/StreamError.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include <Swiften/Elements/Element.h> -#include <Swiften/Base/String.h> +#include <string> namespace Swift { class StreamError : public Element { @@ -44,7 +44,7 @@ namespace Swift { UnsupportedVersion, }; - StreamError(Type type = UndefinedCondition, const String& text = String()) : type_(type), text_(text) { } + StreamError(Type type = UndefinedCondition, const std::string& text = std::string()) : type_(type), text_(text) { } Type getType() const { return type_; @@ -54,16 +54,16 @@ namespace Swift { type_ = type; } - void setText(const String& text) { + void setText(const std::string& text) { text_ = text; } - const String& getText() const { + const std::string& getText() const { return text_; } private: Type type_; - String text_; + std::string text_; }; } diff --git a/Swiften/Elements/StreamFeatures.h b/Swiften/Elements/StreamFeatures.h index 32446ce..fbc0bb8 100644 --- a/Swiften/Elements/StreamFeatures.h +++ b/Swiften/Elements/StreamFeatures.h @@ -9,7 +9,7 @@ #include <vector> #include <algorithm> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Element.h" namespace Swift { @@ -43,27 +43,27 @@ namespace Swift { return hasResourceBind_; } - const std::vector<String>& getCompressionMethods() const { + const std::vector<std::string>& getCompressionMethods() const { return compressionMethods_; } - void addCompressionMethod(const String& mechanism) { + void addCompressionMethod(const std::string& mechanism) { compressionMethods_.push_back(mechanism); } - bool hasCompressionMethod(const String& mechanism) const { + bool hasCompressionMethod(const std::string& mechanism) const { return std::find(compressionMethods_.begin(), compressionMethods_.end(), mechanism) != compressionMethods_.end(); } - const std::vector<String>& getAuthenticationMechanisms() const { + const std::vector<std::string>& getAuthenticationMechanisms() const { return authenticationMechanisms_; } - void addAuthenticationMechanism(const String& mechanism) { + void addAuthenticationMechanism(const std::string& mechanism) { authenticationMechanisms_.push_back(mechanism); } - bool hasAuthenticationMechanism(const String& mechanism) const { + bool hasAuthenticationMechanism(const std::string& mechanism) const { return std::find(authenticationMechanisms_.begin(), authenticationMechanisms_.end(), mechanism) != authenticationMechanisms_.end(); } @@ -81,8 +81,8 @@ namespace Swift { private: bool hasStartTLS_; - std::vector<String> compressionMethods_; - std::vector<String> authenticationMechanisms_; + std::vector<std::string> compressionMethods_; + std::vector<std::string> authenticationMechanisms_; bool hasResourceBind_; bool hasSession_; bool hasStreamManagement_; diff --git a/Swiften/Elements/StreamInitiation.h b/Swiften/Elements/StreamInitiation.h index 16dfd4d..6217cbb 100644 --- a/Swiften/Elements/StreamInitiation.h +++ b/Swiften/Elements/StreamInitiation.h @@ -10,7 +10,7 @@ #include <boost/optional.hpp> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" #include <Swiften/Elements/StreamInitiationFileInfo.h> @@ -21,11 +21,11 @@ namespace Swift { StreamInitiation() : isFileTransfer(true) {} - const String& getID() const { + const std::string& getID() const { return id; } - void setID(const String& id) { + void setID(const std::string& id) { this->id = id; } @@ -37,19 +37,19 @@ namespace Swift { fileInfo = info; } - const std::vector<String>& getProvidedMethods() const { + const std::vector<std::string>& getProvidedMethods() const { return providedMethods; } - void addProvidedMethod(const String& method) { + void addProvidedMethod(const std::string& method) { providedMethods.push_back(method); } - void setRequestedMethod(const String& method) { + void setRequestedMethod(const std::string& method) { requestedMethod = method; } - const String& getRequestedMethod() const { + const std::string& getRequestedMethod() const { return requestedMethod; } @@ -63,9 +63,9 @@ namespace Swift { private: bool isFileTransfer; - String id; + std::string id; boost::optional<StreamInitiationFileInfo> fileInfo; - std::vector<String> providedMethods; - String requestedMethod; + std::vector<std::string> providedMethods; + std::string requestedMethod; }; } diff --git a/Swiften/Elements/StreamInitiationFileInfo.h b/Swiften/Elements/StreamInitiationFileInfo.h index 15b5a66..92b9824 100644 --- a/Swiften/Elements/StreamInitiationFileInfo.h +++ b/Swiften/Elements/StreamInitiationFileInfo.h @@ -6,14 +6,14 @@ #pragma once -#include <Swiften/Base/String.h> +#include <string> namespace Swift { struct StreamInitiationFileInfo { - StreamInitiationFileInfo(const String& name = "", const String& description = "", int size = -1) : name(name), description(description), size(size) {} + StreamInitiationFileInfo(const std::string& name = "", const std::string& description = "", int size = -1) : name(name), description(description), size(size) {} - String name; - String description; + std::string name; + std::string description; int size; }; } diff --git a/Swiften/Elements/Subject.h b/Swiften/Elements/Subject.h index 745ddb5..6b5a916 100644 --- a/Swiften/Elements/Subject.h +++ b/Swiften/Elements/Subject.h @@ -7,23 +7,23 @@ #pragma once #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class Subject : public Payload { public: - Subject(const String& text = "") : text_(text) { + Subject(const std::string& text = "") : text_(text) { } - void setText(const String& text) { + void setText(const std::string& text) { text_ = text; } - const String& getText() const { + const std::string& getText() const { return text_; } private: - String text_; + std::string text_; }; } diff --git a/Swiften/Elements/UnitTest/FormTest.cpp b/Swiften/Elements/UnitTest/FormTest.cpp index 715111b..de92d70 100644 --- a/Swiften/Elements/UnitTest/FormTest.cpp +++ b/Swiften/Elements/UnitTest/FormTest.cpp @@ -31,7 +31,7 @@ class FormTest : public CppUnit::TestFixture { form.addField(FixedFormField::create("Bar")); - CPPUNIT_ASSERT_EQUAL(String("jabber:bot"), form.getFormType()); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), form.getFormType()); } void testGetFormType_InvalidFormType() { @@ -41,7 +41,7 @@ class FormTest : public CppUnit::TestFixture { field->setName("FORM_TYPE"); form.addField(field); - CPPUNIT_ASSERT_EQUAL(String(""), form.getFormType()); + CPPUNIT_ASSERT_EQUAL(std::string(""), form.getFormType()); } void testGetFormType_NoFormType() { @@ -49,7 +49,7 @@ class FormTest : public CppUnit::TestFixture { form.addField(FixedFormField::create("Foo")); - CPPUNIT_ASSERT_EQUAL(String(""), form.getFormType()); + CPPUNIT_ASSERT_EQUAL(std::string(""), form.getFormType()); } }; diff --git a/Swiften/Elements/UnitTest/IQTest.cpp b/Swiften/Elements/UnitTest/IQTest.cpp index 532cec0..c170d61 100644 --- a/Swiften/Elements/UnitTest/IQTest.cpp +++ b/Swiften/Elements/UnitTest/IQTest.cpp @@ -29,7 +29,7 @@ class IQTest : public CppUnit::TestFixture boost::shared_ptr<IQ> iq(IQ::createResult(JID("foo@bar/fum"), "myid", payload)); CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo()); - CPPUNIT_ASSERT_EQUAL(String("myid"), iq->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), iq->getID()); CPPUNIT_ASSERT(iq->getPayload<SoftwareVersion>()); CPPUNIT_ASSERT(payload == iq->getPayload<SoftwareVersion>()); } @@ -38,7 +38,7 @@ class IQTest : public CppUnit::TestFixture boost::shared_ptr<IQ> iq(IQ::createResult(JID("foo@bar/fum"), "myid")); CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo()); - CPPUNIT_ASSERT_EQUAL(String("myid"), iq->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), iq->getID()); CPPUNIT_ASSERT(!iq->getPayload<SoftwareVersion>()); } @@ -46,7 +46,7 @@ class IQTest : public CppUnit::TestFixture boost::shared_ptr<IQ> iq(IQ::createError(JID("foo@bar/fum"), "myid", ErrorPayload::BadRequest, ErrorPayload::Modify)); CPPUNIT_ASSERT_EQUAL(JID("foo@bar/fum"), iq->getTo()); - CPPUNIT_ASSERT_EQUAL(String("myid"), iq->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), iq->getID()); boost::shared_ptr<ErrorPayload> error(iq->getPayload<ErrorPayload>()); CPPUNIT_ASSERT(error); CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, error->getCondition()); diff --git a/Swiften/Elements/UnitTest/StanzaTest.cpp b/Swiften/Elements/UnitTest/StanzaTest.cpp index 27b0f09..4020f8b 100644 --- a/Swiften/Elements/UnitTest/StanzaTest.cpp +++ b/Swiften/Elements/UnitTest/StanzaTest.cpp @@ -43,9 +43,9 @@ class StanzaTest : public CppUnit::TestFixture class MyPayload2 : public Payload { public: - MyPayload2(const String& s = "") : text_(s) {} + MyPayload2(const std::string& s = "") : text_(s) {} - String text_; + std::string text_; }; class MyPayload3 : public Payload { @@ -143,7 +143,7 @@ class StanzaTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size()); boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>()); - CPPUNIT_ASSERT_EQUAL(String("bar"), p->text_); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), p->text_); } void testUpdatePayload_NewPayload() { @@ -155,7 +155,7 @@ class StanzaTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), m.getPayloads().size()); boost::shared_ptr<MyPayload2> p(m.getPayload<MyPayload2>()); - CPPUNIT_ASSERT_EQUAL(String("bar"), p->text_); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), p->text_); } void testGetPayloadOfSameType() { @@ -166,7 +166,7 @@ class StanzaTest : public CppUnit::TestFixture boost::shared_ptr<MyPayload2> payload(boost::dynamic_pointer_cast<MyPayload2>(m.getPayloadOfSameType(boost::shared_ptr<MyPayload2>(new MyPayload2("bar"))))); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("foo"), payload->text_); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), payload->text_); } void testGetPayloadOfSameType_NoSuchPayload() { diff --git a/Swiften/Elements/VCard.h b/Swiften/Elements/VCard.h index 5e26003..d2423e1 100644 --- a/Swiften/Elements/VCard.h +++ b/Swiften/Elements/VCard.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Elements/Payload.h" @@ -26,47 +26,47 @@ namespace Swift { bool isInternet; bool isPreferred; bool isX400; - String address; + std::string address; }; VCard() {} - void setVersion(const String& version) { version_ = version; } - const String& getVersion() const { return version_; } + void setVersion(const std::string& version) { version_ = version; } + const std::string& getVersion() const { return version_; } - void setFullName(const String& fullName) { fullName_ = fullName; } - const String& getFullName() const { return fullName_; } + void setFullName(const std::string& fullName) { fullName_ = fullName; } + const std::string& getFullName() const { return fullName_; } - void setFamilyName(const String& familyName) { familyName_ = familyName; } - const String& getFamilyName() const { return familyName_; } + void setFamilyName(const std::string& familyName) { familyName_ = familyName; } + const std::string& getFamilyName() const { return familyName_; } - void setGivenName(const String& givenName) { givenName_ = givenName; } - const String& getGivenName() const { return givenName_; } + void setGivenName(const std::string& givenName) { givenName_ = givenName; } + const std::string& getGivenName() const { return givenName_; } - void setMiddleName(const String& middleName) { middleName_ = middleName; } - const String& getMiddleName() const { return middleName_; } + void setMiddleName(const std::string& middleName) { middleName_ = middleName; } + const std::string& getMiddleName() const { return middleName_; } - void setPrefix(const String& prefix) { prefix_ = prefix; } - const String& getPrefix() const { return prefix_; } + void setPrefix(const std::string& prefix) { prefix_ = prefix; } + const std::string& getPrefix() const { return prefix_; } - void setSuffix(const String& suffix) { suffix_ = suffix; } - const String& getSuffix() const { return suffix_; } + void setSuffix(const std::string& suffix) { suffix_ = suffix; } + const std::string& getSuffix() const { return suffix_; } - //void setEMailAddress(const String& email) { email_ = email; } - //const String& getEMailAddress() const { return email_; } + //void setEMailAddress(const std::string& email) { email_ = email; } + //const std::string& getEMailAddress() const { return email_; } - void setNickname(const String& nick) { nick_ = nick; } - const String& getNickname() const { return nick_; } + void setNickname(const std::string& nick) { nick_ = nick; } + const std::string& getNickname() const { return nick_; } void setPhoto(const ByteArray& photo) { photo_ = photo; } const ByteArray& getPhoto() { return photo_; } - void setPhotoType(const String& photoType) { photoType_ = photoType; } - const String& getPhotoType() { return photoType_; } + void setPhotoType(const std::string& photoType) { photoType_ = photoType; } + const std::string& getPhotoType() { return photoType_; } - const String& getUnknownContent() const { return unknownContent_; } - void addUnknownContent(const String& c) { + const std::string& getUnknownContent() const { return unknownContent_; } + void addUnknownContent(const std::string& c) { unknownContent_ += c; } @@ -81,18 +81,18 @@ namespace Swift { EMailAddress getPreferredEMailAddress() const; private: - String version_; - String fullName_; - String familyName_; - String givenName_; - String middleName_; - String prefix_; - String suffix_; - //String email_; + std::string version_; + std::string fullName_; + std::string familyName_; + std::string givenName_; + std::string middleName_; + std::string prefix_; + std::string suffix_; + //std::string email_; ByteArray photo_; - String photoType_; - String nick_; - String unknownContent_; + std::string photoType_; + std::string nick_; + std::string unknownContent_; std::vector<EMailAddress> emailAddresses_; }; } diff --git a/Swiften/Elements/VCardUpdate.h b/Swiften/Elements/VCardUpdate.h index 40eda76..bbfd31e 100644 --- a/Swiften/Elements/VCardUpdate.h +++ b/Swiften/Elements/VCardUpdate.h @@ -6,18 +6,18 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { class VCardUpdate : public Payload { public: - VCardUpdate(const String& photoHash = "") : photoHash_(photoHash) {} + VCardUpdate(const std::string& photoHash = "") : photoHash_(photoHash) {} - void setPhotoHash(const String& photoHash) { photoHash_ = photoHash; } - const String& getPhotoHash() { return photoHash_; } + void setPhotoHash(const std::string& photoHash) { photoHash_ = photoHash; } + const std::string& getPhotoHash() { return photoHash_; } private: - String photoHash_; + std::string photoHash_; }; } diff --git a/Swiften/Elements/Version.h b/Swiften/Elements/Version.h index 3ed1958..0a65573 100644 --- a/Swiften/Elements/Version.h +++ b/Swiften/Elements/Version.h @@ -7,23 +7,23 @@ #ifndef SWIFTEN_STANZAS_VERSION_H #define SWIFTEN_STANZAS_VERSION_H -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { class Version : public Payload { public: - Version(const String& name = "", const String& version = "", const String& os = "") : name_(name), version_(version), os_(os) { } + Version(const std::string& name = "", const std::string& version = "", const std::string& os = "") : name_(name), version_(version), os_(os) { } - const String& getName() const { return name_; } - const String& getVersion() const { return version_; } - const String& getOS() const { return os_; } + const std::string& getName() const { return name_; } + const std::string& getVersion() const { return version_; } + const std::string& getOS() const { return os_; } private: - String name_; - String version_; - String os_; + std::string name_; + std::string version_; + std::string os_; }; } diff --git a/Swiften/Examples/BenchTool/BenchTool.cpp b/Swiften/Examples/BenchTool/BenchTool.cpp index aaf83b5..9e54ed9 100644 --- a/Swiften/Examples/BenchTool/BenchTool.cpp +++ b/Swiften/Examples/BenchTool/BenchTool.cpp @@ -45,7 +45,7 @@ int main(int, char**) { BlindCertificateTrustChecker trustChecker; std::vector<CoreClient*> clients; for (int i = 0; i < numberOfInstances; ++i) { - CoreClient* client = new Swift::CoreClient(JID(jid), String(pass), &networkFactories); + CoreClient* client = new Swift::CoreClient(JID(jid), std::string(pass), &networkFactories); client->setCertificateTrustChecker(&trustChecker); client->onConnected.connect(&handleConnected); clients.push_back(client); diff --git a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp index 2f3a751..fda203a 100644 --- a/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp +++ b/Swiften/Examples/ConnectivityTest/ConnectivityTest.cpp @@ -62,13 +62,13 @@ int main(int argc, char* argv[]) { int argi = 1; - String jid = argv[argi++]; - String connectHost = ""; + std::string jid = argv[argi++]; + std::string connectHost = ""; if (argc == 5) { connectHost = argv[argi++]; } - client = new Swift::Client(JID(jid), String(argv[argi++]), &networkFactories); + client = new Swift::Client(JID(jid), std::string(argv[argi++]), &networkFactories); char* timeoutChar = argv[argi++]; int timeout = atoi(timeoutChar); timeout = (timeout ? timeout : 30) * 1000; @@ -76,7 +76,7 @@ int main(int argc, char* argv[]) { client->onConnected.connect(&handleConnected); errorConnection = client->onDisconnected.connect(&handleDisconnected); std::cout << "Connecting to JID " << jid << " with timeout " << timeout << "ms on host: "; ; - if (!connectHost.isEmpty()) { + if (!connectHost.empty()) { std::cout << connectHost << std::endl; client->connect(connectHost); } else { diff --git a/Swiften/Examples/LinkLocalTool/main.cpp b/Swiften/Examples/LinkLocalTool/main.cpp index 65fc9bc..d63ef53 100644 --- a/Swiften/Examples/LinkLocalTool/main.cpp +++ b/Swiften/Examples/LinkLocalTool/main.cpp @@ -27,13 +27,13 @@ int main(int argc, char* argv[]) { boost::shared_ptr<DNSSDQuerier> querier = factory.createQuerier(); querier->start(); - if (String(argv[1]) == "browse") { + if (std::string(argv[1]) == "browse") { boost::shared_ptr<DNSSDBrowseQuery> browseQuery = querier->createBrowseQuery(); browseQuery->startBrowsing(); eventLoop.run(); browseQuery->stopBrowsing(); } - else if (String(argv[1]) == "resolve-service") { + else if (std::string(argv[1]) == "resolve-service") { if (argc < 5) { std::cerr << "Invalid parameters" << std::endl; return -1; diff --git a/Swiften/Examples/SendFile/ReceiveFile.cpp b/Swiften/Examples/SendFile/ReceiveFile.cpp index 278cc3e..b46d790 100644 --- a/Swiften/Examples/SendFile/ReceiveFile.cpp +++ b/Swiften/Examples/SendFile/ReceiveFile.cpp @@ -25,7 +25,7 @@ int exitCode = 2; class FileReceiver { public: - FileReceiver(const JID& jid, const String& password) : jid(jid), password(password), jingleSessionManager(NULL), incomingFileTransferManager(NULL) { + FileReceiver(const JID& jid, const std::string& password) : jid(jid), password(password), jingleSessionManager(NULL), incomingFileTransferManager(NULL) { client = new Swift::Client(jid, password, &networkFactories); client->onConnected.connect(boost::bind(&FileReceiver::handleConnected, this)); client->onDisconnected.connect(boost::bind(&FileReceiver::handleDisconnected, this, _1)); @@ -91,7 +91,7 @@ class FileReceiver { private: JID jid; - String password; + std::string password; Client* client; ClientXMLTracer* tracer; JingleSessionManager* jingleSessionManager; @@ -107,7 +107,7 @@ int main(int argc, char* argv[]) { } JID jid(argv[1]); - FileReceiver fileReceiver(jid, String(argv[2])); + FileReceiver fileReceiver(jid, std::string(argv[2])); fileReceiver.start(); eventLoop.run(); diff --git a/Swiften/Examples/SendFile/SendFile.cpp b/Swiften/Examples/SendFile/SendFile.cpp index b2db22b..5ec00a9 100644 --- a/Swiften/Examples/SendFile/SendFile.cpp +++ b/Swiften/Examples/SendFile/SendFile.cpp @@ -28,7 +28,7 @@ int exitCode = 2; class FileSender { public: - FileSender(const JID& jid, const String& password, const JID& recipient, const boost::filesystem::path& file, int port) : jid(jid), password(password), recipient(recipient), file(file), transfer(NULL) { + FileSender(const JID& jid, const std::string& password, const JID& recipient, const boost::filesystem::path& file, int port) : jid(jid), password(password), recipient(recipient), file(file), transfer(NULL) { connectionServer = BoostConnectionServer::create(port, networkFactories.getIOServiceThread()->getIOService(), &eventLoop); socksBytestreamServer = new SOCKS5BytestreamServer(connectionServer); @@ -94,7 +94,7 @@ class FileSender { BoostConnectionServer::ref connectionServer; SOCKS5BytestreamServer* socksBytestreamServer; JID jid; - String password; + std::string password; JID recipient; boost::filesystem::path file; Client* client; @@ -111,7 +111,7 @@ int main(int argc, char* argv[]) { JID sender(argv[1]); JID recipient(argv[3]); - FileSender fileSender(sender, String(argv[2]), recipient, boost::filesystem::path(argv[4]), 8888); + FileSender fileSender(sender, std::string(argv[2]), recipient, boost::filesystem::path(argv[4]), 8888); fileSender.start(); { diff --git a/Swiften/Examples/SendMessage/SendMessage.cpp b/Swiften/Examples/SendMessage/SendMessage.cpp index d763ffc..d7f7333 100644 --- a/Swiften/Examples/SendMessage/SendMessage.cpp +++ b/Swiften/Examples/SendMessage/SendMessage.cpp @@ -51,13 +51,13 @@ int main(int argc, char* argv[]) { int argi = 1; - String jid = argv[argi++]; - String connectHost = ""; + std::string jid = argv[argi++]; + std::string connectHost = ""; if (argc == 6) { connectHost = argv[argi++]; } - client = new Swift::Client(JID(jid), String(argv[argi++]), &networkFactories); + client = new Swift::Client(JID(jid), std::string(argv[argi++]), &networkFactories); client->setAlwaysTrustCertificates(); recipient = JID(argv[argi++]); @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) { ClientXMLTracer* tracer = new ClientXMLTracer(client); client->onConnected.connect(&handleConnected); errorConnection = client->onDisconnected.connect(&handleDisconnected); - if (!connectHost.isEmpty()) { + if (!connectHost.empty()) { client->connect(connectHost); } else { client->connect(); diff --git a/Swiften/FileTransfer/IBBReceiveSession.cpp b/Swiften/FileTransfer/IBBReceiveSession.cpp index 9eed21d..5c90757 100644 --- a/Swiften/FileTransfer/IBBReceiveSession.cpp +++ b/Swiften/FileTransfer/IBBReceiveSession.cpp @@ -14,7 +14,7 @@ namespace Swift { -IBBReceiveSession::IBBReceiveSession(const String& id, const JID& from, size_t size, WriteBytestream::ref bytestream, IQRouter* router) : SetResponder<IBB>(router), id(id), from(from), size(size), bytestream(bytestream), router(router), sequenceNumber(0), active(false), receivedSize(0) { +IBBReceiveSession::IBBReceiveSession(const std::string& id, const JID& from, size_t size, WriteBytestream::ref bytestream, IQRouter* router) : SetResponder<IBB>(router), id(id), from(from), size(size), bytestream(bytestream), router(router), sequenceNumber(0), active(false), receivedSize(0) { } IBBReceiveSession::~IBBReceiveSession() { @@ -36,7 +36,7 @@ void IBBReceiveSession::finish(boost::optional<FileTransferError> error) { onFinished(error); } -bool IBBReceiveSession::handleSetRequest(const JID& from, const JID&, const String& id, IBB::ref ibb) { +bool IBBReceiveSession::handleSetRequest(const JID& from, const JID&, const std::string& id, IBB::ref ibb) { if (from == this->from && ibb->getStreamID() == id) { if (ibb->getAction() == IBB::Data) { if (sequenceNumber == ibb->getSequenceNumber()) { diff --git a/Swiften/FileTransfer/IBBReceiveSession.h b/Swiften/FileTransfer/IBBReceiveSession.h index b2399b6..6d936de 100644 --- a/Swiften/FileTransfer/IBBReceiveSession.h +++ b/Swiften/FileTransfer/IBBReceiveSession.h @@ -22,7 +22,7 @@ namespace Swift { class IBBReceiveSession : public SetResponder<IBB> { public: - IBBReceiveSession(const String& id, const JID& from, size_t size, WriteBytestream::ref bytestream, IQRouter* router); + IBBReceiveSession(const std::string& id, const JID& from, size_t size, WriteBytestream::ref bytestream, IQRouter* router); ~IBBReceiveSession(); void start(); @@ -31,11 +31,11 @@ namespace Swift { boost::signal<void (boost::optional<FileTransferError>)> onFinished; private: - bool handleSetRequest(const JID& from, const JID& to, const String& id, IBB::ref payload); + bool handleSetRequest(const JID& from, const JID& to, const std::string& id, IBB::ref payload); void finish(boost::optional<FileTransferError>); private: - String id; + std::string id; JID from; size_t size; WriteBytestream::ref bytestream; diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp index 30f8836..0fb47d3 100644 --- a/Swiften/FileTransfer/IBBSendSession.cpp +++ b/Swiften/FileTransfer/IBBSendSession.cpp @@ -14,7 +14,7 @@ namespace Swift { -IBBSendSession::IBBSendSession(const String& id, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router) : id(id), to(to), bytestream(bytestream), router(router), blockSize(4096), sequenceNumber(0), active(false) { +IBBSendSession::IBBSendSession(const std::string& id, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router) : id(id), to(to), bytestream(bytestream), router(router), blockSize(4096), sequenceNumber(0), active(false) { } IBBSendSession::~IBBSendSession() { diff --git a/Swiften/FileTransfer/IBBSendSession.h b/Swiften/FileTransfer/IBBSendSession.h index e114b23..bef7bec 100644 --- a/Swiften/FileTransfer/IBBSendSession.h +++ b/Swiften/FileTransfer/IBBSendSession.h @@ -21,7 +21,7 @@ namespace Swift { class IBBSendSession { public: - IBBSendSession(const String& id, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router); + IBBSendSession(const std::string& id, const JID& to, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* router); ~IBBSendSession(); void start(); @@ -38,7 +38,7 @@ namespace Swift { void finish(boost::optional<FileTransferError>); private: - String id; + std::string id; JID to; boost::shared_ptr<ReadBytestream> bytestream; IQRouter* router; diff --git a/Swiften/FileTransfer/OutgoingFileTransfer.cpp b/Swiften/FileTransfer/OutgoingFileTransfer.cpp index 8e6f839..32f7e17 100644 --- a/Swiften/FileTransfer/OutgoingFileTransfer.cpp +++ b/Swiften/FileTransfer/OutgoingFileTransfer.cpp @@ -15,7 +15,7 @@ namespace Swift { -OutgoingFileTransfer::OutgoingFileTransfer(const String& id, const JID& from, const JID& to, const String& name, int size, const String& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer) { +OutgoingFileTransfer::OutgoingFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer) : id(id), from(from), to(to), name(name), size(size), description(description), bytestream(bytestream), iqRouter(iqRouter), socksServer(socksServer) { } void OutgoingFileTransfer::start() { diff --git a/Swiften/FileTransfer/OutgoingFileTransfer.h b/Swiften/FileTransfer/OutgoingFileTransfer.h index 3ecef5d..a694c13 100644 --- a/Swiften/FileTransfer/OutgoingFileTransfer.h +++ b/Swiften/FileTransfer/OutgoingFileTransfer.h @@ -24,7 +24,7 @@ namespace Swift { class OutgoingFileTransfer { public: - OutgoingFileTransfer(const String& id, const JID& from, const JID& to, const String& name, int size, const String& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer); + OutgoingFileTransfer(const std::string& id, const JID& from, const JID& to, const std::string& name, int size, const std::string& description, boost::shared_ptr<ReadBytestream> bytestream, IQRouter* iqRouter, SOCKS5BytestreamServer* socksServer); void start(); void stop(); @@ -38,12 +38,12 @@ namespace Swift { void handleIBBSessionFinished(boost::optional<FileTransferError> error); private: - String id; + std::string id; JID from; JID to; - String name; + std::string name; int size; - String description; + std::string description; boost::shared_ptr<ReadBytestream> bytestream; IQRouter* iqRouter; SOCKS5BytestreamServer* socksServer; diff --git a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp index a4715a0..7f889b1 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.cpp @@ -11,15 +11,15 @@ namespace Swift { SOCKS5BytestreamRegistry::SOCKS5BytestreamRegistry() { } -void SOCKS5BytestreamRegistry::addBytestream(const String& destination, boost::shared_ptr<ReadBytestream> byteStream) { +void SOCKS5BytestreamRegistry::addBytestream(const std::string& destination, boost::shared_ptr<ReadBytestream> byteStream) { byteStreams[destination] = byteStream; } -void SOCKS5BytestreamRegistry::removeBytestream(const String& destination) { +void SOCKS5BytestreamRegistry::removeBytestream(const std::string& destination) { byteStreams.erase(destination); } -boost::shared_ptr<ReadBytestream> SOCKS5BytestreamRegistry::getBytestream(const String& destination) const { +boost::shared_ptr<ReadBytestream> SOCKS5BytestreamRegistry::getBytestream(const std::string& destination) const { BytestreamMap::const_iterator i = byteStreams.find(destination); if (i != byteStreams.end()) { return i->second; diff --git a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h index 1afd03f..7cee256 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamRegistry.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include <map> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/FileTransfer/ReadBytestream.h" namespace Swift { @@ -17,12 +17,12 @@ namespace Swift { public: SOCKS5BytestreamRegistry(); - boost::shared_ptr<ReadBytestream> getBytestream(const String& destination) const; - void addBytestream(const String& destination, boost::shared_ptr<ReadBytestream> byteStream); - void removeBytestream(const String& destination); + boost::shared_ptr<ReadBytestream> getBytestream(const std::string& destination) const; + void addBytestream(const std::string& destination, boost::shared_ptr<ReadBytestream> byteStream); + void removeBytestream(const std::string& destination); private: - typedef std::map<String, boost::shared_ptr<ReadBytestream> > BytestreamMap; + typedef std::map<std::string, boost::shared_ptr<ReadBytestream> > BytestreamMap; BytestreamMap byteStreams; }; } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp b/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp index 58506f3..9bc49ae 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamServer.cpp @@ -25,15 +25,15 @@ void SOCKS5BytestreamServer::stop() { connectionServer->onNewConnection.disconnect(boost::bind(&SOCKS5BytestreamServer::handleNewConnection, this, _1)); } -void SOCKS5BytestreamServer::addBytestream(const String& id, const JID& from, const JID& to, boost::shared_ptr<ReadBytestream> byteStream) { +void SOCKS5BytestreamServer::addBytestream(const std::string& id, const JID& from, const JID& to, boost::shared_ptr<ReadBytestream> byteStream) { bytestreams.addBytestream(getSOCKSDestinationAddress(id, from, to), byteStream); } -void SOCKS5BytestreamServer::removeBytestream(const String& id, const JID& from, const JID& to) { +void SOCKS5BytestreamServer::removeBytestream(const std::string& id, const JID& from, const JID& to) { bytestreams.removeBytestream(getSOCKSDestinationAddress(id, from, to)); } -String SOCKS5BytestreamServer::getSOCKSDestinationAddress(const String& id, const JID& from, const JID& to) { +std::string SOCKS5BytestreamServer::getSOCKSDestinationAddress(const std::string& id, const JID& from, const JID& to) { return Hexify::hexify(SHA1::getHash(ByteArray(id + from.toString() + to.toString()))); } diff --git a/Swiften/FileTransfer/SOCKS5BytestreamServer.h b/Swiften/FileTransfer/SOCKS5BytestreamServer.h index 35a8d4f..d5a62bb 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamServer.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamServer.h @@ -10,7 +10,7 @@ #include <map> #include "Swiften/Network/ConnectionServer.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/FileTransfer/ReadBytestream.h" #include "Swiften/FileTransfer/SOCKS5BytestreamRegistry.h" @@ -27,16 +27,16 @@ namespace Swift { void start(); void stop(); - void addBytestream(const String& id, const JID& from, const JID& to, boost::shared_ptr<ReadBytestream> byteStream); - void removeBytestream(const String& id, const JID& from, const JID& to); + void addBytestream(const std::string& id, const JID& from, const JID& to, boost::shared_ptr<ReadBytestream> byteStream); + void removeBytestream(const std::string& id, const JID& from, const JID& to); /*protected: - boost::shared_ptr<ReadBytestream> getBytestream(const String& dest);*/ + boost::shared_ptr<ReadBytestream> getBytestream(const std::string& dest);*/ private: void handleNewConnection(boost::shared_ptr<Connection> connection); - static String getSOCKSDestinationAddress(const String& id, const JID& from, const JID& to); + static std::string getSOCKSDestinationAddress(const std::string& id, const JID& from, const JID& to); private: friend class SOCKS5BytestreamServerSession; diff --git a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp index afd71c0..0cd273a 100644 --- a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp @@ -52,7 +52,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { IBB::ref ibb = stanzaChannel->sentStanzas[0]->getPayload<IBB>(); CPPUNIT_ASSERT_EQUAL(IBB::Open, ibb->getAction()); CPPUNIT_ASSERT_EQUAL(1234, ibb->getBlockSize()); - CPPUNIT_ASSERT_EQUAL(String("myid"), ibb->getStreamID()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), ibb->getStreamID()); } void testStart_ResponseStartsSending() { @@ -68,7 +68,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(IBB::Data, ibb->getAction()); CPPUNIT_ASSERT_EQUAL(ByteArray("abc"), ibb->getData()); CPPUNIT_ASSERT_EQUAL(0, ibb->getSequenceNumber()); - CPPUNIT_ASSERT_EQUAL(String("myid"), ibb->getStreamID()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), ibb->getStreamID()); } void testResponseContinuesSending() { @@ -84,7 +84,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(IBB::Data, ibb->getAction()); CPPUNIT_ASSERT_EQUAL(ByteArray("def"), ibb->getData()); CPPUNIT_ASSERT_EQUAL(1, ibb->getSequenceNumber()); - CPPUNIT_ASSERT_EQUAL(String("myid"), ibb->getStreamID()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), ibb->getStreamID()); } void testRespondToAllFinishes() { @@ -120,7 +120,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<IBB>(1, JID("foo@bar.com/baz"), IQ::Set)); IBB::ref ibb = stanzaChannel->sentStanzas[1]->getPayload<IBB>(); CPPUNIT_ASSERT_EQUAL(IBB::Close, ibb->getAction()); - CPPUNIT_ASSERT_EQUAL(String("myid"), ibb->getStreamID()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), ibb->getStreamID()); CPPUNIT_ASSERT(finished); CPPUNIT_ASSERT(!error); } @@ -144,7 +144,7 @@ class IBBSendSessionTest : public CppUnit::TestFixture { } private: - std::auto_ptr<IBBSendSession> createSession(const String& to) { + std::auto_ptr<IBBSendSession> createSession(const std::string& to) { std::auto_ptr<IBBSendSession> session(new IBBSendSession("myid", JID(to), bytestream, iqRouter)); session->onFinished.connect(boost::bind(&IBBSendSessionTest::handleFinished, this, _1)); return session; diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp index b3b93ac..c6d246d 100644 --- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp +++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp @@ -123,12 +123,12 @@ class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture { receivedDataChunks = 0; } - void request(const String& hostname) { - receive(ByteArray("\x05\x01\x00\x03", 4) + hostname.getUTF8Size() + hostname + ByteArray("\x00\x00", 2)); + void request(const std::string& hostname) { + receive(ByteArray("\x05\x01\x00\x03", 4) + hostname.size() + hostname + ByteArray("\x00\x00", 2)); } - void skipHeader(const String& hostname) { - int headerSize = 7 + hostname.getUTF8Size(); + void skipHeader(const std::string& hostname) { + int headerSize = 7 + hostname.size(); receivedData = ByteArray(receivedData.getData() + headerSize, receivedData.getSize() - headerSize); } diff --git a/Swiften/History/HistoryManager.h b/Swiften/History/HistoryManager.h index c6b80e5..c918cbc 100644 --- a/Swiften/History/HistoryManager.h +++ b/Swiften/History/HistoryManager.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/History/HistoryMessage.h" diff --git a/Swiften/History/HistoryMessage.h b/Swiften/History/HistoryMessage.h index bb605ee..5e4782d 100644 --- a/Swiften/History/HistoryMessage.h +++ b/Swiften/History/HistoryMessage.h @@ -11,10 +11,10 @@ namespace Swift { class HistoryMessage { public: - HistoryMessage(const String& message, const JID& from, const JID& to, const boost::posix_time::ptime time) : message_(message), from_(from), to_(to), time_(time) { + HistoryMessage(const std::string& message, const JID& from, const JID& to, const boost::posix_time::ptime time) : message_(message), from_(from), to_(to), time_(time) { } - const String& getMessage() const { + const std::string& getMessage() const { return message_; } @@ -35,7 +35,7 @@ namespace Swift { } private: - String message_; + std::string message_; JID from_; JID to_; boost::posix_time::ptime time_; diff --git a/Swiften/History/SQLiteHistoryManager.cpp b/Swiften/History/SQLiteHistoryManager.cpp index 43443c7..9d5a000 100644 --- a/Swiften/History/SQLiteHistoryManager.cpp +++ b/Swiften/History/SQLiteHistoryManager.cpp @@ -12,9 +12,9 @@ namespace { -inline Swift::String getEscapedString(const Swift::String& s) { - Swift::String result(s); - result.replaceAll('\'', Swift::String("\\'")); +inline Swift::std::string getEscapedString(const Swift::std::string& s) { + Swift::std::string result(s); + result.replaceAll('\'', Swift::std::string("\\'")); return result; } @@ -23,8 +23,8 @@ inline Swift::String getEscapedString(const Swift::String& s) { namespace Swift { -SQLiteHistoryManager::SQLiteHistoryManager(const String& file) : db_(0) { - sqlite3_open(file.getUTF8Data(), &db_); +SQLiteHistoryManager::SQLiteHistoryManager(const std::string& file) : db_(0) { + sqlite3_open(file.c_str(), &db_); if (!db_) { std::cerr << "Error opening database " << file << std::endl; // FIXME } @@ -49,9 +49,9 @@ SQLiteHistoryManager::~SQLiteHistoryManager() { void SQLiteHistoryManager::addMessage(const HistoryMessage& message) { int secondsSinceEpoch = (message.getTime() - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1))).total_seconds(); - String statement = String("INSERT INTO messages('from', 'to', 'message', 'time') VALUES(") + boost::lexical_cast<std::string>(getIDForJID(message.getFrom())) + ", " + boost::lexical_cast<std::string>(getIDForJID(message.getTo())) + ", '" + getEscapedString(message.getMessage()) + "', " + boost::lexical_cast<std::string>(secondsSinceEpoch) + ")"; + std::string statement = std::string("INSERT INTO messages('from', 'to', 'message', 'time') VALUES(") + boost::lexical_cast<std::string>(getIDForJID(message.getFrom())) + ", " + boost::lexical_cast<std::string>(getIDForJID(message.getTo())) + ", '" + getEscapedString(message.getMessage()) + "', " + boost::lexical_cast<std::string>(secondsSinceEpoch) + ")"; char* errorMessage; - int result = sqlite3_exec(db_, statement.getUTF8Data(), 0, 0, &errorMessage); + int result = sqlite3_exec(db_, statement.c_str(), 0, 0, &errorMessage); if (result != SQLITE_OK) { std::cerr << "SQL Error: " << errorMessage << std::endl; sqlite3_free(errorMessage); @@ -61,8 +61,8 @@ void SQLiteHistoryManager::addMessage(const HistoryMessage& message) { std::vector<HistoryMessage> SQLiteHistoryManager::getMessages() const { std::vector<HistoryMessage> result; sqlite3_stmt* selectStatement; - String selectQuery("SELECT messages.'from', messages.'to', messages.'message', messages.'time' FROM messages"); - int r = sqlite3_prepare(db_, selectQuery.getUTF8Data(), selectQuery.getUTF8Size(), &selectStatement, NULL); + std::string selectQuery("SELECT messages.'from', messages.'to', messages.'message', messages.'time' FROM messages"); + int r = sqlite3_prepare(db_, selectQuery.c_str(), selectQuery.size(), &selectStatement, NULL); if (r != SQLITE_OK) { std::cout << "Error: " << sqlite3_errmsg(db_) << std::endl; } @@ -70,7 +70,7 @@ std::vector<HistoryMessage> SQLiteHistoryManager::getMessages() const { while (r == SQLITE_ROW) { boost::optional<JID> from(getJIDFromID(sqlite3_column_int(selectStatement, 0))); boost::optional<JID> to(getJIDFromID(sqlite3_column_int(selectStatement, 1))); - String message(reinterpret_cast<const char*>(sqlite3_column_text(selectStatement, 2))); + std::string message(reinterpret_cast<const char*>(sqlite3_column_text(selectStatement, 2))); int secondsSinceEpoch(sqlite3_column_int(selectStatement, 3)); boost::posix_time::ptime time(boost::gregorian::date(1970, 1, 1), boost::posix_time::seconds(secondsSinceEpoch)); @@ -95,9 +95,9 @@ int SQLiteHistoryManager::getIDForJID(const JID& jid) { } int SQLiteHistoryManager::addJID(const JID& jid) { - String statement = String("INSERT INTO jids('jid') VALUES('") + getEscapedString(jid.toString()) + "')"; + std::string statement = std::string("INSERT INTO jids('jid') VALUES('") + getEscapedString(jid.toString()) + "')"; char* errorMessage; - int result = sqlite3_exec(db_, statement.getUTF8Data(), 0, 0, &errorMessage); + int result = sqlite3_exec(db_, statement.c_str(), 0, 0, &errorMessage); if (result != SQLITE_OK) { std::cerr << "SQL Error: " << errorMessage << std::endl; sqlite3_free(errorMessage); @@ -108,8 +108,8 @@ int SQLiteHistoryManager::addJID(const JID& jid) { boost::optional<JID> SQLiteHistoryManager::getJIDFromID(int id) const { boost::optional<JID> result; sqlite3_stmt* selectStatement; - String selectQuery("SELECT jid FROM jids WHERE id=" + boost::lexical_cast<std::string>(id)); - int r = sqlite3_prepare(db_, selectQuery.getUTF8Data(), selectQuery.getUTF8Size(), &selectStatement, NULL); + std::string selectQuery("SELECT jid FROM jids WHERE id=" + boost::lexical_cast<std::string>(id)); + int r = sqlite3_prepare(db_, selectQuery.c_str(), selectQuery.size(), &selectStatement, NULL); if (r != SQLITE_OK) { std::cout << "Error: " << sqlite3_errmsg(db_) << std::endl; } @@ -124,8 +124,8 @@ boost::optional<JID> SQLiteHistoryManager::getJIDFromID(int id) const { boost::optional<int> SQLiteHistoryManager::getIDFromJID(const JID& jid) const { boost::optional<int> result; sqlite3_stmt* selectStatement; - String selectQuery("SELECT id FROM jids WHERE jid='" + jid.toString() + "'"); - int r = sqlite3_prepare(db_, selectQuery.getUTF8Data(), selectQuery.getUTF8Size(), &selectStatement, NULL); + std::string selectQuery("SELECT id FROM jids WHERE jid='" + jid.toString() + "'"); + int r = sqlite3_prepare(db_, selectQuery.c_str(), selectQuery.size(), &selectStatement, NULL); if (r != SQLITE_OK) { std::cout << "Error: " << sqlite3_errmsg(db_) << std::endl; } diff --git a/Swiften/History/SQLiteHistoryManager.h b/Swiften/History/SQLiteHistoryManager.h index 5c8d153..a2b89f4 100644 --- a/Swiften/History/SQLiteHistoryManager.h +++ b/Swiften/History/SQLiteHistoryManager.h @@ -15,7 +15,7 @@ struct sqlite3; namespace Swift { class SQLiteHistoryManager : public HistoryManager { public: - SQLiteHistoryManager(const String& file); + SQLiteHistoryManager(const std::string& file); ~SQLiteHistoryManager(); virtual void addMessage(const HistoryMessage& message); diff --git a/Swiften/IDN/IDNA.cpp b/Swiften/IDN/IDNA.cpp index 0e76c0b..6b6c7a4 100644 --- a/Swiften/IDN/IDNA.cpp +++ b/Swiften/IDN/IDNA.cpp @@ -13,10 +13,10 @@ namespace Swift { -String IDNA::getEncoded(const String& domain) { +std::string IDNA::getEncoded(const std::string& domain) { char* output; - if (idna_to_ascii_8z(domain.getUTF8Data(), &output, 0) == IDNA_SUCCESS) { - String result(output); + if (idna_to_ascii_8z(domain.c_str(), &output, 0) == IDNA_SUCCESS) { + std::string result(output); free(output); return result; } diff --git a/Swiften/IDN/IDNA.h b/Swiften/IDN/IDNA.h index cc4144b..19af1e6 100644 --- a/Swiften/IDN/IDNA.h +++ b/Swiften/IDN/IDNA.h @@ -6,11 +6,11 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class IDNA { public: - static String getEncoded(const String& s); + static std::string getEncoded(const std::string& s); }; } diff --git a/Swiften/IDN/StringPrep.cpp b/Swiften/IDN/StringPrep.cpp index d9e061e..ff01eed 100644 --- a/Swiften/IDN/StringPrep.cpp +++ b/Swiften/IDN/StringPrep.cpp @@ -8,6 +8,7 @@ #include <stringprep.h> #include <vector> +#include <cassert> namespace Swift { @@ -24,12 +25,12 @@ const Stringprep_profile* getLibIDNProfile(StringPrep::Profile profile) { return 0; } -String StringPrep::getPrepared(const String& s, Profile profile) { +std::string StringPrep::getPrepared(const std::string& s, Profile profile) { - std::vector<char> input(s.getUTF8String().begin(), s.getUTF8String().end()); + std::vector<char> input(s.begin(), s.end()); input.resize(MAX_STRINGPREP_SIZE); if (stringprep(&input[0], MAX_STRINGPREP_SIZE, static_cast<Stringprep_profile_flags>(0), getLibIDNProfile(profile)) == 0) { - return String(&input[0]); + return std::string(&input[0]); } else { return ""; diff --git a/Swiften/IDN/StringPrep.h b/Swiften/IDN/StringPrep.h index 3b27efa..f40553b 100644 --- a/Swiften/IDN/StringPrep.h +++ b/Swiften/IDN/StringPrep.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class StringPrep { @@ -18,6 +18,6 @@ namespace Swift { SASLPrep, }; - static String getPrepared(const String& s, Profile profile); + static std::string getPrepared(const std::string& s, Profile profile); }; } diff --git a/Swiften/JID/JID.cpp b/Swiften/JID/JID.cpp index 3ecd881..e4611b3 100644 --- a/Swiften/JID/JID.cpp +++ b/Swiften/JID/JID.cpp @@ -9,17 +9,18 @@ #include <vector> #include <iostream> -#include <Swiften/Base/String.h> +#include <string> #ifdef SWIFTEN_CACHE_JID_PREP #include <boost/unordered_map.hpp> #endif #include <stringprep.h> +#include <Swiften/Base/String.h> #include "Swiften/JID/JID.h" #include "Swiften/IDN/StringPrep.h" #ifdef SWIFTEN_CACHE_JID_PREP -typedef boost::unordered_map<std::string, Swift::String> PrepCache; +typedef boost::unordered_map<std::string, std::string> PrepCache; static PrepCache nodePrepCache; static PrepCache domainPrepCache; @@ -29,39 +30,39 @@ static PrepCache resourcePrepCache; namespace Swift { JID::JID(const char* jid) { - initializeFromString(String(jid)); + initializeFromString(std::string(jid)); } -JID::JID(const String& jid) { +JID::JID(const std::string& jid) { initializeFromString(jid); } -JID::JID(const String& node, const String& domain) : hasResource_(false) { +JID::JID(const std::string& node, const std::string& domain) : hasResource_(false) { nameprepAndSetComponents(node, domain, ""); } -JID::JID(const String& node, const String& domain, const String& resource) : hasResource_(true) { +JID::JID(const std::string& node, const std::string& domain, const std::string& resource) : hasResource_(true) { nameprepAndSetComponents(node, domain, resource); } -void JID::initializeFromString(const String& jid) { - if (jid.beginsWith('@')) { +void JID::initializeFromString(const std::string& jid) { + if (String::beginsWith(jid, '@')) { return; } - String bare, resource; + std::string bare, resource; size_t slashIndex = jid.find('/'); - if (slashIndex != jid.npos()) { + if (slashIndex != jid.npos) { hasResource_ = true; - bare = jid.getSubstring(0, slashIndex); - resource = jid.getSubstring(slashIndex + 1, jid.npos()); + bare = jid.substr(0, slashIndex); + resource = jid.substr(slashIndex + 1, jid.npos); } else { hasResource_ = false; bare = jid; } - std::pair<String,String> nodeAndDomain = bare.getSplittedAtFirst('@'); - if (nodeAndDomain.second.isEmpty()) { + std::pair<std::string,std::string> nodeAndDomain = String::getSplittedAtFirst(bare, '@'); + if (nodeAndDomain.second.empty()) { nameprepAndSetComponents("", nodeAndDomain.first, resource); } else { @@ -70,7 +71,7 @@ void JID::initializeFromString(const String& jid) { } -void JID::nameprepAndSetComponents(const String& node, const String& domain, const String& resource) { +void JID::nameprepAndSetComponents(const std::string& node, const std::string& domain, const std::string& resource) { #ifndef SWIFTEN_CACHE_JID_PREP node_ = StringPrep::getPrepared(node, StringPrep::NamePrep); domain_ = StringPrep::getPrepared(domain, StringPrep::XMPPNodePrep); @@ -78,19 +79,19 @@ void JID::nameprepAndSetComponents(const String& node, const String& domain, con #else std::pair<PrepCache::iterator, bool> r; - r = nodePrepCache.insert(std::make_pair(node.getUTF8String(), String())); + r = nodePrepCache.insert(std::make_pair(node, std::string())); if (r.second) { r.first->second = StringPrep::getPrepared(node, StringPrep::NamePrep); } node_ = r.first->second; - r = domainPrepCache.insert(std::make_pair(domain.getUTF8String(), String())); + r = domainPrepCache.insert(std::make_pair(domain, std::string())); if (r.second) { r.first->second = StringPrep::getPrepared(domain, StringPrep::XMPPNodePrep); } domain_ = r.first->second; - r = resourcePrepCache.insert(std::make_pair(resource.getUTF8String(), String())); + r = resourcePrepCache.insert(std::make_pair(resource, std::string())); if (r.second) { r.first->second = StringPrep::getPrepared(resource, StringPrep::XMPPResourcePrep); } @@ -98,9 +99,9 @@ void JID::nameprepAndSetComponents(const String& node, const String& domain, con #endif } -String JID::toString() const { - String string; - if (!node_.isEmpty()) { +std::string JID::toString() const { + std::string string; + if (!node_.empty()) { string += node_ + "@"; } string += domain_; diff --git a/Swiften/JID/JID.h b/Swiften/JID/JID.h index 76c2606..78136ff 100644 --- a/Swiften/JID/JID.h +++ b/Swiften/JID/JID.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class JID { @@ -15,22 +15,22 @@ namespace Swift { WithResource, WithoutResource }; - explicit JID(const String& = String()); + explicit JID(const std::string& = std::string()); explicit JID(const char*); - JID(const String& node, const String& domain); - JID(const String& node, const String& domain, const String& resource); + JID(const std::string& node, const std::string& domain); + JID(const std::string& node, const std::string& domain, const std::string& resource); bool isValid() const { - return !domain_.isEmpty(); /* FIXME */ + return !domain_.empty(); /* FIXME */ } - const String& getNode() const { + const std::string& getNode() const { return node_; } - const String& getDomain() const { + const std::string& getDomain() const { return domain_; } - const String& getResource() const { + const std::string& getResource() const { return resource_; } bool isBare() const { @@ -44,7 +44,7 @@ namespace Swift { return result; } - String toString() const; + std::string toString() const; bool equals(const JID& o, CompareType compareType) const { return compare(o, compareType) == 0; @@ -52,7 +52,7 @@ namespace Swift { int compare(const JID& o, CompareType compareType) const; - operator String() const { + operator std::string() const { return toString(); } @@ -74,13 +74,13 @@ namespace Swift { } private: - void nameprepAndSetComponents(const String& node, const String& domain, const String& resource); - void initializeFromString(const String&); + void nameprepAndSetComponents(const std::string& node, const std::string& domain, const std::string& resource); + void initializeFromString(const std::string&); private: - String node_; - String domain_; + std::string node_; + std::string domain_; bool hasResource_; - String resource_; + std::string resource_; }; } diff --git a/Swiften/JID/UnitTest/JIDTest.cpp b/Swiften/JID/UnitTest/JIDTest.cpp index 51e6d2c..0f22e15 100644 --- a/Swiften/JID/UnitTest/JIDTest.cpp +++ b/Swiften/JID/UnitTest/JIDTest.cpp @@ -59,18 +59,18 @@ class JIDTest : public CppUnit::TestFixture void testConstructorWithString() { JID testling("foo@bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("foo"), testling.getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.getDomain()); - CPPUNIT_ASSERT_EQUAL(String("baz"), testling.getResource()); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), testling.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("baz"), testling.getResource()); CPPUNIT_ASSERT(!testling.isBare()); } void testConstructorWithString_NoResource() { JID testling("foo@bar"); - CPPUNIT_ASSERT_EQUAL(String("foo"), testling.getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.getDomain()); - CPPUNIT_ASSERT_EQUAL(String(""), testling.getResource()); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), testling.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResource()); CPPUNIT_ASSERT(testling.isBare()); } @@ -84,38 +84,38 @@ class JIDTest : public CppUnit::TestFixture void testConstructorWithString_NoNode() { JID testling("bar/baz"); - CPPUNIT_ASSERT_EQUAL(String(""), testling.getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.getDomain()); - CPPUNIT_ASSERT_EQUAL(String("baz"), testling.getResource()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("baz"), testling.getResource()); CPPUNIT_ASSERT(!testling.isBare()); } void testConstructorWithString_OnlyDomain() { JID testling("bar"); - CPPUNIT_ASSERT_EQUAL(String(""), testling.getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.getDomain()); - CPPUNIT_ASSERT_EQUAL(String(""), testling.getResource()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResource()); CPPUNIT_ASSERT(testling.isBare()); } void testConstructorWithString_UpperCaseNode() { JID testling("Fo\xCE\xA9@bar"); - CPPUNIT_ASSERT_EQUAL(String("fo\xCF\x89"), testling.getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("fo\xCF\x89"), testling.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); } void testConstructorWithString_UpperCaseDomain() { JID testling("Fo\xCE\xA9"); - CPPUNIT_ASSERT_EQUAL(String("fo\xCF\x89"), testling.getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("fo\xCF\x89"), testling.getDomain()); } void testConstructorWithString_UpperCaseResource() { JID testling("bar/Fo\xCE\xA9"); - CPPUNIT_ASSERT_EQUAL(testling.getResource(), String("Fo\xCE\xA9")); + CPPUNIT_ASSERT_EQUAL(testling.getResource(), std::string("Fo\xCE\xA9")); } void testConstructorWithString_EmptyNode() { @@ -127,9 +127,9 @@ class JIDTest : public CppUnit::TestFixture void testConstructorWithStrings() { JID testling("foo", "bar", "baz"); - CPPUNIT_ASSERT_EQUAL(String("foo"), testling.getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.getDomain()); - CPPUNIT_ASSERT_EQUAL(String("baz"), testling.getResource()); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), testling.getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("baz"), testling.getResource()); } void testIsBare() { @@ -143,49 +143,49 @@ class JIDTest : public CppUnit::TestFixture void testToBare() { JID testling("foo@bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("foo"), testling.toBare().getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.toBare().getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), testling.toBare().getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.toBare().getDomain()); CPPUNIT_ASSERT(testling.toBare().isBare()); } void testToBare_EmptyNode() { JID testling("bar/baz"); - CPPUNIT_ASSERT_EQUAL(String(""), testling.toBare().getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.toBare().getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.toBare().getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.toBare().getDomain()); CPPUNIT_ASSERT(testling.toBare().isBare()); } void testToBare_EmptyResource() { JID testling("bar/"); - CPPUNIT_ASSERT_EQUAL(String(""), testling.toBare().getNode()); - CPPUNIT_ASSERT_EQUAL(String("bar"), testling.toBare().getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.toBare().getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), testling.toBare().getDomain()); CPPUNIT_ASSERT(testling.toBare().isBare()); } void testToString() { JID testling("foo@bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("foo@bar/baz"), testling.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar/baz"), testling.toString()); } void testToString_EmptyNode() { JID testling("bar/baz"); - CPPUNIT_ASSERT_EQUAL(String("bar/baz"), testling.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("bar/baz"), testling.toString()); } void testToString_NoResource() { JID testling("foo@bar"); - CPPUNIT_ASSERT_EQUAL(String("foo@bar"), testling.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar"), testling.toString()); } void testToString_EmptyResource() { JID testling("foo@bar/"); - CPPUNIT_ASSERT_EQUAL(String("foo@bar/"), testling.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("foo@bar/"), testling.toString()); } void testCompare_SmallerNode() { diff --git a/Swiften/Jingle/IncomingJingleSession.cpp b/Swiften/Jingle/IncomingJingleSession.cpp index 29155b8..b18d9d3 100644 --- a/Swiften/Jingle/IncomingJingleSession.cpp +++ b/Swiften/Jingle/IncomingJingleSession.cpp @@ -8,7 +8,7 @@ namespace Swift { -IncomingJingleSession::IncomingJingleSession(const String& id, const std::vector<JingleContent::ref>& contents) : JingleSession(id, contents) { +IncomingJingleSession::IncomingJingleSession(const std::string& id, const std::vector<JingleContent::ref>& contents) : JingleSession(id, contents) { } diff --git a/Swiften/Jingle/IncomingJingleSession.h b/Swiften/Jingle/IncomingJingleSession.h index 222100f..64816f6 100644 --- a/Swiften/Jingle/IncomingJingleSession.h +++ b/Swiften/Jingle/IncomingJingleSession.h @@ -13,7 +13,7 @@ namespace Swift { class IncomingJingleSession : public JingleSession { public: - IncomingJingleSession(const String& id, const std::vector<JingleContent::ref>& contents); + IncomingJingleSession(const std::string& id, const std::vector<JingleContent::ref>& contents); typedef boost::shared_ptr<IncomingJingleSession> ref; }; diff --git a/Swiften/Jingle/JingleResponder.cpp b/Swiften/Jingle/JingleResponder.cpp index 3dfc327..2397e63 100644 --- a/Swiften/Jingle/JingleResponder.cpp +++ b/Swiften/Jingle/JingleResponder.cpp @@ -16,7 +16,7 @@ namespace Swift { JingleResponder::JingleResponder(JingleSessionManager* sessionManager, IQRouter* router) : SetResponder<JinglePayload>(router), sessionManager(sessionManager) { } -bool JingleResponder::handleSetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<JinglePayload> payload) { +bool JingleResponder::handleSetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<JinglePayload> payload) { if (payload->getAction() == JinglePayload::SessionInitiate) { if (sessionManager->getSession(from, payload->getSessionID())) { // TODO: Add tie-break error diff --git a/Swiften/Jingle/JingleResponder.h b/Swiften/Jingle/JingleResponder.h index 47dc90a..6e1965c 100644 --- a/Swiften/Jingle/JingleResponder.h +++ b/Swiften/Jingle/JingleResponder.h @@ -18,7 +18,7 @@ namespace Swift { JingleResponder(JingleSessionManager* sessionManager, IQRouter* router); private: - virtual bool handleSetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<JinglePayload> payload); + virtual bool handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<JinglePayload> payload); private: JingleSessionManager* sessionManager; diff --git a/Swiften/Jingle/JingleSession.cpp b/Swiften/Jingle/JingleSession.cpp index 3dbb12a..d255abd 100644 --- a/Swiften/Jingle/JingleSession.cpp +++ b/Swiften/Jingle/JingleSession.cpp @@ -10,7 +10,7 @@ namespace Swift { -JingleSession::JingleSession(const String& id, const std::vector<JingleContent::ref>& contents) : id(id), contents(contents) { +JingleSession::JingleSession(const std::string& id, const std::vector<JingleContent::ref>& contents) : id(id), contents(contents) { } diff --git a/Swiften/Jingle/JingleSession.h b/Swiften/Jingle/JingleSession.h index 7ed86c2..c00492d 100644 --- a/Swiften/Jingle/JingleSession.h +++ b/Swiften/Jingle/JingleSession.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include <Swiften/Base/boost_bsignals.h> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/Elements/JinglePayload.h> #include <Swiften/Elements/JingleContent.h> #include <Swiften/Base/foreach.h> @@ -20,10 +20,10 @@ namespace Swift { public: typedef boost::shared_ptr<JingleSession> ref; - JingleSession(const String& id, const std::vector<JingleContent::ref>& contents); + JingleSession(const std::string& id, const std::vector<JingleContent::ref>& contents); virtual ~JingleSession(); - String getID() const { + std::string getID() const { return id; } @@ -47,7 +47,7 @@ namespace Swift { void handleIncomingAction(JinglePayload::ref); private: - String id; + std::string id; std::vector<JingleContent::ref> contents; }; } diff --git a/Swiften/Jingle/JingleSessionManager.cpp b/Swiften/Jingle/JingleSessionManager.cpp index d8630cc..e60449b 100644 --- a/Swiften/Jingle/JingleSessionManager.cpp +++ b/Swiften/Jingle/JingleSessionManager.cpp @@ -18,7 +18,7 @@ JingleSessionManager::~JingleSessionManager() { delete responder; } -JingleSession::ref JingleSessionManager::getSession(const JID& jid, const String& id) const { +JingleSession::ref JingleSessionManager::getSession(const JID& jid, const std::string& id) const { SessionMap::const_iterator i = incomingSessions.find(JIDSession(jid, id)); return i != incomingSessions.end() ? i->second : JingleSession::ref(); } diff --git a/Swiften/Jingle/JingleSessionManager.h b/Swiften/Jingle/JingleSessionManager.h index ea4199d..3e99656 100644 --- a/Swiften/Jingle/JingleSessionManager.h +++ b/Swiften/Jingle/JingleSessionManager.h @@ -23,7 +23,7 @@ namespace Swift { JingleSessionManager(IQRouter* router); ~JingleSessionManager(); - JingleSession::ref getSession(const JID& jid, const String& id) const; + JingleSession::ref getSession(const JID& jid, const std::string& id) const; void addIncomingSessionHandler(IncomingJingleSessionHandler* handler); void removeIncomingSessionHandler(IncomingJingleSessionHandler* handler); @@ -36,12 +36,12 @@ namespace Swift { JingleResponder* responder; std::vector<IncomingJingleSessionHandler*> incomingSessionHandlers; struct JIDSession { - JIDSession(const JID& jid, const String& session) : jid(jid), session(session) {} + JIDSession(const JID& jid, const std::string& session) : jid(jid), session(session) {} bool operator<(const JIDSession& o) const { return jid == o.jid ? session < o.session : jid < o.jid; } JID jid; - String session; + std::string session; }; typedef std::map<JIDSession, JingleSession::ref> SessionMap; SessionMap incomingSessions; diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp index f9f2f8f..dd189d9 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.cpp @@ -25,7 +25,7 @@ boost::shared_ptr<DNSSDBrowseQuery> AvahiQuerier::createBrowseQuery() { return boost::shared_ptr<DNSSDBrowseQuery>(new AvahiBrowseQuery(shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const String& name, int port, const ByteArray& info) { +boost::shared_ptr<DNSSDRegisterQuery> AvahiQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) { return boost::shared_ptr<DNSSDRegisterQuery>(new AvahiRegisterQuery(name, port, info, shared_from_this(), eventLoop)); } @@ -33,7 +33,7 @@ boost::shared_ptr<DNSSDResolveServiceQuery> AvahiQuerier::createResolveServiceQu return boost::shared_ptr<DNSSDResolveServiceQuery>(new AvahiResolveServiceQuery(service, shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDResolveHostnameQuery> AvahiQuerier::createResolveHostnameQuery(const String& hostname, int interfaceIndex) { +boost::shared_ptr<DNSSDResolveHostnameQuery> AvahiQuerier::createResolveHostnameQuery(const std::string& hostname, int interfaceIndex) { return boost::shared_ptr<DNSSDResolveHostnameQuery>(new AvahiResolveHostnameQuery(hostname, interfaceIndex, shared_from_this(), eventLoop)); } diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h index d900ade..bfb017e 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiQuerier.h @@ -30,11 +30,11 @@ namespace Swift { boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery(); boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info); + const std::string& name, int port, const ByteArray& info); boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&); boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex); + const std::string& hostname, int interfaceIndex); void start(); void stop(); diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h index 780a0ca..07966af 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiRegisterQuery.h @@ -18,7 +18,7 @@ namespace Swift { class AvahiRegisterQuery : public DNSSDRegisterQuery, public AvahiQuery { public: - AvahiRegisterQuery(const String& name, int port, const ByteArray& txtRecord, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) { + AvahiRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), name(name), port(port), txtRecord(txtRecord), group(0) { } void registerService() { @@ -58,7 +58,7 @@ namespace Swift { AvahiStringList* txtList; avahi_string_list_parse(txtRecord.getData(), txtRecord.getSize(), &txtList); - int result = avahi_entry_group_add_service_strlst(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, static_cast<AvahiPublishFlags>(0), name.getUTF8Data(), "_presence._tcp", NULL, NULL, port, txtList); + int result = avahi_entry_group_add_service_strlst(group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, static_cast<AvahiPublishFlags>(0), name.c_str(), "_presence._tcp", NULL, NULL, port, txtList); if (result < 0) { std::cout << "Error registering service: " << avahi_strerror(result) << std::endl; eventLoop->postEvent(boost::bind(boost::ref(onRegisterFinished), boost::optional<DNSSDServiceID>()), shared_from_this()); @@ -100,7 +100,7 @@ namespace Swift { /* DNSServiceErrorType result = DNSServiceRegister( - &sdRef, 0, 0, name.getUTF8Data(), "_presence._tcp", NULL, NULL, port, + &sdRef, 0, 0, name.c_str(), "_presence._tcp", NULL, NULL, port, txtRecord.getSize(), txtRecord.getData(), &AvahiRegisterQuery::handleServiceRegisteredStatic, this); if (result != kDNSServiceErr_NoError) { @@ -125,7 +125,7 @@ namespace Swift { */ private: - String name; + std::string name; int port; ByteArray txtRecord; AvahiEntryGroup* group; diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h index ebbc68f..00712f1 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveHostnameQuery.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/Avahi/AvahiQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" #include "Swiften/EventLoop/EventLoop.h" @@ -19,7 +19,7 @@ namespace Swift { class AvahiResolveHostnameQuery : public DNSSDResolveHostnameQuery, public AvahiQuery { public: - AvahiResolveHostnameQuery(const String& hostname, int, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), hostname(hostname) { + AvahiResolveHostnameQuery(const std::string& hostname, int, boost::shared_ptr<AvahiQuerier> querier, EventLoop* eventLoop) : AvahiQuery(querier, eventLoop), hostname(hostname) { std::cout << "Resolving hostname " << hostname << std::endl; } @@ -32,6 +32,6 @@ namespace Swift { private: HostAddress hostAddress; - String hostname; + std::string hostname; }; } diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h index a7985ec..e9c4db1 100644 --- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h +++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h @@ -24,7 +24,7 @@ namespace Swift { std::cout << "Start resolving " << service.getName() << " " << service.getType() << " " << service.getDomain() << std::endl; avahi_threaded_poll_lock(querier->getThreadedPoll()); assert(!resolver); - resolver = avahi_service_resolver_new(querier->getClient(), service.getNetworkInterfaceID(), AVAHI_PROTO_UNSPEC, service.getName().getUTF8Data(), service.getType().getUTF8Data(), service.getDomain().getUTF8Data(), AVAHI_PROTO_UNSPEC, static_cast<AvahiLookupFlags>(0), handleServiceResolvedStatic, this); + resolver = avahi_service_resolver_new(querier->getClient(), service.getNetworkInterfaceID(), AVAHI_PROTO_UNSPEC, service.getName().c_str(), service.getType().c_str(), service.getDomain().c_str(), AVAHI_PROTO_UNSPEC, static_cast<AvahiLookupFlags>(0), handleServiceResolvedStatic, this); if (!resolver) { std::cout << "Error starting resolver" << std::endl; eventLoop->postEvent(boost::bind(boost::ref(onServiceResolved), boost::optional<Result>()), shared_from_this()); @@ -62,12 +62,12 @@ namespace Swift { avahi_string_list_serialize(txt, txtRecord.getData(), txtRecord.getSize()); // FIXME: Probably not accurate - String fullname = String(name) + "." + String(type) + "." + String(domain) + "."; - std::cout << "Result: " << fullname << "->" << String(a) << ":" << port << std::endl; + std::string fullname = std::string(name) + "." + std::string(type) + "." + std::string(domain) + "."; + std::cout << "Result: " << fullname << "->" << std::string(a) << ":" << port << std::endl; eventLoop->postEvent( boost::bind( boost::ref(onServiceResolved), - Result(fullname, String(a), port, txtRecord)), + Result(fullname, std::string(a), port, txtRecord)), shared_from_this()); break; } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp index 03271d6..2d346d9 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.cpp @@ -35,7 +35,7 @@ boost::shared_ptr<DNSSDBrowseQuery> BonjourQuerier::createBrowseQuery() { return boost::shared_ptr<DNSSDBrowseQuery>(new BonjourBrowseQuery(shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const String& name, int port, const ByteArray& info) { +boost::shared_ptr<DNSSDRegisterQuery> BonjourQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) { return boost::shared_ptr<DNSSDRegisterQuery>(new BonjourRegisterQuery(name, port, info, shared_from_this(), eventLoop)); } @@ -43,7 +43,7 @@ boost::shared_ptr<DNSSDResolveServiceQuery> BonjourQuerier::createResolveService return boost::shared_ptr<DNSSDResolveServiceQuery>(new BonjourResolveServiceQuery(service, shared_from_this(), eventLoop)); } -boost::shared_ptr<DNSSDResolveHostnameQuery> BonjourQuerier::createResolveHostnameQuery(const String& hostname, int interfaceIndex) { +boost::shared_ptr<DNSSDResolveHostnameQuery> BonjourQuerier::createResolveHostnameQuery(const std::string& hostname, int interfaceIndex) { return boost::shared_ptr<DNSSDResolveHostnameQuery>(new BonjourResolveHostnameQuery(hostname, interfaceIndex, shared_from_this(), eventLoop)); } diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h index 916acc3..edd3056 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuerier.h @@ -27,11 +27,11 @@ namespace Swift { boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery(); boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info); + const std::string& name, int port, const ByteArray& info); boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&); boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex); + const std::string& hostname, int interfaceIndex); void start(); void stop(); diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h index 9d8516b..7eb7ae1 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourRegisterQuery.h @@ -16,9 +16,9 @@ namespace Swift { class BonjourRegisterQuery : public DNSSDRegisterQuery, public BonjourQuery { public: - BonjourRegisterQuery(const String& name, int port, const ByteArray& txtRecord, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { + BonjourRegisterQuery(const std::string& name, int port, const ByteArray& txtRecord, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { DNSServiceErrorType result = DNSServiceRegister( - &sdRef, 0, 0, name.getUTF8Data(), "_presence._tcp", NULL, NULL, port, + &sdRef, 0, 0, name.c_str(), "_presence._tcp", NULL, NULL, port, txtRecord.getSize(), txtRecord.getData(), &BonjourRegisterQuery::handleServiceRegisteredStatic, this); if (result != kDNSServiceErr_NoError) { diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h index 16e9be6..b08b0b7 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveHostnameQuery.h @@ -8,7 +8,7 @@ #pragma GCC diagnostic ignored "-Wold-style-cast" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" #include "Swiften/EventLoop/EventLoop.h" @@ -21,10 +21,10 @@ namespace Swift { class BonjourResolveHostnameQuery : public DNSSDResolveHostnameQuery, public BonjourQuery { public: - BonjourResolveHostnameQuery(const String& hostname, int interfaceIndex, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { + BonjourResolveHostnameQuery(const std::string& hostname, int interfaceIndex, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { DNSServiceErrorType result = DNSServiceGetAddrInfo( &sdRef, 0, interfaceIndex, kDNSServiceProtocol_IPv4, - hostname.getUTF8Data(), + hostname.c_str(), &BonjourResolveHostnameQuery::handleHostnameResolvedStatic, this); if (result != kDNSServiceErr_NoError) { sdRef = NULL; diff --git a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h index 136b366..0501b56 100644 --- a/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h +++ b/Swiften/LinkLocal/DNSSD/Bonjour/BonjourResolveServiceQuery.h @@ -20,8 +20,8 @@ namespace Swift { BonjourResolveServiceQuery(const DNSSDServiceID& service, boost::shared_ptr<BonjourQuerier> querier, EventLoop* eventLoop) : BonjourQuery(querier, eventLoop) { DNSServiceErrorType result = DNSServiceResolve( &sdRef, 0, service.getNetworkInterfaceID(), - service.getName().getUTF8Data(), service.getType().getUTF8Data(), - service.getDomain().getUTF8Data(), + service.getName().c_str(), service.getType().c_str(), + service.getDomain().c_str(), &BonjourResolveServiceQuery::handleServiceResolvedStatic, this); if (result != kDNSServiceErr_NoError) { sdRef = NULL; @@ -55,7 +55,7 @@ namespace Swift { eventLoop->postEvent( boost::bind( boost::ref(onServiceResolved), - Result(String(fullName), String(host), port, + Result(std::string(fullName), std::string(host), port, ByteArray(reinterpret_cast<const char*>(txtRecord), txtLen))), shared_from_this()); } diff --git a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h index 21c4bdc..cd55fb7 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h +++ b/Swiften/LinkLocal/DNSSD/DNSSDQuerier.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> namespace Swift { - class String; + class ByteArray; class DNSSDServiceID; class DNSSDBrowseQuery; @@ -26,10 +26,10 @@ namespace Swift { virtual boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery() = 0; virtual boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info) = 0; + const std::string& name, int port, const ByteArray& info) = 0; virtual boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&) = 0; virtual boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex) = 0; + const std::string& hostname, int interfaceIndex) = 0; }; } diff --git a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h index b5ce232..ad73663 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h +++ b/Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h @@ -16,10 +16,10 @@ namespace Swift { class DNSSDResolveServiceQuery { public: struct Result { - Result(const String& fullName, const String& host, int port, const ByteArray& info) : + Result(const std::string& fullName, const std::string& host, int port, const ByteArray& info) : fullName(fullName), host(host), port(port), info(info) {} - String fullName; - String host; + std::string fullName; + std::string host; int port; ByteArray info; }; diff --git a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h index 1a720a0..9ce0781 100644 --- a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h +++ b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class DNSSDServiceID { @@ -14,9 +14,9 @@ namespace Swift { static const char* PresenceServiceType; DNSSDServiceID( - const String& name, - const String& domain, - const String& type = PresenceServiceType, + const std::string& name, + const std::string& domain, + const std::string& type = PresenceServiceType, int networkInterface = -1) : name(name), domain(domain), @@ -47,15 +47,15 @@ namespace Swift { } } - const String& getName() const { + const std::string& getName() const { return name; } - const String& getDomain() const { + const std::string& getDomain() const { return domain; } - const String& getType() const { + const std::string& getType() const { return type; } @@ -64,9 +64,9 @@ namespace Swift { } private: - String name; - String domain; - String type; + std::string name; + std::string domain; + std::string type; int networkInterface; }; } diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp index 0bcdba1..d7d0228 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.cpp @@ -16,7 +16,7 @@ namespace Swift { -FakeDNSSDQuerier::FakeDNSSDQuerier(const String& domain, EventLoop* eventLoop) : domain(domain), eventLoop(eventLoop) { +FakeDNSSDQuerier::FakeDNSSDQuerier(const std::string& domain, EventLoop* eventLoop) : domain(domain), eventLoop(eventLoop) { } FakeDNSSDQuerier::~FakeDNSSDQuerier() { @@ -29,7 +29,7 @@ boost::shared_ptr<DNSSDBrowseQuery> FakeDNSSDQuerier::createBrowseQuery() { return boost::shared_ptr<DNSSDBrowseQuery>(new FakeDNSSDBrowseQuery(shared_from_this())); } -boost::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const String& name, int port, const ByteArray& info) { +boost::shared_ptr<DNSSDRegisterQuery> FakeDNSSDQuerier::createRegisterQuery(const std::string& name, int port, const ByteArray& info) { return boost::shared_ptr<DNSSDRegisterQuery>(new FakeDNSSDRegisterQuery(name, port, info, shared_from_this())); } @@ -37,7 +37,7 @@ boost::shared_ptr<DNSSDResolveServiceQuery> FakeDNSSDQuerier::createResolveServi return boost::shared_ptr<DNSSDResolveServiceQuery>(new FakeDNSSDResolveServiceQuery(service, shared_from_this())); } -boost::shared_ptr<DNSSDResolveHostnameQuery> FakeDNSSDQuerier::createResolveHostnameQuery(const String& hostname, int interfaceIndex) { +boost::shared_ptr<DNSSDResolveHostnameQuery> FakeDNSSDQuerier::createResolveHostnameQuery(const std::string& hostname, int interfaceIndex) { return boost::shared_ptr<DNSSDResolveHostnameQuery>(new FakeDNSSDResolveHostnameQuery(hostname, interfaceIndex, shared_from_this())); } @@ -61,7 +61,7 @@ void FakeDNSSDQuerier::addRunningQuery(boost::shared_ptr<FakeDNSSDQuery> query) eventLoop->postEvent(boost::bind(boost::ref(registerQuery->onRegisterFinished), service), shared_from_this()); } else if (boost::shared_ptr<FakeDNSSDResolveHostnameQuery> resolveHostnameQuery = boost::dynamic_pointer_cast<FakeDNSSDResolveHostnameQuery>(query)) { - std::map<String,boost::optional<HostAddress> >::const_iterator i = addresses.find(resolveHostnameQuery->hostname); + std::map<std::string,boost::optional<HostAddress> >::const_iterator i = addresses.find(resolveHostnameQuery->hostname); if (i != addresses.end()) { eventLoop->postEvent( boost::bind( @@ -103,7 +103,7 @@ void FakeDNSSDQuerier::setServiceInfo(const DNSSDServiceID& id, const DNSSDResol } } -bool FakeDNSSDQuerier::isServiceRegistered(const String& name, int port, const ByteArray& info) { +bool FakeDNSSDQuerier::isServiceRegistered(const std::string& name, int port, const ByteArray& info) { foreach(const boost::shared_ptr<FakeDNSSDRegisterQuery>& query, getQueries<FakeDNSSDRegisterQuery>()) { if (query->name == name && query->port == port && query->info == info) { return true; @@ -124,7 +124,7 @@ void FakeDNSSDQuerier::setRegisterError() { } } -void FakeDNSSDQuerier::setAddress(const String& hostname, boost::optional<HostAddress> address) { +void FakeDNSSDQuerier::setAddress(const std::string& hostname, boost::optional<HostAddress> address) { addresses[hostname] = address; foreach(const boost::shared_ptr<FakeDNSSDResolveHostnameQuery>& query, getQueries<FakeDNSSDResolveHostnameQuery>()) { if (query->hostname == hostname) { diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h index 9338dd4..b2871c9 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuerier.h @@ -12,7 +12,7 @@ #include <set> #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/EventLoop/EventOwner.h" #include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h" @@ -29,7 +29,7 @@ namespace Swift { public EventOwner, public boost::enable_shared_from_this<FakeDNSSDQuerier> { public: - FakeDNSSDQuerier(const String& domain, EventLoop* eventLoop); + FakeDNSSDQuerier(const std::string& domain, EventLoop* eventLoop); ~FakeDNSSDQuerier(); void start() {} @@ -41,11 +41,11 @@ namespace Swift { boost::shared_ptr<DNSSDBrowseQuery> createBrowseQuery(); boost::shared_ptr<DNSSDRegisterQuery> createRegisterQuery( - const String& name, int port, const ByteArray& info); + const std::string& name, int port, const ByteArray& info); boost::shared_ptr<DNSSDResolveServiceQuery> createResolveServiceQuery( const DNSSDServiceID&); boost::shared_ptr<DNSSDResolveHostnameQuery> createResolveHostnameQuery( - const String& hostname, int interfaceIndex); + const std::string& hostname, int interfaceIndex); void addRunningQuery(boost::shared_ptr<FakeDNSSDQuery>); void removeRunningQuery(boost::shared_ptr<FakeDNSSDQuery>); @@ -53,8 +53,8 @@ namespace Swift { void addService(const DNSSDServiceID& id); void removeService(const DNSSDServiceID& id); void setServiceInfo(const DNSSDServiceID& id, const DNSSDResolveServiceQuery::Result& info); - bool isServiceRegistered(const String& name, int port, const ByteArray& info); - void setAddress(const String& hostname, boost::optional<HostAddress> address); + bool isServiceRegistered(const std::string& name, int port, const ByteArray& info); + void setAddress(const std::string& hostname, boost::optional<HostAddress> address); void setBrowseError(); void setRegisterError(); @@ -84,13 +84,13 @@ namespace Swift { } private: - String domain; + std::string domain; EventLoop* eventLoop; std::list< boost::shared_ptr<FakeDNSSDQuery> > runningQueries; std::list< boost::shared_ptr<FakeDNSSDQuery> > allQueriesEverRun; std::set<DNSSDServiceID> services; typedef std::map<DNSSDServiceID,DNSSDResolveServiceQuery::Result> ServiceInfoMap; ServiceInfoMap serviceInfo; - std::map<String, boost::optional<HostAddress> > addresses; + std::map<std::string, boost::optional<HostAddress> > addresses; }; } diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h index dc144b3..a6ae17a 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDRegisterQuery.h @@ -9,14 +9,14 @@ #include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDRegisterQuery.h" #include "Swiften/Base/ByteArray.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class FakeDNSSDQuerier; class FakeDNSSDRegisterQuery : public DNSSDRegisterQuery, public FakeDNSSDQuery { public: - FakeDNSSDRegisterQuery(const String& name, int port, const ByteArray& info, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) { + FakeDNSSDRegisterQuery(const std::string& name, int port, const ByteArray& info, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), name(name), port(port), info(info) { } void registerService() { @@ -31,7 +31,7 @@ namespace Swift { finish(); } - String name; + std::string name; int port; ByteArray info; }; diff --git a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h index b19bfe9..cbaa6e6 100644 --- a/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h +++ b/Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDResolveHostnameQuery.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/Fake/FakeDNSSDQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveHostnameQuery.h" #include "Swiften/Network/HostAddress.h" @@ -16,7 +16,7 @@ namespace Swift { class FakeDNSSDResolveHostnameQuery : public DNSSDResolveHostnameQuery, public FakeDNSSDQuery { public: - FakeDNSSDResolveHostnameQuery(const String& hostname, int interfaceIndex, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), hostname(hostname), interfaceIndex(interfaceIndex) { + FakeDNSSDResolveHostnameQuery(const std::string& hostname, int interfaceIndex, boost::shared_ptr<FakeDNSSDQuerier> querier) : FakeDNSSDQuery(querier), hostname(hostname), interfaceIndex(interfaceIndex) { } void run() { @@ -27,7 +27,7 @@ namespace Swift { FakeDNSSDQuery::finish(); } - String hostname; + std::string hostname; int interfaceIndex; }; } diff --git a/Swiften/LinkLocal/IncomingLinkLocalSession.h b/Swiften/LinkLocal/IncomingLinkLocalSession.h index 2973330..a586a2e 100644 --- a/Swiften/LinkLocal/IncomingLinkLocalSession.h +++ b/Swiften/LinkLocal/IncomingLinkLocalSession.h @@ -15,7 +15,7 @@ namespace Swift { class ProtocolHeader; - class String; + class Element; class PayloadParserFactoryCollection; class PayloadSerializerCollection; diff --git a/Swiften/LinkLocal/LinkLocalService.cpp b/Swiften/LinkLocal/LinkLocalService.cpp index d67361c..c8d707d 100644 --- a/Swiften/LinkLocal/LinkLocalService.cpp +++ b/Swiften/LinkLocal/LinkLocalService.cpp @@ -8,19 +8,19 @@ namespace Swift { -String LinkLocalService::getDescription() const { +std::string LinkLocalService::getDescription() const { LinkLocalServiceInfo info = getInfo(); - if (!info.getNick().isEmpty()) { + if (!info.getNick().empty()) { return info.getNick(); } - else if (!info.getFirstName().isEmpty()) { - String result = info.getFirstName(); - if (!info.getLastName().isEmpty()) { + else if (!info.getFirstName().empty()) { + std::string result = info.getFirstName(); + if (!info.getLastName().empty()) { result += " " + info.getLastName(); } return result; } - else if (!info.getLastName().isEmpty()) { + else if (!info.getLastName().empty()) { return info.getLastName(); } return getName(); diff --git a/Swiften/LinkLocal/LinkLocalService.h b/Swiften/LinkLocal/LinkLocalService.h index 27491e4..2e74338 100644 --- a/Swiften/LinkLocal/LinkLocalService.h +++ b/Swiften/LinkLocal/LinkLocalService.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/LinkLocal/DNSSD/DNSSDServiceID.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h" @@ -25,7 +25,7 @@ namespace Swift { return id; } - const String& getName() const { + const std::string& getName() const { return id.getName(); } @@ -33,7 +33,7 @@ namespace Swift { return info.port; } - const String& getHostname() const { + const std::string& getHostname() const { return info.host; } @@ -41,7 +41,7 @@ namespace Swift { return LinkLocalServiceInfo::createFromTXTRecord(info.info); } - String getDescription() const; + std::string getDescription() const; JID getJID() const; diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp index efd56e3..8393ade 100644 --- a/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.cpp @@ -63,7 +63,7 @@ bool LinkLocalServiceBrowser::isRegistered() const { return registerQuery; } -void LinkLocalServiceBrowser::registerService(const String& name, int port, const LinkLocalServiceInfo& info) { +void LinkLocalServiceBrowser::registerService(const std::string& name, int port, const LinkLocalServiceInfo& info) { assert(!registerQuery); registerQuery = querier->createRegisterQuery(name, port, info.toTXTRecord()); registerQuery->onRegisterFinished.connect( diff --git a/Swiften/LinkLocal/LinkLocalServiceBrowser.h b/Swiften/LinkLocal/LinkLocalServiceBrowser.h index 6918150..56b4aa4 100644 --- a/Swiften/LinkLocal/LinkLocalServiceBrowser.h +++ b/Swiften/LinkLocal/LinkLocalServiceBrowser.h @@ -12,7 +12,7 @@ #include <map> #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h" #include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h" #include "Swiften/LinkLocal/DNSSD/DNSSDRegisterQuery.h" @@ -32,7 +32,7 @@ namespace Swift { bool hasError() const; void registerService( - const String& name, + const std::string& name, int port, const LinkLocalServiceInfo& info = LinkLocalServiceInfo()); void updateService( diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp index cdde354..bec2e97 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp @@ -12,26 +12,26 @@ namespace Swift { ByteArray LinkLocalServiceInfo::toTXTRecord() const { ByteArray result(getEncoded("txtvers=1")); - if (!firstName.isEmpty()) { + if (!firstName.empty()) { result += getEncoded("1st=" + firstName); } - if (!lastName.isEmpty()) { + if (!lastName.empty()) { result += getEncoded("last=" + lastName); } - if (!email.isEmpty()) { + if (!email.empty()) { result += getEncoded("email=" + email); } if (jid.isValid()) { result += getEncoded("jid=" + jid.toString()); } - if (!message.isEmpty()) { + if (!message.empty()) { result += getEncoded("msg=" + message); } - if (!nick.isEmpty()) { + if (!nick.empty()) { result += getEncoded("nick=" + nick); } if (port) { - result += getEncoded("port.p2pj=" + String(boost::lexical_cast<std::string>(*port))); + result += getEncoded("port.p2pj=" + std::string(boost::lexical_cast<std::string>(*port))); } switch (status) { @@ -43,10 +43,10 @@ ByteArray LinkLocalServiceInfo::toTXTRecord() const { return result; } -ByteArray LinkLocalServiceInfo::getEncoded(const String& s) { +ByteArray LinkLocalServiceInfo::getEncoded(const std::string& s) { ByteArray sizeByte; sizeByte.resize(1); - sizeByte[0] = s.getUTF8Size(); + sizeByte[0] = s.size(); return sizeByte + ByteArray(s); } @@ -54,8 +54,8 @@ LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray& LinkLocalServiceInfo info; size_t i = 0; while (i < record.getSize()) { - std::pair<String,String> entry = readEntry(record, &i); - if (entry.first.isEmpty()) { + std::pair<std::string,std::string> entry = readEntry(record, &i); + if (entry.first.empty()) { break; } else if (entry.first == "1st") { @@ -91,10 +91,10 @@ LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray& return info; } -std::pair<String,String> LinkLocalServiceInfo::readEntry(const ByteArray& record, size_t* index) { +std::pair<std::string,std::string> LinkLocalServiceInfo::readEntry(const ByteArray& record, size_t* index) { size_t& i = *index; - String key; - String value; + std::string key; + std::string value; size_t entryEnd = i + 1 + record[i]; ++i; diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.h b/Swiften/LinkLocal/LinkLocalServiceInfo.h index efe9245..a166c64 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.h +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.h @@ -9,7 +9,7 @@ #include <boost/optional.hpp> #include "Swiften/Base/ByteArray.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" namespace Swift { @@ -20,23 +20,23 @@ namespace Swift { LinkLocalServiceInfo() : status(Available) {} - const String& getFirstName() const { return firstName; } - void setFirstName(const String& f) { firstName = f; } + const std::string& getFirstName() const { return firstName; } + void setFirstName(const std::string& f) { firstName = f; } - const String& getLastName() const { return lastName; } - void setLastName(const String& l) { lastName = l; } + const std::string& getLastName() const { return lastName; } + void setLastName(const std::string& l) { lastName = l; } - const String& getEMail() const { return email; } - void setEMail(const String& e) { email = e; } + const std::string& getEMail() const { return email; } + void setEMail(const std::string& e) { email = e; } const JID& getJID() const { return jid; } void setJID(const JID& j) { jid = j; } - const String& getMessage() const { return message; } - void setMessage(const String& m) { message = m; } + const std::string& getMessage() const { return message; } + void setMessage(const std::string& m) { message = m; } - const String& getNick() const { return nick; } - void setNick(const String& n) { nick = n; } + const std::string& getNick() const { return nick; } + void setNick(const std::string& n) { nick = n; } Status getStatus() const { return status; } void setStatus(Status s) { status = s; } @@ -49,16 +49,16 @@ namespace Swift { static LinkLocalServiceInfo createFromTXTRecord(const ByteArray& record); private: - static ByteArray getEncoded(const String&); - static std::pair<String,String> readEntry(const ByteArray&, size_t*); + static ByteArray getEncoded(const std::string&); + static std::pair<std::string,std::string> readEntry(const ByteArray&, size_t*); private: - String firstName; - String lastName; - String email; + std::string firstName; + std::string lastName; + std::string email; JID jid; - String message; - String nick; + std::string message; + std::string nick; Status status; boost::optional<int> port; }; diff --git a/Swiften/LinkLocal/OutgoingLinkLocalSession.h b/Swiften/LinkLocal/OutgoingLinkLocalSession.h index 2c339bb..34ea411 100644 --- a/Swiften/LinkLocal/OutgoingLinkLocalSession.h +++ b/Swiften/LinkLocal/OutgoingLinkLocalSession.h @@ -16,7 +16,7 @@ namespace Swift { class ConnectionFactory; - class String; + class Element; class PayloadParserFactoryCollection; class PayloadSerializerCollection; diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp index 65b8a67..98deed1 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalConnectorTest.cpp @@ -51,7 +51,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(connectFinished); CPPUNIT_ASSERT(!connectError); CPPUNIT_ASSERT(connection->connectedTo); - CPPUNIT_ASSERT_EQUAL(String(connection->connectedTo->getAddress().toString()), String("192.168.1.1")); + CPPUNIT_ASSERT_EQUAL(std::string(connection->connectedTo->getAddress().toString()), std::string("192.168.1.1")); CPPUNIT_ASSERT_EQUAL(connection->connectedTo->getPort(), 1234); } @@ -113,7 +113,7 @@ class LinkLocalConnectorTest : public CppUnit::TestFixture { } private: - boost::shared_ptr<LinkLocalConnector> createConnector(const String& hostname, int port) { + boost::shared_ptr<LinkLocalConnector> createConnector(const std::string& hostname, int port) { LinkLocalService service( DNSSDServiceID("myname", "local."), DNSSDResolveServiceQuery::Result( diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp index 1e0ee8a..3943e31 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceInfoTest.cpp @@ -28,21 +28,21 @@ class LinkLocalServiceInfoTest : public CppUnit::TestFixture { info.setLastName("Tron\xc3\xe7on"); info.setStatus(LinkLocalServiceInfo::Away); - CPPUNIT_ASSERT_EQUAL(ByteArray("\x09txtvers=1\x09" + String("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), info.toTXTRecord()); + CPPUNIT_ASSERT_EQUAL(ByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away")), info.toTXTRecord()); } void testCreateFromTXTRecord() { - LinkLocalServiceInfo info = LinkLocalServiceInfo::createFromTXTRecord(ByteArray("\x09txtvers=1\x09" + String("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away"))); + LinkLocalServiceInfo info = LinkLocalServiceInfo::createFromTXTRecord(ByteArray("\x09txtvers=1\x09" + std::string("1st=Remko\x0dlast=Tron\xc3\xe7on\x0bstatus=away"))); - CPPUNIT_ASSERT_EQUAL(String("Remko"), info.getFirstName()); - CPPUNIT_ASSERT_EQUAL(String("Tron\xc3\xe7on"), info.getLastName()); + CPPUNIT_ASSERT_EQUAL(std::string("Remko"), info.getFirstName()); + CPPUNIT_ASSERT_EQUAL(std::string("Tron\xc3\xe7on"), info.getLastName()); CPPUNIT_ASSERT_EQUAL(LinkLocalServiceInfo::Away, info.getStatus()); } void testCreateFromTXTRecord_InvalidSize() { LinkLocalServiceInfo info = LinkLocalServiceInfo::createFromTXTRecord(ByteArray("\x10last=a")); - CPPUNIT_ASSERT_EQUAL(String("a"), info.getLastName()); + CPPUNIT_ASSERT_EQUAL(std::string("a"), info.getLastName()); } void testGetTXTRecordCreateFromTXTRecord_RoundTrip() { diff --git a/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp b/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp index 0d4de13..4835bde 100644 --- a/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp +++ b/Swiften/LinkLocal/UnitTest/LinkLocalServiceTest.cpp @@ -24,35 +24,35 @@ class LinkLocalServiceTest : public CppUnit::TestFixture { void testGetDescription_WithNick() { LinkLocalService testling = createService("alice@wonderland", "Alice", "Alice In", "Wonderland"); - CPPUNIT_ASSERT_EQUAL(String("Alice"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), testling.getDescription()); } void testGetDescription_WithFirstName() { LinkLocalService testling = createService("alice@wonderland", "", "Alice In"); - CPPUNIT_ASSERT_EQUAL(String("Alice In"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In"), testling.getDescription()); } void testGetDescription_WithLastName() { LinkLocalService testling = createService("alice@wonderland", "", "", "Wonderland"); - CPPUNIT_ASSERT_EQUAL(String("Wonderland"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), testling.getDescription()); } void testGetDescription_WithFirstAndLastName() { LinkLocalService testling = createService("alice@wonderland", "", "Alice In", "Wonderland"); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), testling.getDescription()); } void testGetDescription_NoInfo() { LinkLocalService testling = createService("alice@wonderland"); - CPPUNIT_ASSERT_EQUAL(String("alice@wonderland"), testling.getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("alice@wonderland"), testling.getDescription()); } private: - LinkLocalService createService(const String& name, const String& nickName = String(), const String& firstName = String(), const String& lastName = String()) { + LinkLocalService createService(const std::string& name, const std::string& nickName = std::string(), const std::string& firstName = std::string(), const std::string& lastName = std::string()) { DNSSDServiceID service(name, "local."); LinkLocalServiceInfo info; info.setFirstName(firstName); diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp index 486ba27..b8c23cd 100644 --- a/Swiften/MUC/MUC.cpp +++ b/Swiften/MUC/MUC.cpp @@ -22,7 +22,7 @@ namespace Swift { -typedef std::pair<String, MUCOccupant> StringMUCOccupantPair; +typedef std::pair<std::string, MUCOccupant> StringMUCOccupantPair; MUC::MUC(StanzaChannel* stanzaChannel, IQRouter* iqRouter, DirectedPresenceSender* presenceSender, const JID &muc, MUCRegistry* mucRegistry) : ownMUCJID(muc), stanzaChannel(stanzaChannel), iqRouter_(iqRouter), presenceSender(presenceSender), mucRegistry(mucRegistry) { scopedConnection_ = stanzaChannel->onPresenceReceived.connect(boost::bind(&MUC::handleIncomingPresence, this, _1)); @@ -33,7 +33,7 @@ MUC::MUC(StanzaChannel* stanzaChannel, IQRouter* iqRouter, DirectedPresenceSende /** * Join the MUC with default context. */ -void MUC::joinAs(const String &nick) { +void MUC::joinAs(const std::string &nick) { joinSince_ = boost::posix_time::not_a_date_time; internalJoin(nick); } @@ -41,12 +41,12 @@ void MUC::joinAs(const String &nick) { /** * Join the MUC with context since date. */ -void MUC::joinWithContextSince(const String &nick, const boost::posix_time::ptime& since) { +void MUC::joinWithContextSince(const std::string &nick, const boost::posix_time::ptime& since) { joinSince_ = since; internalJoin(nick); } -void MUC::internalJoin(const String &nick) { +void MUC::internalJoin(const std::string &nick) { //TODO: password //TODO: history request joinComplete_ = false; @@ -74,7 +74,7 @@ void MUC::part() { } void MUC::handleUserLeft(LeavingType type) { - std::map<String,MUCOccupant>::iterator i = occupants.find(ownMUCJID.getResource()); + std::map<std::string,MUCOccupant>::iterator i = occupants.find(ownMUCJID.getResource()); if (i != occupants.end()) { MUCOccupant me = i->second; occupants.erase(i); @@ -102,7 +102,7 @@ void MUC::handleIncomingPresence(Presence::ref presence) { // (i.e. we start getting non-error presence from the MUC) or not if (!joinSucceeded_) { if (presence->getType() == Presence::Error) { - String reason; + std::string reason; onJoinFailed(presence->getPayload<ErrorPayload>()); return; } @@ -112,8 +112,8 @@ void MUC::handleIncomingPresence(Presence::ref presence) { } } - String nick = presence->getFrom().getResource(); - if (nick.isEmpty()) { + std::string nick = presence->getFrom().getResource(); + if (nick.empty()) { return; } MUCOccupant::Role role(MUCOccupant::NoRole); @@ -135,7 +135,7 @@ void MUC::handleIncomingPresence(Presence::ref presence) { return; } else { - std::map<String,MUCOccupant>::iterator i = occupants.find(nick); + std::map<std::string,MUCOccupant>::iterator i = occupants.find(nick); if (i != occupants.end()) { //TODO: part type onOccupantLeft(i->second, Part, ""); @@ -144,7 +144,7 @@ void MUC::handleIncomingPresence(Presence::ref presence) { } } else if (presence->getType() == Presence::Available) { - std::map<String, MUCOccupant>::iterator it = occupants.find(nick); + std::map<std::string, MUCOccupant>::iterator it = occupants.find(nick); MUCOccupant occupant(nick, role, affiliation); bool isJoin = true; if (realJID) { @@ -161,7 +161,7 @@ void MUC::handleIncomingPresence(Presence::ref presence) { } occupants.erase(it); } - std::pair<std::map<String, MUCOccupant>::iterator, bool> result = occupants.insert(std::make_pair(nick, occupant)); + std::pair<std::map<std::string, MUCOccupant>::iterator, bool> result = occupants.insert(std::make_pair(nick, occupant)); if (isJoin) { onOccupantJoined(result.first->second); } diff --git a/Swiften/MUC/MUC.h b/Swiften/MUC/MUC.h index cdef292..ef76a6a 100644 --- a/Swiften/MUC/MUC.h +++ b/Swiften/MUC/MUC.h @@ -7,7 +7,7 @@ #pragma once #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Message.h" #include "Swiften/Elements/Presence.h" #include "Swiften/Elements/MUCOccupant.h" @@ -42,24 +42,24 @@ namespace Swift { return ownMUCJID.toBare(); } - void joinAs(const String &nick); - void joinWithContextSince(const String &nick, const boost::posix_time::ptime& since); + void joinAs(const std::string &nick); + void joinWithContextSince(const std::string &nick, const boost::posix_time::ptime& since); /*void queryRoomInfo(); */ /*void queryRoomItems(); */ - String getCurrentNick(); + std::string getCurrentNick(); void part(); void handleIncomingMessage(Message::ref message); /** Expose public so it can be called when e.g. user goes offline */ void handleUserLeft(LeavingType); public: - boost::signal<void (const String& /*nick*/)> onJoinComplete; + boost::signal<void (const std::string& /*nick*/)> onJoinComplete; boost::signal<void (ErrorPayload::ref)> onJoinFailed; boost::signal<void (Presence::ref)> onOccupantPresenceChange; - boost::signal<void (const String&, const MUCOccupant& /*now*/, const MUCOccupant::Role& /*old*/)> onOccupantRoleChanged; - boost::signal<void (const String&, const MUCOccupant::Affiliation& /*new*/, const MUCOccupant::Affiliation& /*old*/)> onOccupantAffiliationChanged; + boost::signal<void (const std::string&, const MUCOccupant& /*now*/, const MUCOccupant::Role& /*old*/)> onOccupantRoleChanged; + boost::signal<void (const std::string&, const MUCOccupant::Affiliation& /*new*/, const MUCOccupant::Affiliation& /*old*/)> onOccupantAffiliationChanged; boost::signal<void (const MUCOccupant&)> onOccupantJoined; - boost::signal<void (const MUCOccupant&, LeavingType, const String& /*reason*/)> onOccupantLeft; + boost::signal<void (const MUCOccupant&, LeavingType, const std::string& /*reason*/)> onOccupantLeft; /* boost::signal<void (const MUCInfo&)> onInfoResult; */ /* boost::signal<void (const blah&)> onItemsResult; */ @@ -69,13 +69,13 @@ namespace Swift { return ownMUCJID.equals(j, JID::WithoutResource); } - const String& getOwnNick() const { + const std::string& getOwnNick() const { return ownMUCJID.getResource(); } private: void handleIncomingPresence(Presence::ref presence); - void internalJoin(const String& nick); + void internalJoin(const std::string& nick); void handleCreationConfigResponse(MUCOwnerPayload::ref, ErrorPayload::ref); private: @@ -84,7 +84,7 @@ namespace Swift { IQRouter* iqRouter_; DirectedPresenceSender* presenceSender; MUCRegistry* mucRegistry; - std::map<String, MUCOccupant> occupants; + std::map<std::string, MUCOccupant> occupants; bool joinSucceeded_; bool joinComplete_; boost::bsignals::scoped_connection scopedConnection_; diff --git a/Swiften/MUC/MUCBookmark.h b/Swiften/MUC/MUCBookmark.h index 65797e5..10e1b78 100644 --- a/Swiften/MUC/MUCBookmark.h +++ b/Swiften/MUC/MUCBookmark.h @@ -8,7 +8,7 @@ #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/Elements/Storage.h" @@ -23,7 +23,7 @@ namespace Swift { autojoin_ = room.autoJoin; } - MUCBookmark(const JID& room, const String& bookmarkName) : room_(room), name_(bookmarkName), autojoin_(false) { + MUCBookmark(const JID& room, const std::string& bookmarkName) : room_(room), name_(bookmarkName), autojoin_(false) { } void setAutojoin(bool enabled) { @@ -34,23 +34,23 @@ namespace Swift { return autojoin_; } - void setNick(const boost::optional<String>& nick) { + void setNick(const boost::optional<std::string>& nick) { nick_ = nick; } - void setPassword(const boost::optional<String>& password) { + void setPassword(const boost::optional<std::string>& password) { password_ = password; } - const boost::optional<String>& getNick() const { + const boost::optional<std::string>& getNick() const { return nick_; } - const boost::optional<String>& getPassword() const { + const boost::optional<std::string>& getPassword() const { return password_; } - const String& getName() const { + const std::string& getName() const { return name_; } @@ -78,9 +78,9 @@ namespace Swift { private: JID room_; - String name_; - boost::optional<String> nick_; - boost::optional<String> password_; + std::string name_; + boost::optional<std::string> nick_; + boost::optional<std::string> password_; bool autojoin_; }; } diff --git a/Swiften/MUC/UnitTest/MUCTest.cpp b/Swiften/MUC/UnitTest/MUCTest.cpp index fd07711..117760c 100644 --- a/Swiften/MUC/UnitTest/MUCTest.cpp +++ b/Swiften/MUC/UnitTest/MUCTest.cpp @@ -73,7 +73,7 @@ class MUCTest : public CppUnit::TestFixture { Presence::ref p = channel->getStanzaAtIndex<Presence>(2); CPPUNIT_ASSERT(p); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/Alice"), p->getTo()); - CPPUNIT_ASSERT_EQUAL(String("Test"), p->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("Test"), p->getStatus()); } /*void testJoin_Success() { @@ -83,7 +83,7 @@ class MUCTest : public CppUnit::TestFixture { receivePresence(JID("foo@bar.com/Rabbit"), "Here"); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(joinResults.size())); - CPPUNIT_ASSERT_EQUAL(String("Alice"), joinResults[0].nick); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), joinResults[0].nick); CPPUNIT_ASSERT(joinResults[0].error); } @@ -96,14 +96,14 @@ class MUCTest : public CppUnit::TestFixture { return boost::make_shared<MUC>(channel, router, presenceSender, jid, mucRegistry); } - void handleJoinFinished(const String& nick, ErrorPayload::ref error) { + void handleJoinFinished(const std::string& nick, ErrorPayload::ref error) { JoinResult r; r.nick = nick; r.error = error; joinResults.push_back(r); } - void receivePresence(const JID& jid, const String& status) { + void receivePresence(const JID& jid, const std::string& status) { Presence::ref p = Presence::create(status); p->setFrom(jid); //MUCUserPayload::ref mucUserPayload = boost::make_shared<MUCUserPayload>(); @@ -119,7 +119,7 @@ class MUCTest : public CppUnit::TestFixture { StanzaChannelPresenceSender* stanzaChannelPresenceSender; DirectedPresenceSender* presenceSender; struct JoinResult { - String nick; + std::string nick; ErrorPayload::ref error; }; std::vector<JoinResult> joinResults; diff --git a/Swiften/Network/BoostConnection.cpp b/Swiften/Network/BoostConnection.cpp index 3f33cfc..f7ff8c4 100644 --- a/Swiften/Network/BoostConnection.cpp +++ b/Swiften/Network/BoostConnection.cpp @@ -12,7 +12,7 @@ #include <Swiften/Base/Log.h> #include "Swiften/EventLoop/EventLoop.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Network/HostAddressPort.h" #include "Swiften/Base/sleep.h" diff --git a/Swiften/Network/CAresDomainNameResolver.cpp b/Swiften/Network/CAresDomainNameResolver.cpp index 8462e4f..dd49139 100644 --- a/Swiften/Network/CAresDomainNameResolver.cpp +++ b/Swiften/Network/CAresDomainNameResolver.cpp @@ -26,7 +26,7 @@ namespace Swift { class CAresQuery : public boost::enable_shared_from_this<CAresQuery>, public EventOwner { public: - CAresQuery(const String& query, int dnsclass, int type, CAresDomainNameResolver* resolver) : query(query), dnsclass(dnsclass), type(type), resolver(resolver) { + CAresQuery(const std::string& query, int dnsclass, int type, CAresDomainNameResolver* resolver) : query(query), dnsclass(dnsclass), type(type), resolver(resolver) { } virtual ~CAresQuery() { @@ -37,7 +37,7 @@ class CAresQuery : public boost::enable_shared_from_this<CAresQuery>, public Eve } void doRun(ares_channel* channel) { - ares_query(*channel, query.getUTF8Data(), dnsclass, type, &CAresQuery::handleResult, this); + ares_query(*channel, query.c_str(), dnsclass, type, &CAresQuery::handleResult, this); } static void handleResult(void* arg, int status, int timeouts, unsigned char* buffer, int len) { @@ -47,7 +47,7 @@ class CAresQuery : public boost::enable_shared_from_this<CAresQuery>, public Eve virtual void handleResult(int status, int, unsigned char* buffer, int len) = 0; private: - String query; + std::string query; int dnsclass; int type; CAresDomainNameResolver* resolver; @@ -55,7 +55,7 @@ class CAresQuery : public boost::enable_shared_from_this<CAresQuery>, public Eve class CAresDomainNameServiceQuery : public DomainNameServiceQuery, public CAresQuery { public: - CAresDomainNameServiceQuery(const String& service, CAresDomainNameResolver* resolver) : CAresQuery(service, 1, 33, resolver) { + CAresDomainNameServiceQuery(const std::string& service, CAresDomainNameResolver* resolver) : CAresQuery(service, 1, 33, resolver) { } virtual void run() { @@ -72,7 +72,7 @@ class CAresDomainNameServiceQuery : public DomainNameServiceQuery, public CAresQ record.priority = rawRecords->priority; record.weight = rawRecords->weight; record.port = rawRecords->port; - record.hostname = String(rawRecords->host); + record.hostname = std::string(rawRecords->host); records.push_back(record); } } @@ -87,7 +87,7 @@ class CAresDomainNameServiceQuery : public DomainNameServiceQuery, public CAresQ class CAresDomainNameAddressQuery : public DomainNameAddressQuery, public CAresQuery { public: - CAresDomainNameAddressQuery(const String& host, CAresDomainNameResolver* resolver) : CAresQuery(host, 1, 1, resolver) { + CAresDomainNameAddressQuery(const std::string& host, CAresDomainNameResolver* resolver) : CAresQuery(host, 1, 1, resolver) { } virtual void run() { @@ -129,11 +129,11 @@ CAresDomainNameResolver::~CAresDomainNameResolver() { ares_destroy(channel); } -boost::shared_ptr<DomainNameServiceQuery> CAresDomainNameResolver::createServiceQuery(const String& name) { +boost::shared_ptr<DomainNameServiceQuery> CAresDomainNameResolver::createServiceQuery(const std::string& name) { return boost::shared_ptr<DomainNameServiceQuery>(new CAresDomainNameServiceQuery(getNormalized(name), this)); } -boost::shared_ptr<DomainNameAddressQuery> CAresDomainNameResolver::createAddressQuery(const String& name) { +boost::shared_ptr<DomainNameAddressQuery> CAresDomainNameResolver::createAddressQuery(const std::string& name) { return boost::shared_ptr<DomainNameAddressQuery>(new CAresDomainNameAddressQuery(getNormalized(name), this)); } diff --git a/Swiften/Network/CAresDomainNameResolver.h b/Swiften/Network/CAresDomainNameResolver.h index 74bb6ae..a630b61 100644 --- a/Swiften/Network/CAresDomainNameResolver.h +++ b/Swiften/Network/CAresDomainNameResolver.h @@ -21,8 +21,8 @@ namespace Swift { CAresDomainNameResolver(); ~CAresDomainNameResolver(); - virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const String& name); - virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const String& name); + virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& name); + virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const std::string& name); private: friend class CAresQuery; diff --git a/Swiften/Network/Connection.h b/Swiften/Network/Connection.h index 712f145..529dd82 100644 --- a/Swiften/Network/Connection.h +++ b/Swiften/Network/Connection.h @@ -10,7 +10,7 @@ #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Base/ByteArray.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Network/HostAddressPort.h" namespace Swift { diff --git a/Swiften/Network/Connector.cpp b/Swiften/Network/Connector.cpp index 28088c5..868bd50 100644 --- a/Swiften/Network/Connector.cpp +++ b/Swiften/Network/Connector.cpp @@ -17,7 +17,7 @@ namespace Swift { -Connector::Connector(const String& hostname, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0), queriedAllServices(true) { +Connector::Connector(const std::string& hostname, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) : hostname(hostname), resolver(resolver), connectionFactory(connectionFactory), timerFactory(timerFactory), timeoutMilliseconds(0), queriedAllServices(true) { } void Connector::setTimeoutMilliseconds(int milliseconds) { @@ -45,7 +45,7 @@ void Connector::stop() { finish(boost::shared_ptr<Connection>()); } -void Connector::queryAddress(const String& hostname) { +void Connector::queryAddress(const std::string& hostname) { assert(!addressQuery); addressQuery = resolver->createAddressQuery(hostname); addressQuery->onResult.connect(boost::bind(&Connector::handleAddressQueryResult, shared_from_this(), _1, _2)); diff --git a/Swiften/Network/Connector.h b/Swiften/Network/Connector.h index 52779c2..b3e7d83 100644 --- a/Swiften/Network/Connector.h +++ b/Swiften/Network/Connector.h @@ -14,7 +14,7 @@ #include "Swiften/Network/Connection.h" #include "Swiften/Network/Timer.h" #include "Swiften/Network/HostAddressPort.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Network/DomainNameResolveError.h" namespace Swift { @@ -27,7 +27,7 @@ namespace Swift { public: typedef boost::shared_ptr<Connector> ref; - static Connector::ref create(const String& hostname, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { + static Connector::ref create(const std::string& hostname, DomainNameResolver* resolver, ConnectionFactory* connectionFactory, TimerFactory* timerFactory) { return Connector::ref(new Connector(hostname, resolver, connectionFactory, timerFactory)); } @@ -38,11 +38,11 @@ namespace Swift { boost::signal<void (boost::shared_ptr<Connection>)> onConnectFinished; private: - Connector(const String& hostname, DomainNameResolver*, ConnectionFactory*, TimerFactory*); + Connector(const std::string& hostname, DomainNameResolver*, ConnectionFactory*, TimerFactory*); void handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result); void handleAddressQueryResult(const std::vector<HostAddress>& address, boost::optional<DomainNameResolveError> error); - void queryAddress(const String& hostname); + void queryAddress(const std::string& hostname); void tryNextServiceOrFallback(); void tryNextAddress(); @@ -54,7 +54,7 @@ namespace Swift { private: - String hostname; + std::string hostname; DomainNameResolver* resolver; ConnectionFactory* connectionFactory; TimerFactory* timerFactory; diff --git a/Swiften/Network/DomainNameResolver.h b/Swiften/Network/DomainNameResolver.h index cf9d521..b0ebc35 100644 --- a/Swiften/Network/DomainNameResolver.h +++ b/Swiften/Network/DomainNameResolver.h @@ -8,18 +8,18 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class DomainNameServiceQuery; class DomainNameAddressQuery; - class String; + class DomainNameResolver { public: virtual ~DomainNameResolver(); - virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const String& name) = 0; - virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const String& name) = 0; + virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& name) = 0; + virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const std::string& name) = 0; }; } diff --git a/Swiften/Network/DomainNameServiceQuery.h b/Swiften/Network/DomainNameServiceQuery.h index fb44e82..63d5841 100644 --- a/Swiften/Network/DomainNameServiceQuery.h +++ b/Swiften/Network/DomainNameServiceQuery.h @@ -11,7 +11,7 @@ #include <vector> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Network/DomainNameResolveError.h" namespace Swift { @@ -20,8 +20,8 @@ namespace Swift { typedef boost::shared_ptr<DomainNameServiceQuery> ref; struct Result { - Result(const String& hostname = "", int port = -1, int priority = -1, int weight = -1) : hostname(hostname), port(port), priority(priority), weight(weight) {} - String hostname; + Result(const std::string& hostname = "", int port = -1, int priority = -1, int weight = -1) : hostname(hostname), port(port), priority(priority), weight(weight) {} + std::string hostname; int port; int priority; int weight; diff --git a/Swiften/Network/HostAddress.cpp b/Swiften/Network/HostAddress.cpp index b3876c0..7acd407 100644 --- a/Swiften/Network/HostAddress.cpp +++ b/Swiften/Network/HostAddress.cpp @@ -13,16 +13,16 @@ #include <boost/array.hpp> #include "Swiften/Base/foreach.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { HostAddress::HostAddress() { } -HostAddress::HostAddress(const String& address) { +HostAddress::HostAddress(const std::string& address) { try { - address_ = boost::asio::ip::address::from_string(address.getUTF8String()); + address_ = boost::asio::ip::address::from_string(address); } catch (const std::exception& t) { } diff --git a/Swiften/Network/HostAddress.h b/Swiften/Network/HostAddress.h index 6e2bde0..34ccd24 100644 --- a/Swiften/Network/HostAddress.h +++ b/Swiften/Network/HostAddress.h @@ -11,12 +11,12 @@ #include <boost/asio.hpp> namespace Swift { - class String; + class HostAddress { public: HostAddress(); - HostAddress(const String&); + HostAddress(const std::string&); HostAddress(const unsigned char* address, int length); HostAddress(const boost::asio::ip::address& address); diff --git a/Swiften/Network/PlatformDomainNameAddressQuery.cpp b/Swiften/Network/PlatformDomainNameAddressQuery.cpp index 2a8574d..1832255 100644 --- a/Swiften/Network/PlatformDomainNameAddressQuery.cpp +++ b/Swiften/Network/PlatformDomainNameAddressQuery.cpp @@ -11,7 +11,7 @@ namespace Swift { -PlatformDomainNameAddressQuery::PlatformDomainNameAddressQuery(const String& host, EventLoop* eventLoop, PlatformDomainNameResolver* resolver) : PlatformDomainNameQuery(resolver), hostname(host), eventLoop(eventLoop) { +PlatformDomainNameAddressQuery::PlatformDomainNameAddressQuery(const std::string& host, EventLoop* eventLoop, PlatformDomainNameResolver* resolver) : PlatformDomainNameQuery(resolver), hostname(host), eventLoop(eventLoop) { } void PlatformDomainNameAddressQuery::run() { @@ -21,7 +21,7 @@ void PlatformDomainNameAddressQuery::run() { void PlatformDomainNameAddressQuery::runBlocking() { //std::cout << "PlatformDomainNameResolver::doRun()" << std::endl; boost::asio::ip::tcp::resolver resolver(ioService); - boost::asio::ip::tcp::resolver::query query(hostname.getUTF8String(), "5222"); + boost::asio::ip::tcp::resolver::query query(hostname, "5222"); try { //std::cout << "PlatformDomainNameResolver::doRun(): Resolving" << std::endl; boost::asio::ip::tcp::resolver::iterator endpointIterator = resolver.resolve(query); diff --git a/Swiften/Network/PlatformDomainNameAddressQuery.h b/Swiften/Network/PlatformDomainNameAddressQuery.h index 0153688..c2854ac 100644 --- a/Swiften/Network/PlatformDomainNameAddressQuery.h +++ b/Swiften/Network/PlatformDomainNameAddressQuery.h @@ -12,7 +12,7 @@ #include <Swiften/Network/DomainNameAddressQuery.h> #include <Swiften/Network/PlatformDomainNameQuery.h> #include <Swiften/EventLoop/EventOwner.h> -#include <Swiften/Base/String.h> +#include <string> namespace Swift { class PlatformDomainNameResolver; @@ -20,7 +20,7 @@ namespace Swift { class PlatformDomainNameAddressQuery : public DomainNameAddressQuery, public PlatformDomainNameQuery, public boost::enable_shared_from_this<PlatformDomainNameAddressQuery>, public EventOwner { public: - PlatformDomainNameAddressQuery(const String& host, EventLoop* eventLoop, PlatformDomainNameResolver*); + PlatformDomainNameAddressQuery(const std::string& host, EventLoop* eventLoop, PlatformDomainNameResolver*); void run(); @@ -30,7 +30,7 @@ namespace Swift { private: boost::asio::io_service ioService; - String hostname; + std::string hostname; EventLoop* eventLoop; }; } diff --git a/Swiften/Network/PlatformDomainNameResolver.cpp b/Swiften/Network/PlatformDomainNameResolver.cpp index ec23091..f2c1e36 100644 --- a/Swiften/Network/PlatformDomainNameResolver.cpp +++ b/Swiften/Network/PlatformDomainNameResolver.cpp @@ -15,7 +15,7 @@ #include <boost/thread.hpp> #include <algorithm> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/IDN/IDNA.h" #include "Swiften/Network/HostAddress.h" #include "Swiften/EventLoop/EventLoop.h" @@ -38,11 +38,11 @@ PlatformDomainNameResolver::~PlatformDomainNameResolver() { delete thread; } -boost::shared_ptr<DomainNameServiceQuery> PlatformDomainNameResolver::createServiceQuery(const String& name) { +boost::shared_ptr<DomainNameServiceQuery> PlatformDomainNameResolver::createServiceQuery(const std::string& name) { return boost::shared_ptr<DomainNameServiceQuery>(new PlatformDomainNameServiceQuery(IDNA::getEncoded(name), eventLoop, this)); } -boost::shared_ptr<DomainNameAddressQuery> PlatformDomainNameResolver::createAddressQuery(const String& name) { +boost::shared_ptr<DomainNameAddressQuery> PlatformDomainNameResolver::createAddressQuery(const std::string& name) { return boost::shared_ptr<DomainNameAddressQuery>(new PlatformDomainNameAddressQuery(IDNA::getEncoded(name), eventLoop, this)); } diff --git a/Swiften/Network/PlatformDomainNameResolver.h b/Swiften/Network/PlatformDomainNameResolver.h index 249f2e3..e681331 100644 --- a/Swiften/Network/PlatformDomainNameResolver.h +++ b/Swiften/Network/PlatformDomainNameResolver.h @@ -17,7 +17,7 @@ #include <Swiften/Network/DomainNameAddressQuery.h> namespace Swift { - class String; + class EventLoop; class PlatformDomainNameResolver : public DomainNameResolver { @@ -25,8 +25,8 @@ namespace Swift { PlatformDomainNameResolver(EventLoop* eventLoop); ~PlatformDomainNameResolver(); - virtual DomainNameServiceQuery::ref createServiceQuery(const String& name); - virtual DomainNameAddressQuery::ref createAddressQuery(const String& name); + virtual DomainNameServiceQuery::ref createServiceQuery(const std::string& name); + virtual DomainNameAddressQuery::ref createAddressQuery(const std::string& name); private: void run(); diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.cpp b/Swiften/Network/PlatformDomainNameServiceQuery.cpp index 838b3cf..d3b3561 100644 --- a/Swiften/Network/PlatformDomainNameServiceQuery.cpp +++ b/Swiften/Network/PlatformDomainNameServiceQuery.cpp @@ -36,7 +36,7 @@ using namespace Swift; namespace Swift { -PlatformDomainNameServiceQuery::PlatformDomainNameServiceQuery(const String& service, EventLoop* eventLoop, PlatformDomainNameResolver* resolver) : PlatformDomainNameQuery(resolver), eventLoop(eventLoop), service(service) { +PlatformDomainNameServiceQuery::PlatformDomainNameServiceQuery(const std::string& service, EventLoop* eventLoop, PlatformDomainNameResolver* resolver) : PlatformDomainNameQuery(resolver), eventLoop(eventLoop), service(service) { } void PlatformDomainNameServiceQuery::run() { @@ -51,7 +51,7 @@ void PlatformDomainNameServiceQuery::runBlocking() { #if defined(SWIFTEN_PLATFORM_WINDOWS) DNS_RECORD* responses; // FIXME: This conversion doesn't work if unicode is deffed above - if (DnsQuery(service.getUTF8Data(), DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &responses, NULL) != ERROR_SUCCESS) { + if (DnsQuery(service.c_str(), DNS_TYPE_SRV, DNS_QUERY_STANDARD, NULL, &responses, NULL) != ERROR_SUCCESS) { emitError(); return; } @@ -68,7 +68,7 @@ void PlatformDomainNameServiceQuery::runBlocking() { // conversion to not work at all, but it does. // Actually, it doesn't. Fix this and remove explicit cast // Remove unicode undef above as well - record.hostname = String((const char*) currentEntry->Data.SRV.pNameTarget); + record.hostname = std::string((const char*) currentEntry->Data.SRV.pNameTarget); records.push_back(record); } currentEntry = currentEntry->pNext; @@ -81,7 +81,7 @@ void PlatformDomainNameServiceQuery::runBlocking() { ByteArray response; response.resize(NS_PACKETSZ); - int responseLength = res_query(const_cast<char*>(service.getUTF8Data()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(response.getData()), response.getSize()); + int responseLength = res_query(const_cast<char*>(service.c_str()), ns_c_in, ns_t_srv, reinterpret_cast<u_char*>(response.getData()), response.getSize()); if (responseLength == -1) { SWIFT_LOG(debug) << "Error" << std::endl; emitError(); @@ -151,7 +151,7 @@ void PlatformDomainNameServiceQuery::runBlocking() { emitError(); return; } - record.hostname = String(entry.getData()); + record.hostname = std::string(entry.getData()); records.push_back(record); currentEntry += entryLength; answersCount--; diff --git a/Swiften/Network/PlatformDomainNameServiceQuery.h b/Swiften/Network/PlatformDomainNameServiceQuery.h index c9dbd65..52f8bc1 100644 --- a/Swiften/Network/PlatformDomainNameServiceQuery.h +++ b/Swiften/Network/PlatformDomainNameServiceQuery.h @@ -10,7 +10,7 @@ #include "Swiften/Network/DomainNameServiceQuery.h" #include "Swiften/EventLoop/EventOwner.h" -#include "Swiften/Base/String.h" +#include <string> #include <Swiften/Network/PlatformDomainNameQuery.h> namespace Swift { @@ -18,7 +18,7 @@ namespace Swift { class PlatformDomainNameServiceQuery : public DomainNameServiceQuery, public PlatformDomainNameQuery, public boost::enable_shared_from_this<PlatformDomainNameServiceQuery>, public EventOwner { public: - PlatformDomainNameServiceQuery(const String& service, EventLoop* eventLoop, PlatformDomainNameResolver* resolver); + PlatformDomainNameServiceQuery(const std::string& service, EventLoop* eventLoop, PlatformDomainNameResolver* resolver); virtual void run(); @@ -28,6 +28,6 @@ namespace Swift { private: EventLoop* eventLoop; - String service; + std::string service; }; } diff --git a/Swiften/Network/StaticDomainNameResolver.cpp b/Swiften/Network/StaticDomainNameResolver.cpp index ccea2b7..a338272 100644 --- a/Swiften/Network/StaticDomainNameResolver.cpp +++ b/Swiften/Network/StaticDomainNameResolver.cpp @@ -10,13 +10,13 @@ #include <boost/lexical_cast.hpp> #include "Swiften/Network/DomainNameResolveError.h" -#include "Swiften/Base/String.h" +#include <string> using namespace Swift; namespace { struct ServiceQuery : public DomainNameServiceQuery, public boost::enable_shared_from_this<ServiceQuery> { - ServiceQuery(const String& service, Swift::StaticDomainNameResolver* resolver, EventLoop* eventLoop) : eventLoop(eventLoop), service(service), resolver(resolver) {} + ServiceQuery(const std::string& service, Swift::StaticDomainNameResolver* resolver, EventLoop* eventLoop) : eventLoop(eventLoop), service(service), resolver(resolver) {} virtual void run() { if (!resolver->getIsResponsive()) { @@ -36,12 +36,12 @@ namespace { } EventLoop* eventLoop; - String service; + std::string service; StaticDomainNameResolver* resolver; }; struct AddressQuery : public DomainNameAddressQuery, public boost::enable_shared_from_this<AddressQuery> { - AddressQuery(const String& host, StaticDomainNameResolver* resolver, EventLoop* eventLoop) : eventLoop(eventLoop), host(host), resolver(resolver) {} + AddressQuery(const std::string& host, StaticDomainNameResolver* resolver, EventLoop* eventLoop) : eventLoop(eventLoop), host(host), resolver(resolver) {} virtual void run() { if (!resolver->getIsResponsive()) { @@ -62,7 +62,7 @@ namespace { } EventLoop* eventLoop; - String host; + std::string host; StaticDomainNameResolver* resolver; }; } @@ -72,32 +72,32 @@ namespace Swift { StaticDomainNameResolver::StaticDomainNameResolver(EventLoop* eventLoop) : eventLoop(eventLoop), isResponsive(true) { } -void StaticDomainNameResolver::addAddress(const String& domain, const HostAddress& address) { +void StaticDomainNameResolver::addAddress(const std::string& domain, const HostAddress& address) { addresses[domain].push_back(address); } -void StaticDomainNameResolver::addService(const String& service, const DomainNameServiceQuery::Result& result) { +void StaticDomainNameResolver::addService(const std::string& service, const DomainNameServiceQuery::Result& result) { services.push_back(std::make_pair(service, result)); } -void StaticDomainNameResolver::addXMPPClientService(const String& domain, const HostAddressPort& address) { +void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const HostAddressPort& address) { static int hostid = 0; - String hostname(std::string("host-") + boost::lexical_cast<std::string>(hostid)); + std::string hostname(std::string("host-") + boost::lexical_cast<std::string>(hostid)); hostid++; addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, address.getPort(), 0, 0)); addAddress(hostname, address.getAddress()); } -void StaticDomainNameResolver::addXMPPClientService(const String& domain, const String& hostname, int port) { +void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const std::string& hostname, int port) { addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, port, 0, 0)); } -boost::shared_ptr<DomainNameServiceQuery> StaticDomainNameResolver::createServiceQuery(const String& name) { +boost::shared_ptr<DomainNameServiceQuery> StaticDomainNameResolver::createServiceQuery(const std::string& name) { return boost::shared_ptr<DomainNameServiceQuery>(new ServiceQuery(name, this, eventLoop)); } -boost::shared_ptr<DomainNameAddressQuery> StaticDomainNameResolver::createAddressQuery(const String& name) { +boost::shared_ptr<DomainNameAddressQuery> StaticDomainNameResolver::createAddressQuery(const std::string& name) { return boost::shared_ptr<DomainNameAddressQuery>(new AddressQuery(name, this, eventLoop)); } diff --git a/Swiften/Network/StaticDomainNameResolver.h b/Swiften/Network/StaticDomainNameResolver.h index 39b2782..2ef1295 100644 --- a/Swiften/Network/StaticDomainNameResolver.h +++ b/Swiften/Network/StaticDomainNameResolver.h @@ -17,20 +17,20 @@ #include "Swiften/EventLoop/EventLoop.h" namespace Swift { - class String; + class StaticDomainNameResolver : public DomainNameResolver { public: - typedef std::map<String, std::vector<HostAddress> > AddressesMap; - typedef std::vector< std::pair<String, DomainNameServiceQuery::Result> > ServicesCollection; + typedef std::map<std::string, std::vector<HostAddress> > AddressesMap; + typedef std::vector< std::pair<std::string, DomainNameServiceQuery::Result> > ServicesCollection; public: StaticDomainNameResolver(EventLoop* eventLoop); - void addAddress(const String& domain, const HostAddress& address); - void addService(const String& service, const DomainNameServiceQuery::Result& result); - void addXMPPClientService(const String& domain, const HostAddressPort&); - void addXMPPClientService(const String& domain, const String& host, int port); + void addAddress(const std::string& domain, const HostAddress& address); + void addService(const std::string& service, const DomainNameServiceQuery::Result& result); + void addXMPPClientService(const std::string& domain, const HostAddressPort&); + void addXMPPClientService(const std::string& domain, const std::string& host, int port); const AddressesMap& getAddresses() const { return addresses; @@ -48,8 +48,8 @@ namespace Swift { isResponsive = b; } - virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const String& name); - virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const String& name); + virtual boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& name); + virtual boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const std::string& name); private: EventLoop* eventLoop; diff --git a/Swiften/Network/UnitTest/HostAddressTest.cpp b/Swiften/Network/UnitTest/HostAddressTest.cpp index 45793fa..7fb33ca 100644 --- a/Swiften/Network/UnitTest/HostAddressTest.cpp +++ b/Swiften/Network/UnitTest/HostAddressTest.cpp @@ -8,7 +8,7 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include "Swiften/Network/HostAddress.h" -#include "Swiften/Base/String.h" +#include <string> using namespace Swift; diff --git a/Swiften/Parser/AttributeMap.h b/Swiften/Parser/AttributeMap.h index 5e6512e..c8b287b 100644 --- a/Swiften/Parser/AttributeMap.h +++ b/Swiften/Parser/AttributeMap.h @@ -9,14 +9,14 @@ #include <map> -#include "Swiften/Base/String.h" +#include <string> namespace Swift { - class AttributeMap : public std::map<String,String> { + class AttributeMap : public std::map<std::string,std::string> { public: AttributeMap() {} - String getAttribute(const String& attribute) const { + std::string getAttribute(const std::string& attribute) const { AttributeMap::const_iterator i = find(attribute); if (i == end()) { return ""; @@ -26,7 +26,7 @@ namespace Swift { } } - bool getBoolAttribute(const String& attribute, bool defaultValue = false) const { + bool getBoolAttribute(const std::string& attribute, bool defaultValue = false) const { AttributeMap::const_iterator i = find(attribute); if (i == end()) { return defaultValue; diff --git a/Swiften/Parser/AuthChallengeParser.cpp b/Swiften/Parser/AuthChallengeParser.cpp index 2a4d7dc..1e5e0c4 100644 --- a/Swiften/Parser/AuthChallengeParser.cpp +++ b/Swiften/Parser/AuthChallengeParser.cpp @@ -12,18 +12,18 @@ namespace Swift { AuthChallengeParser::AuthChallengeParser() : GenericElementParser<AuthChallenge>(), depth(0) { } -void AuthChallengeParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void AuthChallengeParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++depth; } -void AuthChallengeParser::handleEndElement(const String&, const String&) { +void AuthChallengeParser::handleEndElement(const std::string&, const std::string&) { --depth; if (depth == 0) { getElementGeneric()->setValue(Base64::decode(text)); } } -void AuthChallengeParser::handleCharacterData(const String& text) { +void AuthChallengeParser::handleCharacterData(const std::string& text) { this->text += text; } diff --git a/Swiften/Parser/AuthChallengeParser.h b/Swiften/Parser/AuthChallengeParser.h index 014d2f9..39f7c57 100644 --- a/Swiften/Parser/AuthChallengeParser.h +++ b/Swiften/Parser/AuthChallengeParser.h @@ -8,19 +8,19 @@ #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/AuthChallenge.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class AuthChallengeParser : public GenericElementParser<AuthChallenge> { public: AuthChallengeParser(); - virtual void handleStartElement(const String&, const String& ns, const AttributeMap&); - virtual void handleEndElement(const String&, const String& ns); - virtual void handleCharacterData(const String&); + virtual void handleStartElement(const std::string&, const std::string& ns, const AttributeMap&); + virtual void handleEndElement(const std::string&, const std::string& ns); + virtual void handleCharacterData(const std::string&); private: int depth; - String text; + std::string text; }; } diff --git a/Swiften/Parser/AuthRequestParser.cpp b/Swiften/Parser/AuthRequestParser.cpp index 5d90826..38af047 100644 --- a/Swiften/Parser/AuthRequestParser.cpp +++ b/Swiften/Parser/AuthRequestParser.cpp @@ -12,21 +12,21 @@ namespace Swift { AuthRequestParser::AuthRequestParser() : GenericElementParser<AuthRequest>(), depth_(0) { } -void AuthRequestParser::handleStartElement(const String&, const String&, const AttributeMap& attribute) { +void AuthRequestParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attribute) { if (depth_ == 0) { getElementGeneric()->setMechanism(attribute.getAttribute("mechanism")); } ++depth_; } -void AuthRequestParser::handleEndElement(const String&, const String&) { +void AuthRequestParser::handleEndElement(const std::string&, const std::string&) { --depth_; if (depth_ == 0) { getElementGeneric()->setMessage(Base64::decode(text_)); } } -void AuthRequestParser::handleCharacterData(const String& text) { +void AuthRequestParser::handleCharacterData(const std::string& text) { text_ += text; } diff --git a/Swiften/Parser/AuthRequestParser.h b/Swiften/Parser/AuthRequestParser.h index 59fe3ec..5cc3694 100644 --- a/Swiften/Parser/AuthRequestParser.h +++ b/Swiften/Parser/AuthRequestParser.h @@ -9,19 +9,19 @@ #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/AuthRequest.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class AuthRequestParser : public GenericElementParser<AuthRequest> { public: AuthRequestParser(); - virtual void handleStartElement(const String&, const String& ns, const AttributeMap&); - virtual void handleEndElement(const String&, const String& ns); - virtual void handleCharacterData(const String&); + virtual void handleStartElement(const std::string&, const std::string& ns, const AttributeMap&); + virtual void handleEndElement(const std::string&, const std::string& ns); + virtual void handleCharacterData(const std::string&); private: - String text_; + std::string text_; int depth_; }; } diff --git a/Swiften/Parser/AuthResponseParser.cpp b/Swiften/Parser/AuthResponseParser.cpp index 2a772db..0db6a2a 100644 --- a/Swiften/Parser/AuthResponseParser.cpp +++ b/Swiften/Parser/AuthResponseParser.cpp @@ -12,18 +12,18 @@ namespace Swift { AuthResponseParser::AuthResponseParser() : GenericElementParser<AuthResponse>(), depth(0) { } -void AuthResponseParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void AuthResponseParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++depth; } -void AuthResponseParser::handleEndElement(const String&, const String&) { +void AuthResponseParser::handleEndElement(const std::string&, const std::string&) { --depth; if (depth == 0) { getElementGeneric()->setValue(Base64::decode(text)); } } -void AuthResponseParser::handleCharacterData(const String& text) { +void AuthResponseParser::handleCharacterData(const std::string& text) { this->text += text; } diff --git a/Swiften/Parser/AuthResponseParser.h b/Swiften/Parser/AuthResponseParser.h index 045d4f9..aee2f9c 100644 --- a/Swiften/Parser/AuthResponseParser.h +++ b/Swiften/Parser/AuthResponseParser.h @@ -8,19 +8,19 @@ #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/AuthResponse.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class AuthResponseParser : public GenericElementParser<AuthResponse> { public: AuthResponseParser(); - virtual void handleStartElement(const String&, const String& ns, const AttributeMap&); - virtual void handleEndElement(const String&, const String& ns); - virtual void handleCharacterData(const String&); + virtual void handleStartElement(const std::string&, const std::string& ns, const AttributeMap&); + virtual void handleEndElement(const std::string&, const std::string& ns); + virtual void handleCharacterData(const std::string&); private: int depth; - String text; + std::string text; }; } diff --git a/Swiften/Parser/AuthSuccessParser.cpp b/Swiften/Parser/AuthSuccessParser.cpp index 98855b5..0dee6ad 100644 --- a/Swiften/Parser/AuthSuccessParser.cpp +++ b/Swiften/Parser/AuthSuccessParser.cpp @@ -12,18 +12,18 @@ namespace Swift { AuthSuccessParser::AuthSuccessParser() : GenericElementParser<AuthSuccess>(), depth(0) { } -void AuthSuccessParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void AuthSuccessParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++depth; } -void AuthSuccessParser::handleEndElement(const String&, const String&) { +void AuthSuccessParser::handleEndElement(const std::string&, const std::string&) { --depth; if (depth == 0) { getElementGeneric()->setValue(Base64::decode(text)); } } -void AuthSuccessParser::handleCharacterData(const String& text) { +void AuthSuccessParser::handleCharacterData(const std::string& text) { this->text += text; } diff --git a/Swiften/Parser/AuthSuccessParser.h b/Swiften/Parser/AuthSuccessParser.h index 5aef18f..30c89d2 100644 --- a/Swiften/Parser/AuthSuccessParser.h +++ b/Swiften/Parser/AuthSuccessParser.h @@ -8,19 +8,19 @@ #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/AuthSuccess.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class AuthSuccessParser : public GenericElementParser<AuthSuccess> { public: AuthSuccessParser(); - virtual void handleStartElement(const String&, const String& ns, const AttributeMap&); - virtual void handleEndElement(const String&, const String& ns); - virtual void handleCharacterData(const String&); + virtual void handleStartElement(const std::string&, const std::string& ns, const AttributeMap&); + virtual void handleEndElement(const std::string&, const std::string& ns); + virtual void handleCharacterData(const std::string&); private: int depth; - String text; + std::string text; }; } diff --git a/Swiften/Parser/ComponentHandshakeParser.cpp b/Swiften/Parser/ComponentHandshakeParser.cpp index e88adb3..4117a56 100644 --- a/Swiften/Parser/ComponentHandshakeParser.cpp +++ b/Swiften/Parser/ComponentHandshakeParser.cpp @@ -12,18 +12,18 @@ namespace Swift { ComponentHandshakeParser::ComponentHandshakeParser() : GenericElementParser<ComponentHandshake>(), depth(0) { } -void ComponentHandshakeParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void ComponentHandshakeParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++depth; } -void ComponentHandshakeParser::handleEndElement(const String&, const String&) { +void ComponentHandshakeParser::handleEndElement(const std::string&, const std::string&) { --depth; if (depth == 0) { getElementGeneric()->setData(text); } } -void ComponentHandshakeParser::handleCharacterData(const String& text) { +void ComponentHandshakeParser::handleCharacterData(const std::string& text) { this->text += text; } diff --git a/Swiften/Parser/ComponentHandshakeParser.h b/Swiften/Parser/ComponentHandshakeParser.h index de5b8e1..389bb6d 100644 --- a/Swiften/Parser/ComponentHandshakeParser.h +++ b/Swiften/Parser/ComponentHandshakeParser.h @@ -8,19 +8,19 @@ #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/ComponentHandshake.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class ComponentHandshakeParser : public GenericElementParser<ComponentHandshake> { public: ComponentHandshakeParser(); - virtual void handleStartElement(const String&, const String& ns, const AttributeMap&); - virtual void handleEndElement(const String&, const String& ns); - virtual void handleCharacterData(const String&); + virtual void handleStartElement(const std::string&, const std::string& ns, const AttributeMap&); + virtual void handleEndElement(const std::string&, const std::string& ns); + virtual void handleCharacterData(const std::string&); private: int depth; - String text; + std::string text; }; } diff --git a/Swiften/Parser/CompressParser.cpp b/Swiften/Parser/CompressParser.cpp index 58ec091..5ce5204 100644 --- a/Swiften/Parser/CompressParser.cpp +++ b/Swiften/Parser/CompressParser.cpp @@ -11,7 +11,7 @@ namespace Swift { CompressParser::CompressParser() : GenericElementParser<CompressRequest>(), currentDepth_(0), inMethod_(false) { } -void CompressParser::handleStartElement(const String& element, const String&, const AttributeMap&) { +void CompressParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap&) { if (currentDepth_ == 1 && element == "method") { inMethod_ = true; currentText_ = ""; @@ -19,7 +19,7 @@ void CompressParser::handleStartElement(const String& element, const String&, co ++currentDepth_; } -void CompressParser::handleEndElement(const String&, const String&) { +void CompressParser::handleEndElement(const std::string&, const std::string&) { --currentDepth_; if (currentDepth_ == 1 && inMethod_) { getElementGeneric()->setMethod(currentText_); @@ -27,7 +27,7 @@ void CompressParser::handleEndElement(const String&, const String&) { } } -void CompressParser::handleCharacterData(const String& data) { +void CompressParser::handleCharacterData(const std::string& data) { currentText_ += data; } diff --git a/Swiften/Parser/CompressParser.h b/Swiften/Parser/CompressParser.h index 56b7e4b..54257b6 100644 --- a/Swiften/Parser/CompressParser.h +++ b/Swiften/Parser/CompressParser.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_CompressParser_H #define SWIFTEN_CompressParser_H -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/CompressRequest.h" @@ -17,13 +17,13 @@ namespace Swift { CompressParser(); private: - void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes); - void handleEndElement(const String& element, const String& ns); - void handleCharacterData(const String& data); + void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes); + void handleEndElement(const std::string& element, const std::string& ns); + void handleCharacterData(const std::string& data); private: int currentDepth_; - String currentText_; + std::string currentText_; bool inMethod_; }; } diff --git a/Swiften/Parser/ElementParser.h b/Swiften/Parser/ElementParser.h index 3224a91..60f2395 100644 --- a/Swiften/Parser/ElementParser.h +++ b/Swiften/Parser/ElementParser.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Element.h" #include "Swiften/Parser/AttributeMap.h" @@ -18,9 +18,9 @@ namespace Swift { public: virtual ~ElementParser(); - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) = 0; - virtual void handleEndElement(const String& element, const String& ns) = 0; - virtual void handleCharacterData(const String& data) = 0; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) = 0; + virtual void handleEndElement(const std::string& element, const std::string& ns) = 0; + virtual void handleCharacterData(const std::string& data) = 0; virtual boost::shared_ptr<Element> getElement() const = 0; }; diff --git a/Swiften/Parser/ExpatParser.cpp b/Swiften/Parser/ExpatParser.cpp index 00dbc9d..c972ef7 100644 --- a/Swiften/Parser/ExpatParser.cpp +++ b/Swiften/Parser/ExpatParser.cpp @@ -8,7 +8,7 @@ #include <iostream> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/XMLParserClient.h" namespace Swift { @@ -16,7 +16,7 @@ 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); + std::pair<std::string,std::string> nsTagPair = std::string(name).getSplittedAtFirst(NAMESPACE_SEPARATOR); if (nsTagPair.second == "") { nsTagPair.second = nsTagPair.first; nsTagPair.first = ""; @@ -24,12 +24,12 @@ static void handleStartElement(void* client, const XML_Char* name, const XML_Cha AttributeMap attributeValues; const XML_Char** currentAttribute = attributes; while (*currentAttribute) { - std::pair<String,String> nsAttributePair = String(*currentAttribute).getSplittedAtFirst(NAMESPACE_SEPARATOR); + std::pair<std::string,std::string> nsAttributePair = std::string(*currentAttribute).getSplittedAtFirst(NAMESPACE_SEPARATOR); if (nsAttributePair.second == "") { nsAttributePair.second = nsAttributePair.first; nsAttributePair.first = ""; } - attributeValues[nsAttributePair.second] = String(*(currentAttribute+1)); + attributeValues[nsAttributePair.second] = std::string(*(currentAttribute+1)); currentAttribute += 2; } @@ -37,7 +37,7 @@ static void handleStartElement(void* client, const XML_Char* name, const XML_Cha } static void handleEndElement(void* client, const XML_Char* name) { - std::pair<String,String> nsTagPair = String(name).getSplittedAtFirst(NAMESPACE_SEPARATOR); + std::pair<std::string,std::string> nsTagPair = std::string(name).getSplittedAtFirst(NAMESPACE_SEPARATOR); if (nsTagPair.second == "") { nsTagPair.second = nsTagPair.first; nsTagPair.first = ""; @@ -46,7 +46,7 @@ static void handleEndElement(void* client, const XML_Char* name) { } static void handleCharacterData(void* client, const XML_Char* data, int len) { - static_cast<XMLParserClient*>(client)->handleCharacterData(String(data, len)); + static_cast<XMLParserClient*>(client)->handleCharacterData(std::string(data, len)); } static void handleXMLDeclaration(void*, const XML_Char*, const XML_Char*, int) { @@ -65,8 +65,8 @@ ExpatParser::~ExpatParser() { XML_ParserFree(parser_); } -bool ExpatParser::parse(const String& data) { - bool success = XML_Parse(parser_, data.getUTF8Data(), data.getUTF8Size(), false) == XML_STATUS_OK; +bool ExpatParser::parse(const std::string& data) { + bool success = XML_Parse(parser_, data.c_str(), data.size(), false) == XML_STATUS_OK; /*if (!success) { std::cout << "ERROR: " << XML_ErrorString(XML_GetErrorCode(parser_)) << " while parsing " << data << std::endl; }*/ diff --git a/Swiften/Parser/ExpatParser.h b/Swiften/Parser/ExpatParser.h index e23df11..f6faf17 100644 --- a/Swiften/Parser/ExpatParser.h +++ b/Swiften/Parser/ExpatParser.h @@ -18,7 +18,7 @@ namespace Swift { ExpatParser(XMLParserClient* client); ~ExpatParser(); - bool parse(const String& data); + bool parse(const std::string& data); private: XML_Parser parser_; diff --git a/Swiften/Parser/GenericElementParser.h b/Swiften/Parser/GenericElementParser.h index a0795f0..224c59e 100644 --- a/Swiften/Parser/GenericElementParser.h +++ b/Swiften/Parser/GenericElementParser.h @@ -12,7 +12,7 @@ #include <Swiften/Parser/ElementParser.h> namespace Swift { - class String; + class PayloadParserFactoryCollection; template<typename ElementType> @@ -31,13 +31,13 @@ namespace Swift { } private: - virtual void handleStartElement(const String&, const String&, const AttributeMap&) { + virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) { } - virtual void handleEndElement(const String&, const String&) { + virtual void handleEndElement(const std::string&, const std::string&) { } - virtual void handleCharacterData(const String&) { + virtual void handleCharacterData(const std::string&) { } private: diff --git a/Swiften/Parser/GenericPayloadParser.h b/Swiften/Parser/GenericPayloadParser.h index 3514541..572901b 100644 --- a/Swiften/Parser/GenericPayloadParser.h +++ b/Swiften/Parser/GenericPayloadParser.h @@ -12,7 +12,7 @@ #include <Swiften/Parser/PayloadParser.h> namespace Swift { - class String; + class FormParser; /** diff --git a/Swiften/Parser/GenericPayloadParserFactory.h b/Swiften/Parser/GenericPayloadParserFactory.h index a636dd7..9b108a0 100644 --- a/Swiften/Parser/GenericPayloadParserFactory.h +++ b/Swiften/Parser/GenericPayloadParserFactory.h @@ -7,7 +7,7 @@ #pragma once #include "Swiften/Parser/PayloadParserFactory.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { @@ -20,10 +20,10 @@ namespace Swift { /** * Construct a parser factory that can parse the given top-level tag in the given namespace. */ - GenericPayloadParserFactory(const String& tag, const String& xmlns = "") : tag_(tag), xmlns_(xmlns) {} + GenericPayloadParserFactory(const std::string& tag, const std::string& xmlns = "") : tag_(tag), xmlns_(xmlns) {} - virtual bool canParse(const String& element, const String& ns, const AttributeMap&) const { - return (tag_.isEmpty() ? true : element == tag_) && (xmlns_.isEmpty() ? true : xmlns_ == ns); + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const { + return (tag_.empty() ? true : element == tag_) && (xmlns_.empty() ? true : xmlns_ == ns); } virtual PayloadParser* createPayloadParser() { @@ -31,7 +31,7 @@ namespace Swift { } private: - String tag_; - String xmlns_; + std::string tag_; + std::string xmlns_; }; } diff --git a/Swiften/Parser/GenericStanzaParser.h b/Swiften/Parser/GenericStanzaParser.h index 9c274f5..c756c9a 100644 --- a/Swiften/Parser/GenericStanzaParser.h +++ b/Swiften/Parser/GenericStanzaParser.h @@ -12,7 +12,7 @@ #include <Swiften/Parser/StanzaParser.h> namespace Swift { - class String; + class PayloadParserFactoryCollection; template<typename STANZA_TYPE> diff --git a/Swiften/Parser/LibXMLParser.cpp b/Swiften/Parser/LibXMLParser.cpp index 7fe13fe..34db4ca 100644 --- a/Swiften/Parser/LibXMLParser.cpp +++ b/Swiften/Parser/LibXMLParser.cpp @@ -10,7 +10,7 @@ #include <cassert> #include <cstring> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/XMLParserClient.h" namespace Swift { @@ -18,17 +18,17 @@ namespace Swift { static void handleStartElement(void *client, const xmlChar* name, const xmlChar*, const xmlChar* xmlns, int, const xmlChar**, int nbAttributes, int, const xmlChar ** attributes) { AttributeMap attributeValues; for (int i = 0; i < nbAttributes*5; i += 5) { - attributeValues[String(reinterpret_cast<const char*>(attributes[i]))] = String(reinterpret_cast<const char*>(attributes[i+3]), attributes[i+4]-attributes[i+3]); + attributeValues[std::string(reinterpret_cast<const char*>(attributes[i]))] = std::string(reinterpret_cast<const char*>(attributes[i+3]), attributes[i+4]-attributes[i+3]); } - static_cast<XMLParserClient*>(client)->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : String()), attributeValues); + static_cast<XMLParserClient*>(client)->handleStartElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string()), attributeValues); } static void handleEndElement(void *client, const xmlChar* name, const xmlChar*, const xmlChar* xmlns) { - static_cast<XMLParserClient*>(client)->handleEndElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : String())); + static_cast<XMLParserClient*>(client)->handleEndElement(reinterpret_cast<const char*>(name), (xmlns ? reinterpret_cast<const char*>(xmlns) : std::string())); } static void handleCharacterData(void* client, const xmlChar* data, int len) { - static_cast<XMLParserClient*>(client)->handleCharacterData(String(reinterpret_cast<const char*>(data), len)); + static_cast<XMLParserClient*>(client)->handleCharacterData(std::string(reinterpret_cast<const char*>(data), len)); } static void handleError(void*, const char* /*m*/, ... ) { @@ -64,8 +64,8 @@ LibXMLParser::~LibXMLParser() { } } -bool LibXMLParser::parse(const String& data) { - if (xmlParseChunk(context_, data.getUTF8Data(), data.getUTF8Size(), false) == XML_ERR_OK) { +bool LibXMLParser::parse(const std::string& data) { + if (xmlParseChunk(context_, data.c_str(), data.size(), false) == XML_ERR_OK) { return true; } xmlError* error = xmlCtxtGetLastError(context_); diff --git a/Swiften/Parser/LibXMLParser.h b/Swiften/Parser/LibXMLParser.h index 10fbe4e..d0dac8b 100644 --- a/Swiften/Parser/LibXMLParser.h +++ b/Swiften/Parser/LibXMLParser.h @@ -17,7 +17,7 @@ namespace Swift { LibXMLParser(XMLParserClient* client); ~LibXMLParser(); - bool parse(const String& data); + bool parse(const std::string& data); private: xmlSAXHandler handler_; diff --git a/Swiften/Parser/PayloadParser.h b/Swiften/Parser/PayloadParser.h index a5a9025..423a2bb 100644 --- a/Swiften/Parser/PayloadParser.h +++ b/Swiften/Parser/PayloadParser.h @@ -12,7 +12,7 @@ #include "Swiften/Elements/Payload.h" namespace Swift { - class String; + /** * A parser for XMPP stanza payloads. @@ -29,17 +29,17 @@ namespace Swift { /** * Handle the start of an XML element. */ - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) = 0; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) = 0; /** * Handle the end of an XML element. */ - virtual void handleEndElement(const String& element, const String& ns) = 0; + virtual void handleEndElement(const std::string& element, const std::string& ns) = 0; /** * Handle character data. */ - virtual void handleCharacterData(const String& data) = 0; + virtual void handleCharacterData(const std::string& data) = 0; /** * Retrieve a pointer to the payload. diff --git a/Swiften/Parser/PayloadParserFactory.h b/Swiften/Parser/PayloadParserFactory.h index 3d647c6..2baa2ad 100644 --- a/Swiften/Parser/PayloadParserFactory.h +++ b/Swiften/Parser/PayloadParserFactory.h @@ -9,7 +9,7 @@ #include "Swiften/Parser/AttributeMap.h" namespace Swift { - class String; + class PayloadParser; /** @@ -22,7 +22,7 @@ namespace Swift { /** * Checks whether this factory can parse the given top-level element in the given namespace (with the given attributes). */ - virtual bool canParse(const String& element, const String& ns, const AttributeMap& attributes) const = 0; + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap& attributes) const = 0; /** * Creates a new payload parser. diff --git a/Swiften/Parser/PayloadParserFactoryCollection.cpp b/Swiften/Parser/PayloadParserFactoryCollection.cpp index 2e41a5f..0080fbe 100644 --- a/Swiften/Parser/PayloadParserFactoryCollection.cpp +++ b/Swiften/Parser/PayloadParserFactoryCollection.cpp @@ -27,7 +27,7 @@ void PayloadParserFactoryCollection::setDefaultFactory(PayloadParserFactory* fac defaultFactory_ = factory; } -PayloadParserFactory* PayloadParserFactoryCollection::getPayloadParserFactory(const String& element, const String& ns, const AttributeMap& attributes) { +PayloadParserFactory* PayloadParserFactoryCollection::getPayloadParserFactory(const std::string& element, const std::string& ns, const AttributeMap& attributes) { std::vector<PayloadParserFactory*>::reverse_iterator i = std::find_if( factories_.rbegin(), factories_.rend(), boost::bind(&PayloadParserFactory::canParse, _1, element, ns, attributes)); diff --git a/Swiften/Parser/PayloadParserFactoryCollection.h b/Swiften/Parser/PayloadParserFactoryCollection.h index fcfb047..9afb9b7 100644 --- a/Swiften/Parser/PayloadParserFactoryCollection.h +++ b/Swiften/Parser/PayloadParserFactoryCollection.h @@ -13,7 +13,7 @@ namespace Swift { class PayloadParserFactory; - class String; + class PayloadParserFactoryCollection { public: @@ -23,7 +23,7 @@ namespace Swift { void removeFactory(PayloadParserFactory* factory); void setDefaultFactory(PayloadParserFactory* factory); - PayloadParserFactory* getPayloadParserFactory(const String& element, const String& ns, const AttributeMap& attributes); + PayloadParserFactory* getPayloadParserFactory(const std::string& element, const std::string& ns, const AttributeMap& attributes); private: std::vector<PayloadParserFactory*> factories_; diff --git a/Swiften/Parser/PayloadParsers/BodyParser.cpp b/Swiften/Parser/PayloadParsers/BodyParser.cpp index 3f76101..d0f4e09 100644 --- a/Swiften/Parser/PayloadParsers/BodyParser.cpp +++ b/Swiften/Parser/PayloadParsers/BodyParser.cpp @@ -11,18 +11,18 @@ namespace Swift { BodyParser::BodyParser() : level_(0) { } -void BodyParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void BodyParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level_; } -void BodyParser::handleEndElement(const String&, const String&) { +void BodyParser::handleEndElement(const std::string&, const std::string&) { --level_; if (level_ == 0) { getPayloadInternal()->setText(text_); } } -void BodyParser::handleCharacterData(const String& data) { +void BodyParser::handleCharacterData(const std::string& data) { text_ += data; } diff --git a/Swiften/Parser/PayloadParsers/BodyParser.h b/Swiften/Parser/PayloadParsers/BodyParser.h index 4318614..f9e17e0 100644 --- a/Swiften/Parser/PayloadParsers/BodyParser.h +++ b/Swiften/Parser/PayloadParsers/BodyParser.h @@ -15,13 +15,13 @@ namespace Swift { public: BodyParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; - String text_; + std::string text_; }; } diff --git a/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp b/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp index 154a925..35db9ec 100644 --- a/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp +++ b/Swiften/Parser/PayloadParsers/BytestreamsParser.cpp @@ -18,7 +18,7 @@ BytestreamsParser::BytestreamsParser() : level(TopLevel) { BytestreamsParser::~BytestreamsParser() { } -void BytestreamsParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) { +void BytestreamsParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level == TopLevel) { getPayloadInternal()->setStreamID(attributes.getAttribute("sid")); } @@ -37,11 +37,11 @@ void BytestreamsParser::handleStartElement(const String& element, const String&, ++level; } -void BytestreamsParser::handleEndElement(const String&, const String&) { +void BytestreamsParser::handleEndElement(const std::string&, const std::string&) { --level; } -void BytestreamsParser::handleCharacterData(const String&) { +void BytestreamsParser::handleCharacterData(const std::string&) { } diff --git a/Swiften/Parser/PayloadParsers/BytestreamsParser.h b/Swiften/Parser/PayloadParsers/BytestreamsParser.h index a45baa4..2d67785 100644 --- a/Swiften/Parser/PayloadParsers/BytestreamsParser.h +++ b/Swiften/Parser/PayloadParsers/BytestreamsParser.h @@ -17,9 +17,9 @@ namespace Swift { BytestreamsParser(); ~BytestreamsParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { diff --git a/Swiften/Parser/PayloadParsers/CapsInfoParser.cpp b/Swiften/Parser/PayloadParsers/CapsInfoParser.cpp index 6ccccd4..d7d9324 100644 --- a/Swiften/Parser/PayloadParsers/CapsInfoParser.cpp +++ b/Swiften/Parser/PayloadParsers/CapsInfoParser.cpp @@ -13,7 +13,7 @@ namespace Swift { CapsInfoParser::CapsInfoParser() : level(0) { } -void CapsInfoParser::handleStartElement(const String&, const String& /*ns*/, const AttributeMap& attributes) { +void CapsInfoParser::handleStartElement(const std::string&, const std::string& /*ns*/, const AttributeMap& attributes) { if (level == 0) { getPayloadInternal()->setHash(attributes.getAttribute("hash")); getPayloadInternal()->setNode(attributes.getAttribute("node")); @@ -22,11 +22,11 @@ void CapsInfoParser::handleStartElement(const String&, const String& /*ns*/, con ++level; } -void CapsInfoParser::handleEndElement(const String&, const String&) { +void CapsInfoParser::handleEndElement(const std::string&, const std::string&) { --level; } -void CapsInfoParser::handleCharacterData(const String&) { +void CapsInfoParser::handleCharacterData(const std::string&) { } diff --git a/Swiften/Parser/PayloadParsers/CapsInfoParser.h b/Swiften/Parser/PayloadParsers/CapsInfoParser.h index 6058837..590326d 100644 --- a/Swiften/Parser/PayloadParsers/CapsInfoParser.h +++ b/Swiften/Parser/PayloadParsers/CapsInfoParser.h @@ -14,9 +14,9 @@ namespace Swift { public: CapsInfoParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level; diff --git a/Swiften/Parser/PayloadParsers/ChatStateParser.cpp b/Swiften/Parser/PayloadParsers/ChatStateParser.cpp index db205dd..3a5ba3b 100644 --- a/Swiften/Parser/PayloadParsers/ChatStateParser.cpp +++ b/Swiften/Parser/PayloadParsers/ChatStateParser.cpp @@ -11,7 +11,7 @@ namespace Swift { ChatStateParser::ChatStateParser() : level_(0) { } -void ChatStateParser::handleStartElement(const String& element, const String&, const AttributeMap&) { +void ChatStateParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap&) { if (level_ == 0) { ChatState::ChatStateType state = ChatState::Active; if (element == "active") { @@ -30,11 +30,11 @@ void ChatStateParser::handleStartElement(const String& element, const String&, c ++level_; } -void ChatStateParser::handleEndElement(const String&, const String&) { +void ChatStateParser::handleEndElement(const std::string&, const std::string&) { --level_; } -void ChatStateParser::handleCharacterData(const String&) { +void ChatStateParser::handleCharacterData(const std::string&) { } diff --git a/Swiften/Parser/PayloadParsers/ChatStateParser.h b/Swiften/Parser/PayloadParsers/ChatStateParser.h index 2ae4e43..8d0e7f5 100644 --- a/Swiften/Parser/PayloadParsers/ChatStateParser.h +++ b/Swiften/Parser/PayloadParsers/ChatStateParser.h @@ -14,9 +14,9 @@ namespace Swift { public: ChatStateParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; diff --git a/Swiften/Parser/PayloadParsers/ChatStateParserFactory.h b/Swiften/Parser/PayloadParsers/ChatStateParserFactory.h index 27d3c51..3dadda7 100644 --- a/Swiften/Parser/PayloadParsers/ChatStateParserFactory.h +++ b/Swiften/Parser/PayloadParsers/ChatStateParserFactory.h @@ -17,7 +17,7 @@ namespace Swift { ChatStateParserFactory() { } - virtual bool canParse(const String& element, const String& ns, const AttributeMap&) const { + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const { return ns == "http://jabber.org/protocol/chatstates" && (element == "active" || element == "composing" || element == "paused" || element == "inactive" || element == "gone"); diff --git a/Swiften/Parser/PayloadParsers/CommandParser.cpp b/Swiften/Parser/PayloadParsers/CommandParser.cpp index 76e4564..9422170 100644 --- a/Swiften/Parser/PayloadParsers/CommandParser.cpp +++ b/Swiften/Parser/PayloadParsers/CommandParser.cpp @@ -18,7 +18,7 @@ CommandParser::~CommandParser() { delete formParserFactory_; } -void CommandParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void CommandParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { ++level_; if (level_ == PayloadLevel) { boost::optional<Command::Action> action = parseAction(attributes.getAttribute("action")); @@ -26,7 +26,7 @@ void CommandParser::handleStartElement(const String& element, const String& ns, getPayloadInternal()->setAction(*action); } - String status = attributes.getAttribute("status"); + std::string status = attributes.getAttribute("status"); if (status == "executing") { getPayloadInternal()->setStatus(Command::Executing); } @@ -49,7 +49,7 @@ void CommandParser::handleStartElement(const String& element, const String& ns, else if (element == "note") { inNote_ = true; currentText_.clear(); - String noteType = attributes.getAttribute("type"); + std::string noteType = attributes.getAttribute("type"); if (noteType == "info") { noteType_ = Command::Note::Info; } @@ -79,7 +79,7 @@ void CommandParser::handleStartElement(const String& element, const String& ns, } } -void CommandParser::handleEndElement(const String& element, const String& ns) { +void CommandParser::handleEndElement(const std::string& element, const std::string& ns) { if (formParser_) { formParser_->handleEndElement(element, ns); } @@ -109,7 +109,7 @@ void CommandParser::handleEndElement(const String& element, const String& ns) { --level_; } -void CommandParser::handleCharacterData(const String& data) { +void CommandParser::handleCharacterData(const std::string& data) { if (formParser_) { formParser_->handleCharacterData(data); } @@ -118,7 +118,7 @@ void CommandParser::handleCharacterData(const String& data) { } } -boost::optional<Command::Action> CommandParser::parseAction(const String& action) { +boost::optional<Command::Action> CommandParser::parseAction(const std::string& action) { if (action == "execute") { return Command::Execute; } diff --git a/Swiften/Parser/PayloadParsers/CommandParser.h b/Swiften/Parser/PayloadParsers/CommandParser.h index a682a80..0415ba6 100644 --- a/Swiften/Parser/PayloadParsers/CommandParser.h +++ b/Swiften/Parser/PayloadParsers/CommandParser.h @@ -20,12 +20,12 @@ namespace Swift { CommandParser(); ~CommandParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: - static boost::optional<Command::Action> parseAction(const String& action); + static boost::optional<Command::Action> parseAction(const std::string& action); private: enum Level { @@ -40,6 +40,6 @@ namespace Swift { Command::Note::Type noteType_; FormParserFactory* formParserFactory_; FormParser* formParser_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/PayloadParsers/CommandParserFactory.h b/Swiften/Parser/PayloadParsers/CommandParserFactory.h index da2f484..9eaaf62 100644 --- a/Swiften/Parser/PayloadParsers/CommandParserFactory.h +++ b/Swiften/Parser/PayloadParsers/CommandParserFactory.h @@ -17,7 +17,7 @@ namespace Swift { CommandParserFactory() { } - virtual bool canParse(const String& element, const String& ns, const AttributeMap&) const { + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const { return ns == "http://jabber.org/protocol/commands" && element == "command"; } diff --git a/Swiften/Parser/PayloadParsers/DelayParser.cpp b/Swiften/Parser/PayloadParsers/DelayParser.cpp index 8e8abff..3425b84 100644 --- a/Swiften/Parser/PayloadParsers/DelayParser.cpp +++ b/Swiften/Parser/PayloadParsers/DelayParser.cpp @@ -15,31 +15,31 @@ namespace Swift { DelayParser::DelayParser(const std::locale& locale) : locale(locale), level_(0) { } -boost::posix_time::ptime DelayParser::dateFromString(const String& string) { - std::istringstream stream(string.getUTF8String()); +boost::posix_time::ptime DelayParser::dateFromString(const std::string& string) { + std::istringstream stream(string); stream.imbue(locale); boost::posix_time::ptime result(boost::posix_time::not_a_date_time); stream >> result; return result; } -void DelayParser::handleStartElement(const String& /*element*/, const String& /*ns*/, const AttributeMap& attributes) { +void DelayParser::handleStartElement(const std::string& /*element*/, const std::string& /*ns*/, const AttributeMap& attributes) { if (level_ == 0) { boost::posix_time::ptime stamp = dateFromString(attributes.getAttribute("stamp")); getPayloadInternal()->setStamp(stamp); - if (!attributes.getAttribute("from").isEmpty()) { - String from = attributes.getAttribute("from"); + if (!attributes.getAttribute("from").empty()) { + std::string from = attributes.getAttribute("from"); getPayloadInternal()->setFrom(JID(from)); } } ++level_; } -void DelayParser::handleEndElement(const String&, const String&) { +void DelayParser::handleEndElement(const std::string&, const std::string&) { --level_; } -void DelayParser::handleCharacterData(const String&) { +void DelayParser::handleCharacterData(const std::string&) { } diff --git a/Swiften/Parser/PayloadParsers/DelayParser.h b/Swiften/Parser/PayloadParsers/DelayParser.h index b2fbdea..c2e2bb6 100644 --- a/Swiften/Parser/PayloadParsers/DelayParser.h +++ b/Swiften/Parser/PayloadParsers/DelayParser.h @@ -14,12 +14,12 @@ namespace Swift { public: DelayParser(const std::locale& locale); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: - boost::posix_time::ptime dateFromString(const String& string); + boost::posix_time::ptime dateFromString(const std::string& string); private: std::locale locale; diff --git a/Swiften/Parser/PayloadParsers/DelayParserFactory.h b/Swiften/Parser/PayloadParsers/DelayParserFactory.h index f3dd328..c150853 100644 --- a/Swiften/Parser/PayloadParsers/DelayParserFactory.h +++ b/Swiften/Parser/PayloadParsers/DelayParserFactory.h @@ -16,7 +16,7 @@ namespace Swift { public: DelayParserFactory(); - virtual bool canParse(const String& /*element*/, const String& ns, const AttributeMap&) const { + virtual bool canParse(const std::string& /*element*/, const std::string& ns, const AttributeMap&) const { return ns == "urn:xmpp:delay"; } diff --git a/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp b/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp index c47c703..e1fcb20 100644 --- a/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp +++ b/Swiften/Parser/PayloadParsers/DiscoInfoParser.cpp @@ -12,7 +12,7 @@ namespace Swift { DiscoInfoParser::DiscoInfoParser() : level_(TopLevel), formParser_(NULL) { } -void DiscoInfoParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void DiscoInfoParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level_ == PayloadLevel) { if (element == "identity") { getPayloadInternal()->addIdentity(DiscoInfo::Identity(attributes.getAttribute("name"), attributes.getAttribute("category"), attributes.getAttribute("type"), attributes.getAttribute("lang"))); @@ -31,7 +31,7 @@ void DiscoInfoParser::handleStartElement(const String& element, const String& ns ++level_; } -void DiscoInfoParser::handleEndElement(const String& element, const String& ns) { +void DiscoInfoParser::handleEndElement(const std::string& element, const std::string& ns) { --level_; if (formParser_) { formParser_->handleEndElement(element, ns); @@ -43,7 +43,7 @@ void DiscoInfoParser::handleEndElement(const String& element, const String& ns) } } -void DiscoInfoParser::handleCharacterData(const String& data) { +void DiscoInfoParser::handleCharacterData(const std::string& data) { if (formParser_) { formParser_->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/DiscoInfoParser.h b/Swiften/Parser/PayloadParsers/DiscoInfoParser.h index d9bfb54..24a1d6f 100644 --- a/Swiften/Parser/PayloadParsers/DiscoInfoParser.h +++ b/Swiften/Parser/PayloadParsers/DiscoInfoParser.h @@ -14,9 +14,9 @@ namespace Swift { public: DiscoInfoParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { diff --git a/Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp b/Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp index 0900354..7ff375b 100644 --- a/Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp +++ b/Swiften/Parser/PayloadParsers/DiscoItemsParser.cpp @@ -11,7 +11,7 @@ namespace Swift { DiscoItemsParser::DiscoItemsParser() : level_(TopLevel) { } -void DiscoItemsParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) { +void DiscoItemsParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level_ == PayloadLevel) { if (element == "item") { getPayloadInternal()->addItem(DiscoItems::Item(attributes.getAttribute("name"), JID(attributes.getAttribute("jid")), attributes.getAttribute("node"))); @@ -20,11 +20,11 @@ void DiscoItemsParser::handleStartElement(const String& element, const String&, ++level_; } -void DiscoItemsParser::handleEndElement(const String&, const String&) { +void DiscoItemsParser::handleEndElement(const std::string&, const std::string&) { --level_; } -void DiscoItemsParser::handleCharacterData(const String&) { +void DiscoItemsParser::handleCharacterData(const std::string&) { } } diff --git a/Swiften/Parser/PayloadParsers/DiscoItemsParser.h b/Swiften/Parser/PayloadParsers/DiscoItemsParser.h index e3da34e..0700df6 100644 --- a/Swiften/Parser/PayloadParsers/DiscoItemsParser.h +++ b/Swiften/Parser/PayloadParsers/DiscoItemsParser.h @@ -14,9 +14,9 @@ namespace Swift { public: DiscoItemsParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { diff --git a/Swiften/Parser/PayloadParsers/ErrorParser.cpp b/Swiften/Parser/PayloadParsers/ErrorParser.cpp index 7ef4176..4034cb5 100644 --- a/Swiften/Parser/PayloadParsers/ErrorParser.cpp +++ b/Swiften/Parser/PayloadParsers/ErrorParser.cpp @@ -11,9 +11,9 @@ namespace Swift { ErrorParser::ErrorParser() : level_(TopLevel) { } -void ErrorParser::handleStartElement(const String&, const String&, const AttributeMap& attributes) { +void ErrorParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) { if (level_ == TopLevel) { - String type = attributes.getAttribute("type"); + std::string type = attributes.getAttribute("type"); if (type == "continue") { getPayloadInternal()->setType(ErrorPayload::Continue); } @@ -33,7 +33,7 @@ void ErrorParser::handleStartElement(const String&, const String&, const Attribu ++level_; } -void ErrorParser::handleEndElement(const String& element, const String&) { +void ErrorParser::handleEndElement(const std::string& element, const std::string&) { --level_; if (level_ == PayloadLevel) { if (element == "text") { @@ -108,7 +108,7 @@ void ErrorParser::handleEndElement(const String& element, const String&) { } } -void ErrorParser::handleCharacterData(const String& data) { +void ErrorParser::handleCharacterData(const std::string& data) { currentText_ += data; } diff --git a/Swiften/Parser/PayloadParsers/ErrorParser.h b/Swiften/Parser/PayloadParsers/ErrorParser.h index 7642910..4318a8c 100644 --- a/Swiften/Parser/PayloadParsers/ErrorParser.h +++ b/Swiften/Parser/PayloadParsers/ErrorParser.h @@ -15,9 +15,9 @@ namespace Swift { public: ErrorParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -25,7 +25,7 @@ namespace Swift { PayloadLevel = 1 }; int level_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/PayloadParsers/FormParser.cpp b/Swiften/Parser/PayloadParsers/FormParser.cpp index dc15ece..f8e02a4 100644 --- a/Swiften/Parser/PayloadParsers/FormParser.cpp +++ b/Swiften/Parser/PayloadParsers/FormParser.cpp @@ -11,9 +11,9 @@ namespace Swift { FormParser::FormParser() : level_(TopLevel) { } -void FormParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) { +void FormParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level_ == TopLevel) { - String type = attributes.getAttribute("type"); + std::string type = attributes.getAttribute("type"); if (type == "form") { getPayloadInternal()->setType(Form::FormType); } @@ -35,7 +35,7 @@ void FormParser::handleStartElement(const String& element, const String&, const currentText_.clear(); } else if (element == "field") { - String type = attributes.getAttribute("type"); + std::string type = attributes.getAttribute("type"); if (type == "boolean") { currentFieldParseHelper_ = BooleanFormFieldParseHelper::create(); } @@ -84,12 +84,12 @@ void FormParser::handleStartElement(const String& element, const String&, const ++level_; } -void FormParser::handleEndElement(const String& element, const String&) { +void FormParser::handleEndElement(const std::string& element, const std::string&) { --level_; if (level_ == PayloadLevel) { if (element == "title") { - String currentTitle = getPayloadInternal()->getTitle(); - if (currentTitle.isEmpty()) { + std::string currentTitle = getPayloadInternal()->getTitle(); + if (currentTitle.empty()) { getPayloadInternal()->setTitle(currentText_); } else { @@ -97,8 +97,8 @@ void FormParser::handleEndElement(const String& element, const String&) { } } else if (element == "instructions") { - String currentInstructions = getPayloadInternal()->getInstructions(); - if (currentInstructions.isEmpty()) { + std::string currentInstructions = getPayloadInternal()->getInstructions(); + if (currentInstructions.empty()) { getPayloadInternal()->setInstructions(currentText_); } else { @@ -128,7 +128,7 @@ void FormParser::handleEndElement(const String& element, const String&) { } } -void FormParser::handleCharacterData(const String& text) { +void FormParser::handleCharacterData(const std::string& text) { currentText_ += text; } diff --git a/Swiften/Parser/PayloadParsers/FormParser.h b/Swiften/Parser/PayloadParsers/FormParser.h index c41e27f..90a3550 100644 --- a/Swiften/Parser/PayloadParsers/FormParser.h +++ b/Swiften/Parser/PayloadParsers/FormParser.h @@ -14,15 +14,15 @@ namespace Swift { public: FormParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: class FieldParseHelper { public: virtual ~FieldParseHelper() {} - virtual void addValue(const String&) = 0; + virtual void addValue(const std::string&) = 0; virtual boost::shared_ptr<FormField> getField() const { return field; } @@ -30,15 +30,15 @@ namespace Swift { boost::shared_ptr<FormField> field; }; class BoolFieldParseHelper : public FieldParseHelper { - virtual void addValue(const String& s) { + virtual void addValue(const std::string& s) { boost::dynamic_pointer_cast< GenericFormField<bool> >(getField())->setValue(s == "1" || s == "true"); getField()->addRawValue(s); } }; class StringFieldParseHelper : public FieldParseHelper { - virtual void addValue(const String& s) { - boost::shared_ptr<GenericFormField<String> > field = boost::dynamic_pointer_cast< GenericFormField<String> >(getField()); - if (field->getValue().isEmpty()) { + virtual void addValue(const std::string& s) { + boost::shared_ptr<GenericFormField<std::string> > field = boost::dynamic_pointer_cast< GenericFormField<std::string> >(getField()); + if (field->getValue().empty()) { field->setValue(s); } else { @@ -48,22 +48,22 @@ namespace Swift { } }; class JIDFieldParseHelper : public FieldParseHelper { - virtual void addValue(const String& s) { + virtual void addValue(const std::string& s) { boost::dynamic_pointer_cast< GenericFormField<JID> >(getField())->setValue(JID(s)); } }; class StringListFieldParseHelper : public FieldParseHelper { - virtual void addValue(const String& s) { + virtual void addValue(const std::string& s) { // FIXME: Inefficient, but too much hassle to do efficiently - boost::shared_ptr<GenericFormField< std::vector<String> > > field = boost::dynamic_pointer_cast< GenericFormField<std::vector<String > > >(getField()); - std::vector<String> l = field->getValue(); + boost::shared_ptr<GenericFormField< std::vector<std::string> > > field = boost::dynamic_pointer_cast< GenericFormField<std::vector<std::string > > >(getField()); + std::vector<std::string> l = field->getValue(); l.push_back(s); field->setValue(l); getField()->addRawValue(s); } }; class JIDListFieldParseHelper : public FieldParseHelper { - virtual void addValue(const String& s) { + virtual void addValue(const std::string& s) { // FIXME: Inefficient, but too much hassle to do efficiently boost::shared_ptr< GenericFormField< std::vector<JID> > > field = boost::dynamic_pointer_cast< GenericFormField<std::vector<JID > > >(getField()); std::vector<JID> l = field->getValue(); @@ -104,8 +104,8 @@ namespace Swift { FieldLevel = 2 }; int level_; - String currentText_; - String currentOptionLabel_; + std::string currentText_; + std::string currentOptionLabel_; boost::shared_ptr<FieldParseHelper> currentFieldParseHelper_; }; } diff --git a/Swiften/Parser/PayloadParsers/FormParserFactory.h b/Swiften/Parser/PayloadParsers/FormParserFactory.h index 805b0f1..7c095a7 100644 --- a/Swiften/Parser/PayloadParsers/FormParserFactory.h +++ b/Swiften/Parser/PayloadParsers/FormParserFactory.h @@ -17,7 +17,7 @@ namespace Swift { FormParserFactory() { } - virtual bool canParse(const String& /*element*/, const String& ns, const AttributeMap&) const { + virtual bool canParse(const std::string& /*element*/, const std::string& ns, const AttributeMap&) const { return ns == "jabber:x:data"; } diff --git a/Swiften/Parser/PayloadParsers/IBBParser.cpp b/Swiften/Parser/PayloadParsers/IBBParser.cpp index b2b4929..f36dc43 100644 --- a/Swiften/Parser/PayloadParsers/IBBParser.cpp +++ b/Swiften/Parser/PayloadParsers/IBBParser.cpp @@ -19,7 +19,7 @@ IBBParser::IBBParser() : level(TopLevel) { IBBParser::~IBBParser() { } -void IBBParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) { +void IBBParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level == TopLevel) { if (element == "data") { getPayloadInternal()->setAction(IBB::Data); @@ -53,23 +53,23 @@ void IBBParser::handleStartElement(const String& element, const String&, const A ++level; } -void IBBParser::handleEndElement(const String& element, const String&) { +void IBBParser::handleEndElement(const std::string& element, const std::string&) { --level; if (level == TopLevel) { if (element == "data") { std::vector<char> data; - for (size_t i = 0; i < currentText.getUTF8Size(); ++i) { + for (size_t i = 0; i < currentText.size(); ++i) { char c = currentText[i]; if (c >= 48 && c <= 122) { data.push_back(c); } } - getPayloadInternal()->setData(Base64::decode(String(&data[0], data.size()))); + getPayloadInternal()->setData(Base64::decode(std::string(&data[0], data.size()))); } } } -void IBBParser::handleCharacterData(const String& data) { +void IBBParser::handleCharacterData(const std::string& data) { currentText += data; } diff --git a/Swiften/Parser/PayloadParsers/IBBParser.h b/Swiften/Parser/PayloadParsers/IBBParser.h index 1fc062f..132e79d 100644 --- a/Swiften/Parser/PayloadParsers/IBBParser.h +++ b/Swiften/Parser/PayloadParsers/IBBParser.h @@ -17,15 +17,15 @@ namespace Swift { IBBParser(); ~IBBParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { TopLevel = 0, }; int level; - String currentText; + std::string currentText; }; } diff --git a/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp b/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp index 5a9b3d8..2ec1916 100644 --- a/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp +++ b/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.cpp @@ -18,7 +18,7 @@ InBandRegistrationPayloadParser::~InBandRegistrationPayloadParser() { delete formParserFactory; } -void InBandRegistrationPayloadParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void InBandRegistrationPayloadParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == TopLevel) { } else if (level == PayloadLevel) { @@ -38,7 +38,7 @@ void InBandRegistrationPayloadParser::handleStartElement(const String& element, ++level; } -void InBandRegistrationPayloadParser::handleEndElement(const String& element, const String& ns) { +void InBandRegistrationPayloadParser::handleEndElement(const std::string& element, const std::string& ns) { --level; if (formParser) { @@ -116,7 +116,7 @@ void InBandRegistrationPayloadParser::handleEndElement(const String& element, co } } -void InBandRegistrationPayloadParser::handleCharacterData(const String& data) { +void InBandRegistrationPayloadParser::handleCharacterData(const std::string& data) { if (formParser) { formParser->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.h b/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.h index d616e70..c0209c4 100644 --- a/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.h +++ b/Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.h @@ -20,9 +20,9 @@ namespace Swift { InBandRegistrationPayloadParser(); ~InBandRegistrationPayloadParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -32,6 +32,6 @@ namespace Swift { int level; FormParserFactory* formParserFactory; FormParser* formParser; - String currentText; + std::string currentText; }; } diff --git a/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp b/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp index 65417a7..ec9e200 100644 --- a/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp +++ b/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.cpp @@ -18,27 +18,27 @@ namespace Swift { MUCUserPayloadParser::MUCUserPayloadParser() : level(TopLevel) { } -void MUCUserPayloadParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) { +void MUCUserPayloadParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level == ItemLevel) { if (element == "item") { MUCUserPayload::Item item; - String affiliation = attributes.getAttribute("affiliation"); - String role = attributes.getAttribute("role"); - String nick = attributes.getAttribute("nick"); - String jid = attributes.getAttribute("jid"); + std::string affiliation = attributes.getAttribute("affiliation"); + std::string role = attributes.getAttribute("role"); + std::string nick = attributes.getAttribute("nick"); + std::string jid = attributes.getAttribute("jid"); item.affiliation = parseAffiliation(affiliation); item.role = parseRole(role); - if (!jid.isEmpty()) { + if (!jid.empty()) { item.realJID = JID(jid); } - if (!nick.isEmpty()) { + if (!nick.empty()) { item.nick = nick; } getPayloadInternal()->addItem(item); } else if (element == "status") { MUCUserPayload::StatusCode status; try { - status.code = boost::lexical_cast<int>(attributes.getAttribute("code").getUTF8Data()); + status.code = boost::lexical_cast<int>(attributes.getAttribute("code").c_str()); getPayloadInternal()->addStatusCode(status); } catch (boost::bad_lexical_cast&) { } @@ -47,7 +47,7 @@ void MUCUserPayloadParser::handleStartElement(const String& element, const Strin ++level; } -MUCOccupant::Role MUCUserPayloadParser::parseRole(const String& roleString) const { +MUCOccupant::Role MUCUserPayloadParser::parseRole(const std::string& roleString) const { if (roleString == "moderator") { return MUCOccupant::Moderator; } @@ -63,7 +63,7 @@ MUCOccupant::Role MUCUserPayloadParser::parseRole(const String& roleString) cons return MUCOccupant::NoRole; } -MUCOccupant::Affiliation MUCUserPayloadParser::parseAffiliation(const String& affiliationString) const { +MUCOccupant::Affiliation MUCUserPayloadParser::parseAffiliation(const std::string& affiliationString) const { if (affiliationString == "owner") { return MUCOccupant::Owner; } @@ -83,11 +83,11 @@ MUCOccupant::Affiliation MUCUserPayloadParser::parseAffiliation(const String& af } -void MUCUserPayloadParser::handleEndElement(const String& /*element*/, const String&) { +void MUCUserPayloadParser::handleEndElement(const std::string& /*element*/, const std::string&) { --level; } -void MUCUserPayloadParser::handleCharacterData(const String& /*data*/) { +void MUCUserPayloadParser::handleCharacterData(const std::string& /*data*/) { } diff --git a/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.h b/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.h index 01c7de1..384f0cd 100644 --- a/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.h +++ b/Swiften/Parser/PayloadParsers/MUCUserPayloadParser.h @@ -16,11 +16,11 @@ namespace Swift { public: MUCUserPayloadParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); - MUCOccupant::Role parseRole(const String& itemString) const; - MUCOccupant::Affiliation parseAffiliation(const String& statusString) const; + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); + MUCOccupant::Role parseRole(const std::string& itemString) const; + MUCOccupant::Affiliation parseAffiliation(const std::string& statusString) const; private: enum Level { TopLevel = 0, diff --git a/Swiften/Parser/PayloadParsers/NicknameParser.cpp b/Swiften/Parser/PayloadParsers/NicknameParser.cpp index c60bc72..cd7ec27 100644 --- a/Swiften/Parser/PayloadParsers/NicknameParser.cpp +++ b/Swiften/Parser/PayloadParsers/NicknameParser.cpp @@ -11,18 +11,18 @@ namespace Swift { NicknameParser::NicknameParser() : level(0) { } -void NicknameParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void NicknameParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level; } -void NicknameParser::handleEndElement(const String&, const String&) { +void NicknameParser::handleEndElement(const std::string&, const std::string&) { --level; if (level == 0) { getPayloadInternal()->setNickname(text); } } -void NicknameParser::handleCharacterData(const String& data) { +void NicknameParser::handleCharacterData(const std::string& data) { text += data; } diff --git a/Swiften/Parser/PayloadParsers/NicknameParser.h b/Swiften/Parser/PayloadParsers/NicknameParser.h index 24003b8..6e723c8 100644 --- a/Swiften/Parser/PayloadParsers/NicknameParser.h +++ b/Swiften/Parser/PayloadParsers/NicknameParser.h @@ -14,12 +14,12 @@ namespace Swift { public: NicknameParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level; - String text; + std::string text; }; } diff --git a/Swiften/Parser/PayloadParsers/PriorityParser.cpp b/Swiften/Parser/PayloadParsers/PriorityParser.cpp index 8872977..bcbf67f 100644 --- a/Swiften/Parser/PayloadParsers/PriorityParser.cpp +++ b/Swiften/Parser/PayloadParsers/PriorityParser.cpp @@ -13,11 +13,11 @@ namespace Swift { PriorityParser::PriorityParser() : level_(0) { } -void PriorityParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void PriorityParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level_; } -void PriorityParser::handleEndElement(const String&, const String&) { +void PriorityParser::handleEndElement(const std::string&, const std::string&) { --level_; if (level_ == 0) { int priority = 0; @@ -30,7 +30,7 @@ void PriorityParser::handleEndElement(const String&, const String&) { } } -void PriorityParser::handleCharacterData(const String& data) { +void PriorityParser::handleCharacterData(const std::string& data) { text_ += data; } diff --git a/Swiften/Parser/PayloadParsers/PriorityParser.h b/Swiften/Parser/PayloadParsers/PriorityParser.h index e9ce592..1b02255 100644 --- a/Swiften/Parser/PayloadParsers/PriorityParser.h +++ b/Swiften/Parser/PayloadParsers/PriorityParser.h @@ -15,13 +15,13 @@ namespace Swift { public: PriorityParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; - String text_; + std::string text_; }; } diff --git a/Swiften/Parser/PayloadParsers/PrivateStorageParser.cpp b/Swiften/Parser/PayloadParsers/PrivateStorageParser.cpp index 2cbe741..026da96 100644 --- a/Swiften/Parser/PayloadParsers/PrivateStorageParser.cpp +++ b/Swiften/Parser/PayloadParsers/PrivateStorageParser.cpp @@ -13,7 +13,7 @@ namespace Swift { PrivateStorageParser::PrivateStorageParser(PayloadParserFactoryCollection* factories) : factories(factories), level(0) { } -void PrivateStorageParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void PrivateStorageParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == 1) { PayloadParserFactory* payloadParserFactory = factories->getPayloadParserFactory(element, ns, attributes); if (payloadParserFactory) { @@ -27,7 +27,7 @@ void PrivateStorageParser::handleStartElement(const String& element, const Strin ++level; } -void PrivateStorageParser::handleEndElement(const String& element, const String& ns) { +void PrivateStorageParser::handleEndElement(const std::string& element, const std::string& ns) { --level; if (currentPayloadParser.get()) { if (level >= 1) { @@ -40,7 +40,7 @@ void PrivateStorageParser::handleEndElement(const String& element, const String& } } -void PrivateStorageParser::handleCharacterData(const String& data) { +void PrivateStorageParser::handleCharacterData(const std::string& data) { if (level > 1 && currentPayloadParser.get()) { currentPayloadParser->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/PrivateStorageParser.h b/Swiften/Parser/PayloadParsers/PrivateStorageParser.h index 1340ba1..f5f569a 100644 --- a/Swiften/Parser/PayloadParsers/PrivateStorageParser.h +++ b/Swiften/Parser/PayloadParsers/PrivateStorageParser.h @@ -19,9 +19,9 @@ namespace Swift { PrivateStorageParser(PayloadParserFactoryCollection* factories); private: - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: PayloadParserFactoryCollection* factories; diff --git a/Swiften/Parser/PayloadParsers/PrivateStorageParserFactory.h b/Swiften/Parser/PayloadParsers/PrivateStorageParserFactory.h index 53bb1ec..9399ace 100644 --- a/Swiften/Parser/PayloadParsers/PrivateStorageParserFactory.h +++ b/Swiften/Parser/PayloadParsers/PrivateStorageParserFactory.h @@ -17,7 +17,7 @@ namespace Swift { PrivateStorageParserFactory(PayloadParserFactoryCollection* factories) : factories(factories) { } - virtual bool canParse(const String& element, const String& ns, const AttributeMap&) const { + virtual bool canParse(const std::string& element, const std::string& ns, const AttributeMap&) const { return element == "query" && ns == "jabber:iq:private"; } diff --git a/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.cpp b/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.cpp index 589e9d9..bc9b843 100644 --- a/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.cpp +++ b/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.cpp @@ -12,12 +12,12 @@ namespace Swift { RawXMLPayloadParser::RawXMLPayloadParser() : level_(0) { } -void RawXMLPayloadParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void RawXMLPayloadParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { ++level_; serializingParser_.handleStartElement(element, ns, attributes); } -void RawXMLPayloadParser::handleEndElement(const String& element, const String& ns) { +void RawXMLPayloadParser::handleEndElement(const std::string& element, const std::string& ns) { serializingParser_.handleEndElement(element, ns); --level_; if (level_ == 0) { @@ -25,7 +25,7 @@ void RawXMLPayloadParser::handleEndElement(const String& element, const String& } } -void RawXMLPayloadParser::handleCharacterData(const String& data) { +void RawXMLPayloadParser::handleCharacterData(const std::string& data) { serializingParser_.handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.h b/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.h index eedc85b..b5c887a 100644 --- a/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.h +++ b/Swiften/Parser/PayloadParsers/RawXMLPayloadParser.h @@ -17,9 +17,9 @@ namespace Swift { public: RawXMLPayloadParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; diff --git a/Swiften/Parser/PayloadParsers/RawXMLPayloadParserFactory.h b/Swiften/Parser/PayloadParsers/RawXMLPayloadParserFactory.h index 755fb08..b180e1e 100644 --- a/Swiften/Parser/PayloadParsers/RawXMLPayloadParserFactory.h +++ b/Swiften/Parser/PayloadParsers/RawXMLPayloadParserFactory.h @@ -8,14 +8,14 @@ #include "Swiften/Parser/PayloadParserFactory.h" #include "Swiften/Parser/PayloadParsers/RawXMLPayloadParser.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class RawXMLPayloadParserFactory : public PayloadParserFactory { public: RawXMLPayloadParserFactory() {} - virtual bool canParse(const String&, const String&, const AttributeMap&) const { + virtual bool canParse(const std::string&, const std::string&, const AttributeMap&) const { return true; } diff --git a/Swiften/Parser/PayloadParsers/ResourceBindParser.cpp b/Swiften/Parser/PayloadParsers/ResourceBindParser.cpp index 92929bf..5c3affb 100644 --- a/Swiften/Parser/PayloadParsers/ResourceBindParser.cpp +++ b/Swiften/Parser/PayloadParsers/ResourceBindParser.cpp @@ -11,7 +11,7 @@ namespace Swift { ResourceBindParser::ResourceBindParser() : level_(0), inJID_(false), inResource_(false) { } -void ResourceBindParser::handleStartElement(const String& element, const String&, const AttributeMap&) { +void ResourceBindParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap&) { if (level_ == 1) { text_ = ""; if (element == "resource") { @@ -24,7 +24,7 @@ void ResourceBindParser::handleStartElement(const String& element, const String& ++level_; } -void ResourceBindParser::handleEndElement(const String&, const String&) { +void ResourceBindParser::handleEndElement(const std::string&, const std::string&) { --level_; if (level_ == 1) { if (inJID_) { @@ -36,7 +36,7 @@ void ResourceBindParser::handleEndElement(const String&, const String&) { } } -void ResourceBindParser::handleCharacterData(const String& data) { +void ResourceBindParser::handleCharacterData(const std::string& data) { text_ += data; } diff --git a/Swiften/Parser/PayloadParsers/ResourceBindParser.h b/Swiften/Parser/PayloadParsers/ResourceBindParser.h index 890f28a..875b5f4 100644 --- a/Swiften/Parser/PayloadParsers/ResourceBindParser.h +++ b/Swiften/Parser/PayloadParsers/ResourceBindParser.h @@ -15,15 +15,15 @@ namespace Swift { public: ResourceBindParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; bool inJID_; bool inResource_; - String text_; + std::string text_; }; } diff --git a/Swiften/Parser/PayloadParsers/RosterParser.cpp b/Swiften/Parser/PayloadParsers/RosterParser.cpp index a8dd63e..ba19fbf 100644 --- a/Swiften/Parser/PayloadParsers/RosterParser.cpp +++ b/Swiften/Parser/PayloadParsers/RosterParser.cpp @@ -12,7 +12,7 @@ namespace Swift { RosterParser::RosterParser() : level_(TopLevel), inItem_(false), unknownContentParser_(0) { } -void RosterParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void RosterParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level_ == PayloadLevel) { if (element == "item") { inItem_ = true; @@ -21,7 +21,7 @@ void RosterParser::handleStartElement(const String& element, const String& ns, c currentItem_.setJID(JID(attributes.getAttribute("jid"))); currentItem_.setName(attributes.getAttribute("name")); - String subscription = attributes.getAttribute("subscription"); + std::string subscription = attributes.getAttribute("subscription"); if (subscription == "both") { currentItem_.setSubscription(RosterItemPayload::Both); } @@ -59,7 +59,7 @@ void RosterParser::handleStartElement(const String& element, const String& ns, c ++level_; } -void RosterParser::handleEndElement(const String& element, const String& ns) { +void RosterParser::handleEndElement(const std::string& element, const std::string& ns) { --level_; if (level_ == PayloadLevel) { if (inItem_) { @@ -83,7 +83,7 @@ void RosterParser::handleEndElement(const String& element, const String& ns) { } } -void RosterParser::handleCharacterData(const String& data) { +void RosterParser::handleCharacterData(const std::string& data) { if (unknownContentParser_) { unknownContentParser_->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/RosterParser.h b/Swiften/Parser/PayloadParsers/RosterParser.h index 4a28618..ac72696 100644 --- a/Swiften/Parser/PayloadParsers/RosterParser.h +++ b/Swiften/Parser/PayloadParsers/RosterParser.h @@ -17,9 +17,9 @@ namespace Swift { public: RosterParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -30,7 +30,7 @@ namespace Swift { int level_; bool inItem_; RosterItemPayload currentItem_; - String currentText_; + std::string currentText_; SerializingParser* unknownContentParser_; }; } diff --git a/Swiften/Parser/PayloadParsers/SearchPayloadParser.cpp b/Swiften/Parser/PayloadParsers/SearchPayloadParser.cpp index f2cf1dd..7c8752c 100644 --- a/Swiften/Parser/PayloadParsers/SearchPayloadParser.cpp +++ b/Swiften/Parser/PayloadParsers/SearchPayloadParser.cpp @@ -18,7 +18,7 @@ SearchPayloadParser::~SearchPayloadParser() { delete formParserFactory; } -void SearchPayloadParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void SearchPayloadParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == TopLevel) { } else if (level == PayloadLevel) { @@ -46,7 +46,7 @@ void SearchPayloadParser::handleStartElement(const String& element, const String ++level; } -void SearchPayloadParser::handleEndElement(const String& element, const String& ns) { +void SearchPayloadParser::handleEndElement(const std::string& element, const std::string& ns) { --level; if (formParser) { @@ -98,7 +98,7 @@ void SearchPayloadParser::handleEndElement(const String& element, const String& } } -void SearchPayloadParser::handleCharacterData(const String& data) { +void SearchPayloadParser::handleCharacterData(const std::string& data) { if (formParser) { formParser->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/SearchPayloadParser.h b/Swiften/Parser/PayloadParsers/SearchPayloadParser.h index 55177b0..01441e8 100644 --- a/Swiften/Parser/PayloadParsers/SearchPayloadParser.h +++ b/Swiften/Parser/PayloadParsers/SearchPayloadParser.h @@ -20,9 +20,9 @@ namespace Swift { SearchPayloadParser(); ~SearchPayloadParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -33,7 +33,7 @@ namespace Swift { int level; FormParserFactory* formParserFactory; FormParser* formParser; - String currentText; + std::string currentText; boost::optional<SearchPayload::Item> currentItem; }; } diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp b/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp index eac297b..bf134d7 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp +++ b/Swiften/Parser/PayloadParsers/SecurityLabelParser.cpp @@ -12,7 +12,7 @@ namespace Swift { SecurityLabelParser::SecurityLabelParser() : level_(TopLevel), labelParser_(0) { } -void SecurityLabelParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void SecurityLabelParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { ++level_; if (level_ == DisplayMarkingOrLabelLevel) { if (element == "displaymarking") { @@ -30,7 +30,7 @@ void SecurityLabelParser::handleStartElement(const String& element, const String } } -void SecurityLabelParser::handleEndElement(const String& element, const String& ns) { +void SecurityLabelParser::handleEndElement(const std::string& element, const std::string& ns) { if (level_ == DisplayMarkingOrLabelLevel) { if (element == "displaymarking") { getPayloadInternal()->setDisplayMarking(currentText_); @@ -53,7 +53,7 @@ void SecurityLabelParser::handleEndElement(const String& element, const String& } -void SecurityLabelParser::handleCharacterData(const String& data) { +void SecurityLabelParser::handleCharacterData(const std::string& data) { if (labelParser_) { labelParser_->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelParser.h b/Swiften/Parser/PayloadParsers/SecurityLabelParser.h index cc62e10..bd80921 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelParser.h +++ b/Swiften/Parser/PayloadParsers/SecurityLabelParser.h @@ -17,9 +17,9 @@ namespace Swift { public: SecurityLabelParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -30,7 +30,7 @@ namespace Swift { }; int level_; SerializingParser* labelParser_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp index abe392f..1f2a6bc 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp +++ b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.cpp @@ -18,7 +18,7 @@ SecurityLabelsCatalogParser::~SecurityLabelsCatalogParser() { delete labelParserFactory_; } -void SecurityLabelsCatalogParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void SecurityLabelsCatalogParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { ++level_; if (level_ == PayloadLevel) { getPayloadInternal()->setTo(JID(attributes.getAttribute("to"))); @@ -38,7 +38,7 @@ void SecurityLabelsCatalogParser::handleStartElement(const String& element, cons } } -void SecurityLabelsCatalogParser::handleEndElement(const String& element, const String& ns) { +void SecurityLabelsCatalogParser::handleEndElement(const std::string& element, const std::string& ns) { if (labelParser_) { labelParser_->handleEndElement(element, ns); } @@ -52,7 +52,7 @@ void SecurityLabelsCatalogParser::handleEndElement(const String& element, const --level_; } -void SecurityLabelsCatalogParser::handleCharacterData(const String& data) { +void SecurityLabelsCatalogParser::handleCharacterData(const std::string& data) { if (labelParser_) { labelParser_->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h index 36a54cb..2222117 100644 --- a/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h +++ b/Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h @@ -19,9 +19,9 @@ namespace Swift { SecurityLabelsCatalogParser(); ~SecurityLabelsCatalogParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { diff --git a/Swiften/Parser/PayloadParsers/SoftwareVersionParser.cpp b/Swiften/Parser/PayloadParsers/SoftwareVersionParser.cpp index 95d29a7..f8e61c7 100644 --- a/Swiften/Parser/PayloadParsers/SoftwareVersionParser.cpp +++ b/Swiften/Parser/PayloadParsers/SoftwareVersionParser.cpp @@ -11,11 +11,11 @@ namespace Swift { SoftwareVersionParser::SoftwareVersionParser() : level_(TopLevel) { } -void SoftwareVersionParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void SoftwareVersionParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level_; } -void SoftwareVersionParser::handleEndElement(const String& element, const String&) { +void SoftwareVersionParser::handleEndElement(const std::string& element, const std::string&) { --level_; if (level_ == PayloadLevel) { if (element == "name") { @@ -31,7 +31,7 @@ void SoftwareVersionParser::handleEndElement(const String& element, const String } } -void SoftwareVersionParser::handleCharacterData(const String& data) { +void SoftwareVersionParser::handleCharacterData(const std::string& data) { currentText_ += data; } diff --git a/Swiften/Parser/PayloadParsers/SoftwareVersionParser.h b/Swiften/Parser/PayloadParsers/SoftwareVersionParser.h index de9a47c..4272e5a 100644 --- a/Swiften/Parser/PayloadParsers/SoftwareVersionParser.h +++ b/Swiften/Parser/PayloadParsers/SoftwareVersionParser.h @@ -15,9 +15,9 @@ namespace Swift { public: SoftwareVersionParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -25,7 +25,7 @@ namespace Swift { PayloadLevel = 1 }; int level_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/PayloadParsers/StartSessionParser.h b/Swiften/Parser/PayloadParsers/StartSessionParser.h index 42090ad..ba6e3c8 100644 --- a/Swiften/Parser/PayloadParsers/StartSessionParser.h +++ b/Swiften/Parser/PayloadParsers/StartSessionParser.h @@ -15,9 +15,9 @@ namespace Swift { public: StartSessionParser() {} - virtual void handleStartElement(const String&, const String&, const AttributeMap&) {} - virtual void handleEndElement(const String&, const String&) {} - virtual void handleCharacterData(const String&) {} + virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) {} + virtual void handleEndElement(const std::string&, const std::string&) {} + virtual void handleCharacterData(const std::string&) {} }; } diff --git a/Swiften/Parser/PayloadParsers/StatusParser.cpp b/Swiften/Parser/PayloadParsers/StatusParser.cpp index 7188fb3..a5d00de 100644 --- a/Swiften/Parser/PayloadParsers/StatusParser.cpp +++ b/Swiften/Parser/PayloadParsers/StatusParser.cpp @@ -11,18 +11,18 @@ namespace Swift { StatusParser::StatusParser() : level_(0) { } -void StatusParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void StatusParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level_; } -void StatusParser::handleEndElement(const String&, const String&) { +void StatusParser::handleEndElement(const std::string&, const std::string&) { --level_; if (level_ == 0) { getPayloadInternal()->setText(text_); } } -void StatusParser::handleCharacterData(const String& data) { +void StatusParser::handleCharacterData(const std::string& data) { text_ += data; } diff --git a/Swiften/Parser/PayloadParsers/StatusParser.h b/Swiften/Parser/PayloadParsers/StatusParser.h index 87e118e..4c6f4ac 100644 --- a/Swiften/Parser/PayloadParsers/StatusParser.h +++ b/Swiften/Parser/PayloadParsers/StatusParser.h @@ -15,13 +15,13 @@ namespace Swift { public: StatusParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; - String text_; + std::string text_; }; } diff --git a/Swiften/Parser/PayloadParsers/StatusShowParser.cpp b/Swiften/Parser/PayloadParsers/StatusShowParser.cpp index 0fd4dd8..774f27d 100644 --- a/Swiften/Parser/PayloadParsers/StatusShowParser.cpp +++ b/Swiften/Parser/PayloadParsers/StatusShowParser.cpp @@ -11,11 +11,11 @@ namespace Swift { StatusShowParser::StatusShowParser() : level_(0) { } -void StatusShowParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void StatusShowParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level_; } -void StatusShowParser::handleEndElement(const String&, const String&) { +void StatusShowParser::handleEndElement(const std::string&, const std::string&) { --level_; if (level_ == 0) { if (text_ == "away") { @@ -36,7 +36,7 @@ void StatusShowParser::handleEndElement(const String&, const String&) { } } -void StatusShowParser::handleCharacterData(const String& data) { +void StatusShowParser::handleCharacterData(const std::string& data) { text_ += data; } diff --git a/Swiften/Parser/PayloadParsers/StatusShowParser.h b/Swiften/Parser/PayloadParsers/StatusShowParser.h index f6563a4..b4100a3 100644 --- a/Swiften/Parser/PayloadParsers/StatusShowParser.h +++ b/Swiften/Parser/PayloadParsers/StatusShowParser.h @@ -15,13 +15,13 @@ namespace Swift { public: StatusShowParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; - String text_; + std::string text_; }; } diff --git a/Swiften/Parser/PayloadParsers/StorageParser.cpp b/Swiften/Parser/PayloadParsers/StorageParser.cpp index c82b82c..94cd0ce 100644 --- a/Swiften/Parser/PayloadParsers/StorageParser.cpp +++ b/Swiften/Parser/PayloadParsers/StorageParser.cpp @@ -13,7 +13,7 @@ namespace Swift { StorageParser::StorageParser() : level(TopLevel) { } -void StorageParser::handleStartElement(const String& element, const String&, const AttributeMap& attributes) { +void StorageParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level == BookmarkLevel) { if (element == "conference") { assert(!room); @@ -35,7 +35,7 @@ void StorageParser::handleStartElement(const String& element, const String&, con ++level; } -void StorageParser::handleEndElement(const String& element, const String&) { +void StorageParser::handleEndElement(const std::string& element, const std::string&) { --level; if (level == BookmarkLevel) { if (element == "conference") { @@ -59,7 +59,7 @@ void StorageParser::handleEndElement(const String& element, const String&) { } } -void StorageParser::handleCharacterData(const String& data) { +void StorageParser::handleCharacterData(const std::string& data) { currentText += data; } diff --git a/Swiften/Parser/PayloadParsers/StorageParser.h b/Swiften/Parser/PayloadParsers/StorageParser.h index a8bd4a2..16fd869 100644 --- a/Swiften/Parser/PayloadParsers/StorageParser.h +++ b/Swiften/Parser/PayloadParsers/StorageParser.h @@ -16,9 +16,9 @@ namespace Swift { public: StorageParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -27,7 +27,7 @@ namespace Swift { DetailLevel = 2 }; int level; - String currentText; + std::string currentText; boost::optional<Storage::Room> room; boost::optional<Storage::URL> url; }; diff --git a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp b/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp index bf36321..28c5cf5 100644 --- a/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp +++ b/Swiften/Parser/PayloadParsers/StreamInitiationParser.cpp @@ -26,10 +26,10 @@ StreamInitiationParser::~StreamInitiationParser() { delete formParserFactory; } -void StreamInitiationParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void StreamInitiationParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == TopLevel) { getPayloadInternal()->setID(attributes.getAttribute("id")); - if (!attributes.getAttribute("profile").isEmpty()) { + if (!attributes.getAttribute("profile").empty()) { getPayloadInternal()->setIsFileTransfer(attributes.getAttribute("profile") == FILE_TRANSFER_NS); } } @@ -64,7 +64,7 @@ void StreamInitiationParser::handleStartElement(const String& element, const Str ++level; } -void StreamInitiationParser::handleEndElement(const String& element, const String& ns) { +void StreamInitiationParser::handleEndElement(const std::string& element, const std::string& ns) { --level; if (formParser) { formParser->handleEndElement(element, ns); @@ -107,7 +107,7 @@ void StreamInitiationParser::handleEndElement(const String& element, const Strin } } -void StreamInitiationParser::handleCharacterData(const String& data) { +void StreamInitiationParser::handleCharacterData(const std::string& data) { if (formParser) { formParser->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/StreamInitiationParser.h b/Swiften/Parser/PayloadParsers/StreamInitiationParser.h index 7a44651..46f5b2f 100644 --- a/Swiften/Parser/PayloadParsers/StreamInitiationParser.h +++ b/Swiften/Parser/PayloadParsers/StreamInitiationParser.h @@ -20,9 +20,9 @@ namespace Swift { StreamInitiationParser(); ~StreamInitiationParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -37,6 +37,6 @@ namespace Swift { bool inFile; bool inFeature; StreamInitiationFileInfo currentFile; - String currentText; + std::string currentText; }; } diff --git a/Swiften/Parser/PayloadParsers/SubjectParser.cpp b/Swiften/Parser/PayloadParsers/SubjectParser.cpp index d28fb7d..d7d9af8 100644 --- a/Swiften/Parser/PayloadParsers/SubjectParser.cpp +++ b/Swiften/Parser/PayloadParsers/SubjectParser.cpp @@ -11,18 +11,18 @@ namespace Swift { SubjectParser::SubjectParser() : level_(0) { } -void SubjectParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void SubjectParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level_; } -void SubjectParser::handleEndElement(const String&, const String&) { +void SubjectParser::handleEndElement(const std::string&, const std::string&) { --level_; if (level_ == 0) { getPayloadInternal()->setText(text_); } } -void SubjectParser::handleCharacterData(const String& data) { +void SubjectParser::handleCharacterData(const std::string& data) { text_ += data; } diff --git a/Swiften/Parser/PayloadParsers/SubjectParser.h b/Swiften/Parser/PayloadParsers/SubjectParser.h index a7b8a89..78e5a9e 100644 --- a/Swiften/Parser/PayloadParsers/SubjectParser.h +++ b/Swiften/Parser/PayloadParsers/SubjectParser.h @@ -14,12 +14,12 @@ namespace Swift { public: SubjectParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: int level_; - String text_; + std::string text_; }; } diff --git a/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp index b03a418..bb53586 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp @@ -27,7 +27,7 @@ class BodyParserTest : public CppUnit::TestFixture CPPUNIT_ASSERT(parser.parse("<body>foo<baz>bar</baz>fum</body>")); Body* payload = dynamic_cast<Body*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("foobarfum"), payload->getText()); + CPPUNIT_ASSERT_EQUAL(std::string("foobarfum"), payload->getText()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp index 5f11718..7ebcbac 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp @@ -29,8 +29,8 @@ class CommandParserTest : public CppUnit::TestFixture { Command::ref payload = parser.getPayload<Command>(); CPPUNIT_ASSERT_EQUAL(Command::Prev, payload->getAction()); - CPPUNIT_ASSERT_EQUAL(String("list"), payload->getNode()); - CPPUNIT_ASSERT_EQUAL(String("myid"), payload->getSessionID()); + CPPUNIT_ASSERT_EQUAL(std::string("list"), payload->getNode()); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), payload->getSessionID()); } void testParse_Result() { @@ -52,9 +52,9 @@ class CommandParserTest : public CppUnit::TestFixture { std::vector<Command::Note> notes = payload->getNotes(); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(notes.size())); CPPUNIT_ASSERT_EQUAL(Command::Note::Warn, notes[0].type); - CPPUNIT_ASSERT_EQUAL(String("Service 'httpd' has been configured."), notes[0].note); + CPPUNIT_ASSERT_EQUAL(std::string("Service 'httpd' has been configured."), notes[0].note); CPPUNIT_ASSERT_EQUAL(Command::Note::Error, notes[1].type); - CPPUNIT_ASSERT_EQUAL(String("I lied."), notes[1].note); + CPPUNIT_ASSERT_EQUAL(std::string("I lied."), notes[1].note); std::vector<Command::Action> actions = payload->getAvailableActions(); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(actions.size())); CPPUNIT_ASSERT_EQUAL(Command::Prev, actions[0]); @@ -77,8 +77,8 @@ class CommandParserTest : public CppUnit::TestFixture { Command::ref payload = parser.getPayload<Command>(); Form::ref form = payload->getForm(); - CPPUNIT_ASSERT_EQUAL(String("Bot Configuration"), form->getTitle()); - CPPUNIT_ASSERT_EQUAL(String("Hello!\nFill out this form to configure your new bot!"), form->getInstructions()); + CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), form->getTitle()); + CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), form->getInstructions()); CPPUNIT_ASSERT_EQUAL(Form::ResultType, form->getType()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp index 5d9e365..793e0c2 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp @@ -33,18 +33,18 @@ class DiscoInfoParserTest : public CppUnit::TestFixture { DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload()); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size())); - CPPUNIT_ASSERT_EQUAL(String("Swift"), payload->getIdentities()[0].getName()); - CPPUNIT_ASSERT_EQUAL(String("pc"), payload->getIdentities()[0].getType()); - CPPUNIT_ASSERT_EQUAL(String("client"), payload->getIdentities()[0].getCategory()); - CPPUNIT_ASSERT_EQUAL(String("en"), payload->getIdentities()[0].getLanguage()); - CPPUNIT_ASSERT_EQUAL(String("Vlug"), payload->getIdentities()[1].getName()); - CPPUNIT_ASSERT_EQUAL(String("pc"), payload->getIdentities()[1].getType()); - CPPUNIT_ASSERT_EQUAL(String("client"), payload->getIdentities()[1].getCategory()); - CPPUNIT_ASSERT_EQUAL(String("nl"), payload->getIdentities()[1].getLanguage()); + CPPUNIT_ASSERT_EQUAL(std::string("Swift"), payload->getIdentities()[0].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[0].getType()); + CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[0].getCategory()); + CPPUNIT_ASSERT_EQUAL(std::string("en"), payload->getIdentities()[0].getLanguage()); + CPPUNIT_ASSERT_EQUAL(std::string("Vlug"), payload->getIdentities()[1].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[1].getType()); + CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[1].getCategory()); + CPPUNIT_ASSERT_EQUAL(std::string("nl"), payload->getIdentities()[1].getLanguage()); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size())); - CPPUNIT_ASSERT_EQUAL(String("foo-feature"), payload->getFeatures()[0]); - CPPUNIT_ASSERT_EQUAL(String("bar-feature"), payload->getFeatures()[1]); - CPPUNIT_ASSERT_EQUAL(String("baz-feature"), payload->getFeatures()[2]); + CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]); } void testParse_Form() { @@ -62,10 +62,10 @@ class DiscoInfoParserTest : public CppUnit::TestFixture { DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload()); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getExtensions().size())); - CPPUNIT_ASSERT_EQUAL(String("Bot Configuration"), payload->getExtensions()[0]->getTitle()); + CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getExtensions()[0]->getTitle()); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getFeatures().size())); - CPPUNIT_ASSERT_EQUAL(String("foo-feature"), payload->getFeatures()[0]); - CPPUNIT_ASSERT_EQUAL(String("bar-feature"), payload->getFeatures()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp index 618ce6d..02c2f7d 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp @@ -30,7 +30,7 @@ class ErrorParserTest : public CppUnit::TestFixture { ErrorPayload::ref payload = boost::dynamic_pointer_cast<ErrorPayload>(parser.getPayload()); CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, payload->getCondition()); CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, payload->getType()); - CPPUNIT_ASSERT_EQUAL(String("boo"), payload->getText()); + CPPUNIT_ASSERT_EQUAL(std::string("boo"), payload->getText()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp index aede75d..6ec825b 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp @@ -31,8 +31,8 @@ class FormParserTest : public CppUnit::TestFixture { )); Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("Bot Configuration"), payload->getTitle()); - CPPUNIT_ASSERT_EQUAL(String("Hello!\nFill out this form to configure your new bot!"), payload->getInstructions()); + CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getTitle()); + CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), payload->getInstructions()); CPPUNIT_ASSERT_EQUAL(Form::SubmitType, payload->getType()); } @@ -84,38 +84,38 @@ class FormParserTest : public CppUnit::TestFixture { Form* payload = dynamic_cast<Form*>(parser.getPayload().get()); CPPUNIT_ASSERT_EQUAL(10, static_cast<int>(payload->getFields().size())); - CPPUNIT_ASSERT_EQUAL(String("jabber:bot"), boost::dynamic_pointer_cast<HiddenFormField>(payload->getFields()[0])->getValue()); - CPPUNIT_ASSERT_EQUAL(String("FORM_TYPE"), payload->getFields()[0]->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), boost::dynamic_pointer_cast<HiddenFormField>(payload->getFields()[0])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("FORM_TYPE"), payload->getFields()[0]->getName()); CPPUNIT_ASSERT(!payload->getFields()[0]->getRequired()); - CPPUNIT_ASSERT_EQUAL(String("Section 1: Bot Info"), boost::dynamic_pointer_cast<FixedFormField>(payload->getFields()[1])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("Section 1: Bot Info"), boost::dynamic_pointer_cast<FixedFormField>(payload->getFields()[1])->getValue()); - CPPUNIT_ASSERT_EQUAL(String("The name of your bot"), payload->getFields()[2]->getLabel()); + CPPUNIT_ASSERT_EQUAL(std::string("The name of your bot"), payload->getFields()[2]->getLabel()); - CPPUNIT_ASSERT_EQUAL(String("This is a bot.\nA quite good one actually"), boost::dynamic_pointer_cast<TextMultiFormField>(payload->getFields()[3])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("This is a bot.\nA quite good one actually"), boost::dynamic_pointer_cast<TextMultiFormField>(payload->getFields()[3])->getValue()); CPPUNIT_ASSERT_EQUAL(true, boost::dynamic_pointer_cast<BooleanFormField>(payload->getFields()[4])->getValue()); CPPUNIT_ASSERT(payload->getFields()[4]->getRequired()); - CPPUNIT_ASSERT_EQUAL(String("1"), boost::dynamic_pointer_cast<BooleanFormField>(payload->getFields()[4])->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("1"), boost::dynamic_pointer_cast<BooleanFormField>(payload->getFields()[4])->getRawValues()[0]); - CPPUNIT_ASSERT_EQUAL(String("news"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[0]); - CPPUNIT_ASSERT_EQUAL(String("news"), payload->getFields()[6]->getRawValues()[0]); - CPPUNIT_ASSERT_EQUAL(String("search"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[1]); - CPPUNIT_ASSERT_EQUAL(String("search"), payload->getFields()[6]->getRawValues()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("news"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getRawValues()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("search"), boost::dynamic_pointer_cast<ListMultiFormField>(payload->getFields()[6])->getValue()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("search"), payload->getFields()[6]->getRawValues()[1]); CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(payload->getFields()[6]->getOptions().size())); - CPPUNIT_ASSERT_EQUAL(String("Contests"), payload->getFields()[6]->getOptions()[0].label); - CPPUNIT_ASSERT_EQUAL(String("contests"), payload->getFields()[6]->getOptions()[0].value); - CPPUNIT_ASSERT_EQUAL(String("News"), payload->getFields()[6]->getOptions()[1].label); - CPPUNIT_ASSERT_EQUAL(String("news"), payload->getFields()[6]->getOptions()[1].value); + CPPUNIT_ASSERT_EQUAL(std::string("Contests"), payload->getFields()[6]->getOptions()[0].label); + CPPUNIT_ASSERT_EQUAL(std::string("contests"), payload->getFields()[6]->getOptions()[0].value); + CPPUNIT_ASSERT_EQUAL(std::string("News"), payload->getFields()[6]->getOptions()[1].label); + CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getOptions()[1].value); - CPPUNIT_ASSERT_EQUAL(String("20"), boost::dynamic_pointer_cast<ListSingleFormField>(payload->getFields()[7])->getValue()); + CPPUNIT_ASSERT_EQUAL(std::string("20"), boost::dynamic_pointer_cast<ListSingleFormField>(payload->getFields()[7])->getValue()); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), boost::dynamic_pointer_cast<JIDMultiFormField>(payload->getFields()[8])->getValue()[0]); CPPUNIT_ASSERT_EQUAL(JID("baz@fum.org"), boost::dynamic_pointer_cast<JIDMultiFormField>(payload->getFields()[8])->getValue()[1]); - CPPUNIT_ASSERT_EQUAL(String("Tell all your friends about your new bot!"), payload->getFields()[8]->getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Tell all your friends about your new bot!"), payload->getFields()[8]->getDescription()); - CPPUNIT_ASSERT_EQUAL(String("foo"), boost::dynamic_pointer_cast<UntypedFormField>(payload->getFields()[9])->getValue()[0]); - CPPUNIT_ASSERT_EQUAL(String("baz"), boost::dynamic_pointer_cast<UntypedFormField>(payload->getFields()[9])->getValue()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), boost::dynamic_pointer_cast<UntypedFormField>(payload->getFields()[9])->getValue()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("baz"), boost::dynamic_pointer_cast<UntypedFormField>(payload->getFields()[9])->getValue()[1]); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h b/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h index ee64181..2c88955 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h +++ b/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h @@ -26,11 +26,11 @@ namespace Swift { delete xmlParser; } - bool parse(const String& data) { + bool parse(const std::string& data) { return xmlParser->parse(data); } - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (level == 0) { CPPUNIT_ASSERT(!payloadParser.get()); PayloadParserFactory* payloadParserFactory = factories.getPayloadParserFactory(element, ns, attributes); @@ -41,12 +41,12 @@ namespace Swift { level++; } - virtual void handleEndElement(const String& element, const String& ns) { + virtual void handleEndElement(const std::string& element, const std::string& ns) { level--; payloadParser->handleEndElement(element, ns); } - virtual void handleCharacterData(const String& data) { + virtual void handleCharacterData(const std::string& data) { payloadParser->handleCharacterData(data); } diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp index 0fe58e0..867b25f 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp @@ -40,7 +40,7 @@ class PrivateStorageParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(payload); boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload()); CPPUNIT_ASSERT(storage); - CPPUNIT_ASSERT_EQUAL(String("Alice"), storage->getRooms()[0].nick); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), storage->getRooms()[0].nick); CPPUNIT_ASSERT_EQUAL(JID("swift@rooms.swift.im"), storage->getRooms()[0].jid); } @@ -75,7 +75,7 @@ class PrivateStorageParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(payload); boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload()); CPPUNIT_ASSERT(storage); - CPPUNIT_ASSERT_EQUAL(String("Rabbit"), storage->getRooms()[0].nick); + CPPUNIT_ASSERT_EQUAL(std::string("Rabbit"), storage->getRooms()[0].nick); } void testParse_UnsupportedPayload() { diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp index bb21f05..8885974 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp @@ -25,7 +25,7 @@ class RawXMLPayloadParserTest : public CppUnit::TestFixture RawXMLPayloadParser testling; PayloadParserTester parser(&testling); - String xml = + std::string xml = "<foo foo-attr=\"foo-val\" xmlns=\"ns:foo\">" "<bar bar-attr=\"bar-val\" xmlns=\"ns:bar\"/>" "<baz baz-attr=\"baz-val\" xmlns=\"ns:baz\"/>" diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp index 18b194e..026ef2c 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp @@ -37,7 +37,7 @@ class ResourceBindParserTest : public CppUnit::TestFixture CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>someresource</resource></bind>")); ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("someresource"), payload->getResource()); + CPPUNIT_ASSERT_EQUAL(std::string("someresource"), payload->getResource()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp index b55a340..1bcea0e 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp @@ -37,15 +37,15 @@ class RosterParserTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size()); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].getJID()); - CPPUNIT_ASSERT_EQUAL(String("Foo @ Bar"), items[0].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::From, items[0].getSubscription()); CPPUNIT_ASSERT(items[0].getSubscriptionRequested()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].getGroups().size()); - CPPUNIT_ASSERT_EQUAL(String("Group 1"), items[0].getGroups()[0]); - CPPUNIT_ASSERT_EQUAL(String("Group 2"), items[0].getGroups()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]); CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].getJID()); - CPPUNIT_ASSERT_EQUAL(String("Baz"), items[1].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].getName()); CPPUNIT_ASSERT_EQUAL(RosterItemPayload::None, items[1].getSubscription()); CPPUNIT_ASSERT(!items[1].getSubscriptionRequested()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].getGroups().size()); @@ -67,9 +67,9 @@ class RosterParserTest : public CppUnit::TestFixture const RosterPayload::RosterItemPayloads& items = payload->getItems(); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), items.size()); - CPPUNIT_ASSERT_EQUAL(String("Group 1"), items[0].getGroups()[0]); - CPPUNIT_ASSERT_EQUAL(String("Group 2"), items[0].getGroups()[1]); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]); + CPPUNIT_ASSERT_EQUAL(std::string( "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>" "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>" ), items[0].getUnknownContent()); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp index 1d94c15..3d3bc7b 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp @@ -31,7 +31,7 @@ class SearchPayloadParserTest : public CppUnit::TestFixture { )); SearchPayload::ref payload = parser.getPayload<SearchPayload>(); - CPPUNIT_ASSERT_EQUAL(String("Foo"), *payload->getInstructions()); + CPPUNIT_ASSERT_EQUAL(std::string("Foo"), *payload->getInstructions()); CPPUNIT_ASSERT(payload->getFirst()); CPPUNIT_ASSERT(payload->getLast()); CPPUNIT_ASSERT(!payload->getNick()); @@ -60,10 +60,10 @@ class SearchPayloadParserTest : public CppUnit::TestFixture { SearchPayload::ref payload = parser.getPayload<SearchPayload>(); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getItems().size())); CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.com"), payload->getItems()[0].jid); - CPPUNIT_ASSERT_EQUAL(String("Juliet"), payload->getItems()[0].first); - CPPUNIT_ASSERT_EQUAL(String("Capulet"), payload->getItems()[0].last); - CPPUNIT_ASSERT_EQUAL(String("JuliC"), payload->getItems()[0].nick); - CPPUNIT_ASSERT_EQUAL(String("juliet@shakespeare.lit"), payload->getItems()[0].email); + CPPUNIT_ASSERT_EQUAL(std::string("Juliet"), payload->getItems()[0].first); + CPPUNIT_ASSERT_EQUAL(std::string("Capulet"), payload->getItems()[0].last); + CPPUNIT_ASSERT_EQUAL(std::string("JuliC"), payload->getItems()[0].nick); + CPPUNIT_ASSERT_EQUAL(std::string("juliet@shakespeare.lit"), payload->getItems()[0].email); CPPUNIT_ASSERT_EQUAL(JID("tybalt@shakespeare.lit"), payload->getItems()[1].jid); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp index 9891330..0812c6b 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp @@ -39,12 +39,12 @@ class SecurityLabelParserTest : public CppUnit::TestFixture "</securitylabel>")); SecurityLabel* payload = dynamic_cast<SecurityLabel*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("SECRET"), payload->getDisplayMarking()); - CPPUNIT_ASSERT_EQUAL(String("black"), payload->getForegroundColor()); - CPPUNIT_ASSERT_EQUAL(String("red"), payload->getBackgroundColor()); - CPPUNIT_ASSERT_EQUAL(String("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabel()); - CPPUNIT_ASSERT_EQUAL(String("<icismlabel classification=\"S\" disseminationControls=\"FOUO\" ownerProducer=\"USA\" xmlns=\"http://example.gov/IC-ISM/0\"/>"), payload->getEquivalentLabels()[0]); - CPPUNIT_ASSERT_EQUAL(String("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"), payload->getEquivalentLabels()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("SECRET"), payload->getDisplayMarking()); + CPPUNIT_ASSERT_EQUAL(std::string("black"), payload->getForegroundColor()); + CPPUNIT_ASSERT_EQUAL(std::string("red"), payload->getBackgroundColor()); + CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabel()); + CPPUNIT_ASSERT_EQUAL(std::string("<icismlabel classification=\"S\" disseminationControls=\"FOUO\" ownerProducer=\"USA\" xmlns=\"http://example.gov/IC-ISM/0\"/>"), payload->getEquivalentLabels()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"), payload->getEquivalentLabels()[1]); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp index b9eedb3..9925e34 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp @@ -37,14 +37,14 @@ class SecurityLabelsCatalogParserTest : public CppUnit::TestFixture "</catalog>")); SecurityLabelsCatalog* payload = dynamic_cast<SecurityLabelsCatalog*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("Default"), payload->getName()); - CPPUNIT_ASSERT_EQUAL(String("an example set of labels"), payload->getDescription()); + CPPUNIT_ASSERT_EQUAL(std::string("Default"), payload->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("an example set of labels"), payload->getDescription()); CPPUNIT_ASSERT_EQUAL(JID("example.com"), payload->getTo()); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getLabels().size())); - CPPUNIT_ASSERT_EQUAL(String("SECRET"), payload->getLabels()[0].getDisplayMarking()); - CPPUNIT_ASSERT_EQUAL(String("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabels()[0].getLabel()); - CPPUNIT_ASSERT_EQUAL(String("CONFIDENTIAL"), payload->getLabels()[1].getDisplayMarking()); - CPPUNIT_ASSERT_EQUAL(String("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>"), payload->getLabels()[1].getLabel()); + CPPUNIT_ASSERT_EQUAL(std::string("SECRET"), payload->getLabels()[0].getDisplayMarking()); + CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabels()[0].getLabel()); + CPPUNIT_ASSERT_EQUAL(std::string("CONFIDENTIAL"), payload->getLabels()[1].getDisplayMarking()); + CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>"), payload->getLabels()[1].getLabel()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp index ae1bbb6..3689f10 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp @@ -32,9 +32,9 @@ class SoftwareVersionParserTest : public CppUnit::TestFixture "</query>")); SoftwareVersion* payload = dynamic_cast<SoftwareVersion*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("myclient"), payload->getName()); - CPPUNIT_ASSERT_EQUAL(String("1.0"), payload->getVersion()); - CPPUNIT_ASSERT_EQUAL(String("Mac OS X"), payload->getOS()); + CPPUNIT_ASSERT_EQUAL(std::string("myclient"), payload->getName()); + CPPUNIT_ASSERT_EQUAL(std::string("1.0"), payload->getVersion()); + CPPUNIT_ASSERT_EQUAL(std::string("Mac OS X"), payload->getOS()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp index a0d3ae7..7791f5f 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp @@ -27,7 +27,7 @@ class StatusParserTest : public CppUnit::TestFixture CPPUNIT_ASSERT(parser.parse("<status>foo<baz>bar</baz>fum</status>")); Status* payload = dynamic_cast<Status*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("foobarfum"), payload->getText()); + CPPUNIT_ASSERT_EQUAL(std::string("foobarfum"), payload->getText()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp index cad3b5c..88730b7 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp @@ -38,11 +38,11 @@ class StorageParserTest : public CppUnit::TestFixture { Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get()); std::vector<Storage::Room> rooms = payload->getRooms(); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(rooms.size())); - CPPUNIT_ASSERT_EQUAL(String("Council of Oberon"), rooms[0].name); + CPPUNIT_ASSERT_EQUAL(std::string("Council of Oberon"), rooms[0].name); CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), rooms[0].jid); CPPUNIT_ASSERT(rooms[0].autoJoin); - CPPUNIT_ASSERT_EQUAL(String("Puck"), rooms[0].nick); - CPPUNIT_ASSERT_EQUAL(String("MyPass"), rooms[0].password); + CPPUNIT_ASSERT_EQUAL(std::string("Puck"), rooms[0].nick); + CPPUNIT_ASSERT_EQUAL(std::string("MyPass"), rooms[0].password); } void testParse_MultipleRooms() { @@ -61,9 +61,9 @@ class StorageParserTest : public CppUnit::TestFixture { Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get()); std::vector<Storage::Room> rooms = payload->getRooms(); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(rooms.size())); - CPPUNIT_ASSERT_EQUAL(String("Council of Oberon"), rooms[0].name); + CPPUNIT_ASSERT_EQUAL(std::string("Council of Oberon"), rooms[0].name); CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), rooms[0].jid); - CPPUNIT_ASSERT_EQUAL(String("Tea party"), rooms[1].name); + CPPUNIT_ASSERT_EQUAL(std::string("Tea party"), rooms[1].name); CPPUNIT_ASSERT_EQUAL(JID("teaparty@wonderland.lit"), rooms[1].jid); } @@ -78,8 +78,8 @@ class StorageParserTest : public CppUnit::TestFixture { Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get()); std::vector<Storage::URL> urls = payload->getURLs(); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(urls.size())); - CPPUNIT_ASSERT_EQUAL(String("Complete Works of Shakespeare"), urls[0].name); - CPPUNIT_ASSERT_EQUAL(String("http://the-tech.mit.edu/Shakespeare/"), urls[0].url); + CPPUNIT_ASSERT_EQUAL(std::string("Complete Works of Shakespeare"), urls[0].name); + CPPUNIT_ASSERT_EQUAL(std::string("http://the-tech.mit.edu/Shakespeare/"), urls[0].url); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp index ca8e353..8001487 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp @@ -42,13 +42,13 @@ class StreamInitiationParserTest : public CppUnit::TestFixture { StreamInitiation::ref si = parser.getPayload<StreamInitiation>(); CPPUNIT_ASSERT(si->getIsFileTransfer()); CPPUNIT_ASSERT(si->getFileInfo()); - CPPUNIT_ASSERT_EQUAL(String("test.txt"), si->getFileInfo()->name); + CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), si->getFileInfo()->name); CPPUNIT_ASSERT_EQUAL(1022, si->getFileInfo()->size); - CPPUNIT_ASSERT_EQUAL(String("This is info about the file."), si->getFileInfo()->description); + CPPUNIT_ASSERT_EQUAL(std::string("This is info about the file."), si->getFileInfo()->description); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(si->getProvidedMethods().size())); - CPPUNIT_ASSERT_EQUAL(String("http://jabber.org/protocol/bytestreams"), si->getProvidedMethods()[0]); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:oob"), si->getProvidedMethods()[1]); - CPPUNIT_ASSERT_EQUAL(String("http://jabber.org/protocol/ibb"), si->getProvidedMethods()[2]); + CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getProvidedMethods()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:oob"), si->getProvidedMethods()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/ibb"), si->getProvidedMethods()[2]); } void testParse_Response() { @@ -68,7 +68,7 @@ class StreamInitiationParserTest : public CppUnit::TestFixture { StreamInitiation::ref si = parser.getPayload<StreamInitiation>(); CPPUNIT_ASSERT(si->getIsFileTransfer()); - CPPUNIT_ASSERT_EQUAL(String("http://jabber.org/protocol/bytestreams"), si->getRequestedMethod()); + CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getRequestedMethod()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp index aed04bc..909401d 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp @@ -53,23 +53,23 @@ class VCardParserTest : public CppUnit::TestFixture { "</vCard>")); boost::shared_ptr<VCard> payload = boost::dynamic_pointer_cast<VCard>(parser.getPayload()); - CPPUNIT_ASSERT_EQUAL(String("2.0"), payload->getVersion()); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), payload->getFullName()); - CPPUNIT_ASSERT_EQUAL(String("Alice"), payload->getGivenName()); - CPPUNIT_ASSERT_EQUAL(String("In"), payload->getMiddleName()); - CPPUNIT_ASSERT_EQUAL(String("Wonderland"), payload->getFamilyName()); - CPPUNIT_ASSERT_EQUAL(String("Mrs"), payload->getPrefix()); - CPPUNIT_ASSERT_EQUAL(String("PhD"), payload->getSuffix()); - CPPUNIT_ASSERT_EQUAL(String("DreamGirl"), payload->getNickname()); - CPPUNIT_ASSERT_EQUAL(String("<BDAY xmlns=\"vcard-temp\">1234</BDAY><MAILER xmlns=\"vcard-temp\">mutt</MAILER>"), payload->getUnknownContent()); + CPPUNIT_ASSERT_EQUAL(std::string("2.0"), payload->getVersion()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), payload->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice"), payload->getGivenName()); + CPPUNIT_ASSERT_EQUAL(std::string("In"), payload->getMiddleName()); + CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), payload->getFamilyName()); + CPPUNIT_ASSERT_EQUAL(std::string("Mrs"), payload->getPrefix()); + CPPUNIT_ASSERT_EQUAL(std::string("PhD"), payload->getSuffix()); + CPPUNIT_ASSERT_EQUAL(std::string("DreamGirl"), payload->getNickname()); + CPPUNIT_ASSERT_EQUAL(std::string("<BDAY xmlns=\"vcard-temp\">1234</BDAY><MAILER xmlns=\"vcard-temp\">mutt</MAILER>"), payload->getUnknownContent()); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getEMailAddresses().size())); - CPPUNIT_ASSERT_EQUAL(String("alice@wonderland.lit"), payload->getEMailAddresses()[0].address); + CPPUNIT_ASSERT_EQUAL(std::string("alice@wonderland.lit"), payload->getEMailAddresses()[0].address); CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isHome); CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isInternet); CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isPreferred); CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isWork); CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isX400); - CPPUNIT_ASSERT_EQUAL(String("alice@teaparty.lit"), payload->getEMailAddresses()[1].address); + CPPUNIT_ASSERT_EQUAL(std::string("alice@teaparty.lit"), payload->getEMailAddresses()[1].address); CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isHome); CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isInternet); CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isPreferred); @@ -92,7 +92,7 @@ class VCardParserTest : public CppUnit::TestFixture { "</vCard>")); VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), payload->getPhotoType()); + CPPUNIT_ASSERT_EQUAL(std::string("image/jpeg"), payload->getPhotoType()); CPPUNIT_ASSERT_EQUAL(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), payload->getPhoto()); } @@ -105,7 +105,7 @@ class VCardParserTest : public CppUnit::TestFixture { "</vCard>")); VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("mynick"), payload->getNickname()); + CPPUNIT_ASSERT_EQUAL(std::string("mynick"), payload->getNickname()); } }; diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp index 79df412..b8ea4fb 100644 --- a/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp +++ b/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp @@ -30,7 +30,7 @@ class VCardUpdateParserTest : public CppUnit::TestFixture "</x>")); VCardUpdate* payload = dynamic_cast<VCardUpdate*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("sha1-hash-of-image"), payload->getPhotoHash()); + CPPUNIT_ASSERT_EQUAL(std::string("sha1-hash-of-image"), payload->getPhotoHash()); } }; diff --git a/Swiften/Parser/PayloadParsers/VCardParser.cpp b/Swiften/Parser/PayloadParsers/VCardParser.cpp index 2f1f8dc..61af0ba 100644 --- a/Swiften/Parser/PayloadParsers/VCardParser.cpp +++ b/Swiften/Parser/PayloadParsers/VCardParser.cpp @@ -14,9 +14,9 @@ namespace Swift { VCardParser::VCardParser() : unknownContentParser_(NULL) { } -void VCardParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void VCardParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { elementStack_.push_back(element); - String elementHierarchy = getElementHierarchy(); + std::string elementHierarchy = getElementHierarchy(); if (elementHierarchy == "/vCard/EMAIL") { currentEMailAddress_ = VCard::EMailAddress(); } @@ -32,12 +32,12 @@ void VCardParser::handleStartElement(const String& element, const String& ns, co currentText_ = ""; } -void VCardParser::handleEndElement(const String& element, const String& ns) { +void VCardParser::handleEndElement(const std::string& element, const std::string& ns) { if (unknownContentParser_) { unknownContentParser_->handleEndElement(element, ns); } - String elementHierarchy = getElementHierarchy(); + std::string elementHierarchy = getElementHierarchy(); if (elementHierarchy == "/vCard/VERSION") { getPayloadInternal()->setVersion(currentText_); } @@ -104,16 +104,16 @@ void VCardParser::handleEndElement(const String& element, const String& ns) { elementStack_.pop_back(); } -void VCardParser::handleCharacterData(const String& text) { +void VCardParser::handleCharacterData(const std::string& text) { if (unknownContentParser_) { unknownContentParser_->handleCharacterData(text); } currentText_ += text; } -String VCardParser::getElementHierarchy() const { - String result; - foreach(const String& element, elementStack_) { +std::string VCardParser::getElementHierarchy() const { + std::string result; + foreach(const std::string& element, elementStack_) { result += "/" + element; } return result; diff --git a/Swiften/Parser/PayloadParsers/VCardParser.h b/Swiften/Parser/PayloadParsers/VCardParser.h index f912ff1..c858e61 100644 --- a/Swiften/Parser/PayloadParsers/VCardParser.h +++ b/Swiften/Parser/PayloadParsers/VCardParser.h @@ -16,17 +16,17 @@ namespace Swift { public: VCardParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: - String getElementHierarchy() const; + std::string getElementHierarchy() const; private: - std::vector<String> elementStack_; + std::vector<std::string> elementStack_; VCard::EMailAddress currentEMailAddress_; SerializingParser* unknownContentParser_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp b/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp index 08d2d35..2218d75 100644 --- a/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp +++ b/Swiften/Parser/PayloadParsers/VCardUpdateParser.cpp @@ -11,21 +11,21 @@ namespace Swift { VCardUpdateParser::VCardUpdateParser() : level_(TopLevel) { } -void VCardUpdateParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void VCardUpdateParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { if (level_ == PayloadLevel) { currentText_ = ""; } ++level_; } -void VCardUpdateParser::handleEndElement(const String& element, const String&) { +void VCardUpdateParser::handleEndElement(const std::string& element, const std::string&) { --level_; if (level_ == PayloadLevel && element == "photo") { getPayloadInternal()->setPhotoHash(currentText_); } } -void VCardUpdateParser::handleCharacterData(const String& text) { +void VCardUpdateParser::handleCharacterData(const std::string& text) { currentText_ += text; } diff --git a/Swiften/Parser/PayloadParsers/VCardUpdateParser.h b/Swiften/Parser/PayloadParsers/VCardUpdateParser.h index df86123..b91c17b 100644 --- a/Swiften/Parser/PayloadParsers/VCardUpdateParser.h +++ b/Swiften/Parser/PayloadParsers/VCardUpdateParser.h @@ -16,9 +16,9 @@ namespace Swift { public: VCardUpdateParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -26,6 +26,6 @@ namespace Swift { PayloadLevel = 1 }; int level_; - String currentText_; + std::string currentText_; }; } diff --git a/Swiften/Parser/SerializingParser.cpp b/Swiften/Parser/SerializingParser.cpp index c25b07f..43dfc51 100644 --- a/Swiften/Parser/SerializingParser.cpp +++ b/Swiften/Parser/SerializingParser.cpp @@ -14,7 +14,7 @@ namespace Swift { SerializingParser::SerializingParser() { } -void SerializingParser::handleStartElement(const String& tag, const String& ns, const AttributeMap& attributes) { +void SerializingParser::handleStartElement(const std::string& tag, const std::string& ns, const AttributeMap& attributes) { boost::shared_ptr<XMLElement> element(new XMLElement(tag, ns)); for (AttributeMap::const_iterator i = attributes.begin(); i != attributes.end(); ++i) { element->setAttribute((*i).first, (*i).second); @@ -29,18 +29,18 @@ void SerializingParser::handleStartElement(const String& tag, const String& ns, elementStack_.push_back(element); } -void SerializingParser::handleEndElement(const String&, const String&) { +void SerializingParser::handleEndElement(const std::string&, const std::string&) { assert(!elementStack_.empty()); elementStack_.pop_back(); } -void SerializingParser::handleCharacterData(const String& data) { +void SerializingParser::handleCharacterData(const std::string& data) { if (!elementStack_.empty()) { (*(elementStack_.end()-1))->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(data))); } } -String SerializingParser::getResult() const { +std::string SerializingParser::getResult() const { return (rootElement_ ? rootElement_->serialize() : ""); } diff --git a/Swiften/Parser/SerializingParser.h b/Swiften/Parser/SerializingParser.h index 4927677..6276ea0 100644 --- a/Swiften/Parser/SerializingParser.h +++ b/Swiften/Parser/SerializingParser.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_SerializingParser_H #define SWIFTEN_SerializingParser_H -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/AttributeMap.h" #include "Swiften/Serializer/XML/XMLElement.h" @@ -16,11 +16,11 @@ namespace Swift { public: SerializingParser(); - void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes); - void handleEndElement(const String& element, const String& ns); - void handleCharacterData(const String& data); + void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes); + void handleEndElement(const std::string& element, const std::string& ns); + void handleCharacterData(const std::string& data); - String getResult() const; + std::string getResult() const; private: std::vector< boost::shared_ptr<XMLElement> > elementStack_; diff --git a/Swiften/Parser/StanzaAckParser.cpp b/Swiften/Parser/StanzaAckParser.cpp index d85eb9b..9d029cc 100644 --- a/Swiften/Parser/StanzaAckParser.cpp +++ b/Swiften/Parser/StanzaAckParser.cpp @@ -13,11 +13,11 @@ namespace Swift { StanzaAckParser::StanzaAckParser() : GenericElementParser<StanzaAck>(), depth(0) { } -void StanzaAckParser::handleStartElement(const String&, const String&, const AttributeMap& attributes) { +void StanzaAckParser::handleStartElement(const std::string&, const std::string&, const AttributeMap& attributes) { if (depth == 0) { - String handledStanzasString = attributes.getAttribute("h"); + std::string handledStanzasString = attributes.getAttribute("h"); try { - getElementGeneric()->setHandledStanzasCount(boost::lexical_cast<int>(handledStanzasString.getUTF8String())); + getElementGeneric()->setHandledStanzasCount(boost::lexical_cast<int>(handledStanzasString)); } catch (const boost::bad_lexical_cast &) { } @@ -25,7 +25,7 @@ void StanzaAckParser::handleStartElement(const String&, const String&, const Att ++depth; } -void StanzaAckParser::handleEndElement(const String&, const String&) { +void StanzaAckParser::handleEndElement(const std::string&, const std::string&) { --depth; } diff --git a/Swiften/Parser/StanzaAckParser.h b/Swiften/Parser/StanzaAckParser.h index fa9644f..4078dc1 100644 --- a/Swiften/Parser/StanzaAckParser.h +++ b/Swiften/Parser/StanzaAckParser.h @@ -14,8 +14,8 @@ namespace Swift { public: StanzaAckParser(); - virtual void handleStartElement(const String&, const String& ns, const AttributeMap&); - virtual void handleEndElement(const String&, const String& ns); + virtual void handleStartElement(const std::string&, const std::string& ns, const AttributeMap&); + virtual void handleEndElement(const std::string&, const std::string& ns); private: int depth; diff --git a/Swiften/Parser/StanzaParser.cpp b/Swiften/Parser/StanzaParser.cpp index 637b45a..64c4901 100644 --- a/Swiften/Parser/StanzaParser.cpp +++ b/Swiften/Parser/StanzaParser.cpp @@ -23,7 +23,7 @@ StanzaParser::StanzaParser(PayloadParserFactoryCollection* factories) : StanzaParser::~StanzaParser() { } -void StanzaParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void StanzaParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (inStanza()) { if (!inPayload()) { assert(!currentPayloadParser_.get()); @@ -56,7 +56,7 @@ void StanzaParser::handleStartElement(const String& element, const String& ns, c ++currentDepth_; } -void StanzaParser::handleEndElement(const String& element, const String& ns) { +void StanzaParser::handleEndElement(const std::string& element, const std::string& ns) { assert(inStanza()); if (inPayload()) { assert(currentPayloadParser_.get()); @@ -75,7 +75,7 @@ void StanzaParser::handleEndElement(const String& element, const String& ns) { } } -void StanzaParser::handleCharacterData(const String& data) { +void StanzaParser::handleCharacterData(const std::string& data) { if (currentPayloadParser_.get()) { currentPayloadParser_->handleCharacterData(data); } diff --git a/Swiften/Parser/StanzaParser.h b/Swiften/Parser/StanzaParser.h index 60ddafc..df01943 100644 --- a/Swiften/Parser/StanzaParser.h +++ b/Swiften/Parser/StanzaParser.h @@ -9,7 +9,7 @@ #include <boost/noncopyable.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Stanza.h" #include "Swiften/Parser/ElementParser.h" #include "Swiften/Parser/AttributeMap.h" @@ -23,9 +23,9 @@ namespace Swift { StanzaParser(PayloadParserFactoryCollection* factories); ~StanzaParser(); - void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes); - void handleEndElement(const String& element, const String& ns); - void handleCharacterData(const String& data); + void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes); + void handleEndElement(const std::string& element, const std::string& ns); + void handleCharacterData(const std::string& data); virtual boost::shared_ptr<Element> getElement() const = 0; virtual void handleStanzaAttributes(const AttributeMap&) {} diff --git a/Swiften/Parser/StreamErrorParser.cpp b/Swiften/Parser/StreamErrorParser.cpp index d222c40..f4530f9 100644 --- a/Swiften/Parser/StreamErrorParser.cpp +++ b/Swiften/Parser/StreamErrorParser.cpp @@ -11,11 +11,11 @@ namespace Swift { StreamErrorParser::StreamErrorParser() : level(TopLevel) { } -void StreamErrorParser::handleStartElement(const String&, const String&, const AttributeMap&) { +void StreamErrorParser::handleStartElement(const std::string&, const std::string&, const AttributeMap&) { ++level; } -void StreamErrorParser::handleEndElement(const String& element, const String& ns) { +void StreamErrorParser::handleEndElement(const std::string& element, const std::string& ns) { --level; if (level == ElementLevel && ns == "urn:ietf:params:xml:ns:xmpp-streams") { if (element == "text") { @@ -102,7 +102,7 @@ void StreamErrorParser::handleEndElement(const String& element, const String& ns } } -void StreamErrorParser::handleCharacterData(const String& data) { +void StreamErrorParser::handleCharacterData(const std::string& data) { currentText += data; } diff --git a/Swiften/Parser/StreamErrorParser.h b/Swiften/Parser/StreamErrorParser.h index a2aaa67..61c8c12 100644 --- a/Swiften/Parser/StreamErrorParser.h +++ b/Swiften/Parser/StreamErrorParser.h @@ -14,9 +14,9 @@ namespace Swift { public: StreamErrorParser(); - virtual void handleStartElement(const String& element, const String&, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String&); - virtual void handleCharacterData(const String& data); + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes); + virtual void handleEndElement(const std::string& element, const std::string&); + virtual void handleCharacterData(const std::string& data); private: enum Level { @@ -24,6 +24,6 @@ namespace Swift { ElementLevel = 1 }; int level; - String currentText; + std::string currentText; }; } diff --git a/Swiften/Parser/StreamFeaturesParser.cpp b/Swiften/Parser/StreamFeaturesParser.cpp index 02e70be..377f215 100644 --- a/Swiften/Parser/StreamFeaturesParser.cpp +++ b/Swiften/Parser/StreamFeaturesParser.cpp @@ -11,7 +11,7 @@ namespace Swift { StreamFeaturesParser::StreamFeaturesParser() : GenericElementParser<StreamFeatures>(), currentDepth_(0), inMechanisms_(false), inMechanism_(false), inCompression_(false), inCompressionMethod_(false) { } -void StreamFeaturesParser::handleStartElement(const String& element, const String& ns, const AttributeMap&) { +void StreamFeaturesParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap&) { if (currentDepth_ == 1) { if (element == "starttls" && ns == "urn:ietf:params:xml:ns:xmpp-tls") { getElementGeneric()->setHasStartTLS(); @@ -45,7 +45,7 @@ void StreamFeaturesParser::handleStartElement(const String& element, const Strin ++currentDepth_; } -void StreamFeaturesParser::handleEndElement(const String&, const String&) { +void StreamFeaturesParser::handleEndElement(const std::string&, const std::string&) { --currentDepth_; if (currentDepth_ == 1) { inCompression_ = false; @@ -63,7 +63,7 @@ void StreamFeaturesParser::handleEndElement(const String&, const String&) { } } -void StreamFeaturesParser::handleCharacterData(const String& data) { +void StreamFeaturesParser::handleCharacterData(const std::string& data) { currentText_ += data; } diff --git a/Swiften/Parser/StreamFeaturesParser.h b/Swiften/Parser/StreamFeaturesParser.h index a12644d..ee65a2a 100644 --- a/Swiften/Parser/StreamFeaturesParser.h +++ b/Swiften/Parser/StreamFeaturesParser.h @@ -7,7 +7,7 @@ #ifndef SWIFTEN_STREAMFEATURESPARSER_H #define SWIFTEN_STREAMFEATURESPARSER_H -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/GenericElementParser.h" #include "Swiften/Elements/StreamFeatures.h" @@ -17,13 +17,13 @@ namespace Swift { StreamFeaturesParser(); private: - void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes); - void handleEndElement(const String& element, const String& ns); - void handleCharacterData(const String& data); + void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes); + void handleEndElement(const std::string& element, const std::string& ns); + void handleCharacterData(const std::string& data); private: int currentDepth_; - String currentText_; + std::string currentText_; bool inMechanisms_; bool inMechanism_; bool inCompression_; diff --git a/Swiften/Parser/UnitTest/ParserTester.h b/Swiften/Parser/UnitTest/ParserTester.h index bdb9291..970c1be 100644 --- a/Swiften/Parser/UnitTest/ParserTester.h +++ b/Swiften/Parser/UnitTest/ParserTester.h @@ -25,19 +25,19 @@ namespace Swift { delete xmlParser_; } - bool parse(const String& data) { + bool parse(const std::string& data) { return xmlParser_->parse(data); } - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { parser_->handleStartElement(element, ns, attributes); } - virtual void handleEndElement(const String& element, const String& ns) { + virtual void handleEndElement(const std::string& element, const std::string& ns) { parser_->handleEndElement(element, ns); } - virtual void handleCharacterData(const String& data) { + virtual void handleCharacterData(const std::string& data) { parser_->handleCharacterData(data); } diff --git a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp b/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp index 668846f..8e49764 100644 --- a/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp +++ b/Swiften/Parser/UnitTest/PayloadParserFactoryCollectionTest.cpp @@ -91,12 +91,12 @@ class PayloadParserFactoryCollectionTest : public CppUnit::TestFixture private: struct DummyFactory : public PayloadParserFactory { - DummyFactory(const String& element = "") : element(element) {} - virtual bool canParse(const String& e, const String&, const AttributeMap&) const { - return element.isEmpty() ? true : element == e; + DummyFactory(const std::string& element = "") : element(element) {} + virtual bool canParse(const std::string& e, const std::string&, const AttributeMap&) const { + return element.empty() ? true : element == e; } virtual PayloadParser* createPayloadParser() { return NULL; } - String element; + std::string element; }; }; diff --git a/Swiften/Parser/UnitTest/SerializingParserTest.cpp b/Swiften/Parser/UnitTest/SerializingParserTest.cpp index e7018a2..c0af493 100644 --- a/Swiften/Parser/UnitTest/SerializingParserTest.cpp +++ b/Swiften/Parser/UnitTest/SerializingParserTest.cpp @@ -35,7 +35,7 @@ class SerializingParserTest : public CppUnit::TestFixture "</html>" "</message>")); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<message to=\"me@foo.com\" type=\"chat\">" "<body>Hello<&World</body>" "<html xmlns=\"http://www.w3.org/1999/xhtml\">foo<b xmlns=\"http://www.w3.org/1999/xhtml\">bar</b>baz</html>" @@ -45,7 +45,7 @@ class SerializingParserTest : public CppUnit::TestFixture void testParse_Empty() { SerializingParser testling; - CPPUNIT_ASSERT_EQUAL(String(""), testling.getResult()); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.getResult()); } void testParse_ToplevelCharacterData() { @@ -57,7 +57,7 @@ class SerializingParserTest : public CppUnit::TestFixture testling.handleEndElement("message", ""); testling.handleCharacterData("bar"); - CPPUNIT_ASSERT_EQUAL(String("<message/>"), testling.getResult()); + CPPUNIT_ASSERT_EQUAL(std::string("<message/>"), testling.getResult()); } }; diff --git a/Swiften/Parser/UnitTest/StanzaParserTest.cpp b/Swiften/Parser/UnitTest/StanzaParserTest.cpp index 48d24da..d57f798 100644 --- a/Swiften/Parser/UnitTest/StanzaParserTest.cpp +++ b/Swiften/Parser/UnitTest/StanzaParserTest.cpp @@ -115,7 +115,7 @@ class StanzaParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(JID("foo@example.com/blo"), testling.getStanza()->getTo()); CPPUNIT_ASSERT_EQUAL(JID("bar@example.com/baz"), testling.getStanza()->getFrom()); - CPPUNIT_ASSERT_EQUAL(String("id-123"), testling.getStanza()->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("id-123"), testling.getStanza()->getID()); } private: @@ -132,14 +132,14 @@ class StanzaParserTest : public CppUnit::TestFixture { public: MyPayload1Parser() {} - virtual void handleStartElement(const String& element, const String&, const AttributeMap&) { + virtual void handleStartElement(const std::string& element, const std::string&, const AttributeMap&) { if (element != "mypayload1") { getPayloadInternal()->hasChild = true; } } - virtual void handleEndElement(const String&, const String&) {} - virtual void handleCharacterData(const String&) {} + virtual void handleEndElement(const std::string&, const std::string&) {} + virtual void handleCharacterData(const std::string&) {} }; class MyPayload1ParserFactory : public PayloadParserFactory @@ -149,7 +149,7 @@ class StanzaParserTest : public CppUnit::TestFixture { PayloadParser* createPayloadParser() { return new MyPayload1Parser(); } - bool canParse(const String& element, const String&, const AttributeMap&) const { + bool canParse(const std::string& element, const std::string&, const AttributeMap&) const { return element == "mypayload1"; } }; @@ -165,9 +165,9 @@ class StanzaParserTest : public CppUnit::TestFixture { public: MyPayload2Parser() {} - virtual void handleStartElement(const String&, const String&, const AttributeMap&) {} - virtual void handleEndElement(const String&, const String&) {} - virtual void handleCharacterData(const String&) {} + virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) {} + virtual void handleEndElement(const std::string&, const std::string&) {} + virtual void handleCharacterData(const std::string&) {} }; @@ -177,7 +177,7 @@ class StanzaParserTest : public CppUnit::TestFixture { MyPayload2ParserFactory() {} PayloadParser* createPayloadParser() { return new MyPayload2Parser(); } - bool canParse(const String& element, const String&, const AttributeMap&) const { + bool canParse(const std::string& element, const std::string&, const AttributeMap&) const { return element == "mypayload2"; } }; diff --git a/Swiften/Parser/UnitTest/XMLParserTest.cpp b/Swiften/Parser/UnitTest/XMLParserTest.cpp index 2aae4cd..426b7a0 100644 --- a/Swiften/Parser/UnitTest/XMLParserTest.cpp +++ b/Swiften/Parser/UnitTest/XMLParserTest.cpp @@ -8,7 +8,7 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/XMLParserClient.h" #ifdef HAVE_EXPAT #include "Swiften/Parser/ExpatParser.h" @@ -45,23 +45,23 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), client_.events[0].attributes.size()); - CPPUNIT_ASSERT_EQUAL(String("get"), client_.events[0].attributes["type"]); - CPPUNIT_ASSERT_EQUAL(String(), client_.events[0].ns); + CPPUNIT_ASSERT_EQUAL(std::string("get"), client_.events[0].attributes["type"]); + CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[0].ns); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[1].data); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), client_.events[1].attributes.size()); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[1].ns); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[2].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[2].ns); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[2].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[3].data); - CPPUNIT_ASSERT_EQUAL(String(), client_.events[3].ns); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string(), client_.events[3].ns); } void testParse_ElementInNamespacedElement() { @@ -75,24 +75,24 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), client_.events[0].attributes.size()); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[0].ns); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[0].ns); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("name"), client_.events[1].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[1].ns); + CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[1].ns); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("Swift"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("Swift"), client_.events[2].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("name"), client_.events[3].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[3].ns); + CPPUNIT_ASSERT_EQUAL(std::string("name"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[3].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[4].data); - CPPUNIT_ASSERT_EQUAL(String("jabber:iq:version"), client_.events[4].ns); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[4].data); + CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:version"), client_.events[4].ns); } void testParse_CharacterData() { @@ -103,25 +103,25 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(7), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("html"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].data); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("i"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[2].data); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("bli"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string("bli"), client_.events[3].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[4].type); - CPPUNIT_ASSERT_EQUAL(String("i"), client_.events[4].data); + CPPUNIT_ASSERT_EQUAL(std::string("i"), client_.events[4].data); CPPUNIT_ASSERT_EQUAL(Client::CharacterData, client_.events[5].type); - CPPUNIT_ASSERT_EQUAL(String("blo"), client_.events[5].data); + CPPUNIT_ASSERT_EQUAL(std::string("blo"), client_.events[5].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[6].type); - CPPUNIT_ASSERT_EQUAL(String("html"), client_.events[6].data); + CPPUNIT_ASSERT_EQUAL(std::string("html"), client_.events[6].data); } void testParse_NamespacePrefix() { @@ -132,20 +132,20 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("x"), client_.events[0].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[0].ns); + CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[0].ns); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("y"), client_.events[1].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[1].ns); + CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[1].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("y"), client_.events[2].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[2].ns); + CPPUNIT_ASSERT_EQUAL(std::string("y"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[2].ns); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[3].type); - CPPUNIT_ASSERT_EQUAL(String("x"), client_.events[3].data); - CPPUNIT_ASSERT_EQUAL(String("bla"), client_.events[3].ns); + CPPUNIT_ASSERT_EQUAL(std::string("x"), client_.events[3].data); + CPPUNIT_ASSERT_EQUAL(std::string("bla"), client_.events[3].ns); } void testParse_UnhandledXML() { @@ -156,10 +156,10 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data); } void testParse_InvalidXML() { @@ -184,10 +184,10 @@ class XMLParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("iq"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("iq"), client_.events[1].data); } void testParse_WhitespaceInAttribute() { @@ -199,11 +199,11 @@ class XMLParserTest : public CppUnit::TestFixture { "<presence/>")); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), client_.events.size()); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("query"), client_.events[0].data); + CPPUNIT_ASSERT_EQUAL(std::string("query"), client_.events[0].data); CPPUNIT_ASSERT_EQUAL(Client::StartElement, client_.events[1].type); - CPPUNIT_ASSERT_EQUAL(String("presence"), client_.events[1].data); + CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[1].data); CPPUNIT_ASSERT_EQUAL(Client::EndElement, client_.events[2].type); - CPPUNIT_ASSERT_EQUAL(String("presence"), client_.events[2].data); + CPPUNIT_ASSERT_EQUAL(std::string("presence"), client_.events[2].data); } private: @@ -213,30 +213,30 @@ class XMLParserTest : public CppUnit::TestFixture { struct Event { Event( Type type, - const String& data, - const String& ns, + const std::string& data, + const std::string& ns, const AttributeMap& attributes) : type(type), data(data), ns(ns), attributes(attributes) {} - Event(Type type, const String& data, const String& ns = String()) + Event(Type type, const std::string& data, const std::string& ns = std::string()) : type(type), data(data), ns(ns) {} Type type; - String data; - String ns; + std::string data; + std::string ns; AttributeMap attributes; }; Client() {} - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { events.push_back(Event(StartElement, element, ns, attributes)); } - virtual void handleEndElement(const String& element, const String& ns) { + virtual void handleEndElement(const std::string& element, const std::string& ns) { events.push_back(Event(EndElement, element, ns)); } - virtual void handleCharacterData(const String& data) { + virtual void handleCharacterData(const std::string& data) { events.push_back(Event(CharacterData, data)); } diff --git a/Swiften/Parser/UnitTest/XMPPParserTest.cpp b/Swiften/Parser/UnitTest/XMPPParserTest.cpp index 1eaa798..8ce96d8 100644 --- a/Swiften/Parser/UnitTest/XMPPParserTest.cpp +++ b/Swiften/Parser/UnitTest/XMPPParserTest.cpp @@ -9,7 +9,7 @@ #include <vector> #include "Swiften/Elements/ProtocolHeader.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/XMPPParser.h" #include "Swiften/Parser/ElementParser.h" #include "Swiften/Parser/XMPPParserClient.h" @@ -49,7 +49,7 @@ class XMPPParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(client_.events.size())); CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("example.com"), client_.events[0].header->getTo()); + CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getTo()); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[1].type); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[2].type); CPPUNIT_ASSERT_EQUAL(Client::ElementEvent, client_.events[3].type); @@ -64,8 +64,8 @@ class XMPPParserTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(client_.events.size())); CPPUNIT_ASSERT_EQUAL(Client::StreamStart, client_.events[0].type); - CPPUNIT_ASSERT_EQUAL(String("example.com"), client_.events[0].header->getFrom()); - CPPUNIT_ASSERT_EQUAL(String("aeab"), client_.events[0].header->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("example.com"), client_.events[0].header->getFrom()); + CPPUNIT_ASSERT_EQUAL(std::string("aeab"), client_.events[0].header->getID()); } diff --git a/Swiften/Parser/UnknownPayloadParser.h b/Swiften/Parser/UnknownPayloadParser.h index c652cf1..8750f22 100644 --- a/Swiften/Parser/UnknownPayloadParser.h +++ b/Swiften/Parser/UnknownPayloadParser.h @@ -12,15 +12,15 @@ #include "Swiften/Parser/PayloadParser.h" namespace Swift { - class String; + class UnknownPayloadParser : public PayloadParser { public: UnknownPayloadParser() {} - virtual void handleStartElement(const String&, const String&, const AttributeMap&) {} - virtual void handleEndElement(const String&, const String&) {} - virtual void handleCharacterData(const String&) {} + virtual void handleStartElement(const std::string&, const std::string&, const AttributeMap&) {} + virtual void handleEndElement(const std::string&, const std::string&) {} + virtual void handleCharacterData(const std::string&) {} virtual boost::shared_ptr<Payload> getPayload() const { return boost::shared_ptr<Payload>(); diff --git a/Swiften/Parser/XMLParser.h b/Swiften/Parser/XMLParser.h index 80d23f4..69a6ecf 100644 --- a/Swiften/Parser/XMLParser.h +++ b/Swiften/Parser/XMLParser.h @@ -4,11 +4,12 @@ * See Documentation/Licenses/GPLv3.txt for more information. */ -#ifndef SWIFTEN_XMLParser_H -#define SWIFTEN_XMLParser_H +#pragma once + +#include <string> namespace Swift { - class String; + class XMLParserClient; class XMLParser { @@ -16,7 +17,7 @@ namespace Swift { XMLParser(XMLParserClient* client); virtual ~XMLParser(); - virtual bool parse(const String& data) = 0; + virtual bool parse(const std::string& data) = 0; protected: XMLParserClient* getClient() const { @@ -27,5 +28,3 @@ namespace Swift { XMLParserClient* client_; }; } - -#endif diff --git a/Swiften/Parser/XMLParserClient.h b/Swiften/Parser/XMLParserClient.h index 9c2df6f..089ef35 100644 --- a/Swiften/Parser/XMLParserClient.h +++ b/Swiften/Parser/XMLParserClient.h @@ -10,15 +10,15 @@ #include "Swiften/Parser/AttributeMap.h" namespace Swift { - class String; + class XMLParserClient { public: virtual ~XMLParserClient(); - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) = 0; - virtual void handleEndElement(const String& element, const String& ns) = 0; - virtual void handleCharacterData(const String& data) = 0; + virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) = 0; + virtual void handleEndElement(const std::string& element, const std::string& ns) = 0; + virtual void handleCharacterData(const std::string& data) = 0; }; } diff --git a/Swiften/Parser/XMPPParser.cpp b/Swiften/Parser/XMPPParser.cpp index b274c94..1fb7682 100644 --- a/Swiften/Parser/XMPPParser.cpp +++ b/Swiften/Parser/XMPPParser.cpp @@ -10,7 +10,7 @@ #include <cassert> #include "Swiften/Elements/ProtocolHeader.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Parser/XMLParser.h" #include "Swiften/Parser/PlatformXMLParserFactory.h" #include "Swiften/Parser/XMPPParserClient.h" @@ -62,12 +62,12 @@ XMPPParser::~XMPPParser() { delete xmlParser_; } -bool XMPPParser::parse(const String& data) { +bool XMPPParser::parse(const std::string& data) { bool xmlParseResult = xmlParser_->parse(data); return xmlParseResult && !parseErrorOccurred_; } -void XMPPParser::handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { +void XMPPParser::handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) { if (!parseErrorOccurred_) { if (level_ == TopLevel) { if (element == "stream" && ns == "http://etherx.jabber.org/streams") { @@ -93,7 +93,7 @@ void XMPPParser::handleStartElement(const String& element, const String& ns, con ++level_; } -void XMPPParser::handleEndElement(const String& element, const String& ns) { +void XMPPParser::handleEndElement(const std::string& element, const std::string& ns) { assert(level_ > TopLevel); --level_; if (!parseErrorOccurred_) { @@ -113,7 +113,7 @@ void XMPPParser::handleEndElement(const String& element, const String& ns) { } } -void XMPPParser::handleCharacterData(const String& data) { +void XMPPParser::handleCharacterData(const std::string& data) { if (!parseErrorOccurred_) { if (currentElementParser_) { currentElementParser_->handleCharacterData(data); @@ -124,7 +124,7 @@ void XMPPParser::handleCharacterData(const String& data) { } } -ElementParser* XMPPParser::createElementParser(const String& element, const String& ns) { +ElementParser* XMPPParser::createElementParser(const std::string& element, const std::string& ns) { if (element == "presence") { return new PresenceParser(payloadParserFactories_); } diff --git a/Swiften/Parser/XMPPParser.h b/Swiften/Parser/XMPPParser.h index c1a9323..8a00995 100644 --- a/Swiften/Parser/XMPPParser.h +++ b/Swiften/Parser/XMPPParser.h @@ -16,7 +16,7 @@ namespace Swift { class XMLParser; class XMPPParserClient; - class String; + class ElementParser; class PayloadParserFactoryCollection; @@ -27,17 +27,17 @@ namespace Swift { PayloadParserFactoryCollection* payloadParserFactories); ~XMPPParser(); - bool parse(const String&); + bool parse(const std::string&); private: virtual void handleStartElement( - const String& element, - const String& ns, + const std::string& element, + const std::string& ns, const AttributeMap& attributes); - virtual void handleEndElement(const String& element, const String& ns); - virtual void handleCharacterData(const String& data); + virtual void handleEndElement(const std::string& element, const std::string& ns); + virtual void handleCharacterData(const std::string& data); - ElementParser* createElementParser(const String& element, const String& xmlns); + ElementParser* createElementParser(const std::string& element, const std::string& xmlns); private: XMLParser* xmlParser_; diff --git a/Swiften/Parser/XMPPParserClient.h b/Swiften/Parser/XMPPParserClient.h index 24b78e2..1ddb86d 100644 --- a/Swiften/Parser/XMPPParserClient.h +++ b/Swiften/Parser/XMPPParserClient.h @@ -11,7 +11,7 @@ #include "Swiften/Elements/Element.h" namespace Swift { - class String; + class ProtocolHeader; class XMPPParserClient { diff --git a/Swiften/Presence/PresenceOracle.h b/Swiften/Presence/PresenceOracle.h index 4e16e41..f98e1cd 100644 --- a/Swiften/Presence/PresenceOracle.h +++ b/Swiften/Presence/PresenceOracle.h @@ -8,7 +8,7 @@ #include <map> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Presence.h" #include "Swiften/Base/boost_bsignals.h" diff --git a/Swiften/Presence/SubscriptionManager.h b/Swiften/Presence/SubscriptionManager.h index fdf3c04..ad55f9d 100644 --- a/Swiften/Presence/SubscriptionManager.h +++ b/Swiften/Presence/SubscriptionManager.h @@ -8,7 +8,7 @@ #include <map> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/Base/boost_bsignals.h" #include "Swiften/Elements/Presence.h" @@ -33,9 +33,9 @@ namespace Swift { * received. This is useful when the subscriber adds extensions to * the request. */ - boost::signal<void (const JID&, const String&, Presence::ref)> onPresenceSubscriptionRequest; + boost::signal<void (const JID&, const std::string&, Presence::ref)> onPresenceSubscriptionRequest; - boost::signal<void (const JID&, const String&)> onPresenceSubscriptionRevoked; + boost::signal<void (const JID&, const std::string&)> onPresenceSubscriptionRevoked; private: void handleIncomingPresence(Presence::ref presence); diff --git a/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp b/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp index 3a6487a..132c865 100644 --- a/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp +++ b/Swiften/Presence/UnitTest/PayloadAddingPresenceSenderTest.cpp @@ -44,7 +44,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->sendPresence(Presence::create("bar")); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex<Presence>(0)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex<Presence>(0)->getStatus()); CPPUNIT_ASSERT(stanzaChannel->getStanzaAtIndex<Presence>(0)->getPayload<MyPayload>()); } @@ -55,7 +55,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->sendPresence(Presence::create("bar")); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex<Presence>(0)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex<Presence>(0)->getStatus()); CPPUNIT_ASSERT(!stanzaChannel->getStanzaAtIndex<Presence>(0)->getPayload<MyPayload>()); } @@ -76,7 +76,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->setPayload(MyPayload::create("foo")); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex<Presence>(1)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex<Presence>(1)->getStatus()); CPPUNIT_ASSERT(stanzaChannel->getStanzaAtIndex<Presence>(1)->getPayload<MyPayload>()); } @@ -102,7 +102,7 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { testling->setPayload(MyPayload::create("foo")); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(stanzaChannel->sentStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("bar"), stanzaChannel->getStanzaAtIndex<Presence>(2)->getStatus()); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), stanzaChannel->getStanzaAtIndex<Presence>(2)->getStatus()); } private: @@ -114,13 +114,13 @@ class PayloadAddingPresenceSenderTest : public CppUnit::TestFixture { struct MyPayload : public Payload { typedef boost::shared_ptr<MyPayload> ref; - MyPayload(const String& body) : body(body) {} + MyPayload(const std::string& body) : body(body) {} - static ref create(const String& body) { + static ref create(const std::string& body) { return ref(new MyPayload(body)); } - String body; + std::string body; }; private: diff --git a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp index aa450a2..24cc62c 100644 --- a/Swiften/Presence/UnitTest/PresenceOracleTest.cpp +++ b/Swiften/Presence/UnitTest/PresenceOracleTest.cpp @@ -122,7 +122,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { } void testSubscriptionRequest() { - String reasonText = "Because I want to"; + std::string reasonText = "Because I want to"; JID sentJID = JID("me@example.com"); boost::shared_ptr<Presence> sentPresence(new Presence()); @@ -147,14 +147,14 @@ class PresenceOracleTest : public CppUnit::TestFixture { } private: - Presence::ref makeOnline(const String& resource, int priority) { + Presence::ref makeOnline(const std::string& resource, int priority) { Presence::ref presence(new Presence()); presence->setPriority(priority); presence->setFrom(JID("alice@wonderland.lit/" + resource)); return presence; } - Presence::ref makeOffline(const String& resource) { + Presence::ref makeOffline(const std::string& resource) { Presence::ref presence(new Presence()); presence->setFrom(JID("alice@wonderland.lit" + resource)); presence->setType(Presence::Unavailable); @@ -165,7 +165,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { changes.push_back(newPresence); } - void handlePresenceSubscriptionRequest(const JID& jid, const String& reason) { + void handlePresenceSubscriptionRequest(const JID& jid, const std::string& reason) { SubscriptionRequestInfo subscriptionRequest; subscriptionRequest.jid = jid; subscriptionRequest.reason = reason; @@ -181,7 +181,7 @@ class PresenceOracleTest : public CppUnit::TestFixture { private: struct SubscriptionRequestInfo { JID jid; - String reason; + std::string reason; }; PresenceOracle* oracle_; SubscriptionManager* subscriptionManager_; diff --git a/Swiften/QA/ClientTest/ClientTest.cpp b/Swiften/QA/ClientTest/ClientTest.cpp index 0fb02ad..35bb096 100644 --- a/Swiften/QA/ClientTest/ClientTest.cpp +++ b/Swiften/QA/ClientTest/ClientTest.cpp @@ -59,7 +59,7 @@ int main(int, char**) { return -1; } - client = new Swift::Client(JID(jid), String(pass), &networkFactories); + client = new Swift::Client(JID(jid), std::string(pass), &networkFactories); ClientXMLTracer* tracer = new ClientXMLTracer(client); client->onConnected.connect(&handleConnected); client->setAlwaysTrustCertificates(); diff --git a/Swiften/QA/DNSSDTest/DNSSDTest.cpp b/Swiften/QA/DNSSDTest/DNSSDTest.cpp index 7aa7b5e..1bf0965 100644 --- a/Swiften/QA/DNSSDTest/DNSSDTest.cpp +++ b/Swiften/QA/DNSSDTest/DNSSDTest.cpp @@ -65,18 +65,18 @@ class DNSSDTest : public CppUnit::TestFixture { // Check that our registered queries are correct CPPUNIT_ASSERT_EQUAL(1, static_cast<int>((registered.size()))); - CPPUNIT_ASSERT_EQUAL(String("DNSSDTest"), registered[0].getName()); - CPPUNIT_ASSERT_EQUAL(String("local"), registered[0].getDomain()); - CPPUNIT_ASSERT_EQUAL(String("_presence._tcp"), registered[0].getType()); + CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), registered[0].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("local"), registered[0].getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), registered[0].getType()); // Check that our browse query discovered us std::sort(added.begin(), added.end()); CPPUNIT_ASSERT(added.size() >= 1); //for (size_t i = 0; i < added.size(); ++i) { for (size_t i = 0; i < added.size(); ++i) { - CPPUNIT_ASSERT_EQUAL(String("DNSSDTest"), added[i].getName()); - CPPUNIT_ASSERT_EQUAL(String("local"), added[i].getDomain()); - CPPUNIT_ASSERT_EQUAL(String("_presence._tcp"), added[i].getType()); + CPPUNIT_ASSERT_EQUAL(std::string("DNSSDTest"), added[i].getName()); + CPPUNIT_ASSERT_EQUAL(std::string("local"), added[i].getDomain()); + CPPUNIT_ASSERT_EQUAL(std::string("_presence._tcp"), added[i].getType()); CPPUNIT_ASSERT(added[i].getNetworkInterfaceID() != 0); } diff --git a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp index 57e7a5a..82a8be2 100644 --- a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp +++ b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp @@ -8,7 +8,7 @@ #include <cppunit/extensions/TestFactoryRegistry.h> #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Network/BoostConnectionServer.h" #include "Swiften/Network/BoostIOServiceThread.h" #include "Swiften/EventLoop/DummyEventLoop.h" diff --git a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp index 61572a0..928e3db 100644 --- a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp +++ b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include <boost/smart_ptr/make_shared.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/sleep.h" #include "Swiften/Network/BoostConnection.h" #include "Swiften/Network/HostAddress.h" diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp index b0316fe..a0a7e7b 100644 --- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp +++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp @@ -11,7 +11,7 @@ #include <algorithm> #include "Swiften/Base/sleep.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/Network/PlatformDomainNameResolver.h" #include "Swiften/Network/DomainNameAddressQuery.h" @@ -147,19 +147,19 @@ class DomainNameResolverTest : public CppUnit::TestFixture { waitForResults(); CPPUNIT_ASSERT_EQUAL(4, static_cast<int>(serviceQueryResult.size())); - CPPUNIT_ASSERT_EQUAL(String("xmpp1.test.swift.im"), serviceQueryResult[0].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp1.test.swift.im"), serviceQueryResult[0].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[0].port); CPPUNIT_ASSERT_EQUAL(0, serviceQueryResult[0].priority); CPPUNIT_ASSERT_EQUAL(1, serviceQueryResult[0].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp-invalid.test.swift.im"), serviceQueryResult[1].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp-invalid.test.swift.im"), serviceQueryResult[1].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[1].port); CPPUNIT_ASSERT_EQUAL(1, serviceQueryResult[1].priority); CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[1].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp3.test.swift.im"), serviceQueryResult[2].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp3.test.swift.im"), serviceQueryResult[2].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[2].port); CPPUNIT_ASSERT_EQUAL(3, serviceQueryResult[2].priority); CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[2].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp2.test.swift.im"), serviceQueryResult[3].hostname); + CPPUNIT_ASSERT_EQUAL(std::string("xmpp2.test.swift.im"), serviceQueryResult[3].hostname); CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[3].port); CPPUNIT_ASSERT_EQUAL(5, serviceQueryResult[3].priority); CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[3].weight); @@ -169,7 +169,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture { } private: - boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const String& domain) { + boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const std::string& domain) { boost::shared_ptr<DomainNameAddressQuery> result = resolver->createAddressQuery(domain); result->onResult.connect(boost::bind(&DomainNameResolverTest::handleAddressQueryResult, this, _1, _2)); return result; @@ -183,7 +183,7 @@ class DomainNameResolverTest : public CppUnit::TestFixture { resultsAvailable = true; } - boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const String& domain) { + boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& domain) { boost::shared_ptr<DomainNameServiceQuery> result = resolver->createServiceQuery(domain); result->onResult.connect(boost::bind(&DomainNameResolverTest::handleServiceQueryResult, this, _1)); return result; diff --git a/Swiften/QA/ReconnectTest/ReconnectTest.cpp b/Swiften/QA/ReconnectTest/ReconnectTest.cpp index e74ae27..117cfa3 100644 --- a/Swiften/QA/ReconnectTest/ReconnectTest.cpp +++ b/Swiften/QA/ReconnectTest/ReconnectTest.cpp @@ -61,7 +61,7 @@ int main(int, char**) { } JID jid(jidChars); - String pass(passChars); + std::string pass(passChars); client_ = new Swift::Client(jid, pass); handleTick(boost::shared_ptr<BoostTimer>()); diff --git a/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp b/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp index b8e9fd4..925c775 100644 --- a/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp +++ b/Swiften/QA/StorageTest/FileReadBytestreamTest.cpp @@ -34,7 +34,7 @@ class FileReadBytestreamTest : public CppUnit::TestFixture { ByteArray result = testling->read(10); - CPPUNIT_ASSERT_EQUAL(String("/*\n * Copy"), result.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("/*\n * Copy"), result.toString()); } void testRead_Twice() { @@ -43,7 +43,7 @@ class FileReadBytestreamTest : public CppUnit::TestFixture { testling->read(10); ByteArray result = testling->read(10); - CPPUNIT_ASSERT_EQUAL(String("right (c) "), result.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("right (c) "), result.toString()); } void testIsFinished_NotFinished() { diff --git a/Swiften/QA/StorageTest/VCardFileStorageTest.cpp b/Swiften/QA/StorageTest/VCardFileStorageTest.cpp index 7ef1fd5..992ee50 100644 --- a/Swiften/QA/StorageTest/VCardFileStorageTest.cpp +++ b/Swiften/QA/StorageTest/VCardFileStorageTest.cpp @@ -6,6 +6,7 @@ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> +#include <boost/algorithm/string.hpp> #include "Swiften/VCards/VCardFileStorage.h" #include "Swiften/JID/JID.h" @@ -44,7 +45,7 @@ class VCardFileStorageTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(boost::filesystem::exists(vcardFile)); ByteArray data; data.readFromFile(vcardFile.string()); - CPPUNIT_ASSERT(data.toString().beginsWith("<vCard xmlns=\"vcard-temp\">")); + CPPUNIT_ASSERT(boost::starts_with(data.toString(), "<vCard xmlns=\"vcard-temp\">")); } void testGetVCard() { @@ -54,7 +55,7 @@ class VCardFileStorageTest : public CppUnit::TestFixture { testling->setVCard(JID("alice@wonderland.lit"), vcard); VCard::ref result = testling->getVCard(JID("alice@wonderland.lit")); - CPPUNIT_ASSERT_EQUAL(String("Alice In Wonderland"), result->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), result->getFullName()); } void testGetVCard_FileDoesNotExist() { diff --git a/Swiften/QA/TLSTest/CertificateTest.cpp b/Swiften/QA/TLSTest/CertificateTest.cpp index 769272b..0f37fde 100644 --- a/Swiften/QA/TLSTest/CertificateTest.cpp +++ b/Swiften/QA/TLSTest/CertificateTest.cpp @@ -42,7 +42,7 @@ class CertificateTest : public CppUnit::TestFixture { void testConstructFromDER() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getCommonNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getCommonNames()[0]); } void testToDER() { @@ -55,7 +55,7 @@ class CertificateTest : public CppUnit::TestFixture { void testGetSubjectName() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); - CPPUNIT_ASSERT_EQUAL(String("/description=114072-VMk8pdi1aj5kTXxO/C=US/ST=Colorado/L=Denver/O=Peter Saint-Andre/OU=StartCom Trusted Certificate Member/CN=*.jabber.org/emailAddress=hostmaster@jabber.org"), testling->getSubjectName()); + CPPUNIT_ASSERT_EQUAL(std::string("/description=114072-VMk8pdi1aj5kTXxO/C=US/ST=Colorado/L=Denver/O=Peter Saint-Andre/OU=StartCom Trusted Certificate Member/CN=*.jabber.org/emailAddress=hostmaster@jabber.org"), testling->getSubjectName()); } */ @@ -63,29 +63,29 @@ class CertificateTest : public CppUnit::TestFixture { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(testling->getCommonNames().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getCommonNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getCommonNames()[0]); } void testGetSRVNames() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(testling->getSRVNames().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getSRVNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getSRVNames()[0]); } void testGetDNSNames() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(testling->getDNSNames().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getDNSNames()[0]); - CPPUNIT_ASSERT_EQUAL(String("jabber.org"), testling->getDNSNames()[1]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getDNSNames()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("jabber.org"), testling->getDNSNames()[1]); } void testGetXMPPAddresses() { Certificate::ref testling = certificateFactory->createCertificateFromDER(certificateData); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(testling->getXMPPAddresses().size())); - CPPUNIT_ASSERT_EQUAL(String("*.jabber.org"), testling->getXMPPAddresses()[0]); + CPPUNIT_ASSERT_EQUAL(std::string("*.jabber.org"), testling->getXMPPAddresses()[0]); } private: diff --git a/Swiften/Queries/DummyIQChannel.h b/Swiften/Queries/DummyIQChannel.h index 92b7f2b..f740b5c 100644 --- a/Swiften/Queries/DummyIQChannel.h +++ b/Swiften/Queries/DummyIQChannel.h @@ -19,7 +19,7 @@ namespace Swift { iqs_.push_back(iq); } - virtual String getNewIQID() { + virtual std::string getNewIQID() { return "test-id"; } diff --git a/Swiften/Queries/GetResponder.h b/Swiften/Queries/GetResponder.h index 2201b95..ca3b677 100644 --- a/Swiften/Queries/GetResponder.h +++ b/Swiften/Queries/GetResponder.h @@ -15,6 +15,6 @@ namespace Swift { GetResponder(IQRouter* router) : Responder<T>(router) {} private: - virtual bool handleSetRequest(const JID&, const JID&, const String&, boost::shared_ptr<T>) { return false; } + virtual bool handleSetRequest(const JID&, const JID&, const std::string&, boost::shared_ptr<T>) { return false; } }; } diff --git a/Swiften/Queries/IQChannel.h b/Swiften/Queries/IQChannel.h index e700b51..22b7572 100644 --- a/Swiften/Queries/IQChannel.h +++ b/Swiften/Queries/IQChannel.h @@ -10,7 +10,7 @@ #include "Swiften/Base/boost_bsignals.h" #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/IQ.h" namespace Swift { @@ -19,7 +19,7 @@ namespace Swift { virtual ~IQChannel(); virtual void sendIQ(boost::shared_ptr<IQ>) = 0; - virtual String getNewIQID() = 0; + virtual std::string getNewIQID() = 0; virtual bool isAvailable() const = 0; diff --git a/Swiften/Queries/IQRouter.cpp b/Swiften/Queries/IQRouter.cpp index a08668a..1bfff70 100644 --- a/Swiften/Queries/IQRouter.cpp +++ b/Swiften/Queries/IQRouter.cpp @@ -87,7 +87,7 @@ void IQRouter::sendIQ(boost::shared_ptr<IQ> iq) { channel_->sendIQ(iq); } -String IQRouter::getNewIQID() { +std::string IQRouter::getNewIQID() { return channel_->getNewIQID(); } diff --git a/Swiften/Queries/IQRouter.h b/Swiften/Queries/IQRouter.h index 42fa6e9..312dca8 100644 --- a/Swiften/Queries/IQRouter.h +++ b/Swiften/Queries/IQRouter.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include <vector> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/IQ.h" namespace Swift { @@ -45,7 +45,7 @@ namespace Swift { * it. */ void sendIQ(boost::shared_ptr<IQ> iq); - String getNewIQID(); + std::string getNewIQID(); bool isAvailable(); diff --git a/Swiften/Queries/Request.h b/Swiften/Queries/Request.h index 4ed8dc2..eee89e9 100644 --- a/Swiften/Queries/Request.h +++ b/Swiften/Queries/Request.h @@ -11,7 +11,7 @@ #include <boost/optional.hpp> #include <boost/enable_shared_from_this.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Queries/IQHandler.h" #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/Payload.h" @@ -66,7 +66,7 @@ namespace Swift { IQ::Type type_; JID receiver_; boost::shared_ptr<Payload> payload_; - String id_; + std::string id_; bool sent_; }; } diff --git a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp index 71c6cf0..b7c36cb 100644 --- a/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp +++ b/Swiften/Queries/Requests/UnitTest/GetPrivateStorageRequestTest.cpp @@ -26,8 +26,8 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { public: class MyPayload : public Payload { public: - MyPayload(const String& text = "") : text(text) {} - String text; + MyPayload(const std::string& text = "") : text(text) {} + std::string text; }; public: @@ -61,7 +61,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { channel->onIQReceived(createResponse("test-id", "foo")); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(responses.size())); - CPPUNIT_ASSERT_EQUAL(String("foo"), boost::dynamic_pointer_cast<MyPayload>(responses[0])->text); + CPPUNIT_ASSERT_EQUAL(std::string("foo"), boost::dynamic_pointer_cast<MyPayload>(responses[0])->text); } void testHandleResponse_Error() { @@ -84,7 +84,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { } } - boost::shared_ptr<IQ> createResponse(const String& id, const String& text) { + boost::shared_ptr<IQ> createResponse(const std::string& id, const std::string& text) { boost::shared_ptr<IQ> iq(new IQ(IQ::Result)); boost::shared_ptr<PrivateStorage> storage(new PrivateStorage()); storage->setPayload(boost::shared_ptr<Payload>(new MyPayload(text))); @@ -93,7 +93,7 @@ class GetPrivateStorageRequestTest : public CppUnit::TestFixture { return iq; } - boost::shared_ptr<IQ> createError(const String& id) { + boost::shared_ptr<IQ> createError(const std::string& id) { boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); iq->setID(id); return iq; diff --git a/Swiften/Queries/Responder.h b/Swiften/Queries/Responder.h index 322ba60..2ce8f10 100644 --- a/Swiften/Queries/Responder.h +++ b/Swiften/Queries/Responder.h @@ -57,40 +57,40 @@ namespace Swift { * * This method is implemented in the concrete subclasses. */ - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0; + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0; /** * Handle an incoming IQ-Set request containing a payload of class PAYLOAD_TYPE. * * This method is implemented in the concrete subclasses. */ - virtual bool handleSetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0; + virtual bool handleSetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) = 0; /** * Convenience function for sending an IQ response. */ - void sendResponse(const JID& to, const String& id, boost::shared_ptr<PAYLOAD_TYPE> payload) { + void sendResponse(const JID& to, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) { router_->sendIQ(IQ::createResult(to, id, payload)); } /** * Convenience function for sending an IQ response, with a specific from address. */ - void sendResponse(const JID& to, const JID& from, const String& id, boost::shared_ptr<PAYLOAD_TYPE> payload) { + void sendResponse(const JID& to, const JID& from, const std::string& id, boost::shared_ptr<PAYLOAD_TYPE> payload) { router_->sendIQ(IQ::createResult(to, from, id, payload)); } /** * Convenience function for responding with an error. */ - void sendError(const JID& to, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { + void sendError(const JID& to, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { router_->sendIQ(IQ::createError(to, id, condition, type)); } /** * Convenience function for responding with an error from a specific from address. */ - void sendError(const JID& to, const JID& from, const String& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { + void sendError(const JID& to, const JID& from, const std::string& id, ErrorPayload::Condition condition, ErrorPayload::Type type) { router_->sendIQ(IQ::createError(to, from, id, condition, type)); } diff --git a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp index cc58114..0b8362c 100644 --- a/Swiften/Queries/Responders/SoftwareVersionResponder.cpp +++ b/Swiften/Queries/Responders/SoftwareVersionResponder.cpp @@ -12,12 +12,12 @@ namespace Swift { SoftwareVersionResponder::SoftwareVersionResponder(IQRouter* router) : GetResponder<SoftwareVersion>(router) { } -void SoftwareVersionResponder::setVersion(const String& client, const String& version) { +void SoftwareVersionResponder::setVersion(const std::string& client, const std::string& version) { this->client = client; this->version = version; } -bool SoftwareVersionResponder::handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<SoftwareVersion>) { +bool SoftwareVersionResponder::handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<SoftwareVersion>) { sendResponse(from, id, boost::shared_ptr<SoftwareVersion>(new SoftwareVersion(client, version))); return true; } diff --git a/Swiften/Queries/Responders/SoftwareVersionResponder.h b/Swiften/Queries/Responders/SoftwareVersionResponder.h index 9da82b0..f6a3d52 100644 --- a/Swiften/Queries/Responders/SoftwareVersionResponder.h +++ b/Swiften/Queries/Responders/SoftwareVersionResponder.h @@ -16,13 +16,13 @@ namespace Swift { public: SoftwareVersionResponder(IQRouter* router); - void setVersion(const String& client, const String& version); + void setVersion(const std::string& client, const std::string& version); private: - virtual bool handleGetRequest(const JID& from, const JID& to, const String& id, boost::shared_ptr<SoftwareVersion> payload); + virtual bool handleGetRequest(const JID& from, const JID& to, const std::string& id, boost::shared_ptr<SoftwareVersion> payload); private: - String client; - String version; + std::string client; + std::string version; }; } diff --git a/Swiften/Queries/SetResponder.h b/Swiften/Queries/SetResponder.h index a04be64..ec3460c 100644 --- a/Swiften/Queries/SetResponder.h +++ b/Swiften/Queries/SetResponder.h @@ -15,6 +15,6 @@ namespace Swift { SetResponder(IQRouter* router) : Responder<T>(router) {} private: - virtual bool handleGetRequest(const JID&, const JID&, const String&, boost::shared_ptr<T>) { return false; } + virtual bool handleGetRequest(const JID&, const JID&, const std::string&, boost::shared_ptr<T>) { return false; } }; } diff --git a/Swiften/Queries/UnitTest/RequestTest.cpp b/Swiften/Queries/UnitTest/RequestTest.cpp index 5013053..e99149e 100644 --- a/Swiften/Queries/UnitTest/RequestTest.cpp +++ b/Swiften/Queries/UnitTest/RequestTest.cpp @@ -30,8 +30,8 @@ class RequestTest : public CppUnit::TestFixture { public: class MyPayload : public Payload { public: - MyPayload(const String& s = "") : text_(s) {} - String text_; + MyPayload(const std::string& s = "") : text_(s) {} + std::string text_; }; typedef GenericRequest<MyPayload> MyRequest; @@ -57,7 +57,7 @@ class RequestTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size())); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), channel_->iqs_[0]->getTo()); CPPUNIT_ASSERT_EQUAL(IQ::Set, channel_->iqs_[0]->getType()); - CPPUNIT_ASSERT_EQUAL(String("test-id"), channel_->iqs_[0]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("test-id"), channel_->iqs_[0]->getID()); } void testSendGet() { @@ -140,19 +140,19 @@ class RequestTest : public CppUnit::TestFixture { else { boost::shared_ptr<MyPayload> payload(boost::dynamic_pointer_cast<MyPayload>(p)); CPPUNIT_ASSERT(payload); - CPPUNIT_ASSERT_EQUAL(String("bar"), payload->text_); + CPPUNIT_ASSERT_EQUAL(std::string("bar"), payload->text_); ++responsesReceived_; } } - boost::shared_ptr<IQ> createResponse(const String& id) { + boost::shared_ptr<IQ> createResponse(const std::string& id) { boost::shared_ptr<IQ> iq(new IQ(IQ::Result)); iq->addPayload(responsePayload_); iq->setID(id); return iq; } - boost::shared_ptr<IQ> createError(const String& id) { + boost::shared_ptr<IQ> createError(const std::string& id) { boost::shared_ptr<IQ> iq(new IQ(IQ::Error)); iq->setID(id); return iq; diff --git a/Swiften/Queries/UnitTest/ResponderTest.cpp b/Swiften/Queries/UnitTest/ResponderTest.cpp index 97eb0c6..c087827 100644 --- a/Swiften/Queries/UnitTest/ResponderTest.cpp +++ b/Swiften/Queries/UnitTest/ResponderTest.cpp @@ -128,15 +128,15 @@ class ResponderTest : public CppUnit::TestFixture { public: MyResponder(IQRouter* router) : Responder<SoftwareVersion>(router), getRequestResponse_(true), setRequestResponse_(true) {} - virtual bool handleGetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<SoftwareVersion> payload) { + virtual bool handleGetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<SoftwareVersion> payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); - CPPUNIT_ASSERT_EQUAL(String("myid"), id); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), id); getPayloads_.push_back(payload); return getRequestResponse_; } - virtual bool handleSetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<SoftwareVersion> payload) { + virtual bool handleSetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<SoftwareVersion> payload) { CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), from); - CPPUNIT_ASSERT_EQUAL(String("myid"), id); + CPPUNIT_ASSERT_EQUAL(std::string("myid"), id); setPayloads_.push_back(payload); return setRequestResponse_; } diff --git a/Swiften/Roster/RosterPushResponder.h b/Swiften/Roster/RosterPushResponder.h index ea7cff5..b38914b 100644 --- a/Swiften/Roster/RosterPushResponder.h +++ b/Swiften/Roster/RosterPushResponder.h @@ -20,7 +20,7 @@ namespace Swift { boost::signal<void (boost::shared_ptr<RosterPayload>)> onRosterReceived; private: - virtual bool handleSetRequest(const JID& from, const JID&, const String& id, boost::shared_ptr<RosterPayload> payload) { + virtual bool handleSetRequest(const JID& from, const JID&, const std::string& id, boost::shared_ptr<RosterPayload> payload) { onRosterReceived(payload); sendResponse(from, id, boost::shared_ptr<RosterPayload>()); return true; diff --git a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp index cabf2bf..4ef1cc1 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterControllerTest.cpp @@ -65,7 +65,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), xmppRoster_->getGroupsForJID(jid1_).size()); CPPUNIT_ASSERT(xmppRoster_->containsJID(jid1_)); - CPPUNIT_ASSERT_EQUAL(String("Bob"), xmppRoster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("Bob"), xmppRoster_->getNameForJID(jid1_)); } void testModify() { @@ -85,7 +85,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("Bob2"), xmppRoster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("Bob2"), xmppRoster_->getNameForJID(jid1_)); } void testRemove() { @@ -135,7 +135,7 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { boost::shared_ptr<RosterPayload> payload4(new RosterPayload()); RosterItemPayload item(jid3_, "Jane", RosterItemPayload::Both); - String janesGroup("Jane's Group"); + std::string janesGroup("Jane's Group"); item.addGroup(janesGroup); payload4->addItem(item); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id4", payload4)); @@ -156,14 +156,14 @@ class XMPPRosterControllerTest : public CppUnit::TestFixture { boost::shared_ptr<RosterPayload> payload6(new RosterPayload()); RosterItemPayload item2(jid2_, "Little Alice", RosterItemPayload::Both); - String alicesGroup("Alice's Group"); + std::string alicesGroup("Alice's Group"); item2.addGroup(alicesGroup); payload6->addItem(item2); channel_->onIQReceived(IQ::createRequest(IQ::Set, JID(), "id6", payload6)); CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("Little Alice"), xmppRoster_->getNameForJID(jid2_)); - CPPUNIT_ASSERT_EQUAL(String("Jane"), xmppRoster_->getNameForJID(jid3_)); + CPPUNIT_ASSERT_EQUAL(std::string("Little Alice"), xmppRoster_->getNameForJID(jid2_)); + CPPUNIT_ASSERT_EQUAL(std::string("Jane"), xmppRoster_->getNameForJID(jid3_)); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), xmppRoster_->getGroupsForJID(jid2_).size()); CPPUNIT_ASSERT_EQUAL(alicesGroup, xmppRoster_->getGroupsForJID(jid2_)[0]); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), xmppRoster_->getGroupsForJID(jid3_).size()); diff --git a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp index 77993ea..edb8271 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp +++ b/Swiften/Roster/UnitTest/XMPPRosterImplTest.cpp @@ -45,21 +45,21 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); roster_->addContact(jid2_, "NameTwo", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid2_)); - CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("NameTwo"), roster_->getNameForJID(jid2_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid2_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); roster_->addContact(jid3_, "NewName", groups2_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid3_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid3_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), roster_->getNameForJID(jid3_)); CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid3_)); } @@ -73,7 +73,7 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { roster_->addContact(jid1_, "NewName2", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("NewName2"), roster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName2"), roster_->getNameForJID(jid1_)); roster_->addContact(jid2_, "NewName3", groups1_, RosterItemPayload::Both); handler_->reset(); roster_->removeContact(jid2_); @@ -89,13 +89,13 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { roster_->addContact(jid1_, "NewName", groups1_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("NewName"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_)); handler_->reset(); roster_->addContact(jid1_, "NameTwo", groups2_, RosterItemPayload::Both); CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent()); CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID()); - CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid1_)); + CPPUNIT_ASSERT_EQUAL(std::string("NameTwo"), roster_->getNameForJID(jid1_)); CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid1_)); } @@ -105,8 +105,8 @@ class XMPPRosterImplTest : public CppUnit::TestFixture { JID jid1_; JID jid2_; JID jid3_; - std::vector<String> groups1_; - std::vector<String> groups2_; + std::vector<std::string> groups1_; + std::vector<std::string> groups2_; }; CPPUNIT_TEST_SUITE_REGISTRATION(XMPPRosterImplTest); diff --git a/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h b/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h index 5e15e9f..1bbd8e9 100644 --- a/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h +++ b/Swiften/Roster/UnitTest/XMPPRosterSignalHandler.h @@ -34,11 +34,11 @@ public: return lastJID_; } - String getLastOldName() { + std::string getLastOldName() { return lastOldName_; } - std::vector<String> getLastOldGroups() { + std::vector<std::string> getLastOldGroups() { return lastOldGroups_; } @@ -57,7 +57,7 @@ private: lastEvent_ = Remove; } - void handleJIDUpdated(const JID& jid, const String& oldName, const std::vector<String>& oldGroups) { + void handleJIDUpdated(const JID& jid, const std::string& oldName, const std::vector<std::string>& oldGroups) { CPPUNIT_ASSERT_EQUAL(None, lastEvent_); lastJID_ = jid; lastOldName_ = oldName; @@ -67,7 +67,7 @@ private: XMPPRosterEvents lastEvent_; JID lastJID_; - String lastOldName_; - std::vector<String> lastOldGroups_; + std::string lastOldName_; + std::vector<std::string> lastOldGroups_; }; diff --git a/Swiften/Roster/XMPPRoster.h b/Swiften/Roster/XMPPRoster.h index 676e8f9..958c1f6 100644 --- a/Swiften/Roster/XMPPRoster.h +++ b/Swiften/Roster/XMPPRoster.h @@ -11,7 +11,7 @@ #include <set> #include "Swiften/Base/boost_bsignals.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/Elements/RosterItemPayload.h" #include <Swiften/Roster/XMPPRosterItem.h> @@ -41,12 +41,12 @@ namespace Swift { /** * Retrieves the stored roster name for the given jid. */ - virtual String getNameForJID(const JID& jid) const = 0; + virtual std::string getNameForJID(const JID& jid) const = 0; /** * Returns the list of groups for the given JID. */ - virtual std::vector<String> getGroupsForJID(const JID& jid) = 0; + virtual std::vector<std::string> getGroupsForJID(const JID& jid) = 0; /** * Retrieve the items in the roster. @@ -61,7 +61,7 @@ namespace Swift { /** * Retrieve the list of (existing) groups. */ - virtual std::set<String> getGroups() const = 0; + virtual std::set<std::string> getGroups() const = 0; public: /** @@ -78,7 +78,7 @@ namespace Swift { * Emitted when the name or the groups of the roster item with the * given JID changes. */ - boost::signal<void (const JID&, const String&, const std::vector<String>&)> onJIDUpdated; + boost::signal<void (const JID&, const std::string&, const std::vector<std::string>&)> onJIDUpdated; /** * Emitted when the roster is reset (e.g. due to logging in/logging out). diff --git a/Swiften/Roster/XMPPRosterController.h b/Swiften/Roster/XMPPRosterController.h index 073a233..28c2541 100644 --- a/Swiften/Roster/XMPPRosterController.h +++ b/Swiften/Roster/XMPPRosterController.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/IQ.h" #include "Swiften/Elements/RosterPayload.h" #include "Swiften/Roster/RosterPushResponder.h" diff --git a/Swiften/Roster/XMPPRosterImpl.cpp b/Swiften/Roster/XMPPRosterImpl.cpp index 3e9e312..8086806 100644 --- a/Swiften/Roster/XMPPRosterImpl.cpp +++ b/Swiften/Roster/XMPPRosterImpl.cpp @@ -12,12 +12,12 @@ namespace Swift { XMPPRosterImpl::XMPPRosterImpl() { } -void XMPPRosterImpl::addContact(const JID& jid, const String& name, const std::vector<String>& groups, RosterItemPayload::Subscription subscription) { +void XMPPRosterImpl::addContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, RosterItemPayload::Subscription subscription) { JID bareJID(jid.toBare()); std::map<JID, XMPPRosterItem>::iterator i = entries_.find(bareJID); if (i != entries_.end()) { - String oldName = i->second.getName(); - std::vector<String> oldGroups = i->second.getGroups(); + std::string oldName = i->second.getName(); + std::vector<std::string> oldGroups = i->second.getGroups(); i->second = XMPPRosterItem(jid, name, groups, subscription); onJIDUpdated(bareJID, oldName, oldGroups); } @@ -41,7 +41,7 @@ bool XMPPRosterImpl::containsJID(const JID& jid) { return entries_.find(JID(jid.toBare())) != entries_.end(); } -String XMPPRosterImpl::getNameForJID(const JID& jid) const { +std::string XMPPRosterImpl::getNameForJID(const JID& jid) const { std::map<JID, XMPPRosterItem>::const_iterator i = entries_.find(jid.toBare()); if (i != entries_.end()) { return i->second.getName(); @@ -51,13 +51,13 @@ String XMPPRosterImpl::getNameForJID(const JID& jid) const { } } -std::vector<String> XMPPRosterImpl::getGroupsForJID(const JID& jid) { +std::vector<std::string> XMPPRosterImpl::getGroupsForJID(const JID& jid) { std::map<JID, XMPPRosterItem>::iterator i = entries_.find(jid.toBare()); if (i != entries_.end()) { return i->second.getGroups(); } else { - return std::vector<String>(); + return std::vector<std::string>(); } } @@ -89,10 +89,10 @@ boost::optional<XMPPRosterItem> XMPPRosterImpl::getItem(const JID& jid) const { } } -std::set<String> XMPPRosterImpl::getGroups() const { - std::set<String> result; +std::set<std::string> XMPPRosterImpl::getGroups() const { + std::set<std::string> result; foreach(const RosterMap::value_type& entry, entries_) { - std::vector<String> groups = entry.second.getGroups(); + std::vector<std::string> groups = entry.second.getGroups(); result.insert(groups.begin(), groups.end()); } return result; diff --git a/Swiften/Roster/XMPPRosterImpl.h b/Swiften/Roster/XMPPRosterImpl.h index f65683f..a44a1ce 100644 --- a/Swiften/Roster/XMPPRosterImpl.h +++ b/Swiften/Roster/XMPPRosterImpl.h @@ -16,18 +16,18 @@ namespace Swift { public: XMPPRosterImpl(); - void addContact(const JID& jid, const String& name, const std::vector<String>& groups, const RosterItemPayload::Subscription subscription); + void addContact(const JID& jid, const std::string& name, const std::vector<std::string>& groups, const RosterItemPayload::Subscription subscription); void removeContact(const JID& jid); void clear(); bool containsJID(const JID& jid); RosterItemPayload::Subscription getSubscriptionStateForJID(const JID& jid); - String getNameForJID(const JID& jid) const; - std::vector<String> getGroupsForJID(const JID& jid); + std::string getNameForJID(const JID& jid) const; + std::vector<std::string> getGroupsForJID(const JID& jid); virtual std::vector<XMPPRosterItem> getItems() const; virtual boost::optional<XMPPRosterItem> getItem(const JID&) const; - virtual std::set<String> getGroups() const; + virtual std::set<std::string> getGroups() const; private: typedef std::map<JID, XMPPRosterItem> RosterMap; diff --git a/Swiften/Roster/XMPPRosterItem.h b/Swiften/Roster/XMPPRosterItem.h index ceb7763..c821cbf 100644 --- a/Swiften/Roster/XMPPRosterItem.h +++ b/Swiften/Roster/XMPPRosterItem.h @@ -9,33 +9,33 @@ #include <vector> -#include <Swiften/Base/String.h> +#include <string> #include <Swiften/JID/JID.h> #include <Swiften/Elements/RosterItemPayload.h> namespace Swift { class XMPPRosterItem { public: - XMPPRosterItem(const JID& jid, const String& name, const std::vector<String>& groups, RosterItemPayload::Subscription subscription) : jid(jid), name(name), groups(groups), subscription(subscription) { + XMPPRosterItem(const JID& jid, const std::string& name, const std::vector<std::string>& groups, RosterItemPayload::Subscription subscription) : jid(jid), name(name), groups(groups), subscription(subscription) { } const JID& getJID() const { return jid; } - const String& getName() const { + const std::string& getName() const { return name; } - void setName(const String& name) { + void setName(const std::string& name) { this->name = name; } - const std::vector<String>& getGroups() const { + const std::vector<std::string>& getGroups() const { return groups; } - void setGroups(const std::vector<String>& groups) { + void setGroups(const std::vector<std::string>& groups) { this->groups = groups; } @@ -45,8 +45,8 @@ namespace Swift { private: JID jid; - String name; - std::vector<String> groups; + std::string name; + std::vector<std::string> groups; RosterItemPayload::Subscription subscription; }; } diff --git a/Swiften/SASL/ClientAuthenticator.cpp b/Swiften/SASL/ClientAuthenticator.cpp index 4eae2b4..533f172 100644 --- a/Swiften/SASL/ClientAuthenticator.cpp +++ b/Swiften/SASL/ClientAuthenticator.cpp @@ -8,7 +8,7 @@ namespace Swift { -ClientAuthenticator::ClientAuthenticator(const String& name) : name(name) { +ClientAuthenticator::ClientAuthenticator(const std::string& name) : name(name) { } ClientAuthenticator::~ClientAuthenticator() { diff --git a/Swiften/SASL/ClientAuthenticator.h b/Swiften/SASL/ClientAuthenticator.h index 718ccdc..33db75f 100644 --- a/Swiften/SASL/ClientAuthenticator.h +++ b/Swiften/SASL/ClientAuthenticator.h @@ -8,20 +8,20 @@ #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" namespace Swift { class ClientAuthenticator { public: - ClientAuthenticator(const String& name); + ClientAuthenticator(const std::string& name); virtual ~ClientAuthenticator(); - const String& getName() const { + const std::string& getName() const { return name; } - void setCredentials(const String& authcid, const String& password, const String& authzid = String()) { + void setCredentials(const std::string& authcid, const std::string& password, const std::string& authzid = std::string()) { this->authcid = authcid; this->password = password; this->authzid = authzid; @@ -30,22 +30,22 @@ namespace Swift { virtual boost::optional<ByteArray> getResponse() const = 0; virtual bool setChallenge(const boost::optional<ByteArray>&) = 0; - const String& getAuthenticationID() const { + const std::string& getAuthenticationID() const { return authcid; } - const String& getAuthorizationID() const { + const std::string& getAuthorizationID() const { return authzid; } - const String& getPassword() const { + const std::string& getPassword() const { return password; } private: - String name; - String authcid; - String password; - String authzid; + std::string name; + std::string authcid; + std::string password; + std::string authzid; }; } diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp index 050b73b..6892948 100644 --- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp +++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.cpp @@ -13,7 +13,7 @@ namespace Swift { -DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const String& host, const String& nonce) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce) { +DIGESTMD5ClientAuthenticator::DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce) : ClientAuthenticator("DIGEST-MD5"), step(Initial), host(host), cnonce(nonce) { } boost::optional<ByteArray> DIGESTMD5ClientAuthenticator::getResponse() const { @@ -21,29 +21,29 @@ boost::optional<ByteArray> DIGESTMD5ClientAuthenticator::getResponse() const { return boost::optional<ByteArray>(); } else if (step == Response) { - String realm; + std::string realm; if (challenge.getValue("realm")) { realm = *challenge.getValue("realm"); } - String qop = "auth"; - String digestURI = "xmpp/" + host; - String nc = "00000001"; + std::string qop = "auth"; + std::string digestURI = "xmpp/" + host; + std::string nc = "00000001"; // Compute the response value ByteArray A1 = MD5::getHash(getAuthenticationID() + ":" + realm + ":" + getPassword()) + ":" + *challenge.getValue("nonce") + ":" + cnonce; - if (!getAuthorizationID().isEmpty()) { + if (!getAuthorizationID().empty()) { A1 += ":" + getAuthenticationID(); } - String A2 = "AUTHENTICATE:" + digestURI; + std::string A2 = "AUTHENTICATE:" + digestURI; - String responseValue = Hexify::hexify(MD5::getHash( + std::string responseValue = Hexify::hexify(MD5::getHash( Hexify::hexify(MD5::getHash(A1)) + ":" + *challenge.getValue("nonce") + ":" + nc + ":" + cnonce + ":" + qop + ":" + Hexify::hexify(MD5::getHash(A2)))); DIGESTMD5Properties response; response.setValue("username", getAuthenticationID()); - if (!realm.isEmpty()) { + if (!realm.empty()) { response.setValue("realm", realm); } response.setValue("nonce", *challenge.getValue("nonce")); @@ -53,7 +53,7 @@ boost::optional<ByteArray> DIGESTMD5ClientAuthenticator::getResponse() const { response.setValue("digest-uri", digestURI); response.setValue("charset", "utf-8"); response.setValue("response", responseValue); - if (!getAuthorizationID().isEmpty()) { + if (!getAuthorizationID().empty()) { response.setValue("authzid", getAuthorizationID()); } return response.serialize(); diff --git a/Swiften/SASL/DIGESTMD5ClientAuthenticator.h b/Swiften/SASL/DIGESTMD5ClientAuthenticator.h index 457bde9..50dd9aa 100644 --- a/Swiften/SASL/DIGESTMD5ClientAuthenticator.h +++ b/Swiften/SASL/DIGESTMD5ClientAuthenticator.h @@ -8,7 +8,7 @@ #include <map> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/SASL/ClientAuthenticator.h" #include "Swiften/SASL/DIGESTMD5Properties.h" @@ -16,7 +16,7 @@ namespace Swift { class DIGESTMD5ClientAuthenticator : public ClientAuthenticator { public: - DIGESTMD5ClientAuthenticator(const String& host, const String& nonce); + DIGESTMD5ClientAuthenticator(const std::string& host, const std::string& nonce); virtual boost::optional<ByteArray> getResponse() const; virtual bool setChallenge(const boost::optional<ByteArray>&); @@ -27,8 +27,8 @@ namespace Swift { Response, Final, } step; - String host; - String cnonce; + std::string host; + std::string cnonce; DIGESTMD5Properties challenge; }; } diff --git a/Swiften/SASL/DIGESTMD5Properties.cpp b/Swiften/SASL/DIGESTMD5Properties.cpp index 571602b..c7a2474 100644 --- a/Swiften/SASL/DIGESTMD5Properties.cpp +++ b/Swiften/SASL/DIGESTMD5Properties.cpp @@ -58,7 +58,7 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) { } else { if (c == ',' && !insideQuotes(currentValue)) { - String key = currentKey.toString(); + std::string key = currentKey.toString(); if (isQuoted(key)) { result.setValue(key, stripQuotes(currentValue).toString()); } @@ -76,7 +76,7 @@ DIGESTMD5Properties DIGESTMD5Properties::parse(const ByteArray& data) { } if (!currentKey.isEmpty()) { - String key = currentKey.toString(); + std::string key = currentKey.toString(); if (isQuoted(key)) { result.setValue(key, stripQuotes(currentValue).toString()); } @@ -106,21 +106,21 @@ ByteArray DIGESTMD5Properties::serialize() const { return result; } -boost::optional<String> DIGESTMD5Properties::getValue(const String& key) const { +boost::optional<std::string> DIGESTMD5Properties::getValue(const std::string& key) const { DIGESTMD5PropertiesMap::const_iterator i = properties.find(key); if (i != properties.end()) { return i->second.toString(); } else { - return boost::optional<String>(); + return boost::optional<std::string>(); } } -void DIGESTMD5Properties::setValue(const String& key, const String& value) { +void DIGESTMD5Properties::setValue(const std::string& key, const std::string& value) { properties.insert(DIGESTMD5PropertiesMap::value_type(key, ByteArray(value))); } -bool DIGESTMD5Properties::isQuoted(const String& p) { +bool DIGESTMD5Properties::isQuoted(const std::string& p) { return p == "authzid" || p == "cnonce" || p == "digest-uri" || p == "nonce" || p == "realm" || p == "username"; } diff --git a/Swiften/SASL/DIGESTMD5Properties.h b/Swiften/SASL/DIGESTMD5Properties.h index 3afd369..6e2e592 100644 --- a/Swiften/SASL/DIGESTMD5Properties.h +++ b/Swiften/SASL/DIGESTMD5Properties.h @@ -9,7 +9,7 @@ #include <map> #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" namespace Swift { @@ -17,19 +17,19 @@ namespace Swift { public: DIGESTMD5Properties(); - boost::optional<String> getValue(const String& key) const; + boost::optional<std::string> getValue(const std::string& key) const; - void setValue(const String& key, const String& value); + void setValue(const std::string& key, const std::string& value); ByteArray serialize() const; static DIGESTMD5Properties parse(const ByteArray&); private: - static bool isQuoted(const String& property); + static bool isQuoted(const std::string& property); private: - typedef std::multimap<String, ByteArray> DIGESTMD5PropertiesMap; + typedef std::multimap<std::string, ByteArray> DIGESTMD5PropertiesMap; DIGESTMD5PropertiesMap properties; }; } diff --git a/Swiften/SASL/PLAINMessage.cpp b/Swiften/SASL/PLAINMessage.cpp index c2621a3..3728b39 100644 --- a/Swiften/SASL/PLAINMessage.cpp +++ b/Swiften/SASL/PLAINMessage.cpp @@ -8,7 +8,7 @@ namespace Swift { -PLAINMessage::PLAINMessage(const String& authcid, const String& password, const String& authzid) : authcid(authcid), authzid(authzid), password(password) { +PLAINMessage::PLAINMessage(const std::string& authcid, const std::string& password, const std::string& authzid) : authcid(authcid), authzid(authzid), password(password) { } PLAINMessage::PLAINMessage(const ByteArray& value) { @@ -37,8 +37,8 @@ PLAINMessage::PLAINMessage(const ByteArray& value) { } ByteArray PLAINMessage::getValue() const { - String s = authzid + '\0' + authcid + '\0' + password; - return ByteArray(s.getUTF8Data(), s.getUTF8Size()); + std::string s = authzid + '\0' + authcid + '\0' + password; + return ByteArray(s.c_str(), s.size()); } } diff --git a/Swiften/SASL/PLAINMessage.h b/Swiften/SASL/PLAINMessage.h index 3624c6e..d08d70d 100644 --- a/Swiften/SASL/PLAINMessage.h +++ b/Swiften/SASL/PLAINMessage.h @@ -8,32 +8,32 @@ // #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" namespace Swift { class PLAINMessage { public: - PLAINMessage(const String& authcid, const String& password, const String& authzid = ""); + PLAINMessage(const std::string& authcid, const std::string& password, const std::string& authzid = ""); PLAINMessage(const ByteArray& value); ByteArray getValue() const; - const String& getAuthenticationID() const { + const std::string& getAuthenticationID() const { return authcid; } - const String& getPassword() const { + const std::string& getPassword() const { return password; } - const String& getAuthorizationID() const { + const std::string& getAuthorizationID() const { return authzid; } private: - String authcid; - String authzid; - String password; + std::string authcid; + std::string authzid; + std::string password; }; } diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp index b8c89c6..72d535a 100644 --- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp +++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.cpp @@ -18,9 +18,9 @@ namespace Swift { -static String escape(const String& s) { - String result; - for (size_t i = 0; i < s.getUTF8Size(); ++i) { +static std::string escape(const std::string& s) { + std::string result; + for (size_t i = 0; i < s.size(); ++i) { if (s[i] == ',') { result += "=2C"; } @@ -35,7 +35,7 @@ static String escape(const String& s) { } -SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const String& nonce, bool useChannelBinding) : ClientAuthenticator(useChannelBinding ? "SCRAM-SHA-1-PLUS" : "SCRAM-SHA-1"), step(Initial), clientnonce(nonce), useChannelBinding(useChannelBinding) { +SCRAMSHA1ClientAuthenticator::SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding) : ClientAuthenticator(useChannelBinding ? "SCRAM-SHA-1-PLUS" : "SCRAM-SHA-1"), step(Initial), clientnonce(nonce), useChannelBinding(useChannelBinding) { } boost::optional<ByteArray> SCRAMSHA1ClientAuthenticator::getResponse() const { @@ -65,26 +65,26 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional<ByteArray> } initialServerMessage = *challenge; - std::map<char, String> keys = parseMap(String(initialServerMessage.getData(), initialServerMessage.getSize())); + std::map<char, std::string> keys = parseMap(std::string(initialServerMessage.getData(), initialServerMessage.getSize())); // Extract the salt ByteArray salt = Base64::decode(keys['s']); // Extract the server nonce - String clientServerNonce = keys['r']; - if (clientServerNonce.getUTF8Size() <= clientnonce.getUTF8Size()) { + std::string clientServerNonce = keys['r']; + if (clientServerNonce.size() <= clientnonce.size()) { return false; } - String receivedClientNonce = clientServerNonce.getSubstring(0, clientnonce.getUTF8Size()); + std::string receivedClientNonce = clientServerNonce.substr(0, clientnonce.size()); if (receivedClientNonce != clientnonce) { return false; } - serverNonce = clientServerNonce.getSubstring(clientnonce.getUTF8Size(), clientServerNonce.npos()); + serverNonce = clientServerNonce.substr(clientnonce.size(), clientServerNonce.npos); // Extract the number of iterations int iterations = 0; try { - iterations = boost::lexical_cast<int>(keys['i'].getUTF8String()); + iterations = boost::lexical_cast<int>(keys['i']); } catch (const boost::bad_lexical_cast&) { return false; @@ -117,14 +117,14 @@ bool SCRAMSHA1ClientAuthenticator::setChallenge(const boost::optional<ByteArray> } } -std::map<char, String> SCRAMSHA1ClientAuthenticator::parseMap(const String& s) { - std::map<char, String> result; - if (s.getUTF8Size() > 0) { +std::map<char, std::string> SCRAMSHA1ClientAuthenticator::parseMap(const std::string& s) { + std::map<char, std::string> result; + if (s.size() > 0) { char key = 0; - String value; + std::string value; size_t i = 0; bool expectKey = true; - while (i < s.getUTF8Size()) { + while (i < s.size()) { if (expectKey) { key = s[i]; expectKey = false; @@ -146,8 +146,8 @@ std::map<char, String> SCRAMSHA1ClientAuthenticator::parseMap(const String& s) { } ByteArray SCRAMSHA1ClientAuthenticator::getInitialBareClientMessage() const { - String authenticationID = StringPrep::getPrepared(getAuthenticationID(), StringPrep::SASLPrep); - return ByteArray(String("n=" + escape(authenticationID) + ",r=" + clientnonce)); + std::string authenticationID = StringPrep::getPrepared(getAuthenticationID(), StringPrep::SASLPrep); + return ByteArray(std::string("n=" + escape(authenticationID) + ",r=" + clientnonce)); } ByteArray SCRAMSHA1ClientAuthenticator::getGS2Header() const { @@ -160,7 +160,7 @@ ByteArray SCRAMSHA1ClientAuthenticator::getGS2Header() const { channelBindingHeader = ByteArray("y"); } } - return channelBindingHeader + ByteArray(",") + (getAuthorizationID().isEmpty() ? "" : "a=" + escape(getAuthorizationID())) + ","; + return channelBindingHeader + ByteArray(",") + (getAuthorizationID().empty() ? "" : "a=" + escape(getAuthorizationID())) + ","; } void SCRAMSHA1ClientAuthenticator::setTLSChannelBindingData(const ByteArray& channelBindingData) { diff --git a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h index 2cf3cc7..602fc94 100644 --- a/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h +++ b/Swiften/SASL/SCRAMSHA1ClientAuthenticator.h @@ -9,14 +9,14 @@ #include <map> #include <boost/optional.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" #include "Swiften/SASL/ClientAuthenticator.h" namespace Swift { class SCRAMSHA1ClientAuthenticator : public ClientAuthenticator { public: - SCRAMSHA1ClientAuthenticator(const String& nonce, bool useChannelBinding = false); + SCRAMSHA1ClientAuthenticator(const std::string& nonce, bool useChannelBinding = false); void setTLSChannelBindingData(const ByteArray& channelBindingData); @@ -28,7 +28,7 @@ namespace Swift { ByteArray getGS2Header() const; ByteArray getFinalMessageWithoutProof() const; - static std::map<char, String> parseMap(const String&); + static std::map<char, std::string> parseMap(const std::string&); private: enum Step { @@ -36,7 +36,7 @@ namespace Swift { Proof, Final } step; - String clientnonce; + std::string clientnonce; ByteArray initialServerMessage; ByteArray serverNonce; ByteArray authMessage; diff --git a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp index 72c2b64..54f0571 100644 --- a/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp +++ b/Swiften/SASL/UnitTest/DIGESTMD5ClientAuthenticatorTest.cpp @@ -38,7 +38,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=088891c800ecff1b842159ad6459104a,username=\"user\""), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=088891c800ecff1b842159ad6459104a,username=\"user\""), response.toString()); } void testGetResponse_WithAuthorizationID() { @@ -52,7 +52,7 @@ class DIGESTMD5ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("authzid=\"myauthzid\",charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=4293834432b6e7889a2dee7e8fe7dd06,username=\"user\""), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("authzid=\"myauthzid\",charset=utf-8,cnonce=\"abcdefgh\",digest-uri=\"xmpp/xmpp.example.com\",nc=00000001,nonce=\"O6skKPuaCZEny3hteI19qXMBXSadoWs840MchORo\",qop=auth,realm=\"example.com\",response=4293834432b6e7889a2dee7e8fe7dd06,username=\"user\""), response.toString()); } }; diff --git a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp index 1b2c121..152a41e 100644 --- a/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp +++ b/Swiften/SASL/UnitTest/DIGESTMD5PropertiesTest.cpp @@ -24,13 +24,13 @@ class DIGESTMD5PropertiesTest : public CppUnit::TestFixture { "algorithm=md5-sess,charset=utf-8")); CPPUNIT_ASSERT(properties.getValue("realm")); - CPPUNIT_ASSERT_EQUAL(String("myrealm1"), *properties.getValue("realm")); + CPPUNIT_ASSERT_EQUAL(std::string("myrealm1"), *properties.getValue("realm")); CPPUNIT_ASSERT(properties.getValue("nonce")); - CPPUNIT_ASSERT_EQUAL(String("mynonce"), *properties.getValue("nonce")); + CPPUNIT_ASSERT_EQUAL(std::string("mynonce"), *properties.getValue("nonce")); CPPUNIT_ASSERT(properties.getValue("algorithm")); - CPPUNIT_ASSERT_EQUAL(String("md5-sess"), *properties.getValue("algorithm")); + CPPUNIT_ASSERT_EQUAL(std::string("md5-sess"), *properties.getValue("algorithm")); CPPUNIT_ASSERT(properties.getValue("charset")); - CPPUNIT_ASSERT_EQUAL(String("utf-8"), *properties.getValue("charset")); + CPPUNIT_ASSERT_EQUAL(std::string("utf-8"), *properties.getValue("charset")); } void testSerialize() { diff --git a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp index 142d09e..d517f0d 100644 --- a/Swiften/SASL/UnitTest/PLAINMessageTest.cpp +++ b/Swiften/SASL/UnitTest/PLAINMessageTest.cpp @@ -40,29 +40,29 @@ class PLAINMessageTest : public CppUnit::TestFixture void testConstructor_WithoutAuthzID() { PLAINMessage message(ByteArray("\0user\0pass", 10)); - CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthorizationID()); - CPPUNIT_ASSERT_EQUAL(String("user"), message.getAuthenticationID()); - CPPUNIT_ASSERT_EQUAL(String("pass"), message.getPassword()); + CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthorizationID()); + CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string("pass"), message.getPassword()); } void testConstructor_WithAuthzID() { PLAINMessage message(ByteArray("authz\0user\0pass", 15)); - CPPUNIT_ASSERT_EQUAL(String("authz"), message.getAuthorizationID()); - CPPUNIT_ASSERT_EQUAL(String("user"), message.getAuthenticationID()); - CPPUNIT_ASSERT_EQUAL(String("pass"), message.getPassword()); + CPPUNIT_ASSERT_EQUAL(std::string("authz"), message.getAuthorizationID()); + CPPUNIT_ASSERT_EQUAL(std::string("user"), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string("pass"), message.getPassword()); } void testConstructor_NoAuthcid() { PLAINMessage message(ByteArray("authzid", 7)); - CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID()); } void testConstructor_NoPassword() { PLAINMessage message(ByteArray("authzid\0authcid", 15)); - CPPUNIT_ASSERT_EQUAL(String(""), message.getAuthenticationID()); + CPPUNIT_ASSERT_EQUAL(std::string(""), message.getAuthenticationID()); } }; diff --git a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp index 0e42f38..5d0edbd 100644 --- a/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp +++ b/Swiften/SASL/UnitTest/SCRAMSHA1ClientAuthenticatorTest.cpp @@ -45,7 +45,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_UsernameHasSpecialChars() { @@ -54,7 +54,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,,n==2Cus=3D=2Cer=3D,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithAuthorizationID() { @@ -63,7 +63,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,a=auth,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,a=auth,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithAuthorizationIDWithSpecialChars() { @@ -72,7 +72,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("n,a=a=3Du=2Cth,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithoutChannelBindingWithTLSChannelBindingData() { @@ -82,7 +82,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("y,,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("y,,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetInitialResponse_WithChannelBindingWithTLSChannelBindingData() { @@ -92,7 +92,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("p=tls-unique,,n=user,r=abcdefghABCDEFGH"), response.toString()); } void testGetFinalResponse() { @@ -102,7 +102,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("c=biws,r=abcdefghABCDEFGH,p=CZbjGDpIteIJwQNBgO0P8pKkMGY="), response.toString()); } void testGetFinalResponse_WithoutChannelBindingWithTLSChannelBindingData() { @@ -113,7 +113,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("c=eSws,r=abcdefghABCDEFGH,p=JNpsiFEcxZvNZ1+FFBBqrYvYxMk="), response.toString()); } void testGetFinalResponse_WithChannelBindingWithTLSChannelBindingData() { @@ -124,7 +124,7 @@ class SCRAMSHA1ClientAuthenticatorTest : public CppUnit::TestFixture { ByteArray response = *testling.getResponse(); - CPPUNIT_ASSERT_EQUAL(String("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response.toString()); + CPPUNIT_ASSERT_EQUAL(std::string("c=cD10bHMtdW5pcXVlLCx4eXph,r=abcdefghABCDEFGH,p=i6Rghite81P1ype8XxaVAa5l7v0="), response.toString()); } void testSetFinalChallenge() { diff --git a/Swiften/Serializer/AuthChallengeSerializer.cpp b/Swiften/Serializer/AuthChallengeSerializer.cpp index 883763f..dcded43 100644 --- a/Swiften/Serializer/AuthChallengeSerializer.cpp +++ b/Swiften/Serializer/AuthChallengeSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthChallengeSerializer::AuthChallengeSerializer() { } -String AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string AuthChallengeSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthChallenge> authChallenge(boost::dynamic_pointer_cast<AuthChallenge>(element)); - String value; + std::string value; boost::optional<ByteArray> message = authChallenge->getValue(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthChallengeSerializer.h b/Swiften/Serializer/AuthChallengeSerializer.h index 336a88c..a62efb3 100644 --- a/Swiften/Serializer/AuthChallengeSerializer.h +++ b/Swiften/Serializer/AuthChallengeSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: AuthChallengeSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const; + virtual std::string serialize(boost::shared_ptr<Element> element) const; }; } diff --git a/Swiften/Serializer/AuthFailureSerializer.h b/Swiften/Serializer/AuthFailureSerializer.h index 7869b1f..477d98c 100644 --- a/Swiften/Serializer/AuthFailureSerializer.h +++ b/Swiften/Serializer/AuthFailureSerializer.h @@ -19,7 +19,7 @@ namespace Swift { AuthFailureSerializer() : GenericElementSerializer<AuthFailure>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-sasl").serialize(); } }; diff --git a/Swiften/Serializer/AuthRequestSerializer.cpp b/Swiften/Serializer/AuthRequestSerializer.cpp index 45b6503..0bee302 100644 --- a/Swiften/Serializer/AuthRequestSerializer.cpp +++ b/Swiften/Serializer/AuthRequestSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthRequestSerializer::AuthRequestSerializer() { } -String AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string AuthRequestSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthRequest> authRequest(boost::dynamic_pointer_cast<AuthRequest>(element)); - String value; + std::string value; boost::optional<ByteArray> message = authRequest->getMessage(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthRequestSerializer.h b/Swiften/Serializer/AuthRequestSerializer.h index 2680d45..18ef5dd 100644 --- a/Swiften/Serializer/AuthRequestSerializer.h +++ b/Swiften/Serializer/AuthRequestSerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: AuthRequestSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const; + virtual std::string serialize(boost::shared_ptr<Element> element) const; }; } diff --git a/Swiften/Serializer/AuthResponseSerializer.cpp b/Swiften/Serializer/AuthResponseSerializer.cpp index d2d5616..a93b4dd 100644 --- a/Swiften/Serializer/AuthResponseSerializer.cpp +++ b/Swiften/Serializer/AuthResponseSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthResponseSerializer::AuthResponseSerializer() { } -String AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string AuthResponseSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthResponse> authResponse(boost::dynamic_pointer_cast<AuthResponse>(element)); - String value; + std::string value; boost::optional<ByteArray> message = authResponse->getValue(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthResponseSerializer.h b/Swiften/Serializer/AuthResponseSerializer.h index b2f4739..cee8ff3 100644 --- a/Swiften/Serializer/AuthResponseSerializer.h +++ b/Swiften/Serializer/AuthResponseSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: AuthResponseSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const; + virtual std::string serialize(boost::shared_ptr<Element> element) const; }; } diff --git a/Swiften/Serializer/AuthSuccessSerializer.cpp b/Swiften/Serializer/AuthSuccessSerializer.cpp index 6e9103b..443c740 100644 --- a/Swiften/Serializer/AuthSuccessSerializer.cpp +++ b/Swiften/Serializer/AuthSuccessSerializer.cpp @@ -14,9 +14,9 @@ namespace Swift { AuthSuccessSerializer::AuthSuccessSerializer() { } -String AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string AuthSuccessSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<AuthSuccess> authSuccess(boost::dynamic_pointer_cast<AuthSuccess>(element)); - String value; + std::string value; boost::optional<ByteArray> message = authSuccess->getValue(); if (message) { if ((*message).isEmpty()) { diff --git a/Swiften/Serializer/AuthSuccessSerializer.h b/Swiften/Serializer/AuthSuccessSerializer.h index 81b0e36..eb3279c 100644 --- a/Swiften/Serializer/AuthSuccessSerializer.h +++ b/Swiften/Serializer/AuthSuccessSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: AuthSuccessSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const; + virtual std::string serialize(boost::shared_ptr<Element> element) const; }; } diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.cpp b/Swiften/Serializer/ComponentHandshakeSerializer.cpp index 011d59e..cf44ea4 100644 --- a/Swiften/Serializer/ComponentHandshakeSerializer.cpp +++ b/Swiften/Serializer/ComponentHandshakeSerializer.cpp @@ -13,7 +13,7 @@ namespace Swift { ComponentHandshakeSerializer::ComponentHandshakeSerializer() { } -String ComponentHandshakeSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string ComponentHandshakeSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<ComponentHandshake> handshake(boost::dynamic_pointer_cast<ComponentHandshake>(element)); return "<handshake>" + handshake->getData() + "</handshake>"; } diff --git a/Swiften/Serializer/ComponentHandshakeSerializer.h b/Swiften/Serializer/ComponentHandshakeSerializer.h index 5423f08..7681e56 100644 --- a/Swiften/Serializer/ComponentHandshakeSerializer.h +++ b/Swiften/Serializer/ComponentHandshakeSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: ComponentHandshakeSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const; + virtual std::string serialize(boost::shared_ptr<Element> element) const; }; } diff --git a/Swiften/Serializer/CompressFailureSerializer.h b/Swiften/Serializer/CompressFailureSerializer.h index 608dadb..02a4b46 100644 --- a/Swiften/Serializer/CompressFailureSerializer.h +++ b/Swiften/Serializer/CompressFailureSerializer.h @@ -19,7 +19,7 @@ namespace Swift { CompressFailureSerializer() : GenericElementSerializer<CompressFailure>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("failure", "http://jabber.org/protocol/compress").serialize(); } }; diff --git a/Swiften/Serializer/CompressRequestSerializer.cpp b/Swiften/Serializer/CompressRequestSerializer.cpp index 4959665..7733169 100644 --- a/Swiften/Serializer/CompressRequestSerializer.cpp +++ b/Swiften/Serializer/CompressRequestSerializer.cpp @@ -13,7 +13,7 @@ namespace Swift { CompressRequestSerializer::CompressRequestSerializer() { } -String CompressRequestSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string CompressRequestSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<CompressRequest> compressRequest(boost::dynamic_pointer_cast<CompressRequest>(element)); return "<compress xmlns='http://jabber.org/protocol/compress'><method>" + compressRequest->getMethod() + "</method></compress>"; } diff --git a/Swiften/Serializer/CompressRequestSerializer.h b/Swiften/Serializer/CompressRequestSerializer.h index 49d6c97..0a14fb1 100644 --- a/Swiften/Serializer/CompressRequestSerializer.h +++ b/Swiften/Serializer/CompressRequestSerializer.h @@ -16,7 +16,7 @@ namespace Swift { public: CompressRequestSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const; + virtual std::string serialize(boost::shared_ptr<Element> element) const; virtual bool canSerialize(boost::shared_ptr<Element> element) const; }; } diff --git a/Swiften/Serializer/ElementSerializer.h b/Swiften/Serializer/ElementSerializer.h index 48d73ee..3abdf08 100644 --- a/Swiften/Serializer/ElementSerializer.h +++ b/Swiften/Serializer/ElementSerializer.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Element.h" namespace Swift { @@ -17,7 +17,7 @@ namespace Swift { public: virtual ~ElementSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const = 0; + virtual std::string serialize(boost::shared_ptr<Element> element) const = 0; virtual bool canSerialize(boost::shared_ptr<Element> element) const = 0; }; } diff --git a/Swiften/Serializer/EnableStreamManagementSerializer.h b/Swiften/Serializer/EnableStreamManagementSerializer.h index c5a5011..e224a9c 100644 --- a/Swiften/Serializer/EnableStreamManagementSerializer.h +++ b/Swiften/Serializer/EnableStreamManagementSerializer.h @@ -18,7 +18,7 @@ namespace Swift { EnableStreamManagementSerializer() : GenericElementSerializer<EnableStreamManagement>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("enable", "urn:xmpp:sm:2").serialize(); } }; diff --git a/Swiften/Serializer/GenericElementSerializer.h b/Swiften/Serializer/GenericElementSerializer.h index 0329411..903c205 100644 --- a/Swiften/Serializer/GenericElementSerializer.h +++ b/Swiften/Serializer/GenericElementSerializer.h @@ -14,7 +14,7 @@ namespace Swift { template<typename T> class GenericElementSerializer : public ElementSerializer { public: - virtual String serialize(boost::shared_ptr<Element> element) const = 0; + virtual std::string serialize(boost::shared_ptr<Element> element) const = 0; virtual bool canSerialize(boost::shared_ptr<Element> element) const { return boost::dynamic_pointer_cast<T>(element); diff --git a/Swiften/Serializer/GenericPayloadSerializer.h b/Swiften/Serializer/GenericPayloadSerializer.h index 13603e5..b501613 100644 --- a/Swiften/Serializer/GenericPayloadSerializer.h +++ b/Swiften/Serializer/GenericPayloadSerializer.h @@ -14,7 +14,7 @@ namespace Swift { template<typename PAYLOAD_TYPE> class GenericPayloadSerializer : public PayloadSerializer { public: - virtual String serialize(boost::shared_ptr<Payload> element) const { + virtual std::string serialize(boost::shared_ptr<Payload> element) const { return serializePayload(boost::dynamic_pointer_cast<PAYLOAD_TYPE>(element)); } @@ -22,6 +22,6 @@ namespace Swift { return boost::dynamic_pointer_cast<PAYLOAD_TYPE>(element); } - virtual String serializePayload(boost::shared_ptr<PAYLOAD_TYPE>) const = 0; + virtual std::string serializePayload(boost::shared_ptr<PAYLOAD_TYPE>) const = 0; }; } diff --git a/Swiften/Serializer/GenericStanzaSerializer.h b/Swiften/Serializer/GenericStanzaSerializer.h index 557fb37..2f0fccf 100644 --- a/Swiften/Serializer/GenericStanzaSerializer.h +++ b/Swiften/Serializer/GenericStanzaSerializer.h @@ -13,7 +13,7 @@ namespace Swift { template<typename STANZA_TYPE> class GenericStanzaSerializer : public StanzaSerializer { public: - GenericStanzaSerializer(const String& tag, PayloadSerializerCollection* payloadSerializers) : StanzaSerializer(tag, payloadSerializers) {} + GenericStanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers) : StanzaSerializer(tag, payloadSerializers) {} virtual bool canSerialize(boost::shared_ptr<Element> element) const { return dynamic_cast<STANZA_TYPE*>(element.get()) != 0; diff --git a/Swiften/Serializer/PayloadSerializer.h b/Swiften/Serializer/PayloadSerializer.h index dbb984d..34e6679 100644 --- a/Swiften/Serializer/PayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializer.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Elements/Payload.h" namespace Swift { @@ -18,7 +18,7 @@ namespace Swift { virtual ~PayloadSerializer(); virtual bool canSerialize(boost::shared_ptr<Payload>) const = 0; - virtual String serialize(boost::shared_ptr<Payload>) const = 0; + virtual std::string serialize(boost::shared_ptr<Payload>) const = 0; }; } diff --git a/Swiften/Serializer/PayloadSerializerCollection.h b/Swiften/Serializer/PayloadSerializerCollection.h index fdb8657..1b3cbc5 100644 --- a/Swiften/Serializer/PayloadSerializerCollection.h +++ b/Swiften/Serializer/PayloadSerializerCollection.h @@ -13,7 +13,7 @@ namespace Swift { class PayloadSerializer; - class String; + class PayloadSerializerCollection { public: diff --git a/Swiften/Serializer/PayloadSerializers/BodySerializer.h b/Swiften/Serializer/PayloadSerializers/BodySerializer.h index c73f0c4..6fc6e6d 100644 --- a/Swiften/Serializer/PayloadSerializers/BodySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/BodySerializer.h @@ -16,7 +16,7 @@ namespace Swift { public: BodySerializer() : GenericPayloadSerializer<Body>() {} - virtual String serializePayload(boost::shared_ptr<Body> body) const { + virtual std::string serializePayload(boost::shared_ptr<Body> body) const { XMLTextNode textNode(body->getText()); return "<body>" + textNode.serialize() + "</body>"; } diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp index 9acabee..f9b89f3 100644 --- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp @@ -19,7 +19,7 @@ namespace Swift { BytestreamsSerializer::BytestreamsSerializer() { } -String BytestreamsSerializer::serializePayload(boost::shared_ptr<Bytestreams> bytestreams) const { +std::string BytestreamsSerializer::serializePayload(boost::shared_ptr<Bytestreams> bytestreams) const { XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams"); queryElement.setAttribute("sid", bytestreams->getStreamID()); foreach(const Bytestreams::StreamHost& streamHost, bytestreams->getStreamHosts()) { diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h index 50d58c2..d9b14db 100644 --- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: BytestreamsSerializer(); - virtual String serializePayload(boost::shared_ptr<Bytestreams>) const; + virtual std::string serializePayload(boost::shared_ptr<Bytestreams>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp index c7b17bd..ced0d62 100644 --- a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.cpp @@ -15,7 +15,7 @@ namespace Swift { CapsInfoSerializer::CapsInfoSerializer() : GenericPayloadSerializer<CapsInfo>() { } -String CapsInfoSerializer::serializePayload(boost::shared_ptr<CapsInfo> capsInfo) const { +std::string CapsInfoSerializer::serializePayload(boost::shared_ptr<CapsInfo> capsInfo) const { XMLElement capsElement("c", "http://jabber.org/protocol/caps"); capsElement.setAttribute("node", capsInfo->getNode()); capsElement.setAttribute("hash", capsInfo->getHash()); diff --git a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h index a94916b..de0a871 100644 --- a/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/CapsInfoSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: CapsInfoSerializer(); - virtual String serializePayload(boost::shared_ptr<CapsInfo>) const; + virtual std::string serializePayload(boost::shared_ptr<CapsInfo>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp index 9f0fe0d..3e877eb 100644 --- a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.cpp @@ -11,8 +11,8 @@ namespace Swift { ChatStateSerializer::ChatStateSerializer() : GenericPayloadSerializer<ChatState>() { } -String ChatStateSerializer::serializePayload(boost::shared_ptr<ChatState> chatState) const { - String result("<"); +std::string ChatStateSerializer::serializePayload(boost::shared_ptr<ChatState> chatState) const { + std::string result("<"); switch (chatState->getChatState()) { case ChatState::Active: result += "active"; break; case ChatState::Composing: result += "composing"; break; diff --git a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h index 724f4a1..a786901 100644 --- a/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ChatStateSerializer.h @@ -14,6 +14,6 @@ namespace Swift { public: ChatStateSerializer(); - virtual String serializePayload(boost::shared_ptr<ChatState> error) const; + virtual std::string serializePayload(boost::shared_ptr<ChatState> error) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp index b29a634..0fa45ce 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.cpp @@ -20,34 +20,34 @@ namespace Swift { CommandSerializer::CommandSerializer() { } -String CommandSerializer::serializePayload(boost::shared_ptr<Command> command) const { +std::string CommandSerializer::serializePayload(boost::shared_ptr<Command> command) const { XMLElement commandElement("command", "http://jabber.org/protocol/comands"); commandElement.setAttribute("node", command->getNode()); - if (!command->getSessionID().isEmpty()) { + if (!command->getSessionID().empty()) { commandElement.setAttribute("sessionid", command->getSessionID()); } - String action = actionToString(command->getAction()); - if (!action.isEmpty()) { + std::string action = actionToString(command->getAction()); + if (!action.empty()) { commandElement.setAttribute("action", action); } - String status; + std::string status; switch (command->getStatus()) { case Command::Executing: status = "executing";break; case Command::Completed: status = "completed";break; case Command::Canceled: status = "canceled";break; case Command::NoStatus: break; } - if (!status.isEmpty()) { + if (!status.empty()) { commandElement.setAttribute("status", status); } if (command->getAvailableActions().size() > 0) { - String actions = "<actions"; - String executeAction = actionToString(command->getExecuteAction()); - if (!executeAction.isEmpty()) { + std::string actions = "<actions"; + std::string executeAction = actionToString(command->getExecuteAction()); + if (!executeAction.empty()) { actions += " execute='" + executeAction + "'"; } actions += ">"; @@ -60,13 +60,13 @@ String CommandSerializer::serializePayload(boost::shared_ptr<Command> command) c foreach (Command::Note note, command->getNotes()) { boost::shared_ptr<XMLElement> noteElement(new XMLElement("note")); - String type; + std::string type; switch (note.type) { case Command::Note::Info: type = "info"; break; case Command::Note::Warn: type = "warn"; break; case Command::Note::Error: type = "error"; break; } - if (!type.isEmpty()) { + if (!type.empty()) { noteElement->setAttribute("type", type); } noteElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(note.note))); @@ -80,8 +80,8 @@ String CommandSerializer::serializePayload(boost::shared_ptr<Command> command) c return commandElement.serialize(); } -String CommandSerializer::actionToString(Command::Action action) const { - String string; +std::string CommandSerializer::actionToString(Command::Action action) const { + std::string string; switch (action) { case Command::Cancel: string = "cancel"; break; case Command::Execute: string = "execute"; break; diff --git a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h index 4b71aea..b1db825 100644 --- a/Swiften/Serializer/PayloadSerializers/CommandSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/CommandSerializer.h @@ -16,9 +16,9 @@ namespace Swift { public: CommandSerializer(); - virtual String serializePayload(boost::shared_ptr<Command>) const; + virtual std::string serializePayload(boost::shared_ptr<Command>) const; private: - String actionToString(Command::Action action) const; + std::string actionToString(Command::Action action) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp index a54cf9e..4922042 100644 --- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.cpp @@ -8,6 +8,7 @@ #include <boost/shared_ptr.hpp> +#include <Swiften/Base/String.h> #include "Swiften/Serializer/XML/XMLElement.h" namespace Swift { @@ -15,19 +16,19 @@ namespace Swift { DelaySerializer::DelaySerializer() : GenericPayloadSerializer<Delay>() { } -String DelaySerializer::serializePayload(boost::shared_ptr<Delay> delay) const { +std::string DelaySerializer::serializePayload(boost::shared_ptr<Delay> delay) const { XMLElement delayElement("delay", "urn:xmpp:delay"); if (delay->getFrom()) { delayElement.setAttribute("from", delay->getFrom()->toString()); } - String stampString = boostPTimeToXEP0082(delay->getStamp()); + std::string stampString = boostPTimeToXEP0082(delay->getStamp()); delayElement.setAttribute("stamp", stampString); return delayElement.serialize(); } -String DelaySerializer::boostPTimeToXEP0082(const boost::posix_time::ptime& time) { - String stampString = String(boost::posix_time::to_iso_extended_string(time)); - stampString.replaceAll(',', "."); +std::string DelaySerializer::boostPTimeToXEP0082(const boost::posix_time::ptime& time) { + std::string stampString = std::string(boost::posix_time::to_iso_extended_string(time)); + String::replaceAll(stampString, ',', "."); stampString += "Z"; return stampString; } diff --git a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h index eb33c9f..c37dc02 100644 --- a/Swiften/Serializer/PayloadSerializers/DelaySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/DelaySerializer.h @@ -14,8 +14,8 @@ namespace Swift { public: DelaySerializer(); - virtual String serializePayload(boost::shared_ptr<Delay>) const; - static String boostPTimeToXEP0082(const boost::posix_time::ptime& time); + virtual std::string serializePayload(boost::shared_ptr<Delay>) const; + static std::string boostPTimeToXEP0082(const boost::posix_time::ptime& time); }; } diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp index f5923dc..65b0a38 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.cpp @@ -18,14 +18,14 @@ namespace Swift { DiscoInfoSerializer::DiscoInfoSerializer() : GenericPayloadSerializer<DiscoInfo>() { } -String DiscoInfoSerializer::serializePayload(boost::shared_ptr<DiscoInfo> discoInfo) const { +std::string DiscoInfoSerializer::serializePayload(boost::shared_ptr<DiscoInfo> discoInfo) const { XMLElement queryElement("query", "http://jabber.org/protocol/disco#info"); - if (!discoInfo->getNode().isEmpty()) { + if (!discoInfo->getNode().empty()) { queryElement.setAttribute("node", discoInfo->getNode()); } foreach(const DiscoInfo::Identity& identity, discoInfo->getIdentities()) { boost::shared_ptr<XMLElement> identityElement(new XMLElement("identity")); - if (!identity.getLanguage().isEmpty()) { + if (!identity.getLanguage().empty()) { identityElement->setAttribute("xml:lang", identity.getLanguage()); } identityElement->setAttribute("category", identity.getCategory()); @@ -33,7 +33,7 @@ String DiscoInfoSerializer::serializePayload(boost::shared_ptr<DiscoInfo> discoI identityElement->setAttribute("type", identity.getType()); queryElement.addNode(identityElement); } - foreach(const String& feature, discoInfo->getFeatures()) { + foreach(const std::string& feature, discoInfo->getFeatures()) { boost::shared_ptr<XMLElement> featureElement(new XMLElement("feature")); featureElement->setAttribute("var", feature); queryElement.addNode(featureElement); diff --git a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h index 63047d1..46e7ce2 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/DiscoInfoSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: DiscoInfoSerializer(); - virtual String serializePayload(boost::shared_ptr<DiscoInfo>) const; + virtual std::string serializePayload(boost::shared_ptr<DiscoInfo>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp index 056c515..cb1b7c1 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.cpp @@ -16,16 +16,16 @@ namespace Swift { DiscoItemsSerializer::DiscoItemsSerializer() : GenericPayloadSerializer<DiscoItems>() { } -String DiscoItemsSerializer::serializePayload(boost::shared_ptr<DiscoItems> discoItems) const { +std::string DiscoItemsSerializer::serializePayload(boost::shared_ptr<DiscoItems> discoItems) const { XMLElement queryElement("query", "http://jabber.org/protocol/disco#items"); - if (!discoItems->getNode().isEmpty()) { + if (!discoItems->getNode().empty()) { queryElement.setAttribute("node", discoItems->getNode()); } foreach(const DiscoItems::Item& item, discoItems->getItems()) { boost::shared_ptr<XMLElement> itemElement(new XMLElement("item")); itemElement->setAttribute("name", item.getName()); itemElement->setAttribute("jid", item.getJID()); - if (!item.getNode().isEmpty()) { + if (!item.getNode().empty()) { itemElement->setAttribute("node", item.getNode()); } queryElement.addNode(itemElement); diff --git a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h index 8116e9b..3b00a17 100644 --- a/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/DiscoItemsSerializer.h @@ -14,7 +14,7 @@ namespace Swift { public: DiscoItemsSerializer(); - virtual String serializePayload(boost::shared_ptr<DiscoItems>) const; + virtual std::string serializePayload(boost::shared_ptr<DiscoItems>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp index d041f6e..15d13d7 100644 --- a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.cpp @@ -12,8 +12,8 @@ namespace Swift { ErrorSerializer::ErrorSerializer() : GenericPayloadSerializer<ErrorPayload>() { } -String ErrorSerializer::serializePayload(boost::shared_ptr<ErrorPayload> error) const { - String result("<error type=\""); +std::string ErrorSerializer::serializePayload(boost::shared_ptr<ErrorPayload> error) const { + std::string result("<error type=\""); switch (error->getType()) { case ErrorPayload::Continue: result += "continue"; break; case ErrorPayload::Modify: result += "modify"; break; @@ -23,7 +23,7 @@ String ErrorSerializer::serializePayload(boost::shared_ptr<ErrorPayload> error) } result += "\">"; - String conditionElement; + std::string conditionElement; switch (error->getCondition()) { case ErrorPayload::BadRequest: conditionElement = "bad-request"; break; case ErrorPayload::Conflict: conditionElement = "conflict"; break; @@ -50,7 +50,7 @@ String ErrorSerializer::serializePayload(boost::shared_ptr<ErrorPayload> error) } result += "<" + conditionElement + " xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"; - if (!error->getText().isEmpty()) { + if (!error->getText().empty()) { XMLTextNode textNode(error->getText()); result += "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">" + textNode.serialize() + "</text>"; } diff --git a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h index ee32279..7fc4dad 100644 --- a/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ErrorSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: ErrorSerializer(); - virtual String serializePayload(boost::shared_ptr<ErrorPayload> error) const; + virtual std::string serializePayload(boost::shared_ptr<ErrorPayload> error) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp index 77c2fd4..53b4241 100644 --- a/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.cpp @@ -8,9 +8,10 @@ #include <boost/shared_ptr.hpp> #include <iostream> +#include <string> -#include "Swiften/Base/foreach.h" #include "Swiften/Base/String.h" +#include "Swiften/Base/foreach.h" #include "Swiften/Serializer/XML/XMLTextNode.h" #include "Swiften/Serializer/XML/XMLRawTextNode.h" @@ -18,8 +19,8 @@ using namespace Swift; namespace { template<typename T> void serializeValueAsString(boost::shared_ptr<FormField> field, boost::shared_ptr<XMLElement> parent) { - String value = boost::dynamic_pointer_cast<T>(field)->getValue(); - if (!value.isEmpty()) { + std::string value = boost::dynamic_pointer_cast<T>(field)->getValue(); + if (!value.empty()) { boost::shared_ptr<XMLElement> valueElement(new XMLElement("value")); valueElement->addNode(XMLTextNode::create(value)); parent->addNode(valueElement); @@ -33,9 +34,9 @@ namespace Swift { FormSerializer::FormSerializer() : GenericPayloadSerializer<Form>() { } -String FormSerializer::serializePayload(boost::shared_ptr<Form> form) const { +std::string FormSerializer::serializePayload(boost::shared_ptr<Form> form) const { boost::shared_ptr<XMLElement> formElement(new XMLElement("x", "jabber:x:data")); - String type; + std::string type; switch (form->getType()) { case Form::FormType: type = "form"; break; case Form::SubmitType: type = "submit"; break; @@ -43,10 +44,10 @@ String FormSerializer::serializePayload(boost::shared_ptr<Form> form) const { case Form::ResultType: type = "result"; break; } formElement->setAttribute("type", type); - if (!form->getTitle().isEmpty()) { + if (!form->getTitle().empty()) { multiLineify(form->getTitle(), "title", formElement); } - if (!form->getInstructions().isEmpty()) { + if (!form->getInstructions().empty()) { multiLineify(form->getInstructions(), "instructions", formElement); } foreach(boost::shared_ptr<FormField> field, form->getFields()) { @@ -57,23 +58,23 @@ String FormSerializer::serializePayload(boost::shared_ptr<Form> form) const { boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormField> field) const { boost::shared_ptr<XMLElement> fieldElement(new XMLElement("field")); - if (!field->getName().isEmpty()) { + if (!field->getName().empty()) { fieldElement->setAttribute("var", field->getName()); } - if (!field->getLabel().isEmpty()) { + if (!field->getLabel().empty()) { fieldElement->setAttribute("label", field->getLabel()); } if (field->getRequired()) { fieldElement->addNode(boost::shared_ptr<XMLElement>(new XMLElement("required"))); } - if (!field->getDescription().isEmpty()) { + if (!field->getDescription().empty()) { boost::shared_ptr<XMLElement> descriptionElement(new XMLElement("desc")); descriptionElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(field->getDescription()))); fieldElement->addNode(descriptionElement); } // Set the value and type - String fieldType; + std::string fieldType; if (boost::dynamic_pointer_cast<BooleanFormField>(field)) { fieldType = "boolean"; boost::shared_ptr<XMLElement> valueElement(new XMLElement("value")); @@ -117,8 +118,8 @@ boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormF } else if (boost::dynamic_pointer_cast<ListMultiFormField>(field)) { fieldType = "list-multi"; - std::vector<String> lines = boost::dynamic_pointer_cast<ListMultiFormField>(field)->getValue(); - foreach(const String& line, lines) { + std::vector<std::string> lines = boost::dynamic_pointer_cast<ListMultiFormField>(field)->getValue(); + foreach(const std::string& line, lines) { boost::shared_ptr<XMLElement> valueElement(new XMLElement("value")); valueElement->addNode(XMLTextNode::create(line)); fieldElement->addNode(valueElement); @@ -129,8 +130,8 @@ boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormF multiLineify(boost::dynamic_pointer_cast<TextMultiFormField>(field)->getValue(), "value", fieldElement); } else if (boost::dynamic_pointer_cast<UntypedFormField>(field)) { - std::vector<String> lines = boost::dynamic_pointer_cast<UntypedFormField>(field)->getValue(); - foreach(const String& line, lines) { + std::vector<std::string> lines = boost::dynamic_pointer_cast<UntypedFormField>(field)->getValue(); + foreach(const std::string& line, lines) { boost::shared_ptr<XMLElement> valueElement(new XMLElement("value")); valueElement->addNode(XMLTextNode::create(line)); fieldElement->addNode(valueElement); @@ -139,13 +140,13 @@ boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormF else { assert(false); } - if (!fieldType.isEmpty()) { + if (!fieldType.empty()) { fieldElement->setAttribute("type", fieldType); } foreach (const FormField::Option& option, field->getOptions()) { boost::shared_ptr<XMLElement> optionElement(new XMLElement("option")); - if (!option.label.isEmpty()) { + if (!option.label.empty()) { optionElement->setAttribute("label", option.label); } @@ -159,11 +160,11 @@ boost::shared_ptr<XMLElement> FormSerializer::fieldToXML(boost::shared_ptr<FormF return fieldElement; } -void FormSerializer::multiLineify(const String& text, const String& elementName, boost::shared_ptr<XMLElement> element) const { - String unRdText(text); - unRdText.removeAll('\r'); - std::vector<String> lines = unRdText.split('\n'); - foreach (String line, lines) { +void FormSerializer::multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr<XMLElement> element) const { + std::string unRdText(text); + unRdText.erase(std::remove(unRdText.begin(), unRdText.end(), '\r'), unRdText.end()); + std::vector<std::string> lines = String::split(unRdText, '\n'); + foreach (std::string line, lines) { boost::shared_ptr<XMLElement> lineElement(new XMLElement(elementName)); lineElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(line))); element->addNode(lineElement); diff --git a/Swiften/Serializer/PayloadSerializers/FormSerializer.h b/Swiften/Serializer/PayloadSerializers/FormSerializer.h index 1cdc7f2..86c8dee 100644 --- a/Swiften/Serializer/PayloadSerializers/FormSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/FormSerializer.h @@ -16,11 +16,11 @@ namespace Swift { public: FormSerializer(); - virtual String serializePayload(boost::shared_ptr<Form>) const; + virtual std::string serializePayload(boost::shared_ptr<Form>) const; private: boost::shared_ptr<XMLElement> fieldToXML(boost::shared_ptr<FormField> field) const; - void multiLineify(const String& text, const String& elementName, boost::shared_ptr<XMLElement> parent) const; + void multiLineify(const std::string& text, const std::string& elementName, boost::shared_ptr<XMLElement> parent) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp index 5e52145..7ac4103 100644 --- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp @@ -20,7 +20,7 @@ namespace Swift { IBBSerializer::IBBSerializer() { } -String IBBSerializer::serializePayload(boost::shared_ptr<IBB> ibb) const { +std::string IBBSerializer::serializePayload(boost::shared_ptr<IBB> ibb) const { switch(ibb->getAction()) { case IBB::Data: { XMLElement ibbElement("data", "http://jabber.org/protocol/ibb"); diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.h b/Swiften/Serializer/PayloadSerializers/IBBSerializer.h index 71b1c80..d750f6f 100644 --- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: IBBSerializer(); - virtual String serializePayload(boost::shared_ptr<IBB>) const; + virtual std::string serializePayload(boost::shared_ptr<IBB>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp index 5729df6..e4ae11f 100644 --- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.cpp @@ -18,7 +18,7 @@ namespace Swift { InBandRegistrationPayloadSerializer::InBandRegistrationPayloadSerializer() { } -String InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr<InBandRegistrationPayload> registration) const { +std::string InBandRegistrationPayloadSerializer::serializePayload(boost::shared_ptr<InBandRegistrationPayload> registration) const { XMLElement registerElement("query", "jabber:iq:register"); if (registration->isRegistered()) { diff --git a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h index 168aa3a..45d49ea 100644 --- a/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/InBandRegistrationPayloadSerializer.h @@ -17,6 +17,6 @@ namespace Swift { public: InBandRegistrationPayloadSerializer(); - virtual String serializePayload(boost::shared_ptr<InBandRegistrationPayload>) const; + virtual std::string serializePayload(boost::shared_ptr<InBandRegistrationPayload>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp index dbf79d4..db28514 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.cpp @@ -15,7 +15,7 @@ namespace Swift { MUCOwnerPayloadSerializer::MUCOwnerPayloadSerializer(PayloadSerializerCollection* serializers) : GenericPayloadSerializer<MUCOwnerPayload>(), serializers(serializers) { } -String MUCOwnerPayloadSerializer::serializePayload(boost::shared_ptr<MUCOwnerPayload> mucOwner) const { +std::string MUCOwnerPayloadSerializer::serializePayload(boost::shared_ptr<MUCOwnerPayload> mucOwner) const { XMLElement mucElement("query", "http://jabber.org/protocol/muc#owner"); boost::shared_ptr<Payload> payload = mucOwner->getPayload(); if (payload) { diff --git a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h index 862cfce..4808744 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MUCOwnerPayloadSerializer.h @@ -14,7 +14,7 @@ namespace Swift { class MUCOwnerPayloadSerializer : public GenericPayloadSerializer<MUCOwnerPayload> { public: MUCOwnerPayloadSerializer(PayloadSerializerCollection* serializers); - virtual String serializePayload(boost::shared_ptr<MUCOwnerPayload> version) const; + virtual std::string serializePayload(boost::shared_ptr<MUCOwnerPayload> version) const; private: PayloadSerializerCollection* serializers; }; diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp index 087dece..d7e1613 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp @@ -7,13 +7,14 @@ #include "Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h" #include "Swiften/Serializer/XML/XMLElement.h" +#include <Swiften/Base/String.h> namespace Swift { MUCPayloadSerializer::MUCPayloadSerializer() : GenericPayloadSerializer<MUCPayload>() { } -String MUCPayloadSerializer::serializePayload(boost::shared_ptr<MUCPayload> muc) const { +std::string MUCPayloadSerializer::serializePayload(boost::shared_ptr<MUCPayload> muc) const { XMLElement mucElement("x", "http://jabber.org/protocol/muc"); boost::shared_ptr<XMLElement> historyElement(new XMLElement("history")); bool history = false; @@ -30,8 +31,8 @@ String MUCPayloadSerializer::serializePayload(boost::shared_ptr<MUCPayload> muc) history = true; } if (muc->getSince() != boost::posix_time::not_a_date_time) { - String sinceString = String(boost::posix_time::to_iso_extended_string(muc->getSince())); - sinceString.replaceAll(',', "."); + std::string sinceString = std::string(boost::posix_time::to_iso_extended_string(muc->getSince())); + String::replaceAll(sinceString, ',', "."); sinceString += "Z"; historyElement->setAttribute("since", sinceString); history = true; diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h index cd7f107..7038e6e 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.h @@ -13,7 +13,7 @@ namespace Swift { class MUCPayloadSerializer : public GenericPayloadSerializer<MUCPayload> { public: MUCPayloadSerializer(); - virtual String serializePayload(boost::shared_ptr<MUCPayload> version) const; + virtual std::string serializePayload(boost::shared_ptr<MUCPayload> version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp index f4732ea..50746a9 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.cpp @@ -20,7 +20,7 @@ namespace Swift { MUCUserPayloadSerializer::MUCUserPayloadSerializer() : GenericPayloadSerializer<MUCUserPayload>() { } -String MUCUserPayloadSerializer::serializePayload(boost::shared_ptr<MUCUserPayload> payload) const { +std::string MUCUserPayloadSerializer::serializePayload(boost::shared_ptr<MUCUserPayload> payload) const { XMLElement mucElement("x", "http://jabber.org/protocol/muc"); foreach (const MUCUserPayload::StatusCode statusCode, payload->getStatusCodes()) { boost::shared_ptr<XMLElement> statusElement(new XMLElement("status")); @@ -44,8 +44,8 @@ String MUCUserPayloadSerializer::serializePayload(boost::shared_ptr<MUCUserPaylo return mucElement.serialize(); } -String MUCUserPayloadSerializer::affiliationToString(MUCOccupant::Affiliation affiliation) const { - String result; +std::string MUCUserPayloadSerializer::affiliationToString(MUCOccupant::Affiliation affiliation) const { + std::string result; switch (affiliation) { case MUCOccupant::Owner: result = "owner"; break; case MUCOccupant::Admin: result = "admin"; break; @@ -57,8 +57,8 @@ String MUCUserPayloadSerializer::affiliationToString(MUCOccupant::Affiliation af return result; } -String MUCUserPayloadSerializer::roleToString(MUCOccupant::Role role) const { - String result; +std::string MUCUserPayloadSerializer::roleToString(MUCOccupant::Role role) const { + std::string result; switch (role) { case MUCOccupant::Moderator: result = "moderator"; break; case MUCOccupant::NoRole: result = "none"; break; diff --git a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h index bad21c9..54e6aff 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/MUCUserPayloadSerializer.h @@ -13,10 +13,10 @@ namespace Swift { class MUCUserPayloadSerializer : public GenericPayloadSerializer<MUCUserPayload> { public: MUCUserPayloadSerializer(); - String affiliationToString(MUCOccupant::Affiliation affiliation) const; - String roleToString(MUCOccupant::Role role) const; + std::string affiliationToString(MUCOccupant::Affiliation affiliation) const; + std::string roleToString(MUCOccupant::Role role) const; - virtual String serializePayload(boost::shared_ptr<MUCUserPayload> version) const; + virtual std::string serializePayload(boost::shared_ptr<MUCUserPayload> version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp index 55d5bb6..23d2c25 100644 --- a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.cpp @@ -16,7 +16,7 @@ namespace Swift { NicknameSerializer::NicknameSerializer() : GenericPayloadSerializer<Nickname>() { } -String NicknameSerializer::serializePayload(boost::shared_ptr<Nickname> nick) const { +std::string NicknameSerializer::serializePayload(boost::shared_ptr<Nickname> nick) const { XMLElement nickElement("nick", "http://jabber.org/protocol/nick"); nickElement.addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(nick->getNickname()))); return nickElement.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h index e296ffd..e07767b 100644 --- a/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/NicknameSerializer.h @@ -14,7 +14,7 @@ namespace Swift { public: NicknameSerializer(); - virtual String serializePayload(boost::shared_ptr<Nickname>) const; + virtual std::string serializePayload(boost::shared_ptr<Nickname>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h index a242215..cc96ce7 100644 --- a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: PrioritySerializer() : GenericPayloadSerializer<Priority>() {} - virtual String serializePayload(boost::shared_ptr<Priority> priority) const { + virtual std::string serializePayload(boost::shared_ptr<Priority> priority) const { return "<priority>" + boost::lexical_cast<std::string>(priority->getPriority()) + "</priority>"; } }; diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp index 1964d96..6e1d74d 100644 --- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.cpp @@ -19,7 +19,7 @@ namespace Swift { PrivateStorageSerializer::PrivateStorageSerializer(PayloadSerializerCollection* serializers) : serializers(serializers) { } -String PrivateStorageSerializer::serializePayload(boost::shared_ptr<PrivateStorage> storage) const { +std::string PrivateStorageSerializer::serializePayload(boost::shared_ptr<PrivateStorage> storage) const { XMLElement storageElement("query", "jabber:iq:private"); boost::shared_ptr<Payload> payload = storage->getPayload(); if (payload) { diff --git a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h index 03448be..7b46136 100644 --- a/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PrivateStorageSerializer.h @@ -16,7 +16,7 @@ namespace Swift { public: PrivateStorageSerializer(PayloadSerializerCollection* serializers); - virtual String serializePayload(boost::shared_ptr<PrivateStorage>) const; + virtual std::string serializePayload(boost::shared_ptr<PrivateStorage>) const; private: PayloadSerializerCollection* serializers; diff --git a/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h index 725a5cd..6874569 100644 --- a/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/RawXMLPayloadSerializer.h @@ -14,7 +14,7 @@ namespace Swift { public: RawXMLPayloadSerializer() : GenericPayloadSerializer<RawXMLPayload>() {} - virtual String serializePayload(boost::shared_ptr<RawXMLPayload> p) const { + virtual std::string serializePayload(boost::shared_ptr<RawXMLPayload> p) const { return p->getRawXML(); } }; diff --git a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp index cdc5764..cfb3a90 100644 --- a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.cpp @@ -16,14 +16,14 @@ namespace Swift { ResourceBindSerializer::ResourceBindSerializer() : GenericPayloadSerializer<ResourceBind>() { } -String ResourceBindSerializer::serializePayload(boost::shared_ptr<ResourceBind> resourceBind) const { +std::string ResourceBindSerializer::serializePayload(boost::shared_ptr<ResourceBind> resourceBind) const { XMLElement bindElement("bind", "urn:ietf:params:xml:ns:xmpp-bind"); if (resourceBind->getJID().isValid()) { boost::shared_ptr<XMLElement> jidNode(new XMLElement("jid")); jidNode->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(resourceBind->getJID().toString()))); bindElement.addNode(jidNode); } - else if (!resourceBind->getResource().isEmpty()) { + else if (!resourceBind->getResource().empty()) { boost::shared_ptr<XMLElement> resourceNode(new XMLElement("resource")); resourceNode->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(resourceBind->getResource()))); bindElement.addNode(resourceNode); diff --git a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h index 7248863..d259555 100644 --- a/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/ResourceBindSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: ResourceBindSerializer(); - virtual String serializePayload(boost::shared_ptr<ResourceBind>) const; + virtual std::string serializePayload(boost::shared_ptr<ResourceBind>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp index b56f404..40faf73 100644 --- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp @@ -18,7 +18,7 @@ namespace Swift { RosterSerializer::RosterSerializer() : GenericPayloadSerializer<RosterPayload>() { } -String RosterSerializer::serializePayload(boost::shared_ptr<RosterPayload> roster) const { +std::string RosterSerializer::serializePayload(boost::shared_ptr<RosterPayload> roster) const { XMLElement queryElement("query", "jabber:iq:roster"); foreach(const RosterItemPayload& item, roster->getItems()) { boost::shared_ptr<XMLElement> itemElement(new XMLElement("item")); @@ -37,13 +37,13 @@ String RosterSerializer::serializePayload(boost::shared_ptr<RosterPayload> roste itemElement->setAttribute("ask", "subscribe"); } - foreach(const String& group, item.getGroups()) { + foreach(const std::string& group, item.getGroups()) { boost::shared_ptr<XMLElement> groupElement(new XMLElement("group")); groupElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(group))); itemElement->addNode(groupElement); } - if (!item.getUnknownContent().isEmpty()) { + if (!item.getUnknownContent().empty()) { itemElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(item.getUnknownContent()))); } diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.h b/Swiften/Serializer/PayloadSerializers/RosterSerializer.h index ce73670..49e194b 100644 --- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: RosterSerializer(); - virtual String serializePayload(boost::shared_ptr<RosterPayload>) const; + virtual std::string serializePayload(boost::shared_ptr<RosterPayload>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp index 5d71fd3..a7a9fda 100644 --- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.cpp @@ -18,7 +18,7 @@ namespace Swift { SearchPayloadSerializer::SearchPayloadSerializer() { } -String SearchPayloadSerializer::serializePayload(boost::shared_ptr<SearchPayload> searchPayload) const { +std::string SearchPayloadSerializer::serializePayload(boost::shared_ptr<SearchPayload> searchPayload) const { XMLElement searchElement("query", "jabber:iq:search"); if (searchPayload->getInstructions()) { diff --git a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h index b64749b..2d8ec85 100644 --- a/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SearchPayloadSerializer.h @@ -17,6 +17,6 @@ namespace Swift { public: SearchPayloadSerializer(); - virtual String serializePayload(boost::shared_ptr<SearchPayload>) const; + virtual std::string serializePayload(boost::shared_ptr<SearchPayload>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp index 841cb0a..b9ec55e 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp @@ -15,14 +15,14 @@ namespace Swift { SecurityLabelSerializer::SecurityLabelSerializer() : GenericPayloadSerializer<SecurityLabel>() { } -String SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel> label) const { +std::string SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel> label) const { XMLElement element("securitylabel", "urn:xmpp:sec-label:0"); - if (!label->getDisplayMarking().isEmpty()) { + if (!label->getDisplayMarking().empty()) { boost::shared_ptr<XMLElement> displayMarking(new XMLElement("displaymarking")); - if (!label->getForegroundColor().isEmpty()) { + if (!label->getForegroundColor().empty()) { displayMarking->setAttribute("fgcolor", label->getForegroundColor()); } - if (!label->getBackgroundColor().isEmpty()) { + if (!label->getBackgroundColor().empty()) { displayMarking->setAttribute("bgcolor", label->getBackgroundColor()); } displayMarking->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(label->getDisplayMarking()))); @@ -33,7 +33,7 @@ String SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel labelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(label->getLabel()))); element.addNode(labelElement); - foreach(const String& equivalentLabel, label->getEquivalentLabels()) { + foreach(const std::string& equivalentLabel, label->getEquivalentLabels()) { boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel")); equivalentLabelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(equivalentLabel))); element.addNode(equivalentLabelElement); diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h index 513655e..a02aeb9 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SecurityLabelSerializer(); - virtual String serializePayload(boost::shared_ptr<SecurityLabel> version) const; + virtual std::string serializePayload(boost::shared_ptr<SecurityLabel> version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp index e44e30e..5e4d8e4 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.cpp @@ -15,19 +15,19 @@ namespace Swift { SecurityLabelsCatalogSerializer::SecurityLabelsCatalogSerializer() : GenericPayloadSerializer<SecurityLabelsCatalog>() { } -String SecurityLabelsCatalogSerializer::serializePayload(boost::shared_ptr<SecurityLabelsCatalog> catalog) const { +std::string SecurityLabelsCatalogSerializer::serializePayload(boost::shared_ptr<SecurityLabelsCatalog> catalog) const { XMLElement element("catalog", "urn:xmpp:sec-label:catalog:0"); - if (!catalog->getName().isEmpty()) { + if (!catalog->getName().empty()) { element.setAttribute("name", catalog->getName()); } if (catalog->getTo().isValid()) { element.setAttribute("to", catalog->getTo()); } - if (!catalog->getDescription().isEmpty()) { + if (!catalog->getDescription().empty()) { element.setAttribute("desc", catalog->getDescription()); } foreach (const SecurityLabel& label, catalog->getLabels()) { - String serializedLabel = SecurityLabelSerializer().serialize(boost::shared_ptr<SecurityLabel>(new SecurityLabel(label))); + std::string serializedLabel = SecurityLabelSerializer().serialize(boost::shared_ptr<SecurityLabel>(new SecurityLabel(label))); element.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(serializedLabel))); } return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h index 2379ec1..88a1541 100644 --- a/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelsCatalogSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SecurityLabelsCatalogSerializer(); - virtual String serializePayload(boost::shared_ptr<SecurityLabelsCatalog> version) const; + virtual std::string serializePayload(boost::shared_ptr<SecurityLabelsCatalog> version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp index f38b2fd..b2eb1ed 100644 --- a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.cpp @@ -11,15 +11,15 @@ namespace Swift { SoftwareVersionSerializer::SoftwareVersionSerializer() : GenericPayloadSerializer<SoftwareVersion>() { } -String SoftwareVersionSerializer::serializePayload(boost::shared_ptr<SoftwareVersion> version) const { - String result("<query xmlns=\"jabber:iq:version\">"); - if (!version->getName().isEmpty()) { +std::string SoftwareVersionSerializer::serializePayload(boost::shared_ptr<SoftwareVersion> version) const { + std::string result("<query xmlns=\"jabber:iq:version\">"); + if (!version->getName().empty()) { result += "<name>" + version->getName() + "</name>"; } - if (!version->getVersion().isEmpty()) { + if (!version->getVersion().empty()) { result += "<version>" + version->getVersion() + "</version>"; } - if (!version->getOS().isEmpty()) { + if (!version->getOS().empty()) { result += "<os>" + version->getOS() + "</os>"; } result += "</query>"; diff --git a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h index 7f01b12..72f4afd 100644 --- a/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SoftwareVersionSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SoftwareVersionSerializer(); - virtual String serializePayload(boost::shared_ptr<SoftwareVersion> version) const; + virtual std::string serializePayload(boost::shared_ptr<SoftwareVersion> version) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h b/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h index 58930b4..dd9ba97 100644 --- a/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StartSessionSerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: StartSessionSerializer() : GenericPayloadSerializer<StartSession>() {} - virtual String serializePayload(boost::shared_ptr<StartSession>) const { + virtual std::string serializePayload(boost::shared_ptr<StartSession>) const { return XMLElement("session", "urn:ietf:params:xml:ns:xmpp-session").serialize(); } }; diff --git a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h index 8de7040..565d554 100644 --- a/Swiften/Serializer/PayloadSerializers/StatusSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StatusSerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: StatusSerializer() : GenericPayloadSerializer<Status>() {} - virtual String serializePayload(boost::shared_ptr<Status> status) const { + virtual std::string serializePayload(boost::shared_ptr<Status> status) const { XMLElement element("status"); element.addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(status->getText()))); return element.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h b/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h index 9102fde..e797e81 100644 --- a/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StatusShowSerializer.h @@ -15,12 +15,12 @@ namespace Swift { public: StatusShowSerializer() : GenericPayloadSerializer<StatusShow>() {} - virtual String serializePayload(boost::shared_ptr<StatusShow> statusShow) const { + virtual std::string serializePayload(boost::shared_ptr<StatusShow> statusShow) const { if (statusShow->getType () == StatusShow::Online || statusShow->getType() == StatusShow::None) { return ""; } else { - String result("<show>"); + std::string result("<show>"); switch (statusShow->getType()) { case StatusShow::Away: result += "away"; break; case StatusShow::XA: result += "xa"; break; diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp index 0de75e5..049c797 100644 --- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.cpp @@ -17,7 +17,7 @@ namespace Swift { StorageSerializer::StorageSerializer() : GenericPayloadSerializer<Storage>() { } -String StorageSerializer::serializePayload(boost::shared_ptr<Storage> storage) const { +std::string StorageSerializer::serializePayload(boost::shared_ptr<Storage> storage) const { XMLElement storageElement("storage", "storage:bookmarks"); foreach(const Storage::Room& room, storage->getRooms()) { @@ -25,12 +25,12 @@ String StorageSerializer::serializePayload(boost::shared_ptr<Storage> storage) c conferenceElement->setAttribute("name", room.name); conferenceElement->setAttribute("jid", room.jid); conferenceElement->setAttribute("autojoin", room.autoJoin ? "1" : "0"); - if (!room.nick.isEmpty()) { + if (!room.nick.empty()) { boost::shared_ptr<XMLElement> nickElement(new XMLElement("nick")); nickElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(room.nick))); conferenceElement->addNode(nickElement); } - if (!room.password.isEmpty()) { + if (!room.password.empty()) { boost::shared_ptr<XMLElement> passwordElement(new XMLElement("password")); passwordElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(room.password))); conferenceElement->addNode(passwordElement); diff --git a/Swiften/Serializer/PayloadSerializers/StorageSerializer.h b/Swiften/Serializer/PayloadSerializers/StorageSerializer.h index c045234..bc682a6 100644 --- a/Swiften/Serializer/PayloadSerializers/StorageSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StorageSerializer.h @@ -14,6 +14,6 @@ namespace Swift { public: StorageSerializer(); - virtual String serializePayload(boost::shared_ptr<Storage>) const; + virtual std::string serializePayload(boost::shared_ptr<Storage>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp index 0c7f593..70fb2ac 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp @@ -25,11 +25,11 @@ namespace Swift { StreamInitiationSerializer::StreamInitiationSerializer() { } -String StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInitiation> streamInitiation) const { +std::string StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInitiation> streamInitiation) const { assert(streamInitiation->getIsFileTransfer()); XMLElement siElement("si", "http://jabber.org/protocol/si"); - if (!streamInitiation->getID().isEmpty()) { + if (!streamInitiation->getID().empty()) { siElement.setAttribute("id", streamInitiation->getID()); } siElement.setAttribute("profile", FILE_TRANSFER_NS); @@ -41,7 +41,7 @@ String StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInit if (file.size != -1) { fileElement->setAttribute("size", boost::lexical_cast<std::string>(file.size)); } - if (!file.description.isEmpty()) { + if (!file.description.empty()) { boost::shared_ptr<XMLElement> descElement(new XMLElement("desc")); descElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(file.description))); fileElement->addNode(descElement); @@ -54,13 +54,13 @@ String StreamInitiationSerializer::serializePayload(boost::shared_ptr<StreamInit Form::ref form(new Form(Form::FormType)); ListSingleFormField::ref field = ListSingleFormField::create(); field->setName("stream-method"); - foreach(const String& method, streamInitiation->getProvidedMethods()) { + foreach(const std::string& method, streamInitiation->getProvidedMethods()) { field->addOption(FormField::Option("", method)); } form->addField(field); featureElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(FormSerializer().serialize(form)))); } - else if (!streamInitiation->getRequestedMethod().isEmpty()) { + else if (!streamInitiation->getRequestedMethod().empty()) { Form::ref form(new Form(Form::SubmitType)); ListSingleFormField::ref field = ListSingleFormField::create(streamInitiation->getRequestedMethod()); field->setName("stream-method"); diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h index 35c71b9..0b51519 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.h @@ -16,6 +16,6 @@ namespace Swift { public: StreamInitiationSerializer(); - virtual String serializePayload(boost::shared_ptr<StreamInitiation>) const; + virtual std::string serializePayload(boost::shared_ptr<StreamInitiation>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h b/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h index fcd82a5..cf78ddd 100644 --- a/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/SubjectSerializer.h @@ -15,7 +15,7 @@ namespace Swift { public: SubjectSerializer() : GenericPayloadSerializer<Subject>() {} - virtual String serializePayload(boost::shared_ptr<Subject> subject) const { + virtual std::string serializePayload(boost::shared_ptr<Subject> subject) const { XMLTextNode textNode(subject->getText()); return "<subject>" + textNode.serialize() + "</subject>"; } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp index 87c5f9d..2604331 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp @@ -24,7 +24,7 @@ class CapsInfoSerializerTest : public CppUnit::TestFixture CapsInfoSerializer testling; boost::shared_ptr<CapsInfo> priority(new CapsInfo("http://swift.im", "myversion", "sha-1")); - CPPUNIT_ASSERT_EQUAL(String("<c hash=\"sha-1\" node=\"http://swift.im\" ver=\"myversion\" xmlns=\"http://jabber.org/protocol/caps\"/>"), testling.serialize(priority)); + CPPUNIT_ASSERT_EQUAL(std::string("<c hash=\"sha-1\" node=\"http://swift.im\" ver=\"myversion\" xmlns=\"http://jabber.org/protocol/caps\"/>"), testling.serialize(priority)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp index c67fcdb..3875efd 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp @@ -30,7 +30,7 @@ class DiscoInfoSerializerTest : public CppUnit::TestFixture discoInfo->addFeature("http://jabber.org/protocol/disco#info"); discoInfo->setNode("http://swift.im#bla"); - String expectedResult = + std::string expectedResult = "<query node=\"http://swift.im#bla\" xmlns=\"http://jabber.org/protocol/disco#info\">" "<identity category=\"client\" name=\"Swift\" type=\"pc\"/>" "<identity category=\"client\" name=\"Vlug\" type=\"pc\" xml:lang=\"nl\"/>" @@ -50,7 +50,7 @@ class DiscoInfoSerializerTest : public CppUnit::TestFixture form->setTitle("Bot Configuration"); discoInfo->addExtension(form); - String expectedResult = + std::string expectedResult = "<query xmlns=\"http://jabber.org/protocol/disco#info\">" "<feature var=\"http://jabber.org/protocol/caps\"/>" "<feature var=\"http://jabber.org/protocol/disco#info\"/>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp index 2d392b0..dd06244 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp @@ -24,7 +24,7 @@ class ErrorSerializerTest : public CppUnit::TestFixture ErrorSerializer testling; boost::shared_ptr<ErrorPayload> error(new ErrorPayload(ErrorPayload::BadRequest, ErrorPayload::Cancel, "My Error")); - CPPUNIT_ASSERT_EQUAL(String("<error type=\"cancel\"><bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">My Error</text></error>"), testling.serialize(error)); + CPPUNIT_ASSERT_EQUAL(std::string("<error type=\"cancel\"><bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">My Error</text></error>"), testling.serialize(error)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp index 4ed3ba9..e4a6661 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/FormSerializerTest.cpp @@ -24,7 +24,7 @@ class FormSerializerTest : public CppUnit::TestFixture { form->setTitle("Bot Configuration"); form->setInstructions("Hello!\nFill out this form to configure your new bot!"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<x type=\"form\" xmlns=\"jabber:x:data\">" "<title>Bot Configuration</title>" "<instructions>Hello!</instructions>" @@ -63,7 +63,7 @@ class FormSerializerTest : public CppUnit::TestFixture { field->setLabel("Password for special access"); form->addField(field); - std::vector<String> values; + std::vector<std::string> values; values.push_back("news"); values.push_back("search"); field = ListMultiFormField::create(values); @@ -96,14 +96,14 @@ class FormSerializerTest : public CppUnit::TestFixture { field->setDescription("Tell all your friends about your new bot!"); form->addField(field); - std::vector<String> values2; + std::vector<std::string> values2; values2.push_back("foo"); values2.push_back("bar"); field = UntypedFormField::create(values2); field->setName("fum"); form->addField(field); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<x type=\"form\" xmlns=\"jabber:x:data\">" "<field type=\"hidden\" var=\"FORM_TYPE\">" "<value>jabber:bot</value>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp index 1654abc..7020537 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/InBandRegistrationPayloadSerializerTest.cpp @@ -23,7 +23,7 @@ class InBandRegistrationPayloadSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<InBandRegistrationPayload> registration(new InBandRegistrationPayload()); registration->setRegistered(true); - String expectedResult = + std::string expectedResult = "<query xmlns=\"jabber:iq:register\">" "<registered/>" "</query>"; @@ -43,7 +43,7 @@ class InBandRegistrationPayloadSerializerTest : public CppUnit::TestFixture { form->addField(field); registration->setForm(form); - String expectedResult = + std::string expectedResult = "<query xmlns=\"jabber:iq:register\">" "<instructions>Use the enclosed form to register.</instructions>" "<x type=\"form\" xmlns=\"jabber:x:data\">" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp index d1dbba9..481d9c2 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp @@ -12,7 +12,7 @@ namespace Swift { -String PayloadsSerializer::serialize(boost::shared_ptr<Payload> payload) { +std::string PayloadsSerializer::serialize(boost::shared_ptr<Payload> payload) { PayloadSerializer* serializer = serializers.getPayloadSerializer(payload); if (serializer) { return serializer->serialize(payload); diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h index 066c481..038b616 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h @@ -9,13 +9,13 @@ #include <boost/shared_ptr.hpp> #include "Swiften/Elements/Payload.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h" namespace Swift { class PayloadsSerializer { public: - String serialize(boost::shared_ptr<Payload> payload); + std::string serialize(boost::shared_ptr<Payload> payload); private: FullPayloadSerializerCollection serializers; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp index 12d9359..c976b12 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PrioritySerializerTest.cpp @@ -24,7 +24,7 @@ class PrioritySerializerTest : public CppUnit::TestFixture PrioritySerializer testling; boost::shared_ptr<Priority> priority(new Priority(-113)); - CPPUNIT_ASSERT_EQUAL(String("<priority>-113</priority>"), testling.serialize(priority)); + CPPUNIT_ASSERT_EQUAL(std::string("<priority>-113</priority>"), testling.serialize(priority)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp index 59df665..b0f4084 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PrivateStorageSerializerTest.cpp @@ -33,7 +33,7 @@ class PrivateStorageSerializerTest : public CppUnit::TestFixture { storage->addRoom(room); privateStorage->setPayload(storage); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<query xmlns=\"jabber:iq:private\">" "<storage xmlns=\"storage:bookmarks\">" "<conference " diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp index 83b75a9..c7872fe 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ResourceBindSerializerTest.cpp @@ -27,7 +27,7 @@ class ResourceBindSerializerTest : public CppUnit::TestFixture boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind()); resourceBind->setJID(JID("somenode@example.com/someresource")); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" "<jid>somenode@example.com/someresource</jid>" "</bind>"), testling.serialize(resourceBind)); @@ -38,7 +38,7 @@ class ResourceBindSerializerTest : public CppUnit::TestFixture boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind()); resourceBind->setResource("someresource"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\">" "<resource>someresource</resource>" "</bind>"), testling.serialize(resourceBind)); @@ -48,7 +48,7 @@ class ResourceBindSerializerTest : public CppUnit::TestFixture ResourceBindSerializer testling; boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind()); - CPPUNIT_ASSERT_EQUAL(String("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"), testling.serialize(resourceBind)); + CPPUNIT_ASSERT_EQUAL(std::string("<bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/>"), testling.serialize(resourceBind)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp index bf30db8..b8ceac3 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp @@ -39,7 +39,7 @@ class RosterSerializerTest : public CppUnit::TestFixture item2.setName("Baz"); roster->addItem(item2); - String expectedResult = + std::string expectedResult = "<query xmlns=\"jabber:iq:roster\">" "<item ask=\"subscribe\" jid=\"foo@bar.com\" name=\"Foo @ Bar\" subscription=\"from\">" "<group>Group 1</group>" @@ -60,12 +60,12 @@ class RosterSerializerTest : public CppUnit::TestFixture item.setName("Baz"); item.addGroup("Group 1"); item.addGroup("Group 2"); - item.addUnknownContent(String( + item.addUnknownContent(std::string( "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>" "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>")); roster->addItem(item); - String expectedResult = + std::string expectedResult = "<query xmlns=\"jabber:iq:roster\">" "<item jid=\"baz@blo.com\" name=\"Baz\" subscription=\"none\">" "<group>Group 1</group>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp index 40951ec..e8328b8 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SearchPayloadSerializerTest.cpp @@ -25,7 +25,7 @@ class SearchPayloadSerializerTest : public CppUnit::TestFixture { payload->setFirst("Juliet"); payload->setLast("Capulet"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<query xmlns=\"jabber:iq:search\">" "<first>Juliet</first>" "<last>Capulet</last>" @@ -53,7 +53,7 @@ class SearchPayloadSerializerTest : public CppUnit::TestFixture { item2.email = "tybalt@shakespeare.lit"; payload->addItem(item2); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<query xmlns=\"jabber:iq:search\">" "<item jid=\"juliet@capulet.com\">" "<first>Juliet</first>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp index bf2139e..03bad89 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp @@ -28,7 +28,7 @@ class SecurityLabelSerializerTest : public CppUnit::TestFixture { securityLabel->addEquivalentLabel("<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>"); securityLabel->addEquivalentLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">" "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>" "<label>" @@ -49,7 +49,7 @@ class SecurityLabelSerializerTest : public CppUnit::TestFixture { securityLabel->setDisplayMarking("SECRET"); securityLabel->setLabel(""); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">" "<displaymarking>SECRET</displaymarking>" "<label></label>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp index 9d471d1..928f209 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelsCatalogSerializerTest.cpp @@ -41,7 +41,7 @@ class SecurityLabelsCatalogSerializerTest : public CppUnit::TestFixture securityLabel2.setLabel("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>"); catalog->addLabel(securityLabel2); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<catalog desc=\"an example set of labels\" name=\"Default\" to=\"example.com\" xmlns=\"urn:xmpp:sec-label:catalog:0\">" "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">" "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp index 963df9f..6fac094 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SoftwareVersionSerializerTest.cpp @@ -24,7 +24,7 @@ class SoftwareVersionSerializerTest : public CppUnit::TestFixture SoftwareVersionSerializer testling; boost::shared_ptr<SoftwareVersion> softwareVersion(new SoftwareVersion("Swift", "0.1", "Mac OS X")); - CPPUNIT_ASSERT_EQUAL(String("<query xmlns=\"jabber:iq:version\"><name>Swift</name><version>0.1</version><os>Mac OS X</os></query>"), testling.serialize(softwareVersion)); + CPPUNIT_ASSERT_EQUAL(std::string("<query xmlns=\"jabber:iq:version\"><name>Swift</name><version>0.1</version><os>Mac OS X</os></query>"), testling.serialize(softwareVersion)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp index 9a8c9d9..c0b1dc2 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusSerializerTest.cpp @@ -24,7 +24,7 @@ class StatusSerializerTest : public CppUnit::TestFixture StatusSerializer testling; boost::shared_ptr<Status> status(new Status("I am away")); - CPPUNIT_ASSERT_EQUAL(String("<status>I am away</status>"), testling.serialize(status)); + CPPUNIT_ASSERT_EQUAL(std::string("<status>I am away</status>"), testling.serialize(status)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp index f165f1c..2fee152 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StatusShowSerializerTest.cpp @@ -27,37 +27,37 @@ class StatusShowSerializerTest : public CppUnit::TestFixture void testSerialize_Online() { StatusShowSerializer testling; boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::Online)); - CPPUNIT_ASSERT_EQUAL(String(""), testling.serialize(statusShow)); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(statusShow)); } void testSerialize_Away() { StatusShowSerializer testling; boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::Away)); - CPPUNIT_ASSERT_EQUAL(String("<show>away</show>"), testling.serialize(statusShow)); + CPPUNIT_ASSERT_EQUAL(std::string("<show>away</show>"), testling.serialize(statusShow)); } void testSerialize_FFC() { StatusShowSerializer testling; boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::FFC)); - CPPUNIT_ASSERT_EQUAL(String("<show>chat</show>"), testling.serialize(statusShow)); + CPPUNIT_ASSERT_EQUAL(std::string("<show>chat</show>"), testling.serialize(statusShow)); } void testSerialize_XA() { StatusShowSerializer testling; boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::XA)); - CPPUNIT_ASSERT_EQUAL(String("<show>xa</show>"), testling.serialize(statusShow)); + CPPUNIT_ASSERT_EQUAL(std::string("<show>xa</show>"), testling.serialize(statusShow)); } void testSerialize_DND() { StatusShowSerializer testling; boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::DND)); - CPPUNIT_ASSERT_EQUAL(String("<show>dnd</show>"), testling.serialize(statusShow)); + CPPUNIT_ASSERT_EQUAL(std::string("<show>dnd</show>"), testling.serialize(statusShow)); } void testSerialize_None() { StatusShowSerializer testling; boost::shared_ptr<StatusShow> statusShow(new StatusShow(StatusShow::None)); - CPPUNIT_ASSERT_EQUAL(String(""), testling.serialize(statusShow)); + CPPUNIT_ASSERT_EQUAL(std::string(""), testling.serialize(statusShow)); } }; diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp index 8add953..01899a9 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp @@ -36,7 +36,7 @@ class StorageSerializerTest : public CppUnit::TestFixture { url.url = "http://the-tech.mit.edu/Shakespeare/"; storage->addURL(url); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<storage xmlns=\"storage:bookmarks\">" "<conference " "autojoin=\"1\" " @@ -58,7 +58,7 @@ class StorageSerializerTest : public CppUnit::TestFixture { room.jid = JID("council@conference.underhill.org"); storage->addRoom(room); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<storage xmlns=\"storage:bookmarks\">" "<conference " "autojoin=\"1\" " diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp index e1a13b8..d05fdba 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StreamInitiationSerializerTest.cpp @@ -28,7 +28,7 @@ class StreamInitiationSerializerTest : public CppUnit::TestFixture{ streamInitiation->addProvidedMethod("jabber:iq:oob"); streamInitiation->addProvidedMethod("http://jabber.org/protocol/ibb"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<si id=\"a0\" profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">" "<file name=\"test.txt\" size=\"1022\" xmlns=\"http://jabber.org/protocol/si/profile/file-transfer\">" "<desc>This is info about the file.</desc>" @@ -51,7 +51,7 @@ class StreamInitiationSerializerTest : public CppUnit::TestFixture{ boost::shared_ptr<StreamInitiation> streamInitiation(new StreamInitiation()); streamInitiation->setRequestedMethod("http://jabber.org/protocol/bytestreams"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<si profile=\"http://jabber.org/protocol/si/profile/file-transfer\" xmlns=\"http://jabber.org/protocol/si\">" "<feature xmlns=\"http://jabber.org/protocol/feature-neg\">" "<x type=\"submit\" xmlns=\"jabber:x:data\">" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp index 82a3ec8..8a9a615 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardSerializerTest.cpp @@ -46,7 +46,7 @@ class VCardSerializerTest : public CppUnit::TestFixture address2.isX400 = true; vcard->addEMailAddress(address2); - String expectedResult = + std::string expectedResult = "<vCard xmlns=\"vcard-temp\">" "<VERSION>2.0</VERSION>" "<FN>Alice In Wonderland</FN>" diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp index a926142..6f37d61 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/VCardUpdateSerializerTest.cpp @@ -25,7 +25,7 @@ class VCardUpdateSerializerTest : public CppUnit::TestFixture boost::shared_ptr<VCardUpdate> update(new VCardUpdate()); update->setPhotoHash("sha1-hash-of-image"); - String expectedResult = + std::string expectedResult = "<x xmlns=\"vcard-temp:x:update\">" "<photo>sha1-hash-of-image</photo>" "</x>"; diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp index bb09469..79e543e 100644 --- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.cpp @@ -19,41 +19,41 @@ namespace Swift { VCardSerializer::VCardSerializer() : GenericPayloadSerializer<VCard>() { } -String VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const { +std::string VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const { XMLElement queryElement("vCard", "vcard-temp"); - if (!vcard->getVersion().isEmpty()) { + if (!vcard->getVersion().empty()) { boost::shared_ptr<XMLElement> versionElement(new XMLElement("VERSION")); versionElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getVersion()))); queryElement.addNode(versionElement); } - if (!vcard->getFullName().isEmpty()) { + if (!vcard->getFullName().empty()) { boost::shared_ptr<XMLElement> fullNameElement(new XMLElement("FN")); fullNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getFullName()))); queryElement.addNode(fullNameElement); } - if (!vcard->getGivenName().isEmpty() || !vcard->getFamilyName().isEmpty() || !vcard->getMiddleName().isEmpty() || !vcard->getPrefix().isEmpty() || !vcard->getSuffix().isEmpty()) { + if (!vcard->getGivenName().empty() || !vcard->getFamilyName().empty() || !vcard->getMiddleName().empty() || !vcard->getPrefix().empty() || !vcard->getSuffix().empty()) { boost::shared_ptr<XMLElement> nameElement(new XMLElement("N")); - if (!vcard->getFamilyName().isEmpty()) { + if (!vcard->getFamilyName().empty()) { boost::shared_ptr<XMLElement> familyNameElement(new XMLElement("FAMILY")); familyNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getFamilyName()))); nameElement->addNode(familyNameElement); } - if (!vcard->getGivenName().isEmpty()) { + if (!vcard->getGivenName().empty()) { boost::shared_ptr<XMLElement> givenNameElement(new XMLElement("GIVEN")); givenNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getGivenName()))); nameElement->addNode(givenNameElement); } - if (!vcard->getMiddleName().isEmpty()) { + if (!vcard->getMiddleName().empty()) { boost::shared_ptr<XMLElement> middleNameElement(new XMLElement("MIDDLE")); middleNameElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getMiddleName()))); nameElement->addNode(middleNameElement); } - if (!vcard->getPrefix().isEmpty()) { + if (!vcard->getPrefix().empty()) { boost::shared_ptr<XMLElement> prefixElement(new XMLElement("PREFIX")); prefixElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getPrefix()))); nameElement->addNode(prefixElement); } - if (!vcard->getSuffix().isEmpty()) { + if (!vcard->getSuffix().empty()) { boost::shared_ptr<XMLElement> suffixElement(new XMLElement("SUFFIX")); suffixElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getSuffix()))); nameElement->addNode(suffixElement); @@ -82,14 +82,14 @@ String VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const } queryElement.addNode(emailElement); } - if (!vcard->getNickname().isEmpty()) { + if (!vcard->getNickname().empty()) { boost::shared_ptr<XMLElement> nickElement(new XMLElement("NICKNAME")); nickElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcard->getNickname()))); queryElement.addNode(nickElement); } - if (!vcard->getPhoto().isEmpty() || !vcard->getPhotoType().isEmpty()) { + if (!vcard->getPhoto().isEmpty() || !vcard->getPhotoType().empty()) { XMLElement::ref photoElement(new XMLElement("PHOTO")); - if (!vcard->getPhotoType().isEmpty()) { + if (!vcard->getPhotoType().empty()) { XMLElement::ref typeElement(new XMLElement("TYPE")); typeElement->addNode(XMLTextNode::ref(new XMLTextNode(vcard->getPhotoType()))); photoElement->addNode(typeElement); @@ -101,7 +101,7 @@ String VCardSerializer::serializePayload(boost::shared_ptr<VCard> vcard) const } queryElement.addNode(photoElement); } - if (!vcard->getUnknownContent().isEmpty()) { + if (!vcard->getUnknownContent().empty()) { queryElement.addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(vcard->getUnknownContent()))); } return queryElement.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/VCardSerializer.h b/Swiften/Serializer/PayloadSerializers/VCardSerializer.h index 79f0524..7b9a8a9 100644 --- a/Swiften/Serializer/PayloadSerializers/VCardSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/VCardSerializer.h @@ -14,6 +14,6 @@ namespace Swift { public: VCardSerializer(); - virtual String serializePayload(boost::shared_ptr<VCard>) const; + virtual std::string serializePayload(boost::shared_ptr<VCard>) const; }; } diff --git a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp index f95995d..e315bc3 100644 --- a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.cpp @@ -16,7 +16,7 @@ namespace Swift { VCardUpdateSerializer::VCardUpdateSerializer() : GenericPayloadSerializer<VCardUpdate>() { } -String VCardUpdateSerializer::serializePayload(boost::shared_ptr<VCardUpdate> vcardUpdate) const { +std::string VCardUpdateSerializer::serializePayload(boost::shared_ptr<VCardUpdate> vcardUpdate) const { XMLElement updateElement("x", "vcard-temp:x:update"); boost::shared_ptr<XMLElement> photoElement(new XMLElement("photo")); photoElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(vcardUpdate->getPhotoHash()))); diff --git a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h index 19610eb..46ca154 100644 --- a/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/VCardUpdateSerializer.h @@ -14,6 +14,6 @@ namespace Swift { public: VCardUpdateSerializer(); - virtual String serializePayload(boost::shared_ptr<VCardUpdate>) const; + virtual std::string serializePayload(boost::shared_ptr<VCardUpdate>) const; }; } diff --git a/Swiften/Serializer/StanzaAckRequestSerializer.h b/Swiften/Serializer/StanzaAckRequestSerializer.h index 26d015d..b03a2c2 100644 --- a/Swiften/Serializer/StanzaAckRequestSerializer.h +++ b/Swiften/Serializer/StanzaAckRequestSerializer.h @@ -18,7 +18,7 @@ namespace Swift { StanzaAckRequestSerializer() : GenericElementSerializer<StanzaAckRequest>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("r", "urn:xmpp:sm:2").serialize(); } }; diff --git a/Swiften/Serializer/StanzaAckSerializer.h b/Swiften/Serializer/StanzaAckSerializer.h index d29fbde..984509f 100644 --- a/Swiften/Serializer/StanzaAckSerializer.h +++ b/Swiften/Serializer/StanzaAckSerializer.h @@ -19,11 +19,11 @@ namespace Swift { StanzaAckSerializer() : GenericElementSerializer<StanzaAck>() { } - virtual String serialize(boost::shared_ptr<Element> element) const { + virtual std::string serialize(boost::shared_ptr<Element> element) const { StanzaAck::ref stanzaAck(boost::dynamic_pointer_cast<StanzaAck>(element)); assert(stanzaAck->isValid()); XMLElement result("a", "urn:xmpp:sm:2"); - result.setAttribute("h", String(boost::lexical_cast<std::string>(stanzaAck->getHandledStanzasCount()))); + result.setAttribute("h", std::string(boost::lexical_cast<std::string>(stanzaAck->getHandledStanzasCount()))); return result.serialize(); } }; diff --git a/Swiften/Serializer/StanzaSerializer.cpp b/Swiften/Serializer/StanzaSerializer.cpp index 36976ce..cfc9a43 100644 --- a/Swiften/Serializer/StanzaSerializer.cpp +++ b/Swiften/Serializer/StanzaSerializer.cpp @@ -18,10 +18,10 @@ namespace Swift { -StanzaSerializer::StanzaSerializer(const String& tag, PayloadSerializerCollection* payloadSerializers) : tag_(tag), payloadSerializers_(payloadSerializers) { +StanzaSerializer::StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers) : tag_(tag), payloadSerializers_(payloadSerializers) { } -String StanzaSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string StanzaSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<Stanza> stanza(boost::dynamic_pointer_cast<Stanza>(element)); XMLElement stanzaElement(tag_); @@ -31,12 +31,12 @@ String StanzaSerializer::serialize(boost::shared_ptr<Element> element) const { if (stanza->getTo().isValid()) { stanzaElement.setAttribute("to", stanza->getTo()); } - if (!stanza->getID().isEmpty()) { + if (!stanza->getID().empty()) { stanzaElement.setAttribute("id", stanza->getID()); } setStanzaSpecificAttributes(stanza, stanzaElement); - String serializedPayloads; + std::string serializedPayloads; foreach (const boost::shared_ptr<Payload>& payload, stanza->getPayloads()) { PayloadSerializer* serializer = payloadSerializers_->getPayloadSerializer(payload); if (serializer) { @@ -46,7 +46,7 @@ String StanzaSerializer::serialize(boost::shared_ptr<Element> element) const { std::cerr << "Could not find serializer for " << typeid(*(payload.get())).name() << std::endl; } } - if (!serializedPayloads.isEmpty()) { + if (!serializedPayloads.empty()) { stanzaElement.addNode(boost::shared_ptr<XMLNode>(new XMLRawTextNode(serializedPayloads))); } diff --git a/Swiften/Serializer/StanzaSerializer.h b/Swiften/Serializer/StanzaSerializer.h index e89665c..505d320 100644 --- a/Swiften/Serializer/StanzaSerializer.h +++ b/Swiften/Serializer/StanzaSerializer.h @@ -9,7 +9,7 @@ #include "Swiften/Elements/Stanza.h" #include "Swiften/Serializer/ElementSerializer.h" -#include "Swiften/Base/String.h" +#include <string> namespace Swift { class PayloadSerializerCollection; @@ -17,13 +17,13 @@ namespace Swift { class StanzaSerializer : public ElementSerializer { public: - StanzaSerializer(const String& tag, PayloadSerializerCollection* payloadSerializers); + StanzaSerializer(const std::string& tag, PayloadSerializerCollection* payloadSerializers); - virtual String serialize(boost::shared_ptr<Element>) const; + virtual std::string serialize(boost::shared_ptr<Element>) const; virtual void setStanzaSpecificAttributes(boost::shared_ptr<Element>, XMLElement&) const = 0; private: - String tag_; + std::string tag_; PayloadSerializerCollection* payloadSerializers_; }; } diff --git a/Swiften/Serializer/StartTLSFailureSerializer.h b/Swiften/Serializer/StartTLSFailureSerializer.h index 8827db6..548a24c 100644 --- a/Swiften/Serializer/StartTLSFailureSerializer.h +++ b/Swiften/Serializer/StartTLSFailureSerializer.h @@ -19,7 +19,7 @@ namespace Swift { StartTLSFailureSerializer() : GenericElementSerializer<StartTLSFailure>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("failure", "urn:ietf:params:xml:ns:xmpp-tls").serialize(); } }; diff --git a/Swiften/Serializer/StartTLSRequestSerializer.h b/Swiften/Serializer/StartTLSRequestSerializer.h index 5599f2a..2e9ecfa 100644 --- a/Swiften/Serializer/StartTLSRequestSerializer.h +++ b/Swiften/Serializer/StartTLSRequestSerializer.h @@ -19,7 +19,7 @@ namespace Swift { StartTLSRequestSerializer() : GenericElementSerializer<StartTLSRequest>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("starttls", "urn:ietf:params:xml:ns:xmpp-tls").serialize(); } }; diff --git a/Swiften/Serializer/StreamErrorSerializer.cpp b/Swiften/Serializer/StreamErrorSerializer.cpp index b88f5c4..11f8a30 100644 --- a/Swiften/Serializer/StreamErrorSerializer.cpp +++ b/Swiften/Serializer/StreamErrorSerializer.cpp @@ -15,11 +15,11 @@ namespace Swift { StreamErrorSerializer::StreamErrorSerializer() : GenericElementSerializer<StreamError>() { } -String StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) const { StreamError::ref error = boost::dynamic_pointer_cast<StreamError>(element); XMLElement errorElement("error", "http://etherx.jabber.org/streams"); - String typeTag; + std::string typeTag; switch (error->getType()) { case StreamError::BadFormat: typeTag = "bad-format"; break; case StreamError::BadNamespacePrefix: typeTag = "bad-namespace-prefix"; break; @@ -49,7 +49,7 @@ String StreamErrorSerializer::serialize(boost::shared_ptr<Element> element) con } errorElement.addNode(boost::make_shared<XMLElement>(typeTag, "urn:ietf:params:xml:ns:xmpp-streams")); - if (!error->getText().isEmpty()) { + if (!error->getText().empty()) { errorElement.addNode(boost::make_shared<XMLElement>("text", "urn:ietf:params:xml:ns:xmpp-streams", error->getText())); } diff --git a/Swiften/Serializer/StreamErrorSerializer.h b/Swiften/Serializer/StreamErrorSerializer.h index 1a7bb79..9d4f60c 100644 --- a/Swiften/Serializer/StreamErrorSerializer.h +++ b/Swiften/Serializer/StreamErrorSerializer.h @@ -14,6 +14,6 @@ namespace Swift { public: StreamErrorSerializer(); - virtual String serialize(boost::shared_ptr<Element> error) const; + virtual std::string serialize(boost::shared_ptr<Element> error) const; }; } diff --git a/Swiften/Serializer/StreamFeaturesSerializer.cpp b/Swiften/Serializer/StreamFeaturesSerializer.cpp index ec21983..915433c 100644 --- a/Swiften/Serializer/StreamFeaturesSerializer.cpp +++ b/Swiften/Serializer/StreamFeaturesSerializer.cpp @@ -15,7 +15,7 @@ namespace Swift { StreamFeaturesSerializer::StreamFeaturesSerializer() { } -String StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) const { +std::string StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) const { boost::shared_ptr<StreamFeatures> streamFeatures(boost::dynamic_pointer_cast<StreamFeatures>(element)); XMLElement streamFeaturesElement("stream:features"); @@ -24,7 +24,7 @@ String StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) } if (!streamFeatures->getCompressionMethods().empty()) { boost::shared_ptr<XMLElement> compressionElement(new XMLElement("compression", "http://jabber.org/features/compress")); - foreach(const String& method, streamFeatures->getCompressionMethods()) { + foreach(const std::string& method, streamFeatures->getCompressionMethods()) { boost::shared_ptr<XMLElement> methodElement(new XMLElement("method")); methodElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(method))); compressionElement->addNode(methodElement); @@ -33,7 +33,7 @@ String StreamFeaturesSerializer::serialize(boost::shared_ptr<Element> element) } if (!streamFeatures->getAuthenticationMechanisms().empty()) { boost::shared_ptr<XMLElement> mechanismsElement(new XMLElement("mechanisms", "urn:ietf:params:xml:ns:xmpp-sasl")); - foreach(const String& mechanism, streamFeatures->getAuthenticationMechanisms()) { + foreach(const std::string& mechanism, streamFeatures->getAuthenticationMechanisms()) { boost::shared_ptr<XMLElement> mechanismElement(new XMLElement("mechanism")); mechanismElement->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(mechanism))); mechanismsElement->addNode(mechanismElement); diff --git a/Swiften/Serializer/StreamFeaturesSerializer.h b/Swiften/Serializer/StreamFeaturesSerializer.h index 004a1e5..3b475e0 100644 --- a/Swiften/Serializer/StreamFeaturesSerializer.h +++ b/Swiften/Serializer/StreamFeaturesSerializer.h @@ -17,7 +17,7 @@ namespace Swift { public: StreamFeaturesSerializer(); - virtual String serialize(boost::shared_ptr<Element> element) const; + virtual std::string serialize(boost::shared_ptr<Element> element) const; }; } diff --git a/Swiften/Serializer/StreamManagementEnabledSerializer.h b/Swiften/Serializer/StreamManagementEnabledSerializer.h index a135390..fc7bd86 100644 --- a/Swiften/Serializer/StreamManagementEnabledSerializer.h +++ b/Swiften/Serializer/StreamManagementEnabledSerializer.h @@ -18,7 +18,7 @@ namespace Swift { StreamManagementEnabledSerializer() : GenericElementSerializer<StreamManagementEnabled>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("enabled", "urn:xmpp:sm:2").serialize(); } }; diff --git a/Swiften/Serializer/StreamManagementFailedSerializer.h b/Swiften/Serializer/StreamManagementFailedSerializer.h index d6aa24b..b22ed0d 100644 --- a/Swiften/Serializer/StreamManagementFailedSerializer.h +++ b/Swiften/Serializer/StreamManagementFailedSerializer.h @@ -18,7 +18,7 @@ namespace Swift { StreamManagementFailedSerializer() : GenericElementSerializer<StreamManagementFailed>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("failed", "urn:xmpp:sm:2").serialize(); } }; diff --git a/Swiften/Serializer/TLSProceedSerializer.h b/Swiften/Serializer/TLSProceedSerializer.h index 217a272..1b08c23 100644 --- a/Swiften/Serializer/TLSProceedSerializer.h +++ b/Swiften/Serializer/TLSProceedSerializer.h @@ -19,7 +19,7 @@ namespace Swift { TLSProceedSerializer() : GenericElementSerializer<TLSProceed>() { } - virtual String serialize(boost::shared_ptr<Element>) const { + virtual std::string serialize(boost::shared_ptr<Element>) const { return XMLElement("proceed", "urn:ietf:params:xml:ns:xmpp-tls").serialize(); } }; diff --git a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp index dc828e0..af857ef 100644 --- a/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthChallengeSerializerTest.cpp @@ -25,7 +25,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge()); authChallenge->setValue("foo"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "Zm9v" "</challenge>"), testling.serialize(authChallenge)); @@ -35,7 +35,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture { AuthChallengeSerializer testling; boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge()); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "</challenge>"), testling.serialize(authChallenge)); } @@ -45,7 +45,7 @@ class AuthChallengeSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthChallenge> authChallenge(new AuthChallenge()); authChallenge->setValue(ByteArray()); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<challenge xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "=" "</challenge>"), testling.serialize(authChallenge)); diff --git a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp index f63db90..9f9f2fa 100644 --- a/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthRequestSerializerTest.cpp @@ -25,7 +25,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN")); authRequest->setMessage("foo"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" "Zm9v" "</auth>"), testling.serialize(authRequest)); @@ -35,7 +35,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture { AuthRequestSerializer testling; boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN")); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" "</auth>"), testling.serialize(authRequest)); } @@ -45,7 +45,7 @@ class AuthRequestSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthRequest> authRequest(new AuthRequest("PLAIN")); authRequest->setMessage(ByteArray()); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"PLAIN\">" "=" "</auth>"), testling.serialize(authRequest)); diff --git a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp index fabe834..c93810c 100644 --- a/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthResponseSerializerTest.cpp @@ -25,7 +25,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthResponse> authResponse(new AuthResponse()); authResponse->setValue("foo"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "Zm9v" "</response>"), testling.serialize(authResponse)); @@ -35,7 +35,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture { AuthResponseSerializer testling; boost::shared_ptr<AuthResponse> authResponse(new AuthResponse()); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "</response>"), testling.serialize(authResponse)); } @@ -45,7 +45,7 @@ class AuthResponseSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthResponse> authResponse(new AuthResponse()); authResponse->setValue(ByteArray()); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<response xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "=" "</response>"), testling.serialize(authResponse)); diff --git a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp index a9b602f..385c1e5 100644 --- a/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/AuthSuccessSerializerTest.cpp @@ -25,7 +25,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess()); authSuccess->setValue("foo"); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "Zm9v" "</success>"), testling.serialize(authSuccess)); @@ -35,7 +35,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture { AuthSuccessSerializer testling; boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess()); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "</success>"), testling.serialize(authSuccess)); } @@ -45,7 +45,7 @@ class AuthSuccessSerializerTest : public CppUnit::TestFixture { boost::shared_ptr<AuthSuccess> authSuccess(new AuthSuccess()); authSuccess->setValue(ByteArray()); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\">" "=" "</success>"), testling.serialize(authSuccess)); diff --git a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp index bd39bd8..65caa81 100644 --- a/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/StreamFeaturesSerializerTest.cpp @@ -33,7 +33,7 @@ class StreamFeaturesSerializerTest : public CppUnit::TestFixture streamFeatures->setHasSession(); streamFeatures->setHasStreamManagement(); - CPPUNIT_ASSERT_EQUAL(String( + CPPUNIT_ASSERT_EQUAL(std::string( "<stream:features>" "<starttls xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>" "<compression xmlns=\"http://jabber.org/features/compress\">" diff --git a/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp b/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp index 45ffe4b..76c1b23 100644 --- a/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp +++ b/Swiften/Serializer/UnitTest/XMPPSerializerTest.cpp @@ -38,7 +38,7 @@ class XMPPSerializerTest : public CppUnit::TestFixture { protocolHeader.setID("myid"); protocolHeader.setVersion("0.99"); - CPPUNIT_ASSERT_EQUAL(String("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader)); + CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader)); } void testSerializeHeader_Component() { @@ -49,7 +49,7 @@ class XMPPSerializerTest : public CppUnit::TestFixture { protocolHeader.setID("myid"); protocolHeader.setVersion("0.99"); - CPPUNIT_ASSERT_EQUAL(String("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:component:accept\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader)); + CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:component:accept\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader)); } void testSerializeHeader_Server() { @@ -60,7 +60,7 @@ class XMPPSerializerTest : public CppUnit::TestFixture { protocolHeader.setID("myid"); protocolHeader.setVersion("0.99"); - CPPUNIT_ASSERT_EQUAL(String("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:server\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader)); + CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:server\" xmlns:stream=\"http://etherx.jabber.org/streams\" from=\"bla@foo.com\" to=\"foo.com\" id=\"myid\" version=\"0.99\">"), testling->serializeHeader(protocolHeader)); } private: 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=\"<"'&>\"/>"), testling.serialize()); + CPPUNIT_ASSERT_EQUAL(std::string("<foo myatt=\"<"'&>\"/>"), 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('&', "&"); - escapedValue.replaceAll('<', "<"); - escapedValue.replaceAll('>', ">"); - escapedValue.replaceAll('\'', "'"); - escapedValue.replaceAll('"', """); +void XMLElement::setAttribute(const std::string& attribute, const std::string& value) { + std::string escapedValue(value); + String::replaceAll(escapedValue, '&', "&"); + String::replaceAll(escapedValue, '<', "<"); + String::replaceAll(escapedValue, '>', ">"); + String::replaceAll(escapedValue, '\'', "'"); + String::replaceAll(escapedValue, '"', """); 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('&', "&"); // Should come first - text_.replaceAll('<', "<"); - text_.replaceAll('>', ">"); + XMLTextNode(const std::string& text) : text_(text) { + String::replaceAll(text_, '&', "&"); // Should come first + String::replaceAll(text_, '<', "<"); + String::replaceAll(text_, '>', ">"); } - 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_; }; } diff --git a/Swiften/Serializer/XMPPSerializer.cpp b/Swiften/Serializer/XMPPSerializer.cpp index ad84152..06f3558 100644 --- a/Swiften/Serializer/XMPPSerializer.cpp +++ b/Swiften/Serializer/XMPPSerializer.cpp @@ -61,25 +61,25 @@ XMPPSerializer::XMPPSerializer(PayloadSerializerCollection* payloadSerializers, serializers_.push_back(boost::make_shared<ComponentHandshakeSerializer>()); } -String XMPPSerializer::serializeHeader(const ProtocolHeader& header) const { - String result = "<?xml version=\"1.0\"?><stream:stream xmlns=\"" + getDefaultNamespace() + "\" xmlns:stream=\"http://etherx.jabber.org/streams\""; - if (!header.getFrom().isEmpty()) { +std::string XMPPSerializer::serializeHeader(const ProtocolHeader& header) const { + std::string result = "<?xml version=\"1.0\"?><stream:stream xmlns=\"" + getDefaultNamespace() + "\" xmlns:stream=\"http://etherx.jabber.org/streams\""; + if (!header.getFrom().empty()) { result += " from=\"" + header.getFrom() + "\""; } - if (!header.getTo().isEmpty()) { + if (!header.getTo().empty()) { result += " to=\"" + header.getTo() + "\""; } - if (!header.getID().isEmpty()) { + if (!header.getID().empty()) { result += " id=\"" + header.getID() + "\""; } - if (!header.getVersion().isEmpty()) { + if (!header.getVersion().empty()) { result += " version=\"" + header.getVersion() + "\""; } result += ">"; return result; } -String XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) const { +std::string XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) const { std::vector< boost::shared_ptr<ElementSerializer> >::const_iterator i = std::find_if( serializers_.begin(), serializers_.end(), boost::bind(&ElementSerializer::canSerialize, _1, element)); @@ -92,11 +92,11 @@ String XMPPSerializer::serializeElement(boost::shared_ptr<Element> element) cons } } -String XMPPSerializer::serializeFooter() const { +std::string XMPPSerializer::serializeFooter() const { return "</stream:stream>"; } -String XMPPSerializer::getDefaultNamespace() const { +std::string XMPPSerializer::getDefaultNamespace() const { switch (type_) { case ClientStreamType: return "jabber:client"; case ServerStreamType: return "jabber:server"; diff --git a/Swiften/Serializer/XMPPSerializer.h b/Swiften/Serializer/XMPPSerializer.h index 13c2cf7..4f83857 100644 --- a/Swiften/Serializer/XMPPSerializer.h +++ b/Swiften/Serializer/XMPPSerializer.h @@ -11,7 +11,7 @@ #include "Swiften/Elements/Element.h" #include "Swiften/Elements/StreamType.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Serializer/ElementSerializer.h" namespace Swift { @@ -23,12 +23,12 @@ namespace Swift { public: XMPPSerializer(PayloadSerializerCollection*, StreamType type); - String serializeHeader(const ProtocolHeader&) const; - String serializeElement(boost::shared_ptr<Element> stanza) const; - String serializeFooter() const; + std::string serializeHeader(const ProtocolHeader&) const; + std::string serializeElement(boost::shared_ptr<Element> stanza) const; + std::string serializeFooter() const; private: - String getDefaultNamespace() const; + std::string getDefaultNamespace() const; private: StreamType type_; diff --git a/Swiften/Server/ServerFromClientSession.cpp b/Swiften/Server/ServerFromClientSession.cpp index 1c47cef..18da7e8 100644 --- a/Swiften/Server/ServerFromClientSession.cpp +++ b/Swiften/Server/ServerFromClientSession.cpp @@ -24,7 +24,7 @@ namespace Swift { ServerFromClientSession::ServerFromClientSession( - const String& id, + const std::string& id, boost::shared_ptr<Connection> connection, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers, diff --git a/Swiften/Server/ServerFromClientSession.h b/Swiften/Server/ServerFromClientSession.h index 2ac4296..80ef063 100644 --- a/Swiften/Server/ServerFromClientSession.h +++ b/Swiften/Server/ServerFromClientSession.h @@ -10,7 +10,7 @@ #include "Swiften/Base/boost_bsignals.h" #include <boost/enable_shared_from_this.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Session/Session.h" #include "Swiften/JID/JID.h" #include "Swiften/Network/Connection.h" @@ -31,7 +31,7 @@ namespace Swift { class ServerFromClientSession : public Session { public: ServerFromClientSession( - const String& id, + const std::string& id, boost::shared_ptr<Connection> connection, PayloadParserFactoryCollection* payloadParserFactories, PayloadSerializerCollection* payloadSerializers, @@ -50,11 +50,11 @@ namespace Swift { } private: - String id_; + std::string id_; UserRegistry* userRegistry_; bool authenticated_; bool initialized; bool allowSASLEXTERNAL; - String user_; + std::string user_; }; } diff --git a/Swiften/Server/SimpleUserRegistry.cpp b/Swiften/Server/SimpleUserRegistry.cpp index 51278d4..2de28fe 100644 --- a/Swiften/Server/SimpleUserRegistry.cpp +++ b/Swiften/Server/SimpleUserRegistry.cpp @@ -11,12 +11,12 @@ namespace Swift { SimpleUserRegistry::SimpleUserRegistry() { } -bool SimpleUserRegistry::isValidUserPassword(const JID& user, const String& password) const { - std::map<JID,String>::const_iterator i = users.find(user); +bool SimpleUserRegistry::isValidUserPassword(const JID& user, const std::string& password) const { + std::map<JID,std::string>::const_iterator i = users.find(user); return i != users.end() ? i->second == password : false; } -void SimpleUserRegistry::addUser(const JID& user, const String& password) { +void SimpleUserRegistry::addUser(const JID& user, const std::string& password) { users.insert(std::make_pair(user, password)); } diff --git a/Swiften/Server/SimpleUserRegistry.h b/Swiften/Server/SimpleUserRegistry.h index 022e017..5de9f64 100644 --- a/Swiften/Server/SimpleUserRegistry.h +++ b/Swiften/Server/SimpleUserRegistry.h @@ -9,20 +9,20 @@ #include <map> #include "Swiften/JID/JID.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Server/UserRegistry.h" namespace Swift { - class String; + class SimpleUserRegistry : public UserRegistry { public: SimpleUserRegistry(); - virtual bool isValidUserPassword(const JID& user, const String& password) const; - void addUser(const JID& user, const String& password); + virtual bool isValidUserPassword(const JID& user, const std::string& password) const; + void addUser(const JID& user, const std::string& password); private: - std::map<JID, String> users; + std::map<JID, std::string> users; }; } diff --git a/Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp b/Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp index d24d1f8..0a5c7c1 100644 --- a/Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp +++ b/Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp @@ -124,7 +124,7 @@ class ServerStanzaRouterTest : public CppUnit::TestFixture { } private: - boost::shared_ptr<Message> createMessageTo(const String& recipient) { + boost::shared_ptr<Message> createMessageTo(const std::string& recipient) { boost::shared_ptr<Message> message(new Message()); message->setTo(JID(recipient)); return message; diff --git a/Swiften/Server/UserRegistry.h b/Swiften/Server/UserRegistry.h index ced2022..c021fc4 100644 --- a/Swiften/Server/UserRegistry.h +++ b/Swiften/Server/UserRegistry.h @@ -6,14 +6,16 @@ #pragma once +#include <string> + namespace Swift { - class String; + class JID; class UserRegistry { public: virtual ~UserRegistry(); - virtual bool isValidUserPassword(const JID& user, const String& password) const = 0; + virtual bool isValidUserPassword(const JID& user, const std::string& password) const = 0; }; } diff --git a/Swiften/Session/BasicSessionStream.cpp b/Swiften/Session/BasicSessionStream.cpp index 03985bd..1736f80 100644 --- a/Swiften/Session/BasicSessionStream.cpp +++ b/Swiften/Session/BasicSessionStream.cpp @@ -188,11 +188,11 @@ void BasicSessionStream::handleConnectionFinished(const boost::optional<Connecti } void BasicSessionStream::handleDataRead(const ByteArray& data) { - onDataRead(String(data.getData(), data.getSize())); + onDataRead(std::string(data.getData(), data.getSize())); } void BasicSessionStream::handleDataWritten(const ByteArray& data) { - onDataWritten(String(data.getData(), data.getSize())); + onDataWritten(std::string(data.getData(), data.getSize())); } }; diff --git a/Swiften/Session/SessionStream.h b/Swiften/Session/SessionStream.h index d0f93ee..017d3d4 100644 --- a/Swiften/Session/SessionStream.h +++ b/Swiften/Session/SessionStream.h @@ -70,8 +70,8 @@ namespace Swift { boost::signal<void (boost::shared_ptr<Element>)> onElementReceived; boost::signal<void (boost::shared_ptr<Error>)> onClosed; boost::signal<void ()> onTLSEncrypted; - boost::signal<void (const String&)> onDataRead; - boost::signal<void (const String&)> onDataWritten; + boost::signal<void (const std::string&)> onDataRead; + boost::signal<void (const std::string&)> onDataWritten; protected: const PKCS12Certificate& getTLSCertificate() const { diff --git a/Swiften/Session/SessionTracer.h b/Swiften/Session/SessionTracer.h index 9315d2f..7c6f3fa 100644 --- a/Swiften/Session/SessionTracer.h +++ b/Swiften/Session/SessionTracer.h @@ -9,7 +9,7 @@ #include <iostream> #include "Swiften/Session/Session.h" -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" namespace Swift { @@ -23,11 +23,11 @@ namespace Swift { private: void printData(char direction, const ByteArray& data) { std::cerr << direction << direction << " " << session->getLocalJID() << " "; - for (unsigned int i = 0; i < 72 - session->getLocalJID().toString().getUTF8Size() - session->getRemoteJID().toString().getUTF8Size(); ++i) { + for (unsigned int i = 0; i < 72 - session->getLocalJID().toString().size() - session->getRemoteJID().toString().size(); ++i) { std::cerr << direction; } std::cerr << " " << session->getRemoteJID()<< " " << direction << direction << std::endl; - std::cerr << String(data.getData(), data.getSize()) << std::endl; + std::cerr << std::string(data.getData(), data.getSize()) << std::endl; } boost::shared_ptr<Session> session; diff --git a/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp b/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp index e53b8c6..1028ae7 100644 --- a/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp +++ b/Swiften/StreamManagement/UnitTest/StanzaAckRequesterTest.cpp @@ -63,7 +63,7 @@ class StanzaAckRequesterTest : public CppUnit::TestFixture { testling->handleAckReceived(1); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(ackedStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("m1"), ackedStanzas[0]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[0]->getID()); } void testHandleAckReceived_AcksMultipleMessages() { @@ -74,8 +74,8 @@ class StanzaAckRequesterTest : public CppUnit::TestFixture { testling->handleAckReceived(2); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(ackedStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("m1"), ackedStanzas[0]->getID()); - CPPUNIT_ASSERT_EQUAL(String("m2"), ackedStanzas[1]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[0]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m2"), ackedStanzas[1]->getID()); } void testHandleAckReceived_AcksMultipleStanzas() { @@ -87,9 +87,9 @@ class StanzaAckRequesterTest : public CppUnit::TestFixture { testling->handleAckReceived(3); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(ackedStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("iq1"), ackedStanzas[0]->getID()); - CPPUNIT_ASSERT_EQUAL(String("p1"), ackedStanzas[1]->getID()); - CPPUNIT_ASSERT_EQUAL(String("m1"), ackedStanzas[2]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("iq1"), ackedStanzas[0]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("p1"), ackedStanzas[1]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[2]->getID()); } void testHandleAckReceived_MultipleAcks() { @@ -102,9 +102,9 @@ class StanzaAckRequesterTest : public CppUnit::TestFixture { testling->handleAckReceived(3); CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(ackedStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("m1"), ackedStanzas[0]->getID()); - CPPUNIT_ASSERT_EQUAL(String("m2"), ackedStanzas[1]->getID()); - CPPUNIT_ASSERT_EQUAL(String("m3"), ackedStanzas[2]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[0]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m2"), ackedStanzas[1]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m3"), ackedStanzas[2]->getID()); } // Handle stanza ack count wrapping, as per the XEP @@ -117,24 +117,24 @@ class StanzaAckRequesterTest : public CppUnit::TestFixture { testling->handleAckReceived(1); CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(ackedStanzas.size())); - CPPUNIT_ASSERT_EQUAL(String("m1"), ackedStanzas[0]->getID()); - CPPUNIT_ASSERT_EQUAL(String("m2"), ackedStanzas[1]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m1"), ackedStanzas[0]->getID()); + CPPUNIT_ASSERT_EQUAL(std::string("m2"), ackedStanzas[1]->getID()); } private: - Message::ref createMessage(const String& id) { + Message::ref createMessage(const std::string& id) { Message::ref result(new Message()); result->setID(id); return result; } - IQ::ref createIQ(const String& id) { + IQ::ref createIQ(const std::string& id) { IQ::ref result(new IQ()); result->setID(id); return result; } - Presence::ref createPresence(const String& id) { + Presence::ref createPresence(const std::string& id) { Presence::ref result(new Presence()); result->setID(id); return result; diff --git a/Swiften/StreamManagement/UnitTest/StanzaAckResponderTest.cpp b/Swiften/StreamManagement/UnitTest/StanzaAckResponderTest.cpp index fa2b782..b24335f 100644 --- a/Swiften/StreamManagement/UnitTest/StanzaAckResponderTest.cpp +++ b/Swiften/StreamManagement/UnitTest/StanzaAckResponderTest.cpp @@ -73,7 +73,7 @@ class StanzaAckResponderTest : public CppUnit::TestFixture { } private: - Message::ref createMessage(const String& id) { + Message::ref createMessage(const std::string& id) { Message::ref result(new Message()); result->setID(id); return result; diff --git a/Swiften/StreamStack/HighLayer.cpp b/Swiften/StreamStack/HighLayer.cpp index da1eec9..7203b7f 100644 --- a/Swiften/StreamStack/HighLayer.cpp +++ b/Swiften/StreamStack/HighLayer.cpp @@ -6,6 +6,8 @@ #include <Swiften/StreamStack/HighLayer.h> +#include <cassert> + #include <Swiften/StreamStack/LowLayer.h> namespace Swift { diff --git a/Swiften/StreamStack/LowLayer.cpp b/Swiften/StreamStack/LowLayer.cpp index ca7b72b..ed93cd2 100644 --- a/Swiften/StreamStack/LowLayer.cpp +++ b/Swiften/StreamStack/LowLayer.cpp @@ -6,6 +6,8 @@ #include <Swiften/StreamStack/LowLayer.h> +#include <cassert> + #include <Swiften/StreamStack/HighLayer.h> namespace Swift { diff --git a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp index 20b976d..be16baa 100644 --- a/Swiften/StreamStack/UnitTest/StreamStackTest.cpp +++ b/Swiften/StreamStack/UnitTest/StreamStackTest.cpp @@ -134,7 +134,7 @@ class StreamStackTest : public CppUnit::TestFixture { private: class MyStreamLayer : public StreamLayer { public: - MyStreamLayer(const String& prepend) : prepend_(prepend) { + MyStreamLayer(const std::string& prepend) : prepend_(prepend) { } virtual void writeData(const ByteArray& data) { @@ -146,7 +146,7 @@ class StreamStackTest : public CppUnit::TestFixture { } private: - String prepend_; + std::string prepend_; }; class TestLowLayer : public LowLayer { diff --git a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp index 77e6f7e..6c69a5f 100644 --- a/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp +++ b/Swiften/StreamStack/UnitTest/XMPPLayerTest.cpp @@ -78,19 +78,19 @@ class XMPPLayerTest : public CppUnit::TestFixture { header.setTo("example.com"); testling_->writeHeader(header); - CPPUNIT_ASSERT_EQUAL(String("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" to=\"example.com\" version=\"1.0\">"), lowLayer_->writtenData); + CPPUNIT_ASSERT_EQUAL(std::string("<?xml version=\"1.0\"?><stream:stream xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\" to=\"example.com\" version=\"1.0\">"), lowLayer_->writtenData); } void testWriteElement() { testling_->writeElement(boost::shared_ptr<Presence>(new Presence())); - CPPUNIT_ASSERT_EQUAL(String("<presence/>"), lowLayer_->writtenData); + CPPUNIT_ASSERT_EQUAL(std::string("<presence/>"), lowLayer_->writtenData); } void testWriteFooter() { testling_->writeFooter(); - CPPUNIT_ASSERT_EQUAL(String("</stream:stream>"), lowLayer_->writtenData); + CPPUNIT_ASSERT_EQUAL(std::string("</stream:stream>"), lowLayer_->writtenData); } void handleElement(boost::shared_ptr<Element>) { @@ -124,7 +124,7 @@ class XMPPLayerTest : public CppUnit::TestFixture { writtenData += std::string(data.getData(), data.getSize()); } - String writtenData; + std::string writtenData; }; FullPayloadParserFactoryCollection parserFactories_; diff --git a/Swiften/StreamStack/XMPPLayer.cpp b/Swiften/StreamStack/XMPPLayer.cpp index 3ecda95..a1e7ba3 100644 --- a/Swiften/StreamStack/XMPPLayer.cpp +++ b/Swiften/StreamStack/XMPPLayer.cpp @@ -40,7 +40,7 @@ void XMPPLayer::writeElement(boost::shared_ptr<Element> element) { writeDataInternal(ByteArray(xmppSerializer_->serializeElement(element))); } -void XMPPLayer::writeData(const String& data) { +void XMPPLayer::writeData(const std::string& data) { writeDataInternal(ByteArray(data)); } @@ -52,7 +52,7 @@ void XMPPLayer::writeDataInternal(const ByteArray& data) { void XMPPLayer::handleDataRead(const ByteArray& data) { onDataRead(data); inParser_ = true; - if (!xmppParser_->parse(String(data.getData(), data.getSize()))) { + if (!xmppParser_->parse(std::string(data.getData(), data.getSize()))) { inParser_ = false; onError(); return; diff --git a/Swiften/StreamStack/XMPPLayer.h b/Swiften/StreamStack/XMPPLayer.h index f08bde1..6669cda 100644 --- a/Swiften/StreamStack/XMPPLayer.h +++ b/Swiften/StreamStack/XMPPLayer.h @@ -34,7 +34,7 @@ namespace Swift { void writeHeader(const ProtocolHeader& header); void writeFooter(); void writeElement(boost::shared_ptr<Element>); - void writeData(const String& data); + void writeData(const std::string& data); void resetParser(); 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)); } }; diff --git a/Swiften/TLS/Certificate.cpp b/Swiften/TLS/Certificate.cpp index 984d668..ecd7d5e 100644 --- a/Swiften/TLS/Certificate.cpp +++ b/Swiften/TLS/Certificate.cpp @@ -19,16 +19,16 @@ const char* Certificate::ID_ON_DNSSRV_OID = "1.3.6.1.5.5.7.8.7"; Certificate::~Certificate() { } -String Certificate::getSHA1Fingerprint() const { +std::string Certificate::getSHA1Fingerprint() const { ByteArray hash = SHA1::getHash(toDER()); std::ostringstream s; for (size_t i = 0; i < hash.getSize(); ++i) { if (i > 0) { s << ":"; } - s << Hexify::hexify(hash[i]).getUTF8String(); + s << Hexify::hexify(hash[i]); } - return String(s.str()); + return std::string(s.str()); } } diff --git a/Swiften/TLS/Certificate.h b/Swiften/TLS/Certificate.h index e01aa74..dc93a2d 100644 --- a/Swiften/TLS/Certificate.h +++ b/Swiften/TLS/Certificate.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/Base/ByteArray.h" namespace Swift { @@ -22,16 +22,16 @@ namespace Swift { * Returns the textual representation of the full Subject * name. */ - virtual String getSubjectName() const = 0; + virtual std::string getSubjectName() const = 0; - virtual std::vector<String> getCommonNames() const = 0; - virtual std::vector<String> getSRVNames() const = 0; - virtual std::vector<String> getDNSNames() const = 0; - virtual std::vector<String> getXMPPAddresses() const = 0; + virtual std::vector<std::string> getCommonNames() const = 0; + virtual std::vector<std::string> getSRVNames() const = 0; + virtual std::vector<std::string> getDNSNames() const = 0; + virtual std::vector<std::string> getXMPPAddresses() const = 0; virtual ByteArray toDER() const = 0; - virtual String getSHA1Fingerprint() const; + virtual std::string getSHA1Fingerprint() const; protected: static const char* ID_ON_XMPPADDR_OID; diff --git a/Swiften/TLS/CertificateTrustChecker.h b/Swiften/TLS/CertificateTrustChecker.h index c248e4a..aec03e3 100644 --- a/Swiften/TLS/CertificateTrustChecker.h +++ b/Swiften/TLS/CertificateTrustChecker.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/TLS/Certificate.h" namespace Swift { diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp index 6a3d688..8a3bf97 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.cpp @@ -58,7 +58,7 @@ void OpenSSLCertificate::parse() { ByteArray subjectNameData; subjectNameData.resize(256); X509_NAME_oneline(X509_get_subject_name(cert.get()), subjectNameData.getData(), subjectNameData.getSize()); - this->subjectName = String(subjectNameData.getData()); + this->subjectName = std::string(subjectNameData.getData()); // Common name int cnLoc = X509_NAME_get_index_by_NID(subjectName, NID_commonName, -1); diff --git a/Swiften/TLS/OpenSSL/OpenSSLCertificate.h b/Swiften/TLS/OpenSSL/OpenSSLCertificate.h index 2255826..b900170 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLCertificate.h +++ b/Swiften/TLS/OpenSSL/OpenSSLCertificate.h @@ -9,7 +9,7 @@ #include <boost/shared_ptr.hpp> #include <openssl/ssl.h> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/TLS/Certificate.h" namespace Swift { @@ -18,23 +18,23 @@ namespace Swift { OpenSSLCertificate(boost::shared_ptr<X509>); OpenSSLCertificate(const ByteArray& der); - String getSubjectName() const { + std::string getSubjectName() const { return subjectName; } - std::vector<String> getCommonNames() const { + std::vector<std::string> getCommonNames() const { return commonNames; } - std::vector<String> getSRVNames() const { + std::vector<std::string> getSRVNames() const { return srvNames; } - std::vector<String> getDNSNames() const { + std::vector<std::string> getDNSNames() const { return dnsNames; } - std::vector<String> getXMPPAddresses() const { + std::vector<std::string> getXMPPAddresses() const { return xmppAddresses; } @@ -47,24 +47,24 @@ namespace Swift { private: void parse(); - void addSRVName(const String& name) { + void addSRVName(const std::string& name) { srvNames.push_back(name); } - void addDNSName(const String& name) { + void addDNSName(const std::string& name) { dnsNames.push_back(name); } - void addXMPPAddress(const String& addr) { + void addXMPPAddress(const std::string& addr) { xmppAddresses.push_back(addr); } private: boost::shared_ptr<X509> cert; - String subjectName; - std::vector<String> commonNames; - std::vector<String> dnsNames; - std::vector<String> xmppAddresses; - std::vector<String> srvNames; + std::string subjectName; + std::vector<std::string> commonNames; + std::vector<std::string> dnsNames; + std::vector<std::string> xmppAddresses; + std::vector<std::string> srvNames; }; } diff --git a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp index be2f0af..21e377f 100644 --- a/Swiften/TLS/OpenSSL/OpenSSLContext.cpp +++ b/Swiften/TLS/OpenSSL/OpenSSLContext.cpp @@ -178,7 +178,7 @@ bool OpenSSLContext::setClientCertificate(const PKCS12Certificate& certificate) X509 *certPtr = 0; EVP_PKEY* privateKeyPtr = 0; STACK_OF(X509)* caCertsPtr = 0; - int result = PKCS12_parse(pkcs12.get(), certificate.getPassword().getUTF8Data(), &privateKeyPtr, &certPtr, &caCertsPtr); + int result = PKCS12_parse(pkcs12.get(), certificate.getPassword().c_str(), &privateKeyPtr, &certPtr, &caCertsPtr); if (result != 1) { return false; } diff --git a/Swiften/TLS/PKCS12Certificate.h b/Swiften/TLS/PKCS12Certificate.h index 1d8c7c2..1c8c38f 100644 --- a/Swiften/TLS/PKCS12Certificate.h +++ b/Swiften/TLS/PKCS12Certificate.h @@ -14,7 +14,7 @@ namespace Swift { public: PKCS12Certificate() {} - PKCS12Certificate(const String& filename, const String& password) : password_(password) { + PKCS12Certificate(const std::string& filename, const std::string& password) : password_(password) { data_.readFromFile(filename); } @@ -30,13 +30,13 @@ namespace Swift { data_ = data; } - const String& getPassword() const { + const std::string& getPassword() const { return password_; } private: ByteArray data_; - String password_; + std::string password_; }; } diff --git a/Swiften/TLS/ServerIdentityVerifier.cpp b/Swiften/TLS/ServerIdentityVerifier.cpp index 05efd31..d7b0580 100644 --- a/Swiften/TLS/ServerIdentityVerifier.cpp +++ b/Swiften/TLS/ServerIdentityVerifier.cpp @@ -6,6 +6,8 @@ #include "Swiften/TLS/ServerIdentityVerifier.h" +#include <boost/algorithm/string.hpp> + #include "Swiften/Base/foreach.h" #include "Swiften/IDN/IDNA.h" @@ -20,8 +22,8 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { bool hasSAN = false; // DNS names - std::vector<String> dnsNames = certificate->getDNSNames(); - foreach (const String& dnsName, dnsNames) { + std::vector<std::string> dnsNames = certificate->getDNSNames(); + foreach (const std::string& dnsName, dnsNames) { if (matchesDomain(dnsName)) { return true; } @@ -29,19 +31,19 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { hasSAN |= !dnsNames.empty(); // SRV names - std::vector<String> srvNames = certificate->getSRVNames(); - foreach (const String& srvName, srvNames) { + std::vector<std::string> srvNames = certificate->getSRVNames(); + foreach (const std::string& srvName, srvNames) { // Only match SRV names that begin with the service; this isn't required per // spec, but we're being purist about this. - if (srvName.beginsWith("_xmpp-client.") && matchesDomain(srvName.getSubstring(String("_xmpp-client.").getUTF8Size(), srvName.npos()))) { + if (boost::starts_with(srvName, "_xmpp-client.") && matchesDomain(srvName.substr(std::string("_xmpp-client.").size(), srvName.npos))) { return true; } } hasSAN |= !srvNames.empty(); // XmppAddr - std::vector<String> xmppAddresses = certificate->getXMPPAddresses(); - foreach (const String& xmppAddress, xmppAddresses) { + std::vector<std::string> xmppAddresses = certificate->getXMPPAddresses(); + foreach (const std::string& xmppAddress, xmppAddresses) { if (matchesAddress(xmppAddress)) { return true; } @@ -50,8 +52,8 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { // CommonNames. Only check this if there was no SAN (according to spec). if (!hasSAN) { - std::vector<String> commonNames = certificate->getCommonNames(); - foreach (const String& commonName, commonNames) { + std::vector<std::string> commonNames = certificate->getCommonNames(); + foreach (const std::string& commonName, commonNames) { if (matchesDomain(commonName)) { return true; } @@ -61,13 +63,13 @@ bool ServerIdentityVerifier::certificateVerifies(Certificate::ref certificate) { return false; } -bool ServerIdentityVerifier::matchesDomain(const String& s) { - if (s.beginsWith("*.")) { - String matchString(s.getSubstring(2, s.npos())); - String matchDomain = encodedDomain; +bool ServerIdentityVerifier::matchesDomain(const std::string& s) { + if (boost::starts_with(s, "*.")) { + std::string matchString(s.substr(2, s.npos)); + std::string matchDomain = encodedDomain; int dotIndex = matchDomain.find('.'); if (dotIndex >= 0) { - matchDomain = matchDomain.getSubstring(dotIndex + 1, matchDomain.npos()); + matchDomain = matchDomain.substr(dotIndex + 1, matchDomain.npos); } return matchString == matchDomain; } @@ -76,7 +78,7 @@ bool ServerIdentityVerifier::matchesDomain(const String& s) { } } -bool ServerIdentityVerifier::matchesAddress(const String& s) { +bool ServerIdentityVerifier::matchesAddress(const std::string& s) { return s == domain; } diff --git a/Swiften/TLS/ServerIdentityVerifier.h b/Swiften/TLS/ServerIdentityVerifier.h index a001a5e..05bb5f0 100644 --- a/Swiften/TLS/ServerIdentityVerifier.h +++ b/Swiften/TLS/ServerIdentityVerifier.h @@ -8,7 +8,7 @@ #include <boost/shared_ptr.hpp> -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/JID/JID.h" #include "Swiften/TLS/Certificate.h" @@ -20,11 +20,11 @@ namespace Swift { bool certificateVerifies(Certificate::ref); private: - bool matchesDomain(const String&); - bool matchesAddress(const String&); + bool matchesDomain(const std::string&); + bool matchesAddress(const std::string&); private: - String domain; - String encodedDomain; + std::string domain; + std::string encodedDomain; }; } diff --git a/Swiften/TLS/SimpleCertificate.h b/Swiften/TLS/SimpleCertificate.h index 7af8530..a81a23e 100644 --- a/Swiften/TLS/SimpleCertificate.h +++ b/Swiften/TLS/SimpleCertificate.h @@ -6,7 +6,7 @@ #pragma once -#include "Swiften/Base/String.h" +#include <string> #include "Swiften/TLS/Certificate.h" namespace Swift { @@ -14,43 +14,43 @@ namespace Swift { public: typedef boost::shared_ptr<SimpleCertificate> ref; - void setSubjectName(const String& name) { + void setSubjectName(const std::string& name) { subjectName = name; } - String getSubjectName() const { + std::string getSubjectName() const { return subjectName; } - std::vector<String> getCommonNames() const { + std::vector<std::string> getCommonNames() const { return commonNames; } - void addCommonName(const String& name) { + void addCommonName(const std::string& name) { commonNames.push_back(name); } - void addSRVName(const String& name) { + void addSRVName(const std::string& name) { srvNames.push_back(name); } - void addDNSName(const String& name) { + void addDNSName(const std::string& name) { dnsNames.push_back(name); } - void addXMPPAddress(const String& addr) { + void addXMPPAddress(const std::string& addr) { xmppAddresses.push_back(addr); } - std::vector<String> getSRVNames() const { + std::vector<std::string> getSRVNames() const { return srvNames; } - std::vector<String> getDNSNames() const { + std::vector<std::string> getDNSNames() const { return dnsNames; } - std::vector<String> getXMPPAddresses() const { + std::vector<std::string> getXMPPAddresses() const { return xmppAddresses; } @@ -66,11 +66,11 @@ namespace Swift { void parse(); private: - String subjectName; + std::string subjectName; ByteArray der; - std::vector<String> commonNames; - std::vector<String> dnsNames; - std::vector<String> xmppAddresses; - std::vector<String> srvNames; + std::vector<std::string> commonNames; + std::vector<std::string> dnsNames; + std::vector<std::string> xmppAddresses; + std::vector<std::string> srvNames; }; } diff --git a/Swiften/TLS/UnitTest/CertificateTest.cpp b/Swiften/TLS/UnitTest/CertificateTest.cpp index b5e69c3..216aaae 100644 --- a/Swiften/TLS/UnitTest/CertificateTest.cpp +++ b/Swiften/TLS/UnitTest/CertificateTest.cpp @@ -25,7 +25,7 @@ class CertificateTest : public CppUnit::TestFixture { SimpleCertificate::ref testling = boost::make_shared<SimpleCertificate>(); testling->setDER(ByteArray("abcdefg")); - CPPUNIT_ASSERT_EQUAL(String("2f:b5:e1:34:19:fc:89:24:68:65:e7:a3:24:f4:76:ec:62:4e:87:40"), testling->getSHA1Fingerprint()); + CPPUNIT_ASSERT_EQUAL(std::string("2f:b5:e1:34:19:fc:89:24:68:65:e7:a3:24:f4:76:ec:62:4e:87:40"), testling->getSHA1Fingerprint()); } }; diff --git a/Swiften/VCards/UnitTest/VCardManagerTest.cpp b/Swiften/VCards/UnitTest/VCardManagerTest.cpp index 1f81f8e..9274639 100644 --- a/Swiften/VCards/UnitTest/VCardManagerTest.cpp +++ b/Swiften/VCards/UnitTest/VCardManagerTest.cpp @@ -64,7 +64,7 @@ class VCardManagerTest : public CppUnit::TestFixture { VCard::ref result = testling->getVCardAndRequestWhenNeeded(JID("foo@bar.com/baz")); - CPPUNIT_ASSERT_EQUAL(String("Foo Bar"), result->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), result->getFullName()); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(stanzaChannel->sentStanzas.size())); } @@ -83,8 +83,8 @@ class VCardManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), changes[0].first); - CPPUNIT_ASSERT_EQUAL(String("Foo Bar"), changes[0].second->getFullName()); - CPPUNIT_ASSERT_EQUAL(String("Foo Bar"), vcardStorage->getVCard(JID("foo@bar.com/baz"))->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), changes[0].second->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Foo Bar"), vcardStorage->getVCard(JID("foo@bar.com/baz"))->getFullName()); CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(ownChanges.size())); } @@ -96,8 +96,8 @@ class VCardManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com/baz"), changes[0].first); - CPPUNIT_ASSERT_EQUAL(String(""), changes[0].second->getFullName()); - CPPUNIT_ASSERT_EQUAL(String(""), vcardStorage->getVCard(JID("foo@bar.com/baz"))->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string(""), changes[0].second->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string(""), vcardStorage->getVCard(JID("foo@bar.com/baz"))->getFullName()); } void testRequest_VCardAlreadyRequested() { @@ -128,11 +128,11 @@ class VCardManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<VCard>(0, JID(), IQ::Get)); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); CPPUNIT_ASSERT_EQUAL(ownJID.toBare(), changes[0].first); - CPPUNIT_ASSERT_EQUAL(String("Myself"), changes[0].second->getFullName()); - CPPUNIT_ASSERT_EQUAL(String("Myself"), vcardStorage->getVCard(ownJID.toBare())->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Myself"), changes[0].second->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Myself"), vcardStorage->getVCard(ownJID.toBare())->getFullName()); CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(ownChanges.size())); - CPPUNIT_ASSERT_EQUAL(String("Myself"), ownChanges[0]->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("Myself"), ownChanges[0]->getFullName()); } void testCreateSetVCardRequest() { @@ -146,7 +146,7 @@ class VCardManagerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(changes.size())); CPPUNIT_ASSERT_EQUAL(ownJID.toBare(), changes[0].first); - CPPUNIT_ASSERT_EQUAL(String("New Name"), changes[0].second->getFullName()); + CPPUNIT_ASSERT_EQUAL(std::string("New Name"), changes[0].second->getFullName()); } void testCreateSetVCardRequest_Error() { diff --git a/Swiften/VCards/VCardFileStorage.cpp b/Swiften/VCards/VCardFileStorage.cpp index abececa..63652ad 100644 --- a/Swiften/VCards/VCardFileStorage.cpp +++ b/Swiften/VCards/VCardFileStorage.cpp @@ -8,6 +8,7 @@ #include <boost/filesystem/fstream.hpp> +#include <Swiften/Base/String.h> #include "Swiften/JID/JID.h" #include "Swiften/Base/ByteArray.h" #include "Swiften/Elements/VCard.h" @@ -28,7 +29,7 @@ boost::shared_ptr<VCard> VCardFileStorage::getVCard(const JID& jid) const { VCardParser parser; PayloadParserTester tester(&parser); - tester.parse(String(data.getData(), data.getSize())); + tester.parse(std::string(data.getData(), data.getSize())); return boost::dynamic_pointer_cast<VCard>(parser.getPayload()); } else { @@ -52,9 +53,9 @@ void VCardFileStorage::setVCard(const JID& jid, VCard::ref v) { } boost::filesystem::path VCardFileStorage::getVCardPath(const JID& jid) const { - String file(jid.toString()); - file.replaceAll('/', "%2f"); - return boost::filesystem::path(vcardsPath / (file.getUTF8String() + ".xml")); + std::string file(jid.toString()); + String::replaceAll(file, '/', "%2f"); + return boost::filesystem::path(vcardsPath / (file + ".xml")); } } |