KDECore
kbufferedio.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 KBUFFEREDIO_H
00022 #define KBUFFEREDIO_H
00023
00024 #include <qcstring.h>
00025 #include <qptrlist.h>
00026 #include "kasyncio.h"
00027
00028 class KBufferedIOPrivate;
00056 class KDECORE_EXPORT KBufferedIO: public KAsyncIO
00057 {
00058 Q_OBJECT
00059
00060 protected:
00061
00062 KBufferedIO();
00063
00064 public:
00068 enum closeModes
00069 {
00070 availRead = 0x01,
00071 dirtyWrite = 0x02,
00072 involuntary = 0x10,
00073 delayed = 0x20,
00074 closedNow = 0x40
00075 };
00076
00081 virtual ~KBufferedIO();
00082
00091 virtual void closeNow() = 0;
00092
00114 virtual bool setBufferSize(int rsize, int wsize = -2);
00115
00120 virtual int bytesAvailable() const;
00121
00128 virtual int waitForMore(int msec) = 0;
00129
00134 virtual int bytesToWrite() const;
00135
00144 virtual bool canReadLine() const;
00145
00146
00147
00148
00149
00150
00151
00152
00165 virtual int peekBlock(char *data, uint maxlen) = 0;
00166
00179 virtual int unreadBlock(const char *data, uint len);
00180
00181 signals:
00186 void bytesWritten(int nbytes);
00187
00188
00189
00190
00205 void closed(int state);
00206
00207 protected:
00212 QPtrList<QByteArray> inBuf;
00213
00218 QPtrList<QByteArray> outBuf;
00219
00220 unsigned inBufIndex ,
00221 outBufIndex ;
00222
00233 virtual unsigned consumeReadBuffer(unsigned nbytes, char *destbuffer, bool discard = true);
00234
00246 virtual void consumeWriteBuffer(unsigned nbytes);
00247
00259 virtual unsigned feedReadBuffer(unsigned nbytes, const char *buffer, bool atBeginning = false);
00260
00269 virtual unsigned feedWriteBuffer(unsigned nbytes, const char *buffer);
00270
00275 virtual unsigned readBufferSize() const;
00276
00281 virtual unsigned writeBufferSize() const;
00282
00283 protected:
00284 virtual void virtual_hook( int id, void* data );
00285 private:
00286 KBufferedIOPrivate *d;
00287 };
00288
00289 #endif // KBUFFEREDIO_H