1 /****************************************************************************
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
5 ** This file is part of the QxtCore module of the Qt eXTension library
7 ** This library is free software; you can redistribute it and/or modify it
8 ** under the terms of th Common Public License, version 1.0, as published by
11 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY
12 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
13 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR
14 ** FITNESS FOR A PARTICULAR PURPOSE.
16 ** You should have received a copy of the CPL along with this file.
17 ** See the LICENSE file and the cpl1.0.txt file included with the source
18 ** distribution for more information. If you did not receive a copy of the
19 ** license, contact the Qxt Foundation.
21 ** <http://libqxt.sourceforge.net> <foundation@libqxt.org>
23 ****************************************************************************/
24 #include "qxtstdstreambufdevice.h"
27 \class QxtStdStreambufDevice QxtStdStreambufDevice
31 \brief QIODevice support for std::streambuf
33 does NOT include the readyRead() signal
38 \fn QxtStdStreambufDevice::QxtStdStreambufDevice(std::streambuf * b,QObject * parent)
40 creates a QxtStdStreambufDevice using a single stream buffer as in and output
43 QxtStdStreambufDevice::QxtStdStreambufDevice(std::streambuf * b,QObject * parent):QIODevice(parent),buff(b)
45 setOpenMode (QIODevice::ReadWrite); ///we don't know the real state
49 \fn QxtStdStreambufDevice::QxtStdStreambufDevice(std::streambuf * r,std::streambuf * w,QObject * parent)
50 creates a QxtStdStreambufDevice using \p r to read and \p w to write
53 QxtStdStreambufDevice::QxtStdStreambufDevice(std::streambuf * r,std::streambuf * w,QObject * parent):QIODevice(parent),buff(r),buff_w(w)
55 setOpenMode (QIODevice::ReadWrite);
57 bool QxtStdStreambufDevice::isSequential() const
59 return true;///for now
62 qint64 QxtStdStreambufDevice::bytesAvailable () const
64 return buff->in_avail();
66 qint64 QxtStdStreambufDevice::readData ( char * data, qint64 maxSize )
68 return buff->sgetn(data,maxSize);
71 qint64 QxtStdStreambufDevice::writeData ( const char * data, qint64 maxSize )
74 return buff_w->sputn(data,maxSize);
75 return buff->sputn(data,maxSize);