Qore Programming Language Reference Manual
1.8.0
|
This class a reverse iterator class for hashes of lists as returned by Qore::SQL::Datasource::select() and Qore::SQL::DatasourcePool::select(), both of which return hashes with keys giving column names where the key values are lists of column values. More...
Public Member Methods | |
constructor (hash< auto > h) | |
Creates the hash list iterator object. More... | |
constructor () | |
Creates an empty hash list iterator object. More... | |
copy () | |
Creates a copy of the HashListReverseIterator object, iterating the same object as the original and in the same position. More... | |
bool | first () |
returns True if on the first element being iterated in the list (ie the last element in the list) More... | |
bool | last () |
returns True if on the last element being iterated in the list (ie the first element in the list) More... | |
auto | memberGate (string key) |
This method allows the iterator to be dereferenced directly as a hash for the current row being iterated, as memberGate methods are called implicitly when an unknown member is accessed from outside the class. More... | |
bool | next () |
Moves the current position to the next element in the result list; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the first element in the list if the list is not empty. More... | |
bool | prev () |
Moves the current position to the previous element in the result list; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the last element in the list if the list is not empty. More... | |
Public Member Methods inherited from Qore::HashListIterator | |
constructor (hash< auto > h) | |
Creates the hash list iterator object. More... | |
constructor () | |
Creates an empty hash list iterator object. More... | |
copy () | |
Creates a copy of the HashListIterator object, iterating the same object as the original and in the same position. More... | |
bool | empty () |
returns True if the result list is empty; False if not More... | |
auto | getKeyValue (string key) |
Returns the current value for the column given as an argument. More... | |
hash< auto > | getRow () |
returns the current row value as a hash or throws an INVALID-ITERATOR exception if the iterator is invalid More... | |
hash< auto > | getValue () |
returns the current row value as a hash or throws an INVALID-ITERATOR exception if the iterator is invalid More... | |
int | index () |
returns the current iterator position in the list or -1 if not pointing at a valid element More... | |
int | max () |
returns the number of elements in the list More... | |
auto | memberGate (string key) |
This method allows the iterator to be dereferenced directly as a hash for the current row being iterated, as memberGate methods are called implicitly when an unknown member is accessed from outside the class. More... | |
reset () | |
Reset the iterator instance to its initial state. More... | |
bool | set (int pos) |
sets the new position in the result list; if the position is invalid then the method returns False, meaning the iterator is not valid, otherwise it returns True More... | |
bool | valid () |
returns True if the iterator is currently pointing at a valid element, False if not More... | |
This class a reverse iterator class for hashes of lists as returned by Qore::SQL::Datasource::select() and Qore::SQL::DatasourcePool::select(), both of which return hashes with keys giving column names where the key values are lists of column values.
Like the Qore::HashListIterator class, this class can be used as a more flexible alternative to the context statement, except this class will iterate the result list in reverse order.
Call HashListReverseIterator::next() to iterate through the lists of column values assigned to each hash key in reverse order; do not use the iterator if HashListReverseIterator::next() returns False. A result list can be iterated in reverse order by calling HashListReverseIterator::prev() instead of HashListReverseIterator::next()
ITERATOR-THREAD-ERROR
to be thrown.Qore::HashListReverseIterator::constructor | ( | ) |
Creates an empty hash list iterator object.
Qore::HashListReverseIterator::constructor | ( | hash< auto > | h | ) |
Creates the hash list iterator object.
h | the hash of lists to iterate |
Qore::HashListReverseIterator::copy | ( | ) |
Creates a copy of the HashListReverseIterator object, iterating the same object as the original and in the same position.
|
virtual |
returns True if on the first element being iterated in the list (ie the last element in the list)
Reimplemented from Qore::HashListIterator.
|
virtual |
returns True if on the last element being iterated in the list (ie the first element in the list)
Reimplemented from Qore::HashListIterator.
auto Qore::HashListReverseIterator::memberGate | ( | string | key | ) |
This method allows the iterator to be dereferenced directly as a hash for the current row being iterated, as memberGate methods are called implicitly when an unknown member is accessed from outside the class.
key | the column name for the value to retrieve |
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
INVALID-ITERATOR | the iterator is not pointing at a valid element |
HASHLISTITERATOR-ERROR | the hash key given has a value that is a list with a size that does not match the expected list size |
|
virtual |
Moves the current position to the next element in the result list; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the first element in the list if the list is not empty.
This method will return True again after it returns False once if list is not empty, otherwise it will always return False. The iterator object should not be used after this method returns False
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
Reimplemented from Qore::HashListIterator.
|
virtual |
Moves the current position to the previous element in the result list; returns False if there are no more elements; if the iterator is not pointing at a valid element before this call, the iterator will be positioned on the last element in the list if the list is not empty.
This method will return True again after it returns False once if the list is not empty, otherwise it will always return False. The iterator object should not be used after this method returns False
ITERATOR-THREAD-ERROR | this exception is thrown if this method is called from any thread other than the thread that created the object |
Reimplemented from Qore::HashListIterator.