equal
deleted
inserted
replaced
60 |
60 |
61 QByteArray *buf; |
61 QByteArray *buf; |
62 QByteArray defaultBuf; |
62 QByteArray defaultBuf; |
63 int ioIndex; |
63 int ioIndex; |
64 |
64 |
|
65 virtual qint64 peek(char *data, qint64 maxSize); |
|
66 virtual QByteArray peek(qint64 maxSize); |
|
67 |
65 #ifndef QT_NO_QOBJECT |
68 #ifndef QT_NO_QOBJECT |
66 // private slots |
69 // private slots |
67 void _q_emitSignals(); |
70 void _q_emitSignals(); |
68 |
71 |
69 qint64 writtenSinceLastEmit; |
72 qint64 writtenSinceLastEmit; |
80 writtenSinceLastEmit = 0; |
83 writtenSinceLastEmit = 0; |
81 emit q->readyRead(); |
84 emit q->readyRead(); |
82 signalsEmitted = false; |
85 signalsEmitted = false; |
83 } |
86 } |
84 #endif |
87 #endif |
|
88 |
|
89 qint64 QBufferPrivate::peek(char *data, qint64 maxSize) |
|
90 { |
|
91 qint64 readBytes = qMin(maxSize, static_cast<qint64>(buf->size()) - pos); |
|
92 memcpy(data, buf->constData() + pos, readBytes); |
|
93 return readBytes; |
|
94 } |
|
95 |
|
96 QByteArray QBufferPrivate::peek(qint64 maxSize) |
|
97 { |
|
98 qint64 readBytes = qMin(maxSize, static_cast<qint64>(buf->size()) - pos); |
|
99 if (pos == 0 && maxSize >= buf->size()) |
|
100 return *buf; |
|
101 return QByteArray(buf->constData() + pos, readBytes); |
|
102 } |
85 |
103 |
86 /*! |
104 /*! |
87 \class QBuffer |
105 \class QBuffer |
88 \reentrant |
106 \reentrant |
89 \brief The QBuffer class provides a QIODevice interface for a QByteArray. |
107 \brief The QBuffer class provides a QIODevice interface for a QByteArray. |