Reputation: 41
I have one QIODevice
which receives data from an undefined source.
What i want to do is Dump all data to a file being sent from QIODevice
, but if i read then another handler which depends on original data changes.
Basically what i want is
void piping( QIODevice* Data )
{
if ( outgoingData )
{
qDebug()<<Data->readAll();
}
// gets nothing as readAll has already consumed all data
dependentOn(Data);
}
function dependentOn
is not defined by me, so i cannot change its definition.
Upvotes: 1
Views: 544
Reputation: 1711
qint64 QIODevice::peek(char * data, qint64 maxSize)
is what you want.
From the documentation :
qint64 QIODevice::peek(char * data, qint64 maxSize)
Reads at most maxSize bytes from the device into data, without side effects (i.e., if you call read() after peek(), you will get the same data). Returns the number of bytes read. If an error occurs, such as when attempting to peek a device opened in WriteOnly mode, this function returns -1.
Reference : http://doc.qt.io/qt-5/qiodevice.html#peek
Upvotes: 2