QbDbIteratorClass is derived from the QbBaseClass. It is designed to define the interface for a database iterator. It has three virtual methods: More, Next, and Reset (these methods are similar to the OQS iterator functions). The More method returns true if there is more data. The Next method returns the next record. The Reset method resets the iterator so that a future call to Next returns the first record instead of the next one.
This class contains the public enumerated variable nextEnum which indicates the desired cursor position:
To create an instance of QbDbIteratorClass, use the QbDatabaseClass method, CreateIterator. Using this method ensures that the iterator is consistent with the database. The state of an iterator is undefined if an Insert, Delete, or Update is done to the database after the iterator is created.
When you no longer need the iterator, delete it to avoid memory leaks.
This chapter describes the following methods:
You can see coding examples in Appendix C, "Sample Code" on page 185. Other programs are located in the qbic/QbicApi
directory.
This is the constructor for the class.
QbDbIteratorClass( void )
This is the destructor for the class.
virtual ~QbDbIteratorClass( void )
This method returns 1 if there is more data, and 0 if this is the last item in the database.
virtual int More( void )
An integer value: 0 indicates the last item in the database; 1 indicates that there is more data
This method advances to the next record in the database (or to the first record following the Reset method). This method copies key and value pairs of the record to key and value objects of QbDatumClass.
virtual int Next( QbDatumClass &key, QbDatumClass &value, nextEnum nextFlag = NextKey )
An integer value: 0 indicates success; -1 indicates failure
This method resets the iterator so that the first call to the Next method returns the first value in the database.
virtual int Reset( void )
An integer value: 0 indicates success; -1 indicates failure