DataStreamOperatorWrapper Class Reference

Wraps around QDataStream stream operators to provide cleaner reading interface. More...

#include <datastreamoperatorwrapper.h>

Public Member Functions

 DataStreamOperatorWrapper (QDataStream *stream)
 
QDataStream * dataStream ()
 Gets underlying QDataStream. More...
 
const QDataStream * dataStream () const
 Gets underlying QDataStream. More...
 
bool hasRemaining () const
 Returns true if there is any data remaining in the stream. More...
 
bool readBool ()
 
double readDouble ()
 
float readFloat ()
 
qint16 readQInt16 ()
 
qint32 readQInt32 ()
 
qint64 readQInt64 ()
 
qint8 readQInt8 ()
 
quint16 readQUInt16 ()
 
quint32 readQUInt32 ()
 
quint64 readQUInt64 ()
 
quint8 readQUInt8 ()
 
QByteArray readRaw (qint64 length)
 Reads specified amount of raw bytes. More...
 
QByteArray readRawAll ()
 Reads all remaining raw bytes. More...
 
QByteArray readRawUntilByte (char stopByte)
 This method calls Strings::readUntilByte() . More...
 
qint64 remaining () const
 Returns a remaining amount of bytes from the underlying QIODevice. More...
 
int skipRawData (int len)
 Reads and discards specified amount of data. More...
 

Detailed Description

Wraps around QDataStream stream operators to provide cleaner reading interface.

Definition at line 36 of file datastreamoperatorwrapper.h.

Member Function Documentation

QDataStream * DataStreamOperatorWrapper::dataStream ( )

Gets underlying QDataStream.

Definition at line 51 of file datastreamoperatorwrapper.cpp.

const QDataStream * DataStreamOperatorWrapper::dataStream ( ) const

Gets underlying QDataStream.

Definition at line 56 of file datastreamoperatorwrapper.cpp.

bool DataStreamOperatorWrapper::hasRemaining ( ) const
inline

Returns true if there is any data remaining in the stream.

The check is performed through 'remaining() > 0' instruction.

Definition at line 57 of file datastreamoperatorwrapper.h.

QByteArray DataStreamOperatorWrapper::readRaw ( qint64  length)

Reads specified amount of raw bytes.

Parameters
lengthAmount of bytes to read.
Returns
QByteArray of read bytes.

Definition at line 116 of file datastreamoperatorwrapper.cpp.

QByteArray DataStreamOperatorWrapper::readRawAll ( )

Reads all remaining raw bytes.

This calls QIODevice::readAll() directly.

Returns
QByteArray of read bytes.

Definition at line 121 of file datastreamoperatorwrapper.cpp.

QByteArray DataStreamOperatorWrapper::readRawUntilByte ( char  stopByte)

This method calls Strings::readUntilByte() .

Definition at line 126 of file datastreamoperatorwrapper.cpp.

qint64 DataStreamOperatorWrapper::remaining ( ) const

Returns a remaining amount of bytes from the underlying QIODevice.

This is done by performing QIODevice::size() - QIODevice::pos(). It is assumed that the QIODevice can return both values, ie. is not sequential.

Definition at line 131 of file datastreamoperatorwrapper.cpp.

int DataStreamOperatorWrapper::skipRawData ( int  len)

Reads and discards specified amount of data.

Calls QIODevice::skipRawData() directly.

Returns
Number of bytes actually skipped or -1 on error.

Definition at line 136 of file datastreamoperatorwrapper.cpp.


The documentation for this class was generated from the following files: