修改preferences读写bool类型错误

Signed-off-by: li_juntao <lijuntao9@huawei.com>
This commit is contained in:
li_juntao
2022-07-27 16:28:45 +08:00
parent 458ce37939
commit 3aeb72d6a3
@@ -328,7 +328,8 @@ void WriteXmlElement(Element &elem, PreferencesValue value, const std::filesyste
for (bool val : values) {
Element element;
element.tag_ = std::string("bool");
element.value_ = std::to_string((bool)val);
std::string tmpVal = std::to_string((bool)val);
element.value_ = tmpVal == "1" ? "true" : "false";
elem.children_.push_back(element);
}
} else if (value.IsStringArray()) {
@@ -345,7 +346,8 @@ void WriteXmlElement(Element &elem, PreferencesValue value, const std::filesyste
elem.value_ = std::to_string((int)value);
} else if (value.IsBool()) {
elem.tag_ = std::string("bool");
elem.value_ = std::to_string((bool)value);
std::string tmpVal = std::to_string((bool)value);
elem.value_ = tmpVal == "1" ? "true" : "false";
} else if (value.IsLong()) {
elem.tag_ = std::string("long");
elem.value_ = std::to_string((int64_t)value);