unilistiter.h

00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 2002-2005 Net Integration Technologies, Inc.
00004  * 
00005  * A simple implementation of a UniConfGen iterator.
00006  */
00007 #ifndef __UNILISTITER_H
00008 #define __UNILISTITER_H
00009 
00010 #include "uniconfgen.h"
00011 #include "wvscatterhash.h"
00012 #include "wvstringcache.h"
00013 
00014 // FIXME: put this class definition somewhere else
00015 class UniSmartKey
00016 {
00017 public:
00018     const UniSmartKey *parent;
00019     UniConfKey child;
00020     
00021     UniSmartKey(const UniSmartKey *_parent, const UniConfKey &_child);
00022     
00023     UniConfKey key() const;
00024     bool operator== (const UniSmartKey &k) const;
00025 };
00026 
00027 
00028 unsigned WvHash(const UniSmartKey &k);
00029 
00030 
00043 class UniListIter : public UniConfGen::Iter
00044 {
00045     IUniConfGen *gen;
00046     
00047     DeclareWvScatterTable(UniSmartKey);
00048     UniSmartKeyTable keylook;
00049 
00050     WvList<UniSmartKey> keys;
00051     WvList<WvString> values;
00052     bool no_more_values;
00053     
00054     WvList<UniSmartKey>::Iter ki;
00055     WvList<WvString>::Iter vi;
00056     
00057     WvStringCache scache;
00058     
00059     static const WvString noval;
00060     
00061     UniSmartKey *new_smart_key(const UniConfKey &k);
00062     
00063 public:
00064     UniListIter(IUniConfGen *_gen);
00065     
00074     void add(WvStringParm k, WvStringParm v = noval);
00075     
00085     void autofill(IUniConfGen::Iter *source);
00086 
00087     /***** Overridden members *****/
00088     virtual void rewind();
00089     virtual bool next();
00090     virtual UniConfKey key() const;
00091     virtual WvString value() const;
00092 };
00093 
00094 #endif // __UNILISTITER_H

Generated on Fri Oct 5 18:20:26 2007 for WvStreams by  doxygen 1.5.3