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
diff options
context:
space:
mode:
authorIlya Grechuhin <i.grechuhin@gmail.com>2016-04-20 16:48:13 +0300
committerIlya Grechuhin <i.grechuhin@gmail.com>2016-04-20 17:36:33 +0300
commitc294c3c2122f01cc1189cc6dc22b463d33bd5481 (patch)
tree91c897f541906f582a76bd3928f6f929a6ae10c0
parent81edaa14e2e7145f12241388b327194dbcb944e5 (diff)
[downloader] Fix behavior for absent description
-rw-r--r--storage/country_name_getter.cpp13
-rw-r--r--storage/country_name_getter.hpp5
-rw-r--r--storage/storage.cpp2
3 files changed, 15 insertions, 5 deletions
diff --git a/storage/country_name_getter.cpp b/storage/country_name_getter.cpp
index 46247081fe..88a54e5d67 100644
--- a/storage/country_name_getter.cpp
+++ b/storage/country_name_getter.cpp
@@ -15,14 +15,19 @@ void CountryNameGetter::SetLocaleForTesting(string const & jsonBuffer, string co
m_getCurLang = platform::ForTestingGetTextByIdFactory(jsonBuffer, locale);
}
-string CountryNameGetter::operator()(TCountryId const & countryId) const
+string CountryNameGetter::Get(string const & key) const
{
- ASSERT(!countryId.empty(), ());
+ ASSERT(!key.empty(), ());
if (m_getCurLang == nullptr)
- return countryId;
+ return string();
- string name = (*m_getCurLang)(countryId);
+ return (*m_getCurLang)(key);
+}
+
+string CountryNameGetter::operator()(TCountryId const & countryId) const
+{
+ string const name = Get(countryId);
if (name.empty())
return countryId;
diff --git a/storage/country_name_getter.hpp b/storage/country_name_getter.hpp
index 37b83103ac..2329afbff8 100644
--- a/storage/country_name_getter.hpp
+++ b/storage/country_name_getter.hpp
@@ -27,6 +27,11 @@ public:
/// \note See countries/languages.txt for the full list of available locales.
void SetLocale(string const & locale);
+ /// \brief Gets localized string for key. If not found returns empty string.
+ /// @param key is a string for lookup.
+ /// \note Unlike operator (), does not return key if localized string is not found.
+ string Get(string const & key) const;
+
string operator()(TCountryId const & countryId) const;
// for testing
diff --git a/storage/storage.cpp b/storage/storage.cpp
index 9898b64c74..511a59e5a8 100644
--- a/storage/storage.cpp
+++ b/storage/storage.cpp
@@ -1332,7 +1332,7 @@ void Storage::GetNodeAttrs(TCountryId const & countryId, NodeAttrs & nodeAttrs)
nodeAttrs.m_status = statusAndErr.status;
nodeAttrs.m_error = statusAndErr.error;
nodeAttrs.m_nodeLocalName = m_countryNameGetter(countryId);
- nodeAttrs.m_nodeLocalDescription = m_countryNameGetter(countryId + LOCALIZATION_DESCRIPTION_SUFFIX);
+ nodeAttrs.m_nodeLocalDescription = m_countryNameGetter.Get(countryId + LOCALIZATION_DESCRIPTION_SUFFIX);
// Progress.
if (nodeAttrs.m_status == NodeStatus::OnDisk)