#include <HxRegistry.h>
Public Methods | |
| HxRegistry () | |
| Constructor. More... | |
| ~HxRegistry () | |
| Destructor. More... | |
| int | import (HxString fileName) |
| Import registry data from file. More... | |
| int | import (const char *argv[]) |
| Import registry data from argument strings. More... | |
| int | exportText (STD_OSTREAM &out) const |
| Export registry data as text to stream. More... | |
| int | exportC (STD_OSTREAM &out, HxString label) const |
| Export registry data in format for use with HxRegistryImporter. More... | |
| HxRegKey * | insertKey (HxString path) |
| Insert key. More... | |
| void | eraseKey (HxString path) |
| Erase key. More... | |
| HxRegKey * | findKey (HxString path) const |
| Find key. More... | |
| void | insertValue (HxString path, const HxRegData &) |
| Insert value. More... | |
| void | insertValue (HxString path, HxString data) |
| Insert value. More... | |
| void | insertValue (HxString path, int data) |
| Insert value. More... | |
| void | eraseValue (HxString path) |
| Erase value. More... | |
| HxString | findValue (HxString path) const |
| Find value. More... | |
| int | valueExists (HxString path) const |
| Check whether value exists. More... | |
| HxRegKey * | setCursorKey (HxString path) |
| Set cursor key. More... | |
| HxRegKey * | setCursorUp () |
| Move cursor key up. More... | |
| HxRegKey * | getCursorKey () const |
| Get cursor key. More... | |
| HxString | getCursorName () const |
| Get cursor name. More... | |
| HxRegKey * | setRootKey () |
| Set root key. More... | |
| HxRegKey * | getRootKey () const |
| Get root key. More... | |
| STD_OSTREAM & | put (STD_OSTREAM &) const |
| Put registry on stream. More... | |
Static Public Methods | |
| HxRegistry & | instance () |
| Access to the single instance of the registry. More... | |
|
|
Constructor.
00028 {
00029 _rootKey = HxRegKey::createRootKey();
00030 _cursorKey = _rootKey;
00031 }
|
|
|
Destructor.
00041 {
00042 delete _rootKey;
00043 }
|
|
|
Access to the single instance of the registry.
00047 {
00048 static HxRegistry theRegistry;
00049 return theRegistry;
00050 }
|
|
|
Import registry data from file.
00088 {
00089 STD_IFSTREAM inStream(fileName.c_str());
00090
00091 if (!inStream) {
00092 HxEnvironment::instance()->errorStream()
00093 << "Cannot open file " << fileName << STD_ENDL;
00094 HxEnvironment::instance()->flush();
00095 return 0;
00096 }
00097
00098 HxStreamCharReader reader(inStream);
00099
00100 HxRegParser::instance().setReader(reader);
00101 HxRegParser::instance().setFileName(fileName);
00102 HxRegParser::instance().setRegistry(*this);
00103 HxRegParser::instance().parse();
00104 return 1;
00105 }
|
|
|
Import registry data from argument strings.
00109 {
00110 if (!*argv)
00111 return 0;
00112 HxString fileName(argv[0]);
00113 fileName += "::";
00114 fileName += argv[1];
00115 argv += 2;
00116 HxArgvCharReader reader(argv);
00117
00118 HxRegParser::instance().setReader(reader);
00119 HxRegParser::instance().setFileName(fileName);
00120 HxRegParser::instance().setRegistry(*this);
00121 HxRegParser::instance().parse();
00122 return 1;
00123 }
|
|
|
Export registry data as text to stream.
00127 {
00128 _rootKey->put(out);
00129 return 1;
00130 }
|
|
||||||||||||
|
Export registry data in format for use with HxRegistryImporter.
00134 {
00135 out << "static const char* " << label << "[] = {" << STD_ENDL;
00136 out << "__FILE__" << "," << STD_ENDL;
00137 out << "\"" << label << "\"," << STD_ENDL;
00138 _rootKey->put(out, "", hxTrue);
00139 out << "(char*)0" << STD_ENDL << "};" << STD_ENDL;
00140 return 1;
00141 }
|
|
|
Insert key.
00145 {
00146 HxStringList nameList;
00147 splitString(name, '/', std::back_inserter(nameList));
00148 HxStringListConstIter namePtr = nameList.begin();
00149 HxRegKey* key = _cursorKey;
00150
00151 if ((namePtr != nameList.end()) && (*namePtr).empty()) {
00152 key = _rootKey;
00153 namePtr++;
00154 }
00155
00156 for (;namePtr != nameList.end(); namePtr++) {
00157 if ((*namePtr).empty())
00158 continue;
00159 key = key->insertKey(*namePtr);
00160 }
00161 return key;
00162 }
|
|
|
Erase key.
|
|
|
Find key.
|
|
||||||||||||
|
Insert value.
00188 {
00189 HxStringList nameList;
00190 int n = splitString(path, '/', std::back_inserter(nameList));
00191 if (n <= 0)
00192 return;
00193 HxString name = nameList.back();
00194 if (name.empty())
00195 return;
00196 nameList.pop_back();
00197 HxRegKey* key = _rootKey->findKey(nameList.begin(), nameList.end());
00198 if (!key)
00199 return;
00200 key->insertValue(name, data);
00201 }
|
|
||||||||||||
|
Insert value.
00109 {
00110 insertValue(path, HxRegData(data));
00111 }
|
|
||||||||||||
|
Insert value.
00115 {
00116 insertValue(path, HxRegData(data));
00117 }
|
|
|
Erase value.
00237 {
00238 HxStringList nameList;
00239 int n = splitString(path, '/', std::back_inserter(nameList));
00240 if (n <= 0)
00241 return;
00242 HxString name = nameList.back();
00243 if (name.empty())
00244 return;
00245 nameList.pop_back();
00246 HxRegKey* key = _rootKey->findKey(nameList.begin(), nameList.end());
00247 if (key)
00248 key->eraseValue(name);
00249 }
|
|
|
Find value.
00220 {
00221 const HxRegValue* val = doFindValue(path);
00222 if (val)
00223 return val->getData().toString();
00224 else
00225 return HxString("");
00226 }
|
|
|
Check whether value exists.
00230 {
00231 const HxRegValue* val = doFindValue(path);
00232 return val ? 1 : 0;
00233 }
|
|
|
Set cursor key.
|
|
|
Move cursor key up.
00262 {
00263 _cursorKey = _cursorKey->getParent();
00264 return _cursorKey;
00265 }
|
|
|
Get cursor key.
00121 {
00122 return _cursorKey;
00123 }
|
|
|
Get cursor name.
00127 {
00128 return _cursorName;
00129 }
|
|
|
Set root key.
00139 {
00140 return _cursorKey = _rootKey;
00141 }
|
|
|
Get root key.
00133 {
00134 return _rootKey;
00135 }
|
|
|
Put registry on stream.
00269 {
00270 return _rootKey->put(os);
00271 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001