diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-11-11 18:25:24 +0300 |
---|---|---|
committer | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-11-11 18:25:24 +0300 |
commit | 2c0d8cec2ad70fc944579d225c0cb2f7ecfd2d2e (patch) | |
tree | 0322b4d571072222d03adcfda65ba65c6336e766 /generator | |
parent | 527000b42016aeb93e70a2508187ac59c61ceaa9 (diff) |
Review fixes.
Diffstat (limited to 'generator')
-rw-r--r-- | generator/restriction_writer.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/generator/restriction_writer.cpp b/generator/restriction_writer.cpp index b2dbea221f..604bc09e1e 100644 --- a/generator/restriction_writer.cpp +++ b/generator/restriction_writer.cpp @@ -18,31 +18,26 @@ namespace { using namespace routing; -vector<string> const kRestrictionTypesNo = {"no_right_turn", "no_left_turn", "no_u_turn", - "no_straight_on", "no_entry", "no_exit"}; -vector<string> const kRestrictionTypesOnly = {"only_right_turn", "only_left_turn", - "only_straight_on"}; +vector<pair<string, Restriction::Type>> const kRestrictionTypes = + {{"no_right_turn", Restriction::Type::No}, {"no_left_turn", Restriction::Type::No}, + {"no_u_turn", Restriction::Type::No}, {"no_straight_on", Restriction::Type::No}, + {"no_entry", Restriction::Type::No}, {"no_exit", Restriction::Type::No}, + {"only_right_turn", Restriction::Type::Only}, {"only_left_turn", Restriction::Type::Only}, + {"only_straight_on", Restriction::Type::Only}}; /// \brief Converts restriction type form string to RestrictionCollector::Type. /// \returns true if conversion was successful and false otherwise. bool TagToType(string const & tag, Restriction::Type & type) { - if (find(kRestrictionTypesNo.cbegin(), kRestrictionTypesNo.cend(), tag) != - kRestrictionTypesNo.cend()) - { - type = Restriction::Type::No; - return true; - } - - if (find(kRestrictionTypesOnly.cbegin(), kRestrictionTypesOnly.cend(), tag) != - kRestrictionTypesOnly.cend()) - { - type = Restriction::Type::Only; - return true; - } - - // Unsupported restriction type. - return false; + auto const it = find_if(kRestrictionTypes.cbegin(), kRestrictionTypes.cend(), + [&tag](pair<string, Restriction::Type> const & v) { + return v.first == tag; + }); + if (it == kRestrictionTypes.cend()) + return false; // Unsupported restriction type. + + type = it->second; + return true; } } // namespace |