00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. 00004 ** 00005 ** This file is part of the Qt3Support module of the Qt Toolkit. 00006 ** 00007 ** This file may be used under the terms of the GNU General Public 00008 ** License versions 2.0 or 3.0 as published by the Free Software 00009 ** Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3 00010 ** included in the packaging of this file. Alternatively you may (at 00011 ** your option) use any later version of the GNU General Public 00012 ** License if such license has been publicly approved by Trolltech ASA 00013 ** (or its successors, if any) and the KDE Free Qt Foundation. In 00014 ** addition, as a special exception, Trolltech gives you certain 00015 ** additional rights. These rights are described in the Trolltech GPL 00016 ** Exception version 1.2, which can be found at 00017 ** http://www.trolltech.com/products/qt/gplexception/ and in the file 00018 ** GPL_EXCEPTION.txt in this package. 00019 ** 00020 ** Please review the following information to ensure GNU General 00021 ** Public Licensing requirements will be met: 00022 ** http://trolltech.com/products/qt/licenses/licensing/opensource/. If 00023 ** you are unsure which license is appropriate for your use, please 00024 ** review the following information: 00025 ** http://trolltech.com/products/qt/licenses/licensing/licensingoverview 00026 ** or contact the sales department at sales@trolltech.com. 00027 ** 00028 ** In addition, as a special exception, Trolltech, as the sole 00029 ** copyright holder for Qt Designer, grants users of the Qt/Eclipse 00030 ** Integration plug-in the right for the Qt/Eclipse Integration to 00031 ** link to functionality provided by Qt Designer and its related 00032 ** libraries. 00033 ** 00034 ** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, 00035 ** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR 00036 ** A PARTICULAR PURPOSE. Trolltech reserves all rights not expressly 00037 ** granted herein. 00038 ** 00039 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00040 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00041 ** 00042 ****************************************************************************/ 00043 00044 #ifndef MMEMBUF_P_H 00045 #define MMEMBUF_P_H 00046 00047 // 00048 // W A R N I N G 00049 // ------------- 00050 // 00051 // This file is not part of the Qt API. It exists for the convenience 00052 // of a number of Qt sources files. This header file may change from 00053 // version to version without notice, or even be removed. 00054 // 00055 // We mean it. 00056 // 00057 00058 #include <QByteArray> 00059 #include <QList> 00060 00061 class MMembuf 00062 { 00063 public: 00064 MMembuf(); 00065 ~MMembuf(); 00066 00067 void append(QByteArray *ba); 00068 void clear(); 00069 00070 bool consumeBytes(quint64 nbytes, char *sink); 00071 QByteArray readAll(); 00072 bool scanNewline(QByteArray *store); 00073 bool canReadLine() const; 00074 00075 int ungetch(int ch); 00076 00077 qint64 size() const; 00078 00079 private: 00080 00081 QList<QByteArray *> buf; 00082 qint64 _size; 00083 qint64 _index; 00084 }; 00085 00086 inline void MMembuf::append(QByteArray *ba) 00087 { buf.append(ba); _size += ba->size(); } 00088 00089 inline void MMembuf::clear() 00090 { qDeleteAll(buf); buf.clear(); _size=0; _index=0; } 00091 00092 inline QByteArray MMembuf::readAll() 00093 { QByteArray ba; ba.resize(_size); consumeBytes(_size,ba.data()); return ba; } 00094 00095 inline bool MMembuf::canReadLine() const 00096 { return const_cast<MMembuf*>(this)->scanNewline(0); } 00097 00098 inline qint64 MMembuf::size() const 00099 { return _size; } 00100 00101 #endif // MMEMBUF_P_H
1.6.3