libkdegames/kggznet
kggzraw.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KGGZRAW_H
00022 #define KGGZRAW_H
00023
00024 #include <QtCore/QObject>
00025
00026 #include "kggznet_export.h"
00027
00044 class QAbstractSocket;
00045 class QDataStream;
00046
00075 class KGGZNET_EXPORT KGGZRaw : public QObject
00076 {
00077 Q_OBJECT
00078 public:
00085 KGGZRaw();
00086
00092 ~KGGZRaw();
00093
00099 enum Format
00100 {
00101 QtFormat,
00102 EasysockFormat
00103 };
00104
00116 void setNetwork(int fd);
00117
00127 void setFormat(Format format);
00128
00129 KGGZRaw& operator<<(qint32 i);
00130 KGGZRaw& operator<<(qint8 i);
00131 KGGZRaw& operator<<(QString s);
00132
00133 KGGZRaw& operator>>(qint32 &i);
00134 KGGZRaw& operator>>(qint8 &i);
00135 KGGZRaw& operator>>(QString &s);
00136
00137 Q_SIGNALS:
00144 void signalError();
00145
00146 private Q_SLOTS:
00147 void slotSocketError();
00148
00149 private:
00150 bool ensureBytes(int bytes);
00151 int peekedStringBytes();
00152 void errorhandler();
00153
00154 QAbstractSocket *m_socket;
00155 QDataStream *m_net;
00156 Format m_format;
00157 };
00158
00159 #endif
00160