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

country_name_getter.hpp « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2329afbff831d5796269ae8452081b09f9622d89 (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
#pragma once

#include "storage/index.hpp"

#include "platform/get_text_by_id.hpp"

#include "std/string.hpp"
#include "std/unique_ptr.hpp"

namespace storage
{

/// CountryNameGetter is responsible for generating text name for TCountryId in a specified locale
/// To get this country name use operator().
/// If the country caption is not available for specified locale, class tries to find it in
/// English locale.
class CountryNameGetter
{
public:
  /// @return current locale. For example "en", "ru", "zh-Hant" and so on.
  /// \note The method returns correct locale after SetLocale has been called.
  /// If not, it returns an empty string.
  string GetLocale() const;

  /// \brief Sets a locale.
  /// @param locale is a string representation of locale. For example "en", "ru", "zh-Hant" and so on.
  /// \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
  void SetLocaleForTesting(string const & jsonBuffer, string const & locale);

private:
  unique_ptr<platform::GetTextById> m_getCurLang;
};

}  // namespace storage