| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kbufferedio.h

    00001 /*
    00002  *  This file is part of the KDE libraries
    00003  *  Copyright (C) 2001 Thiago Macieira <thiagom@mail.com>
    00004  *
    00005  *  $Id: kbufferedio.h,v 1.10 2002/09/08 15:15:33 tjansen Exp $
    00006  *
    00007  *  This library is free software; you can redistribute it and/or
    00008  *  modify it under the terms of the GNU Library General Public
    00009  *  License as published by the Free Software Foundation; either
    00010  *  version 2 of the License, or (at your option) any later version.
    00011  *
    00012  *  This library is distributed in the hope that it will be useful,
    00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015  *  Library General Public License for more details.
    00016  *
    00017  *  You should have received a copy of the GNU Library General Public License
    00018  *  along with this library; see the file COPYING.LIB.  If not, write to
    00019  *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00020  *  Boston, MA 02111-1307, USA.
    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   // no default public constructor
    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   // readBlock, peekBlock and writeBlock are not defined in this class (thus, left
    00150   // pure virtual) because this does not mean only reading and writing
    00151   // to the buffers. It may be necessary to do I/O to complete the
    00152   // transaction (e.g., user wants to read more than is in the buffer).
    00153   // Reading and writing to the buffer are available for access through
    00154   // protected member functions
    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   // There is no read signal here. We use the readyRead signal inherited
    00192   // from KAsyncIO for that purpose
    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 kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:46:20 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001