summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2018-07-26 21:23:45 +0100
committerPeter Powell <petpow@saberuk.com>2018-07-26 21:41:36 +0100
commit9cf448a332799a138dad0acb5b2878535770571d (patch)
tree4d922164f102e1dbf98aa3261e77da305664f532 /src
parent384ef31bc01e4a1a2e59d082c9066002410ba54a (diff)
Replace irc::stringjoiner with a generic stdalgo::string::join.
This can also be used with different types of collection containing values which are not a string.
Diffstat (limited to 'src')
-rw-r--r--src/hashcomp.cpp12
-rw-r--r--src/inspstring.cpp8
-rw-r--r--src/modules/m_operlog.cpp2
-rw-r--r--src/modules/m_samode.cpp2
-rw-r--r--src/modules/m_spanningtree/capab.cpp2
5 files changed, 5 insertions, 21 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 08ce154e8..2288a227e 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -279,18 +279,6 @@ bool irc::sepstream::StreamEnd()
return this->pos > this->tokens.length();
}
-std::string irc::stringjoiner(const std::vector<std::string>& sequence, char separator)
-{
- std::string joined;
- if (sequence.empty())
- return joined; // nothing to do here
-
- for (std::vector<std::string>::const_iterator i = sequence.begin(); i != sequence.end(); ++i)
- joined.append(*i).push_back(separator);
- joined.erase(joined.end()-1);
- return joined;
-}
-
irc::portparser::portparser(const std::string &source, bool allow_overlapped)
: sep(source), in_range(0), range_begin(0), range_end(0), overlapped(allow_overlapped)
{
diff --git a/src/inspstring.cpp b/src/inspstring.cpp
index 283c00d5b..79aef52bd 100644
--- a/src/inspstring.cpp
+++ b/src/inspstring.cpp
@@ -206,12 +206,8 @@ void TokenList::Remove(const std::string& token)
std::string TokenList::ToString() const
{
- std::string buffer(permissive ? "*" : "-*");
- for (insp::flat_set<std::string>::const_iterator iter = tokens.begin(); iter != tokens.end(); ++iter)
- {
- buffer.push_back(' ');
- buffer.append(*iter);
- }
+ std::string buffer(permissive ? "* " : "-* ");
+ buffer.append(stdalgo::string::join(tokens));
return buffer;
}
diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp
index 49d816fa9..53bc247be 100644
--- a/src/modules/m_operlog.cpp
+++ b/src/modules/m_operlog.cpp
@@ -52,7 +52,7 @@ class ModuleOperLog : public Module
Command* thiscommand = ServerInstance->Parser.GetHandler(command);
if ((thiscommand) && (thiscommand->flags_needed == 'o'))
{
- std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + irc::stringjoiner(parameters);
+ std::string msg = "[" + user->GetFullRealHost() + "] " + command + " " + stdalgo::string::join(parameters);
ServerInstance->Logs->Log(MODNAME, LOG_DEFAULT, "OPERLOG: " + msg);
if (tosnomask)
ServerInstance->SNO->WriteGlobalSno('r', msg);
diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp
index e4b102b92..195b767ab 100644
--- a/src/modules/m_samode.cpp
+++ b/src/modules/m_samode.cpp
@@ -68,7 +68,7 @@ class CommandSamode : public Command
// Viewing the modes of a user or a channel can also result in CMD_SUCCESS, but
// that is not possible with /SAMODE because we require at least 2 parameters.
const std::string& lastparse = ServerInstance->Modes.GetLastParse();
- ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SAMODE: " + (lastparse.empty() ? irc::stringjoiner(parameters) : lastparse));
+ ServerInstance->SNO->WriteGlobalSno('a', user->nick + " used SAMODE: " + (lastparse.empty() ? stdalgo::string::join(parameters) : lastparse));
}
return CMD_SUCCESS;
diff --git a/src/modules/m_spanningtree/capab.cpp b/src/modules/m_spanningtree/capab.cpp
index 79019b668..97b4a90af 100644
--- a/src/modules/m_spanningtree/capab.cpp
+++ b/src/modules/m_spanningtree/capab.cpp
@@ -98,7 +98,7 @@ static std::string BuildModeList(ModeType type)
modes.push_back(mdesc);
}
std::sort(modes.begin(), modes.end());
- return irc::stringjoiner(modes);
+ return stdalgo::string::join(modes);
}
void TreeSocket::SendCapabilities(int phase)