All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ConstHashIterator Class Reference

constant iterator class for QoreHashNode, to be only created on the stack More...

`#include <QoreHashNode.h>`

Inheritance diagram for ConstHashIterator:
[legend]
Collaboration diagram for ConstHashIterator:
[legend]

## Public Member Functions

DLLEXPORT | ConstHashIterator (const QoreHashNode *h)
| initializes the iterator with the passed hash
DLLEXPORT | ConstHashIterator (const QoreHashNode &h)
| initializes the iterator with the passed hash
DLLLOCAL | ConstHashIterator (const ConstHashIterator &)
| copy constructor
DLLEXPORT | ~ConstHashIterator ()
| Destroys the iterator.
DLLEXPORT bool | empty () const
| returns true if the hash is empty
DLLEXPORT bool | first () const
| returns true if on the first key of the hash
DLLEXPORT const char * | getKey () const
| returns the current key
DLLEXPORT QoreString * | getKeyString () const
| returns a QoreString for the current key, the caller owns QoreString returned
DLLEXPORT AbstractQoreNode * | getReferencedValue () const
| returns the value of the current key with an incremented reference count
DLLEXPORT const AbstractQoreNode * | getValue () const
| returns the value of the current key
DLLEXPORT bool | last () const
| returns true if on the last key of the hash
DLLEXPORT bool | next ()
| moves to the next element, returns false when there are no more elements to iterate More...
DLLEXPORT bool | prev ()
| moves to the previous element, returns false when there are no more elements to iterate More...
DLLEXPORT void | reset ()
| resets the iterator to its initial state
DLLEXPORT bool | valid () const
| returns true if the iterator is currently pointing at a valid element

## Protected Member Functions

DLLLOCAL ConstHashIterator & | operator= (const HashIterator &)
| this function is not implemented; it is here as a protected function in order to prohibit it from being used

## Detailed Description

constant iterator class for QoreHashNode, to be only created on the stack

ConstHashIterator hi(h);
while (hi.next()) {
QoreStringValueHelper str(hi.getValue());
printf("key: '%s', value: '%s'\n", hi.getKey(), str->getBuffer());
}

## Member Function Documentation

DLLEXPORT bool ConstHashIterator::next | ( |  | ) |

moves to the next element, returns false when there are no more elements to iterate

also moves to the first element if the object has just been initialized after a complete iteration (assuming there is at least one element in the hash)

DLLEXPORT bool ConstHashIterator::prev | ( |  | ) |

moves to the previous element, returns false when there are no more elements to iterate

also moves to the last element if the object has just been initialized after a complete iteration (assuming there is at least one element in the hash)

The documentation for this class was generated from the following file:

- include/qore/QoreHashNode.h (6de6cc3b438610bf03b2bec44a3d7c61f90e3165)