69 inline QRingBufferRef() : m_buf(
nullptr) { }
70 friend class QIODevicePrivate;
73 inline void setChunkSize(
int size) { Q_ASSERT(m_buf); m_buf->setChunkSize(size); }
74 inline int chunkSize()
const { Q_ASSERT(m_buf);
return m_buf->chunkSize(); }
75 inline qint64 nextDataBlockSize()
const {
return (m_buf ? m_buf->nextDataBlockSize() : Q_INT64_C(0)); }
76 inline const char *readPointer()
const {
return (m_buf ? m_buf->readPointer() :
nullptr); }
77 inline const char *readPointerAtPosition(qint64 pos, qint64 &length)
const { Q_ASSERT(m_buf);
return m_buf->readPointerAtPosition(pos, length); }
78 inline void free(qint64 bytes) { Q_ASSERT(m_buf); m_buf->free(bytes); }
79 inline char *reserve(qint64 bytes) { Q_ASSERT(m_buf);
return m_buf->reserve(bytes); }
80 inline char *reserveFront(qint64 bytes) { Q_ASSERT(m_buf);
return m_buf->reserveFront(bytes); }
81 inline void truncate(qint64 pos) { Q_ASSERT(m_buf); m_buf->truncate(pos); }
82 inline void chop(qint64 bytes) { Q_ASSERT(m_buf); m_buf->chop(bytes); }
83 inline bool isEmpty()
const {
return !m_buf || m_buf->isEmpty(); }
84 inline int getChar() {
return (m_buf ? m_buf->getChar() : -1); }
85 inline void putChar(
char c) { Q_ASSERT(m_buf); m_buf->putChar(c); }
86 inline void ungetChar(
char c) { Q_ASSERT(m_buf); m_buf->ungetChar(c); }
87 inline qint64 size()
const {
return (m_buf ? m_buf->size() : Q_INT64_C(0)); }
88 inline void clear() {
if (m_buf) m_buf->clear(); }
89 inline qint64 indexOf(
char c)
const {
return (m_buf ? m_buf->indexOf(c, m_buf->size()) : Q_INT64_C(-1)); }
90 inline qint64 indexOf(
char c, qint64 maxLength, qint64 pos = 0)
const {
return (m_buf ? m_buf->indexOf(c, maxLength, pos) : Q_INT64_C(-1)); }
91 inline qint64 read(
char *data, qint64 maxLength) {
return (m_buf ? m_buf->read(data, maxLength) : Q_INT64_C(0)); }
92 inline QByteArray read() {
return (m_buf ? m_buf->read() : QByteArray()); }
93 inline qint64 peek(
char *data, qint64 maxLength, qint64 pos = 0)
const {
return (m_buf ? m_buf->peek(data, maxLength, pos) : Q_INT64_C(0)); }
94 inline void append(
const char *data, qint64 size) { Q_ASSERT(m_buf); m_buf->append(data, size); }
95 inline void append(
const QByteArray &qba) { Q_ASSERT(m_buf); m_buf->append(qba); }
96 inline qint64 skip(qint64 length) {
return (m_buf ? m_buf->skip(length) : Q_INT64_C(0)); }
97 qint64 readLine(
char *data, qint64 maxLength,
98 ReadLineOptions option = ReadLineOption::NullTerminated)
100 const auto appendNullByte = option & ReadLineOption::NullTerminated;
101 return !m_buf ? Q_INT64_C(-1) :
102 appendNullByte ? m_buf->readLine(data, maxLength) :
103 m_buf->readLineWithoutTerminatingNull(data, maxLength);
105 inline bool canReadLine()
const {
return m_buf && m_buf->canReadLine(); }