wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / unilistiter.h
blob4de187ab79ef140e94ad926a876da7ec9169de7a
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002-2005 Net Integration Technologies, Inc.
4 *
5 * A simple implementation of a UniConfGen iterator.
6 */
7 #ifndef __UNILISTITER_H
8 #define __UNILISTITER_H
10 #include "uniconfgen.h"
11 #include "wvscatterhash.h"
12 #include "wvstringcache.h"
13 #include "wvstringlist.h"
15 /**
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
20 * of keys anyway.
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
29 IUniConfGen *gen;
31 DeclareWvScatterTable(UniConfKey);
32 UniConfKeyTable keylook;
35 UniConfKeyList keys;
36 WvStringList values;
38 UniConfKeyList::Iter ki;
39 WvStringList::Iter vi;
41 WvStringCache scache;
43 public:
44 UniListIter(IUniConfGen *_gen);
46 /**
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,
52 * not the end user.
54 void add(const UniConfKey &k, WvStringParm v = WvString::null);
56 /**
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,
63 * not the end user.
65 void autofill(IUniConfGen::Iter *source);
67 /***** Overridden members *****/
68 virtual void rewind();
69 virtual bool next();
70 virtual UniConfKey key() const;
71 virtual WvString value() const;
74 #endif // __UNILISTITER_H