[zhoulongyu]: 完善配置库的Int数据类型
This commit is contained in:
parent
d44154773f
commit
730c38b2c1
|
@ -21,12 +21,14 @@
|
|||
IpcConfig::IpcConfig()
|
||||
{
|
||||
mCfgChanged = CONFIG_HAS_NOT_CHANGED;
|
||||
mCfgMapInt.insert(std::make_pair<IpcConfigKey, std::reference_wrapper<int>>(
|
||||
IpcConfigKey::TEST_NUM, std::reference_wrapper<int>(mAllData.testNum)));
|
||||
|
||||
std::map<std::string, std::reference_wrapper<CHAR_STRING>> innerMap;
|
||||
innerMap.insert(std::make_pair("test_string", std::reference_wrapper<CHAR_STRING>(mAllData.testString)));
|
||||
mCfgMapString.insert(std::make_pair(IpcConfigKey::TEST_STRING, innerMap));
|
||||
std::map<std::string, std::reference_wrapper<int>> innerMapInt;
|
||||
innerMapInt.insert(std::make_pair("test_num", std::reference_wrapper<int>(mAllData.testNum)));
|
||||
mCfgMapInt.insert(std::make_pair(IpcConfigKey::TEST_NUM, innerMapInt));
|
||||
|
||||
std::map<std::string, std::reference_wrapper<CHAR_STRING>> innerMapString;
|
||||
innerMapString.insert(std::make_pair("test_string", std::reference_wrapper<CHAR_STRING>(mAllData.testString)));
|
||||
mCfgMapString.insert(std::make_pair(IpcConfigKey::TEST_STRING, innerMapString));
|
||||
}
|
||||
const StatusCode IpcConfig::Init(void)
|
||||
{
|
||||
|
@ -52,10 +54,10 @@ const StatusCode IpcConfig::ConfigFileSave(void) { return ConfigSaveFile(mCfg);
|
|||
|
||||
const int IpcConfig::GetInt(const IpcConfigKey &key)
|
||||
{
|
||||
std::map<IpcConfigKey, std::reference_wrapper<int>>::iterator iter;
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<int>>>::iterator iter;
|
||||
iter = mCfgMapInt.find(key);
|
||||
if (iter != mCfgMapInt.end()) {
|
||||
return iter->second;
|
||||
if (iter != mCfgMapInt.end() && CHECK_MAP(iter->second)) {
|
||||
return iter->second.begin()->second;
|
||||
}
|
||||
LogError("Can't find the key.\n");
|
||||
constexpr int UNKNOWN_CONFIG = -1;
|
||||
|
@ -63,10 +65,12 @@ const int IpcConfig::GetInt(const IpcConfigKey &key)
|
|||
}
|
||||
void IpcConfig::SetInt(const IpcConfigKey &key, const int &value)
|
||||
{
|
||||
std::map<IpcConfigKey, std::reference_wrapper<int>>::iterator iter;
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<int>>>::iterator iter;
|
||||
iter = mCfgMapInt.find(key);
|
||||
if (iter != mCfgMapInt.end()) {
|
||||
iter->second.get() = value;
|
||||
if (iter != mCfgMapInt.end() && CHECK_MAP(iter->second)) {
|
||||
iter->second.begin()->second.get() = value;
|
||||
const char *name = iter->second.begin()->first.c_str(); // const std::strinbg --> const char *
|
||||
ConfigSetInt(mCfg, name, iter->second.begin()->second);
|
||||
mCfgChanged = CONFIG_HAS_CHANGED;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
bool mCfgChanged;
|
||||
VConfig *mCfg;
|
||||
Config_s mAllData;
|
||||
std::map<IpcConfigKey, std::reference_wrapper<int>> mCfgMapInt;
|
||||
std::map<IpcConfigKey, std::map<std::string, std::reference_wrapper<int>>> mCfgMapInt;
|
||||
std::map<IpcConfigKey, std::reference_wrapper<short>> mCfgMapShort;
|
||||
std::map<IpcConfigKey, std::reference_wrapper<long>> mCfgMapLong;
|
||||
std::map<IpcConfigKey, std::reference_wrapper<long long>> mCfgMapLongLong;
|
||||
|
|
Loading…
Reference in New Issue
Block a user