1 /***************************************************************************
2 * Copyright (C) 2005-2020 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
23 #include "common-export.h"
29 class COMMON_EXPORT IrcEncoder
33 * Writes an IRC message
34 * @param tags Map of IRCv3 message tags
35 * @param prefix Prefix/Source of the message (should be empty)
40 static QByteArray writeMessage(const QHash<IrcTagKey, QString>& tags,
41 const QByteArray& prefix,
43 const QList<QByteArray>& params);
46 * Encodes a string as IRCv3 message tag value and appends it to the message
47 * @param msg message buffer to append to
48 * @param value unencoded tag value
50 static void writeTagValue(QByteArray& msg, const QString& value);
52 * Writes IRCv3 message tags to the message buffer
53 * @param msg message buffer to append to
54 * @param tags map of IRCv3 message tags
56 static void writeTags(QByteArray& msg, const QHash<IrcTagKey, QString>& tags);
58 * Writes the prefix/source to the message buffer
59 * @param msg message buffer to append to
60 * @param prefix prefix/source
62 static void writePrefix(QByteArray& msg, const QByteArray& prefix);
64 * Writes the command/verb to the message buffer
65 * @param msg message buffer to append to
66 * @param cmd command/verb
68 static void writeCommand(QByteArray& msg, const QString& cmd);
70 * Writes the command parameters/arguments to the message buffer
71 * @param msg message buffer to append to
72 * @param params parameters/arguments
74 static void writeParams(QByteArray& msg, const QList<QByteArray>& params);