QtlMovie 1.12 (A specialized FFmpeg front-end)
QtlFileSlices Class Reference

A read-only file device with sequential access on a list of data slices. More...

Inheritance diagram for QtlFileSlices:

Public Member Functions

 QtlFileSlices (const QString &fileName, const QtlRangeList &slices=QtlRangeList(), QObject *parent=0)
 Constructor. More...
 
virtual bool atEnd () const Q_DECL_OVERRIDE
 Returns true if the current read position is at the end of the device. More...
 
virtual void close () Q_DECL_OVERRIDE
 Close the device. More...
 
QString fileName () const
 Get the file name. More...
 
virtual bool isSequential () const Q_DECL_OVERRIDE
 Returns true if this device is sequential; otherwise returns false. More...
 
virtual bool open (OpenMode mode=ReadOnly) Q_DECL_OVERRIDE
 Open the device. More...
 
virtual qint64 pos () const Q_DECL_OVERRIDE
 Get the position that data is read from. More...
 
virtual qint64 size () const Q_DECL_OVERRIDE
 Get the size of the device, meaning the number of bytes to read. More...
 

Protected Member Functions

virtual qint64 readData (char *data, qint64 maxSize) Q_DECL_OVERRIDE
 Reads up to maxSize bytes from the device into data. More...
 
virtual qint64 writeData (const char *data, qint64 maxSize) Q_DECL_OVERRIDE
 Writes up to maxSize bytes from data to the device. More...
 

Private Member Functions

 QtlFileSlices () Q_DECL_EQ_DELETE
 

Private Attributes

QtlRangeList::ConstIterator _currentSlice
 Current pointer in _slices. More...
 
QFile _file
 Actual device to read. More...
 
int _nextByte
 Next byte in _currentSlice, -1 means at beginning. More...
 
qint64 _readSize
 Number of bytes already read in the file. More...
 
qint64 _size
 Number of bytes to read in the file. More...
 
QtlRangeList _slices
 Slices of file to read. More...
 

Detailed Description

A read-only file device with sequential access on a list of data slices.

When reading the file, only specific portions of the physical files are read.

Constructor & Destructor Documentation

◆ QtlFileSlices() [1/2]

QtlFileSlices::QtlFileSlices ( const QString &  fileName,
const QtlRangeList slices = QtlRangeList(),
QObject *  parent = 0 
)
explicit

Constructor.

Parameters
[in]fileNameName of the file.
[in]slicesSlices of data to read in the files. If empty, the whole file is read.
[in]parentOptional parent object.

◆ QtlFileSlices() [2/2]

QtlFileSlices::QtlFileSlices ( )
private

Member Function Documentation

◆ fileName()

QString QtlFileSlices::fileName ( ) const
inline

Get the file name.

Returns
The file name.

◆ open()

bool QtlFileSlices::open ( OpenMode  mode = ReadOnly)
virtual

Open the device.

Reimplemented from QIODevice.

Parameters
[in]modeOpen mode. The only allowed mode is ReadOnly, with optional flag Text. All other modes are forbidden.
Returns
True on success, false on error.

◆ close()

void QtlFileSlices::close ( )
virtual

Close the device.

Reimplemented from QIODevice.

◆ size()

virtual qint64 QtlFileSlices::size ( ) const
inlinevirtual

Get the size of the device, meaning the number of bytes to read.

Reimplemented from QIODevice.

Returns
The number of bytes to read, which is the sum of all slices to read. This is different from the size of the underlying file. If some slices overlap, the same data are counted several times.

◆ pos()

virtual qint64 QtlFileSlices::pos ( ) const
inlinevirtual

Get the position that data is read from.

Reimplemented from QIODevice.

Returns
The current position in the slices, which is also the number of bytes already read.

◆ atEnd()

virtual bool QtlFileSlices::atEnd ( ) const
inlinevirtual

Returns true if the current read position is at the end of the device.

Reimplemented from QIODevice.

Returns
True if there is no more data to read, false otherwise.

◆ isSequential()

virtual bool QtlFileSlices::isSequential ( ) const
inlinevirtual

Returns true if this device is sequential; otherwise returns false.

Reimplemented from QIODevice.

Returns
Always true.

◆ readData()

qint64 QtlFileSlices::readData ( char *  data,
qint64  maxSize 
)
protectedvirtual

Reads up to maxSize bytes from the device into data.

Implemented from QIODevice requirement.

Parameters
[out]dataBuffer for returned data.
[in]maxSizeMaximum number of bytes to read.
Returns
Number of bytes read or -1 if an error occurred.

◆ writeData()

virtual qint64 QtlFileSlices::writeData ( const char *  data,
qint64  maxSize 
)
inlineprotectedvirtual

Writes up to maxSize bytes from data to the device.

Implemented from QIODevice requirement.

Parameters
[in]dataBuffer for data to write.
[in]maxSizeMaximum number of bytes to write.
Returns
Always -1 (error) since the file is read-only.

Member Data Documentation

◆ _slices

QtlRangeList QtlFileSlices::_slices
private

Slices of file to read.

◆ _size

qint64 QtlFileSlices::_size
private

Number of bytes to read in the file.

◆ _readSize

qint64 QtlFileSlices::_readSize
private

Number of bytes already read in the file.

◆ _file

QFile QtlFileSlices::_file
private

Actual device to read.

◆ _nextByte

int QtlFileSlices::_nextByte
private

Next byte in _currentSlice, -1 means at beginning.

◆ _currentSlice

QtlRangeList::ConstIterator QtlFileSlices::_currentSlice
private

Current pointer in _slices.


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