{"action":"created","comment":{"url":"https://api.github.com/repos/mapsme/omim/pulls/comments/214947438","pull_request_review_id":152102702,"id":214947438,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDk0NzQzOA==","diff_hunk":"@@ -68,16 +67,103 @@ class RegionInfoCollector\n   // It is supposed to be called already on the filtered osm objects that represent regions.\n   void Add(OsmElement const & el);\n   // osmId is osm relation id.\n-  RegionData & Get(uint64_t osmId);\n-  const RegionData & Get(uint64_t osmId) const;\n-  bool Exists(uint64_t osmId) const;\n+  RegionDataProxy Get(uint64_t osmId) const;\n   void Save(std::string const & filename);\n \n private:\n+  friend class RegionDataProxy;\n+\n+  // https://en.wikipedia.org/wiki/ISO_3166-1\n+  struct IsoCode\n+  {\n+    bool HasAlpha2() const { return m_alpha2[0] != '\\0'; }\n+    bool HasAlpha3() const { return m_alpha3[0] != '\\0'; }\n+    bool HasNumeric() const { return m_numeric[0] != '\\0'; }\n+\n+    void SetAlpha2(std::string const & alpha2);\n+    void SetAlpha3(std::string const & alpha3);\n+    void SetNumeric(std::string const & numeric);\n+\n+    std::string GetAlpha2() const { return m_alpha2; }\n+    std::string GetAlpha3() const { return m_alpha3; }\n+    std::string GetNumeric() const { return m_numeric; }\n+\n+    uint64_t m_osmId = 0;\n+    char m_alpha2[3] = {};\n+    char m_alpha3[4] = {};\n+    char m_numeric[4] = {};\n+  };\n+\n+  struct RegionData\n+  {\n+    uint64_t m_osmId = 0;\n+    AdminLevel m_adminLevel = AdminLevel::Unknown;\n+    PlaceType m_place = PlaceType::Unknown;\n+  };\n+\n+  using MapRegionData = std::unordered_map<uint64_t, RegionData>;\n+  using MapIsoCode = std::unordered_map<uint64_t, IsoCode>;\n+\n+  template <typename Source, typename Map>\n+  void ReadMap(Source & src, Map & seq)\n+  {\n+    uint32_t size = 0;\n+    ReadPrimitiveFromSource(src, size);\n+    typename Map::mapped_type data;\n+    for (uint32_t i = 0; i < size; ++i)\n+    {\n+      ReadPrimitiveFromSource(src, data);\n+      seq.emplace(data.m_osmId, std::move(data));\n+    }\n+  }\n+\n+  template <typename Sink, typename Map>\n+  void WriteMap(Sink & sink, Map & seq)\n+  {\n+    static_assert(std::is_trivially_copyable<typename Map::mapped_type>::value, \"\");\n+\n+    uint32_t const sizeRegionData = static_cast<uint32_t>(seq.size());\n+    WriteToSink(sink, sizeRegionData);\n+    for (auto const & el : seq)\n+      sink.Write(&el.second, sizeof(el.second));\n+  }\n+\n   void ParseFile(std::string const & filename);\n-  void Fill(OsmElement const & el, RegionData & rd);\n+  void FillRegionData(OsmElement const & el, RegionData & rd);\n+  void FillIsoCode(OsmElement const & el, IsoCode & rd);\n+\n+  MapRegionData m_mapRegionData;\n+  MapIsoCode m_mapIsoCode;\n+};\n+\n+class RegionDataProxy\n+{\n+public:\n+  RegionDataProxy(RegionInfoCollector const & regionInfoCollector, uint64_t osmId);\n+\n+  uint64_t GetOsmId() const;\n+  AdminLevel GetAdminLevel() const;\n+  PlaceType GetPlaceType() const;\n+\n+  bool HasAdminLevel() const;\n+  bool HasPlaceType() const;\n+\n+  bool HasIsoCodeAlpha2() const;\n+  bool HasIsoCodeAlpha3() const;\n+  bool HasIsoCodeAlphaNumeric() const;\n+\n+  std::string GetIsoCodeAlpha2() const;\n+  std::string GetIsoCodeAlpha3() const;\n+  std::string GetIsoCodeAlphaNumeric() const;\n+\n+private:\n+  bool HasIsoCode() const;\n+  RegionInfoCollector const & Collector() const;","path":"generator/region_info_collector.hpp","position":127,"original_position":127,"commit_id":"29d4e30fc40edb8c7cb1bc4f0ecf8c7dcec688cd","original_commit_id":"29d4e30fc40edb8c7cb1bc4f0ecf8c7dcec688cd","user":{"login":"mpimenov","id":10366009,"node_id":"MDQ6VXNlcjEwMzY2MDA5","avatar_url":"https://avatars0.githubusercontent.com/u/10366009?v=4","gravatar_id":"","url":"https://api.github.com/users/mpimenov","html_url":"https://github.com/mpimenov","followers_url":"https://api.github.com/users/mpimenov/followers","following_url":"https://api.github.com/users/mpimenov/following{/other_user}","gists_url":"https://api.github.com/users/mpimenov/gists{/gist_id}","starred_url":"https://api.github.com/users/mpimenov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpimenov/subscriptions","organizations_url":"https://api.github.com/users/mpimenov/orgs","repos_url":"https://api.github.com/users/mpimenov/repos","events_url":"https://api.github.com/users/mpimenov/events{/privacy}","received_events_url":"https://api.github.com/users/mpimenov/received_events","type":"User","site_admin":false},"body":"GetCollector?","created_at":"2018-09-04T14:53:58Z","updated_at":"2018-09-04T14:55:32Z","html_url":"https://github.com/mapsme/omim/pull/9393#discussion_r214947438","pull_request_url":"https://api.github.com/repos/mapsme/omim/pulls/9393","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments/214947438"},"html":{"href":"https://github.com/mapsme/omim/pull/9393#discussion_r214947438"},"pull_request":{"href":"https://api.github.com/repos/mapsme/omim/pulls/9393"}}},"pull_request":{"url":"https://api.github.com/repos/mapsme/omim/pulls/9393","id":212926449,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyOTI2NDQ5","html_url":"https://github.com/mapsme/omim/pull/9393","diff_url":"https://github.com/mapsme/omim/pull/9393.diff","patch_url":"https://github.com/mapsme/omim/pull/9393.patch","issue_url":"https://api.github.com/repos/mapsme/omim/issues/9393","number":9393,"state":"open","locked":false,"title":"[generator] Added iso3166-1 codes","user":{"login":"maksimandrianov","id":12376740,"node_id":"MDQ6VXNlcjEyMzc2NzQw","avatar_url":"https://avatars3.githubusercontent.com/u/12376740?v=4","gravatar_id":"","url":"https://api.github.com/users/maksimandrianov","html_url":"https://github.com/maksimandrianov","followers_url":"https://api.github.com/users/maksimandrianov/followers","following_url":"https://api.github.com/users/maksimandrianov/following{/other_user}","gists_url":"https://api.github.com/users/maksimandrianov/gists{/gist_id}","starred_url":"https://api.github.com/users/maksimandrianov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maksimandrianov/subscriptions","organizations_url":"https://api.github.com/users/maksimandrianov/orgs","repos_url":"https://api.github.com/users/maksimandrianov/repos","events_url":"https://api.github.com/users/maksimandrianov/events{/privacy}","received_events_url":"https://api.github.com/users/maksimandrianov/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-09-04T10:22:16Z","updated_at":"2018-09-04T14:55:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f4477ca90f00faca0bfc0a61a0a3666afddc15da","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mapsme/omim/pulls/9393/commits","review_comments_url":"https://api.github.com/repos/mapsme/omim/pulls/9393/comments","review_comment_url":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mapsme/omim/issues/9393/comments","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/29d4e30fc40edb8c7cb1bc4f0ecf8c7dcec688cd","head":{"label":"maksimandrianov:region_kv","ref":"region_kv","sha":"29d4e30fc40edb8c7cb1bc4f0ecf8c7dcec688cd","user":{"login":"maksimandrianov","id":12376740,"node_id":"MDQ6VXNlcjEyMzc2NzQw","avatar_url":"https://avatars3.githubusercontent.com/u/12376740?v=4","gravatar_id":"","url":"https://api.github.com/users/maksimandrianov","html_url":"https://github.com/maksimandrianov","followers_url":"https://api.github.com/users/maksimandrianov/followers","following_url":"https://api.github.com/users/maksimandrianov/following{/other_user}","gists_url":"https://api.github.com/users/maksimandrianov/gists{/gist_id}","starred_url":"https://api.github.com/users/maksimandrianov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maksimandrianov/subscriptions","organizations_url":"https://api.github.com/users/maksimandrianov/orgs","repos_url":"https://api.github.com/users/maksimandrianov/repos","events_url":"https://api.github.com/users/maksimandrianov/events{/privacy}","received_events_url":"https://api.github.com/users/maksimandrianov/received_events","type":"User","site_admin":false},"repo":{"id":133388788,"node_id":"MDEwOlJlcG9zaXRvcnkxMzMzODg3ODg=","name":"omim","full_name":"maksimandrianov/omim","owner":{"login":"maksimandrianov","id":12376740,"node_id":"MDQ6VXNlcjEyMzc2NzQw","avatar_url":"https://avatars3.githubusercontent.com/u/12376740?v=4","gravatar_id":"","url":"https://api.github.com/users/maksimandrianov","html_url":"https://github.com/maksimandrianov","followers_url":"https://api.github.com/users/maksimandrianov/followers","following_url":"https://api.github.com/users/maksimandrianov/following{/other_user}","gists_url":"https://api.github.com/users/maksimandrianov/gists{/gist_id}","starred_url":"https://api.github.com/users/maksimandrianov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maksimandrianov/subscriptions","organizations_url":"https://api.github.com/users/maksimandrianov/orgs","repos_url":"https://api.github.com/users/maksimandrianov/repos","events_url":"https://api.github.com/users/maksimandrianov/events{/privacy}","received_events_url":"https://api.github.com/users/maksimandrianov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/maksimandrianov/omim","description":"🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android","fork":true,"url":"https://api.github.com/repos/maksimandrianov/omim","forks_url":"https://api.github.com/repos/maksimandrianov/omim/forks","keys_url":"https://api.github.com/repos/maksimandrianov/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/maksimandrianov/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/maksimandrianov/omim/teams","hooks_url":"https://api.github.com/repos/maksimandrianov/omim/hooks","issue_events_url":"https://api.github.com/repos/maksimandrianov/omim/issues/events{/number}","events_url":"https://api.github.com/repos/maksimandrianov/omim/events","assignees_url":"https://api.github.com/repos/maksimandrianov/omim/assignees{/user}","branches_url":"https://api.github.com/repos/maksimandrianov/omim/branches{/branch}","tags_url":"https://api.github.com/repos/maksimandrianov/omim/tags","blobs_url":"https://api.github.com/repos/maksimandrianov/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/maksimandrianov/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/maksimandrianov/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/maksimandrianov/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/maksimandrianov/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/maksimandrianov/omim/languages","stargazers_url":"https://api.github.com/repos/maksimandrianov/omim/stargazers","contributors_url":"https://api.github.com/repos/maksimandrianov/omim/contributors","subscribers_url":"https://api.github.com/repos/maksimandrianov/omim/subscribers","subscription_url":"https://api.github.com/repos/maksimandrianov/omim/subscription","commits_url":"https://api.github.com/repos/maksimandrianov/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/maksimandrianov/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/maksimandrianov/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/maksimandrianov/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/maksimandrianov/omim/contents/{+path}","compare_url":"https://api.github.com/repos/maksimandrianov/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/maksimandrianov/omim/merges","archive_url":"https://api.github.com/repos/maksimandrianov/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/maksimandrianov/omim/downloads","issues_url":"https://api.github.com/repos/maksimandrianov/omim/issues{/number}","pulls_url":"https://api.github.com/repos/maksimandrianov/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/maksimandrianov/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/maksimandrianov/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/maksimandrianov/omim/labels{/name}","releases_url":"https://api.github.com/repos/maksimandrianov/omim/releases{/id}","deployments_url":"https://api.github.com/repos/maksimandrianov/omim/deployments","created_at":"2018-05-14T16:11:26Z","updated_at":"2018-08-21T14:07:39Z","pushed_at":"2018-09-04T14:03:56Z","git_url":"git://github.com/maksimandrianov/omim.git","ssh_url":"git@github.com:maksimandrianov/omim.git","clone_url":"https://github.com/maksimandrianov/omim.git","svn_url":"https://github.com/maksimandrianov/omim","homepage":"","size":4023498,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"mapsme:master","ref":"master","sha":"b3a19363e3d99920663ee716db931fa4c3da1981","user":{"login":"mapsme","id":14185141,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTg1MTQx","avatar_url":"https://avatars1.githubusercontent.com/u/14185141?v=4","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"repo":{"id":42798033,"node_id":"MDEwOlJlcG9zaXRvcnk0Mjc5ODAzMw==","name":"omim","full_name":"mapsme/omim","owner":{"login":"mapsme","id":14185141,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MTg1MTQx","avatar_url":"https://avatars1.githubusercontent.com/u/14185141?v=4","gravatar_id":"","url":"https://api.github.com/users/mapsme","html_url":"https://github.com/mapsme","followers_url":"https://api.github.com/users/mapsme/followers","following_url":"https://api.github.com/users/mapsme/following{/other_user}","gists_url":"https://api.github.com/users/mapsme/gists{/gist_id}","starred_url":"https://api.github.com/users/mapsme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mapsme/subscriptions","organizations_url":"https://api.github.com/users/mapsme/orgs","repos_url":"https://api.github.com/users/mapsme/repos","events_url":"https://api.github.com/users/mapsme/events{/privacy}","received_events_url":"https://api.github.com/users/mapsme/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mapsme/omim","description":"🗺️ MAPS.ME — Offline OpenStreetMap maps for iOS and Android","fork":false,"url":"https://api.github.com/repos/mapsme/omim","forks_url":"https://api.github.com/repos/mapsme/omim/forks","keys_url":"https://api.github.com/repos/mapsme/omim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mapsme/omim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mapsme/omim/teams","hooks_url":"https://api.github.com/repos/mapsme/omim/hooks","issue_events_url":"https://api.github.com/repos/mapsme/omim/issues/events{/number}","events_url":"https://api.github.com/repos/mapsme/omim/events","assignees_url":"https://api.github.com/repos/mapsme/omim/assignees{/user}","branches_url":"https://api.github.com/repos/mapsme/omim/branches{/branch}","tags_url":"https://api.github.com/repos/mapsme/omim/tags","blobs_url":"https://api.github.com/repos/mapsme/omim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mapsme/omim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mapsme/omim/git/refs{/sha}","trees_url":"https://api.github.com/repos/mapsme/omim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mapsme/omim/statuses/{sha}","languages_url":"https://api.github.com/repos/mapsme/omim/languages","stargazers_url":"https://api.github.com/repos/mapsme/omim/stargazers","contributors_url":"https://api.github.com/repos/mapsme/omim/contributors","subscribers_url":"https://api.github.com/repos/mapsme/omim/subscribers","subscription_url":"https://api.github.com/repos/mapsme/omim/subscription","commits_url":"https://api.github.com/repos/mapsme/omim/commits{/sha}","git_commits_url":"https://api.github.com/repos/mapsme/omim/git/commits{/sha}","comments_url":"https://api.github.com/repos/mapsme/omim/comments{/number}","issue_comment_url":"https://api.github.com/repos/mapsme/omim/issues/comments{/number}","contents_url":"https://api.github.com/repos/mapsme/omim/contents/{+path}","compare_url":"https://api.github.com/repos/mapsme/omim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mapsme/omim/merges","archive_url":"https://api.github.com/repos/mapsme/omim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mapsme/omim/downloads","issues_url":"https://api.github.com/repos/mapsme/omim/issues{/number}","pulls_url":"https://api.github.com/repos/mapsme/omim/pulls{/number}","milestones_url":"https://api.github.com/repos/mapsme/omim/milestones{/number}","notifications_url":"https://api.github.com/repos/mapsme/omim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mapsme/omim/labels{/name}","releases_url":"https://api.github.com/repos/mapsme/omim/releases{/id}","deployments_url":"https://api.github.com/repos/mapsme/omim/deployments","created_at":"2015-09-20T02:57:13Z","updated_at":"2018-09-04T12:57:47Z","pushed_at":"2018-09-04T14:51:37Z","git_url":"git://github.com/mapsme/omim.git","ssh_url":"git@github.com:mapsme/omim.git","clone_url":"https://github.com/mapsme/omim.git","svn_url":"https://github.com/mapsme/omim","homepage":"","size":4055536,"stargazers_count":2768,"watchers_count":2768,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":598,"mirror_url":null,"archived":false,"open_issues_count":732,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":598,"open_issues":732,"watchers":2768,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mapsme/omim/pulls/9393"},"html":{"href":"https://github.com/mapsme/omim/pull/9393"},"issue":{"href":"https://api.github.com/repos/mapsme/omim/issues/9393"},"comments":{"href":"https://api.github.com/repos/mapsme/omim/issues/9393/comments"},"review_comments":{"href":"https://api.github.com/repos/mapsme/omim/pulls/9393/comments"},"review_comment":{"href":"https://api.github.com/repos/mapsme/omim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mapsme/omim/pulls/9393/commits"},"statuses":{"href":"https://api.github.com/repos/mapsme/omim/statuses/29d4e30fc40edb8c7cb1bc4f0ecf8c7dcec688cd"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"mpimenov"}}