mirror of
https://github.com/openharmony/developtools_global_resource_tool.git
synced 2026-07-19 19:33:46 -04:00
@@ -49,7 +49,6 @@ ohos_executable("restool") {
|
||||
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//third_party/jsoncpp/include",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
]
|
||||
|
||||
|
||||
+6
-10
@@ -72,20 +72,16 @@ uint32_t FileManager::ParseReference(const string &output)
|
||||
void FileManager::CheckAllItems(vector<pair<ResType, string>> &noBaseResource)
|
||||
{
|
||||
for (const auto &item : items_) {
|
||||
bool flag = false;
|
||||
for (const auto &iter : item.second) {
|
||||
if (iter.GetLimitKey() == "base") {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
bool found = any_of(item.second.begin(), item.second.end(), [](const auto &iter) {
|
||||
return iter.GetLimitKey() == "base";
|
||||
});
|
||||
if (!found) {
|
||||
auto firstItem = item.second.front();
|
||||
auto ret = find_if(noBaseResource.begin(), noBaseResource.end(), [firstItem](auto &iterItem) {
|
||||
bool ret = any_of(noBaseResource.begin(), noBaseResource.end(), [firstItem](const auto &iterItem) {
|
||||
return (firstItem.GetResType() == iterItem.first) &&
|
||||
(firstItem.GetName() == iterItem.second);
|
||||
});
|
||||
if (ret == noBaseResource.end()) {
|
||||
if (!ret) {
|
||||
noBaseResource.push_back(make_pair(firstItem.GetResType(), firstItem.GetName()));
|
||||
}
|
||||
}
|
||||
|
||||
+6
-10
@@ -679,20 +679,16 @@ bool ResourceAppend::IsBaseIdDefined(const FileInfo &fileInfo)
|
||||
void ResourceAppend::CheckAllItems(vector<pair<ResType, string>> &noBaseResource)
|
||||
{
|
||||
for (const auto &item : items_) {
|
||||
bool flag = false;
|
||||
for (const auto &iter : item.second) {
|
||||
if (iter->GetLimitKey() == "base") {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
bool found = any_of(item.second.begin(), item.second.end(), [](const auto &iter) {
|
||||
return iter->GetLimitKey() == "base";
|
||||
});
|
||||
if (!found) {
|
||||
auto firstItem = item.second.front();
|
||||
auto ret = find_if(noBaseResource.begin(), noBaseResource.end(), [firstItem](auto &iterItem) {
|
||||
bool ret = any_of(noBaseResource.begin(), noBaseResource.end(), [firstItem](const auto &iterItem) {
|
||||
return (firstItem->GetResType() == iterItem.first) &&
|
||||
(firstItem->GetName() == iterItem.second);
|
||||
});
|
||||
if (ret == noBaseResource.end()) {
|
||||
if (!ret) {
|
||||
noBaseResource.push_back(make_pair(firstItem->GetResType(), firstItem->GetName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ bool ResourceUtil::OpenJsonFile(const string &path, cJSON **root)
|
||||
|
||||
string jsonString((istreambuf_iterator<char>(ifs)), istreambuf_iterator<char>());
|
||||
*root = cJSON_Parse(jsonString.c_str());
|
||||
if (!root) {
|
||||
cerr << "Error: cJSON_Parse failed." << NEW_LINE_PATH << path;
|
||||
if (!*root) {
|
||||
cerr << "Error: cJSON_Parse failed, please check the JSON file." << NEW_LINE_PATH << path;
|
||||
cerr << "\n" << cJSON_GetErrorPtr() << endl;
|
||||
ifs.close();
|
||||
return false;
|
||||
|
||||
@@ -116,7 +116,7 @@ bool TranslatableParse::CheckBaseStringPriority(const cJSON *attrNode)
|
||||
string priorityValue = priorityNode->valuestring;
|
||||
if (find(PRIORITY_ATTRS.begin(), PRIORITY_ATTRS.end(), priorityValue) == PRIORITY_ATTRS.end()) {
|
||||
string message("[ ");
|
||||
for (auto &value : PRIORITY_ATTRS) {
|
||||
for (const auto &value : PRIORITY_ATTRS) {
|
||||
message.append("'" + value + "' ");
|
||||
}
|
||||
message.append("]");
|
||||
@@ -148,11 +148,9 @@ bool TranslatableParse::GetReplaceStringTranslate(string &str)
|
||||
return false;
|
||||
}
|
||||
size_t startIndex = 0;
|
||||
size_t endIndex = 0;
|
||||
string tmp;
|
||||
for (size_t index = 0; index < posData.size(); index++) {
|
||||
endIndex = posData[index];
|
||||
tmp.append(str, startIndex, endIndex - startIndex);
|
||||
tmp.append(str, startIndex, posData[index] - startIndex);
|
||||
startIndex = posData[++index];
|
||||
}
|
||||
str = tmp.append(str, posData.back());
|
||||
|
||||
Reference in New Issue
Block a user