kbufferedio.h
/*
* This file is part of the KDE libraries
* Copyright (C) 2001 Thiago Macieira <thiago.macieira@kdemail.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KBUFFEREDIO_H
#define KBUFFEREDIO_H
#include <qcstring.h>
#include <qptrlist.h>
#include "kasyncio.h"
class KBufferedIOPrivate;
class KDECORE_EXPORT KBufferedIO: public KAsyncIO
{
Q_OBJECT
protected:
// no default public constructor
KBufferedIO();
public:
enum closeModes
{
availRead = 0x01,
dirtyWrite = 0x02,
involuntary = 0x10,
delayed = 0x20,
closedNow = 0x40
};
virtual ~KBufferedIO();
virtual void closeNow() = 0;
virtual bool setBufferSize(int rsize, int wsize = -2);
virtual int bytesAvailable() const;
virtual int waitForMore(int msec) = 0;
virtual int bytesToWrite() const;
virtual bool canReadLine() const;
// readBlock, peekBlock and writeBlock are not defined in this class (thus, left
// pure virtual) because this does not mean only reading and writing
// to the buffers. It may be necessary to do I/O to complete the
// transaction (e.g., user wants to read more than is in the buffer).
// Reading and writing to the buffer are available for access through
// protected member functions
virtual int peekBlock(char *data, uint maxlen) = 0;
virtual int unreadBlock(const char *data, uint len);
signals:
void bytesWritten(int nbytes);
// There is no read signal here. We use the readyRead signal inherited
// from KAsyncIO for that purpose
void closed(int state);
protected:
QPtrList<QByteArray> inBuf;
QPtrList<QByteArray> outBuf;
unsigned inBufIndex ,
outBufIndex ;
virtual unsigned consumeReadBuffer(unsigned nbytes, char *destbuffer, bool discard = true);
virtual void consumeWriteBuffer(unsigned nbytes);
virtual unsigned feedReadBuffer(unsigned nbytes, const char *buffer, bool atBeginning = false);
virtual unsigned feedWriteBuffer(unsigned nbytes, const char *buffer);
virtual unsigned readBufferSize() const;
virtual unsigned writeBufferSize() const;
protected:
virtual void virtual_hook( int id, void* data );
private:
KBufferedIOPrivate *d;
};
#endif // KBUFFEREDIO_H
KBufferedIO::closeModes
closeModes
The modes for closed() signal.
Definition: kbufferedio.h:68
KBufferedIO
This abstract class implements basic functionality for buffered input/output.
Definition: kbufferedio.h:56
KBufferedIO::outBuf
QPtrList< QByteArray > outBuf
For an explanation on how this buffer work, please refer to the comments at the top of kbufferedio...
Definition: kbufferedio.h:218
KAsyncIO
Asynchronous I/O Support.
Definition: kasyncio.h:38
KBufferedIO::inBuf
QPtrList< QByteArray > inBuf
For an explanation on how this buffer work, please refer to the comments at the top of kbufferedio...
Definition: kbufferedio.h:212

KDE Home | KDE Accessibility Home | Description of Access Keys