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/search
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-09-30 13:19:01 +0300
committervng <viktor.govako@gmail.com>2015-09-30 15:21:30 +0300
commitc7350fe933afb84e0cded4b9ed4af93c9279c868 (patch)
tree605a130afbddc0a3ed118f546add7b0bacf0798b /search
parentbdd1b883c3195517f4ebc5d908b84b424990ca45 (diff)
[search] Fixed search for Apple-specific emoji variations.
Diffstat (limited to 'search')
-rw-r--r--search/search_query.cpp18
-rw-r--r--search/search_query.hpp2
2 files changed, 20 insertions, 0 deletions
diff --git a/search/search_query.cpp b/search/search_query.cpp
index 28b64367fc..20eb6aac90 100644
--- a/search/search_query.cpp
+++ b/search/search_query.cpp
@@ -368,16 +368,34 @@ void Query::ForEachCategoryTypes(ToDo toDo) const
{
for (int j = 0; j < localesCount; ++j)
m_pCategories->ForEachTypeByName(arrLocales[j], m_tokens[i], bind<void>(ref(toDo), i, _1));
+
+ ProcessEmojiIfNeeded(m_tokens[i], i, toDo);
}
if (!m_prefix.empty())
{
for (int j = 0; j < localesCount; ++j)
m_pCategories->ForEachTypeByName(arrLocales[j], m_prefix, bind<void>(ref(toDo), tokensCount, _1));
+
+ ProcessEmojiIfNeeded(m_prefix, tokensCount, toDo);
}
}
}
+template <class ToDo>
+void Query::ProcessEmojiIfNeeded(strings::UniString const & token, size_t ind, ToDo & toDo) const
+{
+ // Special process of 2 codepoints emoji (e.g. black guy on a bike).
+ // Only emoji synonyms can have one codepoint.
+ if (token.size() > 1)
+ {
+ static int8_t const enLocaleCode = CategoriesHolder::MapLocaleToInteger("en");
+
+ m_pCategories->ForEachTypeByName(enLocaleCode, strings::UniString(1, token[0]),
+ bind<void>(ref(toDo), ind, _1));
+ }
+}
+
void Query::SetQuery(string const & query)
{
m_query = &query;
diff --git a/search/search_query.hpp b/search/search_query.hpp
index 10c45a6f76..1c4236859f 100644
--- a/search/search_query.hpp
+++ b/search/search_query.hpp
@@ -129,6 +129,8 @@ private:
int GetCategoryLocales(int8_t (&arr) [3]) const;
template <class ToDo> void ForEachCategoryTypes(ToDo toDo) const;
+ template <class ToDo> void ProcessEmojiIfNeeded(
+ strings::UniString const & token, size_t ind, ToDo & toDo) const;
using TMWMVector = vector<shared_ptr<MwmInfo>>;
using TOffsetsVector = map<MwmSet::MwmId, vector<uint32_t>>;