#include <HxRegKey.h>
Public Methods | |
~HxRegKey () | |
Destructor. More... | |
HxString | getName () const |
Get name. More... | |
HxRegKey * | getParent () const |
Get parent. More... | |
HxRegKey * | insertKey (HxString path) |
Insert key. More... | |
void | eraseKey (HxString name) |
Erase key. More... | |
HxRegKey * | findKey (HxString path) const |
Find key. More... | |
HxRegKey * | findKey (HxStringListConstIter first, HxStringListConstIter last) const |
Find key. More... | |
int | getKeyList (HxRegKeyListBackInserter) const |
Get list of keys. More... | |
size_t | keyListSize () const |
Get size of list of keys. More... | |
void | insertValue (HxString name, const HxRegData &data) |
Insert value. More... | |
void | insertValue (const HxRegValue &value) |
Insert value. More... | |
void | eraseValue (HxString name) |
Erase value. More... | |
const HxRegValue * | findValue (HxString name) const |
Find value. More... | |
int | getInt (HxString name) const |
Shorthands for findValue. More... | |
HxString | getString (HxString name) const |
Shorthands for findValue. More... | |
int | getValueList (HxRegValueListBackInserter) |
Shorthands for findValue. More... | |
size_t | valueListSize () const |
Shorthands for findValue. More... | |
STD_OSTREAM & | put (STD_OSTREAM &) const |
Put on stream. More... | |
STD_OSTREAM & | put (STD_OSTREAM &, HxString path, int cCode=0) const |
Put on stream. More... | |
Static Public Methods | |
HxRegKey * | createRootKey () |
Create root key. More... | |
Friends | |
class | HxRegKeyFriend |
|
Destructor.
00047 { 00048 if (_keys) { 00049 HxRegKeyMap::iterator ptr; 00050 00051 for (ptr = _keys->begin(); ptr != _keys->end(); ptr++) { 00052 delete (* ptr).second; 00053 } 00054 } 00055 #ifdef HxRegistry_Debug 00056 STD_CERR << "HxRegKey::~HxRegKey(), _name = " << _name << STD_ENDL; 00057 #endif 00058 } |
|
Create root key.
|
|
Get name.
00138 { 00139 return _name; 00140 } |
|
Get parent.
00144 { 00145 return _parent; 00146 } |
|
Insert key.
00093 { 00094 HxStringList nameList; 00095 splitString(path, '/', std::back_inserter(nameList)); 00096 HxStringListConstIter namePtr = nameList.begin(); 00097 HxRegKey* key = this; 00098 00099 if ((namePtr != nameList.end()) && (*namePtr).empty()) { 00100 namePtr++; 00101 } 00102 00103 for (;namePtr != nameList.end(); namePtr++) { 00104 if ((*namePtr).empty()) 00105 continue; 00106 key = key->insertOneKey(*namePtr); 00107 } 00108 return key; 00109 } |
|
Erase key.
00113 { 00114 HxRegKeyMap::iterator ptr; 00115 if (!_keys) 00116 return; 00117 if ((ptr = _keys->find(name)) != _keys->end()) { 00118 HxRegKey* key = (*ptr).second; 00119 delete key; 00120 _keys->erase(name); 00121 } 00122 } |
|
Find key.
00126 { 00127 HxStringList nameList; 00128 splitString(path, '/', std::back_inserter(nameList)); 00129 return findKey(nameList.begin(), nameList.end()); 00130 } |
|
Find key.
00160 { 00161 HxStringListConstIter namePtr = first; 00162 const HxRegKey* key = this; 00163 HxRegKeyMap::const_iterator ptr; 00164 00165 for (;namePtr != last; namePtr++) { 00166 if ((*namePtr).empty()) 00167 continue; 00168 if (!key->_keys) 00169 return 0; 00170 ptr = key->_keys->find(*namePtr); 00171 if (ptr == key->_keys->end()) 00172 return 0; 00173 else 00174 key = (*ptr).second; 00175 } 00176 return (HxRegKey*)key; 00177 } |
|
Get list of keys.
00181 { 00182 HxRegKeyMap::iterator ptr; 00183 int n = 0; 00184 00185 if (!_keys) 00186 return 0; 00187 00188 for (ptr = _keys->begin(); ptr != _keys->end(); ptr++, n++) 00189 *bi++ = (*ptr).second; 00190 return n; 00191 } |
|
Get size of list of keys.
00195 { 00196 return _keys->size(); 00197 } |
|
Insert value.
00150 { 00151 insertValue(HxRegValue(name, data)); 00152 } |
|
Insert value.
00201 { 00202 ValueVector::iterator ptr 00203 = std::lower_bound(_values.begin(), _values.end(), val); 00204 if (ptr == _values.end()) { 00205 _values.insert(ptr, val); 00206 } else if ((*ptr).getName() != val.getName()) { 00207 _values.insert(ptr, val); 00208 } else { 00209 (*ptr).setData(val.getData()); 00210 } 00211 } |
|
Erase value.
00215 { 00216 ValueVector::iterator ptr = std::lower_bound( 00217 _values.begin(), _values.end(), 00218 HxRegValue(name, HxRegData(0))); 00219 if ((ptr != _values.end()) && ((*ptr).getName() == name)) 00220 _values.erase(ptr); 00221 } |
|
Find value.
00225 { 00226 ValueVector::const_iterator ptr = std::lower_bound( 00227 _values.begin(), _values.end(), 00228 HxRegValue(name, HxRegData(0))); 00229 if ((ptr != _values.end()) && ((*ptr).getName() == name)) 00230 return &(*ptr); 00231 else 00232 return 0; 00233 } |
|
Shorthands for findValue. Existence of the values cannot be determined from the return value.
00156 { 00157 const HxRegValue* val = findValue(name); 00158 return val ? val->getData().getInt() : 0; 00159 } |
|
Shorthands for findValue. Existence of the values cannot be determined from the return value.
00163 { 00164 const HxRegValue* val = findValue(name); 00165 return val ? val->getData().getString() : HxString(); 00166 } |
|
Shorthands for findValue. Existence of the values cannot be determined from the return value.
00237 { 00238 ValueVector::iterator ptr; 00239 int n = 0; 00240 for (ptr = _values.begin(); ptr != _values.end(); ptr++, n++) 00241 *bi++ = &(*ptr); 00242 return n; 00243 } |
|
Shorthands for findValue. Existence of the values cannot be determined from the return value.
00247 { 00248 return _values.size(); 00249 } |
|
Put on stream.
00253 { 00254 return put(os, ""); 00255 } |
|
Put on stream.
00259 { 00260 HxRegKeyMap::iterator keyPtr; 00261 ValueVector::const_iterator valPtr; 00262 00263 if (cCode) 00264 os << "\""; 00265 os << "[" << path << "/" << _name << "]"; 00266 if (cCode) 00267 os << "\","; 00268 os << STD_ENDL; 00269 00270 for (valPtr = _values.begin(); valPtr != _values.end(); valPtr++) { 00271 if (cCode) 00272 os << "\""; 00273 (*valPtr).put(os, cCode); 00274 if (cCode) 00275 os << "\","; 00276 os << STD_ENDL; 00277 } 00278 00279 if (_keys) { 00280 if (!_name.empty()) 00281 path += "/" + _name; 00282 for (keyPtr=_keys->begin(); keyPtr != _keys->end(); keyPtr++) { 00283 HxRegKey* k = (*keyPtr).second; 00284 k->put(os, path, cCode); 00285 } 00286 } 00287 return os; 00288 } |