mirror of
https://gitee.com/openharmony/inputmethod_imf
synced 2024-11-27 17:01:21 +00:00
modify code
Signed-off-by: zhaolinglan <zhaolinglan@huawei.com>
This commit is contained in:
parent
0368565bd7
commit
3aa0ff625c
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user