Qyoto  4.0.7
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties
QtCore.QAbstractFileEngineIterator Class Reference

The QAbstractFileEngineIterator class provides an iterator interface for custom file engines. More...

Inheritance diagram for QtCore.QAbstractFileEngineIterator:
Collaboration diagram for QtCore.QAbstractFileEngineIterator:

Public Types

enum  EntryInfoType
 

Public Member Functions

 QAbstractFileEngineIterator (QDir.Filter filters, System.Collections.Generic.List< string > nameFilters)
  More...
 
virtual void CreateProxy ()
 
new void Dispose ()
 

Protected Member Functions

 QAbstractFileEngineIterator (System.Type dummy)
 
virtual object EntryInfo (QAbstractFileEngineIterator.EntryInfoType type)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

virtual QFileInfo CurrentFileInfo [get]
  More...
 
virtual string CurrentFileName [get]
  More...
 
string CurrentFilePath [get]
  More...
 
QDir.Filter Filters [get]
  More...
 
virtual bool HasNext [get]
  More...
 
System.Collections.Generic.List
< string > 
NameFilters [get]
  More...
 
virtual string Next [get]
  More...
 
string Path [get]
  More...
 
virtual System.IntPtr SmokeObject [get, set]
 

Detailed Description

The QAbstractFileEngineIterator class provides an iterator interface for custom file engines.

If all you want is to iterate over entries in a directory, see QDirIterator instead. This class is only for custom file engine authors.

QAbstractFileEngineIterator is a unidirectional single-use virtual iterator that plugs into QDirIterator, providing transparent proxy iteration for custom file engines.

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 *

CustomFileEngine::beginEntryList(QDir::Filters filters, const QStringList &filterNames)

{

return new CustomFileEngineIterator(filters, filterNames);

}

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 hasNext() returns true if the current directory has at least one more entry (i.e., the directory name is valid and accessible, and we have not reached the end of the entry list), and false otherwise. Reimplement next() to seek to the next entry.

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.

class CustomIterator : public QAbstractFileEngineIterator

{

public:

CustomIterator(const QStringList &nameFilters, QDir::Filters filters)

: QAbstractFileEngineIterator(nameFilters, filters), index(0)

{

// In a real iterator, these entries are fetched from the

// file system based on the value of path().

entries << "entry1" << "entry2" << "entry3";

}

bool hasNext() const

{

return index < entries.size() - 1;

}

QString next()

{

if (!hasNext())

return QString();

++index;

return currentFilePath();

}

QString currentFileName()

{

return entries.at(index);

}

private:

QStringList entries;

int index;

};

Note: QAbstractFileEngineIterator does not deal with QDir::IteratorFlags; it simply returns entries for a single directory.

See also QDirIterator.

Member Enumeration Documentation

Constructor & Destructor Documentation

QtCore.QAbstractFileEngineIterator.QAbstractFileEngineIterator ( System.Type  dummy)
protected
QtCore.QAbstractFileEngineIterator.QAbstractFileEngineIterator ( QDir.Filter  filters,
System.Collections.Generic.List< string >  nameFilters 
)

Constructs a QAbstractFileEngineIterator, using the entry filters filters, and wildcard name filters nameFilters.

Here is the call graph for this function:

Member Function Documentation

virtual void QtCore.QAbstractFileEngineIterator.CreateProxy ( )
virtual

Here is the caller graph for this function:

new void QtCore.QAbstractFileEngineIterator.Dispose ( )
virtual object QtCore.QAbstractFileEngineIterator.EntryInfo ( QAbstractFileEngineIterator.EntryInfoType  type)
protectedvirtual

Member Data Documentation

SmokeInvocation QtCore.QAbstractFileEngineIterator.interceptor
protected

Property Documentation

virtual QFileInfo QtCore.QAbstractFileEngineIterator.CurrentFileInfo
get

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.

See also currentFileName().

virtual string QtCore.QAbstractFileEngineIterator.CurrentFileName
get

This pure virtual function returns the name of the current directory entry, excluding the path.

See also currentFilePath().

string QtCore.QAbstractFileEngineIterator.CurrentFilePath
get

Returns the path to the current directory entry. It's the same as prepending path() to the return value of currentFileName().

See also currentFileName().

QDir.Filter QtCore.QAbstractFileEngineIterator.Filters
get

Returns the entry filters for this iterator.

See also QDir::filter(), nameFilters(), and path().

virtual bool QtCore.QAbstractFileEngineIterator.HasNext
get

This pure virtual function returns true if there is at least one more entry in the current directory (i.e., the iterator path is valid and accessible, and the iterator has not reached the end of the entry list).

See also QDirIterator::hasNext().

System.Collections.Generic.List<string> QtCore.QAbstractFileEngineIterator.NameFilters
get

Returns the name filters for this iterator.

See also QDir::nameFilters(), filters(), and path().

virtual string QtCore.QAbstractFileEngineIterator.Next
get

This pure virtual function advances the iterator to the next directory entry, and returns the file path to the current entry.

This function can optionally make use of nameFilters() and filters() to optimize its performance.

Reimplement this function in a subclass to advance the iterator.

See also QDirIterator::next().

string QtCore.QAbstractFileEngineIterator.Path
get

Returns the path for this iterator. QDirIterator is responsible for assigning this path; it cannot change during the iterator's lifetime.

See also nameFilters() and filters().

virtual System.IntPtr QtCore.QAbstractFileEngineIterator.SmokeObject
getset