Warning, file /rolisteam/rolisteam/src/libraries/core/include/network/networkmessagewriter.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*************************************************************************
0002  *     Copyright (C) 2011 by Joseph Boudou                               *
0003  *     https://rolisteam.org/                                         *
0004  *                                                                       *
0005  *   rolisteam is free software; you can redistribute it and/or modify   *
0006  *   it under the terms of the GNU General Public License as published   *
0007  *   by the Free Software Foundation; either version 2 of the License,   *
0008  *   or (at your option) any later version.                              *
0009  *                                                                       *
0010  *   This program is distributed in the hope that it will be useful,     *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of      *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
0013  *   GNU General Public License for more details.                        *
0014  *                                                                       *
0015  *   You should have received a copy of the GNU General Public License   *
0016  *   along with this program; if not, write to the                       *
0017  *   Free Software Foundation, Inc.,                                     *
0018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.           *
0019  *************************************************************************/
0020 
0021 #ifndef NETWORK_MESSAGE_WRITER_H
0022 #define NETWORK_MESSAGE_WRITER_H
0023 
0024 #include "networkmessage.h"
0025 
0026 #include <QDateTime>
0027 #include <QString>
0028 
0029 #include "network_global.h"
0030 
0031 #ifdef QT_GUI_LIB
0032 #include <QPixmap>
0033 #endif
0034 
0035 /**
0036  * @brief The NetworkMessageWriter class
0037  */
0038 class NETWORK_EXPORT NetworkMessageWriter : public NetworkMessage
0039 {
0040 public:
0041     NetworkMessageWriter(NetMsg::Category categorie, NetMsg::Action action,
0042                          NetworkMessage::RecipientMode mode= NetworkMessage::All, int size= 128);
0043     virtual ~NetworkMessageWriter() override;
0044 
0045     NetMsg::Category category() const override;
0046     NetMsg::Action action() const override;
0047 
0048     void reset();
0049 
0050     void uint8(quint8 data);
0051     void uint16(quint16 data);
0052     void uint32(quint32 data);
0053     void uint64(quint64 data);
0054 
0055     void string8(const QString& data);
0056     void string16(const QString& data);
0057     void string32(const QString& data);
0058 
0059     void dateTime(const QDateTime& time);
0060 
0061     void byteArray32(const QByteArray& data);
0062     size_t currentPos() const;
0063 
0064 #ifdef QT_GUI_LIB
0065     bool pixmap(const QPixmap& pix);
0066 #endif
0067     void rgb(unsigned int color);
0068 
0069     quint32 getDataSize() const;
0070     quint32 bufferSize() const;
0071 
0072     void int8(qint8 data);
0073     void int16(qint16 data);
0074     void int32(qint32 data);
0075     void int64(qint64 data);
0076 
0077     void real(qreal data);
0078 
0079     /**
0080      * @brief getRecipientList
0081      * @return
0082      */
0083     void setRecipientList(QStringList, NetworkMessage::RecipientMode mode);
0084     virtual QStringList getRecipientList() const override;
0085     NetworkMessage::RecipientMode getRecipientMode() const override;
0086     QByteArray data() const;
0087 
0088     NetworkMessageHeader* buffer() const override;
0089 
0090 private:
0091     NetworkMessageHeader* m_header;
0092     char* m_buffer;
0093     char* m_begin;
0094     char* m_currentPos;
0095     char* m_end;
0096 
0097     void string(const QString& data, int sizeQChar);
0098     void makeRoom(int size);
0099     long long int m_sizeBuffer;
0100     long long int m_sizeData;
0101     QStringList m_recipientList;
0102     NetworkMessage::RecipientMode m_mode;
0103 };
0104 
0105 #endif