00001 /* 00002 * Copyright (c) 1998, University of Amsterdam, The Netherlands. 00003 * All rights reserved. 00004 * 00005 * 00006 * Author(s): 00007 * Dennis Koelma (koelma@wins.uva.nl) 00008 * Edo Poll (poll@wins.uva.nl) 00009 */ 00010 00011 #ifndef HxRegistry_h 00012 #define HxRegistry_h 00013 #pragma warning (disable : 4786) 00014 00015 #include "HxIoFwd.h" 00016 #include "HxString.h" 00017 #include "HxRegKey.h" 00018 00019 #include "HxTracedObject.h" 00020 00021 00024 class L_HXBASIS HxRegistry TRACED_OBJECT 00025 { 00026 public: 00028 HxRegistry(); 00029 00031 ~HxRegistry(); 00032 00034 static HxRegistry& instance(); 00035 00037 int import(HxString fileName); 00039 int import(const char* argv[]); 00041 int exportText(STD_OSTREAM& out) const; 00045 int exportC(STD_OSTREAM& out, HxString label) const; 00046 00048 HxRegKey* insertKey(HxString path); 00050 void eraseKey(HxString path); 00052 HxRegKey* findKey(HxString path) const; 00053 00055 void insertValue(HxString path, const HxRegData&); 00057 void insertValue(HxString path, HxString data); 00059 void insertValue(HxString path, int data); 00061 void eraseValue(HxString path); 00062 00064 HxString findValue(HxString path) const; 00066 int valueExists(HxString path) const; 00067 00069 HxRegKey* setCursorKey(HxString path); 00071 HxRegKey* setCursorUp(); 00073 HxRegKey* getCursorKey() const; 00075 HxString getCursorName() const; 00076 00078 HxRegKey* setRootKey(); 00080 HxRegKey* getRootKey() const; 00081 00083 STD_OSTREAM& put(STD_OSTREAM&) const; 00084 00085 private: 00086 HxRegistry(const HxRegistry&); 00087 const HxRegistry& operator=(const HxRegistry&); 00088 00089 HxString getCannonicName(HxString) const; 00090 const HxRegValue* doFindValue(HxString path) const; 00091 00092 00093 #pragma warning (disable : 4251) 00094 HxRegKey* _rootKey; 00095 HxRegKey* _cursorKey; 00096 00097 HxString _cursorName; 00098 #pragma warning (default : 4251) 00099 }; 00100 00101 inline STD_OSTREAM& 00102 operator<<(STD_OSTREAM& os, const HxRegistry& reg) 00103 { 00104 return reg.put(os); 00105 } 00106 00107 inline void 00108 HxRegistry::insertValue(HxString path, HxString data) 00109 { 00110 insertValue(path, HxRegData(data)); 00111 } 00112 00113 inline void 00114 HxRegistry::insertValue(HxString path, int data) 00115 { 00116 insertValue(path, HxRegData(data)); 00117 } 00118 00119 inline HxRegKey* 00120 HxRegistry::getCursorKey() const 00121 { 00122 return _cursorKey; 00123 } 00124 00125 inline HxString 00126 HxRegistry::getCursorName() const 00127 { 00128 return _cursorName; 00129 } 00130 00131 inline HxRegKey* 00132 HxRegistry::getRootKey() const 00133 { 00134 return _rootKey; 00135 } 00136 00137 inline HxRegKey* 00138 HxRegistry::setRootKey() 00139 { 00140 return _cursorKey = _rootKey; 00141 } 00142 00143 #endif