summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-04-29 21:50:13 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-04-29 21:50:13 +0200
commitf6e6b8905be010d7329316cea4546900ad8a2d19 (patch)
treec27ff5b83d11c5631742ffc945e3f887fbca0f54 /src
parent594bac1e841588aef66efc208a295e08273aec32 (diff)
downloadbiboumi-f6e6b8905be010d7329316cea4546900ad8a2d19.tar.gz
biboumi-f6e6b8905be010d7329316cea4546900ad8a2d19.tar.bz2
biboumi-f6e6b8905be010d7329316cea4546900ad8a2d19.tar.xz
biboumi-f6e6b8905be010d7329316cea4546900ad8a2d19.zip
Use C++14 string_literals
Diffstat (limited to 'src')
-rw-r--r--src/bridge/bridge.cpp8
-rw-r--r--src/bridge/colors.cpp6
-rw-r--r--src/irc/irc_client.cpp19
-rw-r--r--src/network/socket_handler.cpp4
4 files changed, 22 insertions, 15 deletions
diff --git a/src/bridge/bridge.cpp b/src/bridge/bridge.cpp
index 12a56d7..4b2d895 100644
--- a/src/bridge/bridge.cpp
+++ b/src/bridge/bridge.cpp
@@ -10,6 +10,8 @@
#include <iostream>
#include <tuple>
+using namespace std::string_literals;
+
static const char* action_prefix = "\01ACTION ";
Bridge::Bridge(const std::string& user_jid, XmppComponent* xmpp, Poller* poller):
@@ -243,9 +245,9 @@ void Bridge::send_xmpp_message(const std::string& from, const std::string& autho
if (!author.empty())
{
IrcUser user(author);
- body = std::string("\u000303") + user.nick + (user.host.empty()?
- std::string("\u0003: "):
- (" (\u000310" + user.host + std::string("\u000303)\u0003: "))) + msg;
+ body = "\u000303"s + user.nick + (user.host.empty()?
+ "\u0003: ":
+ (" (\u000310" + user.host + "\u000303)\u0003: ")) + msg;
}
else
body = msg;
diff --git a/src/bridge/colors.cpp b/src/bridge/colors.cpp
index 49f7a39..6f6d7a9 100644
--- a/src/bridge/colors.cpp
+++ b/src/bridge/colors.cpp
@@ -6,6 +6,8 @@
#include <string.h>
+using namespace std::string_literals;
+
static const char IRC_NUM_COLORS = 16;
static const char* irc_colors_to_css[IRC_NUM_COLORS] = {
@@ -130,10 +132,10 @@ Xmpp::body irc_format_to_xhtmlim(const std::string& s)
if (styles.italic)
styles_str += "font-style:italic;";
if (styles.fg != -1)
- styles_str += std::string("color:") +
+ styles_str += "color:"s +
irc_colors_to_css[styles.fg % IRC_NUM_COLORS] + ";";
if (styles.bg != -1)
- styles_str += std::string("background-color:") +
+ styles_str += "background-color:"s +
irc_colors_to_css[styles.bg % IRC_NUM_COLORS] + ";";
if (!styles_str.empty())
{
diff --git a/src/irc/irc_client.cpp b/src/irc/irc_client.cpp
index e70dbe4..da5a947 100644
--- a/src/irc/irc_client.cpp
+++ b/src/irc/irc_client.cpp
@@ -10,6 +10,9 @@
#include <iostream>
#include <stdexcept>
+#include <string>
+using namespace std::string_literals;
+
IrcClient::IrcClient(const std::string& hostname, const std::string& username, Bridge* bridge):
hostname(hostname),
username(username),
@@ -36,7 +39,7 @@ void IrcClient::start()
{
if (this->connected || this->connecting)
return ;
- this->bridge->send_xmpp_message(this->hostname, "", std::string("Connecting to ") +
+ this->bridge->send_xmpp_message(this->hostname, "", "Connecting to "s +
this->hostname + ":" + "6667");
this->connect(this->hostname, "6667");
}
@@ -44,7 +47,7 @@ void IrcClient::start()
void IrcClient::on_connection_failed(const std::string& reason)
{
this->bridge->send_xmpp_message(this->hostname, "",
- std::string("Connection failed: ") + reason);
+ "Connection failed: "s + reason);
}
void IrcClient::on_connected()
@@ -244,7 +247,7 @@ void IrcClient::on_notice(const IrcMessage& message)
this->bridge->send_xmpp_message(this->hostname, from, body);
else
{
- IrcMessage modified_message(std::move(from), "PRIVMSG", {to, std::string("\u000303[notice]\u0003 ") + body});
+ IrcMessage modified_message(std::move(from), "PRIVMSG", {to, "\u000303[notice]\u0003 "s + body});
this->on_channel_message(modified_message);
}
}
@@ -344,7 +347,7 @@ void IrcClient::on_channel_message(const IrcMessage& message)
{
if (body.substr(1, 6) == "ACTION")
this->bridge->send_message(iid, nick,
- std::string("/me") + body.substr(7, body.size() - 8), muc);
+ "/me"s + body.substr(7, body.size() - 8), muc);
}
else
this->bridge->send_message(iid, nick, body, muc);
@@ -486,7 +489,7 @@ void IrcClient::on_error(const IrcMessage& message)
this->bridge->send_muc_leave(std::move(iid), std::move(own_nick), leave_message, true);
}
this->channels.clear();
- this->send_gateway_message(std::string("ERROR: ") + leave_message);
+ this->send_gateway_message("ERROR: "s + leave_message);
}
void IrcClient::on_quit(const IrcMessage& message)
@@ -583,7 +586,7 @@ void IrcClient::on_channel_mode(const IrcMessage& message)
mode_arguments += message.arguments[i];
}
}
- this->bridge->send_message(iid, "", std::string("Mode ") + iid.chan +
+ this->bridge->send_message(iid, "", "Mode "s + iid.chan +
" [" + mode_arguments + "] by " + user.nick,
true);
const IrcChannel* channel = this->get_channel(iid.chan);
@@ -661,7 +664,7 @@ void IrcClient::on_channel_mode(const IrcMessage& message)
void IrcClient::on_user_mode(const IrcMessage& message)
{
this->bridge->send_xmpp_message(this->hostname, "",
- std::string("User mode for ") + message.arguments[0] +
+ "User mode for "s + message.arguments[0] +
" is [" + message.arguments[1] + "]");
}
@@ -685,5 +688,5 @@ void IrcClient::leave_dummy_channel(const std::string& exit_message)
this->dummy_channel.joined = false;
this->dummy_channel.joining = false;
this->dummy_channel.remove_all_users();
- this->bridge->send_muc_leave(Iid(std::string("%") + this->hostname), std::string(this->current_nick), exit_message, true);
+ this->bridge->send_muc_leave(Iid("%"s + this->hostname), std::string(this->current_nick), exit_message, true);
}
diff --git a/src/network/socket_handler.cpp b/src/network/socket_handler.cpp
index 546b1b4..f1b70be 100644
--- a/src/network/socket_handler.cpp
+++ b/src/network/socket_handler.cpp
@@ -42,7 +42,7 @@ void SocketHandler::init_socket()
const int existing_flags = ::fcntl(this->socket, F_GETFL, 0);
if ((existing_flags == -1) ||
(::fcntl(this->socket, F_SETFL, existing_flags | O_NONBLOCK) == -1))
- throw std::runtime_error(std::string("Could not initialize socket: ") + strerror(errno));
+ throw std::runtime_error("Could not initialize socket: "s + strerror(errno));
}
void SocketHandler::connect(const std::string& address, const std::string& port)
@@ -70,7 +70,7 @@ void SocketHandler::connect(const std::string& address, const std::string& port)
if (res != 0)
{
- log_warning(std::string("getaddrinfo failed: ") + gai_strerror(res));
+ log_warning("getaddrinfo failed: "s + gai_strerror(res));
this->close();
this->on_connection_failed(gai_strerror(res));
return ;