NuriaProject Framework  0.1
The NuriaProject Framework
Public Member Functions | Protected Member Functions | List of all members
Nuria::ReferenceDevice Class Reference

Operates on a part of another QIODevice. More...

#include <referencedevice.hpp>

Inheritance diagram for Nuria::ReferenceDevice:

Public Member Functions

 ReferenceDevice (QIODevice *referencedDevice, QObject *parent=0)
 
 ~ReferenceDevice () override
 
bool atEnd () const override
 
qint64 bytesAvailable () const override
 
void close () override
 
void extendRange (qint64 bytes)
 
bool isSequential () const override
 
bool open (OpenMode mode) override
 
qint64 pos () const override
 
qint64 rangeBegin () const
 
qint64 rangeEnd () const
 
QIODevice * referencedDevice () const
 
bool reset () override
 
bool seek (qint64 pos) override
 
void setRange (qint64 begin, qint64 end=-1)
 
qint64 size () const override
 

Protected Member Functions

qint64 readData (char *data, qint64 maxlen)
 
qint64 writeData (const char *data, qint64 len)
 

Detailed Description

Operates on a part of another QIODevice.

ReferenceDevice references a given part of a random-access QIODevice. This device does not store any data itself. This means, that the referenced QIODevice must be kept alive as long a ReferenceDevice is operating on it.

Note
If the referenced device is destroyed, all reference devices will be closed.
Open mode
The open mode is copied form the referenced device in the constructor. The implementation of open() will only allow modes compatible with the current open mode of the device. This means, that if the referenced device is currently in QIODevice::ReadWrite mode, then QIODevice::NotOpen, QIODevice::ReadOnly, QIODevice::WriteOnly and QIODevice::ReadWrite are allowed. If the device is in QIODevice::ReadOnly mode, only QIODevice::NotOpen and QIODevice::ReadOnly are allowed - and so on.

Constructor & Destructor Documentation

Nuria::ReferenceDevice::ReferenceDevice ( QIODevice *  referencedDevice,
QObject *  parent = 0 
)
explicit

Constructs a ReferenceDevice referencing referencedDevice.

See also
setRange
Nuria::ReferenceDevice::~ReferenceDevice ( )
override

Destructor.

Member Function Documentation

void Nuria::ReferenceDevice::extendRange ( qint64  bytes)

Extends the current range by bytes. The same range extension mechanism like in setRange() takes place. Signals are emitted accordingly.

qint64 Nuria::ReferenceDevice::rangeBegin ( ) const

Returns the begin of the referenced range.

qint64 Nuria::ReferenceDevice::rangeEnd ( ) const

Returns the end of the referenced range.

QIODevice* Nuria::ReferenceDevice::referencedDevice ( ) const

Returns the device the ReferenceDevice is operating on.

void Nuria::ReferenceDevice::setRange ( qint64  begin,
qint64  end = -1 
)

Sets the operated range to be from begin till end (exclusive). If end is longer than the current size() of the referencedDevice(), then the range will be extended automatically when data has been written to the referenced device, until it matches the given one.

If begin is not currently outside the referenced device and the range is greater than 0, then readyRead() will be emitted.

If end is -1, then the range will span from begin till the current size() of the referenced device.

Note
After this operation, the position of this device will be 0.

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