Qt 4.8
qt-4.8.6
src
corelib
io
qnoncontiguousbytedevice_p.h
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
5
**
6
** This file is part of the QtCore module of the Qt Toolkit.
7
**
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
16
**
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
**
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
36
**
37
**
38
** $QT_END_LICENSE$
39
**
40
****************************************************************************/
41
42
#ifndef QNONCONTIGUOUSBYTEDEVICE_H
43
#define QNONCONTIGUOUSBYTEDEVICE_H
44
45
//
46
// W A R N I N G
47
// -------------
48
//
49
// This file is not part of the Qt API. It exists for the convenience
50
// of a number of Qt sources files. This header file may change from
51
// version to version without notice, or even be removed.
52
//
53
// We mean it.
54
//
55
56
#include <QtCore/qobject.h>
57
#include <QtCore/qbytearray.h>
58
#include <QtCore/qbuffer.h>
59
#include <QtCore/qiodevice.h>
60
#include <QtCore/QSharedPointer>
61
#include "private/qringbuffer_p.h"
62
63
QT_BEGIN_NAMESPACE
64
65
class
Q_CORE_EXPORT
QNonContiguousByteDevice
:
public
QObject
66
{
67
Q_OBJECT
68
public
:
69
virtual
const
char
* readPointer(
qint64
maximumLength,
qint64
&len) = 0;
70
virtual
bool
advanceReadPointer(
qint64
amount) = 0;
71
virtual
bool
atEnd() = 0;
72
virtual
bool
reset
() = 0;
73
void
disableReset();
74
bool
isResetDisabled
() {
return
resetDisabled; }
75
virtual
qint64
size() = 0;
76
77
virtual
~
QNonContiguousByteDevice
();
78
79
protected
:
80
QNonContiguousByteDevice
();
81
82
83
bool
resetDisabled
;
84
Q_SIGNALS
:
85
void
readyRead();
86
void
readProgress(
qint64
current,
qint64
total);
87
};
88
89
class
Q_CORE_EXPORT
QNonContiguousByteDeviceFactory
90
{
91
public
:
92
static
QNonContiguousByteDevice
*
create
(
QIODevice
*device);
93
static
QNonContiguousByteDevice
*
create
(
QByteArray
*byteArray);
94
static
QNonContiguousByteDevice
*
create
(
QSharedPointer<QRingBuffer>
ringBuffer);
95
static
QIODevice
* wrap(
QNonContiguousByteDevice
* byteDevice);
96
};
97
98
// the actual implementations
99
//
100
101
class
QNonContiguousByteDeviceByteArrayImpl
:
public
QNonContiguousByteDevice
102
{
103
public
:
104
QNonContiguousByteDeviceByteArrayImpl
(
QByteArray
*ba);
105
~
QNonContiguousByteDeviceByteArrayImpl
();
106
const
char
* readPointer(
qint64
maximumLength,
qint64
&len);
107
bool
advanceReadPointer(
qint64
amount);
108
bool
atEnd();
109
bool
reset
();
110
qint64
size();
111
protected
:
112
QByteArray
*
byteArray
;
113
qint64
currentPosition
;
114
};
115
116
class
QNonContiguousByteDeviceRingBufferImpl
:
public
QNonContiguousByteDevice
117
{
118
public
:
119
QNonContiguousByteDeviceRingBufferImpl
(
QSharedPointer<QRingBuffer>
rb);
120
~
QNonContiguousByteDeviceRingBufferImpl
();
121
const
char
* readPointer(
qint64
maximumLength,
qint64
&len);
122
bool
advanceReadPointer(
qint64
amount);
123
bool
atEnd();
124
bool
reset
();
125
qint64
size();
126
protected
:
127
QSharedPointer<QRingBuffer>
ringBuffer
;
128
qint64
currentPosition
;
129
};
130
131
132
class
QNonContiguousByteDeviceIoDeviceImpl
:
public
QNonContiguousByteDevice
133
{
134
Q_OBJECT
135
public
:
136
QNonContiguousByteDeviceIoDeviceImpl
(
QIODevice
*
d
);
137
~
QNonContiguousByteDeviceIoDeviceImpl
();
138
const
char
* readPointer(
qint64
maximumLength,
qint64
&len);
139
bool
advanceReadPointer(
qint64
amount);
140
bool
atEnd();
141
bool
reset
();
142
qint64
size();
143
protected
:
144
QIODevice
*
device
;
145
QByteArray
*
currentReadBuffer
;
146
qint64
currentReadBufferSize
;
147
qint64
currentReadBufferAmount
;
148
qint64
currentReadBufferPosition
;
149
qint64
totalAdvancements
;
//progress counter used for emitting the readProgress signal
150
bool
eof
;
151
qint64
initialPosition
;
152
};
153
154
class
QNonContiguousByteDeviceBufferImpl
:
public
QNonContiguousByteDevice
155
{
156
Q_OBJECT
157
public
:
158
QNonContiguousByteDeviceBufferImpl
(
QBuffer
*b);
159
~
QNonContiguousByteDeviceBufferImpl
();
160
const
char
* readPointer(
qint64
maximumLength,
qint64
&len);
161
bool
advanceReadPointer(
qint64
amount);
162
bool
atEnd();
163
bool
reset
();
164
qint64
size();
165
protected
:
166
QBuffer
*
buffer
;
167
QByteArray
byteArray
;
168
QNonContiguousByteDeviceByteArrayImpl
*
arrayImpl
;
169
};
170
171
// ... and the reverse thing
172
class
QByteDeviceWrappingIoDevice
:
public
QIODevice
173
{
174
public
:
175
QByteDeviceWrappingIoDevice
(
QNonContiguousByteDevice
*bd);
176
~
QByteDeviceWrappingIoDevice
();
177
virtual
bool
isSequential ()
const
;
178
virtual
bool
atEnd ()
const
;
179
virtual
bool
reset
();
180
virtual
qint64
size ()
const
;
181
protected
:
182
virtual
qint64
readData (
char
*
data
,
qint64
maxSize );
183
virtual
qint64
writeData (
const
char
* data,
qint64
maxSize );
184
185
QNonContiguousByteDevice
*
byteDevice
;
186
};
187
188
QT_END_NAMESPACE
189
190
#endif
d
double d
Definition:
qnumeric_p.h:62
QSharedPointer< QRingBuffer >
QNonContiguousByteDeviceIoDeviceImpl::device
QIODevice * device
Definition:
qnoncontiguousbytedevice_p.h:144
QT_END_NAMESPACE
#define QT_END_NAMESPACE
This macro expands to.
Definition:
qglobal.h:90
QNonContiguousByteDeviceIoDeviceImpl::totalAdvancements
qint64 totalAdvancements
Definition:
qnoncontiguousbytedevice_p.h:149
QNonContiguousByteDeviceRingBufferImpl
Definition:
qnoncontiguousbytedevice_p.h:116
QNonContiguousByteDeviceRingBufferImpl::ringBuffer
QSharedPointer< QRingBuffer > ringBuffer
Definition:
qnoncontiguousbytedevice_p.h:127
QByteArray
The QByteArray class provides an array of bytes.
Definition:
qbytearray.h:135
QPatternist::create
static Expression::Ptr create(Expression *const expr, const YYLTYPE &sourceLocator, const ParserContext *const parseInfo)
Definition:
qquerytransformparser.cpp:355
reset
Q_CORE_EXPORT QTextStream & reset(QTextStream &s)
QByteDeviceWrappingIoDevice
Definition:
qnoncontiguousbytedevice_p.h:172
QByteDeviceWrappingIoDevice::byteDevice
QNonContiguousByteDevice * byteDevice
Definition:
qnoncontiguousbytedevice_p.h:185
QNonContiguousByteDevice::isResetDisabled
bool isResetDisabled()
Definition:
qnoncontiguousbytedevice_p.h:74
QNonContiguousByteDeviceByteArrayImpl
Definition:
qnoncontiguousbytedevice_p.h:101
QBuffer
The QBuffer class provides a QIODevice interface for a QByteArray.
Definition:
qbuffer.h:57
QNonContiguousByteDeviceIoDeviceImpl::currentReadBufferSize
qint64 currentReadBufferSize
Definition:
qnoncontiguousbytedevice_p.h:146
QObject
The QObject class is the base class of all Qt objects.
Definition:
qobject.h:111
Q_SIGNALS
#define Q_SIGNALS
Definition:
qobjectdefs.h:72
QNonContiguousByteDeviceBufferImpl::byteArray
QByteArray byteArray
Definition:
qnoncontiguousbytedevice_p.h:167
QNonContiguousByteDeviceRingBufferImpl::currentPosition
qint64 currentPosition
Definition:
qnoncontiguousbytedevice_p.h:128
QNonContiguousByteDevice::resetDisabled
bool resetDisabled
Definition:
qnoncontiguousbytedevice_p.h:83
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition:
qglobal.h:89
QNonContiguousByteDeviceIoDeviceImpl::currentReadBuffer
QByteArray * currentReadBuffer
Definition:
qnoncontiguousbytedevice_p.h:145
data
static const char * data(const QByteArray &arr)
Definition:
qdbusmessage.cpp:60
qint64
__int64 qint64
Definition:
qglobal.h:942
QNonContiguousByteDeviceBufferImpl::buffer
QBuffer * buffer
Definition:
qnoncontiguousbytedevice_p.h:166
QNonContiguousByteDeviceIoDeviceImpl::initialPosition
qint64 initialPosition
Definition:
qnoncontiguousbytedevice_p.h:151
QNonContiguousByteDeviceIoDeviceImpl
Definition:
qnoncontiguousbytedevice_p.h:132
Q_OBJECT
#define Q_OBJECT
Definition:
qobjectdefs.h:157
QNonContiguousByteDeviceByteArrayImpl::byteArray
QByteArray * byteArray
Definition:
qnoncontiguousbytedevice_p.h:112
QNonContiguousByteDeviceFactory
Creates a QNonContiguousByteDevice out of a QIODevice, QByteArray etc.
Definition:
qnoncontiguousbytedevice_p.h:89
Q_CORE_EXPORT
#define Q_CORE_EXPORT
Definition:
qglobal.h:1449
QNonContiguousByteDeviceBufferImpl::arrayImpl
QNonContiguousByteDeviceByteArrayImpl * arrayImpl
Definition:
qnoncontiguousbytedevice_p.h:168
QNonContiguousByteDeviceIoDeviceImpl::eof
bool eof
Definition:
qnoncontiguousbytedevice_p.h:150
QNonContiguousByteDeviceByteArrayImpl::currentPosition
qint64 currentPosition
Definition:
qnoncontiguousbytedevice_p.h:113
QNonContiguousByteDevice
A QNonContiguousByteDevice is a representation of a file, array or buffer that allows access with a r...
Definition:
qnoncontiguousbytedevice_p.h:65
QNonContiguousByteDeviceIoDeviceImpl::currentReadBufferAmount
qint64 currentReadBufferAmount
Definition:
qnoncontiguousbytedevice_p.h:147
QNonContiguousByteDeviceBufferImpl
Definition:
qnoncontiguousbytedevice_p.h:154
QIODevice
The QIODevice class is the base interface class of all I/O devices in Qt.
Definition:
qiodevice.h:66
QNonContiguousByteDeviceIoDeviceImpl::currentReadBufferPosition
qint64 currentReadBufferPosition
Definition:
qnoncontiguousbytedevice_p.h:148
Qt 4.8 Source Code Browser