/**************************************************************************** ** ** Copyright (C) 2022 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ******************************************************************************/ #ifndef QBUFFER_H #define QBUFFER_H #include #include QT_BEGIN_NAMESPACE class QObject; class QBufferPrivate; class Q_CORE_EXPORT QBuffer : public QIODevice { #ifndef QT_NO_QOBJECT Q_OBJECT #endif public: #ifndef QT_NO_QOBJECT explicit QBuffer(QObject *parent = nullptr); QBuffer(QByteArray *buf, QObject *parent = nullptr); #else QBuffer(); explicit QBuffer(QByteArray *buf); #endif ~QBuffer(); QByteArray &buffer(); const QByteArray &buffer() const; void setBuffer(QByteArray *a); void setData(const QByteArray &data); inline void setData(const char *data, int len); const QByteArray &data() const; bool open(OpenMode openMode) override; void close() override; qint64 size() const override; qint64 pos() const override; bool seek(qint64 off) override; bool atEnd() const override; bool canReadLine() const override; protected: #ifndef QT_NO_QOBJECT void connectNotify(const QMetaMethod &) override; void disconnectNotify(const QMetaMethod &) override; #endif qint64 readData(char *data, qint64 maxlen) override; qint64 writeData(const char *data, qint64 len) override; private: Q_DECLARE_PRIVATE(QBuffer) Q_DISABLE_COPY(QBuffer) Q_PRIVATE_SLOT(d_func(), void _q_emitSignals()) }; inline void QBuffer::setData(const char *adata, int alen) { setData(QByteArray(adata, alen)); } QT_END_NAMESPACE #endif // QBUFFER_H