WvStreams
|
An iterator that iterates through a constant list of keys. More...
#include <unilistiter.h>
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. More... | |
void | autofill (IUniConfGen::Iter *source) |
Automatically fill the contents of this iterator by calling add() for each element of the 'source' iterator. More... | |
virtual void | rewind () |
Rewinds the iterator. More... | |
virtual bool | next () |
Seeks to the next element in the sequence. More... | |
virtual UniConfKey | key () const |
Returns the current key. | |
virtual WvString | value () const |
Returns the value of the current key. More... | |
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.
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().
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().
|
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.
|
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.
|
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().