kbufferedio.h
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef KBUFFEREDIO_H
00024 #define KBUFFEREDIO_H
00025 
00026 #include <qcstring.h>
00027 #include <qptrlist.h>
00028 #include "kasyncio.h"
00029 
00030 class KBufferedIOPrivate;
00059 class KBufferedIO: public KAsyncIO
00060 {
00061   Q_OBJECT
00062 
00063 protected:
00064   
00065   KBufferedIO();
00066 
00067 public:
00071   enum closeModes
00072   {
00073     availRead = 0x01,
00074     dirtyWrite = 0x02,
00075     involuntary = 0x10,
00076     delayed = 0x20,
00077     closedNow = 0x40
00078   };
00079 
00084   virtual ~KBufferedIO();
00085 
00094   virtual void closeNow() = 0;
00095 
00117   virtual bool setBufferSize(int rsize, int wsize = -2);
00118 
00123   virtual int bytesAvailable() const;
00124 
00131   virtual int waitForMore(int msec) = 0;
00132 
00137   virtual int bytesToWrite() const;
00138 
00147   virtual bool canReadLine() const;
00148 
00149   
00150   
00151   
00152   
00153   
00154   
00155 
00168   virtual int peekBlock(char *data, uint maxlen) = 0;
00169 
00182   virtual int unreadBlock(const char *data, uint len);
00183 
00184 signals:
00189   void bytesWritten(int nbytes);
00190 
00191   
00192   
00193 
00208   void closed(int state);
00209 
00210 protected:
00215   QPtrList<QByteArray> inBuf;
00216 
00221   QPtrList<QByteArray> outBuf;
00222 
00223   unsigned inBufIndex, outBufIndex;
00224 
00235   virtual unsigned consumeReadBuffer(unsigned nbytes, char *destbuffer, bool discard = true);
00236 
00248   virtual void consumeWriteBuffer(unsigned nbytes);
00249 
00261   virtual unsigned feedReadBuffer(unsigned nbytes, const char *buffer, bool atBeginning = false);
00262 
00271   virtual unsigned feedWriteBuffer(unsigned nbytes, const char *buffer);
00272 
00277   virtual unsigned readBufferSize() const;
00278 
00283   virtual unsigned writeBufferSize() const;
00284 
00285 protected:
00286   virtual void virtual_hook( int id, void* data );
00287 private:
00288   KBufferedIOPrivate *d;
00289 };
00290 
00291 #endif // KBUFFEREDIO_H
 
This file is part of the documentation for kdecore Library Version 3.2.0.