X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcommon%2Firctag.cpp;fp=src%2Fcommon%2Firctag.cpp;h=2c9c221c42fc57ea4d012939a5d09fea423082f2;hp=0000000000000000000000000000000000000000;hb=53e50ab66a5b3fa00282545ebc22ce3433ecf42b;hpb=01d67be28f1eb983a1bd0b97f13160ffb6b39307 diff --git a/src/common/irctag.cpp b/src/common/irctag.cpp new file mode 100644 index 00000000..2c9c221c --- /dev/null +++ b/src/common/irctag.cpp @@ -0,0 +1,56 @@ +/*************************************************************************** + * Copyright (C) 2005-2019 by the Quassel Project * + * devel@quassel-irc.org * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) version 3. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * + ***************************************************************************/ + +#include "irctag.h" + +uint qHash(const IrcTagKey& key) +{ + QString clientTag; + if (key.clientTag) { + clientTag = "+"; + } + return qHash(QString(clientTag + key.vendor + "/" + key.key)); +} + +bool operator==(const IrcTagKey& a, const IrcTagKey& b) +{ + return a.vendor == b.vendor && a.key == b.key && a.clientTag == b.clientTag; +} + +bool operator<(const IrcTagKey& a, const IrcTagKey& b) +{ + return a.vendor < b.vendor || a.key < b.key || a.clientTag < b.clientTag; +} + +QDebug operator<<(QDebug dbg, const IrcTagKey& i) { + return dbg << QString(("(clientTag = %1, vendor = %2,key = %3")).arg(i.clientTag).arg(i.vendor).arg(i.key); +} + +std::ostream& operator<<(std::ostream& o, const IrcTagKey& i) { + std::string result; + if (i.clientTag) + result += "+"; + if (!i.vendor.isEmpty()) { + result += i.vendor.toStdString(); + result += "/"; + } + result += i.key.toStdString(); + return o << result; +}