cmake: avoid de-duplication of user's CXXFLAGS
[quassel.git] / src / common / ircencoder.h
1 /***************************************************************************
2  *   Copyright (C) 2005-2019 by the Quassel Project                        *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
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.                                           *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #pragma once
22
23 #include "common-export.h"
24
25 #include <QByteArray>
26
27 #include "irctag.h"
28
29 class COMMON_EXPORT IrcEncoder
30 {
31 public:
32     /**
33      * Writes an IRC message
34      * @param tags Map of IRCv3 message tags
35      * @param prefix Prefix/Source of the message (should be empty)
36      * @param cmd
37      * @param params
38      * @return
39      */
40     static QByteArray writeMessage(const QHash<IrcTagKey, QString>& tags,
41                                    const QByteArray& prefix,
42                                    const QString& cmd,
43                                    const QList<QByteArray>& params);
44 private:
45     /**
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
49      */
50     static void writeTagValue(QByteArray& msg, const QString& value);
51     /**
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
55      */
56     static void writeTags(QByteArray& msg, const QHash<IrcTagKey, QString>& tags);
57     /**
58      * Writes the prefix/source to the message buffer
59      * @param msg message buffer to append to
60      * @param prefix prefix/source
61      */
62     static void writePrefix(QByteArray& msg, const QByteArray& prefix);
63     /**
64      * Writes the command/verb to the message buffer
65      * @param msg message buffer to append to
66      * @param cmd command/verb
67      */
68     static void writeCommand(QByteArray& msg, const QString& cmd);
69     /**
70      * Writes the command parameters/arguments to the message buffer
71      * @param msg message buffer to append to
72      * @param params parameters/arguments
73      */
74     static void writeParams(QByteArray& msg, const QList<QByteArray>& params);
75 };