📄 warregistrykey.cpp
字号:
#include "StdAfx.h"#include "WarRegistryKey.h" // class implemented/////////////////////////////// PUBLIC /////////////////////////////////////////============================= LIFECYCLE ====================================WarRegistryKey::WarRegistryKey(name_ccstr_t name, text_ccstr_t comment) :WarRegistryBase(name, comment){}// WarRegistryKeyWarRegistryKey::WarRegistryKey(const WarRegistryKey& from) :WarRegistryBase(NULL, NULL){ operator = (from);}// WarRegistryKeyWarRegistryKey::~WarRegistryKey(){}// ~WarRegistryKey//============================= OPERATORS ====================================WarRegistryKey& WarRegistryKey::operator = (const WarRegistryKey& from){ WarRegistryBase::operator = (from); mChildren = from.mChildren; return *this;}// =WarRegistryKey::key_ptr_t WarRegistryKey::Open(name_ccstr_t name) throw(WarException){ key_ptr_t key = new WarRegistryKey(name, NULL); WarRegistryKey::key_set_t::iterator P = mChildren.find(key); if (P == mChildren.end()) WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); return *P;}WarRegistryKey::key_ptr_t WarRegistryKey::Create(name_ccstr_t name) throw(WarException){ if (IsKey(name) || IsValue(name)) WarThrow(WarError(WAR_ERR_OBJECT_EXIST), NULL); key_ptr_t key = new WarRegistryKey(name, NULL); mChildren.insert(key); return key;}//============================= OPERATIONS ===================================void WarRegistryKey::SetValue(name_ccstr_t name, name_ccstr_t value) throw(WarException){ value_ptr_t key = new WarRegistryValue(name, NULL, NULL); WarRegistryKey::value_set_t::iterator P = mValues.find(key); if (P == mValues.end()) { // Insert new key->SetValue(value); std::pair<WarRegistryKey::value_set_t::const_iterator, bool> status = mValues.insert(key); if (!status.second) WarThrow(WarError(WAR_ERR_UNEXCPECTED_REPLY_CODE), "std::insert()"); } else { // Update current (*P)->SetValue(value); }}//============================= CALLBACK ===================================//============================= ACCESS ===================================const WarRegistryValue::value_t& WarRegistryKey::GetValue(name_ccstr_t name)const throw(WarException){ return (*LookupValue(name))->GetValue();}//============================= INQUIRY ===================================bool WarRegistryKey::IsValue(name_ccstr_t name) const{ try { LookupValue(name); } catch(WarException) { return false; } return true;}bool WarRegistryKey::IsKey(name_ccstr_t name) const{ try { LookupKey(name); } catch(WarException) { return false; } return true;}/////////////////////////////// PROTECTED ///////////////////////////////////WarRegistryKey::key_set_t::const_iterator WarRegistryKey::LookupKey(name_ccstr_t name)const throw(WarException){ key_ptr_t key = new WarRegistryKey(name, NULL); WarRegistryKey::key_set_t::const_iterator P = mChildren.find(key); if (P == mChildren.end()) WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); return P;}WarRegistryKey::value_set_t::const_iterator WarRegistryKey::LookupValue(name_ccstr_t name)const throw(WarException){ value_ptr_t key = new WarRegistryValue(name, NULL, NULL); WarRegistryKey::value_set_t::const_iterator P = mValues.find(key); if (P == mValues.end()) WarThrow(WarError(WAR_ERR_OBJECT_NOT_FOUND), NULL); return P;}/////////////////////////////// PRIVATE ///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -