Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines. More...
#include <qabstractfileengine_p.h>
Public Member Functions | |
QAbstractFileEngineIterator (const QString &path, QDir::Filters filters, const QStringList &nameFilters) | |
Constructs a QAbstractFileEngineIterator, using the entry filters filters, and wildcard name filters nameFilters. | |
virtual | ~QAbstractFileEngineIterator () |
Destroys the QAbstractFileEngineIterator. | |
virtual bool | advance ()=0 |
This pure virtual function advances the iterator to the next directory entry; if the operation was successful this method returns true , otherwise it returs false . | |
QString | path () const |
Returns the path for this iterator. | |
QStringList | nameFilters () const |
Returns the name filters for this iterator. | |
QDir::Filters | filters () const |
Returns the entry filters for this iterator. | |
virtual QString | currentFileName () const =0 |
This pure virtual function returns the name of the current directory entry, excluding the path. | |
virtual QFileInfo | currentFileInfo () const |
The virtual function returns a QFileInfo for the current directory entry. | |
virtual QString | currentFilePath () const |
Returns the path to the current directory entry. | |
Protected Attributes | |
QFileInfo | m_fileInfo |
Friends | |
class | QDirIterator |
class | QDirIteratorPrivate |
class | QDirListingPrivate |
The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.
\inmodule QtCore
If all you want is to iterate over entries in a directory, see QDirListing instead. This class is useful only for custom file engine authors.
QAbstractFileEngineIterator is a unidirectional single-use virtual iterator that plugs into QDirListing, providing transparent proxy iteration for custom file engines (for example, QResourceFileEngine).
You can subclass QAbstractFileEngineIterator to provide an iterator when writing your own file engine. To plug the iterator into your file system, you simply return an instance of this subclass from a reimplementation of QAbstractFileEngine::beginEntryList().
Example:
QAbstractFileEngineIterator is associated with a path, name filters, and entry filters. The path is the directory that the iterator lists entries in. The name filters and entry filters are provided for file engines that can optimize directory listing at the iterator level (e.g., network file systems that need to minimize network traffic), but they can also be ignored by the iterator subclass; QAbstractFileEngineIterator already provides the required filtering logics in the matchesFilters() function. You can call dirName() to get the directory name, nameFilters() to get a stringlist of name filters, and filters() to get the entry filters.
The pure virtual function advance(), as its name implies, advances the iterator to the next entry in the current directory; if the operation was successful this method returns true
, otherwise it returns false
. You have to reimplement this function in your sub-class to work with your file engine implementation.
The pure virtual function currentFileName() returns the name of the current entry without advancing the iterator. The currentFilePath() function is provided for convenience; it returns the full path of the current entry.
Here is an example of how to implement an iterator that returns each of three fixed entries in sequence.
Note: QAbstractFileEngineIterator does not deal with QDir::IteratorFlags; it simply returns entries for a single directory.
Definition at line 201 of file qabstractfileengine_p.h.
QAbstractFileEngineIterator::QAbstractFileEngineIterator | ( | const QString & | path, |
QDir::Filters | filters, | ||
const QStringList & | nameFilters ) |
Constructs a QAbstractFileEngineIterator, using the entry filters filters, and wildcard name filters nameFilters.
Definition at line 897 of file qabstractfileengine.cpp.
|
virtual |
Destroys the QAbstractFileEngineIterator.
Definition at line 910 of file qabstractfileengine.cpp.
|
pure virtual |
This pure virtual function advances the iterator to the next directory entry; if the operation was successful this method returns true
, otherwise it returs false
.
This function can optionally make use of nameFilters() and filters() to optimize its performance.
Reimplement this function in a subclass to advance the iterator.
Implemented in CustomIterator, QFSFileEngineIterator, QResourceFileEngineIterator, AndroidContentFileEngineIterator, AndroidAbstractFileEngineIterator, and QQmlPreviewFileEngineIterator.
|
virtual |
The virtual function returns a QFileInfo for the current directory entry.
This function is provided for convenience. It can also be slightly faster than creating a QFileInfo object yourself, as the object returned by this function might contain cached information that QFileInfo otherwise would have to access through the file engine.
Reimplemented in QFSFileEngineIterator, QResourceFileEngineIterator, and AndroidAbstractFileEngineIterator.
Definition at line 979 of file qabstractfileengine.cpp.
References currentFilePath(), QFileInfo::filePath(), m_fileInfo, and QFileInfo::setFile().
|
pure virtual |
This pure virtual function returns the name of the current directory entry, excluding the path.
Implemented in QFSFileEngineIterator, QResourceFileEngineIterator, AndroidContentFileEngineIterator, AndroidAbstractFileEngineIterator, and QQmlPreviewFileEngineIterator.
Referenced by currentFilePath().
|
virtual |
Returns the path to the current directory entry.
It's the same as prepending path() to the return value of currentFileName().
Reimplemented in AndroidContentFileEngineIterator, and AndroidAbstractFileEngineIterator.
Definition at line 961 of file qabstractfileengine.cpp.
References currentFileName(), and path().
Referenced by currentFileInfo(), and QResourceFileEngineIterator::currentFileInfo().
QDir::Filters QAbstractFileEngineIterator::filters | ( | ) | const |
Returns the entry filters for this iterator.
Definition at line 941 of file qabstractfileengine.cpp.
QStringList QAbstractFileEngineIterator::nameFilters | ( | ) | const |
Returns the name filters for this iterator.
Definition at line 931 of file qabstractfileengine.cpp.
QString QAbstractFileEngineIterator::path | ( | ) | const |
Returns the path for this iterator.
The path is set by beginEntryList(). The path should't be changed once iteration begins.
Definition at line 921 of file qabstractfileengine.cpp.
Referenced by QResourceFileEngineIterator::advance(), AndroidContentFileEngineIterator::advance(), and currentFilePath().
|
friend |
Definition at line 223 of file qabstractfileengine_p.h.
|
friend |
Definition at line 224 of file qabstractfileengine_p.h.
|
friend |
Definition at line 225 of file qabstractfileengine_p.h.
|
mutableprotected |
Definition at line 219 of file qabstractfileengine_p.h.
Referenced by QFSFileEngineIterator::advance(), currentFileInfo(), QFSFileEngineIterator::currentFileInfo(), QResourceFileEngineIterator::currentFileInfo(), and QFSFileEngineIterator::currentFileName().