WvStreams
unilistiter.cc
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 2002 Net Integration Technologies, Inc.
4 *
5 * A simple implementation of a UniConfGen iterator. See unilistiter.h.
6 */
7#include "unilistiter.h"
8
9UniListIter::UniListIter(IUniConfGen *_gen)
10 : ki(keys), vi(values)
11{
12 gen = _gen;
13}
14
15
17{
18 UniConfKey *nk = new UniConfKey(k);
19 keys.append(nk, true);
20 keylook.add(nk, false);
21 if (!v.isnull())
22 values.append(new WvString(scache.get(v)), true);
23}
24
25
26void UniListIter::autofill(IUniConfGen::Iter *_source)
27{
28 IUniConfGen::Iter &source(*_source);
29 for (source.rewind(); source.next(); )
30 add(source.key(), source.value());
31}
32
33
35{
36 ki.rewind();
37 vi.rewind();
38}
39
40
42{
43 if (vi.cur())
44 vi.next();
45 return ki.next();
46}
47
48
50{
51 return *ki;
52}
53
54
56{
57 if (vi.cur())
58 return *vi;
59 else
60 return gen->get(*ki);
61}
An abstract data container that backs a UniConf tree.
virtual WvString get(const UniConfKey &key)=0
Fetches a string value for a key from the registry.
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
virtual void rewind()
Rewinds the iterator.
void autofill(IUniConfGen::Iter *source)
Automatically fill the contents of this iterator by calling add() for each element of the 'source' it...
void add(const UniConfKey &k, WvStringParm v=WvString::null)
Add a key/value pair to the list that gets returned by this iterator.
virtual WvString value() const
Returns the value of the current key.
virtual UniConfKey key() const
Returns the current key.
virtual bool next()
Seeks to the next element in the sequence.
A WvFastString acts exactly like a WvString, but can take (const char *) strings without needing to a...
bool isnull() const
returns true if this string is null
WvString get(WvStringParm s)
Get a shared string corresponding to 's'.
WvString is an implementation of a simple and efficient printable-string class.