forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcountry_name_getter.cpp
45 lines (33 loc) · 929 Bytes
/
country_name_getter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "storage/country_name_getter.hpp"
#include "base/assert.hpp"
namespace storage
{
void CountryNameGetter::SetLocale(string const & locale)
{
m_getCurLang = platform::GetTextByIdFactory(platform::TextSource::Countries, locale);
}
void CountryNameGetter::SetLocaleForTesting(string const & jsonBuffer, string const & locale)
{
m_getCurLang = platform::ForTestingGetTextByIdFactory(jsonBuffer, locale);
}
string CountryNameGetter::Get(string const & key) const
{
ASSERT(!key.empty(), ());
if (m_getCurLang == nullptr)
return string();
return (*m_getCurLang)(key);
}
string CountryNameGetter::operator()(TCountryId const & countryId) const
{
string const name = Get(countryId);
if (name.empty())
return countryId;
return name;
}
string CountryNameGetter::GetLocale() const
{
if (m_getCurLang == nullptr)
return string();
return m_getCurLang->GetLocale();
}
} // namespace storage