Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2016-10-19 19:52:01 +0300
committerArsentiy Milchakov <milcars@mapswithme.com>2016-10-19 19:52:01 +0300
commit3becf1abbd59e2f820e8c2af4bd871825a47c0d3 (patch)
tree7d4383f595078cde915743f3092274b9d1a65d32 /editor
parent29273a11053786519a2ffed0fdc6678d56618400 (diff)
fix type priority in editor config
Diffstat (limited to 'editor')
-rw-r--r--editor/editor_config.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/editor/editor_config.cpp b/editor/editor_config.cpp
index 7dcef62f94..54d112b0d5 100644
--- a/editor/editor_config.cpp
+++ b/editor/editor_config.cpp
@@ -37,6 +37,8 @@ static unordered_map<string, EType> const kNamesToFMD= {
// description
};
+unordered_map<string, int> const kPriorityWeights = {{"high", 0}, {"", 1}, {"low", 2}};
+
bool TypeDescriptionFromXml(pugi::xml_node const & root, pugi::xml_node const & node,
editor::TypeAggregatedDescription & outDesc)
{
@@ -96,14 +98,16 @@ vector<pugi::xml_node> GetPrioritizedTypes(pugi::xml_node const & node)
vector<pugi::xml_node> result;
for (auto const xNode : node.select_nodes("/mapsme/editor/types/type[@id]"))
result.push_back(xNode.node());
- stable_sort(begin(result), end(result),
- [](pugi::xml_node const & a, pugi::xml_node const & b)
- {
- if (strcmp(a.attribute("priority").value(), "high") != 0 &&
- strcmp(b.attribute("priority").value(), "high") == 0)
- return true;
- return false;
- });
+ stable_sort(begin(result), end(result), [](pugi::xml_node const & lhs, pugi::xml_node const & rhs)
+ {
+ auto const lhsWeight = kPriorityWeights.find(lhs.attribute("priority").value());
+ auto const rhsWeight = kPriorityWeights.find(rhs.attribute("priority").value());
+
+ CHECK(lhsWeight != kPriorityWeights.end(), (""));
+ CHECK(rhsWeight != kPriorityWeights.end(), (""));
+
+ return lhsWeight->second < rhsWeight->second;
+ });
return result;
}
} // namespace