HashIterator Class Reference

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

#include <QoreHashNode.h>

List of all members.

Public Member Functions

DLLEXPORT HashIterator (QoreHashNode *h)
 initializes the iterator with the passed hash
DLLEXPORT HashIterator (QoreHashNode &h)
 initializes the iterator with the passed hash
DLLEXPORT bool next ()
 moves to the next element, returns false when there are no more elements to iterate
DLLEXPORT const char * getKey () const
 returns the current key
DLLEXPORT QoreStringgetKeyString () const
 returns a QoreString for the current key, the caller owns QoreString returned
DLLEXPORT AbstractQoreNodegetValue () const
 returns the value of the current key
DLLEXPORT AbstractQoreNodetakeValueAndDelete ()
 deletes the key from the hash and returns the value, caller owns the reference
DLLEXPORT void deleteKey (ExceptionSink *xsink)
 deletes the key from the hash and dereferences the value
DLLEXPORT AbstractQoreNode ** getValuePtr () const
 returns a pointer to a pointer to the current value so the value of the key may be manipulated externally
DLLEXPORT AbstractQoreNodegetReferencedValue () const
 returns the value of the current key with an incremented reference count
DLLEXPORT bool first () const
 returns true if on the first key of the hash
DLLEXPORT bool last () const
 returns true if on the last key of the hash


Detailed Description

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

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

Member Function Documentation

DLLEXPORT bool HashIterator::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 void HashIterator::deleteKey ( ExceptionSink xsink  ) 

deletes the key from the hash and dereferences the value

the pointer is moved to the previous element (or before the beginning) so that the next call to next() will put the pointer on the element after the one being deleted


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

Generated on Mon Oct 26 09:09:50 2009 for Qore Programming Language by  doxygen 1.5.6