45 #if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED) 244 #undef CHECK_STREAM_PRECOND 246 #define CHECK_STREAM_PRECOND(retVal) \ 248 qWarning("QDataStream: No device"); \ 252 #define CHECK_STREAM_PRECOND(retVal) \ 258 #define CHECK_STREAM_WRITE_PRECOND(retVal) \ 259 CHECK_STREAM_PRECOND(retVal) \ 260 if (q_status != Ok) \ 282 noswap = QSysInfo::ByteOrder == QSysInfo::BigEndian;
304 noswap = QSysInfo::ByteOrder == QSysInfo::BigEndian;
320 #ifndef QT_NO_QOBJECT 323 buf->
open(QIODevice::OpenMode(mode));
328 noswap = QSysInfo::ByteOrder == QSysInfo::BigEndian;
349 #ifndef QT_NO_QOBJECT 357 noswap = QSysInfo::ByteOrder == QSysInfo::BigEndian;
372 #ifndef QT_NO_QOBJECT 381 noswap = QSysInfo::ByteOrder == QSysInfo::BigEndian;
564 if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
736 if (
dev->
read((
char *)&i, 2) != 2) {
773 if (
dev->
read((
char *)&i, 4) != 4) {
814 if (
dev->
read((
char *)&i, 8) != 8) {
863 if (
dev->
read((
char *)&f, 4) != 4) {
872 x.val2 =
qbswap(*reinterpret_cast<quint32 *>(&f));
879 #if defined(Q_DOUBLE_FORMAT) 880 #define Q_DF(x) Q_DOUBLE_FORMAT[(x)] - '0' 908 #ifndef Q_DOUBLE_FORMAT 909 if (
dev->
read((
char *)&f, 8) != 8) {
918 x.val2 =
qbswap(*reinterpret_cast<quint64 *>(&f));
1007 const quint32 Step = 1024 * 1024;
1015 curBuf =
new char[allocated + blockSize + 1];
1017 memcpy(curBuf, prevBuf, allocated);
1026 }
while (allocated < len);
1225 if (
dev->
write((
char *)&x.val2,
sizeof(
float)) !=
sizeof(float))
1230 if (
dev->
write((
char *)&g,
sizeof(
float)) !=
sizeof(float))
1257 #ifndef Q_DOUBLE_FORMAT 1259 if (
dev->
write((
char *)&f,
sizeof(
double)) !=
sizeof(double))
1268 if (
dev->
write((
char *)&x.val2,
sizeof(
double)) !=
sizeof(double))
1391 int n =
dev->
read(buf, blockSize);
1404 if (pos + len > size)
1428 #endif // QT_NO_DATASTREAM Status status() const
Returns the status of the data stream.
bool blockSignals(bool b)
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke...
virtual qint64 size() const
For open random-access devices, this function returns the size of the device.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
Status
This enum describes the current status of the data stream.
void qbswap(const T src, uchar *dest)
QDataStream()
Constructs a data stream that has no I/O device.
void setData(const QByteArray &data)
Sets the contents of the internal buffer to be data.
bool open(OpenMode openMode)
Reimplemented Function
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
The QByteArray class provides an array of bytes.
virtual qint64 pos() const
For random-access devices, this function returns the position that data is written to or read from...
virtual ~QDataStream()
Destroys the data stream.
bool getChar(char *c)
Reads one character from the device and stores it in c.
bool putChar(char c)
Writes the character c to the device.
long ASN1_INTEGER_get ASN1_INTEGER * a
void setStatus(Status status)
Sets the status of the data stream to the status given.
The QBuffer class provides a QIODevice interface for a QByteArray.
FloatingPointPrecision
The precision of floating point numbers used for reading/writing the data.
#define CHECK_STREAM_WRITE_PRECOND(retVal)
virtual bool atEnd() const
Returns true if the current read and write position is at the end of the device (i.e.
QDataStream::FloatingPointPrecision floatingPointPrecision
qint64 read(char *data, qint64 maxlen)
Reads at most maxSize bytes from the device into data, and returns the number of bytes read...
#define CHECK_STREAM_PRECOND(retVal)
#define QT_BEGIN_NAMESPACE
This macro expands to.
int readRawData(char *, int len)
Reads at most len bytes from the stream into s and returns the number of bytes read.
QDataStream & writeBytes(const char *, uint len)
Writes the length specifier len and the buffer s to the stream and returns a reference to the stream...
void setByteOrder(ByteOrder)
Sets the serialization byte order to bo.
void reset(T *other=0)
Deletes the existing object it is pointing to if any, and sets its pointer to other.
virtual bool isSequential() const
Returns true if this device is sequential; otherwise returns false.
int version() const
Returns the version number of the data serialization format.
uint qstrlen(const char *str)
QDataStream & readBytes(char *&, uint &len)
Reads the buffer s from the stream and returns a reference to the stream.
void resetStatus()
Resets the status of the data stream.
FloatingPointPrecision floatingPointPrecision() const
Returns the floating point precision of the data stream.
void unsetDevice()
Unsets the I/O device.
QDataStream & operator>>(qint8 &i)
Reads a signed byte from the stream into i, and returns a reference to the stream.
void setDevice(QIODevice *)
void QDataStream::setDevice(QIODevice *d)
The QDataStream class provides serialization of binary data to a QIODevice.
ByteOrder
The byte order used for reading/writing the data.
QScopedPointer< QDataStreamPrivate > d
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
int skipRawData(int len)
Skips len bytes from the device.
QDataStream & operator<<(qint8 i)
Writes a signed byte, i, to the stream and returns a reference to the stream.
The QIODevice class is the base interface class of all I/O devices in Qt.
void setFloatingPointPrecision(FloatingPointPrecision precision)
Sets the floating point precision of the data stream to precision.
virtual bool seek(qint64 pos)
For random-access devices, this function sets the current position to pos, returning true on success...
int writeRawData(const char *, int len)
Writes len bytes from s to the stream.