📄 warifoptions.cpp
字号:
#include "StdAfx.h"#include "WarIfOptions.h" // class implemented#include "WarIfSite.h"#include "WarIfUser.h"#include "WarIfAuthModule.h"/////////////////////////////// PUBLIC /////////////////////////////////////////============================= LIFECYCLE ====================================WarIfOptions::~WarIfOptions(){}// ~WarIfOptions//============================= OPERATORS ====================================//============================= OPERATIONS ===================================void WarIfOptions::EnumOptions(option_def_list_t& optionList) const{ const WarIfServer& my_svr = GetServer(); WarWin32Registry my_key; war_registrypath_t my_path; my_path << my_svr.GetRegKey().GetRef().GetPath().GetPath() << WAR_SYSSLASH << WAR_WINNT_REG_MODULES << WAR_SYSSLASH << WAR_WINNT_REG_OPTIONS; my_key.Open(WarWin32Registry::open_t(my_svr.GetRegKey(), my_path)); WarWin32Registry::keyname_list_t val_list; my_key.EnumKey(val_list); for(WarWin32Registry::keyname_list_t::const_iterator P = val_list.begin() ; P != val_list.end() ; ++P) { WarWin32Registry opt_key; opt_key.Open(my_key.GetRef(P->c_str())); option_def_t my_def; my_def.mName = WarCollector<char>(*P).GetValue(); my_def.mDefaultValue = WarCollector<char>(opt_key.GetStrValue(WAR_WINNT_REG_DEF_VALUE)).GetValue(); my_def.mDescription = WarCollector<char>(opt_key.GetStrValue(WAR_WINNT_REG_DESCRIPTION)).GetValue(); my_def.mType = (WarOption::WarOptionTypeE)opt_key.GetIntValue(WAR_WINNT_REG_TYPE); my_def.mLevel = (WarOption::OptLevelE)opt_key.GetIntValue(WAR_WINNT_REG_LEVEL); optionList.push_back(my_def); }}void WarIfOptions::SetOption(const std::string& optionName, const std::string& optionValue){ mRegKey.SetValue(WarCollector<TCHAR>(optionName).GetValue().c_str(), WarCollector<TCHAR>(optionValue).GetValue().c_str());}void WarIfOptions::SetIntOption(const std::string& optionName, const int optionValue){ std::string str; WarItoa(str, optionValue); SetOption(optionName, str);}void WarIfOptions::ClearOption(const std::string& optionName){ try { mRegKey.DeleteValue(WarCollector<TCHAR>(optionName).GetValue().c_str()); } catch(WarException& ex) { if (ex.LocalError() != WAR_ERR_OBJECT_NOT_FOUND) throw(ex); }}//============================= CALLBACK ===================================//============================= ACCESS ===================================const WarIfServer& WarIfOptions::GetServer() const{ if (mServerPtr) return *mServerPtr; WarThrow(WarError(WAR_ERR_INTERNAL_DATA_NOT_INITIALIZED), NULL); return *(WarIfServer *)NULL; // Compiler food}//============================= INQUIRY ===================================std::string WarIfOptions::GetOption(const std::string& optionName) const{ return WarCollector<char>(mRegKey.GetStrValue( WarCollector<TCHAR>(optionName).GetValue().c_str())).GetValue();}int WarIfOptions::GetIntOption(const std::string& optionName) const{ return atoi(GetOption(optionName).c_str());}bool WarIfOptions::HasOwnOption(const std::string& optionName) const{ try { mRegKey.GetStrValue( WarCollector<TCHAR>(optionName).GetValue().c_str(), NULL, true); return true; } catch(WarException) { } return false;}/////////////////////////////// PROTECTED ///////////////////////////////////WarIfOptions::WarIfOptions(WarIfServer& serverRef){ mServerPtr = war_if_server_ptr_t(&serverRef); mRegKey.Create(serverRef.GetRegKey().GetRef(WAR_WINNT_REG_OPTIONS));}WarIfOptions::WarIfOptions(WarIfSite& siteRef){ mServerPtr = war_if_server_ptr_t(&(siteRef.GetServer())); mRegKey.Create(siteRef.GetRegKey().GetRef(WAR_WINNT_REG_OPTIONS));}WarIfOptions::WarIfOptions(WarIfUser& userRef){ mServerPtr = war_if_server_ptr_t(&( userRef.GetIfAuth().GetSite().GetServer())); mRegKey.Create(userRef.GetRegKey().GetRef(WAR_WINNT_REG_OPTIONS));}/////////////////////////////// PRIVATE ///////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -