Ok, the long awaited config wizard is here (at least in a very basic state). There...
[quassel.git] / src / contrib / libqxt-2007-10-24 / src / core / qxtstdstreambufdevice.cpp
1 /****************************************************************************
2 **
3 ** Copyright (C) Qxt Foundation. Some rights reserved.
4 **
5 ** This file is part of the QxtCore module of the Qt eXTension library
6 **
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
9 ** IBM.
10 **
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.
15 **
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.
20 **
21 ** <http://libqxt.sourceforge.net>  <foundation@libqxt.org>
22 **
23 ****************************************************************************/
24 #include "qxtstdstreambufdevice.h"
25
26 /**
27 \class QxtStdStreambufDevice QxtStdStreambufDevice
28
29 \ingroup QxtCore
30
31 \brief QIODevice support for std::streambuf
32
33 does NOT include the readyRead() signal
34
35 */
36
37 /**
38 \fn QxtStdStreambufDevice::QxtStdStreambufDevice(std::streambuf * b,QObject * parent)
39
40 creates a QxtStdStreambufDevice using a single stream buffer as in and output
41
42  */
43 QxtStdStreambufDevice::QxtStdStreambufDevice(std::streambuf * b,QObject * parent):QIODevice(parent),buff(b)
44 {
45     setOpenMode (QIODevice::ReadWrite); ///we don't know the real state
46     buff_w=0;
47 }
48 /**
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
51  */
52
53 QxtStdStreambufDevice::QxtStdStreambufDevice(std::streambuf * r,std::streambuf * w,QObject * parent):QIODevice(parent),buff(r),buff_w(w)
54 {
55     setOpenMode (QIODevice::ReadWrite);
56 }
57 bool QxtStdStreambufDevice::isSequential() const
58 {
59     return true;///for now
60 }
61
62 qint64 QxtStdStreambufDevice::bytesAvailable () const
63 {
64     return buff->in_avail();
65 }
66 qint64 QxtStdStreambufDevice::readData ( char * data, qint64 maxSize )
67 {
68     return buff->sgetn(data,maxSize);
69 }
70
71 qint64 QxtStdStreambufDevice::writeData ( const char * data, qint64 maxSize )
72 {
73     if (buff_w)
74         return buff_w->sputn(data,maxSize);
75     return buff->sputn(data,maxSize);
76 }