Qore Programming Language Reference Manual 1.19.2
Loading...
Searching...
No Matches
Qore::ObjectPairReverseIterator Class Reference

This class an iterator class for objects. More...

#include <QC_ObjectPairReverseIterator.dox.h>

Inheritance diagram for Qore::ObjectPairReverseIterator:
[legend]

Public Member Methods

 constructor (object o)
 Creates the object iterator object. More...
 
 constructor ()
 Creates an empty iterator object. More...
 
 copy ()
 Creates a copy of the ObjectPairReverseIterator object, iterating the same object as the original and in the same position. More...
 
hash< auto > getValue ()
 returns a hash with the current key and value (a hash with 2 keys: "key" and "value") or throws an INVALID-ITERATOR exception if the iterator is invalid More...
 
- Public Member Methods inherited from Qore::ObjectReverseIterator
 constructor (object o)
 Creates the object iterator object. More...
 
 constructor ()
 Creates an empty iterator object. More...
 
 copy ()
 Creates a copy of the ObjectReverseIterator object, iterating the same object as the original and in the same position. More...
 
bool first ()
 returns True if on the last element of the object More...
 
bool last ()
 returns True if on the first element of the object More...
 
bool next ()
 Moves the current position to the previous element in the object; 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 object if the object is not empty. More...
 
bool prev ()
 Moves the current position to the next element in the object; 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 object if the object is not empty. More...
 
- Public Member Methods inherited from Qore::ObjectIterator
 constructor (object o)
 Creates the object iterator object. More...
 
 constructor ()
 Creates an empty object iterator object. More...
 
 copy ()
 Creates a copy of the ObjectIterator object, iterating the same object as the original and in the same position. More...
 
- Public Member Methods inherited from Qore::HashIterator
 constructor (hash< auto > h)
 Creates the hash iterator object. More...
 
 constructor ()
 Creates an empty hash iterator object. More...
 
 copy ()
 Creates a copy of the HashIterator object, iterating the same object as the original and in the same position. More...
 
bool empty ()
 returns True if the hash is empty; False if not More...
 
bool first ()
 returns True if on the first element of the hash More...
 
string getKey ()
 returns the current key value or throws an INVALID-ITERATOR exception if the iterator is invalid More...
 
auto getKeyValue ()
 returns the current value of the current hash key being iterated or throws an INVALID-ITERATOR exception if the iterator is invalid More...
 
auto getValue ()
 returns the current key value or throws an INVALID-ITERATOR exception if the iterator is invalid More...
 
hash< auto > getValuePair ()
 returns a hash with the current key and value (a hash with 2 keys: "key" and "value") or throws an INVALID-ITERATOR exception if the iterator is invalid More...
 
bool last ()
 returns True if on the last element of the hash More...
 
bool next ()
 Moves the current position to the next element in the hash; 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 hash if the hash is not empty. More...
 
bool prev ()
 Moves the current position to the previous element in the hash; 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 hash if the hash is not empty. More...
 
 reset ()
 Reset the iterator instance to its initial state. More...
 
bool valid ()
 returns True if the iterator is currently pointing at a valid element, False if not More...
 
abstract bool prev ()
 Moves the current position to the previous element; returns False if there are no more elements. More...
 
abstract auto getValue ()
 returns the current value More...
 
abstract bool next ()
 Moves the current position to the next element; returns False if there are no more elements. More...
 
abstract bool valid ()
 returns True if the iterator is currently pointing at a valid element, False if not More...
 
abstract bool empty ()
 returns True if the object to iterate is empty; False if not More...
 
abstract bool first ()
 returns True if on the first element More...
 
abstract bool last ()
 returns True if on the last element More...
 

Detailed Description

This class an iterator class for objects.

Call ObjectPairReverseIterator::next() to iterate through the object in reverse order; do not use the iterator if ObjectPairReverseIterator::next() returns False. A object can be iterated in reverse order by calling ObjectPairReverseIterator::prev() instead of ObjectPairReverseIterator::next()

Example: ObjectPairReverseIterator basic usage
class Class1 {
public {
int attr1;
date attr2;
}
constructor() {
attr1 = 1;
attr2 = now();
}
}
Class1 o();
ObjectPairReverseIterator it(o);
while (it.next()) {
printf("iter: %n\n", it.getValue());
}
iter: hash: (key : "attr2", value : 2013-04-17 16:38:31 Wed +02:00 (CEST))
iter: hash: (key : "attr1", value : 1)
Note
See also
ObjectPairIterator

Member Function Documentation

◆ constructor() [1/2]

Qore::ObjectPairReverseIterator::constructor ( )

Creates an empty iterator object.

Example:
*object obj = get_object_or_nothing();
ObjectPairReverseIterator i(obj);

◆ constructor() [2/2]

Qore::ObjectPairReverseIterator::constructor ( object  o)

Creates the object iterator object.

Parameters
othe object to iterate
Example:
ObjectPairReverseIterator i(obj);

◆ copy()

Qore::ObjectPairReverseIterator::copy ( )

Creates a copy of the ObjectPairReverseIterator object, iterating the same object as the original and in the same position.

Example:
ObjectPairReverseIterator ni = i.copy();

◆ getValue()

hash< auto > Qore::ObjectPairReverseIterator::getValue ( )
virtual

returns a hash with the current key and value (a hash with 2 keys: "key" and "value") or throws an INVALID-ITERATOR exception if the iterator is invalid

Returns
a hash with the current key and value (a hash with 2 keys: "key" and "value") or throws an INVALID-ITERATOR exception if the iterator is invalid
Code Flags:
RET_VALUE_ONLY
Example:
foreach hash<auto> h in (new ObjectPairReverseIterator(obj))
printf("%s: %y\n", h.key, h.value);
Exceptions
INVALID-ITERATORthe iterator is not pointing at a valid element
ITERATOR-THREAD-ERRORthis exception is thrown if this method is called from any thread other than the thread that created the object
Since
Qore 0.8.6.2

Reimplemented from Qore::HashIterator.