UniListIter Class Reference

#include <unilistiter.h>

Inheritance diagram for UniListIter:

[legend]
List of all members.

Detailed Description

An iterator that iterates through a constant list of keys.

This is handy if you know the list of keys is relatively short and you don't want to write your own iterator, and/or you know your own object state might change during iteration, so you would have to pre-generate the list of keys anyway.

The creator of the iter is responsible for filling the 'keys' and 'values' lists by calling add(). If the 'values' list runs out of values before 'keys', the remaining values will be retrieved from the given generator (using get()) instead.

Definition at line 43 of file unilistiter.h.

Public Member Functions

 UniListIter (IUniConfGen *_gen)
void add (WvStringParm k, WvStringParm v=noval)
 Add a key/value pair to the list that gets returned by this iterator.
void autofill (IUniConfGen::Iter *source)
 Automatically fill the contents of this iterator by calling add() for each element of the 'source' iterator.
virtual void rewind ()
 Rewinds the iterator.
virtual bool next ()
 Seeks to the next element in the sequence.
virtual UniConfKey key () const
 Returns the current key.
virtual WvString value () const
 Returns the value of the current key.


Member Function Documentation

void UniListIter::add ( WvStringParm  k,
WvStringParm  v = noval 
)

Add a key/value pair to the list that gets returned by this iterator.

If v is 'noval' (the default), the value of the returned item is retrieved by calling get(k). Otherwise the value is v.

This function should only be called by the creator of the iterator, not the end user.

Definition at line 58 of file unilistiter.cc.

References WvList< T >::append(), WvFastString::cstr(), and WvStringCache::get().

Referenced by autofill(), UniTempGen::iterator(), and UniMountGen::iterator().

void UniListIter::autofill ( IUniConfGen::Iter *  source  ) 

Automatically fill the contents of this iterator by calling add() for each element of the 'source' iterator.

This is handy if the source iterator might be unsafe (eg. can't handle set() type operations on the generator without restarting the iteration).

This function should only be called by the creator of the iterator, not the end user.

Definition at line 74 of file unilistiter.cc.

References add().

Referenced by UniTransactionGen::iterator().

void UniListIter::rewind (  )  [virtual]

Rewinds the iterator.

Must be called prior to the first invocation of next().

Implements UniConfGen::Iter.

Definition at line 82 of file unilistiter.cc.

bool UniListIter::next (  )  [virtual]

Seeks to the next element in the sequence.

Returns true if that element exists. Must be called prior to the first invocation of key().

Implements UniConfGen::Iter.

Definition at line 89 of file unilistiter.cc.

WvString UniListIter::value (  )  const [virtual]

Returns the value of the current key.

You could just do a get(), but maybe your generator has a more efficient way.

Implements UniConfGen::Iter.

Definition at line 103 of file unilistiter.cc.

References IUniConfGen::get().


The documentation for this class was generated from the following files:
Generated on Mon Feb 5 10:54:33 2007 for WvStreams by  doxygen 1.5.1