diff options
author | Alex Zolotarev <alex@maps.me> | 2016-02-18 20:49:37 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:49:31 +0300 |
commit | b76b79242126d66f5533048fe7e8e31ae6d17e34 (patch) | |
tree | 760b0ac95f852f4136e9820fe1e5d500327c17bc /indexer/classificator.cpp | |
parent | 700e8364e79166f4c259758c586772091ccae2ae (diff) |
Classificator::GetTypeByReadableObjectName().
Diffstat (limited to 'indexer/classificator.cpp')
-rw-r--r-- | indexer/classificator.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index 648beebfb0..d477559584 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -2,11 +2,12 @@ #include "indexer/map_style_reader.hpp" #include "indexer/tree_structure.hpp" -#include "base/macros.hpp" #include "base/logging.hpp" +#include "base/macros.hpp" +#include "base/string_utils.hpp" -#include "std/bind.hpp" #include "std/algorithm.hpp" +#include "std/bind.hpp" #include "std/iterator.hpp" namespace @@ -414,6 +415,14 @@ uint32_t Classificator::GetTypeByPath(initializer_list<char const *> const & lst return type; } +uint32_t Classificator::GetTypeByReadableObjectName(string const & name) const +{ + ASSERT(!name.empty(), ()); + vector<string> v; + strings::Tokenize(name, "-", [&v] (string const & s) { v.push_back(s); } ); + return GetTypeByPathSafe(v); +} + void Classificator::ReadTypesMapping(istream & s) { m_mapping.Load(s); @@ -427,13 +436,11 @@ void Classificator::Clear() string Classificator::GetReadableObjectName(uint32_t type) const { - string s = classif().GetFullObjectName(type); - - // remove ending dummy symbol + string s = GetFullObjectName(type); + // Remove ending dummy symbol. ASSERT ( !s.empty(), () ); - s.resize(s.size()-1); - - // replace separator + s.pop_back(); + // Replace separator. replace(s.begin(), s.end(), '|', '-'); return s; } |