Insert and find values
class HxRegistry { void insertValue(HxString path, const HxRegData&); void eraseValue(HxString path); HxString findValue(HxString path) const; int valueExists(HxString path) const; }; HxRegistry::instance().insertValue("/methods/getCount/nArgs", HxRegData(0));
If the class interface of HxRegistry is used, values must be specified by path. Again, this can be absolute from the registry root or relative to the current or cursor key of the registry. Note that the result of findValue is always the string representation of the data part of the value. If the value does not exist an empty string is returned. Since an empty string is a legal data part of a value, the method valueExists is provided to determine the existence of a value.
The cursor key
class HxRegistry { HxRegKey* setCursorKey(HxString path); HxRegKey* setCursorUp(); HxRegKey* getCursorKey() const; };
Accessing values and keys relative from the cursor key is more efficient since the specified path does not have to be walked down completely from the root for each access. Some methods are provided to manipulate the cursor key.
Accessing values using the methods provided by the class HxRegistry is neither the most efficient nor the most powerful way to manipulate the values of a key. A better way to manipulate the values of a key is using methods provided by the class HxRegKey.
Managing the values of a key
class HxRegKey { void insertValue(const HxRegValue& value); void eraseValue(HxString name); const HxRegValue* findValue(HxString name) const; };
To obtain a specific key, use the method HxRegistry::findKey. A pointer to a key is returned that can be used to manipulate the values of that key or to navigate further in the key tree.
To obtain a pointer to a value use the method HxRegKey::findValue on its containing key. If a value with the specified name does not exist, a null pointer is returned. A registry value contains an object of class HxRegData. This object is either a string or an integer. The method HxRegData::type is provided to examine the type of a HxRegData object. With methods HxRegData::getInt and HxRegData::getString} the integer or string value are obtained.
Manipulating a value
int nItems = -1; HxRegValue* val = regKey->findValue("nItems"); if (val) { HxRegData data = val->getData(); if (data.type() == HxRegData::Int) { nItems = data.getInt(); } }