![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
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. | |
QAbstractFileEngineIterator (const QString &path, QDirListing::IteratorFlags filters, const QStringList &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 210 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 914 of file qabstractfileengine.cpp.
QAbstractFileEngineIterator::QAbstractFileEngineIterator | ( | const QString & | path, |
QDirListing::IteratorFlags | filters, | ||
const QStringList & | nameFilters ) |
Definition at line 922 of file qabstractfileengine.cpp.
|
virtual |
Destroys the QAbstractFileEngineIterator.
Definition at line 936 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 AndroidAbstractFileEngineIterator, AndroidAbstractFileEngineIterator, AndroidContentFileEngineIterator, CustomIterator, CustomIterator, QAndroidApkFileEngineIterator, QFSFileEngineIterator, QQmlPreviewFileEngineIterator, QQmlPreviewFileEngineIterator, and QResourceFileEngineIterator.
|
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 AndroidAbstractFileEngineIterator, AndroidAbstractFileEngineIterator, QFSFileEngineIterator, and QResourceFileEngineIterator.
Definition at line 1005 of file qabstractfileengine.cpp.
|
pure virtual |
This pure virtual function returns the name of the current directory entry, excluding the path.
Implemented in AndroidAbstractFileEngineIterator, AndroidAbstractFileEngineIterator, AndroidContentFileEngineIterator, QAndroidApkFileEngineIterator, QFSFileEngineIterator, QQmlPreviewFileEngineIterator, QQmlPreviewFileEngineIterator, and QResourceFileEngineIterator.
|
virtual |
Returns the path to the current directory entry.
It's the same as prepending path() to the return value of currentFileName().
Reimplemented in AndroidAbstractFileEngineIterator, AndroidAbstractFileEngineIterator, AndroidContentFileEngineIterator, and QAndroidApkFileEngineIterator.
Definition at line 987 of file qabstractfileengine.cpp.
QDir::Filters QAbstractFileEngineIterator::filters | ( | ) | const |
Returns the entry filters for this iterator.
Definition at line 967 of file qabstractfileengine.cpp.
QStringList QAbstractFileEngineIterator::nameFilters | ( | ) | const |
Returns the name filters for this iterator.
Definition at line 957 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 947 of file qabstractfileengine.cpp.
|
friend |
Definition at line 234 of file qabstractfileengine_p.h.
|
friend |
Definition at line 235 of file qabstractfileengine_p.h.
|
friend |
Definition at line 236 of file qabstractfileengine_p.h.
|
mutableprotected |
Definition at line 230 of file qabstractfileengine_p.h.