WvStreams
uniregistrygen.h
00001 /* -*- Mode: C++ -*-
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2003 Net Integration Technologies, Inc.
00004  *
00005  * A generator that exposes the windows registry.
00006  *
00007  * When linking statically, use the following #pragma to ensure this 
00008  * generator gets registered:
00009  * #pragma comment(linker, "/include:?UniRegistryGenMoniker@@3V?$WvMoniker@VUniConfGen@@@@A")
00010  */
00011 #ifndef __UNICONFREGISTRY_H
00012 #define __UNICONFREGISTRY_H
00013 
00014 #include "uniconfgen.h"
00015 #include "wvlog.h"
00016 #include "windows.h"
00017 
00024 class UniRegistryGen : public UniConfGen
00025 {
00026     WvLog m_log;
00027     HKEY m_hRoot;
00028 
00029 protected:
00030     virtual void flush_buffers() { }
00031 
00032 public:
00033     UniRegistryGen(WvString _base);
00034     virtual ~UniRegistryGen();
00035 
00036     /***** Overridden methods *****/
00037     
00038     virtual bool isok();
00039     virtual WvString get(const UniConfKey &key);
00040     virtual void set(const UniConfKey &key, WvStringParm value);
00041     virtual void setv(const UniConfPairList &pairs);
00042     virtual bool exists(const UniConfKey &key);
00043     virtual bool haschildren(const UniConfKey &key);
00044     virtual Iter *iterator(const UniConfKey &key);
00045 };
00046 
00047 class UniRegistryGenIter : public UniConfGen::Iter
00048 {
00049 public:
00050     UniRegistryGenIter(UniRegistryGen &gen, const UniConfKey &key, HKEY base);
00051 
00053     virtual ~UniRegistryGenIter();
00054 
00059     virtual void rewind();
00060 
00066     virtual bool next();
00067 
00069     virtual UniConfKey key() const;
00070 
00072     virtual WvString value() const;
00073 
00074 private:
00075     LONG next_key();
00076     LONG next_value();
00077 
00078     HKEY m_hKey;
00079     enum Enumerating { KEYS, VALUES } m_enumerating;
00080     unsigned m_index;
00081     UniRegistryGen &gen;
00082     const UniConfKey parent;
00083     UniConfKey current_key;
00084     const HKEY m_dontClose;
00085 };
00086 
00087 #endif // __UNICONFREGISTRY_H