summaryrefslogtreecommitdiff
path: root/src/irc
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-04-07 18:45:24 +0200
committerlouiz’ <louiz@louiz.org>2017-04-07 18:45:24 +0200
commit5402a256d1f0ebbeafa32d250d000cf38fe748fb (patch)
tree7132c08b9465823c0fd5066eca1fac61ffa7185c /src/irc
parentdd4c54c6cde55c034d756fb736259ce51e0120dc (diff)
downloadbiboumi-5402a256d1f0ebbeafa32d250d000cf38fe748fb.tar.gz
biboumi-5402a256d1f0ebbeafa32d250d000cf38fe748fb.tar.bz2
biboumi-5402a256d1f0ebbeafa32d250d000cf38fe748fb.tar.xz
biboumi-5402a256d1f0ebbeafa32d250d000cf38fe748fb.zip
Apply all the clang-tidy modernize-* fixes
Diffstat (limited to 'src/irc')
-rw-r--r--src/irc/iid.cpp9
-rw-r--r--src/irc/iid.hpp2
-rw-r--r--src/irc/irc_client.cpp41
-rw-r--r--src/irc/irc_client.hpp6
4 files changed, 30 insertions, 28 deletions
diff --git a/src/irc/iid.cpp b/src/irc/iid.cpp
index 6b07793..63c7039 100644
--- a/src/irc/iid.cpp
+++ b/src/irc/iid.cpp
@@ -1,3 +1,4 @@
+#include <utility>
#include <utils/tolower.hpp>
#include <config/config.hpp>
#include <bridge/bridge.hpp>
@@ -7,10 +8,10 @@
constexpr char Iid::separator[];
-Iid::Iid(const std::string& local, const std::string& server, Iid::Type type):
- type(type),
- local(local),
- server(server)
+Iid::Iid(std::string local, std::string server, Iid::Type type):
+ type(std::move(type)),
+ local(std::move(local)),
+ server(std::move(server))
{
}
diff --git a/src/irc/iid.hpp b/src/irc/iid.hpp
index 81cf3ca..89f4797 100644
--- a/src/irc/iid.hpp
+++ b/src/irc/iid.hpp
@@ -59,7 +59,7 @@ public:
Iid(const std::string& iid, const std::set<char>& chantypes);
Iid(const std::string& iid, const std::initializer_list<char>& chantypes);
Iid(const std::string& iid, const Bridge* bridge);
- Iid(const std::string& local, const std::string& server, Type type);
+ Iid(std::string local, std::string server, Type type);
Iid() = default;
Iid(const Iid&) = default;
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index 48b105d..710ba15 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -1,3 +1,4 @@
+#include <utility>
#include <utils/timed_events.hpp>
#include <database/database.hpp>
#include <irc/irc_message.hpp>
@@ -127,16 +128,16 @@ static const std::unordered_map<std::string,
{"502", {&IrcClient::on_generic_error, {2, 0}}},
};
-IrcClient::IrcClient(std::shared_ptr<Poller>& poller, const std::string& hostname,
- const std::string& nickname, const std::string& username,
- const std::string& realname, const std::string& user_hostname,
+IrcClient::IrcClient(std::shared_ptr<Poller>& poller, std::string hostname,
+ std::string nickname, std::string username,
+ std::string realname, std::string user_hostname,
Bridge& bridge):
TCPClientSocketHandler(poller),
- hostname(hostname),
- user_hostname(user_hostname),
- username(username),
- realname(realname),
- current_nick(nickname),
+ hostname(std::move(hostname)),
+ user_hostname(std::move(user_hostname)),
+ username(std::move(username)),
+ realname(std::move(realname)),
+ current_nick(std::move(nickname)),
bridge(bridge),
welcomed(false),
chanmodes({"", "", "", ""}),
@@ -791,10 +792,10 @@ void IrcClient::on_nickname_conflict(const IrcMessage& message)
{
const std::string nickname = message.arguments[1];
this->on_generic_error(message);
- for (auto it = this->channels.begin(); it != this->channels.end(); ++it)
+ for (const auto& pair: this->channels)
{
Iid iid;
- iid.set_local(it->first);
+ iid.set_local(pair.first);
iid.set_server(this->hostname);
iid.type = Iid::Type::Channel;
this->bridge.send_nickname_conflict_error(iid, nickname);
@@ -808,10 +809,10 @@ void IrcClient::on_nickname_change_too_fast(const IrcMessage& message)
if (message.arguments.size() >= 3)
txt = message.arguments[2];
this->on_generic_error(message);
- for (auto it = this->channels.begin(); it != this->channels.end(); ++it)
+ for (const auto& pair: this->channels)
{
Iid iid;
- iid.set_local(it->first);
+ iid.set_local(pair.first);
iid.set_server(this->hostname);
iid.type = Iid::Type::Channel;
this->bridge.send_presence_error(iid, nickname,
@@ -896,13 +897,13 @@ void IrcClient::on_error(const IrcMessage& message)
{
const std::string leave_message = message.arguments[0];
// The user is out of all the channels
- for (auto it = this->channels.begin(); it != this->channels.end(); ++it)
+ for (const auto& pair: this->channels)
{
Iid iid;
- iid.set_local(it->first);
+ iid.set_local(pair.first);
iid.set_server(this->hostname);
iid.type = Iid::Type::Channel;
- IrcChannel* channel = it->second.get();
+ IrcChannel* channel = pair.second.get();
if (!channel->joined)
continue;
std::string own_nick = channel->get_self()->nick;
@@ -917,10 +918,10 @@ void IrcClient::on_quit(const IrcMessage& message)
std::string txt;
if (message.arguments.size() >= 1)
txt = message.arguments[0];
- for (auto it = this->channels.begin(); it != this->channels.end(); ++it)
+ for (const auto& pair: this->channels)
{
- const std::string chan_name = it->first;
- IrcChannel* channel = it->second.get();
+ const std::string& chan_name = pair.first;
+ IrcChannel* channel = pair.second.get();
const IrcUser* user = channel->find_user(message.prefix);
if (user)
{
@@ -966,9 +967,9 @@ void IrcClient::on_nick(const IrcMessage& message)
{
change_nick_func("", &this->get_dummy_channel());
}
- for (auto it = this->channels.begin(); it != this->channels.end(); ++it)
+ for (const auto& pair: this->channels)
{
- change_nick_func(it->first, it->second.get());
+ change_nick_func(pair.first, pair.second.get());
}
}
diff --git a/src/irc/irc_client.hpp b/src/irc/irc_client.hpp
index 8119201..7593029 100644
--- a/src/irc/irc_client.hpp
+++ b/src/irc/irc_client.hpp
@@ -26,9 +26,9 @@ class Bridge;
class IrcClient: public TCPClientSocketHandler
{
public:
- explicit IrcClient(std::shared_ptr<Poller>& poller, const std::string& hostname,
- const std::string& nickname, const std::string& username,
- const std::string& realname, const std::string& user_hostname,
+ explicit IrcClient(std::shared_ptr<Poller>& poller, std::string hostname,
+ std::string nickname, std::string username,
+ std::string realname, std::string user_hostname,
Bridge& bridge);
~IrcClient();