2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002-2005 Net Integration Technologies, Inc.
5 * A simple implementation of a UniConfGen iterator.
7 #ifndef __UNILISTITER_H
8 #define __UNILISTITER_H
10 #include "uniconfgen.h"
11 #include "wvscatterhash.h"
12 #include "wvstringcache.h"
13 #include "wvstringlist.h"
16 * An iterator that iterates through a constant list of keys. This is
17 * handy if you know the list of keys is relatively short and you don't
18 * want to write your own iterator, and/or you know your own object state
19 * might change during iteration, so you would have to pre-generate the list
22 * The creator of the iter is responsible for filling the 'keys' and 'values'
23 * lists by calling add(). If the 'values' list runs out of values before
24 * 'keys', the remaining values will be retrieved from the given generator
25 * (using get()) instead.
27 class UniListIter
: public UniConfGen::Iter
31 DeclareWvScatterTable(UniConfKey
);
32 UniConfKeyTable keylook
;
38 UniConfKeyList::Iter ki
;
39 WvStringList::Iter vi
;
44 UniListIter(IUniConfGen
*_gen
);
47 * Add a key/value pair to the list that gets returned by this iterator.
48 * If v is 'noval' (the default), the value of the returned item is
49 * retrieved by calling get(k). Otherwise the value is v.
51 * This function should only be called by the creator of the iterator,
54 void add(const UniConfKey
&k
, WvStringParm v
= WvString::null
);
57 * Automatically fill the contents of this iterator by calling add()
58 * for each element of the 'source' iterator. This is handy if the
59 * source iterator might be unsafe (eg. can't handle set() type
60 * operations on the generator without restarting the iteration).
62 * This function should only be called by the creator of the iterator,
65 void autofill(IUniConfGen::Iter
*source
);
67 /***** Overridden members *****/
68 virtual void rewind();
70 virtual UniConfKey
key() const;
71 virtual WvString
value() const;
74 #endif // __UNILISTITER_H