WvStreams
Public Member Functions
UniListIter Class Reference

An iterator that iterates through a constant list of keys. More...

#include <unilistiter.h>

Inheritance diagram for UniListIter:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 UniListIter (IUniConfGen *_gen)
void add (const UniConfKey &k, WvStringParm v=WvString::null)
 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.

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 27 of file unilistiter.h.


Member Function Documentation

void UniListIter::add ( const UniConfKey k,
WvStringParm  v = WvString::null 
)

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 16 of file unilistiter.cc.

References WvStringCache::get(), and WvFastString::isnull().

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 26 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 34 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 41 of file unilistiter.cc.

UniConfKey UniListIter::key ( ) const [virtual]

Returns the current key.

Implements UniConfGen::Iter.

Definition at line 49 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 55 of file unilistiter.cc.

References IUniConfGen::get().


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