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 <tqcstring.h>
00025 #include <tqptrlist.h>
00026 #include "kasyncio.h"
00027
00028 class TDEBufferedIOPrivate;
00056 class TDECORE_EXPORT TDEBufferedIO: public KAsyncIO
00057 {
00058 Q_OBJECT
00059
00060
00061 protected:
00062
00063 TDEBufferedIO();
00064
00065 public:
00069 enum closeModes
00070 {
00071 availRead = 0x01,
00072 dirtyWrite = 0x02,
00073 involuntary = 0x10,
00074 delayed = 0x20,
00075 closedNow = 0x40
00076 };
00077
00082 virtual ~TDEBufferedIO();
00083
00092 virtual void closeNow() = 0;
00093
00115 virtual bool setBufferSize(int rsize, int wsize = -2);
00116
00121 #ifdef USE_QT3
00122 virtual int bytesAvailable() const;
00123 #endif // USE_QT3
00124 #ifdef USE_QT4
00125 virtual qint64 bytesAvailable() const;
00126 #endif // USE_QT4
00127
00134 virtual int waitForMore(int msec) = 0;
00135
00140 #ifdef USE_QT3
00141 virtual int bytesToWrite() const;
00142 #endif // USE_QT3
00143 #ifdef USE_QT4
00144 virtual qint64 bytesToWrite() const;
00145 #endif // USE_QT4
00146
00155 virtual bool canReadLine() const;
00156
00157
00158
00159
00160
00161
00162
00163
00176 virtual int peekBlock(char *data, uint maxlen) = 0;
00177
00190 virtual int unreadBlock(const char *data, uint len);
00191
00192 signals:
00197 void bytesWritten(int nbytes);
00198
00199
00200
00201
00216 void closed(int state);
00217
00218 protected:
00223 TQPtrList<TQByteArray> inBuf;
00224
00229 TQPtrList<TQByteArray> outBuf;
00230
00231 unsigned inBufIndex ,
00232 outBufIndex ;
00233
00244 virtual unsigned consumeReadBuffer(unsigned nbytes, char *destbuffer, bool discard = true);
00245
00257 virtual void consumeWriteBuffer(unsigned nbytes);
00258
00270 virtual unsigned feedReadBuffer(unsigned nbytes, const char *buffer, bool atBeginning = false);
00271
00280 virtual unsigned feedWriteBuffer(unsigned nbytes, const char *buffer);
00281
00286 virtual unsigned readBufferSize() const;
00287
00292 virtual unsigned writeBufferSize() const;
00293
00294 protected:
00295 virtual void virtual_hook( int id, void* data );
00296 private:
00297 TDEBufferedIOPrivate *d;
00298 };
00299
00300 #endif // KBUFFEREDIO_H