# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kbufferedio.h

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (C) 2001 Thiago Macieira <thiago.macieira@kdemail.net>
    00004  *
    00005  *  This library is free software; you can redistribute it and/or
    00006  *  modify it under the terms of the GNU Library General Public
    00007  *  License as published by the Free Software Foundation; either
    00008  *  version 2 of the License, or (at your option) any later version.
    00009  *
    00010  *  This library is distributed in the hope that it will be useful,
    00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  *  Library General Public License for more details.
    00014  *
    00015  *  You should have received a copy of the GNU Library General Public License
    00016  *  along with this library; see the file COPYING.LIB.  If not, write to
    00017  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00018  *  Boston, MA 02111-1307, USA.
    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   // no default public constructor
    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   // readBlock, peekBlock and writeBlock are not defined in this class (thus, left
    00147   // pure virtual) because this does not mean only reading and writing
    00148   // to the buffers. It may be necessary to do I/O to complete the
    00149   // transaction (e.g., user wants to read more than is in the buffer).
    00150   // Reading and writing to the buffer are available for access through
    00151   // protected member functions
    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   // There is no read signal here. We use the readyRead signal inherited
    00189   // from KAsyncIO for that purpose
    00190
    00205   void closed(int state);
    00206
    00207 protected:
    00212   QPtrList<QByteArray> inBuf;
    00213
    00218   QPtrList<QByteArray> outBuf;
    00219
    00220   unsigned inBufIndex, outBufIndex;
    00221
    00232   virtual unsigned consumeReadBuffer(unsigned nbytes, char *destbuffer, bool discard = true);
    00233
    00245   virtual void consumeWriteBuffer(unsigned nbytes);
    00246
    00258   virtual unsigned feedReadBuffer(unsigned nbytes, const char *buffer, bool atBeginning = false);
    00259
    00268   virtual unsigned feedWriteBuffer(unsigned nbytes, const char *buffer);
    00269
    00274   virtual unsigned readBufferSize() const;
    00275
    00280   virtual unsigned writeBufferSize() const;
    00281
    00282 protected:
    00283   virtual void virtual_hook( int id, void* data );
    00284 private:
    00285   KBufferedIOPrivate *d;
    00286 };
    00287
    00288 #endif // KBUFFEREDIO_H

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:01 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003