From afb42aab9e580f88d9c56ac07de56a6adf625382 Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Mon, 26 Mar 2018 12:55:50 +0300 Subject: [PATCH] [editor] clang-format editor_config.cpp --- editor/editor_config.cpp | 42 ++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/editor/editor_config.cpp b/editor/editor_config.cpp index d28c34822e..e78449c006 100644 --- a/editor/editor_config.cpp +++ b/editor/editor_config.cpp @@ -46,8 +46,7 @@ bool TypeDescriptionFromXml(pugi::xml_node const & root, pugi::xml_node const & if (!node || strcmp(node.attribute("editable").value(), "no") == 0) return false; - auto const handleField = [&outDesc](string const & fieldName) - { + auto const handleField = [&outDesc](string const & fieldName) { if (fieldName == "name") { outDesc.m_name = true; @@ -86,7 +85,7 @@ bool TypeDescriptionFromXml(pugi::xml_node const & root, pugi::xml_node const & { auto const node = xNode.node(); string const fieldName = node.attribute("field").value(); - handleField(fieldName); + handleField(fieldName); } my::SortUnique(outDesc.m_editableFields); @@ -99,16 +98,16 @@ vector GetPrioritizedTypes(pugi::xml_node const & node) vector 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 & lhs, pugi::xml_node const & rhs) - { - auto const lhsWeight = kPriorityWeights.find(lhs.attribute("priority").value()); - auto const rhsWeight = kPriorityWeights.find(rhs.attribute("priority").value()); + 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(), ("")); + CHECK(lhsWeight != kPriorityWeights.end(), ("")); + CHECK(rhsWeight != kPriorityWeights.end(), ("")); - return lhsWeight->second < rhsWeight->second; - }); + return lhsWeight->second < rhsWeight->second; + }); return result; } } // namespace @@ -132,7 +131,7 @@ bool EditorConfig::GetTypeDescription(vector classificatorTypes, } // Adding partial types for 2..N-1 parts of a N-part type. auto hyphenPos = it->find('-'); - while ((hyphenPos = it->find('-', hyphenPos+1)) != string::npos) + while ((hyphenPos = it->find('-', hyphenPos + 1)) != string::npos) { addTypes.push_back(it->substr(0, hyphenPos)); } @@ -140,12 +139,11 @@ bool EditorConfig::GetTypeDescription(vector classificatorTypes, classificatorTypes.insert(classificatorTypes.end(), addTypes.begin(), addTypes.end()); auto const typeNodes = GetPrioritizedTypes(m_document); - auto const it = find_if(begin(typeNodes), end(typeNodes), - [&classificatorTypes](pugi::xml_node const & node) - { - return find(begin(classificatorTypes), end(classificatorTypes), - node.attribute("id").value()) != end(classificatorTypes); - }); + auto const it = + find_if(begin(typeNodes), end(typeNodes), [&classificatorTypes](pugi::xml_node const & node) { + return find(begin(classificatorTypes), end(classificatorTypes), + node.attribute("id").value()) != end(classificatorTypes); + }); if (it == end(typeNodes)) return isBuilding; @@ -154,7 +152,8 @@ bool EditorConfig::GetTypeDescription(vector classificatorTypes, vector EditorConfig::GetTypesThatCanBeAdded() const { - auto const xpathResult = m_document.select_nodes("/mapsme/editor/types/type[not(@can_add='no' or @editable='no')]"); + auto const xpathResult = + m_document.select_nodes("/mapsme/editor/types/type[not(@can_add='no' or @editable='no')]"); vector result; for (auto const xNode : xpathResult) @@ -162,8 +161,5 @@ vector EditorConfig::GetTypesThatCanBeAdded() const return result; } -void EditorConfig::SetConfig(pugi::xml_document const & doc) -{ - m_document.reset(doc); -} +void EditorConfig::SetConfig(pugi::xml_document const & doc) { m_document.reset(doc); } } // namespace editor