• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDECore

kbufferedio.h

Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor,
00018  *  Boston, MA 02110-1301, 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 , 
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

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal