diff options
| author | Kevin Smith <git@kismith.co.uk> | 2018-07-27 13:39:18 (GMT) |
|---|---|---|
| committer | Kevin Smith <kevin.smith@isode.com> | 2018-07-27 13:53:55 (GMT) |
| commit | 48596613cfe0f45c0916beabbcc3a27e01752c4b (patch) | |
| tree | f8137f72b599d02eb1bc4f6dbc833c416f4e0295 | |
| parent | 1bcdcbd4c8e1c6c971087f049422d3bd52be2a6b (diff) | |
| download | swift-48596613cfe0f45c0916beabbcc3a27e01752c4b.zip swift-48596613cfe0f45c0916beabbcc3a27e01752c4b.tar.bz2 | |
Autofix boost-use-to-string clang-tidy warnings
Done by adding --fix --fix-errors to the clang-tidy args in
the Makefile
Test-Information:
Unit tests pass (macOS)
Change-Id: I3a4df955ac3553afeb9384f23f9d8b2ef01117e2
32 files changed, 83 insertions, 83 deletions
diff --git a/Slimber/MainController.cpp b/Slimber/MainController.cpp index cd36132..93eb4e7 100644 --- a/Slimber/MainController.cpp +++ b/Slimber/MainController.cpp @@ -99,19 +99,19 @@ void MainController::handleServicesChanged() { void MainController::handleServerStopped(boost::optional<ServerError> error) { if (error) { std::string message; switch (error->getType()) { case ServerError::C2SPortConflict: - message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getClientToServerPort()) + std::string(" in use"); + message = std::string("Error: Port ") + std::to_string(server->getClientToServerPort()) + std::string(" in use"); break; case ServerError::C2SError: message = std::string("Local connection server error"); break; case ServerError::LinkLocalPortConflict: - message = std::string("Error: Port ") + boost::lexical_cast<std::string>(server->getLinkLocalPort()) + std::string(" in use"); + message = std::string("Error: Port ") + std::to_string(server->getLinkLocalPort()) + std::string(" in use"); break; case ServerError::LinkLocalError: message = std::string("External connection server error"); break; } menuletController->setXMPPStatus(message, MenuletController::Offline); diff --git a/Swift/Controllers/AccountController.cpp b/Swift/Controllers/AccountController.cpp index fe7c200..ec914a6 100644 --- a/Swift/Controllers/AccountController.cpp +++ b/Swift/Controllers/AccountController.cpp @@ -685,13 +685,13 @@ void AccountController::handleDisconnected(const boost::optional<ClientError>& e message = str(format(QT_TRANSLATE_NOOP("", "Disconnected from %1%: %2%. To reconnect, Sign Out and provide your password again.")) % jid_.getDomain() % message); } else { if (!offlineRequested_) { setReconnectTimer(); } if (lastDisconnectError_) { - message = str(format(QT_TRANSLATE_NOOP("", "Reconnect to %1% failed: %2%. Will retry in %3% seconds.")) % jid_.getDomain() % message % boost::lexical_cast<std::string>(timeBeforeNextReconnect_)); + message = str(format(QT_TRANSLATE_NOOP("", "Reconnect to %1% failed: %2%. Will retry in %3% seconds.")) % jid_.getDomain() % message % std::to_string(timeBeforeNextReconnect_)); lastDisconnectError_->conclude(); } else { message = str(format(QT_TRANSLATE_NOOP("", "Disconnected from %1%: %2%.")) % jid_.getDomain() % message); } lastDisconnectError_ = std::make_shared<ErrorEvent>(JID(jid_.getDomain()), message); eventController_->handleIncomingEvent(lastDisconnectError_); diff --git a/Swift/QtUI/QtCachedImageScaler.cpp b/Swift/QtUI/QtCachedImageScaler.cpp index e1f540b..445d113 100644 --- a/Swift/QtUI/QtCachedImageScaler.cpp +++ b/Swift/QtUI/QtCachedImageScaler.cpp @@ -18,13 +18,13 @@ namespace Swift { QtCachedImageScaler::QtCachedImageScaler() { } boost::filesystem::path QtCachedImageScaler::getScaledImage(const boost::filesystem::path& imagePath, int size) { boost::filesystem::path scaledImagePath(imagePath); - std::string suffix = "." + boost::lexical_cast<std::string>(size); + std::string suffix = "." + std::to_string(size); scaledImagePath = stringToPath(pathToString(scaledImagePath) + suffix); if (!boost::filesystem::exists(scaledImagePath)) { QImage image(P2QSTRING(pathToString(imagePath))); if (!image.isNull()) { if (image.width() > size || image.height() > size) { QImage scaledImage = image.scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation); diff --git a/Swift/QtUI/QtFormWidget.cpp b/Swift/QtUI/QtFormWidget.cpp index 96c2da0..860ddfa 100644 --- a/Swift/QtUI/QtFormWidget.cpp +++ b/Swift/QtUI/QtFormWidget.cpp @@ -144,13 +144,13 @@ QWidget* QtFormWidget::createWidget(FormField::ref field, const FormField::Type if (type == FormField::ListMultiType) { widget = createList(field); } std::string indexString; if (index) { /* for multi-item forms we need to distinguish between the different rows */ - indexString = boost::lexical_cast<std::string>(index); + indexString = std::to_string(index); } fields_[field->getName() + indexString] = widget; return widget; } Form::ref QtFormWidget::getCompletedForm() { diff --git a/Swift/QtUI/QtHistoryWindow.cpp b/Swift/QtUI/QtHistoryWindow.cpp index 983d0e9..0e7e89d 100644 --- a/Swift/QtUI/QtHistoryWindow.cpp +++ b/Swift/QtUI/QtHistoryWindow.cpp @@ -128,13 +128,13 @@ void QtHistoryWindow::addMessage(const std::string &message, const std::string & // note: time uses localtime QDate date = QDate(time.date().year(), time.date().month(), time.date().day()); QTime dayTime = QTime(time.time_of_day().hours(), time.time_of_day().minutes(), time.time_of_day().seconds()); QDateTime qTime = QDateTime(date, dayTime); - std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); + std::string id = "id" + std::to_string(idCounter_++); QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.png" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded(); if (addAtTheTop) { bool appendToPrevious = ((senderIsSelf && previousTopMessageWasSelf_) || (!senderIsSelf && !previousTopMessageWasSelf_&& previousTopSenderName_ == P2QSTRING(senderName))); conversation_->addMessageTop(std::make_shared<MessageSnippet>(messageHTML, QtUtilities::htmlEscape(P2QSTRING(senderName)), qTime, qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id), ChatSnippet::getDirection(message))); diff --git a/Swift/QtUI/QtPlainChatView.cpp b/Swift/QtUI/QtPlainChatView.cpp index 3d67091..cdee1e6 100644 --- a/Swift/QtUI/QtPlainChatView.cpp +++ b/Swift/QtUI/QtPlainChatView.cpp @@ -175,13 +175,13 @@ void QtPlainChatView::setAckState(const std::string& /*id*/, ChatWindow::AckStat addSystemMessage(ChatWindow::ChatMessage("Message delivery failed due to disconnection from server."), ChatWindow::DefaultDirection); } } std::string QtPlainChatView::addFileTransfer(const std::string& senderName, const std::string& /*avatarPath*/, bool senderIsSelf, const std::string& filename, const boost::uintmax_t sizeInBytes, const std::string& description) { - const std::string ftId = "ft" + boost::lexical_cast<std::string>(idGenerator_++); + const std::string ftId = "ft" + std::to_string(idGenerator_++); const std::string sizeString = formatSize(sizeInBytes); FileTransfer* transfer; if (senderIsSelf) { QString description = QInputDialog::getText(this, tr("File transfer description"), tr("Description:"), QLineEdit::Normal, ""); diff --git a/Swift/QtUI/QtWebKitChatView.cpp b/Swift/QtUI/QtWebKitChatView.cpp index f2effa8..bca9e2e 100644 --- a/Swift/QtUI/QtWebKitChatView.cpp +++ b/Swift/QtUI/QtWebKitChatView.cpp @@ -577,13 +577,13 @@ std::string QtWebKitChatView::addMessage( QString highlightSpanEnd = highlightWholeMessage ? "</span>" : ""; htmlString += "<span class='swift_inner_message'>" + styleSpanStart + highlightSpanStart + message + highlightSpanEnd + styleSpanEnd + "</span>" ; bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasMessage, senderName, senderIsSelf, label); QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.svg" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded(); - std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); + std::string id = "id" + std::to_string(idCounter_++); addMessageBottom(std::make_shared<MessageSnippet>(htmlString, QtUtilities::htmlEscape(P2QSTRING(senderName)), B2QDATE(time), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id), direction)); previousMessageWasSelf_ = senderIsSelf; previousSenderName_ = P2QSTRING(senderName); previousMessageKind_ = PreviousMessageWasMessage; previousMessageDisplayMarking_ = messageMarkingValue; @@ -655,13 +655,13 @@ std::string QtWebKitChatView::addFileTransfer(const std::string& senderName, con "</div>"; } bool appendToPrevious = appendToPreviousCheck(PreviousMessageWasFileTransfer, senderName, senderIsSelf); QString scaledAvatarPath = QtScaledAvatarCache(32).getScaledAvatarPath(avatarPath.c_str()); QString qAvatarPath = scaledAvatarPath.isEmpty() ? "qrc:/icons/avatar.svg" : QUrl::fromLocalFile(scaledAvatarPath).toEncoded(); - std::string id = "ftmessage" + boost::lexical_cast<std::string>(idCounter_++); + std::string id = "ftmessage" + std::to_string(idCounter_++); addMessageBottom(std::make_shared<MessageSnippet>(htmlString, QtUtilities::htmlEscape(P2QSTRING(senderName)), B2QDATE(boost::posix_time::second_clock::universal_time()), qAvatarPath, senderIsSelf, appendToPrevious, theme_, P2QSTRING(id), ChatSnippet::getDirection(actionText))); previousMessageWasSelf_ = senderIsSelf; previousSenderName_ = P2QSTRING(senderName); previousMessageKind_ = PreviousMessageWasFileTransfer; return Q2PSTRING(ft_id); @@ -689,13 +689,13 @@ std::string QtWebKitChatView::addWhiteboardRequest(const QString& contact, bool htmlString = "<div id='" + wb_id + "'>" + actionText.arg(QtUtilities::htmlEscape(contact)) + ": <br/>" + buildChatWindowButton(tr("Cancel"), ButtonWhiteboardSessionCancel, wb_id) + buildChatWindowButton(tr("Accept"), ButtonWhiteboardSessionAcceptRequest, wb_id) + "</div>"; } QString qAvatarPath = "qrc:/icons/avatar.svg"; - std::string id = "wbmessage" + boost::lexical_cast<std::string>(idCounter_++); + std::string id = "wbmessage" + std::to_string(idCounter_++); addMessageBottom(std::make_shared<MessageSnippet>(htmlString, QtUtilities::htmlEscape(contact), B2QDATE(boost::posix_time::second_clock::universal_time()), qAvatarPath, false, false, theme_, P2QSTRING(id), ChatSnippet::getDirection(actionText))); previousMessageWasSelf_ = false; previousSenderName_ = contact; return Q2PSTRING(wb_id); } @@ -846,26 +846,26 @@ void QtWebKitChatView::handleVerticalScrollBarPositionChanged(double position) { void QtWebKitChatView::addErrorMessage(const ChatWindow::ChatMessage& errorMessage) { if (window_->isWidgetSelected()) { window_->onAllMessagesRead(); } QString errorMessageHTML(chatMessageToHTML(errorMessage)); - std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); + std::string id = "id" + std::to_string(idCounter_++); addMessageBottom(std::make_shared<SystemMessageSnippet>("<span class=\"error\">" + errorMessageHTML + "</span>", QDateTime::currentDateTime(), false, theme_, P2QSTRING(id), ChatSnippet::getDirection(errorMessage))); previousMessageWasSelf_ = false; previousMessageKind_ = PreviousMessageWasSystem; } std::string QtWebKitChatView::addSystemMessage(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction) { if (window_->isWidgetSelected()) { window_->onAllMessagesRead(); } QString messageHTML = chatMessageToHTML(message); - std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); + std::string id = "id" + std::to_string(idCounter_++); addMessageBottom(std::make_shared<SystemMessageSnippet>(messageHTML, QDateTime::currentDateTime(), false, theme_, P2QSTRING(id), getActualDirection(message, direction))); previousMessageKind_ = PreviousMessageWasSystem; return id; } @@ -925,13 +925,13 @@ void QtWebKitChatView::replaceMessage(const QString& message, const std::string& void QtWebKitChatView::addPresenceMessage(const ChatWindow::ChatMessage& message, ChatWindow::Direction direction) { if (window_->isWidgetSelected()) { window_->onAllMessagesRead(); } QString messageHTML = chatMessageToHTML(message); - std::string id = "id" + boost::lexical_cast<std::string>(idCounter_++); + std::string id = "id" + std::to_string(idCounter_++); addMessageBottom(std::make_shared<SystemMessageSnippet>(messageHTML, QDateTime::currentDateTime(), false, theme_, P2QSTRING(id), getActualDirection(message, direction))); previousMessageKind_ = PreviousMessageWasPresence; } void QtWebKitChatView::replaceLastMessage(const ChatWindow::ChatMessage& message, const ChatWindow::TimestampBehaviour timestampBehaviour) { diff --git a/Swiften/Base/URL.cpp b/Swiften/Base/URL.cpp index 4a47a11..3bc97ba 100644 --- a/Swiften/Base/URL.cpp +++ b/Swiften/Base/URL.cpp @@ -129,13 +129,13 @@ std::string URL::toString() const { } else { result += host; } if (port) { result += ":"; - result += boost::lexical_cast<std::string>(*port); + result += std::to_string(*port); } result += path; return result; } // Disabling this code for now, since GCC4.5+boost1.42 (on ubuntu) seems to diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp index 7a7ed3b..771251a 100644 --- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp +++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp @@ -32,13 +32,13 @@ ByteArray LinkLocalServiceInfo::toTXTRecord() const { append(result, getEncoded("msg=" + message)); } if (!nick.empty()) { append(result, getEncoded("nick=" + nick)); } if (port) { - append(result, getEncoded("port.p2pj=" + std::string(boost::lexical_cast<std::string>(*port)))); + append(result, getEncoded("port.p2pj=" + std::string(std::to_string(*port)))); } switch (status) { case Available: append(result, getEncoded("status=avail")); break; case Away: append(result, getEncoded("status=away")); break; case DND: append(result, getEncoded("status=dnd")); break; diff --git a/Swiften/Network/HostAddressPort.cpp b/Swiften/Network/HostAddressPort.cpp index 76c276e..401ddec 100644 --- a/Swiften/Network/HostAddressPort.cpp +++ b/Swiften/Network/HostAddressPort.cpp @@ -18,11 +18,11 @@ HostAddressPort::HostAddressPort(const boost::asio::ip::tcp::endpoint& endpoint) port_ = endpoint.port(); } std::string HostAddressPort::toString() const { std::string portAsString; try { - portAsString = boost::lexical_cast<std::string>(getPort()); + portAsString = std::to_string(getPort()); } catch (boost::bad_lexical_cast&) { } return getAddress().toString() + ":" + portAsString; } diff --git a/Swiften/Network/MiniUPnPInterface.cpp b/Swiften/Network/MiniUPnPInterface.cpp index dbe8bcd..2c61ad3 100644 --- a/Swiften/Network/MiniUPnPInterface.cpp +++ b/Swiften/Network/MiniUPnPInterface.cpp @@ -77,15 +77,15 @@ boost::optional<NATPortMapping> MiniUPnPInterface::addPortForward(int actualLoca if (!p->isValid) { return boost::optional<NATPortMapping>(); } NATPortMapping mapping(actualLocalPort, actualPublicPort, NATPortMapping::TCP); - std::string publicPort = boost::lexical_cast<std::string>(mapping.getPublicPort()); - std::string localPort = boost::lexical_cast<std::string>(mapping.getLocalPort()); - std::string leaseSeconds = boost::lexical_cast<std::string>(mapping.getLeaseInSeconds()); + std::string publicPort = std::to_string(mapping.getPublicPort()); + std::string localPort = std::to_string(mapping.getLocalPort()); + std::string leaseSeconds = std::to_string(mapping.getLeaseInSeconds()); int ret = UPNP_AddPortMapping( p->urls.controlURL, p->data.first.servicetype, publicPort.c_str(), localPort.c_str(), @@ -104,15 +104,15 @@ boost::optional<NATPortMapping> MiniUPnPInterface::addPortForward(int actualLoca bool MiniUPnPInterface::removePortForward(const NATPortMapping& mapping) { if (!p->isValid) { return false; } - std::string publicPort = boost::lexical_cast<std::string>(mapping.getPublicPort()); - std::string localPort = boost::lexical_cast<std::string>(mapping.getLocalPort()); - std::string leaseSeconds = boost::lexical_cast<std::string>(mapping.getLeaseInSeconds()); + std::string publicPort = std::to_string(mapping.getPublicPort()); + std::string localPort = std::to_string(mapping.getLocalPort()); + std::string leaseSeconds = std::to_string(mapping.getLeaseInSeconds()); int ret = UPNP_DeletePortMapping(p->urls.controlURL, p->data.first.servicetype, publicPort.c_str(), mapping.getProtocol() == NATPortMapping::TCP ? "TCP" : "UDP", nullptr); return ret == UPNPCOMMAND_SUCCESS; } bool MiniUPnPInterface::isAvailable() { diff --git a/Swiften/Network/StaticDomainNameResolver.cpp b/Swiften/Network/StaticDomainNameResolver.cpp index b8f4c7a..5a38fc4 100644 --- a/Swiften/Network/StaticDomainNameResolver.cpp +++ b/Swiften/Network/StaticDomainNameResolver.cpp @@ -99,13 +99,13 @@ void StaticDomainNameResolver::addAddress(const std::string& domain, const HostA void StaticDomainNameResolver::addService(const std::string& service, const DomainNameServiceQuery::Result& result) { services.push_back(std::make_pair(service, result)); } void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const HostAddressPort& address) { static int hostid = 0; - std::string hostname(std::string("host-") + boost::lexical_cast<std::string>(hostid)); + std::string hostname(std::string("host-") + std::to_string(hostid)); hostid++; addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, address.getPort(), 0, 0)); addAddress(hostname, address.getAddress()); } diff --git a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp index 5d6fedd..4aeaf24 100644 --- a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp +++ b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp @@ -191,13 +191,13 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { rid++; testling->write(createSafeByteArray("<blah/>")); eventLoop->processEvents(); CPPUNIT_ASSERT_EQUAL(st(2), connectionFactory->connections.size()); /* 0 was waiting for response, open and send on 1 */ CPPUNIT_ASSERT_EQUAL(st(4), boshDataWritten.size()); /* data */ c1 = connectionFactory->connections[1]; - std::string fullBody = "<body rid='" + boost::lexical_cast<std::string>(rid) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'><blah/></body>"; /* check empty write */ + std::string fullBody = "<body rid='" + std::to_string(rid) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'><blah/></body>"; /* check empty write */ CPPUNIT_ASSERT_EQUAL(fullBody, lastBody()); CPPUNIT_ASSERT(c0->pending); CPPUNIT_ASSERT(c1->pending); rid++; @@ -307,13 +307,13 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { testling->restartStream(); eventLoop->processEvents(); CPPUNIT_ASSERT_EQUAL(st(2), boshDataWritten.size()); readResponse("<body></body>", c0); eventLoop->processEvents(); CPPUNIT_ASSERT_EQUAL(st(3), boshDataWritten.size()); - std::string fullBody = "<body rid='" + boost::lexical_cast<std::string>(initialRID + 2) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'></body>"; + std::string fullBody = "<body rid='" + std::to_string(initialRID + 2) + "' sid='" + sid + "' xmlns='http://jabber.org/protocol/httpbind'></body>"; std::string response = boshDataWritten[2]; size_t bodyPosition = response.find("\r\n\r\n"); CPPUNIT_ASSERT_EQUAL(fullBody, response.substr(bodyPosition+4)); } @@ -424,26 +424,26 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture { "HTTP/1.1 200 OK\r\n" "Content-Type: text/xml; charset=utf-8\r\n" "Access-Control-Allow-Origin: *\r\n" "Access-Control-Allow-Headers: Content-Type\r\n" "Content-Length: ")); connection->onDataRead(data1); - std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(boost::lexical_cast<std::string>(response.size()))); + std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(std::to_string(response.size()))); connection->onDataRead(data2); std::shared_ptr<SafeByteArray> data3 = std::make_shared<SafeByteArray>(createSafeByteArray("\r\n\r\n")); connection->onDataRead(data3); std::shared_ptr<SafeByteArray> data4 = std::make_shared<SafeByteArray>(createSafeByteArray(response)); connection->onDataRead(data4); } std::string fullRequestFor(const std::string& data) { std::string body = data; std::string result = "POST /" + path + " HTTP/1.1\r\n" + "Host: " + to + ":" + port + "\r\n" + "Content-Type: text/xml; charset=utf-8\r\n" - + "Content-Length: " + boost::lexical_cast<std::string>(body.size()) + "\r\n\r\n" + + "Content-Length: " + std::to_string(body.size()) + "\r\n\r\n" + body; return result; } private: URL boshURL; diff --git a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp index e34cb96..17d8333 100644 --- a/Swiften/Network/UnitTest/BOSHConnectionTest.cpp +++ b/Swiften/Network/UnitTest/BOSHConnectionTest.cpp @@ -315,13 +315,13 @@ class BOSHConnectionTest : public CppUnit::TestFixture { "HTTP/1.1 200 OK\r\n" "Content-Type: text/xml; charset=utf-8\r\n" "Access-Control-Allow-Origin: *\r\n" "Access-Control-Allow-Headers: Content-Type\r\n" "Content-Length: ")); connection->onDataRead(data1); - std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(boost::lexical_cast<std::string>(response.size()))); + std::shared_ptr<SafeByteArray> data2 = std::make_shared<SafeByteArray>(createSafeByteArray(std::to_string(response.size()))); connection->onDataRead(data2); std::shared_ptr<SafeByteArray> data3 = std::make_shared<SafeByteArray>(createSafeByteArray("\r\n\r\n")); connection->onDataRead(data3); std::shared_ptr<SafeByteArray> data4 = std::make_shared<SafeByteArray>(createSafeByteArray(response)); connection->onDataRead(data4); } diff --git a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp index 78bb0eb..37a9c03 100644 --- a/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/BytestreamsSerializer.cpp @@ -22,13 +22,13 @@ std::string BytestreamsSerializer::serializePayload(std::shared_ptr<Bytestreams> XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams"); queryElement.setAttribute("sid", bytestreams->getStreamID()); for (const auto& streamHost : bytestreams->getStreamHosts()) { std::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost")); streamHostElement->setAttribute("host", streamHost.host); streamHostElement->setAttribute("jid", streamHost.jid.toString()); - streamHostElement->setAttribute("port", boost::lexical_cast<std::string>(streamHost.port)); + streamHostElement->setAttribute("port", std::to_string(streamHost.port)); queryElement.addNode(streamHostElement); } if (bytestreams->getUsedStreamHost()) { std::shared_ptr<XMLElement> streamHostElement(new XMLElement("streamhost-used")); streamHostElement->setAttribute("jid", *bytestreams->getUsedStreamHost()); diff --git a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp index e41ff8c..74a8e7b 100644 --- a/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/IBBSerializer.cpp @@ -23,26 +23,26 @@ IBBSerializer::IBBSerializer() { std::string IBBSerializer::serializePayload(std::shared_ptr<IBB> ibb) const { switch(ibb->getAction()) { case IBB::Data: { XMLElement ibbElement("data", "http://jabber.org/protocol/ibb"); ibbElement.setAttribute("sid", ibb->getStreamID()); if (ibb->getSequenceNumber() >= 0) { - ibbElement.setAttribute("seq", boost::lexical_cast<std::string>(ibb->getSequenceNumber())); + ibbElement.setAttribute("seq", std::to_string(ibb->getSequenceNumber())); } ibbElement.addNode(std::make_shared<XMLTextNode>(Base64::encode(ibb->getData()))); return ibbElement.serialize(); } case IBB::Open: { XMLElement ibbElement("open", "http://jabber.org/protocol/ibb"); ibbElement.setAttribute("sid", ibb->getStreamID()); switch (ibb->getStanzaType()) { case IBB::IQStanza: ibbElement.setAttribute("stanza", "iq"); break; case IBB::MessageStanza: ibbElement.setAttribute("stanza", "message"); break; } assert(ibb->getBlockSize() > 0); - ibbElement.setAttribute("block-size", boost::lexical_cast<std::string>(ibb->getBlockSize())); + ibbElement.setAttribute("block-size", std::to_string(ibb->getBlockSize())); return ibbElement.serialize(); } case IBB::Close: { XMLElement ibbElement("close", "http://jabber.org/protocol/ibb"); ibbElement.setAttribute("sid", ibb->getStreamID()); return ibbElement.serialize(); diff --git a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp index 35a0a6e..95996c7 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleFileTransferFileInfoSerializer.cpp @@ -41,19 +41,19 @@ std::string JingleFileTransferFileInfoSerializer::serializePayload(std::shared_p fileElement.addNode(std::make_shared<XMLElement>("name", "", fileInfo->getName())); } if (fileInfo->getSupportsRangeRequests()) { std::shared_ptr<XMLElement> range = std::make_shared<XMLElement>("range"); if (fileInfo->getRangeOffset() != 0) { - range->setAttribute("offset", boost::lexical_cast<std::string>(fileInfo->getRangeOffset())); + range->setAttribute("offset", std::to_string(fileInfo->getRangeOffset())); } fileElement.addNode(range); } if (fileInfo->getSize() > 0) { - fileElement.addNode(std::make_shared<XMLElement>("size", "", boost::lexical_cast<std::string>(fileInfo->getSize()))); + fileElement.addNode(std::make_shared<XMLElement>("size", "", std::to_string(fileInfo->getSize()))); } for (const auto& hashElement : fileInfo->getHashes()) { std::shared_ptr<XMLElement> hash = std::make_shared<XMLElement>("hash", "urn:xmpp:hashes:1", Base64::encode(hashElement.second)); hash->setAttribute("algo", hashElement.first); fileElement.addNode(hash); diff --git a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp index 9930e44..c5c45e1 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleIBBTransportPayloadSerializer.cpp @@ -25,13 +25,13 @@ namespace Swift { JingleIBBTransportPayloadSerializer::JingleIBBTransportPayloadSerializer() { } std::string JingleIBBTransportPayloadSerializer::serializePayload(std::shared_ptr<JingleIBBTransportPayload> payload) const { XMLElement payloadXML("transport", "urn:xmpp:jingle:transports:ibb:1"); if (payload->getBlockSize()) { - payloadXML.setAttribute("block-size", boost::lexical_cast<std::string>(*payload->getBlockSize())); + payloadXML.setAttribute("block-size", std::to_string(*payload->getBlockSize())); } payloadXML.setAttribute("sid", payload->getSessionID()); return payloadXML.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp index 5e74d8e..f9a1832 100644 --- a/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/JingleS5BTransportPayloadSerializer.cpp @@ -36,14 +36,14 @@ std::string JingleS5BTransportPayloadSerializer::serializePayload(std::shared_pt for (const auto& candidate : payload->getCandidates()) { std::shared_ptr<XMLElement> candidateXML = std::make_shared<XMLElement>("candidate"); candidateXML->setAttribute("cid", candidate.cid); candidateXML->setAttribute("host", candidate.hostPort.getAddress().toString()); candidateXML->setAttribute("jid", candidate.jid.toString()); - candidateXML->setAttribute("port", boost::lexical_cast<std::string>(candidate.hostPort.getPort())); - candidateXML->setAttribute("priority", boost::lexical_cast<std::string>(candidate.priority)); + candidateXML->setAttribute("port", std::to_string(candidate.hostPort.getPort())); + candidateXML->setAttribute("priority", std::to_string(candidate.priority)); candidateXML->setAttribute("type", typeToString(candidate.type)); payloadXML.addNode(candidateXML); } if (payload->hasCandidateError()) { payloadXML.addNode(std::make_shared<XMLElement>("candidate-error")); diff --git a/Swiften/Serializer/PayloadSerializers/LastSerializer.h b/Swiften/Serializer/PayloadSerializers/LastSerializer.h index 1710bc0..719eff5 100644 --- a/Swiften/Serializer/PayloadSerializers/LastSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/LastSerializer.h @@ -15,10 +15,10 @@ namespace Swift { class SWIFTEN_API LastSerializer : public GenericPayloadSerializer<Last> { public: LastSerializer() : GenericPayloadSerializer<Last>() {} virtual std::string serializePayload(std::shared_ptr<Last> last) const { - return "<query xmlns='jabber:iq:last' seconds='" + boost::lexical_cast<std::string>(last->getSeconds()) + "'/>"; + return "<query xmlns='jabber:iq:last' seconds='" + std::to_string(last->getSeconds()) + "'/>"; } }; } diff --git a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp index 4f0f637..cde129e 100644 --- a/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/MUCPayloadSerializer.cpp @@ -22,21 +22,21 @@ MUCPayloadSerializer::MUCPayloadSerializer() : GenericPayloadSerializer<MUCPaylo std::string MUCPayloadSerializer::serializePayload(std::shared_ptr<MUCPayload> muc) const { XMLElement mucElement("x", "http://jabber.org/protocol/muc"); std::shared_ptr<XMLElement> historyElement(new XMLElement("history")); bool history = false; if (muc->getMaxChars() >= 0) { - historyElement->setAttribute("maxchars", boost::lexical_cast<std::string>(muc->getMaxChars())); + historyElement->setAttribute("maxchars", std::to_string(muc->getMaxChars())); history = true; } if (muc->getMaxStanzas() >= 0) { - historyElement->setAttribute("maxstanzas", boost::lexical_cast<std::string>(muc->getMaxStanzas())); + historyElement->setAttribute("maxstanzas", std::to_string(muc->getMaxStanzas())); history = true; } if (muc->getSeconds() >= 0) { - historyElement->setAttribute("seconds", boost::lexical_cast<std::string>(muc->getSeconds())); + historyElement->setAttribute("seconds", std::to_string(muc->getSeconds())); history = true; } if (muc->getSince() != boost::posix_time::not_a_date_time) { std::string sinceString = std::string(boost::posix_time::to_iso_extended_string(muc->getSince())); String::replaceAll(sinceString, ',', "."); sinceString += "Z"; diff --git a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h index 687d07f..fa2cef0 100644 --- a/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h +++ b/Swiften/Serializer/PayloadSerializers/PrioritySerializer.h @@ -15,10 +15,10 @@ namespace Swift { class SWIFTEN_API PrioritySerializer : public GenericPayloadSerializer<Priority> { public: PrioritySerializer() : GenericPayloadSerializer<Priority>() {} virtual std::string serializePayload(std::shared_ptr<Priority> priority) const { - return "<priority>" + boost::lexical_cast<std::string>(priority->getPriority()) + "</priority>"; + return "<priority>" + std::to_string(priority->getPriority()) + "</priority>"; } }; } diff --git a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp index 9786f51..b2c7326 100644 --- a/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/PubSubItemsSerializer.cpp @@ -34,13 +34,13 @@ std::string PubSubItemsSerializer::serializePayload(std::shared_ptr<PubSubItems> } element.setAttribute("node", payload->getNode()); for (const auto& item : payload->getItems()) { element.addNode(std::make_shared<XMLRawTextNode>(PubSubItemSerializer(serializers).serialize(item))); } if (payload->getMaximumItems()) { - element.setAttribute("max_items", boost::lexical_cast<std::string>(*payload->getMaximumItems())); + element.setAttribute("max_items", std::to_string(*payload->getMaximumItems())); } if (payload->getSubscriptionID()) { element.setAttribute("subid", *payload->getSubscriptionID()); } return element.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp index 3302863..3d13ce3 100644 --- a/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/ResultSetSerializer.cpp @@ -26,27 +26,27 @@ std::string ResultSetSerializer::serializePayload(std::shared_ptr<ResultSet> pay return ""; } XMLElement element("set", "http://jabber.org/protocol/rsm"); if (payload->getMaxItems()) { - element.addNode(std::make_shared<XMLElement>("max", "", boost::lexical_cast<std::string>(*payload->getMaxItems()))); + element.addNode(std::make_shared<XMLElement>("max", "", std::to_string(*payload->getMaxItems()))); } if (payload->getCount()) { - element.addNode(std::make_shared<XMLElement>("count", "", boost::lexical_cast<std::string>(*payload->getCount()))); + element.addNode(std::make_shared<XMLElement>("count", "", std::to_string(*payload->getCount()))); } if (payload->getIndex()) { - element.addNode(std::make_shared<XMLElement>("index", "", boost::lexical_cast<std::string>(*payload->getIndex()))); + element.addNode(std::make_shared<XMLElement>("index", "", std::to_string(*payload->getIndex()))); } if (payload->getFirstID()) { std::shared_ptr<XMLElement> firstElement = std::make_shared<XMLElement>("first", "", *payload->getFirstID()); if (payload->getFirstIDIndex()) { - firstElement->setAttribute("index", boost::lexical_cast<std::string>(*payload->getFirstIDIndex())); + firstElement->setAttribute("index", std::to_string(*payload->getFirstIDIndex())); } element.addNode(firstElement); } if (payload->getLastID()) { element.addNode(std::make_shared<XMLElement>("last", "", *payload->getLastID())); diff --git a/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h b/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h index 14cbd14..e992f72 100644 --- a/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h +++ b/Swiften/Serializer/PayloadSerializers/S5BProxyRequestSerializer.h @@ -26,13 +26,13 @@ namespace Swift { public: virtual std::string serializePayload(std::shared_ptr<S5BProxyRequest> s5bProxyRequest) const { XMLElement queryElement("query", "http://jabber.org/protocol/bytestreams"); if (s5bProxyRequest && s5bProxyRequest->getStreamHost()) { std::shared_ptr<XMLElement> streamHost = std::make_shared<XMLElement>("streamhost"); streamHost->setAttribute("host", s5bProxyRequest->getStreamHost().get().host); - streamHost->setAttribute("port", boost::lexical_cast<std::string>(s5bProxyRequest->getStreamHost().get().port)); + streamHost->setAttribute("port", std::to_string(s5bProxyRequest->getStreamHost().get().port)); streamHost->setAttribute("jid", s5bProxyRequest->getStreamHost().get().jid.toString()); queryElement.addNode(streamHost); } else if (s5bProxyRequest && s5bProxyRequest->getActivate()) { queryElement.setAttribute("sid", s5bProxyRequest->getSID()); std::shared_ptr<XMLElement> activate = std::make_shared<XMLElement>("activate", "", s5bProxyRequest->getActivate().get().toString()); queryElement.addNode(activate); diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp index ba296f9..718e550 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationFileInfoSerializer.cpp @@ -37,22 +37,22 @@ std::string StreamInitiationFileInfoSerializer::serializePayload(std::shared_ptr fileElement.setAttribute("algo", fileInfo->getAlgo()); } if (!fileInfo->getName().empty()) { fileElement.setAttribute("name", fileInfo->getName()); } if (fileInfo->getSize() != 0) { - fileElement.setAttribute("size", boost::lexical_cast<std::string>(fileInfo->getSize())); + fileElement.setAttribute("size", std::to_string(fileInfo->getSize())); } if (!fileInfo->getDescription().empty()) { std::shared_ptr<XMLElement> desc = std::make_shared<XMLElement>("desc", "", fileInfo->getDescription()); fileElement.addNode(desc); } if (fileInfo->getSupportsRangeRequests()) { std::shared_ptr<XMLElement> range = std::make_shared<XMLElement>("range"); if (fileInfo->getRangeOffset() != 0) { - range->setAttribute("offset", boost::lexical_cast<std::string>(fileInfo->getRangeOffset())); + range->setAttribute("offset", std::to_string(fileInfo->getRangeOffset())); } fileElement.addNode(range); } return fileElement.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp index 3faa5b7..813edb4 100644 --- a/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/StreamInitiationSerializer.cpp @@ -35,13 +35,13 @@ std::string StreamInitiationSerializer::serializePayload(std::shared_ptr<StreamI if (streamInitiation->getFileInfo()) { StreamInitiationFileInfo file = *streamInitiation->getFileInfo(); std::shared_ptr<XMLElement> fileElement(new XMLElement("file", "http://jabber.org/protocol/si/profile/file-transfer")); fileElement->setAttribute("name", file.getName()); if (file.getSize() != 0) { - fileElement->setAttribute("size", boost::lexical_cast<std::string>(file.getSize())); + fileElement->setAttribute("size", std::to_string(file.getSize())); } if (!file.getDescription().empty()) { std::shared_ptr<XMLElement> descElement(new XMLElement("desc")); descElement->addNode(std::make_shared<XMLTextNode>(file.getDescription())); fileElement->addNode(descElement); } diff --git a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp index 687b566..8bb3a4b 100644 --- a/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/UserTuneSerializer.cpp @@ -23,13 +23,13 @@ UserTuneSerializer::~UserTuneSerializer() { std::string UserTuneSerializer::serializePayload(std::shared_ptr<UserTune> payload) const { if (!payload) { return ""; } XMLElement element("tune", "http://jabber.org/protocol/tune"); if (payload->getRating()) { - element.addNode(std::make_shared<XMLElement>("rating", "", boost::lexical_cast<std::string>(*payload->getRating()))); + element.addNode(std::make_shared<XMLElement>("rating", "", std::to_string(*payload->getRating()))); } if (payload->getTitle()) { element.addNode(std::make_shared<XMLElement>("title", "", *payload->getTitle())); } if (payload->getTrack()) { element.addNode(std::make_shared<XMLElement>("track", "", *payload->getTrack())); @@ -41,12 +41,12 @@ std::string UserTuneSerializer::serializePayload(std::shared_ptr<UserTune> paylo element.addNode(std::make_shared<XMLElement>("uri", "", *payload->getURI())); } if (payload->getSource()) { element.addNode(std::make_shared<XMLElement>("source", "", *payload->getSource())); } if (payload->getLength()) { - element.addNode(std::make_shared<XMLElement>("length", "", boost::lexical_cast<std::string>(*payload->getLength()))); + element.addNode(std::make_shared<XMLElement>("length", "", std::to_string(*payload->getLength()))); } return element.serialize(); } diff --git a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp index 34fd149..4743089 100644 --- a/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/WhiteboardSerializer.cpp @@ -23,105 +23,105 @@ #include <Swiften/Serializer/XML/XMLTextNode.h> namespace Swift { void WhiteboardElementSerializingVisitor::visit(WhiteboardLineElement& line) { element = std::make_shared<XMLElement>("line"); try { - element->setAttribute("x1", boost::lexical_cast<std::string>(line.x1())); - element->setAttribute("y1", boost::lexical_cast<std::string>(line.y1())); - element->setAttribute("x2", boost::lexical_cast<std::string>(line.x2())); - element->setAttribute("y2", boost::lexical_cast<std::string>(line.y2())); + element->setAttribute("x1", std::to_string(line.x1())); + element->setAttribute("y1", std::to_string(line.y1())); + element->setAttribute("x2", std::to_string(line.x2())); + element->setAttribute("y2", std::to_string(line.y2())); element->setAttribute("id", line.getID()); element->setAttribute("stroke", line.getColor().toHex()); - element->setAttribute("stroke-width", boost::lexical_cast<std::string>(line.getPenWidth())); + element->setAttribute("stroke-width", std::to_string(line.getPenWidth())); element->setAttribute("opacity", alphaToOpacity(line.getColor().getAlpha())); } catch (boost::bad_lexical_cast&) { } } void WhiteboardElementSerializingVisitor::visit(WhiteboardFreehandPathElement& path) { element = std::make_shared<XMLElement>("path"); element->setAttribute("id", path.getID()); element->setAttribute("stroke", path.getColor().toHex()); try { - element->setAttribute("stroke-width", boost::lexical_cast<std::string>(path.getPenWidth())); + element->setAttribute("stroke-width", std::to_string(path.getPenWidth())); element->setAttribute("opacity", alphaToOpacity(path.getColor().getAlpha())); std::string pathData; if (path.getPoints().size() != 0) { std::vector<std::pair<int, int> >::const_iterator it = path.getPoints().begin(); - pathData = "M"+boost::lexical_cast<std::string>(it->first)+" "+boost::lexical_cast<std::string>(it->second)+"L"; + pathData = "M"+std::to_string(it->first)+" "+std::to_string(it->second)+"L"; for (; it != path.getPoints().end(); ++it) { - pathData += boost::lexical_cast<std::string>(it->first)+" "+boost::lexical_cast<std::string>(it->second)+" "; + pathData += std::to_string(it->first)+" "+std::to_string(it->second)+" "; } } element->setAttribute("d", pathData); } catch (boost::bad_lexical_cast&) { } } void WhiteboardElementSerializingVisitor::visit(WhiteboardRectElement& rect) { element = std::make_shared<XMLElement>("rect"); try { - element->setAttribute("x", boost::lexical_cast<std::string>(rect.getX())); - element->setAttribute("y", boost::lexical_cast<std::string>(rect.getY())); - element->setAttribute("width", boost::lexical_cast<std::string>(rect.getWidth())); - element->setAttribute("height", boost::lexical_cast<std::string>(rect.getHeight())); + element->setAttribute("x", std::to_string(rect.getX())); + element->setAttribute("y", std::to_string(rect.getY())); + element->setAttribute("width", std::to_string(rect.getWidth())); + element->setAttribute("height", std::to_string(rect.getHeight())); element->setAttribute("id", rect.getID()); element->setAttribute("stroke", rect.getPenColor().toHex()); element->setAttribute("fill", rect.getBrushColor().toHex());; - element->setAttribute("stroke-width", boost::lexical_cast<std::string>(rect.getPenWidth())); + element->setAttribute("stroke-width", std::to_string(rect.getPenWidth())); element->setAttribute("opacity", alphaToOpacity(rect.getPenColor().getAlpha())); element->setAttribute("fill-opacity", alphaToOpacity(rect.getBrushColor().getAlpha())); } catch (boost::bad_lexical_cast&) { } } void WhiteboardElementSerializingVisitor::visit(WhiteboardPolygonElement& polygon) { element = std::make_shared<XMLElement>("polygon"); try { element->setAttribute("id", polygon.getID()); element->setAttribute("stroke", polygon.getPenColor().toHex()); element->setAttribute("fill", polygon.getBrushColor().toHex());; - element->setAttribute("stroke-width", boost::lexical_cast<std::string>(polygon.getPenWidth())); + element->setAttribute("stroke-width", std::to_string(polygon.getPenWidth())); element->setAttribute("opacity", alphaToOpacity(polygon.getPenColor().getAlpha())); element->setAttribute("fill-opacity", alphaToOpacity(polygon.getBrushColor().getAlpha())); std::string points; std::vector<std::pair<int, int> >::const_iterator it = polygon.getPoints().begin(); for (; it != polygon.getPoints().end(); ++it) { - points += boost::lexical_cast<std::string>(it->first)+","+boost::lexical_cast<std::string>(it->second)+" "; + points += std::to_string(it->first)+","+std::to_string(it->second)+" "; } element->setAttribute("points", points); } catch (boost::bad_lexical_cast&) { } } void WhiteboardElementSerializingVisitor::visit(WhiteboardTextElement& text) { element = std::make_shared<XMLElement>("text"); try { - element->setAttribute("x", boost::lexical_cast<std::string>(text.getX())); - element->setAttribute("y", boost::lexical_cast<std::string>(text.getY())); - element->setAttribute("font-size", boost::lexical_cast<std::string>(text.getSize())); + element->setAttribute("x", std::to_string(text.getX())); + element->setAttribute("y", std::to_string(text.getY())); + element->setAttribute("font-size", std::to_string(text.getSize())); element->setAttribute("id", text.getID()); element->setAttribute("fill", text.getColor().toHex()); element->setAttribute("opacity", alphaToOpacity(text.getColor().getAlpha())); element->addNode(std::make_shared<XMLTextNode>(text.getText())); } catch (boost::bad_lexical_cast&) { } } void WhiteboardElementSerializingVisitor::visit(WhiteboardEllipseElement& ellipse) { element = std::make_shared<XMLElement>("ellipse"); try { - element->setAttribute("cx", boost::lexical_cast<std::string>(ellipse.getCX())); - element->setAttribute("cy", boost::lexical_cast<std::string>(ellipse.getCY())); - element->setAttribute("rx", boost::lexical_cast<std::string>(ellipse.getRX())); - element->setAttribute("ry", boost::lexical_cast<std::string>(ellipse.getRY())); + element->setAttribute("cx", std::to_string(ellipse.getCX())); + element->setAttribute("cy", std::to_string(ellipse.getCY())); + element->setAttribute("rx", std::to_string(ellipse.getRX())); + element->setAttribute("ry", std::to_string(ellipse.getRY())); element->setAttribute("id", ellipse.getID()); element->setAttribute("stroke", ellipse.getPenColor().toHex()); element->setAttribute("fill", ellipse.getBrushColor().toHex());; - element->setAttribute("stroke-width", boost::lexical_cast<std::string>(ellipse.getPenWidth())); + element->setAttribute("stroke-width", std::to_string(ellipse.getPenWidth())); element->setAttribute("opacity", alphaToOpacity(ellipse.getPenColor().getAlpha())); element->setAttribute("fill-opacity", alphaToOpacity(ellipse.getBrushColor().getAlpha())); } catch (boost::bad_lexical_cast&) { } } @@ -131,13 +131,13 @@ namespace Swift { std::string WhiteboardElementSerializingVisitor::alphaToOpacity(int alpha) const { int opacity = 100*alpha/254; if (opacity == 100) { return "1"; } else { - return "."+boost::lexical_cast<std::string>(opacity); + return "."+std::to_string(opacity); } } std::string WhiteboardSerializer::serializePayload(std::shared_ptr<WhiteboardPayload> payload) const { XMLElement element("wb", "http://swift.im/whiteboard"); if (payload->getType() == WhiteboardPayload::Data) { @@ -145,40 +145,40 @@ namespace Swift { WhiteboardElementSerializingVisitor visitor; // payload->getElement()->accept(visitor); WhiteboardInsertOperation::ref insertOp = std::dynamic_pointer_cast<WhiteboardInsertOperation>(payload->getOperation()); if (insertOp) { try { operationNode->setAttribute("type", "insert"); - operationNode->setAttribute("pos", boost::lexical_cast<std::string>(insertOp->getPos())); + operationNode->setAttribute("pos", std::to_string(insertOp->getPos())); operationNode->setAttribute("id", insertOp->getID()); operationNode->setAttribute("parentid", insertOp->getParentID()); } catch (boost::bad_lexical_cast&) { } insertOp->getElement()->accept(visitor); operationNode->addNode(visitor.getResult()); } WhiteboardUpdateOperation::ref updateOp = std::dynamic_pointer_cast<WhiteboardUpdateOperation>(payload->getOperation()); if (updateOp) { try { operationNode->setAttribute("type", "update"); - operationNode->setAttribute("pos", boost::lexical_cast<std::string>(updateOp->getPos())); + operationNode->setAttribute("pos", std::to_string(updateOp->getPos())); operationNode->setAttribute("id", updateOp->getID()); operationNode->setAttribute("parentid", updateOp->getParentID()); - operationNode->setAttribute("newpos", boost::lexical_cast<std::string>(updateOp->getNewPos())); + operationNode->setAttribute("newpos", std::to_string(updateOp->getNewPos())); } catch (boost::bad_lexical_cast&) { } updateOp->getElement()->accept(visitor); operationNode->addNode(visitor.getResult()); } WhiteboardDeleteOperation::ref deleteOp = std::dynamic_pointer_cast<WhiteboardDeleteOperation>(payload->getOperation()); if (deleteOp) { try { operationNode->setAttribute("type", "delete"); - operationNode->setAttribute("pos", boost::lexical_cast<std::string>(deleteOp->getPos())); + operationNode->setAttribute("pos", std::to_string(deleteOp->getPos())); operationNode->setAttribute("id", deleteOp->getID()); operationNode->setAttribute("parentid", deleteOp->getParentID()); operationNode->setAttribute("elementid", deleteOp->getElementID()); } catch (boost::bad_lexical_cast&) { } } diff --git a/Swiften/Serializer/StanzaAckSerializer.h b/Swiften/Serializer/StanzaAckSerializer.h index f5a27dc..228d67b 100644 --- a/Swiften/Serializer/StanzaAckSerializer.h +++ b/Swiften/Serializer/StanzaAckSerializer.h @@ -22,11 +22,11 @@ namespace Swift { } virtual SafeByteArray serialize(std::shared_ptr<ToplevelElement> element) const { StanzaAck::ref stanzaAck(std::dynamic_pointer_cast<StanzaAck>(element)); assert(stanzaAck->isValid()); XMLElement result("a", "urn:xmpp:sm:2"); - result.setAttribute("h", std::string(boost::lexical_cast<std::string>(stanzaAck->getHandledStanzasCount()))); + result.setAttribute("h", std::string(std::to_string(stanzaAck->getHandledStanzasCount()))); return createSafeByteArray(result.serialize()); } }; } diff --git a/Swiften/Serializer/StreamResumeSerializer.cpp b/Swiften/Serializer/StreamResumeSerializer.cpp index 619ac9c..e4a40c9 100644 --- a/Swiften/Serializer/StreamResumeSerializer.cpp +++ b/Swiften/Serializer/StreamResumeSerializer.cpp @@ -20,10 +20,10 @@ StreamResumeSerializer::StreamResumeSerializer() : GenericElementSerializer<Stre SafeByteArray StreamResumeSerializer::serialize(std::shared_ptr<ToplevelElement> el) const { std::shared_ptr<StreamResume> e(std::dynamic_pointer_cast<StreamResume>(el)); XMLElement element("resume", "urn:xmpp:sm:2"); element.setAttribute("previd", e->getResumeID()); if (e->getHandledStanzasCount()) { - element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get())); + element.setAttribute("h", std::to_string(e->getHandledStanzasCount().get())); } return createSafeByteArray(element.serialize()); } diff --git a/Swiften/Serializer/StreamResumedSerializer.cpp b/Swiften/Serializer/StreamResumedSerializer.cpp index 5b88ded..2398335 100644 --- a/Swiften/Serializer/StreamResumedSerializer.cpp +++ b/Swiften/Serializer/StreamResumedSerializer.cpp @@ -20,10 +20,10 @@ StreamResumedSerializer::StreamResumedSerializer() : GenericElementSerializer<St SafeByteArray StreamResumedSerializer::serialize(std::shared_ptr<ToplevelElement> el) const { std::shared_ptr<StreamResumed> e(std::dynamic_pointer_cast<StreamResumed>(el)); XMLElement element("resumed", "urn:xmpp:sm:2"); element.setAttribute("previd", e->getResumeID()); if (e->getHandledStanzasCount()) { - element.setAttribute("h", boost::lexical_cast<std::string>(e->getHandledStanzasCount().get())); + element.setAttribute("h", std::to_string(e->getHandledStanzasCount().get())); } return createSafeByteArray(element.serialize()); } |
Swift