Welcome to mirror list, hosted at ThFree Co, Russian Federation.

country_name_getter.cpp « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 88a54e5d6733a7ef1044ae03e41468dd52a0b2e2 (plain)
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