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

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

#include "base/macros.hpp"
#include "base/assert.hpp"

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


namespace strings { class UniString; }

namespace feature
{
  static int const g_arrWorldScales[] = { 3, 5, 7, 9 };    // 9 = scales::GetUpperWorldScale()
  static int const g_arrCountryScales[] = { 10, 12, 14, 17 };  // 17 = scales::GetUpperScale()

  inline string GetTagForIndex(char const * prefix, size_t ind)
  {
    string str;
    str.reserve(strlen(prefix) + 1);
    str = prefix;

    static char const arrChar[] = { '0', '1', '2', '3' };
    static_assert(ARRAY_SIZE(arrChar) >= ARRAY_SIZE(g_arrWorldScales), "");
    static_assert(ARRAY_SIZE(arrChar) >= ARRAY_SIZE(g_arrCountryScales), "");
    ASSERT(ind >= 0 && ind < ARRAY_SIZE(arrChar), (ind));

    str += arrChar[ind];
    return str;
  }

  bool IsDigit(int c);
  bool IsNumber(strings::UniString const & s);

  bool IsHouseNumber(string const & s);
  bool IsHouseNumber(strings::UniString const & s);
  bool IsHouseNumberDeepCheck(strings::UniString const & s);

  uint8_t PopulationToRank(uint64_t p);
  uint64_t RankToPopulation(uint8_t r);
} // namespace feature