summaryrefslogtreecommitdiff
path: root/src/command_parse.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/command_parse.cpp')
-rw-r--r--src/command_parse.cpp83
1 files changed, 43 insertions, 40 deletions
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 7c18c8ab1..d0b114816 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -609,32 +609,24 @@ void CommandParser::SetupCommandTable()
this->CreateCommand(new CommandReload(ServerInstance));
}
-int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest)
+int CommandParser::TranslateUIDs(const std::vector<TranslateType> to, const std::string &source, std::string &dest)
{
+ irc::spacesepstream items(source);
+ std::vector<TranslateType>::const_iterator types = to.begin();
User* user = NULL;
std::string item;
int translations = 0;
dest.clear();
- switch (to)
+ while (items.GetToken(item))
{
- case TR_NICK:
- /* Translate single nickname */
- user = ServerInstance->FindNick(source);
- if (user)
- {
- dest = user->uuid;
- translations++;
- }
- else
- dest = source;
- break;
- case TR_NICKLIST:
+ TranslateType t = *types;
+ types++;
+
+ switch (t)
{
- /* Translate comma seperated list of nicknames */
- irc::commasepstream items(source);
- while (items.GetToken(item))
- {
+ case TR_NICK:
+ /* Translate single nickname */
user = ServerInstance->FindNick(item);
if (user)
{
@@ -643,31 +635,42 @@ int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, st
}
else
dest.append(item);
- dest.append(",");
- }
- if (!dest.empty())
- dest.erase(dest.end() - 1);
+ break;
+ break;
+ case TR_END:
+ case TR_TEXT:
+ default:
+ /* Do nothing */
+ dest.append(item);
+ break;
}
- break;
- case TR_SPACENICKLIST:
- {
- /* Translate space seperated list of nicknames */
- irc::spacesepstream items(source);
- while (items.GetToken(item))
+ dest.append(" ");
+ }
+
+ if (!dest.empty())
+ dest.erase(dest.end() - 1);
+ return translations;
+}
+
+int CommandParser::TranslateUIDs(TranslateType to, const std::string &source, std::string &dest)
+{
+ User* user = NULL;
+ std::string item;
+ int translations = 0;
+ dest.clear();
+
+ switch (to)
+ {
+ case TR_NICK:
+ /* Translate single nickname */
+ user = ServerInstance->FindNick(source);
+ if (user)
{
- user = ServerInstance->FindNick(item);
- if (user)
- {
- dest.append(user->uuid);
- translations++;
- }
- else
- dest.append(item);
- dest.append(" ");
+ dest = user->uuid;
+ translations++;
}
- if (!dest.empty())
- dest.erase(dest.end() - 1);
- }
+ else
+ dest = source;
break;
case TR_END:
case TR_TEXT: