modify code

Signed-off-by: zhaolinglan <zhaolinglan@huawei.com>
This commit is contained in:
zhaolinglan 2024-01-04 20:57:10 +08:00
parent 0368565bd7
commit 3aa0ff625c
3 changed files with 4 additions and 5 deletions

View File

@ -34,7 +34,7 @@ class ImeConfigParse {
public:
static std::string ReadFile(const std::string &path);
static CfgFiles* ParseFromCustom();
static bool parseJson(const std::string &cfgPath, const std::string &parseKey, nlohmann::json &jsonCfg);
static bool ParseJson(const std::string &cfgPath, const std::string &parseKey, nlohmann::json &jsonCfg);
template<typename T>
static bool ParseFromCustomSystem(const std::string &parseKey, T &data);
template<typename T>
@ -113,7 +113,7 @@ template<typename T>
bool ImeConfigParse::GetCfgsFromFile(const std::string &cfgPath, const std::string &parseKey, T &data)
{
nlohmann::json jsonCfg;
if (parseJson(cfgPath, parseKey, jsonCfg)) {
if (ParseJson(cfgPath, parseKey, jsonCfg)) {
data = jsonCfg.at(parseKey).get<T>();
return true;
}
@ -124,7 +124,7 @@ template<typename T>
bool ImeConfigParse::GetCfgsFromFile(const std::string &cfgPath, const std::string &parseKey, std::vector<T> &data)
{
nlohmann::json jsonCfg;
if (parseJson(cfgPath, parseKey, jsonCfg)) {
if (ParseJson(cfgPath, parseKey, jsonCfg)) {
if (!jsonCfg.at(parseKey).is_array()) {
IMSA_HILOGE("%{public}s is not array", parseKey.c_str());
return false;

View File

@ -52,7 +52,6 @@ constexpr int32_t CONFIG_LEN = 128;
void from_json(const nlohmann::json &jsonConfigs, ImeConfig &config)
{
json jsonCfg = jsonConfigs[SYSTEM_CONFIG];
if (jsonConfigs.find(SYSTEM_INPUT_METHOD_CONFIG_ABILITY) != jsonConfigs.end()
&& jsonConfigs[SYSTEM_INPUT_METHOD_CONFIG_ABILITY].is_string()) {
jsonConfigs.at(SYSTEM_INPUT_METHOD_CONFIG_ABILITY).get_to(config.systemInputMethodConfigAbility);

View File

@ -40,7 +40,7 @@ CfgFiles* ImeConfigParse::ParseFromCustom()
return GetCfgFiles(IME_INPUT_TYPE_CFG_FILE_PATH);
}
bool ImeConfigParse::parseJson(const std::string &cfgPath, const std::string &parseKey, nlohmann::json &jsonCfg)
bool ImeConfigParse::ParseJson(const std::string &cfgPath, const std::string &parseKey, nlohmann::json &jsonCfg)
{
IMSA_HILOGD("in");
std::string jsonStr = ImeConfigParse::ReadFile(cfgPath);