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 bool exists(const UniConfKey &key); 00042 virtual bool haschildren(const UniConfKey &key); 00043 virtual Iter *iterator(const UniConfKey &key); 00044 }; 00045 00046 class UniRegistryGenIter : public UniConfGen::Iter 00047 { 00048 public: 00049 UniRegistryGenIter(UniRegistryGen &gen, const UniConfKey &key, HKEY base); 00050 00052 virtual ~UniRegistryGenIter(); 00053 00058 virtual void rewind(); 00059 00065 virtual bool next(); 00066 00068 virtual UniConfKey key() const; 00069 00071 virtual WvString value() const; 00072 00073 private: 00074 LONG next_key(); 00075 LONG next_value(); 00076 00077 HKEY m_hKey; 00078 enum Enumerating { KEYS, VALUES } m_enumerating; 00079 unsigned m_index; 00080 UniRegistryGen &gen; 00081 const UniConfKey parent; 00082 UniConfKey current_key; 00083 const HKEY m_dontClose; 00084 }; 00085 00086 #endif // __UNICONFREGISTRY_H