2
* bytestream.h - base class for bytestreams
3
* Copyright (C) 2003 Justin Karneges
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#ifndef CS_BYTESTREAM_H
22
#define CS_BYTESTREAM_H
30
class ByteStream : public QObject
34
enum Error { ErrRead, ErrWrite, ErrCustom = 10 };
35
ByteStream(QObject *parent=0);
36
virtual ~ByteStream()=0;
38
virtual bool isOpen() const;
40
virtual void write(const QByteArray &);
41
virtual QByteArray read(int bytes=0);
42
virtual int bytesAvailable() const;
43
virtual int bytesToWrite() const;
45
void write(const QCString &);
47
static void appendArray(QByteArray *a, const QByteArray &b);
48
static QByteArray takeArray(QByteArray *from, int size=0, bool del=true);
51
void connectionClosed();
52
void delayedCloseFinished();
54
void bytesWritten(int);
58
void clearReadBuffer();
59
void clearWriteBuffer();
60
void appendRead(const QByteArray &);
61
void appendWrite(const QByteArray &);
62
QByteArray takeRead(int size=0, bool del=true);
63
QByteArray takeWrite(int size=0, bool del=true);
64
QByteArray & readBuf();
65
QByteArray & writeBuf();
66
virtual int tryWrite();