diff options
author | Tobias Markmann <tm@ayena.de> | 2016-04-01 17:23:49 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-04-04 08:28:23 (GMT) |
commit | 741c45b74d5f634622eb5f757c49323274fb8937 (patch) | |
tree | b9cfa6c2fe2e79e03cc8cb7c1ca1e9cf45aa5328 /Swift/Controllers/Chat/ChatMessageParser.cpp | |
parent | eddd92ed76ae68cb1e202602fd3ebd11b69191a2 (diff) | |
download | swift-741c45b74d5f634622eb5f757c49323274fb8937.zip swift-741c45b74d5f634622eb5f757c49323274fb8937.tar.bz2 |
Modernize code to use C++11 shared_ptr instead of Boost's
This change was done by applying the following 'gsed'
replacement calls to all source files:
's/\#include <boost\/shared_ptr\.hpp>/\#include <memory>/g'
's/\#include <boost\/enable_shared_from_this\.hpp>/\#include <memory>/g'
's/\#include <boost\/smart_ptr\/make_shared\.hpp>/\#include <memory>/g'
's/\#include <boost\/make_shared\.hpp>/\#include <memory>/g'
's/\#include <boost\/weak_ptr\.hpp>/\#include <memory>/g'
's/boost::make_shared/std::make_shared/g'
's/boost::dynamic_pointer_cast/std::dynamic_pointer_cast/g'
's/boost::shared_ptr/std::shared_ptr/g'
's/boost::weak_ptr/std::weak_ptr/g'
's/boost::enable_shared_from_this/std::enable_shared_from_this/g'
The remaining issues have been fixed manually.
Test-Information:
Code builds on OS X 10.11.4 and unit tests pass.
Change-Id: Ia7ae34eab869fb9ad6387a1348426b71ae4acd5f
Diffstat (limited to 'Swift/Controllers/Chat/ChatMessageParser.cpp')
-rw-r--r-- | Swift/Controllers/Chat/ChatMessageParser.cpp | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/Swift/Controllers/Chat/ChatMessageParser.cpp b/Swift/Controllers/Chat/ChatMessageParser.cpp index 08e4fcd..c204371 100644 --- a/Swift/Controllers/Chat/ChatMessageParser.cpp +++ b/Swift/Controllers/Chat/ChatMessageParser.cpp @@ -6,11 +6,11 @@ #include <Swift/Controllers/Chat/ChatMessageParser.h> +#include <memory> #include <utility> #include <vector> #include <boost/algorithm/string.hpp> -#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Base/Regex.h> #include <Swiften/Base/foreach.h> @@ -42,10 +42,10 @@ namespace Swift { else { if (i == links.second) { found = true; - parsedMessage.append(boost::make_shared<ChatWindow::ChatURIMessagePart>(part)); + parsedMessage.append(std::make_shared<ChatWindow::ChatURIMessagePart>(part)); } else { - parsedMessage.append(boost::make_shared<ChatWindow::ChatTextMessagePart>(part)); + parsedMessage.append(std::make_shared<ChatWindow::ChatTextMessagePart>(part)); } } } @@ -85,9 +85,9 @@ namespace Swift { boost::regex emoticonRegex(regexString); ChatWindow::ChatMessage newMessage; - foreach (boost::shared_ptr<ChatWindow::ChatMessagePart> part, parsedMessage.getParts()) { - boost::shared_ptr<ChatWindow::ChatTextMessagePart> textPart; - if ((textPart = boost::dynamic_pointer_cast<ChatWindow::ChatTextMessagePart>(part))) { + foreach (std::shared_ptr<ChatWindow::ChatMessagePart> part, parsedMessage.getParts()) { + std::shared_ptr<ChatWindow::ChatTextMessagePart> textPart; + if ((textPart = std::dynamic_pointer_cast<ChatWindow::ChatTextMessagePart>(part))) { try { boost::match_results<std::string::const_iterator> match; const std::string& text = textPart->text; @@ -104,9 +104,9 @@ namespace Swift { std::string::const_iterator matchEnd = match[matchIndex].second; if (start != matchStart) { /* If we're skipping over plain text since the previous emoticon, record it as plain text */ - newMessage.append(boost::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, matchStart))); + newMessage.append(std::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, matchStart))); } - boost::shared_ptr<ChatWindow::ChatEmoticonMessagePart> emoticonPart = boost::make_shared<ChatWindow::ChatEmoticonMessagePart>(); + std::shared_ptr<ChatWindow::ChatEmoticonMessagePart> emoticonPart = std::make_shared<ChatWindow::ChatEmoticonMessagePart>(); std::string matchString = match[matchIndex].str(); std::map<std::string, std::string>::const_iterator emoticonIterator = emoticons_.find(matchString); assert (emoticonIterator != emoticons_.end()); @@ -118,7 +118,7 @@ namespace Swift { } if (start != text.end()) { /* If there's plain text after the last emoticon, record it */ - newMessage.append(boost::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, text.end()))); + newMessage.append(std::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, text.end()))); } } @@ -153,9 +153,9 @@ namespace Swift { const std::vector<boost::regex> keywordRegex = rule.getKeywordRegex(nick); foreach(const boost::regex& regex, keywordRegex) { ChatWindow::ChatMessage newMessage; - foreach (boost::shared_ptr<ChatWindow::ChatMessagePart> part, parsedMessage.getParts()) { - boost::shared_ptr<ChatWindow::ChatTextMessagePart> textPart; - if ((textPart = boost::dynamic_pointer_cast<ChatWindow::ChatTextMessagePart>(part))) { + foreach (std::shared_ptr<ChatWindow::ChatMessagePart> part, parsedMessage.getParts()) { + std::shared_ptr<ChatWindow::ChatTextMessagePart> textPart; + if ((textPart = std::dynamic_pointer_cast<ChatWindow::ChatTextMessagePart>(part))) { try { boost::match_results<std::string::const_iterator> match; const std::string& text = textPart->text; @@ -165,9 +165,9 @@ namespace Swift { std::string::const_iterator matchEnd = match[0].second; if (start != matchStart) { /* If we're skipping over plain text since the previous emoticon, record it as plain text */ - newMessage.append(boost::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, matchStart))); + newMessage.append(std::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, matchStart))); } - boost::shared_ptr<ChatWindow::ChatHighlightingMessagePart> highlightPart = boost::make_shared<ChatWindow::ChatHighlightingMessagePart>(); + std::shared_ptr<ChatWindow::ChatHighlightingMessagePart> highlightPart = std::make_shared<ChatWindow::ChatHighlightingMessagePart>(); highlightPart->text = match.str(); highlightPart->action = rule.getAction(); newMessage.append(highlightPart); @@ -175,7 +175,7 @@ namespace Swift { } if (start != text.end()) { /* If there's plain text after the last emoticon, record it */ - newMessage.append(boost::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, text.end()))); + newMessage.append(std::make_shared<ChatWindow::ChatTextMessagePart>(std::string(start, text.end()))); } } catch (std::runtime_error) { |